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
NeutronApiTests._test_network_list_for_tenant
( self, include_external, filter_params, should_called, **extra_kwargs)
Convenient method to test network_list_for_tenant. :param include_external: Passed to network_list_for_tenant. :param filter_params: Filters passed to network_list_for_tenant :param should_called: this argument specifies which methods should be called. Methods in this list should be...
Convenient method to test network_list_for_tenant.
def _test_network_list_for_tenant( self, include_external, filter_params, should_called, **extra_kwargs): """Convenient method to test network_list_for_tenant. :param include_external: Passed to network_list_for_tenant. :param filter_params: Filters passed to network_lis...
[ "def", "_test_network_list_for_tenant", "(", "self", ",", "include_external", ",", "filter_params", ",", "should_called", ",", "*", "*", "extra_kwargs", ")", ":", "filter_params", "=", "filter_params", "or", "{", "}", "all_networks", "=", "self", ".", "networks", ...
[ 48, 4 ]
[ 115, 49 ]
python
en
['en', 'en', 'en']
True
Context.__init__
(self, strategy: Strategy)
Usually, the Context accepts a strategy through the constructor, but also provides a setter to change it at runtime.
Usually, the Context accepts a strategy through the constructor, but also provides a setter to change it at runtime.
def __init__(self, strategy: Strategy) -> None: """ Usually, the Context accepts a strategy through the constructor, but also provides a setter to change it at runtime. """ self._strategy = strategy
[ "def", "__init__", "(", "self", ",", "strategy", ":", "Strategy", ")", "->", "None", ":", "self", ".", "_strategy", "=", "strategy" ]
[ 27, 4 ]
[ 33, 33 ]
python
en
['en', 'error', 'th']
False
Context.strategy
(self)
The Context maintains a reference to one of the Strategy objects. The Context does not know the concrete class of a strategy. It should work with all strategies via the Strategy interface.
The Context maintains a reference to one of the Strategy objects. The Context does not know the concrete class of a strategy. It should work with all strategies via the Strategy interface.
def strategy(self) -> Strategy: """ The Context maintains a reference to one of the Strategy objects. The Context does not know the concrete class of a strategy. It should work with all strategies via the Strategy interface. """ return self._strategy
[ "def", "strategy", "(", "self", ")", "->", "Strategy", ":", "return", "self", ".", "_strategy" ]
[ 36, 4 ]
[ 43, 29 ]
python
en
['en', 'error', 'th']
False
Context.strategy
(self, strategy: Strategy)
Usually, the Context allows replacing a Strategy object at runtime.
Usually, the Context allows replacing a Strategy object at runtime.
def strategy(self, strategy: Strategy) -> None: """ Usually, the Context allows replacing a Strategy object at runtime. """ self._strategy = strategy
[ "def", "strategy", "(", "self", ",", "strategy", ":", "Strategy", ")", "->", "None", ":", "self", ".", "_strategy", "=", "strategy" ]
[ 46, 4 ]
[ 51, 33 ]
python
en
['en', 'error', 'th']
False
auto_decode
(data)
Check a bytes string for a BOM to correctly detect the encoding Fallback to locale.getpreferredencoding(False) like open() on Python3
Check a bytes string for a BOM to correctly detect the encoding
def auto_decode(data): # type: (bytes) -> Text """Check a bytes string for a BOM to correctly detect the encoding Fallback to locale.getpreferredencoding(False) like open() on Python3""" for bom, encoding in BOMS: if data.startswith(bom): return data[len(bom):].decode(encoding) ...
[ "def", "auto_decode", "(", "data", ")", ":", "# type: (bytes) -> Text", "for", "bom", ",", "encoding", "in", "BOMS", ":", "if", "data", ".", "startswith", "(", "bom", ")", ":", "return", "data", "[", "len", "(", "bom", ")", ":", "]", ".", "decode", "...
[ 23, 0 ]
[ 40, 5 ]
python
en
['en', 'en', 'en']
True
get_modified_streams
( user_ids: List[int], cutoff_date: datetime.datetime )
Skipping streams where the user's subscription status has changed when constructing digests is critical to ensure correctness for streams without shared history, guest users, and long-term idle users, because it means that every user has the same view of the history of a given stream whose message histo...
Skipping streams where the user's subscription status has changed when constructing digests is critical to ensure correctness for streams without shared history, guest users, and long-term idle users, because it means that every user has the same view of the history of a given stream whose message histo...
def get_modified_streams( user_ids: List[int], cutoff_date: datetime.datetime ) -> Dict[int, Set[int]]: """Skipping streams where the user's subscription status has changed when constructing digests is critical to ensure correctness for streams without shared history, guest users, and long-term idle ...
[ "def", "get_modified_streams", "(", "user_ids", ":", "List", "[", "int", "]", ",", "cutoff_date", ":", "datetime", ".", "datetime", ")", "->", "Dict", "[", "int", ",", "Set", "[", "int", "]", "]", ":", "events", "=", "[", "RealmAuditLog", ".", "SUBSCRI...
[ 399, 0 ]
[ 438, 17 ]
python
en
['en', 'en', 'en']
True
_attr_key
(attr)
Return an appropriate key for an attribute for sorting Attributes have a namespace that can be either ``None`` or a string. We can't compare the two because they're different types, so we convert ``None`` to an empty string first.
Return an appropriate key for an attribute for sorting
def _attr_key(attr): """Return an appropriate key for an attribute for sorting Attributes have a namespace that can be either ``None`` or a string. We can't compare the two because they're different types, so we convert ``None`` to an empty string first. """ return (attr[0][0] or ''), attr[0][...
[ "def", "_attr_key", "(", "attr", ")", ":", "return", "(", "attr", "[", "0", "]", "[", "0", "]", "or", "''", ")", ",", "attr", "[", "0", "]", "[", "1", "]" ]
[ 7, 0 ]
[ 15, 41 ]
python
en
['en', 'en', 'en']
True
showwarning
(message, category, filename, lineno, file=None, line=None)
Hook to write a warning to a file; replace if you like.
Hook to write a warning to a file; replace if you like.
def showwarning(message, category, filename, lineno, file=None, line=None): """Hook to write a warning to a file; replace if you like.""" msg = WarningMessage(message, category, filename, lineno, file, line) _showwarnmsg_impl(msg)
[ "def", "showwarning", "(", "message", ",", "category", ",", "filename", ",", "lineno", ",", "file", "=", "None", ",", "line", "=", "None", ")", ":", "msg", "=", "WarningMessage", "(", "message", ",", "category", ",", "filename", ",", "lineno", ",", "fi...
[ 9, 0 ]
[ 12, 26 ]
python
en
['en', 'en', 'en']
True
formatwarning
(message, category, filename, lineno, line=None)
Function to format a warning the standard way.
Function to format a warning the standard way.
def formatwarning(message, category, filename, lineno, line=None): """Function to format a warning the standard way.""" msg = WarningMessage(message, category, filename, lineno, None, line) return _formatwarnmsg_impl(msg)
[ "def", "formatwarning", "(", "message", ",", "category", ",", "filename", ",", "lineno", ",", "line", "=", "None", ")", ":", "msg", "=", "WarningMessage", "(", "message", ",", "category", ",", "filename", ",", "lineno", ",", "None", ",", "line", ")", "...
[ 14, 0 ]
[ 17, 35 ]
python
en
['en', 'en', 'en']
True
_showwarnmsg
(msg)
Hook to write a warning to a file; replace if you like.
Hook to write a warning to a file; replace if you like.
def _showwarnmsg(msg): """Hook to write a warning to a file; replace if you like.""" try: sw = showwarning except NameError: pass else: if sw is not _showwarning_orig: # warnings.showwarning() was replaced if not callable(sw): raise TypeErr...
[ "def", "_showwarnmsg", "(", "msg", ")", ":", "try", ":", "sw", "=", "showwarning", "except", "NameError", ":", "pass", "else", ":", "if", "sw", "is", "not", "_showwarning_orig", ":", "# warnings.showwarning() was replaced", "if", "not", "callable", "(", "sw", ...
[ 84, 0 ]
[ 100, 26 ]
python
en
['en', 'en', 'en']
True
_formatwarnmsg
(msg)
Function to format a warning the standard way.
Function to format a warning the standard way.
def _formatwarnmsg(msg): """Function to format a warning the standard way.""" try: fw = formatwarning except NameError: pass else: if fw is not _formatwarning_orig: # warnings.formatwarning() was replaced return fw(msg.message, msg.category, ...
[ "def", "_formatwarnmsg", "(", "msg", ")", ":", "try", ":", "fw", "=", "formatwarning", "except", "NameError", ":", "pass", "else", ":", "if", "fw", "is", "not", "_formatwarning_orig", ":", "# warnings.formatwarning() was replaced", "return", "fw", "(", "msg", ...
[ 105, 0 ]
[ 116, 35 ]
python
en
['en', 'en', 'en']
True
filterwarnings
(action, message="", category=Warning, module="", lineno=0, append=False)
Insert an entry into the list of warnings filters (at the front). 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'message' -- a regex that the warning message must match 'category' -- a class that the warning must be a subclass of 'module' -- a regex that...
Insert an entry into the list of warnings filters (at the front).
def filterwarnings(action, message="", category=Warning, module="", lineno=0, append=False): """Insert an entry into the list of warnings filters (at the front). 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'message' -- a regex that the w...
[ "def", "filterwarnings", "(", "action", ",", "message", "=", "\"\"", ",", "category", "=", "Warning", ",", "module", "=", "\"\"", ",", "lineno", "=", "0", ",", "append", "=", "False", ")", ":", "import", "re", "assert", "action", "in", "(", "\"error\""...
[ 118, 0 ]
[ 140, 54 ]
python
en
['en', 'en', 'en']
True
simplefilter
(action, category=Warning, lineno=0, append=False)
Insert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'category' -- a class that the warning must be a subclass of 'lineno' -- an integer li...
Insert a simple entry into the list of warnings filters (at the front).
def simplefilter(action, category=Warning, lineno=0, append=False): """Insert a simple entry into the list of warnings filters (at the front). A simple filter matches all modules and messages. 'action' -- one of "error", "ignore", "always", "default", "module", or "once" 'category' -- a...
[ "def", "simplefilter", "(", "action", ",", "category", "=", "Warning", ",", "lineno", "=", "0", ",", "append", "=", "False", ")", ":", "assert", "action", "in", "(", "\"error\"", ",", "\"ignore\"", ",", "\"always\"", ",", "\"default\"", ",", "\"module\"", ...
[ 142, 0 ]
[ 156, 68 ]
python
en
['en', 'en', 'en']
True
resetwarnings
()
Clear the list of warning filters, so that no filters are active.
Clear the list of warning filters, so that no filters are active.
def resetwarnings(): """Clear the list of warning filters, so that no filters are active.""" filters[:] = [] _filters_mutated()
[ "def", "resetwarnings", "(", ")", ":", "filters", "[", ":", "]", "=", "[", "]", "_filters_mutated", "(", ")" ]
[ 172, 0 ]
[ 175, 22 ]
python
en
['en', 'en', 'en']
True
_is_internal_frame
(frame)
Signal whether the frame is an internal CPython implementation detail.
Signal whether the frame is an internal CPython implementation detail.
def _is_internal_frame(frame): """Signal whether the frame is an internal CPython implementation detail.""" filename = frame.f_code.co_filename return 'importlib' in filename and '_bootstrap' in filename
[ "def", "_is_internal_frame", "(", "frame", ")", ":", "filename", "=", "frame", ".", "f_code", ".", "co_filename", "return", "'importlib'", "in", "filename", "and", "'_bootstrap'", "in", "filename" ]
[ 253, 0 ]
[ 256, 63 ]
python
en
['en', 'en', 'en']
True
_next_external_frame
(frame)
Find the next frame that doesn't involve CPython internals.
Find the next frame that doesn't involve CPython internals.
def _next_external_frame(frame): """Find the next frame that doesn't involve CPython internals.""" frame = frame.f_back while frame is not None and _is_internal_frame(frame): frame = frame.f_back return frame
[ "def", "_next_external_frame", "(", "frame", ")", ":", "frame", "=", "frame", ".", "f_back", "while", "frame", "is", "not", "None", "and", "_is_internal_frame", "(", "frame", ")", ":", "frame", "=", "frame", ".", "f_back", "return", "frame" ]
[ 259, 0 ]
[ 264, 16 ]
python
en
['en', 'en', 'en']
True
warn
(message, category=None, stacklevel=1, source=None)
Issue a warning, or maybe ignore it or raise an exception.
Issue a warning, or maybe ignore it or raise an exception.
def warn(message, category=None, stacklevel=1, source=None): """Issue a warning, or maybe ignore it or raise an exception.""" # Check if message is already a Warning object if isinstance(message, Warning): category = message.__class__ # Check category argument if category is None: ca...
[ "def", "warn", "(", "message", ",", "category", "=", "None", ",", "stacklevel", "=", "1", ",", "source", "=", "None", ")", ":", "# Check if message is already a Warning object", "if", "isinstance", "(", "message", ",", "Warning", ")", ":", "category", "=", "...
[ 268, 0 ]
[ 318, 34 ]
python
en
['en', 'en', 'en']
True
catch_warnings.__init__
(self, *, record=False, module=None)
Specify whether to record warnings and if an alternative module should be used other than sys.modules['warnings']. For compatibility with Python 3.0, please consider all arguments to be keyword-only.
Specify whether to record warnings and if an alternative module should be used other than sys.modules['warnings'].
def __init__(self, *, record=False, module=None): """Specify whether to record warnings and if an alternative module should be used other than sys.modules['warnings']. For compatibility with Python 3.0, please consider all arguments to be keyword-only. """ self._record ...
[ "def", "__init__", "(", "self", ",", "*", ",", "record", "=", "False", ",", "module", "=", "None", ")", ":", "self", ".", "_record", "=", "record", "self", ".", "_module", "=", "sys", ".", "modules", "[", "'warnings'", "]", "if", "module", "is", "N...
[ 427, 4 ]
[ 437, 29 ]
python
en
['en', 'en', 'en']
True
_objectify
(items, container_name)
Splits a listing of objects into their appropriate wrapper classes.
Splits a listing of objects into their appropriate wrapper classes.
def _objectify(items, container_name): """Splits a listing of objects into their appropriate wrapper classes.""" objects = [] # Deal with objects and object pseudo-folders first, save subdirs for later for item in items: if item.get("subdir", None) is not None: object_cls = PseudoFo...
[ "def", "_objectify", "(", "items", ",", "container_name", ")", ":", "objects", "=", "[", "]", "# Deal with objects and object pseudo-folders first, save subdirs for later", "for", "item", "in", "items", ":", "if", "item", ".", "get", "(", "\"subdir\"", ",", "None", ...
[ 90, 0 ]
[ 103, 18 ]
python
en
['en', 'en', 'en']
True
BaseAction.verify_action
( self, action: Callable[[], object], *, event_types: Optional[List[str]] = None, include_subscribers: bool = True, state_change_expected: bool = True, notification_settings_null: bool = False, client_gravatar: bool = True, user_avatar_url_field_op...
Make sure we have a clean slate of client descriptors for these tests. If we don't do this, then certain failures will only manifest when you run multiple tests within a single test function. See also https://zulip.readthedocs.io/en/latest/subsystems/events-system.html#testing ...
Make sure we have a clean slate of client descriptors for these tests. If we don't do this, then certain failures will only manifest when you run multiple tests within a single test function.
def verify_action( self, action: Callable[[], object], *, event_types: Optional[List[str]] = None, include_subscribers: bool = True, state_change_expected: bool = True, notification_settings_null: bool = False, client_gravatar: bool = True, user_av...
[ "def", "verify_action", "(", "self", ",", "action", ":", "Callable", "[", "[", "]", ",", "object", "]", ",", "*", ",", "event_types", ":", "Optional", "[", "List", "[", "str", "]", "]", "=", "None", ",", "include_subscribers", ":", "bool", "=", "True...
[ 222, 4 ]
[ 328, 21 ]
python
en
['en', 'error', 'th']
False
NormalActionsTest.test_do_delete_message_stream_legacy
(self)
Test for legacy method of deleting messages which sends an event per message to delete to the client.
Test for legacy method of deleting messages which sends an event per message to delete to the client.
def test_do_delete_message_stream_legacy(self) -> None: """ Test for legacy method of deleting messages which sends an event per message to delete to the client. """ hamlet = self.example_user("hamlet") msg_id = self.send_stream_message(hamlet, "Verona") msg_id_2 ...
[ "def", "test_do_delete_message_stream_legacy", "(", "self", ")", "->", "None", ":", "hamlet", "=", "self", ".", "example_user", "(", "\"hamlet\"", ")", "msg_id", "=", "self", ".", "send_stream_message", "(", "hamlet", ",", "\"Verona\"", ")", "msg_id_2", "=", "...
[ 1739, 4 ]
[ 1760, 9 ]
python
en
['en', 'error', 'th']
False
UserDisplayActionTest.do_set_user_display_settings_test
(self, setting_name: str)
Test updating each setting in UserProfile.property_types dict.
Test updating each setting in UserProfile.property_types dict.
def do_set_user_display_settings_test(self, setting_name: str) -> None: """Test updating each setting in UserProfile.property_types dict.""" test_changes: Dict[str, Any] = dict( emojiset=["twitter"], default_language=["es", "de", "en"], default_view=["all_messages", ...
[ "def", "do_set_user_display_settings_test", "(", "self", ",", "setting_name", ":", "str", ")", "->", "None", ":", "test_changes", ":", "Dict", "[", "str", ",", "Any", "]", "=", "dict", "(", "emojiset", "=", "[", "\"twitter\"", "]", ",", "default_language", ...
[ 2050, 4 ]
[ 2086, 75 ]
python
en
['en', 'en', 'en']
True
SelectionPreferences.__init__
( self, allow_yanked, # type: bool allow_all_prereleases=False, # type: bool format_control=None, # type: Optional[FormatControl] prefer_binary=False, # type: bool ignore_requires_python=None, # type: Optional[bool] )
Create a SelectionPreferences object. :param allow_yanked: Whether files marked as yanked (in the sense of PEP 592) are permitted to be candidates for install. :param format_control: A FormatControl object or None. Used to control the selection of source packages / binary packag...
Create a SelectionPreferences object.
def __init__( self, allow_yanked, # type: bool allow_all_prereleases=False, # type: bool format_control=None, # type: Optional[FormatControl] prefer_binary=False, # type: bool ignore_requires_python=None, # type: Optional[bool] ): # type: ...
[ "def", "__init__", "(", "self", ",", "allow_yanked", ",", "# type: bool", "allow_all_prereleases", "=", "False", ",", "# type: bool", "format_control", "=", "None", ",", "# type: Optional[FormatControl]", "prefer_binary", "=", "False", ",", "# type: bool", "ignore_requi...
[ 20, 4 ]
[ 48, 60 ]
python
en
['en', 'en', 'en']
True
get_platform
(archive_root)
Return our platform name 'win32', 'linux_x86_64
Return our platform name 'win32', 'linux_x86_64
def get_platform(archive_root): """Return our platform name 'win32', 'linux_x86_64'""" # XXX remove distutils dependency result = distutils.util.get_platform() if result.startswith("macosx") and archive_root is not None: result = calculate_macosx_platform_tag(archive_root, result) if result ...
[ "def", "get_platform", "(", "archive_root", ")", ":", "# XXX remove distutils dependency", "result", "=", "distutils", ".", "util", ".", "get_platform", "(", ")", "if", "result", ".", "startswith", "(", "\"macosx\"", ")", "and", "archive_root", "is", "not", "Non...
[ 42, 0 ]
[ 51, 17 ]
python
en
['fr', 'en', 'en']
True
get_flag
(var, fallback, expected=True, warn=True)
Use a fallback value for determining SOABI flags if the needed config var is unset or unavailable.
Use a fallback value for determining SOABI flags if the needed config var is unset or unavailable.
def get_flag(var, fallback, expected=True, warn=True): """Use a fallback value for determining SOABI flags if the needed config var is unset or unavailable.""" val = get_config_var(var) if val is None: if warn: warnings.warn("Config variable '{0}' is unset, Python ABI tag may " ...
[ "def", "get_flag", "(", "var", ",", "fallback", ",", "expected", "=", "True", ",", "warn", "=", "True", ")", ":", "val", "=", "get_config_var", "(", "var", ")", "if", "val", "is", "None", ":", "if", "warn", ":", "warnings", ".", "warn", "(", "\"Con...
[ 54, 0 ]
[ 63, 26 ]
python
en
['en', 'en', 'en']
True
get_abi_tag
()
Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).
Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).
def get_abi_tag(): """Return the ABI tag based on SOABI (if available) or emulate SOABI (CPython 2, PyPy).""" soabi = get_config_var('SOABI') impl = tags.interpreter_name() if not soabi and impl in ('cp', 'pp') and hasattr(sys, 'maxunicode'): d = '' m = '' u = '' if g...
[ "def", "get_abi_tag", "(", ")", ":", "soabi", "=", "get_config_var", "(", "'SOABI'", ")", "impl", "=", "tags", ".", "interpreter_name", "(", ")", "if", "not", "soabi", "and", "impl", "in", "(", "'cp'", ",", "'pp'", ")", "and", "hasattr", "(", "sys", ...
[ 66, 0 ]
[ 99, 14 ]
python
en
['en', 'sm', 'en']
True
bdist_wheel.wheel_dist_name
(self)
Return distribution full name with - replaced with _
Return distribution full name with - replaced with _
def wheel_dist_name(self): """Return distribution full name with - replaced with _""" components = (safer_name(self.distribution.get_name()), safer_version(self.distribution.get_version())) if self.build_number: components += (self.build_number,) return ...
[ "def", "wheel_dist_name", "(", "self", ")", ":", "components", "=", "(", "safer_name", "(", "self", ".", "distribution", ".", "get_name", "(", ")", ")", ",", "safer_version", "(", "self", ".", "distribution", ".", "get_version", "(", ")", ")", ")", "if",...
[ 225, 4 ]
[ 231, 35 ]
python
en
['en', 'en', 'en']
True
bdist_wheel.egg2dist
(self, egginfo_path, distinfo_path)
Convert an .egg-info directory into a .dist-info directory
Convert an .egg-info directory into a .dist-info directory
def egg2dist(self, egginfo_path, distinfo_path): """Convert an .egg-info directory into a .dist-info directory""" def adios(p): """Appropriately delete directory, file or link.""" if os.path.exists(p) and not os.path.islink(p) and os.path.isdir(p): shutil.rmtree(p...
[ "def", "egg2dist", "(", "self", ",", "egginfo_path", ",", "distinfo_path", ")", ":", "def", "adios", "(", "p", ")", ":", "\"\"\"Appropriately delete directory, file or link.\"\"\"", "if", "os", ".", "path", ".", "exists", "(", "p", ")", "and", "not", "os", "...
[ 420, 4 ]
[ 475, 27 ]
python
en
['it', 'lb', 'en']
False
JsonHookTests.test_json_github_push__1_commit_message
(self)
Tests if json github push 1 commit is handled correctly
Tests if json github push 1 commit is handled correctly
def test_json_github_push__1_commit_message(self) -> None: """ Tests if json github push 1 commit is handled correctly """ with open("zerver/webhooks/json/fixtures/json_github_push__1_commit.json") as f: original_fixture = json.load(f) expected_topic = "JSON" ...
[ "def", "test_json_github_push__1_commit_message", "(", "self", ")", "->", "None", ":", "with", "open", "(", "\"zerver/webhooks/json/fixtures/json_github_push__1_commit.json\"", ")", "as", "f", ":", "original_fixture", "=", "json", ".", "load", "(", "f", ")", "expected...
[ 10, 4 ]
[ 23, 90 ]
python
en
['en', 'error', 'th']
False
JsonHookTests.test_json_pingdom_http_up_to_down_message
(self)
Tests if json pingdom http up to down is handled correctly
Tests if json pingdom http up to down is handled correctly
def test_json_pingdom_http_up_to_down_message(self) -> None: """ Tests if json pingdom http up to down is handled correctly """ with open("zerver/webhooks/json/fixtures/json_pingdom_http_up_to_down.json") as f: original_fixture = json.load(f) expected_topic = "JSON" ...
[ "def", "test_json_pingdom_http_up_to_down_message", "(", "self", ")", "->", "None", ":", "with", "open", "(", "\"zerver/webhooks/json/fixtures/json_pingdom_http_up_to_down.json\"", ")", "as", "f", ":", "original_fixture", "=", "json", ".", "load", "(", "f", ")", "expe...
[ 25, 4 ]
[ 38, 92 ]
python
en
['en', 'error', 'th']
False
JsonHookTests.test_json_sentry_event_for_exception_js_message
(self)
Tests if json sentry event for exception js is handled correctly
Tests if json sentry event for exception js is handled correctly
def test_json_sentry_event_for_exception_js_message(self) -> None: """ Tests if json sentry event for exception js is handled correctly """ with open("zerver/webhooks/json/fixtures/json_sentry_event_for_exception_js.json") as f: original_fixture = json.load(f) expect...
[ "def", "test_json_sentry_event_for_exception_js_message", "(", "self", ")", "->", "None", ":", "with", "open", "(", "\"zerver/webhooks/json/fixtures/json_sentry_event_for_exception_js.json\"", ")", "as", "f", ":", "original_fixture", "=", "json", ".", "load", "(", "f", ...
[ 40, 4 ]
[ 53, 98 ]
python
en
['en', 'error', 'th']
False
json_response_from_error
(exception: JsonableError)
This should only be needed in middleware; in app code, just raise. When app code raises a JsonableError, the JsonErrorHandler middleware takes care of transforming it into a response by calling this function.
This should only be needed in middleware; in app code, just raise.
def json_response_from_error(exception: JsonableError) -> HttpResponse: """ This should only be needed in middleware; in app code, just raise. When app code raises a JsonableError, the JsonErrorHandler middleware takes care of transforming it into a response by calling this function. """ re...
[ "def", "json_response_from_error", "(", "exception", ":", "JsonableError", ")", "->", "HttpResponse", ":", "response", "=", "json_response", "(", "\"error\"", ",", "msg", "=", "exception", ".", "msg", ",", "data", "=", "exception", ".", "data", ",", "status", ...
[ 66, 0 ]
[ 81, 19 ]
python
en
['en', 'error', 'th']
False
ErrorParserBase.parse_error
(self, line)
Parses a line of test output. If it contains an error, returns a formatted message describing the error; otherwise, returns None. Subclasses must override this method.
Parses a line of test output. If it contains an error, returns a formatted message describing the error; otherwise, returns None. Subclasses must override this method.
def parse_error(self, line): '''Parses a line of test output. If it contains an error, returns a formatted message describing the error; otherwise, returns None. Subclasses must override this method. ''' raise NotImplementedError
[ "def", "parse_error", "(", "self", ",", "line", ")", ":", "raise", "NotImplementedError" ]
[ 21, 4 ]
[ 26, 33 ]
python
en
['en', 'en', 'en']
True
HTMLTokenizer.__iter__
(self)
This is where the magic happens. We do our usually processing through the states and when we have a token to return we yield the token which pauses processing until the next token is requested.
This is where the magic happens.
def __iter__(self): """ This is where the magic happens. We do our usually processing through the states and when we have a token to return we yield the token which pauses processing until the next token is requested. """ self.tokenQueue = deque([]) # Start proce...
[ "def", "__iter__", "(", "self", ")", ":", "self", ".", "tokenQueue", "=", "deque", "(", "[", "]", ")", "# Start processing. When EOF is reached self.state will return False", "# instead of True and the loop will terminate.", "while", "self", ".", "state", "(", ")", ":",...
[ 54, 4 ]
[ 68, 47 ]
python
en
['en', 'en', 'en']
True
HTMLTokenizer.consumeNumberEntity
(self, isHex)
This function returns either U+FFFD or the character based on the decimal or hexadecimal representation. It also discards ";" if present. If not present self.tokenQueue.append({"type": tokenTypes["ParseError"]}) is invoked.
This function returns either U+FFFD or the character based on the decimal or hexadecimal representation. It also discards ";" if present. If not present self.tokenQueue.append({"type": tokenTypes["ParseError"]}) is invoked.
def consumeNumberEntity(self, isHex): """This function returns either U+FFFD or the character based on the decimal or hexadecimal representation. It also discards ";" if present. If not present self.tokenQueue.append({"type": tokenTypes["ParseError"]}) is invoked. """ allowed = ...
[ "def", "consumeNumberEntity", "(", "self", ",", "isHex", ")", ":", "allowed", "=", "digits", "radix", "=", "10", "if", "isHex", ":", "allowed", "=", "hexDigits", "radix", "=", "16", "charStack", "=", "[", "]", "# Consume all the characters that are in range whil...
[ 70, 4 ]
[ 140, 19 ]
python
en
['en', 'en', 'en']
True
HTMLTokenizer.processEntityInAttribute
(self, allowedChar)
This method replaces the need for "entityInAttributeValueState".
This method replaces the need for "entityInAttributeValueState".
def processEntityInAttribute(self, allowedChar): """This method replaces the need for "entityInAttributeValueState". """ self.consumeEntity(allowedChar=allowedChar, fromAttribute=True)
[ "def", "processEntityInAttribute", "(", "self", ",", "allowedChar", ")", ":", "self", ".", "consumeEntity", "(", "allowedChar", "=", "allowedChar", ",", "fromAttribute", "=", "True", ")" ]
[ 222, 4 ]
[ 225, 71 ]
python
en
['en', 'en', 'en']
True
HTMLTokenizer.emitCurrentToken
(self)
This method is a generic handler for emitting the tags. It also sets the state to "data" because that's what's needed after a token has been emitted.
This method is a generic handler for emitting the tags. It also sets the state to "data" because that's what's needed after a token has been emitted.
def emitCurrentToken(self): """This method is a generic handler for emitting the tags. It also sets the state to "data" because that's what's needed after a token has been emitted. """ token = self.currentToken # Add token to the queue to be yielded if (token["typ...
[ "def", "emitCurrentToken", "(", "self", ")", ":", "token", "=", "self", ".", "currentToken", "# Add token to the queue to be yielded", "if", "(", "token", "[", "\"type\"", "]", "in", "tagTokenTypes", ")", ":", "token", "[", "\"name\"", "]", "=", "token", "[", ...
[ 227, 4 ]
[ 252, 35 ]
python
en
['en', 'en', 'en']
True
connection_from_url
(url, **kw)
Given a url, return an :class:`.ConnectionPool` instance of its host. This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an :class:`.ConnectionPool` instance. :param url: Absolute URL string that must include the scheme. Port is optional. ...
Given a url, return an :class:`.ConnectionPool` instance of its host.
def connection_from_url(url, **kw): """ Given a url, return an :class:`.ConnectionPool` instance of its host. This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an :class:`.ConnectionPool` instance. :param url: Absolute URL string that must...
[ "def", "connection_from_url", "(", "url", ",", "*", "*", "kw", ")", ":", "scheme", ",", "host", ",", "port", "=", "get_host", "(", "url", ")", "port", "=", "port", "or", "port_by_scheme", ".", "get", "(", "scheme", ",", "80", ")", "if", "scheme", "...
[ 989, 0 ]
[ 1014, 56 ]
python
en
['en', 'error', 'th']
False
_normalize_host
(host, scheme)
Normalize hosts for comparisons and use with sockets.
Normalize hosts for comparisons and use with sockets.
def _normalize_host(host, scheme): """ Normalize hosts for comparisons and use with sockets. """ host = normalize_host(host, scheme) # httplib doesn't like it when we include brackets in IPv6 addresses # Specifically, if we include brackets but also pass the port then # httplib crazily dou...
[ "def", "_normalize_host", "(", "host", ",", "scheme", ")", ":", "host", "=", "normalize_host", "(", "host", ",", "scheme", ")", "# httplib doesn't like it when we include brackets in IPv6 addresses", "# Specifically, if we include brackets but also pass the port then", "# httplib...
[ 1017, 0 ]
[ 1032, 15 ]
python
en
['en', 'error', 'th']
False
ConnectionPool.close
(self)
Close all pooled connections and disable the pool.
Close all pooled connections and disable the pool.
def close(self): """ Close all pooled connections and disable the pool. """ pass
[ "def", "close", "(", "self", ")", ":", "pass" ]
[ 96, 4 ]
[ 100, 12 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._new_conn
(self)
Return a fresh :class:`HTTPConnection`.
Return a fresh :class:`HTTPConnection`.
def _new_conn(self): """ Return a fresh :class:`HTTPConnection`. """ self.num_connections += 1 log.debug( "Starting new HTTP connection (%d): %s:%s", self.num_connections, self.host, self.port or "80", ) conn = self...
[ "def", "_new_conn", "(", "self", ")", ":", "self", ".", "num_connections", "+=", "1", "log", ".", "debug", "(", "\"Starting new HTTP connection (%d): %s:%s\"", ",", "self", ".", "num_connections", ",", "self", ".", "host", ",", "self", ".", "port", "or", "\"...
[ 220, 4 ]
[ 239, 19 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._get_conn
(self, timeout=None)
Get a connection. Will return a pooled connection if one is available. If no connections are available and :prop:`.block` is ``False``, then a fresh connection is returned. :param timeout: Seconds to wait before giving up and raising :class:`urllib3.exceptions....
Get a connection. Will return a pooled connection if one is available.
def _get_conn(self, timeout=None): """ Get a connection. Will return a pooled connection if one is available. If no connections are available and :prop:`.block` is ``False``, then a fresh connection is returned. :param timeout: Seconds to wait before giving up and r...
[ "def", "_get_conn", "(", "self", ",", "timeout", "=", "None", ")", ":", "conn", "=", "None", "try", ":", "conn", "=", "self", ".", "pool", ".", "get", "(", "block", "=", "self", ".", "block", ",", "timeout", "=", "timeout", ")", "except", "Attribut...
[ 241, 4 ]
[ 278, 39 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._put_conn
(self, conn)
Put a connection back into the pool. :param conn: Connection object for the current host and port as returned by :meth:`._new_conn` or :meth:`._get_conn`. If the pool is already full, the connection is closed and discarded because we exceeded maxsize. If connec...
Put a connection back into the pool.
def _put_conn(self, conn): """ Put a connection back into the pool. :param conn: Connection object for the current host and port as returned by :meth:`._new_conn` or :meth:`._get_conn`. If the pool is already full, the connection is closed and discarded ...
[ "def", "_put_conn", "(", "self", ",", "conn", ")", ":", "try", ":", "self", ".", "pool", ".", "put", "(", "conn", ",", "block", "=", "False", ")", "return", "# Everything is dandy, done.", "except", "AttributeError", ":", "# self.pool is None.", "pass", "exc...
[ 280, 4 ]
[ 306, 24 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._validate_conn
(self, conn)
Called right before a request is made, after the socket is created.
Called right before a request is made, after the socket is created.
def _validate_conn(self, conn): """ Called right before a request is made, after the socket is created. """ pass
[ "def", "_validate_conn", "(", "self", ",", "conn", ")", ":", "pass" ]
[ 308, 4 ]
[ 312, 12 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool._get_timeout
(self, timeout)
Helper that always returns a :class:`urllib3.util.Timeout`
Helper that always returns a :class:`urllib3.util.Timeout`
def _get_timeout(self, timeout): """ Helper that always returns a :class:`urllib3.util.Timeout` """ if timeout is _Default: return self.timeout.clone() if isinstance(timeout, Timeout): return timeout.clone() else: # User passed us an int/float. This i...
[ "def", "_get_timeout", "(", "self", ",", "timeout", ")", ":", "if", "timeout", "is", "_Default", ":", "return", "self", ".", "timeout", ".", "clone", "(", ")", "if", "isinstance", "(", "timeout", ",", "Timeout", ")", ":", "return", "timeout", ".", "clo...
[ 318, 4 ]
[ 328, 46 ]
python
en
['en', 'lb', 'en']
True
HTTPConnectionPool._raise_timeout
(self, err, url, timeout_value)
Is the error actually a timeout? Will raise a ReadTimeout or pass
Is the error actually a timeout? Will raise a ReadTimeout or pass
def _raise_timeout(self, err, url, timeout_value): """Is the error actually a timeout? Will raise a ReadTimeout or pass""" if isinstance(err, SocketTimeout): raise ReadTimeoutError( self, url, "Read timed out. (read timeout=%s)" % timeout_value ) # See t...
[ "def", "_raise_timeout", "(", "self", ",", "err", ",", "url", ",", "timeout_value", ")", ":", "if", "isinstance", "(", "err", ",", "SocketTimeout", ")", ":", "raise", "ReadTimeoutError", "(", "self", ",", "url", ",", "\"Read timed out. (read timeout=%s)\"", "%...
[ 330, 4 ]
[ 353, 13 ]
python
en
['en', 'en', 'en']
True
HTTPConnectionPool._make_request
( self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw )
Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout: Socket timeout in seconds for the request. This can be a float or integer, which will set the same ...
Perform a request on a given urllib connection object taken from our pool.
def _make_request( self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw ): """ Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout:...
[ "def", "_make_request", "(", "self", ",", "conn", ",", "method", ",", "url", ",", "timeout", "=", "_Default", ",", "chunked", "=", "False", ",", "*", "*", "httplib_request_kw", ")", ":", "self", ".", "num_requests", "+=", "1", "timeout_obj", "=", "self",...
[ 355, 4 ]
[ 454, 31 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool.close
(self)
Close all pooled connections and disable the pool.
Close all pooled connections and disable the pool.
def close(self): """ Close all pooled connections and disable the pool. """ if self.pool is None: return # Disable access to the pool old_pool, self.pool = self.pool, None try: while True: conn = old_pool.get(block=False) ...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "pool", "is", "None", ":", "return", "# Disable access to the pool", "old_pool", ",", "self", ".", "pool", "=", "self", ".", "pool", ",", "None", "try", ":", "while", "True", ":", "conn", "=", ...
[ 459, 4 ]
[ 475, 16 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool.is_same_host
(self, url)
Check if the given ``url`` is a member of the same host as this connection pool.
Check if the given ``url`` is a member of the same host as this connection pool.
def is_same_host(self, url): """ Check if the given ``url`` is a member of the same host as this connection pool. """ if url.startswith("/"): return True # TODO: Add optional support for socket.gethostbyname checking. scheme, host, port = get_host(url...
[ "def", "is_same_host", "(", "self", ",", "url", ")", ":", "if", "url", ".", "startswith", "(", "\"/\"", ")", ":", "return", "True", "# TODO: Add optional support for socket.gethostbyname checking.", "scheme", ",", "host", ",", "port", "=", "get_host", "(", "url"...
[ 477, 4 ]
[ 496, 74 ]
python
en
['en', 'error', 'th']
False
HTTPConnectionPool.urlopen
( self, method, url, body=None, headers=None, retries=None, redirect=True, assert_same_host=True, timeout=_Default, pool_timeout=None, release_conn=None, chunked=False, body_pos=None, **response_kw )
Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you'll need to specify all the raw details. .. note:: More commonly, it's appropriate to use a convenience method provided by :class:`.RequestMethod...
Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you'll need to specify all the raw details.
def urlopen( self, method, url, body=None, headers=None, retries=None, redirect=True, assert_same_host=True, timeout=_Default, pool_timeout=None, release_conn=None, chunked=False, body_pos=None, **response_kw...
[ "def", "urlopen", "(", "self", ",", "method", ",", "url", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "retries", "=", "None", ",", "redirect", "=", "True", ",", "assert_same_host", "=", "True", ",", "timeout", "=", "_Default", ",", "p...
[ 498, 4 ]
[ 830, 23 ]
python
en
['en', 'error', 'th']
False
HTTPSConnectionPool._prepare_conn
(self, conn)
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used.
Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used.
def _prepare_conn(self, conn): """ Prepare the ``connection`` for :meth:`urllib3.util.ssl_wrap_socket` and establish the tunnel if proxy is used. """ if isinstance(conn, VerifiedHTTPSConnection): conn.set_cert( key_file=self.key_file, ...
[ "def", "_prepare_conn", "(", "self", ",", "conn", ")", ":", "if", "isinstance", "(", "conn", ",", "VerifiedHTTPSConnection", ")", ":", "conn", ".", "set_cert", "(", "key_file", "=", "self", ".", "key_file", ",", "key_password", "=", "self", ".", "key_passw...
[ 903, 4 ]
[ 921, 19 ]
python
en
['en', 'error', 'th']
False
HTTPSConnectionPool._prepare_proxy
(self, conn)
Establish tunnel connection early, because otherwise httplib would improperly set Host: header to proxy's IP:port.
Establish tunnel connection early, because otherwise httplib would improperly set Host: header to proxy's IP:port.
def _prepare_proxy(self, conn): """ Establish tunnel connection early, because otherwise httplib would improperly set Host: header to proxy's IP:port. """ conn.set_tunnel(self._proxy_host, self.port, self.proxy_headers) conn.connect()
[ "def", "_prepare_proxy", "(", "self", ",", "conn", ")", ":", "conn", ".", "set_tunnel", "(", "self", ".", "_proxy_host", ",", "self", ".", "port", ",", "self", ".", "proxy_headers", ")", "conn", ".", "connect", "(", ")" ]
[ 923, 4 ]
[ 929, 22 ]
python
en
['en', 'error', 'th']
False
HTTPSConnectionPool._new_conn
(self)
Return a fresh :class:`httplib.HTTPSConnection`.
Return a fresh :class:`httplib.HTTPSConnection`.
def _new_conn(self): """ Return a fresh :class:`httplib.HTTPSConnection`. """ self.num_connections += 1 log.debug( "Starting new HTTPS connection (%d): %s:%s", self.num_connections, self.host, self.port or "443", ) ...
[ "def", "_new_conn", "(", "self", ")", ":", "self", ".", "num_connections", "+=", "1", "log", ".", "debug", "(", "\"Starting new HTTPS connection (%d): %s:%s\"", ",", "self", ".", "num_connections", ",", "self", ".", "host", ",", "self", ".", "port", "or", "\...
[ 931, 4 ]
[ 965, 39 ]
python
en
['en', 'error', 'th']
False
HTTPSConnectionPool._validate_conn
(self, conn)
Called right before a request is made, after the socket is created.
Called right before a request is made, after the socket is created.
def _validate_conn(self, conn): """ Called right before a request is made, after the socket is created. """ super(HTTPSConnectionPool, self)._validate_conn(conn) # Force connect early to allow us to validate the connection. if not getattr(conn, "sock", None): # AppEngin...
[ "def", "_validate_conn", "(", "self", ",", "conn", ")", ":", "super", "(", "HTTPSConnectionPool", ",", "self", ")", ".", "_validate_conn", "(", "conn", ")", "# Force connect early to allow us to validate the connection.", "if", "not", "getattr", "(", "conn", ",", ...
[ 967, 4 ]
[ 986, 13 ]
python
en
['en', 'error', 'th']
False
openapi_param_value_generator
( endpoints: List[str], )
This decorator is used to register OpenAPI param value genarator functions with endpoints. Example usage: @openapi_param_value_generator(["/messages/render:post"]) def ...
This decorator is used to register OpenAPI param value genarator functions with endpoints. Example usage:
def openapi_param_value_generator( endpoints: List[str], ) -> Callable[[Callable[[], Dict[str, object]]], Callable[[], Dict[str, object]]]: """This decorator is used to register OpenAPI param value genarator functions with endpoints. Example usage: @openapi_param_value_generator(["/messages/render:post...
[ "def", "openapi_param_value_generator", "(", "endpoints", ":", "List", "[", "str", "]", ",", ")", "->", "Callable", "[", "[", "Callable", "[", "[", "]", ",", "Dict", "[", "str", ",", "object", "]", "]", "]", ",", "Callable", "[", "[", "]", ",", "Di...
[ 35, 0 ]
[ 57, 18 ]
python
en
['en', 'en', 'en']
True
assert_all_helper_functions_called
()
Throws an exception if any registered helpers were not called by tests
Throws an exception if any registered helpers were not called by tests
def assert_all_helper_functions_called() -> None: """Throws an exception if any registered helpers were not called by tests""" if REGISTERED_GENERATOR_FUNCTIONS == CALLED_GENERATOR_FUNCTIONS: return uncalled_functions = str(REGISTERED_GENERATOR_FUNCTIONS - CALLED_GENERATOR_FUNCTIONS) raise Exc...
[ "def", "assert_all_helper_functions_called", "(", ")", "->", "None", ":", "if", "REGISTERED_GENERATOR_FUNCTIONS", "==", "CALLED_GENERATOR_FUNCTIONS", ":", "return", "uncalled_functions", "=", "str", "(", "REGISTERED_GENERATOR_FUNCTIONS", "-", "CALLED_GENERATOR_FUNCTIONS", ")"...
[ 60, 0 ]
[ 67, 92 ]
python
en
['en', 'en', 'en']
True
CreateNetwork._setup_subnet_parameters
(self, params, data, is_create=True)
Setup subnet parameters This methods setups subnet parameters which are available in both create and update.
Setup subnet parameters
def _setup_subnet_parameters(self, params, data, is_create=True): """Setup subnet parameters This methods setups subnet parameters which are available in both create and update. """ is_update = not is_create params['enable_dhcp'] = data['enable_dhcp'] if int(data...
[ "def", "_setup_subnet_parameters", "(", "self", ",", "params", ",", "data", ",", "is_create", "=", "True", ")", ":", "is_update", "=", "not", "is_create", "params", "[", "'enable_dhcp'", "]", "=", "data", "[", "'enable_dhcp'", "]", "if", "int", "(", "data"...
[ 503, 4 ]
[ 533, 51 ]
python
en
['en', 'fr', 'en']
True
CreateNetwork._delete_network
(self, request, network)
Delete the created network when subnet creation failed.
Delete the created network when subnet creation failed.
def _delete_network(self, request, network): """Delete the created network when subnet creation failed.""" try: api.neutron.network_delete(request, network.id) LOG.debug('Delete the created network %s ' 'due to subnet creation failure.', network.id) ...
[ "def", "_delete_network", "(", "self", ",", "request", ",", "network", ")", ":", "try", ":", "api", ".", "neutron", ".", "network_delete", "(", "request", ",", "network", ".", "id", ")", "LOG", ".", "debug", "(", "'Delete the created network %s '", "'due to ...
[ 583, 4 ]
[ 599, 62 ]
python
en
['en', 'en', 'en']
True
TestInstances.test_create_delete_instance
(self)
tests the instance creation and deletion functionality: * creates a new instance in Project > Compute > Instances page * verifies the instance appears in the instances table as active * deletes the newly created instance via proper page (depends on user) * verifies the instance does not...
tests the instance creation and deletion functionality:
def test_create_delete_instance(self): """tests the instance creation and deletion functionality: * creates a new instance in Project > Compute > Instances page * verifies the instance appears in the instances table as active * deletes the newly created instance via proper page (depends...
[ "def", "test_create_delete_instance", "(", "self", ")", ":", "instances_page", "=", "self", ".", "home_pg", ".", "go_to_project_compute_instancespage", "(", ")", "instances_page", ".", "create_instance", "(", "self", ".", "INSTANCE_NAME", ")", "self", ".", "assertTr...
[ 25, 4 ]
[ 48, 79 ]
python
en
['en', 'en', 'en']
True
TestInstances.test_instances_pagination
(self)
This test checks instance pagination Steps: 1) Login to Horizon Dashboard as regular user 2) Navigate to user settings page 3) Change 'Items Per Page' value to 1 4) Go to Project > Compute > Instances page 5) Create 2 instances 6) Go to appropriate page (depends ...
This test checks instance pagination
def test_instances_pagination(self): """This test checks instance pagination Steps: 1) Login to Horizon Dashboard as regular user 2) Navigate to user settings page 3) Change 'Items Per Page' value to 1 4) Go to Project > Compute > Instances page 5) Create 2 insta...
[ "def", "test_instances_pagination", "(", "self", ")", ":", "items_per_page", "=", "1", "instance_count", "=", "2", "instance_list", "=", "[", "\"{0}-{1}\"", ".", "format", "(", "self", ".", "INSTANCE_NAME", ",", "item", ")", "for", "item", "in", "range", "("...
[ 51, 4 ]
[ 111, 76 ]
python
en
['en', 'en', 'en']
True
TestInstances.test_instances_pagination_and_filtration
(self)
This test checks instance pagination and filtration Steps: 1) Login to Horizon Dashboard as regular user 2) Go to to user settings page 3) Change 'Items Per Page' value to 1 4) Go to Project > Compute > Instances page 5) Create 2 instances 6) Go to appropriate pa...
This test checks instance pagination and filtration
def test_instances_pagination_and_filtration(self): """This test checks instance pagination and filtration Steps: 1) Login to Horizon Dashboard as regular user 2) Go to to user settings page 3) Change 'Items Per Page' value to 1 4) Go to Project > Compute > Instances pag...
[ "def", "test_instances_pagination_and_filtration", "(", "self", ")", ":", "items_per_page", "=", "1", "instance_count", "=", "2", "instance_list", "=", "[", "\"{0}-{1}\"", ".", "format", "(", "self", ".", "INSTANCE_NAME", ",", "item", ")", "for", "item", "in", ...
[ 114, 4 ]
[ 184, 76 ]
python
en
['en', 'en', 'en']
True
TestInstances.test_filter_instances
(self)
This test checks filtering of instances by Instance Name Steps: 1) Login to Horizon dashboard as regular user 2) Go to Project > Compute > Instances 3) Create 2 instances 4) Go to appropriate page (depends on user) 5) Use filter by Instance Name 6) Check that fil...
This test checks filtering of instances by Instance Name
def test_filter_instances(self): """This test checks filtering of instances by Instance Name Steps: 1) Login to Horizon dashboard as regular user 2) Go to Project > Compute > Instances 3) Create 2 instances 4) Go to appropriate page (depends on user) 5) Use filte...
[ "def", "test_filter_instances", "(", "self", ")", ":", "instance_count", "=", "2", "instance_list", "=", "[", "\"{0}-{1}\"", ".", "format", "(", "self", ".", "INSTANCE_NAME", ",", "item", ")", "for", "item", "in", "range", "(", "1", ",", "instance_count", ...
[ 187, 4 ]
[ 234, 76 ]
python
en
['en', 'en', 'en']
True
reporthook
(t)
https://github.com/tqdm/tqdm
https://github.com/tqdm/tqdm
def reporthook(t): """https://github.com/tqdm/tqdm""" last_b = [0] def inner(b=1, bsize=1, tsize=None): """ b: int, optionala Number of blocks just transferred [default: 1]. bsize: int, optional Size of each block (in tqdm units) [default: 1]. tsize: int, opt...
[ "def", "reporthook", "(", "t", ")", ":", "last_b", "=", "[", "0", "]", "def", "inner", "(", "b", "=", "1", ",", "bsize", "=", "1", ",", "tsize", "=", "None", ")", ":", "\"\"\"\n b: int, optionala\n Number of blocks just transferred [default: 1].\n ...
[ 12, 0 ]
[ 29, 16 ]
python
en
['en', 'hmn', 'hi']
False
url_to_file_path
(url, filecache)
Return the file cache path based on the URL. This does not ensure the file exists!
Return the file cache path based on the URL.
def url_to_file_path(url, filecache): """Return the file cache path based on the URL. This does not ensure the file exists! """ key = CacheController.cache_url(url) return filecache._fn(key)
[ "def", "url_to_file_path", "(", "url", ",", "filecache", ")", ":", "key", "=", "CacheController", ".", "cache_url", "(", "url", ")", "return", "filecache", ".", "_fn", "(", "key", ")" ]
[ 139, 0 ]
[ 145, 29 ]
python
en
['en', 'en', 'en']
True
read_file
(path_to_file: str)
Return the file data from `path_to_file`.
Return the file data from `path_to_file`.
def read_file(path_to_file: str): """Return the file data from `path_to_file`.""" with open(path_to_file, 'r') as json_file: return json_file.read()
[ "def", "read_file", "(", "path_to_file", ":", "str", ")", ":", "with", "open", "(", "path_to_file", ",", "'r'", ")", "as", "json_file", ":", "return", "json_file", ".", "read", "(", ")" ]
[ 13, 0 ]
[ 16, 31 ]
python
en
['en', 'en', 'en']
True
write_to_file
(path_to_file: str, data)
Write `data` to file from `path_to_file`.
Write `data` to file from `path_to_file`.
def write_to_file(path_to_file: str, data): """Write `data` to file from `path_to_file`.""" with open(path_to_file, 'w') as json_file: return json_file.write(data)
[ "def", "write_to_file", "(", "path_to_file", ":", "str", ",", "data", ")", ":", "with", "open", "(", "path_to_file", ",", "'w'", ")", "as", "json_file", ":", "return", "json_file", ".", "write", "(", "data", ")" ]
[ 18, 0 ]
[ 21, 36 ]
python
en
['en', 'en', 'en']
True
load_json_from_file
(path_to_file: str)
Load JSON data from file from `path_to_file` by `json.load()`. Previously call `read_file()`.
Load JSON data from file from `path_to_file` by `json.load()`. Previously call `read_file()`.
def load_json_from_file(path_to_file: str): """Load JSON data from file from `path_to_file` by `json.load()`. Previously call `read_file()`. """ return json.loads(read_file(path_to_file))
[ "def", "load_json_from_file", "(", "path_to_file", ":", "str", ")", ":", "return", "json", ".", "loads", "(", "read_file", "(", "path_to_file", ")", ")" ]
[ 23, 0 ]
[ 27, 46 ]
python
en
['en', 'en', 'en']
True
dump_json_to_file
(path_to_file: str, data)
Dump JSON data and write it to file from `path_to_file`. `ensure_ascii` option is disabled, indentation is enabled.
Dump JSON data and write it to file from `path_to_file`. `ensure_ascii` option is disabled, indentation is enabled.
def dump_json_to_file(path_to_file: str, data): """Dump JSON data and write it to file from `path_to_file`. `ensure_ascii` option is disabled, indentation is enabled. """ write_to_file( path_to_file, json.dumps(data, ensure_ascii=False, indent=4) )
[ "def", "dump_json_to_file", "(", "path_to_file", ":", "str", ",", "data", ")", ":", "write_to_file", "(", "path_to_file", ",", "json", ".", "dumps", "(", "data", ",", "ensure_ascii", "=", "False", ",", "indent", "=", "4", ")", ")" ]
[ 29, 0 ]
[ 36, 9 ]
python
en
['en', 'en', 'en']
True
Jwrap.__init__
(self, path_to_file)
Check `path_to_file`, create directory if not exist and create file if not exist. If file is empty write empty dict into it. Load JSON from file. Varisbles: `__file` -- contains path to json file (`path_to_file`). `__json_data` -- contains loaded JSON data from `__file`. ...
Check `path_to_file`, create directory if not exist and create file if not exist. If file is empty write empty dict into it. Load JSON from file.
def __init__(self, path_to_file): """Check `path_to_file`, create directory if not exist and create file if not exist. If file is empty write empty dict into it. Load JSON from file. Varisbles: `__file` -- contains path to json file (`path_to_file`). `__json_data` -...
[ "def", "__init__", "(", "self", ",", "path_to_file", ")", ":", "dirname", "=", "os", ".", "path", ".", "dirname", "(", "path_to_file", ")", "if", "dirname", "==", "''", "or", "dirname", "==", "'.'", ":", "self", ".", "__file", "=", "path_to_file", "els...
[ 49, 4 ]
[ 71, 63 ]
python
en
['en', 'en', 'en']
True
Jwrap.get_file
(self)
Return abspath to `__file`.
Return abspath to `__file`.
def get_file(self) -> str: """Return abspath to `__file`.""" return os.path.abspath(self.__file)
[ "def", "get_file", "(", "self", ")", "->", "str", ":", "return", "os", ".", "path", ".", "abspath", "(", "self", ".", "__file", ")" ]
[ 73, 4 ]
[ 75, 43 ]
python
en
['en', 'de', 'en']
True
Jwrap.json
(self)
Return `__json_data`.
Return `__json_data`.
def json(self) -> dict: """Return `__json_data`.""" return self.__json_data
[ "def", "json", "(", "self", ")", "->", "dict", ":", "return", "self", ".", "__json_data" ]
[ 77, 4 ]
[ 79, 31 ]
python
en
['en', 'ha', 'hi']
False
Jwrap.reload
(self)
Reload JSON data from file.
Reload JSON data from file.
def reload(self): """Reload JSON data from file.""" self.__json_data = load_json_from_file(self.__file)
[ "def", "reload", "(", "self", ")", ":", "self", ".", "__json_data", "=", "load_json_from_file", "(", "self", ".", "__file", ")" ]
[ 81, 4 ]
[ 83, 59 ]
python
en
['en', 'en', 'en']
True
Jwrap.commit
(self)
Write JSON data to file.
Write JSON data to file.
def commit(self): """Write JSON data to file.""" dump_json_to_file(self.__file, self.__json_data)
[ "def", "commit", "(", "self", ")", ":", "dump_json_to_file", "(", "self", ".", "__file", ",", "self", ".", "__json_data", ")" ]
[ 85, 4 ]
[ 87, 56 ]
python
en
['en', 'jv', 'en']
True
Jwrap.keys
(self)
Return root level key list.
Return root level key list.
def keys(self) -> list: """Return root level key list.""" return list(self.__json_data.keys())
[ "def", "keys", "(", "self", ")", "->", "list", ":", "return", "list", "(", "self", ".", "__json_data", ".", "keys", "(", ")", ")" ]
[ 89, 4 ]
[ 91, 44 ]
python
bg
['fr', 'bg', 'en']
False
Jwrap.subkeys
(self, key: str)
Return list of `key` subkeys.
Return list of `key` subkeys.
def subkeys(self, key: str) -> list: """Return list of `key` subkeys.""" return list(self.__json_data[key].keys())
[ "def", "subkeys", "(", "self", ",", "key", ":", "str", ")", "->", "list", ":", "return", "list", "(", "self", ".", "__json_data", "[", "key", "]", ".", "keys", "(", ")", ")" ]
[ 93, 4 ]
[ 95, 49 ]
python
en
['en', 'ru-Latn', 'en']
True
Jwrap.keys_by_value
(self, value)
Return list of keys by value `value`
Return list of keys by value `value`
def keys_by_value(self, value) -> list: """Return list of keys by value `value`""" return [key for key, val in self.__json_data.items() if val == value]
[ "def", "keys_by_value", "(", "self", ",", "value", ")", "->", "list", ":", "return", "[", "key", "for", "key", ",", "val", "in", "self", ".", "__json_data", ".", "items", "(", ")", "if", "val", "==", "value", "]" ]
[ 97, 4 ]
[ 99, 77 ]
python
en
['en', 'sv', 'en']
True
Jwrap.ins
(self, key: str, value)
Insert `key` with value `value`.
Insert `key` with value `value`.
def ins(self, key: str, value): """Insert `key` with value `value`.""" self.__json_data[key] = value
[ "def", "ins", "(", "self", ",", "key", ":", "str", ",", "value", ")", ":", "self", ".", "__json_data", "[", "key", "]", "=", "value" ]
[ 101, 4 ]
[ 103, 37 ]
python
en
['en', 'en', 'en']
True
Jwrap.inssub
(self, key: str, subkey: str, value)
Similar to `ins`, but for subset.
Similar to `ins`, but for subset.
def inssub(self, key: str, subkey: str, value): """Similar to `ins`, but for subset.""" self.__json_data[key][subkey] = value
[ "def", "inssub", "(", "self", ",", "key", ":", "str", ",", "subkey", ":", "str", ",", "value", ")", ":", "self", ".", "__json_data", "[", "key", "]", "[", "subkey", "]", "=", "value" ]
[ 105, 4 ]
[ 107, 45 ]
python
en
['en', 'en', 'en']
True
Jwrap.rem
(self, key: str)
Remove value from JSON by `key`.
Remove value from JSON by `key`.
def rem(self, key: str): """Remove value from JSON by `key`.""" del self.__json_data[key]
[ "def", "rem", "(", "self", ",", "key", ":", "str", ")", ":", "del", "self", ".", "__json_data", "[", "key", "]" ]
[ 109, 4 ]
[ 111, 33 ]
python
en
['en', 'en', 'en']
True
Jwrap.remsub
(self, key: str, subkey: str)
Similar to `rem`, but for subset. Remove value by `subkey` of `key`.
Similar to `rem`, but for subset. Remove value by `subkey` of `key`.
def remsub(self, key: str, subkey: str): """Similar to `rem`, but for subset. Remove value by `subkey` of `key`. """ del self.__json_data[key][subkey]
[ "def", "remsub", "(", "self", ",", "key", ":", "str", ",", "subkey", ":", "str", ")", ":", "del", "self", ".", "__json_data", "[", "key", "]", "[", "subkey", "]" ]
[ 113, 4 ]
[ 117, 41 ]
python
en
['en', 'en', 'en']
True
_build_pack_info_from_dones
(dones: torch.Tensor, T: int)
Create the indexing info needed to make the PackedSequence based on the dones. PackedSequences are PyTorch's way of supporting a single RNN forward call where each input in the batch can have an arbitrary sequence length They work as follows: Given the sequences [c], [x, y, z], [a, b], we generat...
Create the indexing info needed to make the PackedSequence based on the dones.
def _build_pack_info_from_dones(dones: torch.Tensor, T: int) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]: """ Create the indexing info needed to make the PackedSequence based on the dones. PackedSequences are PyTorch's way of supporting a single RNN forward call where...
[ "def", "_build_pack_info_from_dones", "(", "dones", ":", "torch", ".", "Tensor", ",", "T", ":", "int", ")", "->", "Tuple", "[", "torch", ".", "Tensor", ",", "torch", ".", "Tensor", ",", "torch", ".", "Tensor", ",", "torch", ".", "Tensor", ",", "torch",...
[ 36, 0 ]
[ 132, 88 ]
python
en
['en', 'error', 'th']
False
build_rnn_inputs
(x, dones_cpu, rnn_states, T: int)
Create a PackedSequence input for an RNN such that each set of steps that are part of the same episode are all part of a batch in the PackedSequence. Use the returned select_inds and build_core_out_from_seq to invert this. :param x: A (N*T, -1) tensor of the data to build the PackedSequence out of ...
Create a PackedSequence input for an RNN such that each set of steps that are part of the same episode are all part of a batch in the PackedSequence. Use the returned select_inds and build_core_out_from_seq to invert this. :param x: A (N*T, -1) tensor of the data to build the PackedSequence out of ...
def build_rnn_inputs(x, dones_cpu, rnn_states, T: int): """ Create a PackedSequence input for an RNN such that each set of steps that are part of the same episode are all part of a batch in the PackedSequence. Use the returned select_inds and build_core_out_from_seq to invert this. :param x: A (...
[ "def", "build_rnn_inputs", "(", "x", ",", "dones_cpu", ",", "rnn_states", ",", "T", ":", "int", ")", ":", "rollout_starts", ",", "is_new_episode", ",", "select_inds", ",", "batch_sizes", ",", "sorted_indices", "=", "_build_pack_info_from_dones", "(", "dones_cpu", ...
[ 135, 0 ]
[ 175, 50 ]
python
en
['en', 'error', 'th']
False
LearnerWorker._calculate_gae
(self, buffer)
Calculate advantages using Generalized Advantage Estimation. This is leftover the from previous version of the algorithm. Perhaps should be re-implemented in PyTorch tensors, similar to V-trace for uniformity.
Calculate advantages using Generalized Advantage Estimation. This is leftover the from previous version of the algorithm. Perhaps should be re-implemented in PyTorch tensors, similar to V-trace for uniformity.
def _calculate_gae(self, buffer): """ Calculate advantages using Generalized Advantage Estimation. This is leftover the from previous version of the algorithm. Perhaps should be re-implemented in PyTorch tensors, similar to V-trace for uniformity. """ rewards = torch.sta...
[ "def", "_calculate_gae", "(", "self", ",", "buffer", ")", ":", "rewards", "=", "torch", ".", "stack", "(", "buffer", ".", "rewards", ")", ".", "numpy", "(", ")", ".", "squeeze", "(", ")", "# [E, T]", "dones", "=", "torch", ".", "stack", "(", "buffer"...
[ 295, 4 ]
[ 330, 21 ]
python
en
['en', 'error', 'th']
False
LearnerWorker._get_minibatches
(self, batch_size, experience_size)
Generating minibatches for training.
Generating minibatches for training.
def _get_minibatches(self, batch_size, experience_size): """Generating minibatches for training.""" assert self.cfg.rollout % self.cfg.recurrence == 0 assert experience_size % batch_size == 0, f'experience size: {experience_size}, batch size: {batch_size}' if self.cfg.num_batches_per_it...
[ "def", "_get_minibatches", "(", "self", ",", "batch_size", ",", "experience_size", ")", ":", "assert", "self", ".", "cfg", ".", "rollout", "%", "self", ".", "cfg", ".", "recurrence", "==", "0", "assert", "experience_size", "%", "batch_size", "==", "0", ","...
[ 450, 4 ]
[ 470, 26 ]
python
en
['en', 'en', 'en']
True
LearnerWorker._after_optimizer_step
(self)
A hook to be called after each optimizer step.
A hook to be called after each optimizer step.
def _after_optimizer_step(self): """A hook to be called after each optimizer step.""" self.train_step += 1 self._maybe_save()
[ "def", "_after_optimizer_step", "(", "self", ")", ":", "self", ".", "train_step", "+=", "1", "self", ".", "_maybe_save", "(", ")" ]
[ 497, 4 ]
[ 500, 26 ]
python
en
['en', 'en', 'en']
True
LearnerWorker._update_pbt
(self)
To be called from the training loop, same thread that updates the model!
To be called from the training loop, same thread that updates the model!
def _update_pbt(self): """To be called from the training loop, same thread that updates the model!""" with self.pbt_mutex: if self.load_policy_id is not None: assert self.cfg.with_pbt log.debug('Learner %d loads policy from %d', self.policy_id, self.load_poli...
[ "def", "_update_pbt", "(", "self", ")", ":", "with", "self", ".", "pbt_mutex", ":", "if", "self", ".", "load_policy_id", "is", "not", "None", ":", "assert", "self", ".", "cfg", ".", "with_pbt", "log", ".", "debug", "(", "'Learner %d loads policy from %d'", ...
[ 900, 4 ]
[ 921, 35 ]
python
en
['en', 'en', 'en']
True
avatar
( request: HttpRequest, user_profile: UserProfile, email_or_id: str, medium: bool = False )
Accepts an email address or user ID and returns the avatar
Accepts an email address or user ID and returns the avatar
def avatar( request: HttpRequest, user_profile: UserProfile, email_or_id: str, medium: bool = False ) -> HttpResponse: """Accepts an email address or user ID and returns the avatar""" is_email = False try: int(email_or_id) except ValueError: is_email = True try: realm = ...
[ "def", "avatar", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "email_or_id", ":", "str", ",", "medium", ":", "bool", "=", "False", ")", "->", "HttpResponse", ":", "is_email", "=", "False", "try", ":", "int", "(", "ema...
[ 214, 0 ]
[ 246, 24 ]
python
en
['en', 'en', 'en']
True
get_members_backend
( request: HttpRequest, user_profile: UserProfile, user_id: Optional[int] = None, include_custom_profile_fields: bool = REQ(json_validator=check_bool, default=False), client_gravatar: bool = REQ(json_validator=check_bool, default=False), )
The client_gravatar field here is set to True if clients can compute their own gravatars, which saves us bandwidth. We want to eventually make this the default behavior, but we have old clients that expect the server to compute this for us.
The client_gravatar field here is set to True if clients can compute their own gravatars, which saves us bandwidth. We want to eventually make this the default behavior, but we have old clients that expect the server to compute this for us.
def get_members_backend( request: HttpRequest, user_profile: UserProfile, user_id: Optional[int] = None, include_custom_profile_fields: bool = REQ(json_validator=check_bool, default=False), client_gravatar: bool = REQ(json_validator=check_bool, default=False), ) -> HttpResponse: """ The clie...
[ "def", "get_members_backend", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "user_id", ":", "Optional", "[", "int", "]", "=", "None", ",", "include_custom_profile_fields", ":", "bool", "=", "REQ", "(", "json_validator", "=", ...
[ 520, 0 ]
[ 558, 29 ]
python
en
['en', 'error', 'th']
False
install_lib.get_outputs
(self)
Return the list of files that would be installed if this command were actually run. Not affected by the "dry-run" flag or whether modules have actually been built yet.
Return the list of files that would be installed if this command were actually run. Not affected by the "dry-run" flag or whether modules have actually been built yet.
def get_outputs(self): """Return the list of files that would be installed if this command were actually run. Not affected by the "dry-run" flag or whether modules have actually been built yet. """ pure_outputs = \ self._mutate_outputs(self.distribution.has_pure_modu...
[ "def", "get_outputs", "(", "self", ")", ":", "pure_outputs", "=", "self", ".", "_mutate_outputs", "(", "self", ".", "distribution", ".", "has_pure_modules", "(", ")", ",", "'build_py'", ",", "'build_lib'", ",", "self", ".", "install_dir", ")", "if", "self", ...
[ 179, 4 ]
[ 198, 60 ]
python
en
['en', 'en', 'en']
True
install_lib.get_inputs
(self)
Get the list of files that are input to this command, ie. the files that get installed as they are named in the build tree. The files in this list correspond one-to-one to the output filenames returned by 'get_outputs()'.
Get the list of files that are input to this command, ie. the files that get installed as they are named in the build tree. The files in this list correspond one-to-one to the output filenames returned by 'get_outputs()'.
def get_inputs(self): """Get the list of files that are input to this command, ie. the files that get installed as they are named in the build tree. The files in this list correspond one-to-one to the output filenames returned by 'get_outputs()'. """ inputs = [] ...
[ "def", "get_inputs", "(", "self", ")", ":", "inputs", "=", "[", "]", "if", "self", ".", "distribution", ".", "has_pure_modules", "(", ")", ":", "build_py", "=", "self", ".", "get_finalized_command", "(", "'build_py'", ")", "inputs", ".", "extend", "(", "...
[ 200, 4 ]
[ 216, 21 ]
python
en
['en', 'en', 'en']
True
add_missing_messages
(user_profile: UserProfile)
This function takes a soft-deactivated user, and computes and adds to the database any UserMessage rows that were not created while the user was soft-deactivated. The end result is that from the perspective of the message database, it should be impossible to tell that the user was soft-deactivated at a...
This function takes a soft-deactivated user, and computes and adds to the database any UserMessage rows that were not created while the user was soft-deactivated. The end result is that from the perspective of the message database, it should be impossible to tell that the user was soft-deactivated at a...
def add_missing_messages(user_profile: UserProfile) -> None: """This function takes a soft-deactivated user, and computes and adds to the database any UserMessage rows that were not created while the user was soft-deactivated. The end result is that from the perspective of the message database, it shou...
[ "def", "add_missing_messages", "(", "user_profile", ":", "UserProfile", ")", "->", "None", ":", "assert", "user_profile", ".", "last_active_message_id", "is", "not", "None", "all_stream_subs", "=", "list", "(", "Subscription", ".", "objects", ".", "filter", "(", ...
[ 103, 0 ]
[ 228, 67 ]
python
en
['en', 'en', 'en']
True
TestGroup.test_create_delete_group
(self)
Tests ability to create and delete a group
Tests ability to create and delete a group
def test_create_delete_group(self): """Tests ability to create and delete a group""" group_name = self.group_name self._test_create_group(group_name) self._test_delete_group(group_name)
[ "def", "test_create_delete_group", "(", "self", ")", ":", "group_name", "=", "self", ".", "group_name", "self", ".", "_test_create_group", "(", "group_name", ")", "self", ".", "_test_delete_group", "(", "group_name", ")" ]
[ 47, 4 ]
[ 51, 43 ]
python
en
['en', 'en', 'en']
True
TestGroup.test_edit_group
(self)
Tests ability to edit group name and description
Tests ability to edit group name and description
def test_edit_group(self): """Tests ability to edit group name and description""" group_name = self.group_name self._test_create_group(group_name) new_group_name = self.group_name new_group_desc = self.group_description self.groups_page.edit_group(group_name, new_group_na...
[ "def", "test_edit_group", "(", "self", ")", ":", "group_name", "=", "self", ".", "group_name", "self", ".", "_test_create_group", "(", "group_name", ")", "new_group_name", "=", "self", ".", "group_name", "new_group_desc", "=", "self", ".", "group_description", "...
[ 53, 4 ]
[ 65, 47 ]
python
en
['en', 'en', 'en']
True
to_genshi
(walker)
Convert a tree to a genshi tree :arg walker: the treewalker to use to walk the tree to convert it :returns: generator of genshi nodes
Convert a tree to a genshi tree
def to_genshi(walker): """Convert a tree to a genshi tree :arg walker: the treewalker to use to walk the tree to convert it :returns: generator of genshi nodes """ text = [] for token in walker: type = token["type"] if type in ("Characters", "SpaceCharacters"): tex...
[ "def", "to_genshi", "(", "walker", ")", ":", "text", "=", "[", "]", "for", "token", "in", "walker", ":", "type", "=", "token", "[", "\"type\"", "]", "if", "type", "in", "(", "\"Characters\"", ",", "\"SpaceCharacters\"", ")", ":", "text", ".", "append",...
[ 6, 0 ]
[ 53, 49 ]
python
en
['en', 'mk', '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(): # type: () -> int """Get the current umask which involves having to set it temporarily.""" mask = os.umask(0) os.umask(mask) return mask
[ "def", "current_umask", "(", ")", ":", "# type: () -> int", "mask", "=", "os", ".", "umask", "(", "0", ")", "os", ".", "umask", "(", "mask", ")", "return", "mask" ]
[ 46, 0 ]
[ 51, 15 ]
python
en
['en', 'en', 'en']
True
has_leading_dir
(paths)
Returns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)
Returns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)
def has_leading_dir(paths): # type: (Iterable[Union[str, Text]]) -> bool """Returns true if all the paths have the same leading path name (i.e., everything is in one subdirectory in an archive)""" common_prefix = None for path in paths: prefix, rest = split_leading_dir(path) if not p...
[ "def", "has_leading_dir", "(", "paths", ")", ":", "# type: (Iterable[Union[str, Text]]) -> bool", "common_prefix", "=", "None", "for", "path", "in", "paths", ":", "prefix", ",", "rest", "=", "split_leading_dir", "(", "path", ")", "if", "not", "prefix", ":", "ret...
[ 70, 0 ]
[ 83, 15 ]
python
en
['en', 'en', 'en']
True
is_within_directory
(directory, target)
Return true if the absolute path of target is within the directory
Return true if the absolute path of target is within the directory
def is_within_directory(directory, target): # type: ((Union[str, Text]), (Union[str, Text])) -> bool """ Return true if the absolute path of target is within the directory """ abs_directory = os.path.abspath(directory) abs_target = os.path.abspath(target) prefix = os.path.commonprefix([abs_...
[ "def", "is_within_directory", "(", "directory", ",", "target", ")", ":", "# type: ((Union[str, Text]), (Union[str, Text])) -> bool", "abs_directory", "=", "os", ".", "path", ".", "abspath", "(", "directory", ")", "abs_target", "=", "os", ".", "path", ".", "abspath",...
[ 86, 0 ]
[ 95, 34 ]
python
en
['en', 'error', 'th']
False
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): # type: (Union[str, Text]) -> None """ 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", ")", ":", "# type: (Union[str, Text]) -> None", "os", ".", "chmod", "(", "path", ",", "(", "0o777", "&", "~", "current_umask", "(", ")", "|", "0o111", ")", ")" ]
[ 98, 0 ]
[ 104, 54 ]
python
en
['en', 'error', 'th']
False
unzip_file
(filename, location, flatten=True)
Unzip the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Not...
Unzip the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Not...
def unzip_file(filename, location, flatten=True): # type: (str, str, bool) -> None """ Unzip the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execut...
[ "def", "unzip_file", "(", "filename", ",", "location", ",", "flatten", "=", "True", ")", ":", "# type: (str, str, bool) -> None", "ensure_dir", "(", "location", ")", "zipfp", "=", "open", "(", "filename", ",", "'rb'", ")", "try", ":", "zip", "=", "zipfile", ...
[ 115, 0 ]
[ 159, 21 ]
python
en
['en', 'error', 'th']
False
untar_file
(filename, location)
Untar the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Not...
Untar the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (user, group, or world) have "chmod +x" applied after being written. Not...
def untar_file(filename, location): # type: (str, str) -> None """ Untar the file (with path `filename`) to the destination `location`. All files are written based on system defaults and umask (i.e. permissions are not preserved), except that regular file members with any execute permissions (us...
[ "def", "untar_file", "(", "filename", ",", "location", ")", ":", "# type: (str, str) -> None", "ensure_dir", "(", "location", ")", "if", "filename", ".", "lower", "(", ")", ".", "endswith", "(", "'.gz'", ")", "or", "filename", ".", "lower", "(", ")", ".", ...
[ 162, 0 ]
[ 242, 19 ]
python
en
['en', 'error', 'th']
False