diff options
author | emkael <emkael@tlen.pl> | 2015-09-01 12:02:55 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2015-09-01 12:02:55 +0200 |
commit | 553b5e01dd60ded1404bd500457eabdf5a875ad2 (patch) | |
tree | 00b6102fa20838df8bfe8b9e6eeaf59966753dd2 /bidding_data.py | |
parent | 873ac6829408854b2a4c64756252627f04286c5d (diff) |
* path parsing and file existence checks
Diffstat (limited to 'bidding_data.py')
-rw-r--r-- | bidding_data.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/bidding_data.py b/bidding_data.py index a56847b..e24ffba 100644 --- a/bidding_data.py +++ b/bidding_data.py @@ -156,7 +156,7 @@ class JFRBidding: self.__round_lineups = self.__parse_lineup_data(self.__lineup_data) self.__bids = self.__parse_bidding_data(bid_data) self.__tournament_prefix = path.splitext( - path.realpath(file_prefix + '.html'))[0] + path.realpath(file_prefix))[0] self.__tournament_files_match = re.compile( re.escape(self.__tournament_prefix) + '([0-9]{3})\.html') self.__map_board_numbers() @@ -276,10 +276,20 @@ if __name__ == '__main__': argument_parser = argparse.ArgumentParser( description='Display bidding data from BWS files on JFR Pary pages') + + def file_path(filepath): + filepath = unicode(filepath, sys.getfilesystemencoding()) + if path.isfile(filepath): + return filepath + else: + argument_parser.error('File %s does not exist' % filepath) + argument_parser.add_argument('bws_file', metavar='BWS_FILE', - help='path to BWS file') + help='path to BWS file', + type=file_path) argument_parser.add_argument('path', metavar='PATH', - help='tournament path with JFR prefix') + help='tournament path (to PREFIX.html)', + type=file_path) arguments = argument_parser.parse_args() |