-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtransformer_class.py
37 lines (32 loc) · 1.23 KB
/
transformer_class.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
"""Class instance for BETYdb CSV file upload transformer
"""
import argparse
class Transformer():
"""Generic class for supporting transformers
"""
def __init__(self, **kwargs):
"""Performs initialization of class instance
Arguments:
kwargs: additional parameters passed into Transformer instance
"""
# pylint: disable=unused-argument
self.args = None
def get_transformer_params(self, args: argparse.Namespace, metadata: list) -> dict:
"""Returns a parameter list for processing data
Arguments:
args: result of calling argparse.parse_args
metadata: the list of loaded metadata
Return:
A dictionary of parameter names and value to pass to transformer
"""
# pylint: disable=unused-argument
self.args = args
# Get the list of files, if there are some
file_list = []
if args.file_list:
for one_file in args.file_list:
# Filter out arguments that are obviously not files
if not one_file.startswith('-'):
file_list.append(one_file)
params = {'check_md': {'list_files': lambda: file_list}}
return params