diff options
author | emkael <emkael@tlen.pl> | 2015-09-02 22:05:26 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2015-09-02 22:05:26 +0200 |
commit | e67e494d8d0521e8a2bd9bb6403756731e7ad0d7 (patch) | |
tree | 765fec36806d5ae2fd0532a83fe0af2481798888 | |
parent | 73859195967e77005d3133211b6245a18facaa04 (diff) |
* cleanup of unused bidding table files
-rw-r--r-- | TODO.md | 1 | ||||
-rw-r--r-- | bundle/bidding_data-1.0.zip | bin | 6041987 -> 6173067 bytes | |||
-rw-r--r-- | src/bidding_data.py | 18 |
3 files changed, 14 insertions, 5 deletions
@@ -1,2 +1 @@ - * czyszczenie nieużywanych plików *_bidding_*.txt * pobieranie nazwisk z BWS(?) diff --git a/bundle/bidding_data-1.0.zip b/bundle/bidding_data-1.0.zip Binary files differindex e1fa496..cad4f8e 100644 --- a/bundle/bidding_data-1.0.zip +++ b/bundle/bidding_data-1.0.zip diff --git a/src/bidding_data.py b/src/bidding_data.py index ae789f1..98762b6 100644 --- a/src/bidding_data.py +++ b/src/bidding_data.py @@ -3,7 +3,7 @@ import glob import re import pypyodbc -from os import path +from os import path, remove from bs4 import BeautifulSoup as bs4 @@ -148,6 +148,9 @@ class JFRBidding: # BWS number -> JFR number mapping __board_number_mapping = {} + # all generated bidding table files, for cleanup purposes + __bidding_files = [] + def __init__(self, bws_file, file_prefix): with pypyodbc.win_connect_mdb(bws_file) as connection: cursor = connection.cursor() @@ -198,6 +201,7 @@ class JFRBidding: self.__get_bidding_file_output_path( self.__board_number_mapping[board_no], round_no, table_no) + self.__bidding_files.append(bidding_fpath) with file(bidding_fpath, 'w') as bidding_file: bidding_file.write( self.__format_bidding(bidding_table)) @@ -255,10 +259,14 @@ class JFRBidding: bidding_link = board_text_content.new_tag( 'a', href='#', **{'class': 'biddingLink'}) bidding_link.string = ' ' + bidding_path = self.__get_bidding_file_output_path( + int(file_number, 10), + pair_numbers=pair_numbers) bidding_link['data-bidding-link'] = path.basename( - self.__get_bidding_file_output_path( - int(file_number, 10), - pair_numbers=pair_numbers)) + bidding_path) + if bidding_path in self.__bidding_files: + del self.__bidding_files[ + self.__bidding_files.index(bidding_path)] # only append link if we've got bidding data if path.isfile(path.join( path.dirname(self.__tournament_prefix), @@ -271,6 +279,8 @@ class JFRBidding: board_text.write(board_text_content.table.prettify( 'iso-8859-2', formatter='html')) board_text.truncate() + for unused_file in self.__bidding_files: + remove(unused_file) if __name__ == '__main__': import argparse |