onlinejudge.type module

class onlinejudge.type.Contest[source]

Bases: abc.ABC

Note

Contest represents just a URL of a contest, without the data of the contest.

download_data(*, session=None)[source]
Return type

ContestData

abstract classmethod from_url(s)[source]
Return type

Optional[Contest]

abstract get_service()[source]
Return type

Service

abstract get_url()[source]
Return type

str

iterate_submissions(*, session=None)[source]
Return type

Iterator[Submission]

list_problems(*, session=None)[source]
Return type

List[Problem]

class onlinejudge.type.ContestData[source]

Bases: onlinejudge.type.DownloadedData

abstract property contest
Return type

Contest

abstract property name
Return type

str

property service
Return type

Service

url()[source]
Return type

str

class onlinejudge.type.DownloadedData[source]

Bases: abc.ABC

Note

DownloadedData and its subclasses represent contents which are obtained by network access. The values may depends your session. DownloadedData とそのサブクラスは、ネットワークアクセスの結果得られるようなデータを表現します。その値はログイン状況などにより接続のたびに変化することがあります。

property html
Return type

Optional[bytes]

property json
Return type

Optional[bytes]

property response
Return type

Optional[Response]

property session
Return type

Optional[Session]

property timestamp
Return type

Optional[datetime]

abstract property url
Return type

str

class onlinejudge.type.Language(id, name)

Bases: tuple

Variables
property id

Alias for field number 0

property name

Alias for field number 1

onlinejudge.type.LanguageId(x)
Note

This is just a NewType -ed str not, but you should not use this other than a label.

exception onlinejudge.type.LoginError[source]

Bases: RuntimeError

exception onlinejudge.type.NotLoggedInError[source]

Bases: RuntimeError

class onlinejudge.type.Problem[source]

Bases: abc.ABC

Note

Problem represents just a URL of a problem, without the data of the problem. Problem はちょうど問題の URL のみを表現します。キャッシュや内部状態は持ちません。

download_data(*, session=None)[source]
Return type

ProblemData

abstract download_sample_cases(*, session=None)[source]
Raises

SampleParseError

Return type

List[TestCase]

download_system_cases(*, session=None)[source]
Raises

NotLoggedInError

Return type

List[TestCase]

abstract classmethod from_url(s)[source]
Return type

Optional[Problem]

get_available_languages(*, session=None)[source]
Return type

List[Language]

get_contest()[source]
Return type

Contest

abstract get_service()[source]
Return type

Service

abstract get_url()[source]
Return type

str

submit_code(code, language_id, *, filename=None, session=None)[source]
Parameters
Raises
Return type

Submission

class onlinejudge.type.ProblemData[source]

Bases: onlinejudge.type.DownloadedData

property contest
Return type

Contest

abstract property name

for example of Problem:

  • 器物損壊!高橋君

  • AtCoDeerくんと変なじゃんけん / AtCoDeer and Rock-Paper

  • Xor Sum

Return type

str

abstract property problem
Return type

Problem

property sample_cases
Return type

Optional[List[TestCase]]

property service
Return type

Service

url()[source]
Return type

str

exception onlinejudge.type.SampleParseError[source]

Bases: RuntimeError

class onlinejudge.type.Service[source]

Bases: abc.ABC

abstract classmethod from_url(s)[source]
Return type

Optional[Service]

abstract get_name()[source]

example:

  • AtCoder

  • Codeforces

  • PKU JudgeOnline

Note

If you want something like identifier (e.g. atcoder, codeforces or poj), you can use a domain obtained from get_url().

Return type

str

abstract get_url()[source]
Return type

str

get_url_of_login_page()[source]
Return type

str

is_logged_in(*, session=None)[source]
Return type

bool

iterate_contests(*, session=None)[source]
Return type

Iterator[Contest]

login(*, get_credentials, session=None)[source]
Parameters

get_credentials (Callable[[], Tuple[str, str]]) – returns a tuple of (username, password)

Raises

LoginError

Return type

None

class onlinejudge.type.Submission[source]

Bases: abc.ABC

download_data(*, session=None)[source]
Return type

SubmissionData

abstract classmethod from_url(s)[source]
Return type

Optional[Submission]

get_contest()[source]
Return type

Contest

abstract get_problem()[source]
Return type

Problem

abstract get_service()[source]
Return type

Service

abstract get_url()[source]
Return type

str

class onlinejudge.type.SubmissionData[source]

Bases: onlinejudge.type.DownloadedData

property contest
Return type

Contest

property problem
Return type

Problem

property service
Return type

Service

property source_code
Return type

bytes

abstract property status
Return type

str

abstract property submission
Return type

Submission

url()[source]
Return type

str

exception onlinejudge.type.SubmissionError[source]

Bases: RuntimeError

class onlinejudge.type.TestCase(name, input_name, input_data, output_name, output_data)

Bases: tuple

property input_data

Alias for field number 2

property input_name

Alias for field number 1

property name

Alias for field number 0

property output_data

Alias for field number 4

property output_name

Alias for field number 3