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
_NamespaceLoader.load_module
(self, fullname)
Load a namespace module. This method is deprecated. Use exec_module() instead.
Load a namespace module.
def load_module(self, fullname): """Load a namespace module. This method is deprecated. Use exec_module() instead. """ # The import system never calls this method. _bootstrap._verbose_message('namespace module loaded with path {!r}', self._p...
[ "def", "load_module", "(", "self", ",", "fullname", ")", ":", "# The import system never calls this method.", "_bootstrap", ".", "_verbose_message", "(", "'namespace module loaded with path {!r}'", ",", "self", ".", "_path", ")", "return", "_bootstrap", ".", "_load_module...
[ 1040, 4 ]
[ 1049, 59 ]
python
en
['en', 'co', 'en']
True
PathFinder.invalidate_caches
(cls)
Call the invalidate_caches() method on all path entry finders stored in sys.path_importer_caches (where implemented).
Call the invalidate_caches() method on all path entry finders stored in sys.path_importer_caches (where implemented).
def invalidate_caches(cls): """Call the invalidate_caches() method on all path entry finders stored in sys.path_importer_caches (where implemented).""" for finder in sys.path_importer_cache.values(): if hasattr(finder, 'invalidate_caches'): finder.invalidate_caches()
[ "def", "invalidate_caches", "(", "cls", ")", ":", "for", "finder", "in", "sys", ".", "path_importer_cache", ".", "values", "(", ")", ":", "if", "hasattr", "(", "finder", ",", "'invalidate_caches'", ")", ":", "finder", ".", "invalidate_caches", "(", ")" ]
[ 1059, 4 ]
[ 1064, 42 ]
python
en
['en', 'en', 'en']
True
PathFinder._path_hooks
(cls, path)
Search sys.path_hooks for a finder for 'path'.
Search sys.path_hooks for a finder for 'path'.
def _path_hooks(cls, path): """Search sys.path_hooks for a finder for 'path'.""" if sys.path_hooks is not None and not sys.path_hooks: _warnings.warn('sys.path_hooks is empty', ImportWarning) for hook in sys.path_hooks: try: return hook(path) e...
[ "def", "_path_hooks", "(", "cls", ",", "path", ")", ":", "if", "sys", ".", "path_hooks", "is", "not", "None", "and", "not", "sys", ".", "path_hooks", ":", "_warnings", ".", "warn", "(", "'sys.path_hooks is empty'", ",", "ImportWarning", ")", "for", "hook",...
[ 1067, 4 ]
[ 1077, 23 ]
python
en
['en', 'en', 'en']
True
PathFinder._path_importer_cache
(cls, path)
Get the finder for the path entry from sys.path_importer_cache. If the path entry is not in the cache, find the appropriate finder and cache it. If no finder is available, store None.
Get the finder for the path entry from sys.path_importer_cache.
def _path_importer_cache(cls, path): """Get the finder for the path entry from sys.path_importer_cache. If the path entry is not in the cache, find the appropriate finder and cache it. If no finder is available, store None. """ if path == '': try: pa...
[ "def", "_path_importer_cache", "(", "cls", ",", "path", ")", ":", "if", "path", "==", "''", ":", "try", ":", "path", "=", "_os", ".", "getcwd", "(", ")", "except", "FileNotFoundError", ":", "# Don't cache the failure as the cwd can easily change to", "# a valid di...
[ 1080, 4 ]
[ 1099, 21 ]
python
en
['en', 'en', 'en']
True
PathFinder._get_spec
(cls, fullname, path, target=None)
Find the loader or namespace_path for this module/package name.
Find the loader or namespace_path for this module/package name.
def _get_spec(cls, fullname, path, target=None): """Find the loader or namespace_path for this module/package name.""" # If this ends up being a namespace package, namespace_path is # the list of paths that will become its __path__ namespace_path = [] for entry in path: ...
[ "def", "_get_spec", "(", "cls", ",", "fullname", ",", "path", ",", "target", "=", "None", ")", ":", "# If this ends up being a namespace package, namespace_path is", "# the list of paths that will become its __path__", "namespace_path", "=", "[", "]", "for", "entry", "in...
[ 1117, 4 ]
[ 1146, 23 ]
python
en
['en', 'en', 'en']
True
PathFinder.find_spec
(cls, fullname, path=None, target=None)
Try to find a spec for 'fullname' on sys.path or 'path'. The search is based on sys.path_hooks and sys.path_importer_cache.
Try to find a spec for 'fullname' on sys.path or 'path'.
def find_spec(cls, fullname, path=None, target=None): """Try to find a spec for 'fullname' on sys.path or 'path'. The search is based on sys.path_hooks and sys.path_importer_cache. """ if path is None: path = sys.path spec = cls._get_spec(fullname, path, target) ...
[ "def", "find_spec", "(", "cls", ",", "fullname", ",", "path", "=", "None", ",", "target", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "sys", ".", "path", "spec", "=", "cls", ".", "_get_spec", "(", "fullname", ",", "path", ...
[ 1149, 4 ]
[ 1170, 23 ]
python
en
['en', 'en', 'en']
True
PathFinder.find_module
(cls, fullname, path=None)
find the module on sys.path or 'path' based on sys.path_hooks and sys.path_importer_cache. This method is deprecated. Use find_spec() instead.
find the module on sys.path or 'path' based on sys.path_hooks and sys.path_importer_cache.
def find_module(cls, fullname, path=None): """find the module on sys.path or 'path' based on sys.path_hooks and sys.path_importer_cache. This method is deprecated. Use find_spec() instead. """ spec = cls.find_spec(fullname, path) if spec is None: return Non...
[ "def", "find_module", "(", "cls", ",", "fullname", ",", "path", "=", "None", ")", ":", "spec", "=", "cls", ".", "find_spec", "(", "fullname", ",", "path", ")", "if", "spec", "is", "None", ":", "return", "None", "return", "spec", ".", "loader" ]
[ 1173, 4 ]
[ 1183, 26 ]
python
en
['en', 'en', 'en']
True
FileFinder.__init__
(self, path, *loader_details)
Initialize with the path to search on and a variable number of 2-tuples containing the loader and the file suffixes the loader recognizes.
Initialize with the path to search on and a variable number of 2-tuples containing the loader and the file suffixes the loader recognizes.
def __init__(self, path, *loader_details): """Initialize with the path to search on and a variable number of 2-tuples containing the loader and the file suffixes the loader recognizes.""" loaders = [] for loader, suffixes in loader_details: loaders.extend((suffix, loa...
[ "def", "__init__", "(", "self", ",", "path", ",", "*", "loader_details", ")", ":", "loaders", "=", "[", "]", "for", "loader", ",", "suffixes", "in", "loader_details", ":", "loaders", ".", "extend", "(", "(", "suffix", ",", "loader", ")", "for", "suffix...
[ 1195, 4 ]
[ 1207, 40 ]
python
en
['en', 'en', 'en']
True
FileFinder.invalidate_caches
(self)
Invalidate the directory mtime.
Invalidate the directory mtime.
def invalidate_caches(self): """Invalidate the directory mtime.""" self._path_mtime = -1
[ "def", "invalidate_caches", "(", "self", ")", ":", "self", ".", "_path_mtime", "=", "-", "1" ]
[ 1209, 4 ]
[ 1211, 29 ]
python
en
['en', 'en', 'en']
True
FileFinder.find_loader
(self, fullname)
Try to find a loader for the specified module, or the namespace package portions. Returns (loader, list-of-portions). This method is deprecated. Use find_spec() instead.
Try to find a loader for the specified module, or the namespace package portions. Returns (loader, list-of-portions).
def find_loader(self, fullname): """Try to find a loader for the specified module, or the namespace package portions. Returns (loader, list-of-portions). This method is deprecated. Use find_spec() instead. """ spec = self.find_spec(fullname) if spec is None: ...
[ "def", "find_loader", "(", "self", ",", "fullname", ")", ":", "spec", "=", "self", ".", "find_spec", "(", "fullname", ")", "if", "spec", "is", "None", ":", "return", "None", ",", "[", "]", "return", "spec", ".", "loader", ",", "spec", ".", "submodule...
[ 1215, 4 ]
[ 1225, 65 ]
python
en
['en', 'en', 'en']
True
FileFinder.find_spec
(self, fullname, target=None)
Try to find a spec for the specified module. Returns the matching spec, or None if not found.
Try to find a spec for the specified module.
def find_spec(self, fullname, target=None): """Try to find a spec for the specified module. Returns the matching spec, or None if not found. """ is_namespace = False tail_module = fullname.rpartition('.')[2] try: mtime = _path_stat(self.path or _os.getcwd())....
[ "def", "find_spec", "(", "self", ",", "fullname", ",", "target", "=", "None", ")", ":", "is_namespace", "=", "False", "tail_module", "=", "fullname", ".", "rpartition", "(", "'.'", ")", "[", "2", "]", "try", ":", "mtime", "=", "_path_stat", "(", "self"...
[ 1232, 4 ]
[ 1278, 19 ]
python
en
['en', 'en', 'en']
True
FileFinder._fill_cache
(self)
Fill the cache of potential modules and packages for this directory.
Fill the cache of potential modules and packages for this directory.
def _fill_cache(self): """Fill the cache of potential modules and packages for this directory.""" path = self.path try: contents = _os.listdir(path or _os.getcwd()) except (FileNotFoundError, PermissionError, NotADirectoryError): # Directory has either been remove...
[ "def", "_fill_cache", "(", "self", ")", ":", "path", "=", "self", ".", "path", "try", ":", "contents", "=", "_os", ".", "listdir", "(", "path", "or", "_os", ".", "getcwd", "(", ")", ")", "except", "(", "FileNotFoundError", ",", "PermissionError", ",", ...
[ 1280, 4 ]
[ 1309, 70 ]
python
en
['en', 'en', 'en']
True
FileFinder.path_hook
(cls, *loader_details)
A class method which returns a closure to use on sys.path_hook which will return an instance using the specified loaders and the path called on the closure. If the path called on the closure is not a directory, ImportError is raised.
A class method which returns a closure to use on sys.path_hook which will return an instance using the specified loaders and the path called on the closure.
def path_hook(cls, *loader_details): """A class method which returns a closure to use on sys.path_hook which will return an instance using the specified loaders and the path called on the closure. If the path called on the closure is not a directory, ImportError is raised. ...
[ "def", "path_hook", "(", "cls", ",", "*", "loader_details", ")", ":", "def", "path_hook_for_FileFinder", "(", "path", ")", ":", "\"\"\"Path hook for importlib.machinery.FileFinder.\"\"\"", "if", "not", "_path_isdir", "(", "path", ")", ":", "raise", "ImportError", "(...
[ 1312, 4 ]
[ 1327, 39 ]
python
en
['en', 'en', 'en']
True
query_for_ids
(query: QuerySet, user_ids: List[int], field: str)
This function optimizes searches of the form `user_profile_id in (1, 2, 3, 4)` by quickly building the where clauses. Profiling shows significant speedups over the normal Django-based approach. Use this very carefully! Also, the caller should guard against empty lists of user_ids.
This function optimizes searches of the form `user_profile_id in (1, 2, 3, 4)` by quickly building the where clauses. Profiling shows significant speedups over the normal Django-based approach.
def query_for_ids(query: QuerySet, user_ids: List[int], field: str) -> QuerySet: """ This function optimizes searches of the form `user_profile_id in (1, 2, 3, 4)` by quickly building the where clauses. Profiling shows significant speedups over the normal Django-based approach. Use this very c...
[ "def", "query_for_ids", "(", "query", ":", "QuerySet", ",", "user_ids", ":", "List", "[", "int", "]", ",", "field", ":", "str", ")", "->", "QuerySet", ":", "assert", "user_ids", "clause", "=", "f\"{field} IN %s\"", "query", "=", "query", ".", "extra", "(...
[ 98, 0 ]
[ 114, 16 ]
python
en
['en', 'error', 'th']
False
get_display_recipient_by_id
( recipient_id: int, recipient_type: int, recipient_type_id: Optional[int] )
returns: an object describing the recipient (using a cache). If the type is a stream, the type_id must be an int; a string is returned. Otherwise, type_id may be None; an array of recipient dicts is returned.
returns: an object describing the recipient (using a cache). If the type is a stream, the type_id must be an int; a string is returned. Otherwise, type_id may be None; an array of recipient dicts is returned.
def get_display_recipient_by_id( recipient_id: int, recipient_type: int, recipient_type_id: Optional[int] ) -> DisplayRecipientT: """ returns: an object describing the recipient (using a cache). If the type is a stream, the type_id must be an int; a string is returned. Otherwise, type_id may be None...
[ "def", "get_display_recipient_by_id", "(", "recipient_id", ":", "int", ",", "recipient_type", ":", "int", ",", "recipient_type_id", ":", "Optional", "[", "int", "]", ")", "->", "DisplayRecipientT", ":", "# Have to import here, to avoid circular dependency.", "from", "ze...
[ 128, 0 ]
[ 142, 60 ]
python
en
['en', 'error', 'th']
False
realm_filters_for_realm
(realm_id: int)
Processes data from `linkifiers_for_realm` to return to older clients, which use the `realm_filters` events.
Processes data from `linkifiers_for_realm` to return to older clients, which use the `realm_filters` events.
def realm_filters_for_realm(realm_id: int) -> List[Tuple[str, str, int]]: """ Processes data from `linkifiers_for_realm` to return to older clients, which use the `realm_filters` events. """ linkifiers = linkifiers_for_realm(realm_id) realm_filters: List[Tuple[str, str, int]] = [] for linkif...
[ "def", "realm_filters_for_realm", "(", "realm_id", ":", "int", ")", "->", "List", "[", "Tuple", "[", "str", ",", "str", ",", "int", "]", "]", ":", "linkifiers", "=", "linkifiers_for_realm", "(", "realm_id", ")", "realm_filters", ":", "List", "[", "Tuple", ...
[ 965, 0 ]
[ 974, 24 ]
python
en
['en', 'error', 'th']
False
get_active_streams
(realm: Optional[Realm])
Return all streams (including invite-only streams) that have not been deactivated.
Return all streams (including invite-only streams) that have not been deactivated.
def get_active_streams(realm: Optional[Realm]) -> QuerySet: # TODO: Change return type to QuerySet[Stream] # NOTE: Return value is used as a QuerySet, so cannot currently be Sequence[QuerySet] """ Return all streams (including invite-only streams) that have not been deactivated. """ return Strea...
[ "def", "get_active_streams", "(", "realm", ":", "Optional", "[", "Realm", "]", ")", "->", "QuerySet", ":", "# TODO: Change return type to QuerySet[Stream]", "# NOTE: Return value is used as a QuerySet, so cannot currently be Sequence[QuerySet]", "return", "Stream", ".", "objects"...
[ 2007, 0 ]
[ 2013, 64 ]
python
en
['en', 'error', 'th']
False
get_stream
(stream_name: str, realm: Realm)
Callers that don't have a Realm object already available should use get_realm_stream directly, to avoid unnecessarily fetching the Realm object.
Callers that don't have a Realm object already available should use get_realm_stream directly, to avoid unnecessarily fetching the Realm object.
def get_stream(stream_name: str, realm: Realm) -> Stream: """ Callers that don't have a Realm object already available should use get_realm_stream directly, to avoid unnecessarily fetching the Realm object. """ return get_realm_stream(stream_name, realm.id)
[ "def", "get_stream", "(", "stream_name", ":", "str", ",", "realm", ":", "Realm", ")", "->", "Stream", ":", "return", "get_realm_stream", "(", "stream_name", ",", "realm", ".", "id", ")" ]
[ 2016, 0 ]
[ 2022, 50 ]
python
en
['en', 'error', 'th']
False
bulk_get_huddle_user_ids
(recipients: List[Recipient])
Takes a list of huddle-type recipients, returns a dict mapping recipient id to list of user ids in the huddle.
Takes a list of huddle-type recipients, returns a dict mapping recipient id to list of user ids in the huddle.
def bulk_get_huddle_user_ids(recipients: List[Recipient]) -> Dict[int, List[int]]: """ Takes a list of huddle-type recipients, returns a dict mapping recipient id to list of user ids in the huddle. """ assert all(recipient.type == Recipient.HUDDLE for recipient in recipients) if not recipients: ...
[ "def", "bulk_get_huddle_user_ids", "(", "recipients", ":", "List", "[", "Recipient", "]", ")", "->", "Dict", "[", "int", ",", "List", "[", "int", "]", "]", ":", "assert", "all", "(", "recipient", ".", "type", "==", "Recipient", ".", "HUDDLE", "for", "r...
[ 2084, 0 ]
[ 2105, 22 ]
python
en
['en', 'error', 'th']
False
Realm.authentication_methods_dict
(self)
Returns the a mapping from authentication flags to their status, showing only those authentication flags that are supported on the current server (i.e. if EmailAuthBackend is not configured on the server, this will not return an entry for "Email").
Returns the a mapping from authentication flags to their status, showing only those authentication flags that are supported on the current server (i.e. if EmailAuthBackend is not configured on the server, this will not return an entry for "Email").
def authentication_methods_dict(self) -> Dict[str, bool]: """Returns the a mapping from authentication flags to their status, showing only those authentication flags that are supported on the current server (i.e. if EmailAuthBackend is not configured on the server, this will not return a...
[ "def", "authentication_methods_dict", "(", "self", ")", "->", "Dict", "[", "str", ",", "bool", "]", ":", "# This mapping needs to be imported from here due to the cyclic", "# dependency.", "from", "zproject", ".", "backends", "import", "AUTH_BACKEND_NAME_MAP", "ret", ":",...
[ 568, 4 ]
[ 586, 18 ]
python
en
['en', 'en', 'en']
True
Realm.get_admin_users_and_bots
( self, include_realm_owners: bool = True )
Use this in contexts where we want administrative users as well as bots with administrator privileges, like send_event calls for notifications to all administrator users.
Use this in contexts where we want administrative users as well as bots with administrator privileges, like send_event calls for notifications to all administrator users.
def get_admin_users_and_bots( self, include_realm_owners: bool = True ) -> Sequence["UserProfile"]: """Use this in contexts where we want administrative users as well as bots with administrator privileges, like send_event calls for notifications to all administrator users. ""...
[ "def", "get_admin_users_and_bots", "(", "self", ",", "include_realm_owners", ":", "bool", "=", "True", ")", "->", "Sequence", "[", "\"UserProfile\"", "]", ":", "if", "include_realm_owners", ":", "roles", "=", "[", "UserProfile", ".", "ROLE_REALM_ADMINISTRATOR", ",...
[ 599, 4 ]
[ 616, 9 ]
python
en
['en', 'en', 'en']
True
Realm.get_human_admin_users
(self, include_realm_owners: bool = True)
Use this in contexts where we want only human users with administrative privileges, like sending an email to all of a realm's administrators (bots don't have real email addresses).
Use this in contexts where we want only human users with administrative privileges, like sending an email to all of a realm's administrators (bots don't have real email addresses).
def get_human_admin_users(self, include_realm_owners: bool = True) -> QuerySet: """Use this in contexts where we want only human users with administrative privileges, like sending an email to all of a realm's administrators (bots don't have real email addresses). """ if include_r...
[ "def", "get_human_admin_users", "(", "self", ",", "include_realm_owners", ":", "bool", "=", "True", ")", "->", "QuerySet", ":", "if", "include_realm_owners", ":", "roles", "=", "[", "UserProfile", ".", "ROLE_REALM_ADMINISTRATOR", ",", "UserProfile", ".", "ROLE_REA...
[ 618, 4 ]
[ 634, 9 ]
python
en
['en', 'en', 'en']
True
Realm.get_first_human_user
(self)
A useful value for communications with newly created realms. Has a few fundamental limitations: * Its value will be effectively random for realms imported from Slack or other third-party tools. * The user may be deactivated, etc., so it's not something that's useful for feat...
A useful value for communications with newly created realms. Has a few fundamental limitations:
def get_first_human_user(self) -> Optional["UserProfile"]: """A useful value for communications with newly created realms. Has a few fundamental limitations: * Its value will be effectively random for realms imported from Slack or other third-party tools. * The user may be dea...
[ "def", "get_first_human_user", "(", "self", ")", "->", "Optional", "[", "\"UserProfile\"", "]", ":", "return", "UserProfile", ".", "objects", ".", "filter", "(", "realm", "=", "self", ",", "is_bot", "=", "False", ")", ".", "order_by", "(", "\"id\"", ")", ...
[ 648, 4 ]
[ 657, 90 ]
python
en
['en', 'en', 'en']
True
Realm.display_subdomain
(self)
Likely to be temporary function to avoid signup messages being sent to an empty topic
Likely to be temporary function to avoid signup messages being sent to an empty topic
def display_subdomain(self) -> str: """Likely to be temporary function to avoid signup messages being sent to an empty topic""" if self.string_id == "": return "." return self.string_id
[ "def", "display_subdomain", "(", "self", ")", "->", "str", ":", "if", "self", ".", "string_id", "==", "\"\"", ":", "return", "\".\"", "return", "self", ".", "string_id" ]
[ 713, 4 ]
[ 718, 29 ]
python
en
['en', 'en', 'en']
True
UserProfile.can_admin_user
(self, target_user: "UserProfile")
Returns whether this user has permission to modify target_user
Returns whether this user has permission to modify target_user
def can_admin_user(self, target_user: "UserProfile") -> bool: """Returns whether this user has permission to modify target_user""" if target_user.bot_owner == self: return True elif self.is_realm_admin and self.realm == target_user.realm: return True else: ...
[ "def", "can_admin_user", "(", "self", ",", "target_user", ":", "\"UserProfile\"", ")", "->", "bool", ":", "if", "target_user", ".", "bot_owner", "==", "self", ":", "return", "True", "elif", "self", ".", "is_realm_admin", "and", "self", ".", "realm", "==", ...
[ 1460, 4 ]
[ 1467, 24 ]
python
en
['en', 'en', 'en']
True
Message.topic_name
(self)
Please start using this helper to facilitate an eventual switch over to a separate topic table.
Please start using this helper to facilitate an eventual switch over to a separate topic table.
def topic_name(self) -> str: """ Please start using this helper to facilitate an eventual switch over to a separate topic table. """ return self.subject
[ "def", "topic_name", "(", "self", ")", "->", "str", ":", "return", "self", ".", "subject" ]
[ 2185, 4 ]
[ 2190, 27 ]
python
en
['en', 'error', 'th']
False
Message.is_stream_message
(self)
Find out whether a message is a stream message by looking up its recipient.type. TODO: Make this an easier operation by denormalizing the message type onto Message, either explicitly (message.type) or implicitly (message.stream_id is not None).
Find out whether a message is a stream message by looking up its recipient.type. TODO: Make this an easier operation by denormalizing the message type onto Message, either explicitly (message.type) or implicitly (message.stream_id is not None).
def is_stream_message(self) -> bool: """ Find out whether a message is a stream message by looking up its recipient.type. TODO: Make this an easier operation by denormalizing the message type onto Message, either explicitly (message.type) or implicitly (message.stream_id...
[ "def", "is_stream_message", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "recipient", ".", "type", "==", "Recipient", ".", "STREAM" ]
[ 2195, 4 ]
[ 2203, 54 ]
python
en
['en', 'error', 'th']
False
Message.sent_by_human
(self)
Used to determine whether a message was sent by a full Zulip UI style client (and thus whether the message should be treated as sent by a human and automatically marked as read for the sender). The purpose of this distinction is to ensure that message sent to the user by e.g. a Google C...
Used to determine whether a message was sent by a full Zulip UI style client (and thus whether the message should be treated as sent by a human and automatically marked as read for the sender). The purpose of this distinction is to ensure that message sent to the user by e.g. a Google C...
def sent_by_human(self) -> bool: """Used to determine whether a message was sent by a full Zulip UI style client (and thus whether the message should be treated as sent by a human and automatically marked as read for the sender). The purpose of this distinction is to ensure that ...
[ "def", "sent_by_human", "(", "self", ")", "->", "bool", ":", "sending_client", "=", "self", ".", "sending_client", ".", "name", ".", "lower", "(", ")", "return", "(", "sending_client", "in", "(", "\"zulipandroid\"", ",", "\"zulipios\"", ",", "\"zulipdesktop\""...
[ 2223, 4 ]
[ 2248, 46 ]
python
en
['en', 'en', 'en']
True
Message.is_status_message
(content: str, rendered_content: str)
"status messages" start with /me and have special rendering: /me loves chocolate -> Full Name loves chocolate
"status messages" start with /me and have special rendering: /me loves chocolate -> Full Name loves chocolate
def is_status_message(content: str, rendered_content: str) -> bool: """ "status messages" start with /me and have special rendering: /me loves chocolate -> Full Name loves chocolate """ if content.startswith("/me "): return True return False
[ "def", "is_status_message", "(", "content", ":", "str", ",", "rendered_content", ":", "str", ")", "->", "bool", ":", "if", "content", ".", "startswith", "(", "\"/me \"", ")", ":", "return", "True", "return", "False" ]
[ 2251, 4 ]
[ 2258, 20 ]
python
en
['en', 'error', 'th']
False
AbstractUserMessage.flags_list_for_flags
(val: int)
This function is highly optimized, because it actually slows down sending messages in a naive implementation.
This function is highly optimized, because it actually slows down sending messages in a naive implementation.
def flags_list_for_flags(val: int) -> List[str]: """ This function is highly optimized, because it actually slows down sending messages in a naive implementation. """ flags = [] mask = 1 for flag in UserMessage.ALL_FLAGS: if (val & mask) and flag not i...
[ "def", "flags_list_for_flags", "(", "val", ":", "int", ")", "->", "List", "[", "str", "]", ":", "flags", "=", "[", "]", "mask", "=", "1", "for", "flag", "in", "UserMessage", ".", "ALL_FLAGS", ":", "if", "(", "val", "&", "mask", ")", "and", "flag", ...
[ 2533, 4 ]
[ 2544, 20 ]
python
en
['en', 'error', 'th']
False
report_error
( request: HttpRequest, user_profile: UserProfile, message: str = REQ(), stacktrace: str = REQ(), ui_message: bool = REQ(json_validator=check_bool), user_agent: str = REQ(), href: str = REQ(), log: str = REQ(), more_info: Mapping[str, Any] = REQ(json_validator=check_dict([]), default...
Accepts an error report and stores in a queue for processing. The actual error reports are later handled by do_report_error
Accepts an error report and stores in a queue for processing. The actual error reports are later handled by do_report_error
def report_error( request: HttpRequest, user_profile: UserProfile, message: str = REQ(), stacktrace: str = REQ(), ui_message: bool = REQ(json_validator=check_bool), user_agent: str = REQ(), href: str = REQ(), log: str = REQ(), more_info: Mapping[str, Any] = REQ(json_validator=check_d...
[ "def", "report_error", "(", "request", ":", "HttpRequest", ",", "user_profile", ":", "UserProfile", ",", "message", ":", "str", "=", "REQ", "(", ")", ",", "stacktrace", ":", "str", "=", "REQ", "(", ")", ",", "ui_message", ":", "bool", "=", "REQ", "(", ...
[ 106, 0 ]
[ 173, 25 ]
python
en
['en', 'en', 'en']
True
ZabbixHookTests.test_zabbix_alert_message
(self)
Tests if zabbix alert is handled correctly
Tests if zabbix alert is handled correctly
def test_zabbix_alert_message(self) -> None: """ Tests if zabbix alert is handled correctly """ expected_topic = "www.example.com" expected_message = "PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528):\n* Zabbix a...
[ "def", "test_zabbix_alert_message", "(", "self", ")", "->", "None", ":", "expected_topic", "=", "\"www.example.com\"", "expected_message", "=", "\"PROBLEM (Average) alert on [www.example.com](https://zabbix.example.com/tr_events.php?triggerid=14032&eventid=10528):\\n* Zabbix agent on www.e...
[ 11, 4 ]
[ 17, 76 ]
python
en
['en', 'error', 'th']
False
ZabbixHookTests.test_zabbix_invalid_payload_with_missing_data
(self)
Tests if invalid Zabbix payloads are handled correctly
Tests if invalid Zabbix payloads are handled correctly
def test_zabbix_invalid_payload_with_missing_data(self) -> None: """ Tests if invalid Zabbix payloads are handled correctly """ self.url = self.build_webhook_url() payload = self.get_body("zabbix_invalid_payload_with_missing_data") result = self.client_post(self.url, payl...
[ "def", "test_zabbix_invalid_payload_with_missing_data", "(", "self", ")", "->", "None", ":", "self", ".", "url", "=", "self", ".", "build_webhook_url", "(", ")", "payload", "=", "self", ".", "get_body", "(", "\"zabbix_invalid_payload_with_missing_data\"", ")", "resu...
[ 19, 4 ]
[ 35, 64 ]
python
en
['en', 'error', 'th']
False
abstractmethod
(funcobj)
A decorator indicating abstract methods. Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using any of the normal 'super' call me...
A decorator indicating abstract methods.
def abstractmethod(funcobj): """A decorator indicating abstract methods. Requires that the metaclass is ABCMeta or derived from it. A class that has a metaclass derived from ABCMeta cannot be instantiated unless all of its abstract methods are overridden. The abstract methods can be called using a...
[ "def", "abstractmethod", "(", "funcobj", ")", ":", "funcobj", ".", "__isabstractmethod__", "=", "True", "return", "funcobj" ]
[ 8, 0 ]
[ 25, 18 ]
python
en
['en', 'en', 'en']
True
get_cache_token
()
Returns the current ABC cache token. The token is an opaque object (supporting equality testing) identifying the current version of the ABC cache for virtual subclasses. The token changes with every call to ``register()`` on any ABC.
Returns the current ABC cache token.
def get_cache_token(): """Returns the current ABC cache token. The token is an opaque object (supporting equality testing) identifying the current version of the ABC cache for virtual subclasses. The token changes with every call to ``register()`` on any ABC. """ return ABCMeta._abc_invalidatio...
[ "def", "get_cache_token", "(", ")", ":", "return", "ABCMeta", ".", "_abc_invalidation_counter" ]
[ 242, 0 ]
[ 249, 44 ]
python
en
['en', 'en', 'en']
True
ABCMeta.register
(cls, subclass)
Register a virtual subclass of an ABC. Returns the subclass, to allow usage as a class decorator.
Register a virtual subclass of an ABC.
def register(cls, subclass): """Register a virtual subclass of an ABC. Returns the subclass, to allow usage as a class decorator. """ if not isinstance(subclass, type): raise TypeError("Can only register classes") if issubclass(subclass, cls): return subc...
[ "def", "register", "(", "cls", ",", "subclass", ")", ":", "if", "not", "isinstance", "(", "subclass", ",", "type", ")", ":", "raise", "TypeError", "(", "\"Can only register classes\"", ")", "if", "issubclass", "(", "subclass", ",", "cls", ")", ":", "return...
[ 150, 4 ]
[ 166, 23 ]
python
en
['en', 'en', 'en']
True
ABCMeta._dump_registry
(cls, file=None)
Debug helper to print the ABC registry.
Debug helper to print the ABC registry.
def _dump_registry(cls, file=None): """Debug helper to print the ABC registry.""" print("Class: %s.%s" % (cls.__module__, cls.__qualname__), file=file) print("Inv.counter: %s" % ABCMeta._abc_invalidation_counter, file=file) for name in sorted(cls.__dict__): if name.startswith...
[ "def", "_dump_registry", "(", "cls", ",", "file", "=", "None", ")", ":", "print", "(", "\"Class: %s.%s\"", "%", "(", "cls", ".", "__module__", ",", "cls", ".", "__qualname__", ")", ",", "file", "=", "file", ")", "print", "(", "\"Inv.counter: %s\"", "%", ...
[ 168, 4 ]
[ 177, 58 ]
python
en
['en', 'hmn', 'en']
True
ABCMeta.__instancecheck__
(cls, instance)
Override for isinstance(instance, cls).
Override for isinstance(instance, cls).
def __instancecheck__(cls, instance): """Override for isinstance(instance, cls).""" # Inline the cache checking subclass = instance.__class__ if subclass in cls._abc_cache: return True subtype = type(instance) if subtype is subclass: if (cls._abc_n...
[ "def", "__instancecheck__", "(", "cls", ",", "instance", ")", ":", "# Inline the cache checking", "subclass", "=", "instance", ".", "__class__", "if", "subclass", "in", "cls", ".", "_abc_cache", ":", "return", "True", "subtype", "=", "type", "(", "instance", "...
[ 179, 4 ]
[ 193, 73 ]
python
en
['en', 'en', 'en']
True
ABCMeta.__subclasscheck__
(cls, subclass)
Override for issubclass(subclass, cls).
Override for issubclass(subclass, cls).
def __subclasscheck__(cls, subclass): """Override for issubclass(subclass, cls).""" # Check cache if subclass in cls._abc_cache: return True # Check negative cache; may have to invalidate if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter: ...
[ "def", "__subclasscheck__", "(", "cls", ",", "subclass", ")", ":", "# Check cache", "if", "subclass", "in", "cls", ".", "_abc_cache", ":", "return", "True", "# Check negative cache; may have to invalidate", "if", "cls", ".", "_abc_negative_cache_version", "<", "ABCMet...
[ 195, 4 ]
[ 232, 20 ]
python
en
['en', 'en', 'en']
True
BaseReporter.starting
(self)
Called before the resolution actually starts.
Called before the resolution actually starts.
def starting(self): """Called before the resolution actually starts. """
[ "def", "starting", "(", "self", ")", ":" ]
[ 4, 4 ]
[ 6, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.starting_round
(self, index)
Called before each round of resolution starts. The index is zero-based.
Called before each round of resolution starts.
def starting_round(self, index): """Called before each round of resolution starts. The index is zero-based. """
[ "def", "starting_round", "(", "self", ",", "index", ")", ":" ]
[ 8, 4 ]
[ 12, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.ending_round
(self, index, state)
Called before each round of resolution ends. This is NOT called if the resolution ends at this round. Use `ending` if you want to report finalization. The index is zero-based.
Called before each round of resolution ends.
def ending_round(self, index, state): """Called before each round of resolution ends. This is NOT called if the resolution ends at this round. Use `ending` if you want to report finalization. The index is zero-based. """
[ "def", "ending_round", "(", "self", ",", "index", ",", "state", ")", ":" ]
[ 14, 4 ]
[ 19, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.ending
(self, state)
Called before the resolution ends successfully.
Called before the resolution ends successfully.
def ending(self, state): """Called before the resolution ends successfully. """
[ "def", "ending", "(", "self", ",", "state", ")", ":" ]
[ 21, 4 ]
[ 23, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.adding_requirement
(self, requirement, parent)
Called when adding a new requirement into the resolve criteria. :param requirement: The additional requirement to be applied to filter the available candidaites. :param parent: The candidate that requires ``requirement`` as a dependency, or None if ``requirement`` is one of the ...
Called when adding a new requirement into the resolve criteria.
def adding_requirement(self, requirement, parent): """Called when adding a new requirement into the resolve criteria. :param requirement: The additional requirement to be applied to filter the available candidaites. :param parent: The candidate that requires ``requirement`` as a ...
[ "def", "adding_requirement", "(", "self", ",", "requirement", ",", "parent", ")", ":" ]
[ 25, 4 ]
[ 33, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.backtracking
(self, candidate)
Called when rejecting a candidate during backtracking.
Called when rejecting a candidate during backtracking.
def backtracking(self, candidate): """Called when rejecting a candidate during backtracking. """
[ "def", "backtracking", "(", "self", ",", "candidate", ")", ":" ]
[ 35, 4 ]
[ 37, 11 ]
python
en
['en', 'en', 'en']
True
BaseReporter.pinning
(self, candidate)
Called when adding a candidate to the potential solution.
Called when adding a candidate to the potential solution.
def pinning(self, candidate): """Called when adding a candidate to the potential solution. """
[ "def", "pinning", "(", "self", ",", "candidate", ")", ":" ]
[ 39, 4 ]
[ 41, 11 ]
python
en
['en', 'en', 'en']
True
Node.handlers
(topic: str)
Returns a list of handlers to the given topic, or an empty list if there are none.
Returns a list of handlers to the given topic, or an empty list if there are none.
def handlers(topic: str) -> List[Callable[[Message], None]]: """ Returns a list of handlers to the given topic, or an empty list if there are none. """ return _SUBSCRIBERS.get(topic, [])
[ "def", "handlers", "(", "topic", ":", "str", ")", "->", "List", "[", "Callable", "[", "[", "Message", "]", ",", "None", "]", "]", ":", "return", "_SUBSCRIBERS", ".", "get", "(", "topic", ",", "[", "]", ")" ]
[ 134, 4 ]
[ 140, 42 ]
python
en
['en', 'error', 'th']
False
build_message_list
( user: UserProfile, messages: List[Message], stream_map: Dict[int, Stream], # only needs id, name )
Builds the message list object for the message notification email template. The messages are collapsed into per-recipient and per-sender blocks, like our web interface
Builds the message list object for the message notification email template. The messages are collapsed into per-recipient and per-sender blocks, like our web interface
def build_message_list( user: UserProfile, messages: List[Message], stream_map: Dict[int, Stream], # only needs id, name ) -> List[Dict[str, Any]]: """ Builds the message list object for the message notification email template. The messages are collapsed into per-recipient and per-sender blocks...
[ "def", "build_message_list", "(", "user", ":", "UserProfile", ",", "messages", ":", "List", "[", "Message", "]", ",", "stream_map", ":", "Dict", "[", "int", ",", "Stream", "]", ",", "# only needs id, name", ")", "->", "List", "[", "Dict", "[", "str", ","...
[ 180, 0 ]
[ 317, 29 ]
python
en
['en', 'error', 'th']
False
get_narrow_url
( user_profile: UserProfile, message: Message, display_recipient: Optional[DisplayRecipientT] = None, stream: Optional[Stream] = None, )
The display_recipient and stream arguments are optional. If not provided, we'll compute them from the message; they exist as a performance optimization for cases where the caller needs those data too.
The display_recipient and stream arguments are optional. If not provided, we'll compute them from the message; they exist as a performance optimization for cases where the caller needs those data too.
def get_narrow_url( user_profile: UserProfile, message: Message, display_recipient: Optional[DisplayRecipientT] = None, stream: Optional[Stream] = None, ) -> str: """The display_recipient and stream arguments are optional. If not provided, we'll compute them from the message; they exist as a ...
[ "def", "get_narrow_url", "(", "user_profile", ":", "UserProfile", ",", "message", ":", "Message", ",", "display_recipient", ":", "Optional", "[", "DisplayRecipientT", "]", "=", "None", ",", "stream", ":", "Optional", "[", "Stream", "]", "=", "None", ",", ")"...
[ 320, 0 ]
[ 353, 81 ]
python
en
['en', 'en', 'en']
True
do_send_missedmessage_events_reply_in_zulip
( user_profile: UserProfile, missed_messages: List[Dict[str, Any]], message_count: int )
Send a reminder email to a user if she's missed some PMs by being offline. The email will have its reply to address set to a limited used email address that will send a Zulip message to the correct recipient. This allows the user to respond to missed PMs, huddles, and @-mentions directly from the ...
Send a reminder email to a user if she's missed some PMs by being offline.
def do_send_missedmessage_events_reply_in_zulip( user_profile: UserProfile, missed_messages: List[Dict[str, Any]], message_count: int ) -> None: """ Send a reminder email to a user if she's missed some PMs by being offline. The email will have its reply to address set to a limited used email addres...
[ "def", "do_send_missedmessage_events_reply_in_zulip", "(", "user_profile", ":", "UserProfile", ",", "missed_messages", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ",", "message_count", ":", "int", ")", "->", "None", ":", "from", "zerver", ".", ...
[ 364, 0 ]
[ 532, 54 ]
python
en
['en', 'error', 'th']
False
access_user_by_id
( user_profile: UserProfile, target_user_id: int, *, allow_deactivated: bool = False, allow_bots: bool = False, for_admin: bool, )
Master function for accessing another user by ID in API code; verifies the user ID is in the same realm, and if requested checks for administrative privileges, with flags for various special cases.
Master function for accessing another user by ID in API code; verifies the user ID is in the same realm, and if requested checks for administrative privileges, with flags for various special cases.
def access_user_by_id( user_profile: UserProfile, target_user_id: int, *, allow_deactivated: bool = False, allow_bots: bool = False, for_admin: bool, ) -> UserProfile: """Master function for accessing another user by ID in API code; verifies the user ID is in the same realm, and if reque...
[ "def", "access_user_by_id", "(", "user_profile", ":", "UserProfile", ",", "target_user_id", ":", "int", ",", "*", ",", "allow_deactivated", ":", "bool", "=", "False", ",", "allow_bots", ":", "bool", "=", "False", ",", "for_admin", ":", "bool", ",", ")", "-...
[ 243, 0 ]
[ 269, 17 ]
python
en
['en', 'en', 'en']
True
format_user_row
( realm: Realm, acting_user: Optional[UserProfile], row: Dict[str, Any], client_gravatar: bool, user_avatar_url_field_optional: bool, custom_profile_field_data: Optional[Dict[str, Any]] = None, )
Formats a user row returned by a database fetch using .values(*realm_user_dict_fields) into a dictionary representation of that user for API delivery to clients. The acting_user argument is used for permissions checks.
Formats a user row returned by a database fetch using .values(*realm_user_dict_fields) into a dictionary representation of that user for API delivery to clients. The acting_user argument is used for permissions checks.
def format_user_row( realm: Realm, acting_user: Optional[UserProfile], row: Dict[str, Any], client_gravatar: bool, user_avatar_url_field_optional: bool, custom_profile_field_data: Optional[Dict[str, Any]] = None, ) -> Dict[str, Any]: """Formats a user row returned by a database fetch using ...
[ "def", "format_user_row", "(", "realm", ":", "Realm", ",", "acting_user", ":", "Optional", "[", "UserProfile", "]", ",", "row", ":", "Dict", "[", "str", ",", "Any", "]", ",", "client_gravatar", ":", "bool", ",", "user_avatar_url_field_optional", ":", "bool",...
[ 361, 0 ]
[ 439, 17 ]
python
en
['en', 'en', 'en']
True
get_raw_user_data
( realm: Realm, acting_user: Optional[UserProfile], *, target_user: Optional[UserProfile] = None, client_gravatar: bool, user_avatar_url_field_optional: bool, include_custom_profile_fields: bool = True, )
Fetches data about the target user(s) appropriate for sending to acting_user via the standard format for the Zulip API. If target_user is None, we fetch all users in the realm.
Fetches data about the target user(s) appropriate for sending to acting_user via the standard format for the Zulip API. If target_user is None, we fetch all users in the realm.
def get_raw_user_data( realm: Realm, acting_user: Optional[UserProfile], *, target_user: Optional[UserProfile] = None, client_gravatar: bool, user_avatar_url_field_optional: bool, include_custom_profile_fields: bool = True, ) -> Dict[int, Dict[str, str]]: """Fetches data about the target...
[ "def", "get_raw_user_data", "(", "realm", ":", "Realm", ",", "acting_user", ":", "Optional", "[", "UserProfile", "]", ",", "*", ",", "target_user", ":", "Optional", "[", "UserProfile", "]", "=", "None", ",", "client_gravatar", ":", "bool", ",", "user_avatar_...
[ 515, 0 ]
[ 559, 17 ]
python
en
['en', 'en', 'en']
True
micro_maestro_not_supported
(method)
Methods using this decorator will raise a MicroMaestroNotSupportedError if the Controller is for the Micro Maestro.
Methods using this decorator will raise a MicroMaestroNotSupportedError if the Controller is for the Micro Maestro.
def micro_maestro_not_supported(method): """ Methods using this decorator will raise a MicroMaestroNotSupportedError if the Controller is for the Micro Maestro. """ @wraps(method) def wrapper(self, *args, **kwargs): __doc__ = method.__doc__ if self.is_micro: raise MicroM...
[ "def", "micro_maestro_not_supported", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "wrapper", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "__doc__", "=", "method", ".", "__doc__", "if", "self", ".", "is_micro"...
[ 19, 0 ]
[ 34, 18 ]
python
en
['en', 'error', 'th']
False
Maestro.__init__
( self, is_micro: bool, channels: int, tty: str = '/dev/ttyACM0', device: int = SerialCommands.DEFAULT_DEVICE_NUMBER, safe_close: bool = True, timeout: float = None )
:param is_micro: Whether or not the device is the Micro Maestro, which lacks some functionality. :param channels: Number of channels the Maestro has. :param tty: :param device: :param safe_close: If `True`, tells the Maestro to stop sending servo signals before closing the conne...
:param is_micro: Whether or not the device is the Micro Maestro, which lacks some functionality. :param channels: Number of channels the Maestro has. :param tty: :param device: :param safe_close: If `True`, tells the Maestro to stop sending servo signals before closing the conne...
def __init__( self, is_micro: bool, channels: int, tty: str = '/dev/ttyACM0', device: int = SerialCommands.DEFAULT_DEVICE_NUMBER, safe_close: bool = True, timeout: float = None ): """ :param is_micro: Whether or not ...
[ "def", "__init__", "(", "self", ",", "is_micro", ":", "bool", ",", "channels", ":", "int", ",", "tty", ":", "str", "=", "'/dev/ttyACM0'", ",", "device", ":", "int", "=", "SerialCommands", ".", "DEFAULT_DEVICE_NUMBER", ",", "safe_close", ":", "bool", "=", ...
[ 95, 4 ]
[ 138, 28 ]
python
en
['en', 'error', 'th']
False
Maestro._read
(self, byte_count: int)
:raises TimeoutError: Connection timed out waiting to read the specified number of bytes. Input buffer is reset.
:raises TimeoutError: Connection timed out waiting to read the specified number of bytes. Input buffer is reset.
def _read(self, byte_count: int) -> bytes: """ :raises TimeoutError: Connection timed out waiting to read the specified number of bytes. Input buffer is reset. """ assert byte_count > 0 with self._conn_lock: data = self._conn.read(byte_count) actual_byte_...
[ "def", "_read", "(", "self", ",", "byte_count", ":", "int", ")", "->", "bytes", ":", "assert", "byte_count", ">", "0", "with", "self", ".", "_conn_lock", ":", "data", "=", "self", ".", "_conn", ".", "read", "(", "byte_count", ")", "actual_byte_count", ...
[ 150, 4 ]
[ 163, 19 ]
python
en
['en', 'error', 'th']
False
Maestro.close
(self)
Cleanup by closing USB serial port.
Cleanup by closing USB serial port.
def close(self): """Cleanup by closing USB serial port.""" if self._closed: return with self._conn_lock: if self.safe_close: for channel in range(self.channels): self.stop_channel(channel) self._conn.close() self....
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "return", "with", "self", ".", "_conn_lock", ":", "if", "self", ".", "safe_close", ":", "for", "channel", "in", "range", "(", "self", ".", "channels", ")", ":", "self", ".", ...
[ 165, 4 ]
[ 177, 27 ]
python
en
['en', 'en', 'en']
True
Maestro.get_errors
(self)
Use this command to examine the errors that the Maestro has detected. Section 4.e lists the specific errors that can be detected by the Maestro. The error register is sent as a two-byte response immediately after the command is received, then all the error bits are cleared. For most application...
Use this command to examine the errors that the Maestro has detected. Section 4.e lists the specific errors that can be detected by the Maestro. The error register is sent as a two-byte response immediately after the command is received, then all the error bits are cleared. For most application...
def get_errors(self) -> int: """ Use this command to examine the errors that the Maestro has detected. Section 4.e lists the specific errors that can be detected by the Maestro. The error register is sent as a two-byte response immediately after the command is received, then all the erro...
[ "def", "get_errors", "(", "self", ")", "->", "int", ":", "with", "self", ".", "_conn_lock", ":", "self", ".", "send_cmd", "(", "bytes", "(", "(", "self", ".", "SerialCommands", ".", "GET_ERRORS", ",", ")", ")", ")", "data", "=", "self", ".", "_read",...
[ 179, 4 ]
[ 197, 37 ]
python
en
['en', 'error', 'th']
False
Maestro.go_home
(self)
Sends all servos and outputs to their home positions, just as if an error had occurred. For servos and outputs set to "Ignore", the position will be unchanged.
Sends all servos and outputs to their home positions, just as if an error had occurred. For servos and outputs set to "Ignore", the position will be unchanged.
def go_home(self): """ Sends all servos and outputs to their home positions, just as if an error had occurred. For servos and outputs set to "Ignore", the position will be unchanged. """ self.send_cmd(bytes((self.SerialCommands.GO_HOME,)))
[ "def", "go_home", "(", "self", ")", ":", "self", ".", "send_cmd", "(", "bytes", "(", "(", "self", ".", "SerialCommands", ".", "GO_HOME", ",", ")", ")", ")" ]
[ 199, 4 ]
[ 204, 60 ]
python
en
['en', 'error', 'th']
False
Maestro.script_is_running
(self)
:return: True if a script is running; False otherwise. :raises TimeoutError: Connection timed out.
:return: True if a script is running; False otherwise. :raises TimeoutError: Connection timed out.
def script_is_running(self) -> bool: """ :return: True if a script is running; False otherwise. :raises TimeoutError: Connection timed out. """ with self._conn_lock: self.send_cmd(bytes((self.SerialCommands.GET_SCRIPT_STATUS,))) # Maestro returns 0x00 if...
[ "def", "script_is_running", "(", "self", ")", "->", "bool", ":", "with", "self", ".", "_conn_lock", ":", "self", ".", "send_cmd", "(", "bytes", "(", "(", "self", ".", "SerialCommands", ".", "GET_SCRIPT_STATUS", ",", ")", ")", ")", "# Maestro returns 0x00 if ...
[ 206, 4 ]
[ 216, 43 ]
python
en
['en', 'error', 'th']
False
Maestro.send_cmd
(self, cmd: bytes)
Send a Pololu command out the serial port.
Send a Pololu command out the serial port.
def send_cmd(self, cmd: bytes): """Send a Pololu command out the serial port.""" with self._conn_lock: self._conn.write(self._pololu_cmd + cmd) self._conn.flush()
[ "def", "send_cmd", "(", "self", ",", "cmd", ":", "bytes", ")", ":", "with", "self", ".", "_conn_lock", ":", "self", ".", "_conn", ".", "write", "(", "self", ".", "_pololu_cmd", "+", "cmd", ")", "self", ".", "_conn", ".", "flush", "(", ")" ]
[ 218, 4 ]
[ 222, 30 ]
python
en
['en', 'en', 'en']
True
Maestro.set_pwm
(self, on_time_us: Real, period_us: Real)
Sets the PWM output to the specified on time and period. This command is not available on the Micro Maestro. :param on_time_us: PWM on-time in microseconds. :param period_us: PWM period in microseconds.
Sets the PWM output to the specified on time and period. This command is not available on the Micro Maestro.
def set_pwm(self, on_time_us: Real, period_us: Real): """ Sets the PWM output to the specified on time and period. This command is not available on the Micro Maestro. :param on_time_us: PWM on-time in microseconds. :param period_us: PWM period in microseconds. """ ...
[ "def", "set_pwm", "(", "self", ",", "on_time_us", ":", "Real", ",", "period_us", ":", "Real", ")", ":", "on_time", "=", "int", "(", "round", "(", "48", "*", "on_time_us", ")", ")", "# The command uses 1/48th us intervals", "on_time_lsb", ",", "on_time_msb", ...
[ 225, 4 ]
[ 239, 109 ]
python
en
['en', 'error', 'th']
False
Maestro.set_range
(self, channel: int, min_us: Real, max_us: Real)
Set channels min and max value range. Use this as a safety to protect from accidentally moving outside known safe parameters. A setting of 0 or None allows unrestricted movement. Note that the Maestro itself is configured to limit the range of servo travel which has precedence over these ...
Set channels min and max value range. Use this as a safety to protect from accidentally moving outside known safe parameters. A setting of 0 or None allows unrestricted movement.
def set_range(self, channel: int, min_us: Real, max_us: Real): """ Set channels min and max value range. Use this as a safety to protect from accidentally moving outside known safe parameters. A setting of 0 or None allows unrestricted movement. Note that the Maestro itself is configur...
[ "def", "set_range", "(", "self", ",", "channel", ":", "int", ",", "min_us", ":", "Real", ",", "max_us", ":", "Real", ")", ":", "self", ".", "_check_channel", "(", "channel", ")", "self", ".", "min_targets_us", "[", "channel", "]", "=", "min_us", "self"...
[ 241, 4 ]
[ 252, 45 ]
python
en
['en', 'error', 'th']
False
Maestro.stop_channel
(self, channel: int)
Sets the target of the specified channel to 0, causing the Maestro to stop sending PWM signals on that channel. :param channel: PWM channel to stop sending PWM signals to.
Sets the target of the specified channel to 0, causing the Maestro to stop sending PWM signals on that channel.
def stop_channel(self, channel: int): """ Sets the target of the specified channel to 0, causing the Maestro to stop sending PWM signals on that channel. :param channel: PWM channel to stop sending PWM signals to. """ self._check_channel(channel) self.set_target(channel,...
[ "def", "stop_channel", "(", "self", ",", "channel", ":", "int", ")", ":", "self", ".", "_check_channel", "(", "channel", ")", "self", ".", "set_target", "(", "channel", ",", "0", ")" ]
[ 254, 4 ]
[ 261, 35 ]
python
en
['en', 'error', 'th']
False
Maestro.stop_script
(self)
Causes the script to stop, if it is currently running.
Causes the script to stop, if it is currently running.
def stop_script(self): """Causes the script to stop, if it is currently running.""" self.send_cmd(bytes((self.SerialCommands.STOP_SCRIPT,)))
[ "def", "stop_script", "(", "self", ")", ":", "self", ".", "send_cmd", "(", "bytes", "(", "(", "self", ".", "SerialCommands", ".", "STOP_SCRIPT", ",", ")", ")", ")" ]
[ 263, 4 ]
[ 265, 64 ]
python
en
['en', 'en', 'en']
True
Maestro.get_min
(self, channel: int)
Return minimum channel range value.
Return minimum channel range value.
def get_min(self, channel: int): """Return minimum channel range value.""" self._check_channel(channel) return self.min_targets_us[channel]
[ "def", "get_min", "(", "self", ",", "channel", ":", "int", ")", ":", "self", ".", "_check_channel", "(", "channel", ")", "return", "self", ".", "min_targets_us", "[", "channel", "]" ]
[ 267, 4 ]
[ 270, 43 ]
python
en
['it', 'et', 'en']
False
Maestro.get_max
(self, channel: int)
Return maximum channel range value.
Return maximum channel range value.
def get_max(self, channel: int): """Return maximum channel range value.""" self._check_channel(channel) return self.max_targets_us[channel]
[ "def", "get_max", "(", "self", ",", "channel", ":", "int", ")", ":", "self", ".", "_check_channel", "(", "channel", ")", "return", "self", ".", "max_targets_us", "[", "channel", "]" ]
[ 272, 4 ]
[ 275, 43 ]
python
en
['it', 'la', 'en']
False
Maestro.set_target
(self, channel: int, target_us: Real)
Set channel to a specified target value. Servo will begin moving based on Speed and Acceleration parameters previously set. Target values will be constrained within Min and Max range, if set. For servos, target represents the pulse width in of quarter-microseconds Servo center ...
Set channel to a specified target value. Servo will begin moving based on Speed and Acceleration parameters previously set. Target values will be constrained within Min and Max range, if set. For servos, target represents the pulse width in of quarter-microseconds Servo center ...
def set_target(self, channel: int, target_us: Real): """ Set channel to a specified target value. Servo will begin moving based on Speed and Acceleration parameters previously set. Target values will be constrained within Min and Max range, if set. For servos, target represents ...
[ "def", "set_target", "(", "self", ",", "channel", ":", "int", ",", "target_us", ":", "Real", ")", ":", "self", ".", "_check_channel", "(", "channel", ")", "# If min is defined and target is below, force to min", "min_target_us", "=", "self", ".", "min_targets_us", ...
[ 277, 4 ]
[ 305, 81 ]
python
en
['en', 'error', 'th']
False
Maestro.set_targets
(self, targets: Mapping[int, Real])
Set multiple channel targets at once. The Micro Maestro does not support the "set multiple targets" command, so this method will simply set each channel target one at a time. The other Maestro models, however, support the option of setting the targets for a block of channels using a ...
Set multiple channel targets at once.
def set_targets(self, targets: Mapping[int, Real]): """ Set multiple channel targets at once. The Micro Maestro does not support the "set multiple targets" command, so this method will simply set each channel target one at a time. The other Maestro models, however, support the ...
[ "def", "set_targets", "(", "self", ",", "targets", ":", "Mapping", "[", "int", ",", "Real", "]", ")", ":", "if", "self", ".", "is_micro", ":", "with", "self", ".", "_conn_lock", ":", "for", "channel", ",", "target", "in", "targets", ".", "items", "("...
[ 307, 4 ]
[ 358, 42 ]
python
en
['en', 'error', 'th']
False
Maestro.set_speed
(self, channel: int, speed: int)
Set speed of channel Speed is measured as 0.25microseconds/10milliseconds For the standard 1ms pulse width change to move a servo between extremes, a speed of 1 will take 1 minute, and a speed of 60 would take 1 second. Speed of 0 is unrestricted.
Set speed of channel Speed is measured as 0.25microseconds/10milliseconds For the standard 1ms pulse width change to move a servo between extremes, a speed of 1 will take 1 minute, and a speed of 60 would take 1 second. Speed of 0 is unrestricted.
def set_speed(self, channel: int, speed: int): """ Set speed of channel Speed is measured as 0.25microseconds/10milliseconds For the standard 1ms pulse width change to move a servo between extremes, a speed of 1 will take 1 minute, and a speed of 60 would take 1 second. Speed of ...
[ "def", "set_speed", "(", "self", ",", "channel", ":", "int", ",", "speed", ":", "int", ")", ":", "self", ".", "_check_channel", "(", "channel", ")", "lsb", ",", "msb", "=", "_get_lsb_msb", "(", "speed", ")", "self", ".", "send_cmd", "(", "bytes", "("...
[ 360, 4 ]
[ 369, 80 ]
python
en
['en', 'error', 'th']
False
Maestro.set_acceleration
(self, channel: int, acceleration: int)
Set acceleration of channel This provide soft starts and finishes when servo moves to target position. Valid values are from 0 to 255. 0 = unrestricted, 1 is slowest start. A value of 1 will take the servo about 3s to move between 1ms to 2ms range.
Set acceleration of channel This provide soft starts and finishes when servo moves to target position. Valid values are from 0 to 255. 0 = unrestricted, 1 is slowest start. A value of 1 will take the servo about 3s to move between 1ms to 2ms range.
def set_acceleration(self, channel: int, acceleration: int): """ Set acceleration of channel This provide soft starts and finishes when servo moves to target position. Valid values are from 0 to 255. 0 = unrestricted, 1 is slowest start. A value of 1 will take the servo about 3s ...
[ "def", "set_acceleration", "(", "self", ",", "channel", ":", "int", ",", "acceleration", ":", "int", ")", ":", "self", ".", "_check_channel", "(", "channel", ")", "lsb", ",", "msb", "=", "_get_lsb_msb", "(", "acceleration", ")", "self", ".", "send_cmd", ...
[ 371, 4 ]
[ 380, 87 ]
python
en
['en', 'error', 'th']
False
Maestro.get_position
(self, channel: int)
Get the current position of the device on the specified channel The result is returned in a measure of quarter-microseconds, which mirrors the Target parameter of setTarget. This is not reading the true servo position, but the last target position sent to the servo. If the Speed...
Get the current position of the device on the specified channel The result is returned in a measure of quarter-microseconds, which mirrors the Target parameter of setTarget. This is not reading the true servo position, but the last target position sent to the servo. If the Speed...
def get_position(self, channel: int) -> float: """ Get the current position of the device on the specified channel The result is returned in a measure of quarter-microseconds, which mirrors the Target parameter of setTarget. This is not reading the true servo position, but the la...
[ "def", "get_position", "(", "self", ",", "channel", ":", "int", ")", "->", "float", ":", "self", ".", "_check_channel", "(", "channel", ")", "with", "self", ".", "_conn_lock", ":", "self", ".", "send_cmd", "(", "bytes", "(", "(", "self", ".", "SerialCo...
[ 382, 4 ]
[ 400, 43 ]
python
en
['en', 'error', 'th']
False
Maestro.is_moving
(self, channel: int)
Test to see if a servo has reached the set target position. This only provides useful results if the Speed parameter is set slower than the maximum speed of the servo. Servo range must be defined first using setRange. See setRange comment. ***Note if target position goes outside of M...
Test to see if a servo has reached the set target position. This only provides useful results if the Speed parameter is set slower than the maximum speed of the servo. Servo range must be defined first using setRange. See setRange comment.
def is_moving(self, channel: int) -> bool: """ Test to see if a servo has reached the set target position. This only provides useful results if the Speed parameter is set slower than the maximum speed of the servo. Servo range must be defined first using setRange. See setRange comment....
[ "def", "is_moving", "(", "self", ",", "channel", ":", "int", ")", "->", "bool", ":", "self", ".", "_check_channel", "(", "channel", ")", "target_us", "=", "self", ".", "targets_us", "[", "channel", "]", "return", "target_us", "and", "abs", "(", "target_u...
[ 402, 4 ]
[ 414, 79 ]
python
en
['en', 'error', 'th']
False
Maestro.servos_are_moving
(self)
Determines whether the servo outputs have reached their targets or are still changing, and will return True as long as there is at least one servo that is limited by a speed or acceleration setting still moving. Using this command together with the set_target command, you can initiate several s...
Determines whether the servo outputs have reached their targets or are still changing, and will return True as long as there is at least one servo that is limited by a speed or acceleration setting still moving. Using this command together with the set_target command, you can initiate several s...
def servos_are_moving(self) -> bool: """ Determines whether the servo outputs have reached their targets or are still changing, and will return True as long as there is at least one servo that is limited by a speed or acceleration setting still moving. Using this command together with th...
[ "def", "servos_are_moving", "(", "self", ")", "->", "bool", ":", "with", "self", ".", "_conn_lock", ":", "self", ".", "send_cmd", "(", "bytes", "(", "(", "self", ".", "SerialCommands", ".", "GET_MOVING_STATE", ",", ")", ")", ")", "return", "self", ".", ...
[ 417, 4 ]
[ 430, 43 ]
python
en
['en', 'error', 'th']
False
Maestro.run_script_subroutine
(self, subroutine: int)
Starts the script running at a location specified by the subroutine number argument. The subroutines are numbered in the order they are defined in your script, starting with 0 for the first subroutine. The first subroutine is sent as 0x00 for this command, the second as 0x01, etc. To find the n...
Starts the script running at a location specified by the subroutine number argument. The subroutines are numbered in the order they are defined in your script, starting with 0 for the first subroutine. The first subroutine is sent as 0x00 for this command, the second as 0x01, etc. To find the n...
def run_script_subroutine(self, subroutine: int): """ Starts the script running at a location specified by the subroutine number argument. The subroutines are numbered in the order they are defined in your script, starting with 0 for the first subroutine. The first subroutine is sent as ...
[ "def", "run_script_subroutine", "(", "self", ",", "subroutine", ":", "int", ")", ":", "self", ".", "send_cmd", "(", "bytes", "(", "(", "self", ".", "SerialCommands", ".", "RESTART_SCRIPT_AT_SUBROUTINE", ",", "subroutine", ")", ")", ")" ]
[ 432, 4 ]
[ 443, 92 ]
python
en
['en', 'error', 'th']
False
Maestro.run_script_subroutine_with_parameter
(self, subroutine: int, parameter: int)
This method is just like the "run_script_subroutine" method, except it loads a parameter on to the stack before starting the subroutine. Since data bytes can only contain 7 bits of data, the parameter must be between 0 and 16383. :param subroutine: The subroutine number to run. ...
This method is just like the "run_script_subroutine" method, except it loads a parameter on to the stack before starting the subroutine. Since data bytes can only contain 7 bits of data, the parameter must be between 0 and 16383.
def run_script_subroutine_with_parameter(self, subroutine: int, parameter: int): """ This method is just like the "run_script_subroutine" method, except it loads a parameter on to the stack before starting the subroutine. Since data bytes can only contain 7 bits of data, the parameter must be be...
[ "def", "run_script_subroutine_with_parameter", "(", "self", ",", "subroutine", ":", "int", ",", "parameter", ":", "int", ")", ":", "parameter_lsb", ",", "parameter_msb", "=", "_get_lsb_msb", "(", "parameter", ")", "self", ".", "send_cmd", "(", "bytes", "(", "(...
[ 445, 4 ]
[ 461, 11 ]
python
en
['en', 'error', 'th']
False
suppressed_cache_errors
()
If we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled.
If we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled.
def suppressed_cache_errors(): # type: () -> Iterator[None] """If we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. """ try: yield except (OSError, IOError): pass
[ "def", "suppressed_cache_errors", "(", ")", ":", "# type: () -> Iterator[None]", "try", ":", "yield", "except", "(", "OSError", ",", "IOError", ")", ":", "pass" ]
[ 24, 0 ]
[ 32, 12 ]
python
en
['en', 'en', 'en']
True
LinearDecay.__init__
(self, milestones, staircase=None)
Linear decay of some value according to schedule. See tests for usage examples. :param milestones: list List of tuples (step, desired_value) E.g. [(0, 100), (1000, 50)] means for step <= 0 use value 100, between step 0 and 1000 interpolate the value between 100 and 50, ...
Linear decay of some value according to schedule. See tests for usage examples.
def __init__(self, milestones, staircase=None): """ Linear decay of some value according to schedule. See tests for usage examples. :param milestones: list List of tuples (step, desired_value) E.g. [(0, 100), (1000, 50)] means for step <= 0 use value 100, between step 0 ...
[ "def", "__init__", "(", "self", ",", "milestones", ",", "staircase", "=", "None", ")", ":", "if", "len", "(", "milestones", ")", "==", "0", ":", "raise", "Exception", "(", "'Milestones list should not be empty!'", ")", "self", ".", "_schedule", "=", "sorted"...
[ 4, 4 ]
[ 22, 35 ]
python
en
['en', 'error', 'th']
False
dist_from_wheel_url
(name, url, session)
Return a pkg_resources.Distribution from the given wheel URL. This uses HTTP range requests to only fetch the potion of the wheel containing metadata, just enough for the object to be constructed. If such requests are not supported, HTTPRangeRequestUnsupported is raised.
Return a pkg_resources.Distribution from the given wheel URL.
def dist_from_wheel_url(name, url, session): # type: (str, str, PipSession) -> Distribution """Return a pkg_resources.Distribution from the given wheel URL. This uses HTTP range requests to only fetch the potion of the wheel containing metadata, just enough for the object to be constructed. If such...
[ "def", "dist_from_wheel_url", "(", "name", ",", "url", ",", "session", ")", ":", "# type: (str, str, PipSession) -> Distribution", "with", "LazyZipOverHTTP", "(", "url", ",", "session", ")", "as", "wheel", ":", "# For read-only ZIP files, ZipFile only needs methods read,", ...
[ 33, 0 ]
[ 48, 79 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.mode
(self)
Opening mode, which is always rb.
Opening mode, which is always rb.
def mode(self): # type: () -> str """Opening mode, which is always rb.""" return 'rb'
[ "def", "mode", "(", "self", ")", ":", "# type: () -> str", "return", "'rb'" ]
[ 76, 4 ]
[ 79, 19 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.name
(self)
Path to the underlying file.
Path to the underlying file.
def name(self): # type: () -> str """Path to the underlying file.""" return self._file.name
[ "def", "name", "(", "self", ")", ":", "# type: () -> str", "return", "self", ".", "_file", ".", "name" ]
[ 82, 4 ]
[ 85, 30 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.seekable
(self)
Return whether random access is supported, which is True.
Return whether random access is supported, which is True.
def seekable(self): # type: () -> bool """Return whether random access is supported, which is True.""" return True
[ "def", "seekable", "(", "self", ")", ":", "# type: () -> bool", "return", "True" ]
[ 87, 4 ]
[ 90, 19 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.close
(self)
Close the file.
Close the file.
def close(self): # type: () -> None """Close the file.""" self._file.close()
[ "def", "close", "(", "self", ")", ":", "# type: () -> None", "self", ".", "_file", ".", "close", "(", ")" ]
[ 92, 4 ]
[ 95, 26 ]
python
en
['en', 'it', 'en']
True
LazyZipOverHTTP.closed
(self)
Whether the file is closed.
Whether the file is closed.
def closed(self): # type: () -> bool """Whether the file is closed.""" return self._file.closed
[ "def", "closed", "(", "self", ")", ":", "# type: () -> bool", "return", "self", ".", "_file", ".", "closed" ]
[ 98, 4 ]
[ 101, 32 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.read
(self, size=-1)
Read up to size bytes from the object and return them. As a convenience, if size is unspecified or -1, all bytes until EOF are returned. Fewer than size bytes may be returned if EOF is reached.
Read up to size bytes from the object and return them.
def read(self, size=-1): # type: (int) -> bytes """Read up to size bytes from the object and return them. As a convenience, if size is unspecified or -1, all bytes until EOF are returned. Fewer than size bytes may be returned if EOF is reached. """ download_size...
[ "def", "read", "(", "self", ",", "size", "=", "-", "1", ")", ":", "# type: (int) -> bytes", "download_size", "=", "max", "(", "size", ",", "self", ".", "_chunk_size", ")", "start", ",", "length", "=", "self", ".", "tell", "(", ")", ",", "self", ".", ...
[ 103, 4 ]
[ 116, 36 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.readable
(self)
Return whether the file is readable, which is True.
Return whether the file is readable, which is True.
def readable(self): # type: () -> bool """Return whether the file is readable, which is True.""" return True
[ "def", "readable", "(", "self", ")", ":", "# type: () -> bool", "return", "True" ]
[ 118, 4 ]
[ 121, 19 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.seek
(self, offset, whence=0)
Change stream position and return the new absolute position. Seek to offset relative position indicated by whence: * 0: Start of stream (the default). pos should be >= 0; * 1: Current position - pos may be negative; * 2: End of stream - pos usually negative.
Change stream position and return the new absolute position.
def seek(self, offset, whence=0): # type: (int, int) -> int """Change stream position and return the new absolute position. Seek to offset relative position indicated by whence: * 0: Start of stream (the default). pos should be >= 0; * 1: Current position - pos may be negative;...
[ "def", "seek", "(", "self", ",", "offset", ",", "whence", "=", "0", ")", ":", "# type: (int, int) -> int", "return", "self", ".", "_file", ".", "seek", "(", "offset", ",", "whence", ")" ]
[ 123, 4 ]
[ 132, 46 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.tell
(self)
Return the current possition.
Return the current possition.
def tell(self): # type: () -> int """Return the current possition.""" return self._file.tell()
[ "def", "tell", "(", "self", ")", ":", "# type: () -> int", "return", "self", ".", "_file", ".", "tell", "(", ")" ]
[ 134, 4 ]
[ 137, 32 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.truncate
(self, size=None)
Resize the stream to the given size in bytes. If size is unspecified resize to the current position. The current stream position isn't changed. Return the new file size.
Resize the stream to the given size in bytes.
def truncate(self, size=None): # type: (Optional[int]) -> int """Resize the stream to the given size in bytes. If size is unspecified resize to the current position. The current stream position isn't changed. Return the new file size. """ return self._file.trunc...
[ "def", "truncate", "(", "self", ",", "size", "=", "None", ")", ":", "# type: (Optional[int]) -> int", "return", "self", ".", "_file", ".", "truncate", "(", "size", ")" ]
[ 139, 4 ]
[ 148, 40 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP.writable
(self)
Return False.
Return False.
def writable(self): # type: () -> bool """Return False.""" return False
[ "def", "writable", "(", "self", ")", ":", "# type: () -> bool", "return", "False" ]
[ 150, 4 ]
[ 153, 20 ]
python
en
['en', 'ms', 'en']
False
LazyZipOverHTTP._stay
(self)
Return a context manager keeping the position. At the end of the block, seek back to original position.
Return a context manager keeping the position.
def _stay(self): # type: ()-> Iterator[None] """Return a context manager keeping the position. At the end of the block, seek back to original position. """ pos = self.tell() try: yield finally: self.seek(pos)
[ "def", "_stay", "(", "self", ")", ":", "# type: ()-> Iterator[None]", "pos", "=", "self", ".", "tell", "(", ")", "try", ":", "yield", "finally", ":", "self", ".", "seek", "(", "pos", ")" ]
[ 165, 4 ]
[ 175, 26 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP._check_zip
(self)
Check and download until the file is a valid ZIP.
Check and download until the file is a valid ZIP.
def _check_zip(self): # type: () -> None """Check and download until the file is a valid ZIP.""" end = self._length - 1 for start in reversed(range(0, end, self._chunk_size)): self._download(start, end) with self._stay(): try: #...
[ "def", "_check_zip", "(", "self", ")", ":", "# type: () -> None", "end", "=", "self", ".", "_length", "-", "1", "for", "start", "in", "reversed", "(", "range", "(", "0", ",", "end", ",", "self", ".", "_chunk_size", ")", ")", ":", "self", ".", "_downl...
[ 177, 4 ]
[ 191, 25 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP._stream_response
(self, start, end, base_headers=HEADERS)
Return HTTP response to a range request from start to end.
Return HTTP response to a range request from start to end.
def _stream_response(self, start, end, base_headers=HEADERS): # type: (int, int, Dict[str, str]) -> Response """Return HTTP response to a range request from start to end.""" headers = base_headers.copy() headers['Range'] = 'bytes={}-{}'.format(start, end) # TODO: Get range reques...
[ "def", "_stream_response", "(", "self", ",", "start", ",", "end", ",", "base_headers", "=", "HEADERS", ")", ":", "# type: (int, int, Dict[str, str]) -> Response", "headers", "=", "base_headers", ".", "copy", "(", ")", "headers", "[", "'Range'", "]", "=", "'bytes...
[ 193, 4 ]
[ 200, 73 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP._merge
(self, start, end, left, right)
Return an iterator of intervals to be fetched. Args: start (int): Start of needed interval end (int): End of needed interval left (int): Index of first overlapping downloaded data right (int): Index after last overlapping downloaded data
Return an iterator of intervals to be fetched.
def _merge(self, start, end, left, right): # type: (int, int, int, int) -> Iterator[Tuple[int, int]] """Return an iterator of intervals to be fetched. Args: start (int): Start of needed interval end (int): End of needed interval left (int): Index of first ove...
[ "def", "_merge", "(", "self", ",", "start", ",", "end", ",", "left", ",", "right", ")", ":", "# type: (int, int, int, int) -> Iterator[Tuple[int, int]]", "lslice", ",", "rslice", "=", "self", ".", "_left", "[", "left", ":", "right", "]", ",", "self", ".", ...
[ 202, 4 ]
[ 221, 72 ]
python
en
['en', 'en', 'en']
True
LazyZipOverHTTP._download
(self, start, end)
Download bytes from start to end inclusively.
Download bytes from start to end inclusively.
def _download(self, start, end): # type: (int, int) -> None """Download bytes from start to end inclusively.""" with self._stay(): left = bisect_left(self._right, start) right = bisect_right(self._left, end) for start, end in self._merge(start, end, left, righ...
[ "def", "_download", "(", "self", ",", "start", ",", "end", ")", ":", "# type: (int, int) -> None", "with", "self", ".", "_stay", "(", ")", ":", "left", "=", "bisect_left", "(", "self", ".", "_right", ",", "start", ")", "right", "=", "bisect_right", "(", ...
[ 223, 4 ]
[ 234, 43 ]
python
en
['en', 'en', 'en']
True
get_set_message_semaphore
(channel_layer, message)
Set a semaphore in redis. Used to prevent sending the same message twice within 2 seconds.
Set a semaphore in redis. Used to prevent sending the same message twice within 2 seconds.
async def get_set_message_semaphore(channel_layer, message): """Set a semaphore in redis. Used to prevent sending the same message twice within 2 seconds.""" msg_hash = message_to_hash(message) async with channel_layer.connection(0) as connection: return await connection.set(msg_hash, 1, expire=...
[ "async", "def", "get_set_message_semaphore", "(", "channel_layer", ",", "message", ")", ":", "msg_hash", "=", "message_to_hash", "(", "message", ")", "async", "with", "channel_layer", ".", "connection", "(", "0", ")", "as", "connection", ":", "return", "await", ...
[ 14, 0 ]
[ 19, 84 ]
python
it
['it', 'la', 'it']
True
info
()
return eSpeak version information
return eSpeak version information
def info(): ''' return eSpeak version information ''' dummy = ctypes.c_char_p(b'') res = _info(ctypes.byref(dummy)) return res.decode('ASCII')
[ "def", "info", "(", ")", ":", "dummy", "=", "ctypes", ".", "c_char_p", "(", "b''", ")", "res", "=", "_info", "(", "ctypes", ".", "byref", "(", "dummy", ")", ")", "return", "res", ".", "decode", "(", "'ASCII'", ")" ]
[ 39, 0 ]
[ 45, 30 ]
python
en
['en', 'error', 'th']
False
vcmp
(v1, v2)
cmp()-style version comparison
cmp()-style version comparison
def vcmp(v1, v2): ''' cmp()-style version comparison ''' v1 = v1.split('.') v2 = v2.split('.') for c1, c2 in itertools.zip_longest(v1, v2, fillvalue=0): c1 = int(c1) c2 = int(c2) if c1 > c2: return 1 elif c1 < c2: return -1 return 0
[ "def", "vcmp", "(", "v1", ",", "v2", ")", ":", "v1", "=", "v1", ".", "split", "(", "'.'", ")", "v2", "=", "v2", ".", "split", "(", "'.'", ")", "for", "c1", ",", "c2", "in", "itertools", ".", "zip_longest", "(", "v1", ",", "v2", ",", "fillvalu...
[ 49, 0 ]
[ 62, 12 ]
python
en
['en', 'error', 'th']
False
init
()
initialize eSpeak
initialize eSpeak
def init(): ''' initialize eSpeak ''' rc = _initialize(0, 0, None, 0) if rc <= 0: raise RuntimeError('espeak_Initialize(): internal error')
[ "def", "init", "(", ")", ":", "rc", "=", "_initialize", "(", "0", ",", "0", ",", "None", ",", "0", ")", "if", "rc", "<=", "0", ":", "raise", "RuntimeError", "(", "'espeak_Initialize(): internal error'", ")" ]
[ 69, 0 ]
[ 75, 65 ]
python
en
['en', 'error', 'th']
False
set_voice_by_name
(s)
use this voice for synthesis
use this voice for synthesis
def set_voice_by_name(s): ''' use this voice for synthesis ''' s = s.encode('ASCII') rc = _set_voice_by_name(s) if rc == 0: return else: # no coverage if rc == -1: msg = 'internal error' elif rc == 1: msg = 'the command could not be buffered' ...
[ "def", "set_voice_by_name", "(", "s", ")", ":", "s", "=", "s", ".", "encode", "(", "'ASCII'", ")", "rc", "=", "_set_voice_by_name", "(", "s", ")", "if", "rc", "==", "0", ":", "return", "else", ":", "# no coverage", "if", "rc", "==", "-", "1", ":", ...
[ 82, 0 ]
[ 97, 61 ]
python
en
['en', 'error', 'th']
False