Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Added directory/wildcard support #4

Merged
merged 1 commit into from
Dec 13, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 16 additions & 5 deletions squeezeit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,23 @@ def loadfiles(configfile, config, srcdir, files):

for file in files:
try:
if '*' in file:
file, suffix = file.split('*')
filepath = os.path.join(srcdir,file)
f = open(filepath)
filedata = f.read()
f.close()

rawdata.append(filedata)
if os.path.isdir(filepath):
for (dirpath,dirnames,filenames) in os.walk(filepath):
for filename in filenames:
if suffix and not filename.endswith(suffix):
continue
f = open(os.path.join(dirpath,filename))
filedata = f.read()
f.close()
rawdata.append(filedata)
else:
f = open(filepath)
filedata = f.read()
f.close()
rawdata.append(filedata)
except:
logging.warning("Could not read {0}". format(filepath))

Expand Down