Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#429: avoid the limitation of the new API of AOJ #432

Merged
merged 1 commit into from
Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions onlinejudge/service/aoj.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,24 +81,16 @@ def download_system_cases(self, session: Optional[requests.Session] = None) -> L
# get testcases via the official API
testcases = [] # type: List[TestCase]
for header in header['headers']:
# reference: http://developers.u-aizu.ac.jp/api?key=judgedat%2Ftestcases%2F%7BproblemId%7D%2F%7Bserial%7D_GET
# NOTE: the endpoints are not same to http://developers.u-aizu.ac.jp/api?key=judgedat%2Ftestcases%2F%7BproblemId%7D%2F%7Bserial%7D_GET since the json API often says "..... (terminated because of the limitation)"
url = 'https://judgedat.u-aizu.ac.jp/testcases/{}/{}'.format(self.problem_id, header['serial'])
resp = utils.request('GET', url, session=session)
testcase = json.loads(resp.content.decode(resp.encoding))
skipped = False
for type in ('in', 'out'):
if testcase[type].endswith('..... (terminated because of the limitation)\n'):
log.error('AOJ API says: terminated because of the limitation')
skipped = True
if skipped:
log.warning("skipped due to the limitation of AOJ API")
continue
resp_in = utils.request('GET', url + '/in', session=session)
resp_out = utils.request('GET', url + '/out', session=session)
testcases += [TestCase(
header['name'],
header['name'],
testcase['in'].encode(),
resp_in.content,
header['name'],
testcase['out'].encode(),
resp_out.content,
)]
return testcases

Expand Down
12 changes: 4 additions & 8 deletions tests/command_download_aoj.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,10 @@ def test_call_download_aoj_system_ITP1_1_B(self):
}, is_system=True)

def test_call_download_aoj_system_1169(self):
# NOTE: the data exists, but AOJ says "..... (terminated because of the limitation)"
self.snippet_call_download(
'http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1169&lang=jp',
{
# '1.in': 'f0ecaede832a038d0e940c2c4d0ab5e5',
# '1.out': '8d2f7846dc2fc10ef37dcb548635c788',
},
is_system=True)
self.snippet_call_download('http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1169&lang=jp', {
'judge_data.in': 'f0ecaede832a038d0e940c2c4d0ab5e5',
'judge_data.out': '8d2f7846dc2fc10ef37dcb548635c788',
}, is_system=True)


class DownloadAOJArenaTest(unittest.TestCase):
Expand Down