Move get_filenames to auxillary and generalise
This commit is contained in:
parent
a49fc8b0d2
commit
0d757ce365
1 changed files with 15 additions and 1 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
import json
|
import json
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import os
|
||||||
|
|
||||||
def update_options(options, required_options, default_options):
|
def update_options(options, required_options, default_options):
|
||||||
''' Takes a dictionary of options along with a list of required options and dictionary of default options, and sets all keyval-pairs of options that is not already defined to the default values'''
|
''' Takes a dictionary of options along with a list of required options and dictionary of default options, and sets all keyval-pairs of options that is not already defined to the default values'''
|
||||||
|
|
@ -71,4 +72,17 @@ def write_log(message, options={}):
|
||||||
|
|
||||||
|
|
||||||
with open(options['logfile'], 'a') as f:
|
with open(options['logfile'], 'a') as f:
|
||||||
f.write(message)
|
f.write(message)
|
||||||
|
|
||||||
|
|
||||||
|
#Function that "collects" all the files in a folder, only accepting .dat-files from xanes-measurements
|
||||||
|
def get_filenames(path, ext):
|
||||||
|
''' Collects all filenames from specified path with a specificed extension
|
||||||
|
|
||||||
|
Input:
|
||||||
|
path: path to find all filenames (relative or absolute)
|
||||||
|
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)]
|
||||||
|
|
||||||
|
return filenames
|
||||||
Loading…
Add table
Add a link
Reference in a new issue