Add filter
This commit is contained in:
parent
0d757ce365
commit
303704c357
1 changed files with 3 additions and 3 deletions
|
|
@ -68,7 +68,7 @@ def write_log(message, options={}):
|
||||||
options = update_options(options=options, required_options=required_options, default_options=default_options)
|
options = update_options(options=options, required_options=required_options, default_options=default_options)
|
||||||
|
|
||||||
now = datetime.now().strftime('%Y/%m/%d %H:%M:%S')
|
now = datetime.now().strftime('%Y/%m/%d %H:%M:%S')
|
||||||
message = f'{now} {message} \n'
|
message = f'[{now}] {message} \n'
|
||||||
|
|
||||||
|
|
||||||
with open(options['logfile'], 'a') as f:
|
with open(options['logfile'], 'a') as f:
|
||||||
|
|
@ -76,13 +76,13 @@ def write_log(message, options={}):
|
||||||
|
|
||||||
|
|
||||||
#Function that "collects" all the files in a folder, only accepting .dat-files from xanes-measurements
|
#Function that "collects" all the files in a folder, only accepting .dat-files from xanes-measurements
|
||||||
def get_filenames(path, ext):
|
def get_filenames(path, ext, filter=''):
|
||||||
''' Collects all filenames from specified path with a specificed extension
|
''' Collects all filenames from specified path with a specificed extension
|
||||||
|
|
||||||
Input:
|
Input:
|
||||||
path: path to find all filenames (relative or absolute)
|
path: path to find all filenames (relative or absolute)
|
||||||
ext: extension (including ".")'''
|
ext: extension (including ".")'''
|
||||||
|
|
||||||
filenames = [os.path.join(path, filename) for filename in os.listdir(path) if os.path.isfile(os.path.join(path, filename)) and filename.endswith(ext)]
|
filenames = [os.path.join(path, filename) for filename in os.listdir(path) if os.path.isfile(os.path.join(path, filename)) and filename.endswith(ext) and filter in filename]
|
||||||
|
|
||||||
return filenames
|
return filenames
|
||||||
Loading…
Add table
Add a link
Reference in a new issue