Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
ModelAdminChecks._check_list_display
(self, obj)
Check that list_display only contains fields or usable attributes.
Check that list_display only contains fields or usable attributes.
def _check_list_display(self, obj): """ Check that list_display only contains fields or usable attributes. """ if not isinstance(obj.list_display, (list, tuple)): return must_be('a list or tuple', option='list_display', obj=obj, id='admin.E107') else: return list...
[ "def", "_check_list_display", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_display", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'list_display'",...
[ 590, 4 ]
[ 600, 15 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_display_links
(self, obj)
Check that list_display_links is a unique subset of list_display.
Check that list_display_links is a unique subset of list_display.
def _check_list_display_links(self, obj): """ Check that list_display_links is a unique subset of list_display. """ from django.contrib.admin.options import ModelAdmin if obj.list_display_links is None: return [] elif not isinstance(obj.list_display_links, (list, tup...
[ "def", "_check_list_display_links", "(", "self", ",", "obj", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "options", "import", "ModelAdmin", "if", "obj", ".", "list_display_links", "is", "None", ":", "return", "[", "]", "elif", "not", "is...
[ 657, 4 ]
[ 674, 17 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_filter_item
(self, obj, model, item, label)
Check one item of `list_filter`, i.e. check if it is one of three options: 1. 'field' -- a basic field filter, possibly w/ relationships (e.g. 'field__rel') 2. ('field', SomeFieldListFilter) - a field-based list filter class 3. SomeListFilter - a non-field list filter class ...
Check one item of `list_filter`, i.e. check if it is one of three options: 1. 'field' -- a basic field filter, possibly w/ relationships (e.g. 'field__rel') 2. ('field', SomeFieldListFilter) - a field-based list filter class 3. SomeListFilter - a non-field list filter class ...
def _check_list_filter_item(self, obj, model, item, label): """ Check one item of `list_filter`, i.e. check if it is one of three options: 1. 'field' -- a basic field filter, possibly w/ relationships (e.g. 'field__rel') 2. ('field', SomeFieldListFilter) - a field-based list f...
[ "def", "_check_list_filter_item", "(", "self", ",", "obj", ",", "model", ",", "item", ",", "label", ")", ":", "from", "django", ".", "contrib", ".", "admin", "import", "ListFilter", ",", "FieldListFilter", "if", "callable", "(", "item", ")", "and", "not", ...
[ 699, 4 ]
[ 749, 25 ]
python
en
['en', 'error', 'th']
False
ModelAdminChecks._check_list_select_related
(self, obj)
Check that list_select_related is a boolean, a list or a tuple.
Check that list_select_related is a boolean, a list or a tuple.
def _check_list_select_related(self, obj): """ Check that list_select_related is a boolean, a list or a tuple. """ if not isinstance(obj.list_select_related, (bool, list, tuple)): return must_be('a boolean, tuple or list', option='list_select_related', obj=obj, id='admin.E117') else...
[ "def", "_check_list_select_related", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_select_related", ",", "(", "bool", ",", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a boolean, tuple or list'", ","...
[ 751, 4 ]
[ 757, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_per_page
(self, obj)
Check that list_per_page is an integer.
Check that list_per_page is an integer.
def _check_list_per_page(self, obj): """ Check that list_per_page is an integer. """ if not isinstance(obj.list_per_page, int): return must_be('an integer', option='list_per_page', obj=obj, id='admin.E118') else: return []
[ "def", "_check_list_per_page", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_per_page", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", ",", "option", "=", "'list_per_page'", ",", "obj", "=", "obj", ...
[ 759, 4 ]
[ 765, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_max_show_all
(self, obj)
Check that list_max_show_all is an integer.
Check that list_max_show_all is an integer.
def _check_list_max_show_all(self, obj): """ Check that list_max_show_all is an integer. """ if not isinstance(obj.list_max_show_all, int): return must_be('an integer', option='list_max_show_all', obj=obj, id='admin.E119') else: return []
[ "def", "_check_list_max_show_all", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_max_show_all", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", ",", "option", "=", "'list_max_show_all'", ",", "obj", "=",...
[ 767, 4 ]
[ 773, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_editable
(self, obj)
Check that list_editable is a sequence of editable fields from list_display without first element.
Check that list_editable is a sequence of editable fields from list_display without first element.
def _check_list_editable(self, obj): """ Check that list_editable is a sequence of editable fields from list_display without first element. """ if not isinstance(obj.list_editable, (list, tuple)): return must_be('a list or tuple', option='list_editable', obj=obj, id='admin.E120') ...
[ "def", "_check_list_editable", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_editable", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'list_editable...
[ 775, 4 ]
[ 785, 15 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_search_fields
(self, obj)
Check search_fields is a sequence.
Check search_fields is a sequence.
def _check_search_fields(self, obj): """ Check search_fields is a sequence. """ if not isinstance(obj.search_fields, (list, tuple)): return must_be('a list or tuple', option='search_fields', obj=obj, id='admin.E126') else: return []
[ "def", "_check_search_fields", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "search_fields", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'search_fields...
[ 837, 4 ]
[ 843, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_date_hierarchy
(self, obj)
Check that date_hierarchy refers to DateField or DateTimeField.
Check that date_hierarchy refers to DateField or DateTimeField.
def _check_date_hierarchy(self, obj): """ Check that date_hierarchy refers to DateField or DateTimeField. """ if obj.date_hierarchy is None: return [] else: try: field = get_fields_from_path(obj.model, obj.date_hierarchy)[-1] except (NotRelati...
[ "def", "_check_date_hierarchy", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "date_hierarchy", "is", "None", ":", "return", "[", "]", "else", ":", "try", ":", "field", "=", "get_fields_from_path", "(", "obj", ".", "model", ",", "obj", ".", "dat...
[ 845, 4 ]
[ 866, 29 ]
python
en
['en', 'en', 'en']
True
InlineModelAdminChecks._check_extra
(self, obj)
Check that extra is an integer.
Check that extra is an integer.
def _check_extra(self, obj): """ Check that extra is an integer. """ if not isinstance(obj.extra, int): return must_be('an integer', option='extra', obj=obj, id='admin.E203') else: return []
[ "def", "_check_extra", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "extra", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", ",", "option", "=", "'extra'", ",", "obj", "=", "obj", ",", "id", "=", "'...
[ 919, 4 ]
[ 925, 21 ]
python
en
['en', 'en', 'en']
True
InlineModelAdminChecks._check_max_num
(self, obj)
Check that max_num is an integer.
Check that max_num is an integer.
def _check_max_num(self, obj): """ Check that max_num is an integer. """ if obj.max_num is None: return [] elif not isinstance(obj.max_num, int): return must_be('an integer', option='max_num', obj=obj, id='admin.E204') else: return []
[ "def", "_check_max_num", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "max_num", "is", "None", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "max_num", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", "...
[ 927, 4 ]
[ 935, 21 ]
python
en
['en', 'en', 'en']
True
InlineModelAdminChecks._check_min_num
(self, obj)
Check that min_num is an integer.
Check that min_num is an integer.
def _check_min_num(self, obj): """ Check that min_num is an integer. """ if obj.min_num is None: return [] elif not isinstance(obj.min_num, int): return must_be('an integer', option='min_num', obj=obj, id='admin.E205') else: return []
[ "def", "_check_min_num", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "min_num", "is", "None", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "min_num", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", "...
[ 937, 4 ]
[ 945, 21 ]
python
en
['en', 'en', 'en']
True
InlineModelAdminChecks._check_formset
(self, obj)
Check formset is a subclass of BaseModelFormSet.
Check formset is a subclass of BaseModelFormSet.
def _check_formset(self, obj): """ Check formset is a subclass of BaseModelFormSet. """ if not issubclass(obj.formset, BaseModelFormSet): return must_inherit_from(parent='BaseModelFormSet', option='formset', obj=obj, id='admin.E206') else: return []
[ "def", "_check_formset", "(", "self", ",", "obj", ")", ":", "if", "not", "issubclass", "(", "obj", ".", "formset", ",", "BaseModelFormSet", ")", ":", "return", "must_inherit_from", "(", "parent", "=", "'BaseModelFormSet'", ",", "option", "=", "'formset'", ",...
[ 947, 4 ]
[ 953, 21 ]
python
en
['en', 'en', 'en']
True
tostring
(element)
Serialize an element and its child nodes to a string
Serialize an element and its child nodes to a string
def tostring(element): """Serialize an element and its child nodes to a string""" rv = [] def serializeElement(element): if not hasattr(element, "tag"): if element.docinfo.internalDTD: if element.docinfo.doctype: dtd_str = element.docinfo.doctype ...
[ "def", "tostring", "(", "element", ")", ":", "rv", "=", "[", "]", "def", "serializeElement", "(", "element", ")", ":", "if", "not", "hasattr", "(", "element", ",", "\"tag\"", ")", ":", "if", "element", ".", "docinfo", ".", "internalDTD", ":", "if", "...
[ 143, 0 ]
[ 181, 22 ]
python
en
['en', 'en', 'en']
True
store_config
(config, dataset_id)
Store a config defined in d into the database. Args: config (dict): nested dict containing config, [section][key] -> [value]
Store a config defined in d into the database.
def store_config(config, dataset_id): """ Store a config defined in d into the database. Args: config (dict): nested dict containing config, [section][key] -> [value] """ logger.info("storing config to database for dataset %s" % dataset_id) error = "type of value %s, key %s in section %...
[ "def", "store_config", "(", "config", ",", "dataset_id", ")", ":", "logger", ".", "info", "(", "\"storing config to database for dataset %s\"", "%", "dataset_id", ")", "error", "=", "\"type of value %s, key %s in section %s has type %s, we only do %s\"", "for", "section", "...
[ 18, 0 ]
[ 40, 40 ]
python
en
['en', 'error', 'th']
False
fetch_config
(dataset_id)
Retrieve the stored config for given dataset id Returns: nested dict [section][key] -> [value]
Retrieve the stored config for given dataset id
def fetch_config(dataset_id): """ Retrieve the stored config for given dataset id Returns: nested dict [section][key] -> [value] """ logger.info("fetching config from database for dataset %s" % dataset_id) error = "type in database is %s but we only support %s" result = execute(fetc...
[ "def", "fetch_config", "(", "dataset_id", ")", ":", "logger", ".", "info", "(", "\"fetching config from database for dataset %s\"", "%", "dataset_id", ")", "error", "=", "\"type in database is %s but we only support %s\"", "result", "=", "execute", "(", "fetch_query", ","...
[ 48, 0 ]
[ 68, 17 ]
python
en
['en', 'error', 'th']
False
delete_selected
(modeladmin, request, queryset)
Default action which deletes the selected objects. This action first displays a confirmation page which shows all the deleteable objects, or, if the user has no permission one of the related childs (foreignkeys), a "permission denied" message. Next, it deletes all selected objects and redirects b...
Default action which deletes the selected objects.
def delete_selected(modeladmin, request, queryset): """ Default action which deletes the selected objects. This action first displays a confirmation page which shows all the deleteable objects, or, if the user has no permission one of the related childs (foreignkeys), a "permission denied" message....
[ "def", "delete_selected", "(", "modeladmin", ",", "request", ",", "queryset", ")", ":", "opts", "=", "modeladmin", ".", "model", ".", "_meta", "app_label", "=", "opts", ".", "app_label", "# Check that the user has delete permission for the actual model", "if", "not", ...
[ 14, 0 ]
[ 86, 15 ]
python
en
['en', 'error', 'th']
False
get_model_from_url_params
(app_name, model_name)
retrieve a content type from an app_name / model_name combo. Throw Http404 if not a valid setting type
retrieve a content type from an app_name / model_name combo. Throw Http404 if not a valid setting type
def get_model_from_url_params(app_name, model_name): """ retrieve a content type from an app_name / model_name combo. Throw Http404 if not a valid setting type """ model = registry.get_by_natural_key(app_name, model_name) if model is None: raise Http404 return model
[ "def", "get_model_from_url_params", "(", "app_name", ",", "model_name", ")", ":", "model", "=", "registry", ".", "get_by_natural_key", "(", "app_name", ",", "model_name", ")", "if", "model", "is", "None", ":", "raise", "Http404", "return", "model" ]
[ 19, 0 ]
[ 27, 16 ]
python
en
['en', 'error', 'th']
False
touch
(path)
Equivalent to linux's touch
Equivalent to linux's touch
def touch(path): """Equivalent to linux's touch""" with open(path, 'a'): os.utime(path, None) return path
[ "def", "touch", "(", "path", ")", ":", "with", "open", "(", "path", ",", "'a'", ")", ":", "os", ".", "utime", "(", "path", ",", "None", ")", "return", "path" ]
[ 1537, 0 ]
[ 1541, 15 ]
python
en
['en', 'en', 'it']
True
make_fake_zipdir
(dir_path, fakefile=None, base_dir=None, archive='zip', extension='.zip')
Creates a directory with a file in it if asked to, then compresses it
Creates a directory with a file in it if asked to, then compresses it
def make_fake_zipdir(dir_path, fakefile=None, base_dir=None, archive='zip', extension='.zip'): """Creates a directory with a file in it if asked to, then compresses it""" utils.mkdir(dir_path) if fakefile: touch(os.path.join(dir_path, fakefile)) shutil.make_archive(dir_path,...
[ "def", "make_fake_zipdir", "(", "dir_path", ",", "fakefile", "=", "None", ",", "base_dir", "=", "None", ",", "archive", "=", "'zip'", ",", "extension", "=", "'.zip'", ")", ":", "utils", ".", "mkdir", "(", "dir_path", ")", "if", "fakefile", ":", "touch", ...
[ 1544, 0 ]
[ 1551, 31 ]
python
en
['en', 'en', 'en']
True
PoolWorker.quit
(self)
Send a special control message to the worker that tells it to exit gracefully.
Send a special control message to the worker that tells it to exit gracefully.
def quit(self): """ Send a special control message to the worker that tells it to exit gracefully. """ self.queue.put('QUIT')
[ "def", "quit", "(", "self", ")", ":", "self", ".", "queue", ".", "put", "(", "'QUIT'", ")" ]
[ 91, 4 ]
[ 96, 30 ]
python
en
['en', 'error', 'th']
False
AutoscalePool.cleanup
(self)
Perform some internal account and cleanup. This is run on every cluster node heartbeat: 1. Discover worker processes that exited, and recover messages they were handling. 2. Clean up unnecessary, idle workers. 3. Check to see if the database says this node is ru...
Perform some internal account and cleanup. This is run on every cluster node heartbeat:
def cleanup(self): """ Perform some internal account and cleanup. This is run on every cluster node heartbeat: 1. Discover worker processes that exited, and recover messages they were handling. 2. Clean up unnecessary, idle workers. 3. Check to see if the...
[ "def", "cleanup", "(", "self", ")", ":", "orphaned", "=", "[", "]", "for", "w", "in", "self", ".", "workers", "[", ":", ":", "]", ":", "if", "not", "w", ".", "alive", ":", "# the worker process has exited", "# 1. take the task it was running and enqueue the er...
[ 350, 4 ]
[ 422, 49 ]
python
en
['en', 'error', 'th']
False
RateLimiterBackendBase.api_calls_left_from_history
( self, history: List[float], max_window: int, max_calls: int, now: float )
This depends on the algorithm used in the backend, and should be defined by the test class.
This depends on the algorithm used in the backend, and should be defined by the test class.
def api_calls_left_from_history( self, history: List[float], max_window: int, max_calls: int, now: float ) -> Tuple[int, float]: """ This depends on the algorithm used in the backend, and should be defined by the test class. """ raise NotImplementedError()
[ "def", "api_calls_left_from_history", "(", "self", ",", "history", ":", "List", "[", "float", "]", ",", "max_window", ":", "int", ",", "max_calls", ":", "int", ",", "now", ":", "float", ")", "->", "Tuple", "[", "int", ",", "float", "]", ":", "raise", ...
[ 85, 4 ]
[ 91, 35 ]
python
en
['en', 'error', 'th']
False
RedisRateLimiterBackendTest.test_block_access
(self)
This test cannot verify that the user will get unblocked after the correct amount of time, because that event happens inside Redis, so we're not able to mock the timer. Making the test sleep for 1s is also too costly to be worth it.
This test cannot verify that the user will get unblocked after the correct amount of time, because that event happens inside Redis, so we're not able to mock the timer. Making the test sleep for 1s is also too costly to be worth it.
def test_block_access(self) -> None: """ This test cannot verify that the user will get unblocked after the correct amount of time, because that event happens inside Redis, so we're not able to mock the timer. Making the test sleep for 1s is also too costly to be worth it. ...
[ "def", "test_block_access", "(", "self", ")", "->", "None", ":", "obj", "=", "self", ".", "create_object", "(", "\"test\"", ",", "[", "(", "2", ",", "5", ")", "]", ")", "obj", ".", "block_access", "(", "1", ")", "self", ".", "make_request", "(", "o...
[ 164, 4 ]
[ 174, 84 ]
python
en
['en', 'error', 'th']
False
staff_member_required
(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url='admin:login')
Decorator for views that checks that the user is logged in and is a staff member, redirecting to the login page if necessary.
Decorator for views that checks that the user is logged in and is a staff member, redirecting to the login page if necessary.
def staff_member_required(view_func=None, redirect_field_name=REDIRECT_FIELD_NAME, login_url='admin:login'): """ Decorator for views that checks that the user is logged in and is a staff member, redirecting to the login page if necessary. """ actual_decorator = user_passes_...
[ "def", "staff_member_required", "(", "view_func", "=", "None", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "login_url", "=", "'admin:login'", ")", ":", "actual_decorator", "=", "user_passes_test", "(", "lambda", "u", ":", "u", ".", "is_active", "a...
[ 4, 0 ]
[ 17, 27 ]
python
en
['en', 'error', 'th']
False
launch_experiment
(conf_est, conf_sim, observations, exp_prefix, n_mc_samples=10**6, n_x_cond=10, n_seeds=5, tail_measures=False)
:param conf_est: Dict with keys: Name of estimator, value: params for the estimator :param conf_sim: Dict with keys: Name of the density simulator, value: params for the simulator :param observations: List or scalar that defines how many samples to use from the distribution :param exp_prefix: directory...
:param conf_est: Dict with keys: Name of estimator, value: params for the estimator :param conf_sim: Dict with keys: Name of the density simulator, value: params for the simulator :param observations: List or scalar that defines how many samples to use from the distribution :param exp_prefix: directory...
def launch_experiment(conf_est, conf_sim, observations, exp_prefix, n_mc_samples=10**6, n_x_cond=10, n_seeds=5, tail_measures=False): """ :param conf_est: Dict with keys: Name of estimator, value: params for the estimator :param conf_sim: Dict with keys: Name of the density simulator, value: params for the ...
[ "def", "launch_experiment", "(", "conf_est", ",", "conf_sim", ",", "observations", ",", "exp_prefix", ",", "n_mc_samples", "=", "10", "**", "6", ",", "n_x_cond", "=", "10", ",", "n_seeds", "=", "5", ",", "tail_measures", "=", "False", ")", ":", "parser", ...
[ 26, 0 ]
[ 55, 20 ]
python
en
['en', 'error', 'th']
False
launch_logprob_experiment
(conf_est, conf_sim, observations, exp_prefix, n_test_samples=10**5, n_seeds=5)
:param conf_est: Dict with keys: Name of estimator, value: params for the estimator :param conf_sim: Dict with keys: Name of the density simulator, value: params for the simulator :param observations: List or scalar that defines how many samples to use from the distribution :param exp_prefix: directory...
:param conf_est: Dict with keys: Name of estimator, value: params for the estimator :param conf_sim: Dict with keys: Name of the density simulator, value: params for the simulator :param observations: List or scalar that defines how many samples to use from the distribution :param exp_prefix: directory...
def launch_logprob_experiment(conf_est, conf_sim, observations, exp_prefix, n_test_samples=10**5, n_seeds=5): """ :param conf_est: Dict with keys: Name of estimator, value: params for the estimator :param conf_sim: Dict with keys: Name of the density simulator, value: params for the simulator :param obs...
[ "def", "launch_logprob_experiment", "(", "conf_est", ",", "conf_sim", ",", "observations", ",", "exp_prefix", ",", "n_test_samples", "=", "10", "**", "5", ",", "n_seeds", "=", "5", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description",...
[ 58, 0 ]
[ 82, 20 ]
python
en
['en', 'error', 'th']
False
RemoteUserMiddleware.clean_username
(self, username, request)
Allows the backend to clean the username, if the backend defines a clean_username method.
Allows the backend to clean the username, if the backend defines a clean_username method.
def clean_username(self, username, request): """ Allows the backend to clean the username, if the backend defines a clean_username method. """ backend_str = request.session[auth.BACKEND_SESSION_KEY] backend = auth.load_backend(backend_str) try: usernam...
[ "def", "clean_username", "(", "self", ",", "username", ",", "request", ")", ":", "backend_str", "=", "request", ".", "session", "[", "auth", ".", "BACKEND_SESSION_KEY", "]", "backend", "=", "auth", ".", "load_backend", "(", "backend_str", ")", "try", ":", ...
[ 97, 4 ]
[ 108, 23 ]
python
en
['en', 'error', 'th']
False
RemoteUserMiddleware._remove_invalid_user
(self, request)
Removes the current authenticated user in the request which is invalid but only if the user is authenticated via the RemoteUserBackend.
Removes the current authenticated user in the request which is invalid but only if the user is authenticated via the RemoteUserBackend.
def _remove_invalid_user(self, request): """ Removes the current authenticated user in the request which is invalid but only if the user is authenticated via the RemoteUserBackend. """ try: stored_backend = load_backend(request.session.get(auth.BACKEND_SESSION_KEY, ''...
[ "def", "_remove_invalid_user", "(", "self", ",", "request", ")", ":", "try", ":", "stored_backend", "=", "load_backend", "(", "request", ".", "session", ".", "get", "(", "auth", ".", "BACKEND_SESSION_KEY", ",", "''", ")", ")", "except", "ImportError", ":", ...
[ 110, 4 ]
[ 122, 36 ]
python
en
['en', 'error', 'th']
False
get_site_for_hostname
(hostname, port)
Return the wagtailcore.Site object for the given hostname and port.
Return the wagtailcore.Site object for the given hostname and port.
def get_site_for_hostname(hostname, port): """Return the wagtailcore.Site object for the given hostname and port.""" Site = apps.get_model('wagtailcore.Site') sites = list(Site.objects.annotate(match=Case( # annotate the results by best choice descending # put exact hostname+port match fir...
[ "def", "get_site_for_hostname", "(", "hostname", ",", "port", ")", ":", "Site", "=", "apps", ".", "get_model", "(", "'wagtailcore.Site'", ")", "sites", "=", "list", "(", "Site", ".", "objects", ".", "annotate", "(", "match", "=", "Case", "(", "# annotate t...
[ 10, 0 ]
[ 49, 29 ]
python
en
['en', 'en', 'en']
True
Scenario._BuildScenarioConfig
(self)
Builds scenario config from gfootball.environment config.
Builds scenario config from gfootball.environment config.
def _BuildScenarioConfig(self): """Builds scenario config from gfootball.environment config.""" self._scenario_cfg.real_time = self._config['real_time'] self._scenario_cfg.left_agents = self._config.number_of_left_players() self._scenario_cfg.right_agents = self._config.number_of_right_players() # T...
[ "def", "_BuildScenarioConfig", "(", "self", ")", ":", "self", ".", "_scenario_cfg", ".", "real_time", "=", "self", ".", "_config", "[", "'real_time'", "]", "self", ".", "_scenario_cfg", ".", "left_agents", "=", "self", ".", "_config", ".", "number_of_left_play...
[ 72, 2 ]
[ 97, 50 ]
python
en
['en', 'gl', 'en']
True
Scenario.AddPlayer
(self, x, y, role, lazy=False, controllable=True)
Build player for the current scenario. Args: x: x coordinate of the player in the range [-1, 1]. y: y coordinate of the player in the range [-0.42, 0.42]. role: Player's role in the game (goal keeper etc.). lazy: Computer doesn't perform any automatic actions for lazy player. controll...
Build player for the current scenario.
def AddPlayer(self, x, y, role, lazy=False, controllable=True): """Build player for the current scenario. Args: x: x coordinate of the player in the range [-1, 1]. y: y coordinate of the player in the range [-0.42, 0.42]. role: Player's role in the game (goal keeper etc.). lazy: Compute...
[ "def", "AddPlayer", "(", "self", ",", "x", ",", "y", ",", "role", ",", "lazy", "=", "False", ",", "controllable", "=", "True", ")", ":", "player", "=", "Player", "(", "x", ",", "y", ",", "role", ",", "lazy", ",", "controllable", ")", "if", "self"...
[ 105, 2 ]
[ 119, 50 ]
python
en
['en', 'en', 'en']
True
TrelloHookTests.test_ignored_card_actions
(self)
Certain card-related actions are now ignored solely based on the action type, and we don't need to do any other parsing to ignore them as invalid.
Certain card-related actions are now ignored solely based on the action type, and we don't need to do any other parsing to ignore them as invalid.
def test_ignored_card_actions(self) -> None: """ Certain card-related actions are now ignored solely based on the action type, and we don't need to do any other parsing to ignore them as invalid. """ actions = [ "copyCard", "createCheckItem", ...
[ "def", "test_ignored_card_actions", "(", "self", ")", "->", "None", ":", "actions", "=", "[", "\"copyCard\"", ",", "\"createCheckItem\"", ",", "\"updateCheckItem\"", ",", "\"updateList\"", ",", "]", "for", "action", "in", "actions", ":", "data", "=", "dict", "...
[ 127, 4 ]
[ 147, 48 ]
python
en
['en', 'error', 'th']
False
read_gmip_data
(gdir, area_path=None, thick_path=None, width_path=None)
Read area, thick and width data from the GlacierMIP files. Also converts areas to m2. Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the glacier directory to process area_path : str the path to the area bins file thick_path : str the path to the thickess...
Read area, thick and width data from the GlacierMIP files.
def read_gmip_data(gdir, area_path=None, thick_path=None, width_path=None): """Read area, thick and width data from the GlacierMIP files. Also converts areas to m2. Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the glacier directory to process area_path : str t...
[ "def", "read_gmip_data", "(", "gdir", ",", "area_path", "=", "None", ",", "thick_path", "=", "None", ",", "width_path", "=", "None", ")", ":", "keys", "=", "[", "'area'", ",", "'thick'", ",", "'width'", "]", "paths", "=", "[", "area_path", ",", "thick_...
[ 18, 0 ]
[ 59, 14 ]
python
en
['en', 'en', 'en']
True
present_time_glacier_from_bins
(gdir, data=None, area_path=None, thick_path=None, width_path=None)
Generates a flowline object from binned data in the glacierMIP format. Parameters ---------- gdir : :py:class:`oggm.GlacierDirectory` the glacier directory to process data : pd.Dataframe a dataframe with the 'area', 'thick', 'width' columns and the elevation as index. If not pro...
Generates a flowline object from binned data in the glacierMIP format.
def present_time_glacier_from_bins(gdir, data=None, area_path=None, thick_path=None, width_path=None): """Generates a flowline object from binned data in the glacierMIP format. Parameters ---------- ...
[ "def", "present_time_glacier_from_bins", "(", "gdir", ",", "data", "=", "None", ",", "area_path", "=", "None", ",", "thick_path", "=", "None", ",", "width_path", "=", "None", ")", ":", "if", "data", "is", "None", ":", "data", "=", "read_gmip_data", "(", ...
[ 63, 0 ]
[ 120, 16 ]
python
en
['en', 'fy', 'nl']
False
addScriptOptions
(parser, pos_args, kw_args)
add script-specific script options
add script-specific script options
def addScriptOptions(parser, pos_args, kw_args): """ add script-specific script options """ script_options_group = parser.add_argument_group('Options') hlpstr = "Prefix string for output filenames. Can optionally include a " \ "full path. Defaults to the input filename." opti...
[ "def", "addScriptOptions", "(", "parser", ",", "pos_args", ",", "kw_args", ")", ":", "script_options_group", "=", "parser", ".", "add_argument_group", "(", "'Options'", ")", "hlpstr", "=", "\"Prefix string for output filenames. Can optionally include a \"", "\"full path. De...
[ 94, 0 ]
[ 130, 37 ]
python
en
['en', 'it', 'en']
True
parseBam
(thisbam, region=None, LOG_EVERY_N=10000)
parses a bam file gathering statistics Returns a dictionary of various gathered statistics.
parses a bam file gathering statistics Returns a dictionary of various gathered statistics.
def parseBam(thisbam, region=None, LOG_EVERY_N=10000): """parses a bam file gathering statistics Returns a dictionary of various gathered statistics.""" if type(thisbam) is str: thisbam = pysam.AlignmentFile(args.infile, "rb") refs = thisbam.references read_lengths={} ...
[ "def", "parseBam", "(", "thisbam", ",", "region", "=", "None", ",", "LOG_EVERY_N", "=", "10000", ")", ":", "if", "type", "(", "thisbam", ")", "is", "str", ":", "thisbam", "=", "pysam", ".", "AlignmentFile", "(", "args", ".", "infile", ",", "\"rb\"", ...
[ 132, 0 ]
[ 226, 55 ]
python
en
['en', 'en', 'en']
True
plotReadLengthHist
(stats_data, binwidth=20, alpha=0.5, figsize=(12,8), fileout=None)
plot the read length histograms
plot the read length histograms
def plotReadLengthHist(stats_data, binwidth=20, alpha=0.5, figsize=(12,8), fileout=None): """ plot the read length histograms """ fig = plt.figure(figsize=figsize) common_params = dict( bins=numpy.arange(0, max(stats_data["aligned_lengths"])+binwidth, binwidth), ...
[ "def", "plotReadLengthHist", "(", "stats_data", ",", "binwidth", "=", "20", ",", "alpha", "=", "0.5", ",", "figsize", "=", "(", "12", ",", "8", ")", ",", "fileout", "=", "None", ")", ":", "fig", "=", "plt", ".", "figure", "(", "figsize", "=", "figs...
[ 228, 0 ]
[ 250, 15 ]
python
en
['en', 'mg', 'en']
True
plotLengthDensity
(stats_data, gridsize=100, cmap="Greens", figsize=(16,12), fileout=None)
plot the read length histograms
plot the read length histograms
def plotLengthDensity(stats_data, gridsize=100, cmap="Greens", figsize=(16,12), fileout=None): """ plot the read length histograms """ fig = plt.figure(figsize=figsize) plt.hexbin(stats_data["aligned_lengths"], stats_data["read_lengths"], gridsize=gridsize, xscale="log", ys...
[ "def", "plotLengthDensity", "(", "stats_data", ",", "gridsize", "=", "100", ",", "cmap", "=", "\"Greens\"", ",", "figsize", "=", "(", "16", ",", "12", ")", ",", "fileout", "=", "None", ")", ":", "fig", "=", "plt", ".", "figure", "(", "figsize", "=", ...
[ 252, 0 ]
[ 274, 15 ]
python
en
['en', 'mg', 'en']
True
plotSkipLengthHist
(stats_data, binwidth=20, alpha=1.0, figsize=(12,8), fileout=None)
plot the read length histograms
plot the read length histograms
def plotSkipLengthHist(stats_data, binwidth=20, alpha=1.0, figsize=(12,8), fileout=None): """ plot the read length histograms """ fig = plt.figure(figsize=(12,8)) common_params = dict( bins=numpy.arange(0, max(stats_data["3p_end_skips"])+binwidth, binwidth), ...
[ "def", "plotSkipLengthHist", "(", "stats_data", ",", "binwidth", "=", "20", ",", "alpha", "=", "1.0", ",", "figsize", "=", "(", "12", ",", "8", ")", ",", "fileout", "=", "None", ")", ":", "fig", "=", "plt", ".", "figure", "(", "figsize", "=", "(", ...
[ 276, 0 ]
[ 302, 15 ]
python
en
['en', 'mg', 'en']
True
annotCount
(annot_filename, bam_file, feature="genes", annot_fmt="gtf", LOG_EVERY_N=10000)
count the number of reads mapping to each feature
count the number of reads mapping to each feature
def annotCount(annot_filename, bam_file, feature="genes", annot_fmt="gtf", LOG_EVERY_N=10000): """ count the number of reads mapping to each feature """ # load annotation print "loading annotation..." annot = annotation(annot_filename, filetype=annot_fmt) annot.set_feature(feature) afe...
[ "def", "annotCount", "(", "annot_filename", ",", "bam_file", ",", "feature", "=", "\"genes\"", ",", "annot_fmt", "=", "\"gtf\"", ",", "LOG_EVERY_N", "=", "10000", ")", ":", "# load annotation", "print", "\"loading annotation...\"", "annot", "=", "annotation", "(",...
[ 304, 0 ]
[ 370, 18 ]
python
en
['en', 'en', 'en']
True
plotAnnotCountvCov
(counts, log=True, bins=50, feature_label="genes", cmap="Greens", figsize=(12,8), fileout=None)
plots the counts vs the fractional coverage for a dataset uses output from annotCount.
plots the counts vs the fractional coverage for a dataset uses output from annotCount.
def plotAnnotCountvCov(counts, log=True, bins=50, feature_label="genes", cmap="Greens", figsize=(12,8), fileout=None): """plots the counts vs the fractional coverage for a dataset uses output from annotCount. """ fig = plt.figure(figsize=figsize) ind = num...
[ "def", "plotAnnotCountvCov", "(", "counts", ",", "log", "=", "True", ",", "bins", "=", "50", ",", "feature_label", "=", "\"genes\"", ",", "cmap", "=", "\"Greens\"", ",", "figsize", "=", "(", "12", ",", "8", ")", ",", "fileout", "=", "None", ")", ":",...
[ 372, 0 ]
[ 397, 15 ]
python
en
['en', 'en', 'en']
True
plotAnnotCountScatter
(counts1, counts2, c1label="", c2label="", log=True, xylog=True, bins=50, feature_label="genes", figsize=(10,8), fileout=None)
plots the read counts for two datasets for the same annotation uses output from annotCount. Make sure the same annotation was used to generate both sets of counts - that way things will all be in the right order
plots the read counts for two datasets for the same annotation uses output from annotCount. Make sure the same annotation was used to generate both sets of counts - that way things will all be in the right order
def plotAnnotCountScatter(counts1, counts2, c1label="", c2label="", log=True, xylog=True, bins=50, feature_label="genes", figsize=(10,8), fileout=None): """plots the read counts for two datasets for the same annotation uses output from annotCount. Ma...
[ "def", "plotAnnotCountScatter", "(", "counts1", ",", "counts2", ",", "c1label", "=", "\"\"", ",", "c2label", "=", "\"\"", ",", "log", "=", "True", ",", "xylog", "=", "True", ",", "bins", "=", "50", ",", "feature_label", "=", "\"genes\"", ",", "figsize", ...
[ 399, 0 ]
[ 439, 15 ]
python
en
['en', 'en', 'en']
True
plotAnnotCovScatter
(counts1, counts2, c1label="", c2label="", log=True, bins=50, feature_label="genes", figsize=(10,8), fileout=None)
plots the fractional read coverage for two datasets for the same annotation uses output from annotCount. Make sure the same annotation was used to generate both sets of counts - that way things will all be in the right order
plots the fractional read coverage for two datasets for the same annotation uses output from annotCount. Make sure the same annotation was used to generate both sets of counts - that way things will all be in the right order
def plotAnnotCovScatter(counts1, counts2, c1label="", c2label="", log=True, bins=50, feature_label="genes", figsize=(10,8), fileout=None): """plots the fractional read coverage for two datasets for the same annotation uses output from annotCount. Make su...
[ "def", "plotAnnotCovScatter", "(", "counts1", ",", "counts2", ",", "c1label", "=", "\"\"", ",", "c2label", "=", "\"\"", ",", "log", "=", "True", ",", "bins", "=", "50", ",", "feature_label", "=", "\"genes\"", ",", "figsize", "=", "(", "10", ",", "8", ...
[ 441, 0 ]
[ 465, 15 ]
python
en
['en', 'en', 'en']
True
GatlingExecutor.check
(self)
Checks if tool is still running. Also checks if resulting logs contains any data and throws exception otherwise. :return: bool :raise TaurusConfigError: :raise TaurusToolError:
Checks if tool is still running. Also checks if resulting logs contains any data and throws exception otherwise.
def check(self): """ Checks if tool is still running. Also checks if resulting logs contains any data and throws exception otherwise. :return: bool :raise TaurusConfigError: :raise TaurusToolError: """ self.retcode = self.process.poll() # detect ...
[ "def", "check", "(", "self", ")", ":", "self", ".", "retcode", "=", "self", ".", "process", ".", "poll", "(", ")", "# detect interactive mode and raise exception if it found", "if", "not", "self", ".", "simulation_started", ":", "wrong_line", "=", "\"Choose a simu...
[ 405, 4 ]
[ 434, 118 ]
python
en
['en', 'error', 'th']
False
GatlingExecutor.shutdown
(self)
If tool is still running - let's stop it.
If tool is still running - let's stop it.
def shutdown(self): """ If tool is still running - let's stop it. """ shutdown_process(self.process, self.log) if self.start_time: self.end_time = time.time() self.log.debug("Gatling worked for %s seconds", self.end_time - self.start_time)
[ "def", "shutdown", "(", "self", ")", ":", "shutdown_process", "(", "self", ".", "process", ",", "self", ".", "log", ")", "if", "self", ".", "start_time", ":", "self", ".", "end_time", "=", "time", ".", "time", "(", ")", "self", ".", "log", ".", "de...
[ 436, 4 ]
[ 444, 92 ]
python
en
['en', 'error', 'th']
False
GatlingExecutor.post_process
(self)
Save data log as artifact
Save data log as artifact
def post_process(self): """ Save data log as artifact """ if self.reader and self.reader.file and self.reader.file.name: self.engine.existing_artifact(self.reader.file.name) super(GatlingExecutor, self).post_process()
[ "def", "post_process", "(", "self", ")", ":", "if", "self", ".", "reader", "and", "self", ".", "reader", ".", "file", "and", "self", ".", "reader", ".", "file", ".", "name", ":", "self", ".", "engine", ".", "existing_artifact", "(", "self", ".", "rea...
[ 446, 4 ]
[ 452, 51 ]
python
en
['en', 'error', 'th']
False
DataLogReader._extract_log
(self, fields)
Extract stats from Gatling format of version 3.1 and after :param fields: :return:
Extract stats from Gatling format of version 3.1 and after :param fields: :return:
def _extract_log(self, fields): """ Extract stats from Gatling format of version 3.1 and after :param fields: :return: """ # 0 ${RequestRecordHeader.value} # 1 $scenario # -|2 $userId, absent in Gatling 3.4+ # 2 ${serializeGroups(groupHierarchy)} ...
[ "def", "_extract_log", "(", "self", ",", "fields", ")", ":", "# 0 ${RequestRecordHeader.value}", "# 1 $scenario", "# -|2 $userId, absent in Gatling 3.4+", "# 2 ${serializeGroups(groupHierarchy)}", "# 3 $label", "# 4 $startTimestamp", "# 5 $endTimestamp", "# 6 $status", "# [7] ${seria...
[ 520, 4 ]
[ 551, 23 ]
python
en
['en', 'error', 'th']
False
DataLogReader._read
(self, last_pass=False)
Generator method that returns next portion of data :param last_pass:
Generator method that returns next portion of data
def _read(self, last_pass=False): """ Generator method that returns next portion of data :param last_pass: """ lines = self.file.get_lines(size=1024 * 1024, last_pass=last_pass) for line in lines: if not line.endswith("\n"): self.partial_buff...
[ "def", "_read", "(", "self", ",", "last_pass", "=", "False", ")", ":", "lines", "=", "self", ".", "file", ".", "get_lines", "(", "size", "=", "1024", "*", "1024", ",", "last_pass", "=", "last_pass", ")", "for", "line", "in", "lines", ":", "if", "no...
[ 641, 4 ]
[ 666, 109 ]
python
en
['en', 'error', 'th']
False
DataLogReader.open_fds
(self, filename)
open gatling simulation.log
open gatling simulation.log
def open_fds(self, filename): """ open gatling simulation.log """ if os.path.isdir(self.basedir): prog = re.compile("^%s-[0-9]+$" % self.dir_prefix) for fname in os.listdir(self.basedir): if prog.match(fname): filename = os.pat...
[ "def", "open_fds", "(", "self", ",", "filename", ")", ":", "if", "os", ".", "path", ".", "isdir", "(", "self", ".", "basedir", ")", ":", "prog", "=", "re", ".", "compile", "(", "\"^%s-[0-9]+$\"", "%", "self", ".", "dir_prefix", ")", "for", "fname", ...
[ 668, 4 ]
[ 692, 39 ]
python
en
['en', 'error', 'th']
False
MigrationOptimizer.optimize
(self, operations, app_label=None)
Main optimization entry point. Pass in a list of Operation instances, get out a new list of Operation instances. Unfortunately, due to the scope of the optimization (two combinable operations might be separated by several hundred others), this can't be done as a peephole optimi...
Main optimization entry point. Pass in a list of Operation instances, get out a new list of Operation instances.
def optimize(self, operations, app_label=None): """ Main optimization entry point. Pass in a list of Operation instances, get out a new list of Operation instances. Unfortunately, due to the scope of the optimization (two combinable operations might be separated by several hundr...
[ "def", "optimize", "(", "self", ",", "operations", ",", "app_label", "=", "None", ")", ":", "# Internal tracking variable for test assertions about # of loops", "self", ".", "_iterations", "=", "0", "while", "True", ":", "result", "=", "self", ".", "optimize_inner",...
[ 14, 4 ]
[ 41, 31 ]
python
en
['en', 'error', 'th']
False
MigrationOptimizer.optimize_inner
(self, operations, app_label=None)
Inner optimization loop.
Inner optimization loop.
def optimize_inner(self, operations, app_label=None): """ Inner optimization loop. """ new_operations = [] for i, operation in enumerate(operations): # Compare it to each operation after it for j, other in enumerate(operations[i + 1:]): in_...
[ "def", "optimize_inner", "(", "self", ",", "operations", ",", "app_label", "=", "None", ")", ":", "new_operations", "=", "[", "]", "for", "i", ",", "operation", "in", "enumerate", "(", "operations", ")", ":", "# Compare it to each operation after it", "for", "...
[ 43, 4 ]
[ 65, 29 ]
python
en
['en', 'error', 'th']
False
is_connection_dropped
(conn)
Returns True if the connection is dropped and should be closed. :param conn: :class:`http.client.HTTPConnection` object. Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection recycling transparently for us.
Returns True if the connection is dropped and should be closed.
def is_connection_dropped(conn): # Platform-specific """ Returns True if the connection is dropped and should be closed. :param conn: :class:`http.client.HTTPConnection` object. Note: For platforms like AppEngine, this will always return ``False`` to let the platform handle connection rec...
[ "def", "is_connection_dropped", "(", "conn", ")", ":", "# Platform-specific", "sock", "=", "getattr", "(", "conn", ",", "\"sock\"", ",", "False", ")", "if", "sock", "is", "False", ":", "# Platform-specific: AppEngine", "return", "False", "if", "sock", "is", "N...
[ 11, 0 ]
[ 30, 20 ]
python
en
['en', 'error', 'th']
False
create_connection
( address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, socket_options=None, )
Connect to *address* and return the socket object. Convenience function. Connect to *address* (a 2-tuple ``(host, port)``) and return the socket object. Passing the optional *timeout* parameter will set the timeout on the socket instance before attempting to connect. If no *timeout* is supplied, the...
Connect to *address* and return the socket object.
def create_connection( address, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, source_address=None, socket_options=None, ): """Connect to *address* and return the socket object. Convenience function. Connect to *address* (a 2-tuple ``(host, port)``) and return the socket object. Passing the opti...
[ "def", "create_connection", "(", "address", ",", "timeout", "=", "socket", ".", "_GLOBAL_DEFAULT_TIMEOUT", ",", "source_address", "=", "None", ",", "socket_options", "=", "None", ",", ")", ":", "host", ",", "port", "=", "address", "if", "host", ".", "startsw...
[ 37, 0 ]
[ 97, 59 ]
python
en
['en', 'en', 'en']
True
allowed_gai_family
()
This function is designed to work in the context of getaddrinfo, where family=socket.AF_UNSPEC is the default and will perform a DNS search for both IPv6 and IPv4 records.
This function is designed to work in the context of getaddrinfo, where family=socket.AF_UNSPEC is the default and will perform a DNS search for both IPv6 and IPv4 records.
def allowed_gai_family(): """This function is designed to work in the context of getaddrinfo, where family=socket.AF_UNSPEC is the default and will perform a DNS search for both IPv6 and IPv4 records.""" family = socket.AF_INET if HAS_IPV6: family = socket.AF_UNSPEC return family
[ "def", "allowed_gai_family", "(", ")", ":", "family", "=", "socket", ".", "AF_INET", "if", "HAS_IPV6", ":", "family", "=", "socket", ".", "AF_UNSPEC", "return", "family" ]
[ 108, 0 ]
[ 116, 17 ]
python
en
['en', 'en', 'en']
True
_has_ipv6
(host)
Returns True if the system can bind an IPv6 address.
Returns True if the system can bind an IPv6 address.
def _has_ipv6(host): """ Returns True if the system can bind an IPv6 address. """ sock = None has_ipv6 = False # App Engine doesn't support IPV6 sockets and actually has a quota on the # number of sockets that can be used, so just early out here instead of # creating a socket needlessly. # ...
[ "def", "_has_ipv6", "(", "host", ")", ":", "sock", "=", "None", "has_ipv6", "=", "False", "# App Engine doesn't support IPV6 sockets and actually has a quota on the", "# number of sockets that can be used, so just early out here instead of", "# creating a socket needlessly.", "# See ht...
[ 119, 0 ]
[ 146, 19 ]
python
en
['en', 'lb', 'en']
True
SimplerXMLGenerator.addQuickElement
(self, name, contents=None, attrs=None)
Convenience method for adding an element with no children
Convenience method for adding an element with no children
def addQuickElement(self, name, contents=None, attrs=None): "Convenience method for adding an element with no children" if attrs is None: attrs = {} self.startElement(name, attrs) if contents is not None: self.characters(contents) self.endElement(name)
[ "def", "addQuickElement", "(", "self", ",", "name", ",", "contents", "=", "None", ",", "attrs", "=", "None", ")", ":", "if", "attrs", "is", "None", ":", "attrs", "=", "{", "}", "self", ".", "startElement", "(", "name", ",", "attrs", ")", "if", "con...
[ 13, 4 ]
[ 20, 29 ]
python
en
['en', 'en', 'en']
True
TestGetDocumentModel.test_custom_get_document_model
(self)
Test get_document_model with a custom document model
Test get_document_model with a custom document model
def test_custom_get_document_model(self): """Test get_document_model with a custom document model""" self.assertIs(get_document_model(), CustomDocument)
[ "def", "test_custom_get_document_model", "(", "self", ")", ":", "self", ".", "assertIs", "(", "get_document_model", "(", ")", ",", "CustomDocument", ")" ]
[ 230, 4 ]
[ 232, 59 ]
python
en
['en', 'en', 'en']
True
TestGetDocumentModel.test_custom_get_document_model_string
(self)
Test get_document_model_string with a custom document model
Test get_document_model_string with a custom document model
def test_custom_get_document_model_string(self): """Test get_document_model_string with a custom document model""" self.assertEqual(get_document_model_string(), 'tests.CustomDocument')
[ "def", "test_custom_get_document_model_string", "(", "self", ")", ":", "self", ".", "assertEqual", "(", "get_document_model_string", "(", ")", ",", "'tests.CustomDocument'", ")" ]
[ 235, 4 ]
[ 237, 77 ]
python
en
['en', 'en', 'en']
True
TestGetDocumentModel.test_standard_get_document_model
(self)
Test get_document_model with no WAGTAILDOCS_DOCUMENT_MODEL
Test get_document_model with no WAGTAILDOCS_DOCUMENT_MODEL
def test_standard_get_document_model(self): """Test get_document_model with no WAGTAILDOCS_DOCUMENT_MODEL""" del settings.WAGTAILDOCS_DOCUMENT_MODEL from wagtail.documents.models import Document self.assertIs(get_document_model(), Document)
[ "def", "test_standard_get_document_model", "(", "self", ")", ":", "del", "settings", ".", "WAGTAILDOCS_DOCUMENT_MODEL", "from", "wagtail", ".", "documents", ".", "models", "import", "Document", "self", ".", "assertIs", "(", "get_document_model", "(", ")", ",", "Do...
[ 240, 4 ]
[ 244, 53 ]
python
en
['en', 'en', 'sw']
True
TestGetDocumentModel.test_standard_get_document_model_string
(self)
Test get_document_model_string with no WAGTAILDOCS_DOCUMENT_MODEL
Test get_document_model_string with no WAGTAILDOCS_DOCUMENT_MODEL
def test_standard_get_document_model_string(self): """Test get_document_model_string with no WAGTAILDOCS_DOCUMENT_MODEL""" del settings.WAGTAILDOCS_DOCUMENT_MODEL self.assertEqual(get_document_model_string(), 'wagtaildocs.Document')
[ "def", "test_standard_get_document_model_string", "(", "self", ")", ":", "del", "settings", ".", "WAGTAILDOCS_DOCUMENT_MODEL", "self", ".", "assertEqual", "(", "get_document_model_string", "(", ")", ",", "'wagtaildocs.Document'", ")" ]
[ 247, 4 ]
[ 250, 77 ]
python
en
['en', 'en', 'sw']
True
TestGetDocumentModel.test_unknown_get_document_model
(self)
Test get_document_model with an unknown model
Test get_document_model with an unknown model
def test_unknown_get_document_model(self): """Test get_document_model with an unknown model""" with self.assertRaises(ImproperlyConfigured): get_document_model()
[ "def", "test_unknown_get_document_model", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "get_document_model", "(", ")" ]
[ 253, 4 ]
[ 256, 32 ]
python
en
['en', 'en', 'en']
True
TestGetDocumentModel.test_invalid_get_document_model
(self)
Test get_document_model with an invalid model string
Test get_document_model with an invalid model string
def test_invalid_get_document_model(self): """Test get_document_model with an invalid model string""" with self.assertRaises(ImproperlyConfigured): get_document_model()
[ "def", "test_invalid_get_document_model", "(", "self", ")", ":", "with", "self", ".", "assertRaises", "(", "ImproperlyConfigured", ")", ":", "get_document_model", "(", ")" ]
[ 259, 4 ]
[ 262, 32 ]
python
en
['en', 'en', 'en']
True
replace_assignees_username_with_name
(assignees: List[Dict[str, str]])
Replace the username of each assignee with their (full) name. This is a hack-like adaptor so that when assignees are passed to `get_pull_request_event_message` we can use the assignee's name and not their username (for more consistency).
Replace the username of each assignee with their (full) name.
def replace_assignees_username_with_name(assignees: List[Dict[str, str]]) -> List[Dict[str, str]]: """Replace the username of each assignee with their (full) name. This is a hack-like adaptor so that when assignees are passed to `get_pull_request_event_message` we can use the assignee's name and not th...
[ "def", "replace_assignees_username_with_name", "(", "assignees", ":", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ")", "->", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ":", "for", "assignee", "in", "assignees", ":", "assignee", "...
[ 172, 0 ]
[ 181, 20 ]
python
en
['en', 'en', 'en']
True
Permutation.build_permuted_index
( self, lshash, buckets, num_permutation, beam_size, num_neighbour)
Build a permutedIndex and store it into the dict self.permutedIndexs. lshash: the binary lshash object (nearpy.hashes.lshash). buckets: the buckets object corresponding to lshash. It's a dict object which can get from nearpy.storage.buckets[lshash.hash_name] num_permut...
Build a permutedIndex and store it into the dict self.permutedIndexs. lshash: the binary lshash object (nearpy.hashes.lshash). buckets: the buckets object corresponding to lshash. It's a dict object which can get from nearpy.storage.buckets[lshash.hash_name] num_permut...
def build_permuted_index( self, lshash, buckets, num_permutation, beam_size, num_neighbour): """ Build a permutedIndex and store it into the dict self.permutedIndexs. lshash: the binary lshash object (nearpy.hashes.lshash). ...
[ "def", "build_permuted_index", "(", "self", ",", "lshash", ",", "buckets", ",", "num_permutation", ",", "beam_size", ",", "num_neighbour", ")", ":", "# Init a PermutedIndex", "pi", "=", "PermutedIndex", "(", "lshash", ",", "buckets", ",", "num_permutation", ",", ...
[ 39, 4 ]
[ 64, 43 ]
python
en
['en', 'error', 'th']
False
Permutation.get_neighbour_keys
(self, hash_name, bucket_key)
Return the neighbour buckets given hash_name and query bucket key.
Return the neighbour buckets given hash_name and query bucket key.
def get_neighbour_keys(self, hash_name, bucket_key): """ Return the neighbour buckets given hash_name and query bucket key. """ # get the permutedIndex given hash_name permutedIndex = self.permutedIndexs[hash_name] # return neighbour bucket keys of query bucket key ...
[ "def", "get_neighbour_keys", "(", "self", ",", "hash_name", ",", "bucket_key", ")", ":", "# get the permutedIndex given hash_name", "permutedIndex", "=", "self", ".", "permutedIndexs", "[", "hash_name", "]", "# return neighbour bucket keys of query bucket key", "return", "p...
[ 66, 4 ]
[ 75, 40 ]
python
en
['en', 'error', 'th']
False
api_zendesk_webhook
( request: HttpRequest, user_profile: UserProfile, ticket_title: str = REQ(), ticket_id: str = REQ(), message: str = REQ(), )
Zendesk uses triggers with message templates. This webhook uses the ticket_id and ticket_title to create a subject. And passes with zendesk user's configured message to zulip.
Zendesk uses triggers with message templates. This webhook uses the ticket_id and ticket_title to create a subject. And passes with zendesk user's configured message to zulip.
def api_zendesk_webhook( request: HttpRequest, user_profile: UserProfile, ticket_title: str = REQ(), ticket_id: str = REQ(), message: str = REQ(), ) -> HttpResponse: """ Zendesk uses triggers with message templates. This webhook uses the ticket_id and ticket_title to create a subject. An...
[ "def", "api_zendesk_webhook", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "ticket_title", ":", "str", "=", "REQ", "(", ")", ",", "ticket_id", ":", "str", "=", "REQ", "(", ")", ",", "message", ":", "str", "=", "REQ", ...
[ 18, 0 ]
[ 32, 25 ]
python
en
['en', 'error', 'th']
False
SettingHelpExtension.extendMarkdown
(self, md: Markdown)
Add SettingHelpExtension to the Markdown instance.
Add SettingHelpExtension to the Markdown instance.
def extendMarkdown(self, md: Markdown) -> None: """Add SettingHelpExtension to the Markdown instance.""" md.registerExtension(self) md.preprocessors.register(Setting(), "setting", 515)
[ "def", "extendMarkdown", "(", "self", ",", "md", ":", "Markdown", ")", "->", "None", ":", "md", ".", "registerExtension", "(", "self", ")", "md", ".", "preprocessors", ".", "register", "(", "Setting", "(", ")", ",", "\"setting\"", ",", "515", ")" ]
[ 98, 4 ]
[ 101, 60 ]
python
en
['en', 'en', 'en']
True
_initialize_model_cv
(model_key, conf_dict, verbose=False)
make kartesian product of listed parameters per model
make kartesian product of listed parameters per model
def _initialize_model_cv(model_key, conf_dict, verbose=False): ''' make kartesian product of listed parameters per model ''' assert 'estimator' in conf_dict.keys() estimator = conf_dict.pop('estimator') param_dict_cv = {} param_dict_init = {} for param_key, param_value in conf_dict.items(): ...
[ "def", "_initialize_model_cv", "(", "model_key", ",", "conf_dict", ",", "verbose", "=", "False", ")", ":", "assert", "'estimator'", "in", "conf_dict", ".", "keys", "(", ")", "estimator", "=", "conf_dict", ".", "pop", "(", "'estimator'", ")", "param_dict_cv", ...
[ 142, 0 ]
[ 161, 61 ]
python
en
['en', 'id', 'en']
True
register_ipaddress
(conn_or_curs=None)
Register conversion support between `ipaddress` objects and `network types`__. :param conn_or_curs: the scope where to register the type casters. If `!None` register them globally. After the function is called, PostgreSQL :sql:`inet` values will be converted into `~ipaddress.IPv4Interface` or...
Register conversion support between `ipaddress` objects and `network types`__.
def register_ipaddress(conn_or_curs=None): """ Register conversion support between `ipaddress` objects and `network types`__. :param conn_or_curs: the scope where to register the type casters. If `!None` register them globally. After the function is called, PostgreSQL :sql:`inet` values will b...
[ "def", "register_ipaddress", "(", "conn_or_curs", "=", "None", ")", ":", "global", "ipaddress", "import", "ipaddress", "global", "_casters", "if", "_casters", "is", "None", ":", "_casters", "=", "_make_casters", "(", ")", "for", "c", "in", "_casters", ":", "...
[ 35, 0 ]
[ 61, 44 ]
python
en
['en', 'error', 'th']
False
_load_variables
(load_path, sess, prefix='', remove_prefix=True)
Loads variables from checkpoint of policy trained by baselines.
Loads variables from checkpoint of policy trained by baselines.
def _load_variables(load_path, sess, prefix='', remove_prefix=True): """Loads variables from checkpoint of policy trained by baselines.""" # Forked from address below since we needed loading from different var names: # https://github.com/openai/baselines/blob/master/baselines/common/tf_util.py variables = [v f...
[ "def", "_load_variables", "(", "load_path", ",", "sess", ",", "prefix", "=", "''", ",", "remove_prefix", "=", "True", ")", ":", "# Forked from address below since we needed loading from different var names:", "# https://github.com/openai/baselines/blob/master/baselines/common/tf_ut...
[ 71, 0 ]
[ 85, 20 ]
python
en
['en', 'en', 'en']
True
current_umask
()
Get the current umask which involves having to set it temporarily.
Get the current umask which involves having to set it temporarily.
def current_umask(): """Get the current umask which involves having to set it temporarily.""" mask = os.umask(0) os.umask(mask) return mask
[ "def", "current_umask", "(", ")", ":", "mask", "=", "os", ".", "umask", "(", "0", ")", "os", ".", "umask", "(", "mask", ")", "return", "mask" ]
[ 24, 0 ]
[ 28, 15 ]
python
en
['en', 'en', 'en']
True
set_extracted_file_to_default_mode_plus_executable
(path)
Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs
Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs
def set_extracted_file_to_default_mode_plus_executable(path): """ Make file present at path have execute for user/group/world (chmod +x) is no-op on windows per python docs """ os.chmod(path, (0o777 & ~current_umask() | 0o111))
[ "def", "set_extracted_file_to_default_mode_plus_executable", "(", "path", ")", ":", "os", ".", "chmod", "(", "path", ",", "(", "0o777", "&", "~", "current_umask", "(", ")", "|", "0o111", ")", ")" ]
[ 31, 0 ]
[ 36, 54 ]
python
en
['en', 'error', 'th']
False
main
()
Generate a BUILD file for an unzipped Wheel We allow for empty Python sources as for Wheels containing only compiled C code there may be no Python sources whatsoever (e.g. packages written in Cython: like `pymssql`).
Generate a BUILD file for an unzipped Wheel
def main(): """ Generate a BUILD file for an unzipped Wheel We allow for empty Python sources as for Wheels containing only compiled C code there may be no Python sources whatsoever (e.g. packages written in Cython: like `pymssql`). """ args = parser.parse_args() whl = Wheel(args.whl) # Extract the f...
[ "def", "main", "(", ")", ":", "args", "=", "parser", ".", "parse_args", "(", ")", "whl", "=", "Wheel", "(", "args", ".", "whl", ")", "# Extract the files into the current directory", "whl", ".", "expand", "(", "args", ".", "directory", ")", "with", "open",...
[ 163, 0 ]
[ 211, 6 ]
python
en
['en', 'error', 'th']
False
Wheel.dependencies
(self, extra=None)
Access the dependencies of this Wheel. Args: extra: if specified, include the additional dependencies of the named "extra". Yields: the names of requirements from the metadata.json, in lexical order.
Access the dependencies of this Wheel.
def dependencies(self, extra=None): """Access the dependencies of this Wheel. Args: extra: if specified, include the additional dependencies of the named "extra". Yields: the names of requirements from the metadata.json, in lexical order. """ # TODO(mattmoor): Is there a sc...
[ "def", "dependencies", "(", "self", ",", "extra", "=", "None", ")", ":", "# TODO(mattmoor): Is there a schema to follow for this?", "dependency_set", "=", "set", "(", ")", "run_requires", "=", "self", ".", "metadata", "(", ")", ".", "get", "(", "'run_requires'", ...
[ 90, 2 ]
[ 119, 33 ]
python
en
['en', 'en', 'en']
True
FieldBlock.value_from_form
(self, value)
The value that we get back from the form field might not be the type that this block works with natively; for example, the block may want to wrap a simple value such as a string in an object that provides a fancy HTML rendering (e.g. EmbedBlock). We therefore provide this metho...
The value that we get back from the form field might not be the type that this block works with natively; for example, the block may want to wrap a simple value such as a string in an object that provides a fancy HTML rendering (e.g. EmbedBlock).
def value_from_form(self, value): """ The value that we get back from the form field might not be the type that this block works with natively; for example, the block may want to wrap a simple value such as a string in an object that provides a fancy HTML rendering (e.g. EmbedBlo...
[ "def", "value_from_form", "(", "self", ",", "value", ")", ":", "return", "value" ]
[ 26, 4 ]
[ 37, 20 ]
python
en
['en', 'error', 'th']
False
FieldBlock.value_for_form
(self, value)
Reverse of value_from_form; convert a value of this block's native value type to one that can be rendered by the form field
Reverse of value_from_form; convert a value of this block's native value type to one that can be rendered by the form field
def value_for_form(self, value): """ Reverse of value_from_form; convert a value of this block's native value type to one that can be rendered by the form field """ return value
[ "def", "value_for_form", "(", "self", ",", "value", ")", ":", "return", "value" ]
[ 39, 4 ]
[ 44, 20 ]
python
en
['en', 'error', 'th']
False
BaseChoiceBlock._get_callable_choices
(self, choices, blank_choice=True)
Return a callable that we can pass into `forms.ChoiceField`, which will provide the choices list with the addition of a blank choice (if blank_choice=True and one does not already exist).
Return a callable that we can pass into `forms.ChoiceField`, which will provide the choices list with the addition of a blank choice (if blank_choice=True and one does not already exist).
def _get_callable_choices(self, choices, blank_choice=True): """ Return a callable that we can pass into `forms.ChoiceField`, which will provide the choices list with the addition of a blank choice (if blank_choice=True and one does not already exist). """ def choices_cal...
[ "def", "_get_callable_choices", "(", "self", ",", "choices", ",", "blank_choice", "=", "True", ")", ":", "def", "choices_callable", "(", ")", ":", "# Variable choices could be an instance of CallableChoiceIterator, which may be wrapping", "# something we don't want to evaluate mu...
[ 445, 4 ]
[ 482, 31 ]
python
en
['en', 'error', 'th']
False
ChoiceBlock.deconstruct
(self)
Always deconstruct ChoiceBlock instances as if they were plain ChoiceBlocks with their choice list passed in the constructor, even if they are actually subclasses. This allows users to define subclasses of ChoiceBlock in their models.py, with specific choice lists passed in, without ref...
Always deconstruct ChoiceBlock instances as if they were plain ChoiceBlocks with their choice list passed in the constructor, even if they are actually subclasses. This allows users to define subclasses of ChoiceBlock in their models.py, with specific choice lists passed in, without ref...
def deconstruct(self): """ Always deconstruct ChoiceBlock instances as if they were plain ChoiceBlocks with their choice list passed in the constructor, even if they are actually subclasses. This allows users to define subclasses of ChoiceBlock in their models.py, with specific choice li...
[ "def", "deconstruct", "(", "self", ")", ":", "return", "(", "'wagtail.core.blocks.ChoiceBlock'", ",", "[", "]", ",", "self", ".", "_constructor_kwargs", ")" ]
[ 501, 4 ]
[ 508, 80 ]
python
en
['en', 'error', 'th']
False
MultipleChoiceBlock._get_callable_choices
(self, choices, blank_choice=False)
Override to default blank choice to False
Override to default blank choice to False
def _get_callable_choices(self, choices, blank_choice=False): """ Override to default blank choice to False """ return super()._get_callable_choices(choices, blank_choice=blank_choice)
[ "def", "_get_callable_choices", "(", "self", ",", "choices", ",", "blank_choice", "=", "False", ")", ":", "return", "super", "(", ")", ".", "_get_callable_choices", "(", "choices", ",", "blank_choice", "=", "blank_choice", ")" ]
[ 529, 4 ]
[ 532, 80 ]
python
en
['en', 'en', 'en']
True
MultipleChoiceBlock.deconstruct
(self)
Always deconstruct MultipleChoiceBlock instances as if they were plain MultipleChoiceBlocks with their choice list passed in the constructor, even if they are actually subclasses. This allows users to define subclasses of MultipleChoiceBlock in their models.py, with specific choice ...
Always deconstruct MultipleChoiceBlock instances as if they were plain MultipleChoiceBlocks with their choice list passed in the constructor, even if they are actually subclasses. This allows users to define subclasses of MultipleChoiceBlock in their models.py, with specific choice ...
def deconstruct(self): """ Always deconstruct MultipleChoiceBlock instances as if they were plain MultipleChoiceBlocks with their choice list passed in the constructor, even if they are actually subclasses. This allows users to define subclasses of MultipleChoiceBlock in their mo...
[ "def", "deconstruct", "(", "self", ")", ":", "return", "(", "'wagtail.core.blocks.MultipleChoiceBlock'", ",", "[", "]", ",", "self", ".", "_constructor_kwargs", ")" ]
[ 534, 4 ]
[ 543, 88 ]
python
en
['en', 'error', 'th']
False
ChooserBlock.bulk_to_python
(self, values)
Return the model instances for the given list of primary keys. The instances must be returned in the same order as the values and keep None values.
Return the model instances for the given list of primary keys.
def bulk_to_python(self, values): """Return the model instances for the given list of primary keys. The instances must be returned in the same order as the values and keep None values. """ objects = self.target_model.objects.in_bulk(values) return [objects.get(id) for id in valu...
[ "def", "bulk_to_python", "(", "self", ",", "values", ")", ":", "objects", "=", "self", ".", "target_model", ".", "objects", ".", "in_bulk", "(", "values", ")", "return", "[", "objects", ".", "get", "(", "id", ")", "for", "id", "in", "values", "]" ]
[ 673, 4 ]
[ 679, 49 ]
python
en
['en', 'en', 'en']
True
PageChooserBlock.target_model
(self)
Defines the model used by the base ChooserBlock for ID <-> instance conversions. If a single page type is specified in target_model, we can use that to get the more specific instance "for free"; otherwise use the generic Page model.
Defines the model used by the base ChooserBlock for ID <-> instance conversions. If a single page type is specified in target_model, we can use that to get the more specific instance "for free"; otherwise use the generic Page model.
def target_model(self): """ Defines the model used by the base ChooserBlock for ID <-> instance conversions. If a single page type is specified in target_model, we can use that to get the more specific instance "for free"; otherwise use the generic Page model. """ ...
[ "def", "target_model", "(", "self", ")", ":", "if", "len", "(", "self", ".", "target_models", ")", "==", "1", ":", "return", "self", ".", "target_models", "[", "0", "]", "return", "resolve_model_string", "(", "'wagtailcore.Page'", ")" ]
[ 737, 4 ]
[ 747, 55 ]
python
en
['en', 'error', 'th']
False
netspace_cmd
(rpc_port: int, delta_block_height: str, start: str)
Calculates the estimated space on the network given two block header hashes.
Calculates the estimated space on the network given two block header hashes.
def netspace_cmd(rpc_port: int, delta_block_height: str, start: str) -> None: """ Calculates the estimated space on the network given two block header hashes. """ import asyncio from .netspace_funcs import netstorge_async asyncio.run(netstorge_async(rpc_port, delta_block_height, start))
[ "def", "netspace_cmd", "(", "rpc_port", ":", "int", ",", "delta_block_height", ":", "str", ",", "start", ":", "str", ")", "->", "None", ":", "import", "asyncio", "from", ".", "netspace_funcs", "import", "netstorge_async", "asyncio", ".", "run", "(", "netstor...
[ 34, 0 ]
[ 41, 69 ]
python
en
['en', 'error', 'th']
False
delete_old_scheduled_jobs
(apps: StateApps, schema_editor: DatabaseSchemaEditor)
Delete any old scheduled jobs, to handle changes in the format of that table. Ideally, we'd translate the jobs, but it's not really worth the development effort to save a few invitation reminders and day2 followup emails.
Delete any old scheduled jobs, to handle changes in the format of that table. Ideally, we'd translate the jobs, but it's not really worth the development effort to save a few invitation reminders and day2 followup emails.
def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Delete any old scheduled jobs, to handle changes in the format of that table. Ideally, we'd translate the jobs, but it's not really worth the development effort to save a few invitation reminders and day2 fo...
[ "def", "delete_old_scheduled_jobs", "(", "apps", ":", "StateApps", ",", "schema_editor", ":", "DatabaseSchemaEditor", ")", "->", "None", ":", "ScheduledJob", "=", "apps", ".", "get_model", "(", "\"zerver\"", ",", "\"ScheduledJob\"", ")", "ScheduledJob", ".", "obje...
[ 6, 0 ]
[ 13, 39 ]
python
en
['en', 'en', 'en']
True
GameServerStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.GetEnvResult = channel.unary_unary( '/gfootball.eval_server.GameServer/GetEnvResult', request_serializer=gfootball_dot_eval__server_dot_proto_dot_game__server__pb2.GetEnvResultRequest.SerializeToS...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "GetEnvResult", "=", "channel", ".", "unary_unary", "(", "'/gfootball.eval_server.GameServer/GetEnvResult'", ",", "request_serializer", "=", "gfootball_dot_eval__server_dot_proto_dot_game__server__pb2", ...
[ 24, 2 ]
[ 49, 9 ]
python
en
['en', 'en', 'en']
False
GameServerServicer.GetEnvResult
(self, request, context)
Rpc for obtaining the current state.
Rpc for obtaining the current state.
def GetEnvResult(self, request, context): """Rpc for obtaining the current state. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "GetEnvResult", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplementedErr...
[ 56, 2 ]
[ 61, 56 ]
python
en
['en', 'en', 'en']
True
GameServerServicer.Step
(self, request, context)
Rpc for doing a step in the environment and obtaining a state after that.
Rpc for doing a step in the environment and obtaining a state after that.
def Step(self, request, context): """Rpc for doing a step in the environment and obtaining a state after that. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "Step", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplementedError", "...
[ 63, 2 ]
[ 68, 56 ]
python
en
['en', 'en', 'en']
True
GameServerServicer.GetCapacity
(self, request, context)
Rpc for informing Master how many games can still be scheduled on this GS.
Rpc for informing Master how many games can still be scheduled on this GS.
def GetCapacity(self, request, context): """Rpc for informing Master how many games can still be scheduled on this GS. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "GetCapacity", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplementedErro...
[ 70, 2 ]
[ 75, 56 ]
python
en
['en', 'en', 'en']
True
GameServerServicer.CreateGame
(self, request, context)
Rpc to create a new game instance, only called by Master.
Rpc to create a new game instance, only called by Master.
def CreateGame(self, request, context): """Rpc to create a new game instance, only called by Master. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') raise NotImplementedError('Method not implemented!')
[ "def", "CreateGame", "(", "self", ",", "request", ",", "context", ")", ":", "context", ".", "set_code", "(", "grpc", ".", "StatusCode", ".", "UNIMPLEMENTED", ")", "context", ".", "set_details", "(", "'Method not implemented!'", ")", "raise", "NotImplementedError...
[ 77, 2 ]
[ 82, 56 ]
python
en
['en', 'en', 'en']
True
LSHash.__init__
(self, hash_name)
The hash name is used in storage to store buckets of different hashes without collision.
The hash name is used in storage to store buckets of different hashes without collision.
def __init__(self, hash_name): """ The hash name is used in storage to store buckets of different hashes without collision. """ self.hash_name = hash_name
[ "def", "__init__", "(", "self", ",", "hash_name", ")", ":", "self", ".", "hash_name", "=", "hash_name" ]
[ 26, 4 ]
[ 31, 34 ]
python
en
['en', 'error', 'th']
False
LSHash.reset
(self, dim)
Resets / Initializes the hash for the specified dimension.
Resets / Initializes the hash for the specified dimension.
def reset(self, dim): """ Resets / Initializes the hash for the specified dimension. """ raise NotImplementedError
[ "def", "reset", "(", "self", ",", "dim", ")", ":", "raise", "NotImplementedError" ]
[ 33, 4 ]
[ 35, 33 ]
python
en
['en', 'en', 'en']
True
LSHash.hash_vector
(self, v, querying=False)
Hashes the vector and returns a list of bucket keys, that match the vector. Depending on the hash implementation this list can contain one or many bucket keys. Querying is True if this is used for retrieval and not indexing.
Hashes the vector and returns a list of bucket keys, that match the vector. Depending on the hash implementation this list can contain one or many bucket keys. Querying is True if this is used for retrieval and not indexing.
def hash_vector(self, v, querying=False): """ Hashes the vector and returns a list of bucket keys, that match the vector. Depending on the hash implementation this list can contain one or many bucket keys. Querying is True if this is used for retrieval and not indexing. "...
[ "def", "hash_vector", "(", "self", ",", "v", ",", "querying", "=", "False", ")", ":", "raise", "NotImplementedError" ]
[ 37, 4 ]
[ 44, 33 ]
python
en
['en', 'error', 'th']
False
LSHash.get_config
(self)
Returns pickle-serializable configuration struct for storage.
Returns pickle-serializable configuration struct for storage.
def get_config(self): """ Returns pickle-serializable configuration struct for storage. """ raise NotImplementedError
[ "def", "get_config", "(", "self", ")", ":", "raise", "NotImplementedError" ]
[ 46, 4 ]
[ 50, 33 ]
python
en
['en', 'error', 'th']
False
LSHash.apply_config
(self, config)
Applies config
Applies config
def apply_config(self, config): """ Applies config """ raise NotImplementedError
[ "def", "apply_config", "(", "self", ",", "config", ")", ":", "raise", "NotImplementedError" ]
[ 52, 4 ]
[ 56, 33 ]
python
en
['en', 'error', 'th']
False
TestConverter.test_include_controllers
(self)
check whether known controller included into unknown one is parsed properly
check whether known controller included into unknown one is parsed properly
def test_include_controllers(self): """ check whether known controller included into unknown one is parsed properly """ with open(RESOURCES_DIR + "jmeter/jmx/all_controllers.jmx") as f: content = f.read() # make IfControllers unknown content = content.replace("IfController",...
[ "def", "test_include_controllers", "(", "self", ")", ":", "with", "open", "(", "RESOURCES_DIR", "+", "\"jmeter/jmx/all_controllers.jmx\"", ")", "as", "f", ":", "content", "=", "f", ".", "read", "(", ")", "# make IfControllers unknown", "content", "=", "content", ...
[ 553, 4 ]
[ 573, 36 ]
python
en
['en', 'en', 'en']
True
path_to_url
(path)
Convert a path to a file: URL. The path will be made absolute and have quoted path parts.
Convert a path to a file: URL. The path will be made absolute and have quoted path parts.
def path_to_url(path): # type: (Union[str, Text]) -> str """ Convert a path to a file: URL. The path will be made absolute and have quoted path parts. """ path = os.path.normpath(os.path.abspath(path)) url = urllib_parse.urljoin('file:', urllib_request.pathname2url(path)) return url
[ "def", "path_to_url", "(", "path", ")", ":", "# type: (Union[str, Text]) -> str", "path", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", "url", "=", "urllib_parse", ".", "urljoin", "(", "'file:'", ...
[ 19, 0 ]
[ 27, 14 ]
python
en
['en', 'error', 'th']
False
url_to_path
(url)
Convert a file: URL to a path.
Convert a file: URL to a path.
def url_to_path(url): # type: (str) -> str """ Convert a file: URL to a path. """ assert url.startswith('file:'), ( "You can only turn file: urls into filenames (not {url!r})" .format(**locals())) _, netloc, path, _, _ = urllib_parse.urlsplit(url) if not netloc or netloc ==...
[ "def", "url_to_path", "(", "url", ")", ":", "# type: (str) -> str", "assert", "url", ".", "startswith", "(", "'file:'", ")", ",", "(", "\"You can only turn file: urls into filenames (not {url!r})\"", ".", "format", "(", "*", "*", "locals", "(", ")", ")", ")", "_...
[ 30, 0 ]
[ 54, 15 ]
python
en
['en', 'error', 'th']
False
BasicListParser._normalize
(self, input)
Wrapper to normalize a value. Default method just calls .rstrip()
Wrapper to normalize a value. Default method just calls .rstrip()
def _normalize(self, input): """ Wrapper to normalize a value. Default method just calls .rstrip() """ return input.rstrip()
[ "def", "_normalize", "(", "self", ",", "input", ")", ":", "return", "input", ".", "rstrip", "(", ")" ]
[ 44, 4 ]
[ 48, 29 ]
python
en
['en', 'error', 'th']
False
YAMLParserNS._normalize
(self, item)
Normalize to lower case
Normalize to lower case
def _normalize(self, item): """ Normalize to lower case """ return item.rstrip().lower()
[ "def", "_normalize", "(", "self", ",", "item", ")", ":", "return", "item", ".", "rstrip", "(", ")", ".", "lower", "(", ")" ]
[ 286, 4 ]
[ 290, 36 ]
python
en
['en', 'error', 'th']
False