diff options
-rw-r--r-- | deal-converter.py | 6 | ||||
-rw-r--r-- | dealconvert/formats/html.py | 11 |
2 files changed, 11 insertions, 6 deletions
diff --git a/deal-converter.py b/deal-converter.py index 7e5e91d..43345cb 100644 --- a/deal-converter.py +++ b/deal-converter.py @@ -15,6 +15,8 @@ parser = argparse.ArgumentParser( 'To print deals to HTML file, use *.html output file.\n') parser.add_argument('--jfr', action='store_true', help='For PBN file, write only JFR DD fields') +parser.add_argument('--columns', type=int, default=None, + help='For HTML files, print-out column count') parser.add_argument('input', metavar='INPUT_FILE', help='Input file path') parser.add_argument('output', metavar='OUTPUT_FILE', nargs='*', @@ -27,7 +29,9 @@ def _warning(msg, *args, **kwargs): warnings.showwarning = _warning try: - converter = DealConverter(arguments.input, jfr_only=arguments.jfr) + converter = DealConverter( + arguments.input, + jfr_only=arguments.jfr, columns=arguments.columns) converter.output(arguments.output) except RuntimeError as e: print('ERROR: %s' % (str(e)), file=sys.stderr) diff --git a/dealconvert/formats/html.py b/dealconvert/formats/html.py index e39bae4..a60b3a3 100644 --- a/dealconvert/formats/html.py +++ b/dealconvert/formats/html.py @@ -18,8 +18,6 @@ HTML_SUITS = OrderedDict([ ('c', u'\u2663') ]) -_deals_per_column = 6 - _page_template = ''' <html> <head> @@ -82,6 +80,9 @@ class HTMLFormat(DealFormat): def suffix(self): return '.html' + def __init__(self, *args, **kwargs): + self.deals_per_column = kwargs.get('columns', 6) + def parse_content(self, content): raise NotImplementedError @@ -185,8 +186,8 @@ class HTMLFormat(DealFormat): deal_rows = [] event_name = dealset[0].event while len(dealset) > 0: - deal_rows.append(dealset[0:_deals_per_column]) - dealset = dealset[_deals_per_column:] + deal_rows.append(dealset[0:self.deals_per_column]) + dealset = dealset[self.deals_per_column:] table_content = '' for row in deal_rows: table_content += '<tr>' @@ -220,7 +221,7 @@ class HTMLFormat(DealFormat): table_content += '</td>' table_content += '</tr>' return _page_template % ( - _deals_per_column - 1, event_name, table_content + self.deals_per_column - 1, event_name, table_content ) def output_content(self, out_file, dealset): |