From bd5fd6a6596dd7625019c6c0f0ff043597cda837 Mon Sep 17 00:00:00 2001 From: emkael Date: Mon, 31 Jul 2017 20:45:13 +0200 Subject: Renaming module to avoid ambiguity --- jfr_playoff/__init__.py | 0 jfr_playoff/db.py | 19 +++++++ jfr_playoff/settings.py | 31 ++++++++++++ jfr_playoff/sql.py | 34 +++++++++++++ jfr_playoff/template.py | 128 ++++++++++++++++++++++++++++++++++++++++++++++++ playoff.py | 8 +-- playoff/__init__.py | 0 playoff/db.py | 19 ------- playoff/settings.py | 31 ------------ playoff/sql.py | 34 ------------- playoff/template.py | 128 ------------------------------------------------ 11 files changed, 216 insertions(+), 216 deletions(-) create mode 100644 jfr_playoff/__init__.py create mode 100644 jfr_playoff/db.py create mode 100644 jfr_playoff/settings.py create mode 100644 jfr_playoff/sql.py create mode 100644 jfr_playoff/template.py delete mode 100644 playoff/__init__.py delete mode 100644 playoff/db.py delete mode 100644 playoff/settings.py delete mode 100644 playoff/sql.py delete mode 100644 playoff/template.py diff --git a/jfr_playoff/__init__.py b/jfr_playoff/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jfr_playoff/db.py b/jfr_playoff/db.py new file mode 100644 index 0000000..aa0c2e2 --- /dev/null +++ b/jfr_playoff/db.py @@ -0,0 +1,19 @@ +import mysql.connector + +class PlayoffDB(object): + + db_cursor = None + + def __init__(self, settings): + self.database = mysql.connector.connect( + user=settings['user'], + password=settings['pass'], + host=settings['host'], + port=settings['port'] + ) + self.db_cursor = self.database.cursor(buffered=True) + + def fetch(self, db, sql, params): + self.db_cursor.execute(sql.replace('#db#', db), params) + row = self.db_cursor.fetchone() + return row diff --git a/jfr_playoff/settings.py b/jfr_playoff/settings.py new file mode 100644 index 0000000..dd7399d --- /dev/null +++ b/jfr_playoff/settings.py @@ -0,0 +1,31 @@ +import glob, json, os, readline, sys + +def complete_filename(text, state): + return (glob.glob(text+'*')+[None])[state] + +class PlayoffSettings: + + def __init__(self): + self.interactive = False + if len(sys.argv) > 1: + settings_file = sys.argv[1] + else: + self.interactive = True + readline.set_completer_delims(' \t\n;') + readline.parse_and_bind("tab: complete") + readline.set_completer(complete_filename) + settings_file = raw_input('JSON settings file: ') + + if not os.path.exists(settings_file): + raise IOError('Settings file %s not found' % settings_file) + + self.settings = json.load(open(settings_file)) + + def has_section(self, key): + return key in self.settings + + def get(self, *keys): + section = self.settings + for key in keys: + section = section[key] + return section diff --git a/jfr_playoff/sql.py b/jfr_playoff/sql.py new file mode 100644 index 0000000..76ea728 --- /dev/null +++ b/jfr_playoff/sql.py @@ -0,0 +1,34 @@ +MATCH_RESULTS = ''' +SELECT t1.fullname, t2.fullname, matches.carry, matches.vph, matches.vpv, matches.corrh, matches.corrv +FROM #db#.matches matches +JOIN #db#.teams t1 + ON t1.id = #db#.matches.homet +JOIN #db#.teams t2 + ON t2.id = #db#.matches.visit +WHERE matches.tabl = %s AND matches.rnd = %s +''' + +BOARD_COUNT = ''' +SELECT segmentsperround*boardspersegment, SUM(sc1.contract IS NOT NULL AND sc2.contract IS NOT NULL) +FROM #db#.scores sc1 +JOIN #db#.scores sc2 + ON sc1.rnd = sc2.rnd + AND sc1.segment = sc2.segment + AND sc1.tabl = sc2.tabl + AND sc1.board = sc2.board + AND sc1.room = 1 + AND sc2.room = 2 +JOIN #db#.admin +WHERE sc1.tabl = %s AND sc1.rnd = %s +''' + +TOWEL_COUNT = ''' +SELECT #db#.admin.boardspersegment * SUM(#db#.segments.towel > 0) +FROM #db#.segments +JOIN #db#.admin +WHERE #db#.segments.tabl = %s AND #db#.segments.rnd = %s +''' + +PREFIX = ''' +SELECT shortname FROM #db#.admin +''' diff --git a/jfr_playoff/template.py b/jfr_playoff/template.py new file mode 100644 index 0000000..8713ab9 --- /dev/null +++ b/jfr_playoff/template.py @@ -0,0 +1,128 @@ +#encoding=utf-8 + +MATCH_TABLE = ''' + + + + + +%s +
  wynik 
+''' + +MATCH_TEAM_ROW = ''' + + %s  + + + %.1f  + + + +''' + +MATCH_RUNNING = ''' + + +%d + + +''' + +MATCH_GRID = ''' +
+ +%s + +
+''' + +MATCH_GRID_PHASE = ''' + +%s + +''' + +MATCH_GRID_PHASE_RUNNING = ''' + + +%s + + +''' + +MATCH_BOX = ''' +
+%s +
+''' + +LEADERBOARD = ''' + + + + + + + + + + + +%s +
 KLASYFIKACJA KOŃCOWA 
 
 miejsce  drużyna 
+''' + +LEADERBOARD_ROW = ''' + +%d + + %s  %s  + + +''' + +LEADERBOARD_ROW_FLAG = ''' + +''' + +PAGE_HEAD = ''' + + + + + + +%s +%s + + +''' + +PAGE_HEAD_REFRESH = ''' + +''' + +PAGE_BODY = ''' + +%s +%s +%s +%s +''' + +PAGE_BODY_FOOTER = ''' +

 Admin ©Jan Romański'2005, PlayOff ©Michał Klichowicz'2017, strona wygenerowana %s

+''' + +PAGE = ''' + + + +%s + + +%s + + +''' diff --git a/playoff.py b/playoff.py index 8a2a9e3..bb3e141 100644 --- a/playoff.py +++ b/playoff.py @@ -1,10 +1,10 @@ import os, shutil, socket from datetime import datetime from urlparse import urljoin -import playoff.sql as p_sql -import playoff.template as p_temp -from playoff.db import PlayoffDB -from playoff.settings import PlayoffSettings +import jfr_playoff.sql as p_sql +import jfr_playoff.template as p_temp +from jfr_playoff.db import PlayoffDB +from jfr_playoff.settings import PlayoffSettings def get_shortname(fullname, teams): for team in teams: diff --git a/playoff/__init__.py b/playoff/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/playoff/db.py b/playoff/db.py deleted file mode 100644 index aa0c2e2..0000000 --- a/playoff/db.py +++ /dev/null @@ -1,19 +0,0 @@ -import mysql.connector - -class PlayoffDB(object): - - db_cursor = None - - def __init__(self, settings): - self.database = mysql.connector.connect( - user=settings['user'], - password=settings['pass'], - host=settings['host'], - port=settings['port'] - ) - self.db_cursor = self.database.cursor(buffered=True) - - def fetch(self, db, sql, params): - self.db_cursor.execute(sql.replace('#db#', db), params) - row = self.db_cursor.fetchone() - return row diff --git a/playoff/settings.py b/playoff/settings.py deleted file mode 100644 index dd7399d..0000000 --- a/playoff/settings.py +++ /dev/null @@ -1,31 +0,0 @@ -import glob, json, os, readline, sys - -def complete_filename(text, state): - return (glob.glob(text+'*')+[None])[state] - -class PlayoffSettings: - - def __init__(self): - self.interactive = False - if len(sys.argv) > 1: - settings_file = sys.argv[1] - else: - self.interactive = True - readline.set_completer_delims(' \t\n;') - readline.parse_and_bind("tab: complete") - readline.set_completer(complete_filename) - settings_file = raw_input('JSON settings file: ') - - if not os.path.exists(settings_file): - raise IOError('Settings file %s not found' % settings_file) - - self.settings = json.load(open(settings_file)) - - def has_section(self, key): - return key in self.settings - - def get(self, *keys): - section = self.settings - for key in keys: - section = section[key] - return section diff --git a/playoff/sql.py b/playoff/sql.py deleted file mode 100644 index 76ea728..0000000 --- a/playoff/sql.py +++ /dev/null @@ -1,34 +0,0 @@ -MATCH_RESULTS = ''' -SELECT t1.fullname, t2.fullname, matches.carry, matches.vph, matches.vpv, matches.corrh, matches.corrv -FROM #db#.matches matches -JOIN #db#.teams t1 - ON t1.id = #db#.matches.homet -JOIN #db#.teams t2 - ON t2.id = #db#.matches.visit -WHERE matches.tabl = %s AND matches.rnd = %s -''' - -BOARD_COUNT = ''' -SELECT segmentsperround*boardspersegment, SUM(sc1.contract IS NOT NULL AND sc2.contract IS NOT NULL) -FROM #db#.scores sc1 -JOIN #db#.scores sc2 - ON sc1.rnd = sc2.rnd - AND sc1.segment = sc2.segment - AND sc1.tabl = sc2.tabl - AND sc1.board = sc2.board - AND sc1.room = 1 - AND sc2.room = 2 -JOIN #db#.admin -WHERE sc1.tabl = %s AND sc1.rnd = %s -''' - -TOWEL_COUNT = ''' -SELECT #db#.admin.boardspersegment * SUM(#db#.segments.towel > 0) -FROM #db#.segments -JOIN #db#.admin -WHERE #db#.segments.tabl = %s AND #db#.segments.rnd = %s -''' - -PREFIX = ''' -SELECT shortname FROM #db#.admin -''' diff --git a/playoff/template.py b/playoff/template.py deleted file mode 100644 index 8713ab9..0000000 --- a/playoff/template.py +++ /dev/null @@ -1,128 +0,0 @@ -#encoding=utf-8 - -MATCH_TABLE = ''' - - - - - -%s -
  wynik 
-''' - -MATCH_TEAM_ROW = ''' - - %s  - - - %.1f  - - - -''' - -MATCH_RUNNING = ''' - - -%d - - -''' - -MATCH_GRID = ''' -
- -%s - -
-''' - -MATCH_GRID_PHASE = ''' - -%s - -''' - -MATCH_GRID_PHASE_RUNNING = ''' - - -%s - - -''' - -MATCH_BOX = ''' -
-%s -
-''' - -LEADERBOARD = ''' - - - - - - - - - - - -%s -
 KLASYFIKACJA KOŃCOWA 
 
 miejsce  drużyna 
-''' - -LEADERBOARD_ROW = ''' - -%d - - %s  %s  - - -''' - -LEADERBOARD_ROW_FLAG = ''' - -''' - -PAGE_HEAD = ''' - - - - - - -%s -%s - - -''' - -PAGE_HEAD_REFRESH = ''' - -''' - -PAGE_BODY = ''' - -%s -%s -%s -%s -''' - -PAGE_BODY_FOOTER = ''' -

 Admin ©Jan Romański'2005, PlayOff ©Michał Klichowicz'2017, strona wygenerowana %s

-''' - -PAGE = ''' - - - -%s - - -%s - - -''' -- cgit v1.2.3