rbx.cp 0.13.8__py3-none-any.whl → 0.16.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. rbx/__version__.py +1 -0
  2. rbx/box/cli.py +74 -70
  3. rbx/box/code.py +3 -0
  4. rbx/box/contest/build_contest_statements.py +65 -23
  5. rbx/box/contest/contest_package.py +8 -1
  6. rbx/box/contest/main.py +9 -3
  7. rbx/box/contest/schema.py +17 -13
  8. rbx/box/contest/statements.py +12 -8
  9. rbx/box/dump_schemas.py +2 -1
  10. rbx/box/environment.py +1 -1
  11. rbx/box/fields.py +22 -4
  12. rbx/box/generators.py +32 -13
  13. rbx/box/git_utils.py +29 -1
  14. rbx/box/limits_info.py +161 -0
  15. rbx/box/package.py +18 -1
  16. rbx/box/packaging/boca/boca_language_utils.py +26 -0
  17. rbx/box/packaging/boca/boca_outcome_utils.py +10 -0
  18. rbx/box/packaging/boca/packager.py +7 -5
  19. rbx/box/packaging/contest_main.py +20 -12
  20. rbx/box/packaging/packager.py +24 -14
  21. rbx/box/packaging/polygon/packager.py +7 -3
  22. rbx/box/packaging/polygon/upload.py +2 -1
  23. rbx/box/presets/__init__.py +143 -78
  24. rbx/box/presets/fetch.py +10 -2
  25. rbx/box/presets/schema.py +16 -1
  26. rbx/box/remote.py +3 -3
  27. rbx/box/sanitizers/issue_stack.py +124 -0
  28. rbx/box/schema.py +87 -27
  29. rbx/box/solutions.py +74 -117
  30. rbx/box/statements/build_statements.py +12 -1
  31. rbx/box/statements/builders.py +5 -3
  32. rbx/box/statements/latex_jinja.py +73 -23
  33. rbx/box/statements/schema.py +7 -9
  34. rbx/box/stressing/generator_parser.py +3 -1
  35. rbx/box/tasks.py +10 -10
  36. rbx/box/testcase_extractors.py +8 -0
  37. rbx/box/testing/testing_preset.py +129 -2
  38. rbx/box/testing/testing_shared.py +3 -1
  39. rbx/box/timing.py +305 -0
  40. rbx/box/tooling/boca/debug_utils.py +88 -0
  41. rbx/box/tooling/boca/manual_scrape.py +20 -0
  42. rbx/box/tooling/boca/scraper.py +660 -57
  43. rbx/box/unit.py +0 -2
  44. rbx/box/validators.py +0 -4
  45. rbx/grading/judge/cacher.py +36 -0
  46. rbx/grading/judge/program.py +12 -2
  47. rbx/grading/judge/sandbox.py +1 -1
  48. rbx/grading/judge/sandboxes/stupid_sandbox.py +2 -1
  49. rbx/grading/judge/storage.py +36 -3
  50. rbx/grading/limits.py +4 -0
  51. rbx/grading/steps.py +3 -2
  52. rbx/resources/presets/default/contest/contest.rbx.yml +7 -1
  53. rbx/resources/presets/default/contest/statement/info.rbx.tex +46 -0
  54. rbx/resources/presets/default/preset.rbx.yml +1 -0
  55. rbx/resources/presets/default/problem/.gitignore +1 -0
  56. rbx/resources/presets/default/problem/problem.rbx.yml +19 -3
  57. rbx/resources/presets/default/problem/rbx.h +52 -5
  58. rbx/resources/presets/default/problem/statement/statement.rbx.tex +6 -2
  59. rbx/resources/presets/default/problem/testlib.h +6299 -0
  60. rbx/resources/presets/default/problem/validator.cpp +4 -3
  61. rbx/resources/presets/default/shared/contest_template.rbx.tex +8 -4
  62. rbx/resources/presets/default/shared/icpc.sty +18 -3
  63. rbx/resources/presets/default/shared/problem_template.rbx.tex +4 -1
  64. rbx/testing_utils.py +17 -1
  65. rbx/utils.py +45 -0
  66. {rbx_cp-0.13.8.dist-info → rbx_cp-0.16.0.dist-info}/METADATA +5 -2
  67. {rbx_cp-0.13.8.dist-info → rbx_cp-0.16.0.dist-info}/RECORD +71 -67
  68. {rbx_cp-0.13.8.dist-info → rbx_cp-0.16.0.dist-info}/entry_points.txt +0 -1
  69. rbx/providers/__init__.py +0 -43
  70. rbx/providers/codeforces.py +0 -73
  71. rbx/providers/provider.py +0 -26
  72. rbx/submitors/__init__.py +0 -18
  73. rbx/submitors/codeforces.py +0 -121
  74. rbx/submitors/submitor.py +0 -25
  75. /rbx/resources/presets/default/problem/sols/{wa.cpp → wa-overflow.cpp} +0 -0
  76. {rbx_cp-0.13.8.dist-info → rbx_cp-0.16.0.dist-info}/LICENSE +0 -0
  77. {rbx_cp-0.13.8.dist-info → rbx_cp-0.16.0.dist-info}/WHEEL +0 -0
rbx/providers/provider.py DELETED
@@ -1,26 +0,0 @@
1
- import abc
2
- from typing import List
3
-
4
- from rbx.schema import Problem
5
-
6
-
7
- class ProviderInterface(abc.ABC):
8
- @abc.abstractmethod
9
- def should_handle(self, url: str) -> bool:
10
- pass
11
-
12
- def is_contest(self, problems: List[Problem]) -> bool:
13
- batches = set(problem.batch.id for problem in problems)
14
- return len(batches) == 1
15
-
16
- def should_simplify_contest_problems(self) -> bool:
17
- return False
18
-
19
- def get_problem_code_within_contest(self, problem: Problem) -> str:
20
- return self.get_code(problem)
21
-
22
- def get_code(self, problem: Problem) -> str:
23
- return problem.name
24
-
25
- def get_aliases(self, problem: Problem) -> List[str]:
26
- return []
rbx/submitors/__init__.py DELETED
@@ -1,18 +0,0 @@
1
- import pathlib
2
-
3
- from rbx.config import Language, get_config
4
- from rbx.schema import Problem
5
- from rbx.submitors.codeforces import CodeforcesSubmitor
6
-
7
- _SUBMITORS = [CodeforcesSubmitor()]
8
-
9
-
10
- def handle_submit(file: pathlib.Path, problem: Problem, lang: Language) -> bool:
11
- for submitor in _SUBMITORS:
12
- if submitor.should_handle(problem):
13
- submitor_config = get_config().submitor[lang.submitor]
14
- credentials = get_config().credentials[submitor.key()]
15
- return submitor.submit(
16
- file, problem, submitor_config[submitor.key()], credentials
17
- )
18
- return False
@@ -1,121 +0,0 @@
1
- import pathlib
2
- from typing import Any
3
-
4
- import mechanize
5
-
6
- from rbx import utils
7
- from rbx.console import console
8
- from rbx.schema import Problem
9
- from rbx.submitors.submitor import Submitor
10
-
11
- _SUBMITOR_KEY = 'codeforces'
12
-
13
-
14
- class Session:
15
- def __init__(self):
16
- self.br = mechanize.Browser()
17
- self.br.set_handle_robots(False)
18
- self.br.addheaders = [ # type: ignore
19
- (
20
- 'User-agent',
21
- 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1',
22
- )
23
- ]
24
-
25
- def select_form_by_id(self, id, forms):
26
- for form in forms:
27
- if form.attrs.get('id') == id:
28
- return form
29
- return None
30
-
31
- def select_form_by_class(self, cl, forms):
32
- for form in forms:
33
- if form.attrs.get('class') == cl:
34
- return form
35
- return None
36
-
37
- def login(self, handle, password):
38
- response = self.br.open('http://codeforces.com/enter')
39
- if response is None:
40
- raise Exception('Response was not received')
41
- if not response.geturl().endswith('enter'):
42
- return
43
- form = self.select_form_by_id('enterForm', self.br.forms())
44
- if form is None:
45
- raise Exception('Login form was not found')
46
-
47
- form['handleOrEmail'] = handle
48
- form['password'] = password
49
- self.br.form = form
50
- response = self.br.submit()
51
- if response is None:
52
- raise Exception('Response was not received')
53
- if response.geturl().endswith('enter'):
54
- raise Exception(
55
- 'Login attempt was not successful. Check your credentials or your internet connection'
56
- )
57
-
58
- def submit_from_contest(self, url: str, file: pathlib.Path, typeid: int):
59
- filename = str(utils.abspath(file))
60
- self.br.open(url)
61
- form = self.select_form_by_class('submit-form', self.br.forms())
62
- if form is None:
63
- raise Exception('You are not logged in or problem does not exist')
64
-
65
- form['programTypeId'] = [str(typeid)]
66
- form.add_file(file.open(), 'plain/text', filename)
67
- self.br.form = form
68
- self.br.submit()
69
-
70
- def submit(self, url: str, file: pathlib.Path, typeid: int):
71
- filename = str(utils.abspath(file))
72
- response = self.br.open(url)
73
- if response is None:
74
- raise Exception('Response was not received')
75
- if response.geturl().endswith('attachments'):
76
- self.submit_from_contest(url.replace('/problem/', '/submit/'), file, typeid)
77
- return
78
- form = self.select_form_by_class('submitForm', self.br.forms())
79
- if form is None:
80
- raise Exception('You are not logged in or problem does not exist')
81
-
82
- form['programTypeId'] = [str(typeid)]
83
- form.add_file(file.open(), 'plain/text', filename)
84
- self.br.form = form
85
- self.br.submit()
86
-
87
-
88
- class CodeforcesSubmitor(Submitor):
89
- def key(self) -> str:
90
- return _SUBMITOR_KEY
91
-
92
- def should_handle(self, problem: Problem) -> bool:
93
- return 'codeforces.com/' in problem.url
94
-
95
- def submit(
96
- self,
97
- file: pathlib.Path,
98
- problem: Problem,
99
- submitor_config: Any,
100
- credentials: Any,
101
- ) -> bool:
102
- typeid = submitor_config['typeid']
103
- handle = credentials['handle']
104
- password = credentials['password']
105
-
106
- session = Session()
107
- console.print(
108
- f'Trying to login with handle [item]{handle}[/item] in Codeforces.'
109
- )
110
- try:
111
- session.login(handle, password)
112
- except Exception as e:
113
- console.print(f'[error]Failed to log in: {str(e)}[/error]')
114
- return False
115
- console.print('[italic]Possibly[/italic] logged in!')
116
- try:
117
- session.submit(problem.url, file, typeid)
118
- except Exception as e:
119
- console.print(f'[error]Failed to submit: {str(e)}[/error]')
120
- return False
121
- return True
rbx/submitors/submitor.py DELETED
@@ -1,25 +0,0 @@
1
- import abc
2
- import pathlib
3
- from typing import Any
4
-
5
- from rbx.schema import Problem
6
-
7
-
8
- class Submitor(abc.ABC):
9
- @abc.abstractmethod
10
- def key(self) -> str:
11
- pass
12
-
13
- @abc.abstractmethod
14
- def should_handle(self, problem: Problem) -> bool:
15
- pass
16
-
17
- @abc.abstractmethod
18
- def submit(
19
- self,
20
- file: pathlib.Path,
21
- problem: Problem,
22
- submitor_config: Any,
23
- credentials: Any,
24
- ) -> bool:
25
- pass