def fill_db_from_contest_xml(contest_xmls_dir, cursor, origin):
    files_walker = AllFilesWalker()
    for extension, filename in files_walker.walk(contest_xmls_dir):
        contest_id = os.path.basename(filename)[:6]
        if not contest_id.isdigit():
            logging.warning('Invalid contest id {}'.format(contest_id))
            continue
        contest_name = ejudge_get_contest_name(filename)
        logging.info('Filling contest name for contest #{}'.format(contest_id))
        cursor.execute('UPDATE Contests SET name = ? WHERE origin = ? AND contest_id = ?',
                       (contest_name, origin, contest_id.rjust(6, '0')))
        if cursor.rowcount != 1:
            logging.warning('Contest #{} not found'.format(contest_id))
Beispiel #2
0
class TestAllFilesWalker(PestoTestCase):
    def setUp(self):
        self.walker = AllFilesWalker()

    def test_walk(self):
        dir = os.path.join('testdata', 'count_submit_test', '000017')
        files = list(self.walker.walk(dir))
        good_files = [('xml', os.path.join('testdata', 'count_submit_test', '000017', '000077')),
                      ('xml', os.path.join('testdata', 'count_submit_test', '000017', '0', '000066')),
                      ('gzip', os.path.join('testdata', 'count_submit_test', '000017', 'A', '000068.gz'))]
        self.assertEqual(sorted(files), sorted(good_files))
Beispiel #3
0
 def setUp(self):
     self.walker = AllFilesWalker()