summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2015-09-02 22:05:26 +0200
committeremkael <emkael@tlen.pl>2015-09-02 22:05:26 +0200
commite67e494d8d0521e8a2bd9bb6403756731e7ad0d7 (patch)
tree765fec36806d5ae2fd0532a83fe0af2481798888
parent73859195967e77005d3133211b6245a18facaa04 (diff)
* cleanup of unused bidding table files
-rw-r--r--TODO.md1
-rw-r--r--bundle/bidding_data-1.0.zipbin6041987 -> 6173067 bytes
-rw-r--r--src/bidding_data.py18
3 files changed, 14 insertions, 5 deletions
diff --git a/TODO.md b/TODO.md
index 0c809b8..98de040 100644
--- a/TODO.md
+++ b/TODO.md
@@ -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
index e1fa496..cad4f8e 100644
--- a/bundle/bidding_data-1.0.zip
+++ b/bundle/bidding_data-1.0.zip
Binary files differ
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