glob path code example
Example 1: python glob
import glob
print 'Named explicitly:'
for name in glob.glob('dir/subdir/*'):
print '\t', name
print 'Named with wildcard:'
for name in glob.glob('dir/*/*'):
print '\t', name
Example 2: python import filenames that match search
glob.glob('/directory/to/search/search_pattern')
/directory/file.png
/directory/file1.txt
/directory/file2.txt
/directory/file3.png
glob.glob('/directory/*png')
--> ['/directory/file.png', '/directory/filea.png']
files = glob.glob('/directory/*png')
filenames = [files[i].split('/')[-1] for i in range(len(files))]
print(filenames)
--> ['file.png', 'filea.png']
Example 3: python glob subdirectories
import glob
subdirectories = glob.glob("./*/")
Example 4: Files.Glob
apiVersion: v1
kind: ConfigMap
metadata:
name: conf
data:
{{ (.Files.Glob "foo/*").AsConfig | indent 2 }}
---
apiVersion: v1
kind: Secret
metadata:
name: very-secret
type: Opaque
data:
{{ (.Files.Glob "bar/*").AsSecrets | indent 2 }}