개요
그 동안 이 모듈은 boj
라는 이름과는 달리, Baekjoon Online Judge 관련 기능을 중점적으로 다루지 않았습니다.
명확하지 않던 정체성을 확실하게 할 필요가 있다고 느꼈고, 이에 따라 다음과 같이 모듈 구조를 수정할 것을 제안합니다.
제안 모듈 구조
boj
├─ python
| ├─ core
│ │ ├─ problem.py // 문제 데이터를 다루는 인터페이스 정의
│ │ └─ web.py // 정보 수집 관련 작업
│ │
│ └─ judge.py // 가채점기 관련 모듈
│
├─ __init__.py
└─ __main__.py
boj.python.core.web
web.py
에서는 웹으로 부터 데이터를 받아오고 처리하기 위한 인터페이스를 제공합니다.
받아온 HTML 문서를 파싱하고 다룹니다.
interface Crawler
interface Crawler {
str get(String url);
}
Methods
get()
url
로 부터 HTML문서를 불러옵니다.
REST api의 'GET' 메소드를 사용하며, 받아온 HTML은 문자열의 형태로 반환됩니다.
Args:
url: HTML문서를 불러올 url 주소입니다.
Returns:
HTML문서를 반환합니다.
interface HTMLElement
interface HTMLElement {
attribute str inner_HTML;
str to_markdown();
}
Properties
inner_HTML
해당 HTML 요소 안의 내용입니다.
Methods
to_markdown()
해당 요소의 내용을 마크다운으로 변환하여 반환합니다.
Returns:
마크다운 문법으로 변환된 문서를 반환합니다.
boj.python.core.problem
problem.py
에서는 문제에 데이터를 다루기 위한 인터페이스를 제공합니다.
interface Document
interface Document {
str title;
HTMLElement desc;
HTMLElement input;
HTMLElement output;
HTMLElement hint;
}
Document
는 문제 설명에 대해 다루기 위한 가장 기본 단위입니다.
https://www.acmicpc.net/problem/:number
에 표시되는 대부분의 정보는 Document
를 통해 다루어집니다.
Properties
title
문제의 제목입니다.
desc
문제의 설명입니다.
input
문제의 입력에 대한 설명입니다.
output
문제의 출력에 대한 설명입니다.
hint
문제에 대한 힌트입니다.
interface Rule
문제 풀이 규칙에 관련된 인터페이스입니다.
interface Rule {
// Definition Group
SPECIAL_JUDGE = 2;
attribute int method;
}
interface Problem
interface Problem {
readonly attribute int number;
readonly attribute Document document;
attribute Rule rule;
None save(str path);
None load(str path);
None
}
Properties
Methods
``
Args:
Returns:
Raises: