Skip to content
Snippets Groups Projects
Commit 5b1c50b7 authored by philip.roeggla's avatar philip.roeggla
Browse files

click.File needs to be initialised (and reformatting)

parent dd5128a3
No related branches found
No related tags found
No related merge requests found
...@@ -12,16 +12,23 @@ from travelogues_extraction.controller.main import FromAlmaOutputToExcel ...@@ -12,16 +12,23 @@ from travelogues_extraction.controller.main import FromAlmaOutputToExcel
@click.command() @click.command()
@click.option('--input-file', help='Use .xlsx file as input', type=click.File) @click.option('--input-file', help='Use .xlsx file as input', type=click.File())
@click.option('--ac-column', type=click.STRING, help= @click.option('--ac-column', type=click.STRING, help=
'The column of the input file, where the ac numbers are. The column name is the string in the first row of the column', 'The column of the input file, where the ac numbers are. The column name is the string in the first row of the column',
) )
@click.option('--start', default=0, type=click.INT, help='The first record of the input file to extract the data') @click.option('--start', default=0, type=click.INT, help='The first record of the input file to extract the data')
@click.option('--stop', default=None, type=click.INT, help='The last record of the input file to extract the data') @click.option('--stop', default=None, type=click.INT, help='The last record of the input file to extract the data')
@click.option('--output-file', help='Generate this .xlsx file', type=click.File) @click.option('--output-file', help='Generate this .xlsx file', type=click.File())
@click.option('--log-file', default=None, help='If given, write a csv log that that file', type=click.File) @click.option('--log-file', default=None, help='If given, write a csv log that that file', type=click.File())
@click.option('--deep-log-file', default=None, help='If given, write a deep json log that that file', type=click.File) @click.option('--deep-log-file', default=None, help='If given, write a deep json log that that file', type=click.File())
def extract_data(input_file: str, output_file: str, ac_column: str, start: typing.Optional[int] = 0, stop: typing.Optional[int]=None, log_file: typing.Optional[str]=None, deep_log_file: typing.Optional[str]=None): def extract_data(input_file: str,
output_file: str,
ac_column: str,
start: typing.Optional[int] = 0,
stop: typing.Optional[int] = None,
log_file: typing.Optional[str] = None,
deep_log_file: typing.Optional[str] = None
):
""" """
Takes an excel file with a column of ac numbers, gets data from alma, brings the data in excel like shape, and generates an excel file with this data Takes an excel file with a column of ac numbers, gets data from alma, brings the data in excel like shape, and generates an excel file with this data
""" """
...@@ -30,7 +37,9 @@ def extract_data(input_file: str, output_file: str, ac_column: str, start: typin ...@@ -30,7 +37,9 @@ def extract_data(input_file: str, output_file: str, ac_column: str, start: typin
loop.run_until_complete(_extract_data(input_file, output_file, ac_column, start, stop, log_file, deep_log_file)) loop.run_until_complete(_extract_data(input_file, output_file, ac_column, start, stop, log_file, deep_log_file))
async def _extract_data(input_file: str, output_file: str, ac_column: str, start: typing.Optional[int] = 0, stop: typing.Optional[int]=None, log_file: typing.Optional[str]=None, deep_log_file: typing.Optional[str]=None) -> typing.NoReturn: async def _extract_data(input_file: str, output_file: str, ac_column: str, start: typing.Optional[int] = 0,
stop: typing.Optional[int] = None, log_file: typing.Optional[str] = None,
deep_log_file: typing.Optional[str] = None) -> typing.NoReturn:
input_file = pathlib.Path(input_file) input_file = pathlib.Path(input_file)
output_path = pathlib.Path(output_file) output_path = pathlib.Path(output_file)
...@@ -47,5 +56,6 @@ async def _extract_data(input_file: str, output_file: str, ac_column: str, start ...@@ -47,5 +56,6 @@ async def _extract_data(input_file: str, output_file: str, ac_column: str, start
with open(deep_log_file, 'w') as file: with open(deep_log_file, 'w') as file:
json.dump(converter.sub_log, file) json.dump(converter.sub_log, file)
if __name__ == '__main__': if __name__ == '__main__':
extract_data() extract_data()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment