Commit 71bcebff authored by Hans van den Heuvel's avatar Hans van den Heuvel
Browse files

Keeping DTUCAG in line with ProcessingFactors dir

parent f0f08a46
......@@ -7,7 +7,7 @@ __version__ = '.'.join(__version_info__)
# Phase 0. Initialization
# Doing stuff like parsing arguments, and reading the files.
#
import dataconversion
from dataconversion import DataSet, PY_INDENT, thisyear
import pandas as pd
from datetime import datetime
import textwrap
......@@ -20,8 +20,8 @@ def print_as_link(text):
# These are the files we work with
# Create list
dataset = dataconversion.DataSet(
opening='(c) ' + datetime.now().strftime('%Y')
dataset = DataSet(
opening='(c) ' + thisyear
+ ' Biometris, Wageningen University and Research.',
description='Converts the EFSA CAPEG database Excel sheet into MCRA '
+ 'effects and assessment groups.',
......@@ -213,4 +213,4 @@ dataset.agm.sheet = capeg[agm_header].drop_duplicates()
dataset.agm.sheet.mcra.keepcolumn(agm_header)
# DONE
dataset.close(file_report=True, version = __version__)
dataset.close(file_report=True)
......@@ -17,7 +17,7 @@ import textwrap
import getpass
import re
__version_info__ = ('0', '9', '1')
__version_info__ = ('0', '9', '2')
__version__ = '.'.join(__version_info__)
# For debugging purposes
......@@ -388,6 +388,7 @@ class DataSet:
self.runtime = datetime.now().strftime('%H:%M:%S, %d %b %Y')
self.runcommand = ' '.join(sys.argv)
self.runarguments = ' '.join(sys.argv[1:])
self.usedarguments = None
self.scriptname = os.path.split(sys.argv[0])[1]
md5_hash = hashlib.md5()
with open(sys.argv[0], "rb") as f:
......@@ -418,8 +419,10 @@ class DataSet:
# self.parser.add_argument(
# '-x', '--example', action='store_const', const='Example',
# help='Uses input files from the %(const)s subdir.')
if not version:
version = __version__
if version:
self.version = version
else:
self.version = __version__
zip = f'Build\\{self.scriptnoun}.{version}.zip'
self.parser.add_argument(
'-z', '--zip', nargs='?', const=zip, default=zip,
......@@ -495,6 +498,7 @@ class DataSet:
def init(self):
# Initializes the command line parameters
self.args = self.parser.parse_args()
self.usedarguments = self.args.__dict__
for datasetname in self.list:
dataset = getattr(self, datasetname)
......@@ -502,6 +506,7 @@ class DataSet:
datasetfilename = dataset.file.default_name
else:
datasetfilename = getattr(self.args, datasetname+'_file')
self.usedarguments[datasetname+'_file'] = datasetfilename
if dataset.direction == 'Input':
dataset.file.suggest(
......@@ -569,7 +574,7 @@ class DataSet:
if not data.closed:
data.close(auto_report=False, also_save=True)
def close(self, file_report=False, save=True, version = False):
def close(self, file_report=False, save=True):
'''
Method to close the dataset.
Most importantly save files.
......@@ -582,16 +587,24 @@ class DataSet:
report_content += textwrap.indent(
f'* Filename: {self.scriptname}\n', PY_INDENT)
report_content += textwrap.indent(
f'* Arguments: {self.runarguments}\n', PY_INDENT)
f'* Command line Arguments: {self.runarguments}\n', PY_INDENT)
report_content += textwrap.indent(
'* Arguments executed:\n', PY_INDENT)
for key, value in self.usedarguments.items():
if value is None:
report_content += textwrap.indent(
f'* --{key}\n', 2*PY_INDENT)
else:
report_content += textwrap.indent(
f'* --{key} {value}\n', 2*PY_INDENT)
report_content += textwrap.indent(
f'* Hash: {self.scripthash}\n', PY_INDENT)
report_content += textwrap.indent(
f'* Executed at: {self.runtime}\n', PY_INDENT)
report_content += textwrap.indent(
f'* Executed by: {self.runuser}\n', PY_INDENT)
if version:
report_content += textwrap.indent(
f'* Version: {version}\n', PY_INDENT)
report_content += textwrap.indent(
f'* Version: {self.version}\n', PY_INDENT)
report_content += textwrap.indent(
f'* Depends upon module: {__name__}\n', PY_INDENT)
report_content += textwrap.indent(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment