summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jfr_playoff/logger.py15
-rw-r--r--jfr_playoff/matchinfo.py5
-rw-r--r--playoff.py9
3 files changed, 25 insertions, 4 deletions
diff --git a/jfr_playoff/logger.py b/jfr_playoff/logger.py
new file mode 100644
index 0000000..8944e5b
--- /dev/null
+++ b/jfr_playoff/logger.py
@@ -0,0 +1,15 @@
+import logging as log
+
+
+class PlayoffLogger:
+
+ @classmethod
+ def setup(cls, level):
+ log.basicConfig(
+ level=getattr(log, level),
+ streamhandler=log.StreamHandler(),
+ format='%(levelname)-8s %(name)-8s %(message)s')
+
+ @classmethod
+ def get(cls, category=''):
+ return log.getLogger(category)
diff --git a/jfr_playoff/matchinfo.py b/jfr_playoff/matchinfo.py
index f65c23c..997e685 100644
--- a/jfr_playoff/matchinfo.py
+++ b/jfr_playoff/matchinfo.py
@@ -180,9 +180,6 @@ class MatchInfo:
def __has_towel_image(self, cell):
return len(cell.select('img[alt="towel"]')) > 0
- def __has_running_board_count(self, cell):
- return len(cell.select('img[alt="running..."]')) > 0
-
def __get_html_running_boards(self, cell):
return int(cell.contents[-1].strip())
@@ -218,7 +215,7 @@ class MatchInfo:
return 1, 1 # entire match is toweled, so mark as finished
else:
raise ValueError('segments not found')
- running_segments = [cell for cell in row.select('td.bdca') if self.__has_running_board_count(cell)]
+ running_segments = row.select('td.bdca')
running_boards = sum([self.__get_html_running_boards(segment) for segment in running_segments])
finished_segments = []
boards_in_segment = None
diff --git a/playoff.py b/playoff.py
index a88d151..16113fc 100644
--- a/playoff.py
+++ b/playoff.py
@@ -3,6 +3,7 @@ import traceback
from jfr_playoff.filemanager import PlayoffFileManager
from jfr_playoff.generator import PlayoffGenerator
from jfr_playoff.settings import PlayoffSettings
+from jfr_playoff.logger import PlayoffLogger
def main():
@@ -15,6 +16,8 @@ def main():
description='Generate play-off HTML for JFR Teamy tournaments')
output_args = arg_parser.add_mutually_exclusive_group()
output_args.add_argument('-v', '--verbose', action='store_true',
+ help='display info on STDERR')
+ output_args.add_argument('-vv', '--debug', action='store_true',
help='display debug info on STDERR')
output_args.add_argument('-q', '--quiet', action='store_true',
help='suppress warnings on STDERR')
@@ -23,6 +26,12 @@ def main():
type=str, nargs='?', default=None)
arguments = arg_parser.parse_args()
+ PlayoffLogger.setup('ERROR' if arguments.quiet else (
+ 'INFO' if arguments.verbose else (
+ 'DEBUG' if arguments.debug else 'WARNING')))
+
+ PlayoffLogger.get().debug('started with arguments: %s', arguments)
+
settings = PlayoffSettings(arguments.config_file)
interactive = settings.interactive