-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathteal_deer.py
43 lines (35 loc) · 1.18 KB
/
teal_deer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import glob
import argparse
import json
def get_file_list(path, file_type='pdf'):
"""
Gets a list of files of the directory of pdfs.
:param path: Directory path
:param file_type: Type of file to be imported.
:return: List of files.
"""
path += ('*.' + file_type)
return glob.glob(path)
def parse_args():
"""
Returns arguments passed at the command line as a dict
"""
parser = argparse.ArgumentParser(description='Generates a machine Learning Dataset.')
parser.add_argument('-c', help="Config File Location", required=True,
dest='config')
args = vars(parser.parse_args())
return args
def load_config(config_name):
"""
loads a json config file and returns a config dictionary
"""
with open(config_name) as config_file:
config = json.load(config_file)
return config
def replace_file_type_in_file_name(file_path, input_type='pdf', output_type='txt'):
"""
Replace one file type with another in the specified file name.
:param file_path: Starting file path.
:return: File name with replacement type.
"""
return file_path.replace('.' + input_type, '.' + output_type)