-
Notifications
You must be signed in to change notification settings - Fork 6
Home
Importing all classes from modules Copyright (C) 2021 Vadim Vergasov
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Class for generating request URLs, which includes working with random, unpacking parameters, calculating hashes. Copyright (C) 2021 Vadim Vergasov
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
class CodeforcesApiRequestMaker()
| __init__(api_key=None, secret=None, random_number=1000000)
Initializes main variables: api_key, secret, random (default is between 1 and 1000000 unless specified)
| generate_request(method_name, **fields)
Generates request URL and data for API.
| check_return_code(response)
Checks if a returned response is OK.
If not OK Exception will be raised will additional info.
| renew_rand(random_number=1000000)
It's recommended that you renew your apiSig for each request default is between 100000 and 1000000 unless specified)
Defining types. Copyright (C) 2021 Vadim Vergasov
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/. Source of inspiration: https://github.com/eternnoir/pyTelegramBotAPI/blob/master/telebot/types.py
class Dictionaryable(object)
Subclasses of this class are guaranteed to be able to be converted to dictionary. All subclasses of this class must override to_dict.
| to_dict()
Returns a DICT with class field values This function must be overridden by subclasses.
Returns:
a DICT
class JSONDeserializable(object)
Subclasses of this class are guaranteed to be able to be created from a json-style dict or json formatted string. All subclasses of this class must override de_json.
| @classmethod
| from_json(cls, json_string)
Returns an instance of this class from the given json dict or string. This function must be overridden by subclasses.
Returns:
an instance of this class created from the given json dict or string.
| @staticmethod
| check_json(json_type)
Checks whether json_type is a dict or a string. If it is already a dict, it is returned as-is. If it is not, it is converted to a dict by means of json.loads(json_type)
Arguments:
-
json_type
:
Returns:
Parse methods from codeforces.com Copyright (C) 2021 Vadim Vergasov
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
class CodeforcesParser()
| __init__()
Initializing class. All we will need is a session to optimize performance.
| get_solution(contest_id, submit_id)
Returns source code for specified submit.
contest_id is the id of contest.
submit_id is the id of sumbission.
| get_tags(contest_id, index, include_rating=False)
Get tags of the given problem.
contest_id is the number of the contest.
index is the number of the problem, better to be a capital letter. Also could be an integer or lowercase letter.
include_rating is bool which indicates include or not task rating.
The main class for the API requests. Copyright (C) 2021 Vadim Vergasov
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.
class CodeforcesApi(CodeforcesApiRequestMaker)
Class for using official API requests.
| __init__(api_key=None, secret=None, random_number=1000000, method="POST")
Initializing class. All we will need is a session to optimize performance.
| blog_entry_comments(blog_entry_id)
Get blogEntry.commnets for blog, blog_entry_id required.
Returns parsed response from codeforces.com.
| blog_entry_view(blog_entry_id)
Get blogEntry.view for blog, blog_entry_id required.
Returns parsed response from codeforces.com.
| contest_hacks(contest_id)
Get contest.hacks for contest, contest_id required.
Returns parsed response from codeforces.com.
| contest_list(gym=False)
Get all contests you can get all gym by gym parameter.
Returns parsed response from codeforces.com
| contest_rating_changes(contest_id)
Get contest.ratingChanges for the contest, contest_id required.
Returns parsed response from codeforces.com.
| contest_standings(contest_id, start=-1, count=-1, handles=[""], room=-1, show_unofficial=False)
Get contest.standings for contest, contest_id required.
From is replaced with a start, because from is reserved python word.
count defines how many submits will be returned.
handles should be a list of handles to get (max 10000).
room is the number of the room which is needed.
show_unofficial is used for adding or removing not official participants.
Returns parsed response from codeforces.com.
| contest_status(contest_id, handle="", start=-1, count=-1)
Get contest.status for contest, contest_id required.
From is replaced with a start, because from is reserved python word.
count defines how many submits will be returned.
handle is used for specifying a user.
Returns parsed response from codeforces.com.
| problemset_problems(tags=[""], problemset_name="")
Get problemset.problems.
tags is a list of tags for tasks.
problemset_name is a string with an additional archive name. For example 'acmsguru'.
Returns parsed response from codeforces.com.
| problemset_recent_status(count, problemset_name="")
Get problemset.recentStatus.
count is the number of returned submits, up to 1000.
problemset_name is a string with an additional archive name.
For example 'acmsguru'.
Returns parsed response from codeforces.com.
| recent_actions(max_count=100)
Get recentActions.
max_count is the number of returned actions.
max_count should be less or equal to 100.
Returns parsed response from codeforces.com.
| user_blog_entries(handle)
Get user.blogEntries.
handle is required.
Returns parsed response from codeforces.com.
| user_friends(only_online=False)
Get user.friends.
Auth is required for this method, so create a class instance with api_key and secret.
only_online should be boolean.
Returns parsed response from codeforces.com.
| user_info(handles)
Get user.info.
handles should be a list of users, up to 10000.
Returns parsed response from codeforces.com.
| user_rated_list(active_only=False)
Get user.ratedList.
active_only is used to show only users, which participated last month.
Returns parsed response from codeforces.com.
| user_rating(handle)
Get user.rating.
handle should be a string.
Returns parsed response from codeforces.com.
| user_status(handle, start=-1, count=-1)
Get user.status.
handle is required.
From was replaced with a start because from is reserved python word.
count is the number of attempts to return.
Returns parsed response from codeforces.com.