|
|
@ -1,6 +1,49 @@ |
|
|
|
from seminar import ovvpfile |
|
|
|
import os |
|
|
|
import datetime |
|
|
|
import sqlite3 |
|
|
|
|
|
|
|
from django.utils.html import escape |
|
|
|
|
|
|
|
from seminar import ovvpfile |
|
|
|
from seminar.models import Problem |
|
|
|
from seminar.utils import roman, from_roman |
|
|
|
|
|
|
|
|
|
|
|
# MM_ZADANIA.TYP |
|
|
|
typtable={'1': Problem.TYP_ULOHA, '2':Problem.TYP_TEMA, '3':Problem.TYP_SERIAL} |
|
|
|
|
|
|
|
# MM_DOZ.ZARADENIE, MM_AZAD.ZAMERANIE |
|
|
|
def dectag(x): |
|
|
|
return ["MFIOTKPZD"[bi] for bi in range(0, 9) if (int(x) & (1 << bi))] |
|
|
|
|
|
|
|
# Datum z formatu "DD.MM.YY" |
|
|
|
def transdate(s): |
|
|
|
if '.' not in s: return None |
|
|
|
d,m,r = map(int, s.split('.')) |
|
|
|
return datetime.date(r + 2000 if r < 30 else r + 1900, m, d) |
|
|
|
|
|
|
|
class SQLiteRow(object): |
|
|
|
def __unicode__(self): |
|
|
|
return self.__dict__.__unicode__() |
|
|
|
def __str__(self): |
|
|
|
return self.__dict__.__str__() |
|
|
|
def __repr__(self): |
|
|
|
return self.__dict__.__str__() |
|
|
|
|
|
|
|
# sqlite3 helper |
|
|
|
def sqget(db, sql, limit=None): |
|
|
|
c = db.execute(sql) |
|
|
|
rows = c.fetchmany(limit) if limit else c.fetchall() |
|
|
|
res = [] |
|
|
|
for row in rows: |
|
|
|
o = SQLiteRow() |
|
|
|
for coli in range(len(c.description)): |
|
|
|
col = c.description[coli] |
|
|
|
o.__setattr__(col[0], row[coli]) |
|
|
|
res.append(o) |
|
|
|
return res |
|
|
|
|
|
|
|
## ovvpfile - based import helpers (old) |
|
|
|
|
|
|
|
def read_all_tables(basedir): |
|
|
|
tables = {} |
|
|
|