repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
pyslackers/slack-sansio
slack/sansio.py
raise_for_api_error
def raise_for_api_error(headers: MutableMapping, data: MutableMapping) -> None: """ Check request response for Slack API error Args: headers: Response headers data: Response data Raises: :class:`slack.exceptions.SlackAPIError` """ if not data["ok"]: raise excep...
python
def raise_for_api_error(headers: MutableMapping, data: MutableMapping) -> None: """ Check request response for Slack API error Args: headers: Response headers data: Response data Raises: :class:`slack.exceptions.SlackAPIError` """ if not data["ok"]: raise excep...
[ "def", "raise_for_api_error", "(", "headers", ":", "MutableMapping", ",", "data", ":", "MutableMapping", ")", "->", "None", ":", "if", "not", "data", "[", "\"ok\"", "]", ":", "raise", "exceptions", ".", "SlackAPIError", "(", "data", ".", "get", "(", "\"err...
Check request response for Slack API error Args: headers: Response headers data: Response data Raises: :class:`slack.exceptions.SlackAPIError`
[ "Check", "request", "response", "for", "Slack", "API", "error" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L60-L76
pyslackers/slack-sansio
slack/sansio.py
decode_body
def decode_body(headers: MutableMapping, body: bytes) -> dict: """ Decode the response body For 'application/json' content-type load the body as a dictionary Args: headers: Response headers body: Response body Returns: decoded body """ type_, encoding = parse_cont...
python
def decode_body(headers: MutableMapping, body: bytes) -> dict: """ Decode the response body For 'application/json' content-type load the body as a dictionary Args: headers: Response headers body: Response body Returns: decoded body """ type_, encoding = parse_cont...
[ "def", "decode_body", "(", "headers", ":", "MutableMapping", ",", "body", ":", "bytes", ")", "->", "dict", ":", "type_", ",", "encoding", "=", "parse_content_type", "(", "headers", ")", "decoded_body", "=", "body", ".", "decode", "(", "encoding", ")", "# T...
Decode the response body For 'application/json' content-type load the body as a dictionary Args: headers: Response headers body: Response body Returns: decoded body
[ "Decode", "the", "response", "body" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L79-L105
pyslackers/slack-sansio
slack/sansio.py
parse_content_type
def parse_content_type(headers: MutableMapping) -> Tuple[Optional[str], str]: """ Find content-type and encoding of the response Args: headers: Response headers Returns: :py:class:`tuple` (content-type, encoding) """ content_type = headers.get("content-type") if not content...
python
def parse_content_type(headers: MutableMapping) -> Tuple[Optional[str], str]: """ Find content-type and encoding of the response Args: headers: Response headers Returns: :py:class:`tuple` (content-type, encoding) """ content_type = headers.get("content-type") if not content...
[ "def", "parse_content_type", "(", "headers", ":", "MutableMapping", ")", "->", "Tuple", "[", "Optional", "[", "str", "]", ",", "str", "]", ":", "content_type", "=", "headers", ".", "get", "(", "\"content-type\"", ")", "if", "not", "content_type", ":", "ret...
Find content-type and encoding of the response Args: headers: Response headers Returns: :py:class:`tuple` (content-type, encoding)
[ "Find", "content", "-", "type", "and", "encoding", "of", "the", "response" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L108-L124
pyslackers/slack-sansio
slack/sansio.py
prepare_request
def prepare_request( url: Union[str, methods], data: Optional[MutableMapping], headers: Optional[MutableMapping], global_headers: MutableMapping, token: str, as_json: Optional[bool] = None, ) -> Tuple[str, Union[str, MutableMapping], MutableMapping]: """ Prepare outgoing request Cre...
python
def prepare_request( url: Union[str, methods], data: Optional[MutableMapping], headers: Optional[MutableMapping], global_headers: MutableMapping, token: str, as_json: Optional[bool] = None, ) -> Tuple[str, Union[str, MutableMapping], MutableMapping]: """ Prepare outgoing request Cre...
[ "def", "prepare_request", "(", "url", ":", "Union", "[", "str", ",", "methods", "]", ",", "data", ":", "Optional", "[", "MutableMapping", "]", ",", "headers", ":", "Optional", "[", "MutableMapping", "]", ",", "global_headers", ":", "MutableMapping", ",", "...
Prepare outgoing request Create url, headers, add token to the body and if needed json encode it Args: url: :class:`slack.methods` item or string of url data: Outgoing data headers: Custom headers global_headers: Global headers token: Slack API token as_json: Po...
[ "Prepare", "outgoing", "request" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L127-L172
pyslackers/slack-sansio
slack/sansio.py
decode_response
def decode_response(status: int, headers: MutableMapping, body: bytes) -> dict: """ Decode incoming response Args: status: Response status headers: Response headers body: Response body Returns: Response data """ data = decode_body(headers, body) raise_for_st...
python
def decode_response(status: int, headers: MutableMapping, body: bytes) -> dict: """ Decode incoming response Args: status: Response status headers: Response headers body: Response body Returns: Response data """ data = decode_body(headers, body) raise_for_st...
[ "def", "decode_response", "(", "status", ":", "int", ",", "headers", ":", "MutableMapping", ",", "body", ":", "bytes", ")", "->", "dict", ":", "data", "=", "decode_body", "(", "headers", ",", "body", ")", "raise_for_status", "(", "status", ",", "headers", ...
Decode incoming response Args: status: Response status headers: Response headers body: Response body Returns: Response data
[ "Decode", "incoming", "response" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L203-L219
pyslackers/slack-sansio
slack/sansio.py
find_iteration
def find_iteration( url: Union[methods, str], itermode: Optional[str] = None, iterkey: Optional[str] = None, ) -> Tuple[str, str]: """ Find iteration mode and iteration key for a given :class:`slack.methods` Args: url: :class:`slack.methods` or string url itermode: Custom iterat...
python
def find_iteration( url: Union[methods, str], itermode: Optional[str] = None, iterkey: Optional[str] = None, ) -> Tuple[str, str]: """ Find iteration mode and iteration key for a given :class:`slack.methods` Args: url: :class:`slack.methods` or string url itermode: Custom iterat...
[ "def", "find_iteration", "(", "url", ":", "Union", "[", "methods", ",", "str", "]", ",", "itermode", ":", "Optional", "[", "str", "]", "=", "None", ",", "iterkey", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "Tuple", "[", "str", ...
Find iteration mode and iteration key for a given :class:`slack.methods` Args: url: :class:`slack.methods` or string url itermode: Custom iteration mode iterkey: Custom iteration key Returns: :py:class:`tuple` (itermode, iterkey)
[ "Find", "iteration", "mode", "and", "iteration", "key", "for", "a", "given", ":", "class", ":", "slack", ".", "methods" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L222-L249
pyslackers/slack-sansio
slack/sansio.py
prepare_iter_request
def prepare_iter_request( url: Union[methods, str], data: MutableMapping, *, iterkey: Optional[str] = None, itermode: Optional[str] = None, limit: int = 200, itervalue: Optional[Union[str, int]] = None, ) -> Tuple[MutableMapping, str, str]: """ Prepare outgoing iteration request ...
python
def prepare_iter_request( url: Union[methods, str], data: MutableMapping, *, iterkey: Optional[str] = None, itermode: Optional[str] = None, limit: int = 200, itervalue: Optional[Union[str, int]] = None, ) -> Tuple[MutableMapping, str, str]: """ Prepare outgoing iteration request ...
[ "def", "prepare_iter_request", "(", "url", ":", "Union", "[", "methods", ",", "str", "]", ",", "data", ":", "MutableMapping", ",", "*", ",", "iterkey", ":", "Optional", "[", "str", "]", "=", "None", ",", "itermode", ":", "Optional", "[", "str", "]", ...
Prepare outgoing iteration request Args: url: :class:`slack.methods` item or string of url data: Outgoing data limit: Maximum number of results to return per call. iterkey: Key in response data to iterate over (required for url string). itermode: Iteration mode (required for...
[ "Prepare", "outgoing", "iteration", "request" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L252-L289
pyslackers/slack-sansio
slack/sansio.py
decode_iter_request
def decode_iter_request(data: dict) -> Optional[Union[str, int]]: """ Decode incoming response from an iteration request Args: data: Response data Returns: Next itervalue """ if "response_metadata" in data: return data["response_metadata"].get("next_cursor") elif "p...
python
def decode_iter_request(data: dict) -> Optional[Union[str, int]]: """ Decode incoming response from an iteration request Args: data: Response data Returns: Next itervalue """ if "response_metadata" in data: return data["response_metadata"].get("next_cursor") elif "p...
[ "def", "decode_iter_request", "(", "data", ":", "dict", ")", "->", "Optional", "[", "Union", "[", "str", ",", "int", "]", "]", ":", "if", "\"response_metadata\"", "in", "data", ":", "return", "data", "[", "\"response_metadata\"", "]", ".", "get", "(", "\...
Decode incoming response from an iteration request Args: data: Response data Returns: Next itervalue
[ "Decode", "incoming", "response", "from", "an", "iteration", "request" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L292-L313
pyslackers/slack-sansio
slack/sansio.py
discard_event
def discard_event(event: events.Event, bot_id: str = None) -> bool: """ Check if the incoming event needs to be discarded Args: event: Incoming :class:`slack.events.Event` bot_id: Id of connected bot Returns: boolean """ if event["type"] in SKIP_EVENTS: return T...
python
def discard_event(event: events.Event, bot_id: str = None) -> bool: """ Check if the incoming event needs to be discarded Args: event: Incoming :class:`slack.events.Event` bot_id: Id of connected bot Returns: boolean """ if event["type"] in SKIP_EVENTS: return T...
[ "def", "discard_event", "(", "event", ":", "events", ".", "Event", ",", "bot_id", ":", "str", "=", "None", ")", "->", "bool", ":", "if", "event", "[", "\"type\"", "]", "in", "SKIP_EVENTS", ":", "return", "True", "elif", "bot_id", "and", "isinstance", "...
Check if the incoming event needs to be discarded Args: event: Incoming :class:`slack.events.Event` bot_id: Id of connected bot Returns: boolean
[ "Check", "if", "the", "incoming", "event", "needs", "to", "be", "discarded" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L316-L336
pyslackers/slack-sansio
slack/sansio.py
validate_request_signature
def validate_request_signature( body: str, headers: MutableMapping, signing_secret: str ) -> None: """ Validate incoming request signature using the application signing secret. Contrary to the ``team_id`` and ``verification_token`` verification this method is not called by ``slack-sansio`` when creatin...
python
def validate_request_signature( body: str, headers: MutableMapping, signing_secret: str ) -> None: """ Validate incoming request signature using the application signing secret. Contrary to the ``team_id`` and ``verification_token`` verification this method is not called by ``slack-sansio`` when creatin...
[ "def", "validate_request_signature", "(", "body", ":", "str", ",", "headers", ":", "MutableMapping", ",", "signing_secret", ":", "str", ")", "->", "None", ":", "request_timestamp", "=", "int", "(", "headers", "[", "\"X-Slack-Request-Timestamp\"", "]", ")", "if",...
Validate incoming request signature using the application signing secret. Contrary to the ``team_id`` and ``verification_token`` verification this method is not called by ``slack-sansio`` when creating object from incoming HTTP request. Because the body of the request needs to be provided as text and not decoded a...
[ "Validate", "incoming", "request", "signature", "using", "the", "application", "signing", "secret", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L355-L389
zagaran/mongobackup
mongobackup/backups.py
backup
def backup(mongo_username, mongo_password, local_backup_directory_path, database=None, attached_directory_path=None, custom_prefix="backup", mongo_backup_directory_path="/tmp/mongo_dump", s3_bucket=None, s3_access_key_id=None, s3_secret_key=None, purge_local=None, purge_a...
python
def backup(mongo_username, mongo_password, local_backup_directory_path, database=None, attached_directory_path=None, custom_prefix="backup", mongo_backup_directory_path="/tmp/mongo_dump", s3_bucket=None, s3_access_key_id=None, s3_secret_key=None, purge_local=None, purge_a...
[ "def", "backup", "(", "mongo_username", ",", "mongo_password", ",", "local_backup_directory_path", ",", "database", "=", "None", ",", "attached_directory_path", "=", "None", ",", "custom_prefix", "=", "\"backup\"", ",", "mongo_backup_directory_path", "=", "\"/tmp/mongo_...
Runs a backup operation to At Least a local directory. You must provide mongodb credentials along with a a directory for a dump operation and a directory to contain your compressed backup. backup_prefix: optionally provide a prefix to be prepended to your backups, by default the pr...
[ "Runs", "a", "backup", "operation", "to", "At", "Least", "a", "local", "directory", ".", "You", "must", "provide", "mongodb", "credentials", "along", "with", "a", "a", "directory", "for", "a", "dump", "operation", "and", "a", "directory", "to", "contain", ...
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L37-L94
zagaran/mongobackup
mongobackup/backups.py
restore
def restore(mongo_user, mongo_password, backup_tbz_path, backup_directory_output_path="/tmp/mongo_dump", drop_database=False, cleanup=True, silent=False, skip_system_and_user_files=False): """ Runs mongorestore with source data from the provided .tbz backup, using t...
python
def restore(mongo_user, mongo_password, backup_tbz_path, backup_directory_output_path="/tmp/mongo_dump", drop_database=False, cleanup=True, silent=False, skip_system_and_user_files=False): """ Runs mongorestore with source data from the provided .tbz backup, using t...
[ "def", "restore", "(", "mongo_user", ",", "mongo_password", ",", "backup_tbz_path", ",", "backup_directory_output_path", "=", "\"/tmp/mongo_dump\"", ",", "drop_database", "=", "False", ",", "cleanup", "=", "True", ",", "silent", "=", "False", ",", "skip_system_and_u...
Runs mongorestore with source data from the provided .tbz backup, using the provided username and password. The contents of the .tbz will be dumped into the provided backup directory, and that folder will be deleted after a successful mongodb restore unless cleanup is set to False. Note: ...
[ "Runs", "mongorestore", "with", "source", "data", "from", "the", "provided", ".", "tbz", "backup", "using", "the", "provided", "username", "and", "password", ".", "The", "contents", "of", "the", ".", "tbz", "will", "be", "dumped", "into", "the", "provided", ...
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L97-L132
zagaran/mongobackup
mongobackup/backups.py
mongodump
def mongodump(mongo_user, mongo_password, mongo_dump_directory_path, database=None, silent=False): """ Runs mongodump using the provided credentials on the running mongod process. WARNING: This function will delete the contents of the provided directory before it runs. """ ...
python
def mongodump(mongo_user, mongo_password, mongo_dump_directory_path, database=None, silent=False): """ Runs mongodump using the provided credentials on the running mongod process. WARNING: This function will delete the contents of the provided directory before it runs. """ ...
[ "def", "mongodump", "(", "mongo_user", ",", "mongo_password", ",", "mongo_dump_directory_path", ",", "database", "=", "None", ",", "silent", "=", "False", ")", ":", "if", "path", ".", "exists", "(", "mongo_dump_directory_path", ")", ":", "# If a backup dump alread...
Runs mongodump using the provided credentials on the running mongod process. WARNING: This function will delete the contents of the provided directory before it runs.
[ "Runs", "mongodump", "using", "the", "provided", "credentials", "on", "the", "running", "mongod", "process", ".", "WARNING", ":", "This", "function", "will", "delete", "the", "contents", "of", "the", "provided", "directory", "before", "it", "runs", "." ]
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L135-L152
zagaran/mongobackup
mongobackup/backups.py
mongorestore
def mongorestore(mongo_user, mongo_password, backup_directory_path, drop_database=False, silent=False): """ Warning: Setting drop_database to True will drop the ENTIRE CURRENTLY RUNNING DATABASE before restoring. Mongorestore requires a running mongod process, in addition the provided ...
python
def mongorestore(mongo_user, mongo_password, backup_directory_path, drop_database=False, silent=False): """ Warning: Setting drop_database to True will drop the ENTIRE CURRENTLY RUNNING DATABASE before restoring. Mongorestore requires a running mongod process, in addition the provided ...
[ "def", "mongorestore", "(", "mongo_user", ",", "mongo_password", ",", "backup_directory_path", ",", "drop_database", "=", "False", ",", "silent", "=", "False", ")", ":", "if", "not", "path", ".", "exists", "(", "backup_directory_path", ")", ":", "raise", "Exce...
Warning: Setting drop_database to True will drop the ENTIRE CURRENTLY RUNNING DATABASE before restoring. Mongorestore requires a running mongod process, in addition the provided user must have restore permissions for the database. A mongolia superuser will have more than a...
[ "Warning", ":", "Setting", "drop_database", "to", "True", "will", "drop", "the", "ENTIRE", "CURRENTLY", "RUNNING", "DATABASE", "before", "restoring", ".", "Mongorestore", "requires", "a", "running", "mongod", "process", "in", "addition", "the", "provided", "user",...
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L155-L176
zagaran/mongobackup
mongobackup/backups.py
get_backup_file_time_tag
def get_backup_file_time_tag(file_name, custom_prefix="backup"): """ Returns a datetime object computed from a file name string, with formatting based on DATETIME_FORMAT.""" name_string = file_name[len(custom_prefix):] time_tag = name_string.split(".", 1)[0] return datetime.strptime(time_ta...
python
def get_backup_file_time_tag(file_name, custom_prefix="backup"): """ Returns a datetime object computed from a file name string, with formatting based on DATETIME_FORMAT.""" name_string = file_name[len(custom_prefix):] time_tag = name_string.split(".", 1)[0] return datetime.strptime(time_ta...
[ "def", "get_backup_file_time_tag", "(", "file_name", ",", "custom_prefix", "=", "\"backup\"", ")", ":", "name_string", "=", "file_name", "[", "len", "(", "custom_prefix", ")", ":", "]", "time_tag", "=", "name_string", ".", "split", "(", "\".\"", ",", "1", ")...
Returns a datetime object computed from a file name string, with formatting based on DATETIME_FORMAT.
[ "Returns", "a", "datetime", "object", "computed", "from", "a", "file", "name", "string", "with", "formatting", "based", "on", "DATETIME_FORMAT", "." ]
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L184-L189
zagaran/mongobackup
mongobackup/backups.py
purge_old_files
def purge_old_files(date_time, directory_path, custom_prefix="backup"): """ Takes a datetime object and a directory path, runs through files in the directory and deletes those tagged with a date from before the provided datetime. If your backups have a custom_prefix that is not the defau...
python
def purge_old_files(date_time, directory_path, custom_prefix="backup"): """ Takes a datetime object and a directory path, runs through files in the directory and deletes those tagged with a date from before the provided datetime. If your backups have a custom_prefix that is not the defau...
[ "def", "purge_old_files", "(", "date_time", ",", "directory_path", ",", "custom_prefix", "=", "\"backup\"", ")", ":", "for", "file_name", "in", "listdir", "(", "directory_path", ")", ":", "try", ":", "file_date_time", "=", "get_backup_file_time_tag", "(", "file_na...
Takes a datetime object and a directory path, runs through files in the directory and deletes those tagged with a date from before the provided datetime. If your backups have a custom_prefix that is not the default ("backup"), provide it with the "custom_prefix" kwarg.
[ "Takes", "a", "datetime", "object", "and", "a", "directory", "path", "runs", "through", "files", "in", "the", "directory", "and", "deletes", "those", "tagged", "with", "a", "date", "from", "before", "the", "provided", "datetime", ".", "If", "your", "backups"...
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L192-L208
cakebread/yolk
yolk/setuptools_support.py
get_download_uri
def get_download_uri(package_name, version, source, index_url=None): """ Use setuptools to search for a package's URI @returns: URI string """ tmpdir = None force_scan = True develop_ok = False if not index_url: index_url = 'http://cheeseshop.python.org/pypi' if version: ...
python
def get_download_uri(package_name, version, source, index_url=None): """ Use setuptools to search for a package's URI @returns: URI string """ tmpdir = None force_scan = True develop_ok = False if not index_url: index_url = 'http://cheeseshop.python.org/pypi' if version: ...
[ "def", "get_download_uri", "(", "package_name", ",", "version", ",", "source", ",", "index_url", "=", "None", ")", ":", "tmpdir", "=", "None", "force_scan", "=", "True", "develop_ok", "=", "False", "if", "not", "index_url", ":", "index_url", "=", "'http://ch...
Use setuptools to search for a package's URI @returns: URI string
[ "Use", "setuptools", "to", "search", "for", "a", "package", "s", "URI" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/setuptools_support.py#L50-L81
cakebread/yolk
yolk/setuptools_support.py
get_pkglist
def get_pkglist(): """ Return list of all installed packages Note: It returns one project name per pkg no matter how many versions of a particular package is installed @returns: list of project name strings for every installed pkg """ dists = Distributions() projects = [] for (di...
python
def get_pkglist(): """ Return list of all installed packages Note: It returns one project name per pkg no matter how many versions of a particular package is installed @returns: list of project name strings for every installed pkg """ dists = Distributions() projects = [] for (di...
[ "def", "get_pkglist", "(", ")", ":", "dists", "=", "Distributions", "(", ")", "projects", "=", "[", "]", "for", "(", "dist", ",", "_active", ")", "in", "dists", ".", "get_distributions", "(", "\"all\"", ")", ":", "if", "dist", ".", "project_name", "not...
Return list of all installed packages Note: It returns one project name per pkg no matter how many versions of a particular package is installed @returns: list of project name strings for every installed pkg
[ "Return", "list", "of", "all", "installed", "packages" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/setuptools_support.py#L83-L99
pyslackers/slack-sansio
slack/commands.py
Router.register
def register(self, command: str, handler: Any): """ Register a new handler for a specific slash command Args: command: Slash command handler: Callback """ if not command.startswith("/"): command = f"/{command}" LOG.info("Registering ...
python
def register(self, command: str, handler: Any): """ Register a new handler for a specific slash command Args: command: Slash command handler: Callback """ if not command.startswith("/"): command = f"/{command}" LOG.info("Registering ...
[ "def", "register", "(", "self", ",", "command", ":", "str", ",", "handler", ":", "Any", ")", ":", "if", "not", "command", ".", "startswith", "(", "\"/\"", ")", ":", "command", "=", "f\"/{command}\"", "LOG", ".", "info", "(", "\"Registering %s to %s\"", "...
Register a new handler for a specific slash command Args: command: Slash command handler: Callback
[ "Register", "a", "new", "handler", "for", "a", "specific", "slash", "command" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/commands.py#L71-L84
pyslackers/slack-sansio
slack/commands.py
Router.dispatch
def dispatch(self, command: Command) -> Iterator[Any]: """ Yields handlers matching the incoming :class:`slack.actions.Command`. Args: command: :class:`slack.actions.Command` Yields: handler """ LOG.debug("Dispatching command %s", command["comman...
python
def dispatch(self, command: Command) -> Iterator[Any]: """ Yields handlers matching the incoming :class:`slack.actions.Command`. Args: command: :class:`slack.actions.Command` Yields: handler """ LOG.debug("Dispatching command %s", command["comman...
[ "def", "dispatch", "(", "self", ",", "command", ":", "Command", ")", "->", "Iterator", "[", "Any", "]", ":", "LOG", ".", "debug", "(", "\"Dispatching command %s\"", ",", "command", "[", "\"command\"", "]", ")", "for", "callback", "in", "self", ".", "_rou...
Yields handlers matching the incoming :class:`slack.actions.Command`. Args: command: :class:`slack.actions.Command` Yields: handler
[ "Yields", "handlers", "matching", "the", "incoming", ":", "class", ":", "slack", ".", "actions", ".", "Command", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/commands.py#L86-L98
ales-erjavec/anyqt
AnyQt/__init__.py
setpreferredapi
def setpreferredapi(api): """ Set the preferred Qt API. Will raise a RuntimeError if a Qt API was already selected. Note that QT_API environment variable (if set) will take precedence. """ global __PREFERRED_API if __SELECTED_API is not None: raise RuntimeError("A Qt api {} was alr...
python
def setpreferredapi(api): """ Set the preferred Qt API. Will raise a RuntimeError if a Qt API was already selected. Note that QT_API environment variable (if set) will take precedence. """ global __PREFERRED_API if __SELECTED_API is not None: raise RuntimeError("A Qt api {} was alr...
[ "def", "setpreferredapi", "(", "api", ")", ":", "global", "__PREFERRED_API", "if", "__SELECTED_API", "is", "not", "None", ":", "raise", "RuntimeError", "(", "\"A Qt api {} was already selected\"", ".", "format", "(", "__SELECTED_API", ")", ")", "if", "api", ".", ...
Set the preferred Qt API. Will raise a RuntimeError if a Qt API was already selected. Note that QT_API environment variable (if set) will take precedence.
[ "Set", "the", "preferred", "Qt", "API", "." ]
train
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/__init__.py#L11-L26
ales-erjavec/anyqt
AnyQt/__init__.py
selectapi
def selectapi(api): """ Select an Qt API to use. This can only be set once and before any of the Qt modules are explicitly imported. """ global __SELECTED_API, USED_API if api.lower() not in {"pyqt4", "pyqt5", "pyside", "pyside2"}: raise ValueError(api) if __SELECTED_API is not...
python
def selectapi(api): """ Select an Qt API to use. This can only be set once and before any of the Qt modules are explicitly imported. """ global __SELECTED_API, USED_API if api.lower() not in {"pyqt4", "pyqt5", "pyside", "pyside2"}: raise ValueError(api) if __SELECTED_API is not...
[ "def", "selectapi", "(", "api", ")", ":", "global", "__SELECTED_API", ",", "USED_API", "if", "api", ".", "lower", "(", ")", "not", "in", "{", "\"pyqt4\"", ",", "\"pyqt5\"", ",", "\"pyside\"", ",", "\"pyside2\"", "}", ":", "raise", "ValueError", "(", "api...
Select an Qt API to use. This can only be set once and before any of the Qt modules are explicitly imported.
[ "Select", "an", "Qt", "API", "to", "use", "." ]
train
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/__init__.py#L29-L46
cakebread/yolk
yolk/yolklib.py
get_highest_version
def get_highest_version(versions): """ Returns highest available version for a package in a list of versions Uses pkg_resources to parse the versions @param versions: List of PyPI package versions @type versions: List of strings @returns: string of a PyPI package version """ sorted_v...
python
def get_highest_version(versions): """ Returns highest available version for a package in a list of versions Uses pkg_resources to parse the versions @param versions: List of PyPI package versions @type versions: List of strings @returns: string of a PyPI package version """ sorted_v...
[ "def", "get_highest_version", "(", "versions", ")", ":", "sorted_versions", "=", "[", "]", "for", "ver", "in", "versions", ":", "sorted_versions", ".", "append", "(", "(", "pkg_resources", ".", "parse_version", "(", "ver", ")", ",", "ver", ")", ")", "sorte...
Returns highest available version for a package in a list of versions Uses pkg_resources to parse the versions @param versions: List of PyPI package versions @type versions: List of strings @returns: string of a PyPI package version
[ "Returns", "highest", "available", "version", "for", "a", "package", "in", "a", "list", "of", "versions", "Uses", "pkg_resources", "to", "parse", "the", "versions" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L154-L172
cakebread/yolk
yolk/yolklib.py
Distributions.get_distributions
def get_distributions(self, show, pkg_name="", version=""): """ Yield installed packages @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @param pkg_name: PyPI project name @type pkg_name: string ...
python
def get_distributions(self, show, pkg_name="", version=""): """ Yield installed packages @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @param pkg_name: PyPI project name @type pkg_name: string ...
[ "def", "get_distributions", "(", "self", ",", "show", ",", "pkg_name", "=", "\"\"", ",", "version", "=", "\"\"", ")", ":", "#pylint: disable-msg=W0612", "#'name' is a placeholder for the sorted list", "for", "name", ",", "dist", "in", "self", ".", "get_alpha", "("...
Yield installed packages @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @param pkg_name: PyPI project name @type pkg_name: string @param version: project's PyPI version @type version: string ...
[ "Yield", "installed", "packages" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L49-L77
cakebread/yolk
yolk/yolklib.py
Distributions.get_alpha
def get_alpha(self, show, pkg_name="", version=""): """ Return list of alphabetized packages @param pkg_name: PyPI project name @type pkg_name: string @param version: project's PyPI version @type version: string @returns: Alphabetized list of tuples. Each tuple...
python
def get_alpha(self, show, pkg_name="", version=""): """ Return list of alphabetized packages @param pkg_name: PyPI project name @type pkg_name: string @param version: project's PyPI version @type version: string @returns: Alphabetized list of tuples. Each tuple...
[ "def", "get_alpha", "(", "self", ",", "show", ",", "pkg_name", "=", "\"\"", ",", "version", "=", "\"\"", ")", ":", "alpha_list", "=", "[", "]", "for", "dist", "in", "self", ".", "get_packages", "(", "show", ")", ":", "if", "pkg_name", "and", "dist", ...
Return list of alphabetized packages @param pkg_name: PyPI project name @type pkg_name: string @param version: project's PyPI version @type version: string @returns: Alphabetized list of tuples. Each tuple contains a string and a pkg_resources Distribution ob...
[ "Return", "list", "of", "alphabetized", "packages" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L79-L105
cakebread/yolk
yolk/yolklib.py
Distributions.get_packages
def get_packages(self, show): """ Return list of Distributions filtered by active status or all @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @returns: list of pkg_resources Distribution objects """ ...
python
def get_packages(self, show): """ Return list of Distributions filtered by active status or all @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @returns: list of pkg_resources Distribution objects """ ...
[ "def", "get_packages", "(", "self", ",", "show", ")", ":", "if", "show", "==", "'nonactive'", "or", "show", "==", "\"all\"", ":", "all_packages", "=", "[", "]", "for", "package", "in", "self", ".", "environment", ":", "#There may be multiple versions of same p...
Return list of Distributions filtered by active status or all @param show: Type of package(s) to show; active, non-active or all @type show: string: "active", "non-active", "all" @returns: list of pkg_resources Distribution objects
[ "Return", "list", "of", "Distributions", "filtered", "by", "active", "status", "or", "all" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L107-L128
cakebread/yolk
yolk/yolklib.py
Distributions.case_sensitive_name
def case_sensitive_name(self, package_name): """ Return case-sensitive package name given any-case package name @param project_name: PyPI project name @type project_name: string """ if len(self.environment[package_name]): return self.environment[package_name...
python
def case_sensitive_name(self, package_name): """ Return case-sensitive package name given any-case package name @param project_name: PyPI project name @type project_name: string """ if len(self.environment[package_name]): return self.environment[package_name...
[ "def", "case_sensitive_name", "(", "self", ",", "package_name", ")", ":", "if", "len", "(", "self", ".", "environment", "[", "package_name", "]", ")", ":", "return", "self", ".", "environment", "[", "package_name", "]", "[", "0", "]", ".", "project_name" ]
Return case-sensitive package name given any-case package name @param project_name: PyPI project name @type project_name: string
[ "Return", "case", "-", "sensitive", "package", "name", "given", "any", "-", "case", "package", "name" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L130-L139
brutasse/django-ratelimit-backend
ratelimitbackend/backends.py
RateLimitMixin.cache_incr
def cache_incr(self, key): """ Non-atomic cache increment operation. Not optimal but consistent across different cache backends. """ cache.set(key, cache.get(key, 0) + 1, self.expire_after())
python
def cache_incr(self, key): """ Non-atomic cache increment operation. Not optimal but consistent across different cache backends. """ cache.set(key, cache.get(key, 0) + 1, self.expire_after())
[ "def", "cache_incr", "(", "self", ",", "key", ")", ":", "cache", ".", "set", "(", "key", ",", "cache", ".", "get", "(", "key", ",", "0", ")", "+", "1", ",", "self", ".", "expire_after", "(", ")", ")" ]
Non-atomic cache increment operation. Not optimal but consistent across different cache backends.
[ "Non", "-", "atomic", "cache", "increment", "operation", ".", "Not", "optimal", "but", "consistent", "across", "different", "cache", "backends", "." ]
train
https://github.com/brutasse/django-ratelimit-backend/blob/1f8f485c139eb8067f0d821ff77df98038ab9448/ratelimitbackend/backends.py#L84-L89
cakebread/yolk
yolk/plugins/__init__.py
call_plugins
def call_plugins(plugins, method, *arg, **kw): """Call all method on plugins in list, that define it, with provided arguments. The first response that is not None is returned. """ for plug in plugins: func = getattr(plug, method, None) if func is None: continue #LOG.d...
python
def call_plugins(plugins, method, *arg, **kw): """Call all method on plugins in list, that define it, with provided arguments. The first response that is not None is returned. """ for plug in plugins: func = getattr(plug, method, None) if func is None: continue #LOG.d...
[ "def", "call_plugins", "(", "plugins", ",", "method", ",", "*", "arg", ",", "*", "*", "kw", ")", ":", "for", "plug", "in", "plugins", ":", "func", "=", "getattr", "(", "plug", ",", "method", ",", "None", ")", "if", "func", "is", "None", ":", "con...
Call all method on plugins in list, that define it, with provided arguments. The first response that is not None is returned.
[ "Call", "all", "method", "on", "plugins", "in", "list", "that", "define", "it", "with", "provided", "arguments", ".", "The", "first", "response", "that", "is", "not", "None", "is", "returned", "." ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/__init__.py#L75-L87
cakebread/yolk
yolk/plugins/__init__.py
load_plugins
def load_plugins(builtin=True, others=True): """Load plugins, either builtin, others, or both. """ for entry_point in pkg_resources.iter_entry_points('yolk.plugins'): #LOG.debug("load plugin %s" % entry_point) try: plugin = entry_point.load() except KeyboardInterrupt: ...
python
def load_plugins(builtin=True, others=True): """Load plugins, either builtin, others, or both. """ for entry_point in pkg_resources.iter_entry_points('yolk.plugins'): #LOG.debug("load plugin %s" % entry_point) try: plugin = entry_point.load() except KeyboardInterrupt: ...
[ "def", "load_plugins", "(", "builtin", "=", "True", ",", "others", "=", "True", ")", ":", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "'yolk.plugins'", ")", ":", "#LOG.debug(\"load plugin %s\" % entry_point)", "try", ":", "plugin", ...
Load plugins, either builtin, others, or both.
[ "Load", "plugins", "either", "builtin", "others", "or", "both", "." ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/__init__.py#L89-L109
zagaran/mongobackup
mongobackup/s3.py
s3_connect
def s3_connect(bucket_name, s3_access_key_id, s3_secret_key): """ Returns a Boto connection to the provided S3 bucket. """ conn = connect_s3(s3_access_key_id, s3_secret_key) try: return conn.get_bucket(bucket_name) except S3ResponseError as e: if e.status == 403: raise Except...
python
def s3_connect(bucket_name, s3_access_key_id, s3_secret_key): """ Returns a Boto connection to the provided S3 bucket. """ conn = connect_s3(s3_access_key_id, s3_secret_key) try: return conn.get_bucket(bucket_name) except S3ResponseError as e: if e.status == 403: raise Except...
[ "def", "s3_connect", "(", "bucket_name", ",", "s3_access_key_id", ",", "s3_secret_key", ")", ":", "conn", "=", "connect_s3", "(", "s3_access_key_id", ",", "s3_secret_key", ")", "try", ":", "return", "conn", ".", "get_bucket", "(", "bucket_name", ")", "except", ...
Returns a Boto connection to the provided S3 bucket.
[ "Returns", "a", "Boto", "connection", "to", "the", "provided", "S3", "bucket", "." ]
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L33-L41
zagaran/mongobackup
mongobackup/s3.py
s3_list
def s3_list(s3_bucket, s3_access_key_id, s3_secret_key, prefix=None): """ Lists the contents of the S3 bucket that end in .tbz and match the passed prefix, if any. """ bucket = s3_connect(s3_bucket, s3_access_key_id, s3_secret_key) return sorted([key.name for key in bucket.list() ...
python
def s3_list(s3_bucket, s3_access_key_id, s3_secret_key, prefix=None): """ Lists the contents of the S3 bucket that end in .tbz and match the passed prefix, if any. """ bucket = s3_connect(s3_bucket, s3_access_key_id, s3_secret_key) return sorted([key.name for key in bucket.list() ...
[ "def", "s3_list", "(", "s3_bucket", ",", "s3_access_key_id", ",", "s3_secret_key", ",", "prefix", "=", "None", ")", ":", "bucket", "=", "s3_connect", "(", "s3_bucket", ",", "s3_access_key_id", ",", "s3_secret_key", ")", "return", "sorted", "(", "[", "key", "...
Lists the contents of the S3 bucket that end in .tbz and match the passed prefix, if any.
[ "Lists", "the", "contents", "of", "the", "S3", "bucket", "that", "end", "in", ".", "tbz", "and", "match", "the", "passed", "prefix", "if", "any", "." ]
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L49-L55
zagaran/mongobackup
mongobackup/s3.py
s3_download
def s3_download(output_file_path, s3_bucket, s3_access_key_id, s3_secret_key, s3_file_key=None, prefix=None): """ Downloads the file matching the provided key, in the provided bucket, from Amazon S3. If s3_file_key is none, it downloads the last file from the provide...
python
def s3_download(output_file_path, s3_bucket, s3_access_key_id, s3_secret_key, s3_file_key=None, prefix=None): """ Downloads the file matching the provided key, in the provided bucket, from Amazon S3. If s3_file_key is none, it downloads the last file from the provide...
[ "def", "s3_download", "(", "output_file_path", ",", "s3_bucket", ",", "s3_access_key_id", ",", "s3_secret_key", ",", "s3_file_key", "=", "None", ",", "prefix", "=", "None", ")", ":", "bucket", "=", "s3_connect", "(", "s3_bucket", ",", "s3_access_key_id", ",", ...
Downloads the file matching the provided key, in the provided bucket, from Amazon S3. If s3_file_key is none, it downloads the last file from the provided bucket with the .tbz extension, filtering by prefix if it is provided.
[ "Downloads", "the", "file", "matching", "the", "provided", "key", "in", "the", "provided", "bucket", "from", "Amazon", "S3", ".", "If", "s3_file_key", "is", "none", "it", "downloads", "the", "last", "file", "from", "the", "provided", "bucket", "with", "the",...
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L58-L74
zagaran/mongobackup
mongobackup/s3.py
s3_upload
def s3_upload(source_file_path, bucket_name, s3_access_key_id, s3_secret_key): """ Uploads the to Amazon S3 the contents of the provided file, keyed with the name of the file. """ key = s3_key(bucket_name, s3_access_key_id, s3_secret_key) file_name = source_file_path.split("/")[-1] key.key = fil...
python
def s3_upload(source_file_path, bucket_name, s3_access_key_id, s3_secret_key): """ Uploads the to Amazon S3 the contents of the provided file, keyed with the name of the file. """ key = s3_key(bucket_name, s3_access_key_id, s3_secret_key) file_name = source_file_path.split("/")[-1] key.key = fil...
[ "def", "s3_upload", "(", "source_file_path", ",", "bucket_name", ",", "s3_access_key_id", ",", "s3_secret_key", ")", ":", "key", "=", "s3_key", "(", "bucket_name", ",", "s3_access_key_id", ",", "s3_secret_key", ")", "file_name", "=", "source_file_path", ".", "spli...
Uploads the to Amazon S3 the contents of the provided file, keyed with the name of the file.
[ "Uploads", "the", "to", "Amazon", "S3", "the", "contents", "of", "the", "provided", "file", "keyed", "with", "the", "name", "of", "the", "file", "." ]
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L77-L86
ales-erjavec/anyqt
AnyQt/_fixes.py
fix_pyqt5_QGraphicsItem_itemChange
def fix_pyqt5_QGraphicsItem_itemChange(): """ Attempt to remedy: https://www.riverbankcomputing.com/pipermail/pyqt/2016-February/037015.html """ from PyQt5.QtWidgets import QGraphicsObject, QGraphicsItem class Obj(QGraphicsObject): def itemChange(self, change, value): return...
python
def fix_pyqt5_QGraphicsItem_itemChange(): """ Attempt to remedy: https://www.riverbankcomputing.com/pipermail/pyqt/2016-February/037015.html """ from PyQt5.QtWidgets import QGraphicsObject, QGraphicsItem class Obj(QGraphicsObject): def itemChange(self, change, value): return...
[ "def", "fix_pyqt5_QGraphicsItem_itemChange", "(", ")", ":", "from", "PyQt5", ".", "QtWidgets", "import", "QGraphicsObject", ",", "QGraphicsItem", "class", "Obj", "(", "QGraphicsObject", ")", ":", "def", "itemChange", "(", "self", ",", "change", ",", "value", ")"...
Attempt to remedy: https://www.riverbankcomputing.com/pipermail/pyqt/2016-February/037015.html
[ "Attempt", "to", "remedy", ":", "https", ":", "//", "www", ".", "riverbankcomputing", ".", "com", "/", "pipermail", "/", "pyqt", "/", "2016", "-", "February", "/", "037015", ".", "html" ]
train
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/_fixes.py#L4-L49
cakebread/yolk
yolk/cli.py
setup_opt_parser
def setup_opt_parser(): """ Setup the optparser @returns: opt_parser.OptionParser """ #pylint: disable-msg=C0301 #line too long usage = "usage: %prog [options]" opt_parser = optparse.OptionParser(usage=usage) opt_parser.add_option("--version", action='store_true', dest= ...
python
def setup_opt_parser(): """ Setup the optparser @returns: opt_parser.OptionParser """ #pylint: disable-msg=C0301 #line too long usage = "usage: %prog [options]" opt_parser = optparse.OptionParser(usage=usage) opt_parser.add_option("--version", action='store_true', dest= ...
[ "def", "setup_opt_parser", "(", ")", ":", "#pylint: disable-msg=C0301", "#line too long", "usage", "=", "\"usage: %prog [options]\"", "opt_parser", "=", "optparse", ".", "OptionParser", "(", "usage", "=", "usage", ")", "opt_parser", ".", "add_option", "(", "\"--versio...
Setup the optparser @returns: opt_parser.OptionParser
[ "Setup", "the", "optparser" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L928-L1063
cakebread/yolk
yolk/cli.py
validate_pypi_opts
def validate_pypi_opts(opt_parser): """ Check parse options that require pkg_spec @returns: pkg_spec """ (options, remaining_args) = opt_parser.parse_args() options_pkg_specs = [ options.versions_available, options.query_metadata_pypi, options.show_download_links, ...
python
def validate_pypi_opts(opt_parser): """ Check parse options that require pkg_spec @returns: pkg_spec """ (options, remaining_args) = opt_parser.parse_args() options_pkg_specs = [ options.versions_available, options.query_metadata_pypi, options.show_download_links, ...
[ "def", "validate_pypi_opts", "(", "opt_parser", ")", ":", "(", "options", ",", "remaining_args", ")", "=", "opt_parser", ".", "parse_args", "(", ")", "options_pkg_specs", "=", "[", "options", ".", "versions_available", ",", "options", ".", "query_metadata_pypi", ...
Check parse options that require pkg_spec @returns: pkg_spec
[ "Check", "parse", "options", "that", "require", "pkg_spec" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L1075-L1093
cakebread/yolk
yolk/cli.py
StdOut.write
def write(self, inline): """ Write a line to stdout if it isn't in a blacklist Try to get the name of the calling module to see if we want to filter it. If there is no calling module, use current frame in case there's a traceback before there is any calling module """ ...
python
def write(self, inline): """ Write a line to stdout if it isn't in a blacklist Try to get the name of the calling module to see if we want to filter it. If there is no calling module, use current frame in case there's a traceback before there is any calling module """ ...
[ "def", "write", "(", "self", ",", "inline", ")", ":", "frame", "=", "inspect", ".", "currentframe", "(", ")", ".", "f_back", "if", "frame", ":", "mod", "=", "frame", ".", "f_globals", ".", "get", "(", "'__name__'", ")", "else", ":", "mod", "=", "sy...
Write a line to stdout if it isn't in a blacklist Try to get the name of the calling module to see if we want to filter it. If there is no calling module, use current frame in case there's a traceback before there is any calling module
[ "Write", "a", "line", "to", "stdout", "if", "it", "isn", "t", "in", "a", "blacklist" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L75-L89
cakebread/yolk
yolk/cli.py
Yolk.get_plugin
def get_plugin(self, method): """ Return plugin object if CLI option is activated and method exists @param method: name of plugin's method we're calling @type method: string @returns: list of plugins with `method` """ all_plugins = [] for entry_point in...
python
def get_plugin(self, method): """ Return plugin object if CLI option is activated and method exists @param method: name of plugin's method we're calling @type method: string @returns: list of plugins with `method` """ all_plugins = [] for entry_point in...
[ "def", "get_plugin", "(", "self", ",", "method", ")", ":", "all_plugins", "=", "[", "]", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "'yolk.plugins'", ")", ":", "plugin_obj", "=", "entry_point", ".", "load", "(", ")", "plugin"...
Return plugin object if CLI option is activated and method exists @param method: name of plugin's method we're calling @type method: string @returns: list of plugins with `method`
[ "Return", "plugin", "object", "if", "CLI", "option", "is", "activated", "and", "method", "exists" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L121-L142
cakebread/yolk
yolk/cli.py
Yolk.set_log_level
def set_log_level(self): """ Set log level according to command-line options @returns: logger object """ if self.options.debug: self.logger.setLevel(logging.DEBUG) elif self.options.quiet: self.logger.setLevel(logging.ERROR) else: ...
python
def set_log_level(self): """ Set log level according to command-line options @returns: logger object """ if self.options.debug: self.logger.setLevel(logging.DEBUG) elif self.options.quiet: self.logger.setLevel(logging.ERROR) else: ...
[ "def", "set_log_level", "(", "self", ")", ":", "if", "self", ".", "options", ".", "debug", ":", "self", ".", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "elif", "self", ".", "options", ".", "quiet", ":", "self", ".", "logger", ".", ...
Set log level according to command-line options @returns: logger object
[ "Set", "log", "level", "according", "to", "command", "-", "line", "options" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L144-L158
cakebread/yolk
yolk/cli.py
Yolk.run
def run(self): """ Perform actions based on CLI options @returns: status code """ opt_parser = setup_opt_parser() (self.options, remaining_args) = opt_parser.parse_args() logger = self.set_log_level() pkg_spec = validate_pypi_opts(opt_parser) if ...
python
def run(self): """ Perform actions based on CLI options @returns: status code """ opt_parser = setup_opt_parser() (self.options, remaining_args) = opt_parser.parse_args() logger = self.set_log_level() pkg_spec = validate_pypi_opts(opt_parser) if ...
[ "def", "run", "(", "self", ")", ":", "opt_parser", "=", "setup_opt_parser", "(", ")", "(", "self", ".", "options", ",", "remaining_args", ")", "=", "opt_parser", ".", "parse_args", "(", ")", "logger", "=", "self", ".", "set_log_level", "(", ")", "pkg_spe...
Perform actions based on CLI options @returns: status code
[ "Perform", "actions", "based", "on", "CLI", "options" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L160-L215
cakebread/yolk
yolk/cli.py
Yolk.show_updates
def show_updates(self): """ Check installed packages for available updates on PyPI @param project_name: optional package name to check; checks every installed pacakge if none specified @type project_name: string @returns: None """ di...
python
def show_updates(self): """ Check installed packages for available updates on PyPI @param project_name: optional package name to check; checks every installed pacakge if none specified @type project_name: string @returns: None """ di...
[ "def", "show_updates", "(", "self", ")", ":", "dists", "=", "Distributions", "(", ")", "if", "self", ".", "project_name", ":", "#Check for a single package", "pkg_list", "=", "[", "self", ".", "project_name", "]", "else", ":", "#Check for every installed package",...
Check installed packages for available updates on PyPI @param project_name: optional package name to check; checks every installed pacakge if none specified @type project_name: string @returns: None
[ "Check", "installed", "packages", "for", "available", "updates", "on", "PyPI" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L236-L279
cakebread/yolk
yolk/cli.py
Yolk.show_distributions
def show_distributions(self, show): """ Show list of installed activated OR non-activated packages @param show: type of pkgs to show (all, active or nonactive) @type show: string @returns: None or 2 if error """ show_metadata = self.options.metadata #Se...
python
def show_distributions(self, show): """ Show list of installed activated OR non-activated packages @param show: type of pkgs to show (all, active or nonactive) @type show: string @returns: None or 2 if error """ show_metadata = self.options.metadata #Se...
[ "def", "show_distributions", "(", "self", ",", "show", ")", ":", "show_metadata", "=", "self", ".", "options", ".", "metadata", "#Search for any plugins with active CLI options with add_column() method", "plugins", "=", "self", ".", "get_plugin", "(", "\"add_column\"", ...
Show list of installed activated OR non-activated packages @param show: type of pkgs to show (all, active or nonactive) @type show: string @returns: None or 2 if error
[ "Show", "list", "of", "installed", "activated", "OR", "non", "-", "activated", "packages" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L282-L344
cakebread/yolk
yolk/cli.py
Yolk.print_metadata
def print_metadata(self, metadata, develop, active, installed_by): """ Print out formatted metadata @param metadata: package's metadata @type metadata: pkg_resources Distribution obj @param develop: path to pkg if its deployed in development mode @type develop: string ...
python
def print_metadata(self, metadata, develop, active, installed_by): """ Print out formatted metadata @param metadata: package's metadata @type metadata: pkg_resources Distribution obj @param develop: path to pkg if its deployed in development mode @type develop: string ...
[ "def", "print_metadata", "(", "self", ",", "metadata", ",", "develop", ",", "active", ",", "installed_by", ")", ":", "show_metadata", "=", "self", ".", "options", ".", "metadata", "if", "self", ".", "options", ".", "fields", ":", "fields", "=", "self", "...
Print out formatted metadata @param metadata: package's metadata @type metadata: pkg_resources Distribution obj @param develop: path to pkg if its deployed in development mode @type develop: string @param active: show if package is activated or not @type active: boolea...
[ "Print", "out", "formatted", "metadata", "@param", "metadata", ":", "package", "s", "metadata", "@type", "metadata", ":", "pkg_resources", "Distribution", "obj" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L347-L411
cakebread/yolk
yolk/cli.py
Yolk.show_deps
def show_deps(self): """ Show dependencies for package(s) @returns: 0 - sucess 1 - No dependency info supplied """ pkgs = pkg_resources.Environment() for pkg in pkgs[self.project_name]: if not self.version: print(pkg.project_name, pkg.versi...
python
def show_deps(self): """ Show dependencies for package(s) @returns: 0 - sucess 1 - No dependency info supplied """ pkgs = pkg_resources.Environment() for pkg in pkgs[self.project_name]: if not self.version: print(pkg.project_name, pkg.versi...
[ "def", "show_deps", "(", "self", ")", ":", "pkgs", "=", "pkg_resources", ".", "Environment", "(", ")", "for", "pkg", "in", "pkgs", "[", "self", ".", "project_name", "]", ":", "if", "not", "self", ".", "version", ":", "print", "(", "pkg", ".", "projec...
Show dependencies for package(s) @returns: 0 - sucess 1 - No dependency info supplied
[ "Show", "dependencies", "for", "package", "(", "s", ")" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L413-L439
cakebread/yolk
yolk/cli.py
Yolk.show_pypi_changelog
def show_pypi_changelog(self): """ Show detailed PyPI ChangeLog for the last `hours` @returns: 0 = sucess or 1 if failed to retrieve from XML-RPC server """ hours = self.options.show_pypi_changelog if not hours.isdigit(): self.logger.error("Error: You must s...
python
def show_pypi_changelog(self): """ Show detailed PyPI ChangeLog for the last `hours` @returns: 0 = sucess or 1 if failed to retrieve from XML-RPC server """ hours = self.options.show_pypi_changelog if not hours.isdigit(): self.logger.error("Error: You must s...
[ "def", "show_pypi_changelog", "(", "self", ")", ":", "hours", "=", "self", ".", "options", ".", "show_pypi_changelog", "if", "not", "hours", ".", "isdigit", "(", ")", ":", "self", ".", "logger", ".", "error", "(", "\"Error: You must supply an integer.\"", ")",...
Show detailed PyPI ChangeLog for the last `hours` @returns: 0 = sucess or 1 if failed to retrieve from XML-RPC server
[ "Show", "detailed", "PyPI", "ChangeLog", "for", "the", "last", "hours" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L441-L469
cakebread/yolk
yolk/cli.py
Yolk.show_pypi_releases
def show_pypi_releases(self): """ Show PyPI releases for the last number of `hours` @returns: 0 = success or 1 if failed to retrieve from XML-RPC server """ try: hours = int(self.options.show_pypi_releases) except ValueError: self.logger.error("E...
python
def show_pypi_releases(self): """ Show PyPI releases for the last number of `hours` @returns: 0 = success or 1 if failed to retrieve from XML-RPC server """ try: hours = int(self.options.show_pypi_releases) except ValueError: self.logger.error("E...
[ "def", "show_pypi_releases", "(", "self", ")", ":", "try", ":", "hours", "=", "int", "(", "self", ".", "options", ".", "show_pypi_releases", ")", "except", "ValueError", ":", "self", ".", "logger", ".", "error", "(", "\"ERROR: You must supply an integer.\"", "...
Show PyPI releases for the last number of `hours` @returns: 0 = success or 1 if failed to retrieve from XML-RPC server
[ "Show", "PyPI", "releases", "for", "the", "last", "number", "of", "hours" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L471-L492
cakebread/yolk
yolk/cli.py
Yolk.show_download_links
def show_download_links(self): """ Query PyPI for pkg download URI for a packge @returns: 0 """ #In case they specify version as 'dev' instead of using -T svn, #don't show three svn URI's if self.options.file_type == "all" and self.version == "dev": ...
python
def show_download_links(self): """ Query PyPI for pkg download URI for a packge @returns: 0 """ #In case they specify version as 'dev' instead of using -T svn, #don't show three svn URI's if self.options.file_type == "all" and self.version == "dev": ...
[ "def", "show_download_links", "(", "self", ")", ":", "#In case they specify version as 'dev' instead of using -T svn,", "#don't show three svn URI's", "if", "self", ".", "options", ".", "file_type", "==", "\"all\"", "and", "self", ".", "version", "==", "\"dev\"", ":", "...
Query PyPI for pkg download URI for a packge @returns: 0
[ "Query", "PyPI", "for", "pkg", "download", "URI", "for", "a", "packge" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L494-L524
cakebread/yolk
yolk/cli.py
Yolk.print_download_uri
def print_download_uri(self, version, source): """ @param version: version number or 'dev' for svn @type version: string @param source: download source or egg @type source: boolean @returns: None """ if version == "dev": pkg_type = "subvers...
python
def print_download_uri(self, version, source): """ @param version: version number or 'dev' for svn @type version: string @param source: download source or egg @type source: boolean @returns: None """ if version == "dev": pkg_type = "subvers...
[ "def", "print_download_uri", "(", "self", ",", "version", ",", "source", ")", ":", "if", "version", "==", "\"dev\"", ":", "pkg_type", "=", "\"subversion\"", "source", "=", "True", "elif", "source", ":", "pkg_type", "=", "\"source\"", "else", ":", "pkg_type",...
@param version: version number or 'dev' for svn @type version: string @param source: download source or egg @type source: boolean @returns: None
[ "@param", "version", ":", "version", "number", "or", "dev", "for", "svn", "@type", "version", ":", "string" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L526-L552
cakebread/yolk
yolk/cli.py
Yolk.fetch
def fetch(self): """ Download a package @returns: 0 = success or 1 if failed download """ #Default type to download source = True directory = "." if self.options.file_type == "svn": version = "dev" svn_uri = get_download_uri(self...
python
def fetch(self): """ Download a package @returns: 0 = success or 1 if failed download """ #Default type to download source = True directory = "." if self.options.file_type == "svn": version = "dev" svn_uri = get_download_uri(self...
[ "def", "fetch", "(", "self", ")", ":", "#Default type to download", "source", "=", "True", "directory", "=", "\".\"", "if", "self", ".", "options", ".", "file_type", "==", "\"svn\"", ":", "version", "=", "\"dev\"", "svn_uri", "=", "get_download_uri", "(", "s...
Download a package @returns: 0 = success or 1 if failed download
[ "Download", "a", "package" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L554-L588
cakebread/yolk
yolk/cli.py
Yolk.fetch_uri
def fetch_uri(self, directory, uri): """ Use ``urllib.urlretrieve`` to download package to file in sandbox dir. @param directory: directory to download to @type directory: string @param uri: uri to download @type uri: string @returns: 0 = success or 1 for faile...
python
def fetch_uri(self, directory, uri): """ Use ``urllib.urlretrieve`` to download package to file in sandbox dir. @param directory: directory to download to @type directory: string @param uri: uri to download @type uri: string @returns: 0 = success or 1 for faile...
[ "def", "fetch_uri", "(", "self", ",", "directory", ",", "uri", ")", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "urlparse", "(", "uri", ")", "[", "2", "]", ")", "if", "os", ".", "path", ".", "exists", "(", "filename", ")", ":",...
Use ``urllib.urlretrieve`` to download package to file in sandbox dir. @param directory: directory to download to @type directory: string @param uri: uri to download @type uri: string @returns: 0 = success or 1 for failed download
[ "Use", "urllib", ".", "urlretrieve", "to", "download", "package", "to", "file", "in", "sandbox", "dir", "." ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L590-L623
cakebread/yolk
yolk/cli.py
Yolk.fetch_svn
def fetch_svn(self, svn_uri, directory): """ Fetch subversion repository @param svn_uri: subversion repository uri to check out @type svn_uri: string @param directory: directory to download to @type directory: string @returns: 0 = success or 1 for failed downlo...
python
def fetch_svn(self, svn_uri, directory): """ Fetch subversion repository @param svn_uri: subversion repository uri to check out @type svn_uri: string @param directory: directory to download to @type directory: string @returns: 0 = success or 1 for failed downlo...
[ "def", "fetch_svn", "(", "self", ",", "svn_uri", ",", "directory", ")", ":", "if", "not", "command_successful", "(", "\"svn --version\"", ")", ":", "self", ".", "logger", ".", "error", "(", "\"ERROR: Do you have subversion installed?\"", ")", "return", "1", "if"...
Fetch subversion repository @param svn_uri: subversion repository uri to check out @type svn_uri: string @param directory: directory to download to @type directory: string @returns: 0 = success or 1 for failed download
[ "Fetch", "subversion", "repository" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L626-L660
cakebread/yolk
yolk/cli.py
Yolk.browse_website
def browse_website(self, browser=None): """ Launch web browser at project's homepage @param browser: name of web browser to use @type browser: string @returns: 0 if homepage found, 1 if no homepage found """ if len(self.all_versions): metadata = self...
python
def browse_website(self, browser=None): """ Launch web browser at project's homepage @param browser: name of web browser to use @type browser: string @returns: 0 if homepage found, 1 if no homepage found """ if len(self.all_versions): metadata = self...
[ "def", "browse_website", "(", "self", ",", "browser", "=", "None", ")", ":", "if", "len", "(", "self", ".", "all_versions", ")", ":", "metadata", "=", "self", ".", "pypi", ".", "release_data", "(", "self", ".", "project_name", ",", "self", ".", "all_ve...
Launch web browser at project's homepage @param browser: name of web browser to use @type browser: string @returns: 0 if homepage found, 1 if no homepage found
[ "Launch", "web", "browser", "at", "project", "s", "homepage" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L662-L686
cakebread/yolk
yolk/cli.py
Yolk.query_metadata_pypi
def query_metadata_pypi(self): """ Show pkg metadata queried from PyPI @returns: 0 """ if self.version and self.version in self.all_versions: metadata = self.pypi.release_data(self.project_name, self.version) else: #Give highest version ...
python
def query_metadata_pypi(self): """ Show pkg metadata queried from PyPI @returns: 0 """ if self.version and self.version in self.all_versions: metadata = self.pypi.release_data(self.project_name, self.version) else: #Give highest version ...
[ "def", "query_metadata_pypi", "(", "self", ")", ":", "if", "self", ".", "version", "and", "self", ".", "version", "in", "self", ".", "all_versions", ":", "metadata", "=", "self", ".", "pypi", ".", "release_data", "(", "self", ".", "project_name", ",", "s...
Show pkg metadata queried from PyPI @returns: 0
[ "Show", "pkg", "metadata", "queried", "from", "PyPI" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L689-L708
cakebread/yolk
yolk/cli.py
Yolk.versions_available
def versions_available(self): """ Query PyPI for a particular version or all versions of a package @returns: 0 if version(s) found or 1 if none found """ if self.version: spec = "%s==%s" % (self.project_name, self.version) else: spec = self.proje...
python
def versions_available(self): """ Query PyPI for a particular version or all versions of a package @returns: 0 if version(s) found or 1 if none found """ if self.version: spec = "%s==%s" % (self.project_name, self.version) else: spec = self.proje...
[ "def", "versions_available", "(", "self", ")", ":", "if", "self", ".", "version", ":", "spec", "=", "\"%s==%s\"", "%", "(", "self", ".", "project_name", ",", "self", ".", "version", ")", "else", ":", "spec", "=", "self", ".", "project_name", "if", "sel...
Query PyPI for a particular version or all versions of a package @returns: 0 if version(s) found or 1 if none found
[ "Query", "PyPI", "for", "a", "particular", "version", "or", "all", "versions", "of", "a", "package" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L710-L733
cakebread/yolk
yolk/cli.py
Yolk.parse_search_spec
def parse_search_spec(self, spec): """ Parse search args and return spec dict for PyPI * Owwww, my eyes!. Re-write this. @param spec: Cheese Shop package search spec e.g. name=Cheetah license=ZPL license...
python
def parse_search_spec(self, spec): """ Parse search args and return spec dict for PyPI * Owwww, my eyes!. Re-write this. @param spec: Cheese Shop package search spec e.g. name=Cheetah license=ZPL license...
[ "def", "parse_search_spec", "(", "self", ",", "spec", ")", ":", "usage", "=", "\"\"\"You can search PyPI by the following:\n name\n version\n author\n author_email\n maintainer\n maintainer_email\n home_page\n license\n summary\n description\n keywords...
Parse search args and return spec dict for PyPI * Owwww, my eyes!. Re-write this. @param spec: Cheese Shop package search spec e.g. name=Cheetah license=ZPL license=ZPL AND name=Cheetah @type spec: string ...
[ "Parse", "search", "args", "and", "return", "spec", "dict", "for", "PyPI", "*", "Owwww", "my", "eyes!", ".", "Re", "-", "write", "this", "." ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L735-L798
cakebread/yolk
yolk/cli.py
Yolk.pypi_search
def pypi_search(self): """ Search PyPI by metadata keyword e.g. yolk -S name=yolk AND license=GPL @param spec: Cheese Shop search spec @type spec: list of strings spec examples: ["name=yolk"] ["license=GPL"] ["name=yolk", "AND", "license=GP...
python
def pypi_search(self): """ Search PyPI by metadata keyword e.g. yolk -S name=yolk AND license=GPL @param spec: Cheese Shop search spec @type spec: list of strings spec examples: ["name=yolk"] ["license=GPL"] ["name=yolk", "AND", "license=GP...
[ "def", "pypi_search", "(", "self", ")", ":", "spec", "=", "self", ".", "pkg_spec", "#Add remainging cli arguments to options.pypi_search", "search_arg", "=", "self", ".", "options", ".", "pypi_search", "spec", ".", "insert", "(", "0", ",", "search_arg", ".", "st...
Search PyPI by metadata keyword e.g. yolk -S name=yolk AND license=GPL @param spec: Cheese Shop search spec @type spec: list of strings spec examples: ["name=yolk"] ["license=GPL"] ["name=yolk", "AND", "license=GPL"] @returns: 0 on success or 1 if...
[ "Search", "PyPI", "by", "metadata", "keyword", "e", ".", "g", ".", "yolk", "-", "S", "name", "=", "yolk", "AND", "license", "=", "GPL" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L801-L834
cakebread/yolk
yolk/cli.py
Yolk.show_entry_map
def show_entry_map(self): """ Show entry map for a package @param dist: package @param type: srting @returns: 0 for success or 1 if error """ pprinter = pprint.PrettyPrinter() try: entry_map = pkg_resources.get_entry_map(self.options.show_ent...
python
def show_entry_map(self): """ Show entry map for a package @param dist: package @param type: srting @returns: 0 for success or 1 if error """ pprinter = pprint.PrettyPrinter() try: entry_map = pkg_resources.get_entry_map(self.options.show_ent...
[ "def", "show_entry_map", "(", "self", ")", ":", "pprinter", "=", "pprint", ".", "PrettyPrinter", "(", ")", "try", ":", "entry_map", "=", "pkg_resources", ".", "get_entry_map", "(", "self", ".", "options", ".", "show_entry_map", ")", "if", "entry_map", ":", ...
Show entry map for a package @param dist: package @param type: srting @returns: 0 for success or 1 if error
[ "Show", "entry", "map", "for", "a", "package" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L836-L854
cakebread/yolk
yolk/cli.py
Yolk.show_entry_points
def show_entry_points(self): """ Show entry points for a module @returns: 0 for success or 1 if error """ found = False for entry_point in \ pkg_resources.iter_entry_points(self.options.show_entry_points): found = True try: ...
python
def show_entry_points(self): """ Show entry points for a module @returns: 0 for success or 1 if error """ found = False for entry_point in \ pkg_resources.iter_entry_points(self.options.show_entry_points): found = True try: ...
[ "def", "show_entry_points", "(", "self", ")", ":", "found", "=", "False", "for", "entry_point", "in", "pkg_resources", ".", "iter_entry_points", "(", "self", ".", "options", ".", "show_entry_points", ")", ":", "found", "=", "True", "try", ":", "plugin", "=",...
Show entry points for a module @returns: 0 for success or 1 if error
[ "Show", "entry", "points", "for", "a", "module" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L856-L880
cakebread/yolk
yolk/cli.py
Yolk.parse_pkg_ver
def parse_pkg_ver(self, want_installed): """ Return tuple with project_name and version from CLI args If the user gave the wrong case for the project name, this corrects it @param want_installed: whether package we want is installed or not @type want_installed: boolean ...
python
def parse_pkg_ver(self, want_installed): """ Return tuple with project_name and version from CLI args If the user gave the wrong case for the project name, this corrects it @param want_installed: whether package we want is installed or not @type want_installed: boolean ...
[ "def", "parse_pkg_ver", "(", "self", ",", "want_installed", ")", ":", "all_versions", "=", "[", "]", "arg_str", "=", "(", "\"\"", ")", ".", "join", "(", "self", ".", "pkg_spec", ")", "if", "\"==\"", "not", "in", "arg_str", ":", "#No version specified", "...
Return tuple with project_name and version from CLI args If the user gave the wrong case for the project name, this corrects it @param want_installed: whether package we want is installed or not @type want_installed: boolean @returns: tuple(project_name, version, all_versions)
[ "Return", "tuple", "with", "project_name", "and", "version", "from", "CLI", "args", "If", "the", "user", "gave", "the", "wrong", "case", "for", "the", "project", "name", "this", "corrects", "it" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L891-L926
ales-erjavec/anyqt
AnyQt/importhooks.py
install_backport_hook
def install_backport_hook(api): """ Install a backport import hook for Qt4 api Parameters ---------- api : str The Qt4 api whose structure should be intercepted ('pyqt4' or 'pyside'). Example ------- >>> install_backport_hook("pyqt4") >>> import PyQt4 Loaded mod...
python
def install_backport_hook(api): """ Install a backport import hook for Qt4 api Parameters ---------- api : str The Qt4 api whose structure should be intercepted ('pyqt4' or 'pyside'). Example ------- >>> install_backport_hook("pyqt4") >>> import PyQt4 Loaded mod...
[ "def", "install_backport_hook", "(", "api", ")", ":", "if", "api", "==", "USED_API", ":", "raise", "ValueError", "sys", ".", "meta_path", ".", "insert", "(", "0", ",", "ImportHookBackport", "(", "api", ")", ")" ]
Install a backport import hook for Qt4 api Parameters ---------- api : str The Qt4 api whose structure should be intercepted ('pyqt4' or 'pyside'). Example ------- >>> install_backport_hook("pyqt4") >>> import PyQt4 Loaded module AnyQt._backport as a substitute for PyQt...
[ "Install", "a", "backport", "import", "hook", "for", "Qt4", "api" ]
train
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/importhooks.py#L81-L101
ales-erjavec/anyqt
AnyQt/importhooks.py
install_deny_hook
def install_deny_hook(api): """ Install a deny import hook for Qt api. Parameters ---------- api : str The Qt api whose import should be prevented Example ------- >>> install_deny_import("pyqt4") >>> import PyQt4 Traceback (most recent call last):... ImportError: Im...
python
def install_deny_hook(api): """ Install a deny import hook for Qt api. Parameters ---------- api : str The Qt api whose import should be prevented Example ------- >>> install_deny_import("pyqt4") >>> import PyQt4 Traceback (most recent call last):... ImportError: Im...
[ "def", "install_deny_hook", "(", "api", ")", ":", "if", "api", "==", "USED_API", ":", "raise", "ValueError", "sys", ".", "meta_path", ".", "insert", "(", "0", ",", "ImportHookDeny", "(", "api", ")", ")" ]
Install a deny import hook for Qt api. Parameters ---------- api : str The Qt api whose import should be prevented Example ------- >>> install_deny_import("pyqt4") >>> import PyQt4 Traceback (most recent call last):... ImportError: Import of PyQt4 is denied.
[ "Install", "a", "deny", "import", "hook", "for", "Qt", "api", "." ]
train
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/importhooks.py#L104-L124
cakebread/yolk
yolk/utils.py
run_command
def run_command(cmd, env=None, max_timeout=None): """ Run command and return its return status code and its output """ arglist = cmd.split() output = os.tmpfile() try: pipe = Popen(arglist, stdout=output, stderr=STDOUT, env=env) except Exception as errmsg: return 1, errmsg ...
python
def run_command(cmd, env=None, max_timeout=None): """ Run command and return its return status code and its output """ arglist = cmd.split() output = os.tmpfile() try: pipe = Popen(arglist, stdout=output, stderr=STDOUT, env=env) except Exception as errmsg: return 1, errmsg ...
[ "def", "run_command", "(", "cmd", ",", "env", "=", "None", ",", "max_timeout", "=", "None", ")", ":", "arglist", "=", "cmd", ".", "split", "(", ")", "output", "=", "os", ".", "tmpfile", "(", ")", "try", ":", "pipe", "=", "Popen", "(", "arglist", ...
Run command and return its return status code and its output
[ "Run", "command", "and", "return", "its", "return", "status", "code", "and", "its", "output" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/utils.py#L30-L55
pyslackers/slack-sansio
slack/io/abc.py
SlackAPI.iter
async def iter( self, url: Union[str, methods], data: Optional[MutableMapping] = None, headers: Optional[MutableMapping] = None, *, limit: int = 200, iterkey: Optional[str] = None, itermode: Optional[str] = None, minimum_time: Optional[int] = None,...
python
async def iter( self, url: Union[str, methods], data: Optional[MutableMapping] = None, headers: Optional[MutableMapping] = None, *, limit: int = 200, iterkey: Optional[str] = None, itermode: Optional[str] = None, minimum_time: Optional[int] = None,...
[ "async", "def", "iter", "(", "self", ",", "url", ":", "Union", "[", "str", ",", "methods", "]", ",", "data", ":", "Optional", "[", "MutableMapping", "]", "=", "None", ",", "headers", ":", "Optional", "[", "MutableMapping", "]", "=", "None", ",", "*",...
Iterate over a slack API method supporting pagination When using :class:`slack.methods` the request is made `as_json` if available Args: url: :class:`slack.methods` or url string data: JSON encodable MutableMapping headers: limit: Maximum number of resul...
[ "Iterate", "over", "a", "slack", "API", "method", "supporting", "pagination" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/io/abc.py#L88-L149
pyslackers/slack-sansio
slack/io/abc.py
SlackAPI._incoming_from_rtm
async def _incoming_from_rtm( self, url: str, bot_id: str ) -> AsyncIterator[events.Event]: """ Connect and discard incoming RTM event if necessary. :param url: Websocket url :param bot_id: Bot ID :return: Incoming events """ async for data in self._r...
python
async def _incoming_from_rtm( self, url: str, bot_id: str ) -> AsyncIterator[events.Event]: """ Connect and discard incoming RTM event if necessary. :param url: Websocket url :param bot_id: Bot ID :return: Incoming events """ async for data in self._r...
[ "async", "def", "_incoming_from_rtm", "(", "self", ",", "url", ":", "str", ",", "bot_id", ":", "str", ")", "->", "AsyncIterator", "[", "events", ".", "Event", "]", ":", "async", "for", "data", "in", "self", ".", "_rtm", "(", "url", ")", ":", "event",...
Connect and discard incoming RTM event if necessary. :param url: Websocket url :param bot_id: Bot ID :return: Incoming events
[ "Connect", "and", "discard", "incoming", "RTM", "event", "if", "necessary", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/io/abc.py#L195-L212
brutasse/django-ratelimit-backend
ratelimitbackend/views.py
login
def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm, current_app=None, extra_context=None): """ Displays the login form and handles the login action. """ redirect_to = request.POST.get(r...
python
def login(request, template_name='registration/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm, current_app=None, extra_context=None): """ Displays the login form and handles the login action. """ redirect_to = request.POST.get(r...
[ "def", "login", "(", "request", ",", "template_name", "=", "'registration/login.html'", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "authentication_form", "=", "AuthenticationForm", ",", "current_app", "=", "None", ",", "extra_context", "=", "None", "...
Displays the login form and handles the login action.
[ "Displays", "the", "login", "form", "and", "handles", "the", "login", "action", "." ]
train
https://github.com/brutasse/django-ratelimit-backend/blob/1f8f485c139eb8067f0d821ff77df98038ab9448/ratelimitbackend/views.py#L17-L59
cakebread/yolk
examples/plugins/yolk_pkg_manager/yolk_acme.py
PackageManagerPlugin.package_manager_owns
def package_manager_owns(self, dist): """ Returns True if package manager 'owns' file Returns False if package manager does not 'own' file There is currently no way to determine if distutils or setuptools installed a package. A future feature of setuptools will make a pa...
python
def package_manager_owns(self, dist): """ Returns True if package manager 'owns' file Returns False if package manager does not 'own' file There is currently no way to determine if distutils or setuptools installed a package. A future feature of setuptools will make a pa...
[ "def", "package_manager_owns", "(", "self", ",", "dist", ")", ":", "#Installed by distutils/setuptools or external package manager?", "#If location is in site-packages dir, check for .egg-info file", "if", "dist", ".", "location", ".", "lower", "(", ")", "==", "get_python_lib",...
Returns True if package manager 'owns' file Returns False if package manager does not 'own' file There is currently no way to determine if distutils or setuptools installed a package. A future feature of setuptools will make a package manifest which can be checked. '...
[ "Returns", "True", "if", "package", "manager", "owns", "file", "Returns", "False", "if", "package", "manager", "does", "not", "own", "file" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/examples/plugins/yolk_pkg_manager/yolk_acme.py#L71-L96
cakebread/yolk
yolk/pypi.py
check_proxy_setting
def check_proxy_setting(): """ If the environmental variable 'HTTP_PROXY' is set, it will most likely be in one of these forms: proxyhost:8080 http://proxyhost:8080 urlllib2 requires the proxy URL to start with 'http://' This routine does that, and returns the transport for xml...
python
def check_proxy_setting(): """ If the environmental variable 'HTTP_PROXY' is set, it will most likely be in one of these forms: proxyhost:8080 http://proxyhost:8080 urlllib2 requires the proxy URL to start with 'http://' This routine does that, and returns the transport for xml...
[ "def", "check_proxy_setting", "(", ")", ":", "try", ":", "http_proxy", "=", "os", ".", "environ", "[", "'HTTP_PROXY'", "]", "except", "KeyError", ":", "return", "if", "not", "http_proxy", ".", "startswith", "(", "'http://'", ")", ":", "match", "=", "re", ...
If the environmental variable 'HTTP_PROXY' is set, it will most likely be in one of these forms: proxyhost:8080 http://proxyhost:8080 urlllib2 requires the proxy URL to start with 'http://' This routine does that, and returns the transport for xmlrpc.
[ "If", "the", "environmental", "variable", "HTTP_PROXY", "is", "set", "it", "will", "most", "likely", "be", "in", "one", "of", "these", "forms", ":" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L95-L117
cakebread/yolk
yolk/pypi.py
filter_url
def filter_url(pkg_type, url): """ Returns URL of specified file type 'source', 'egg', or 'all' """ bad_stuff = ["?modtime", "#md5="] for junk in bad_stuff: if junk in url: url = url.split(junk)[0] break #pkg_spec==dev (svn) if url.endswith("-dev"): ...
python
def filter_url(pkg_type, url): """ Returns URL of specified file type 'source', 'egg', or 'all' """ bad_stuff = ["?modtime", "#md5="] for junk in bad_stuff: if junk in url: url = url.split(junk)[0] break #pkg_spec==dev (svn) if url.endswith("-dev"): ...
[ "def", "filter_url", "(", "pkg_type", ",", "url", ")", ":", "bad_stuff", "=", "[", "\"?modtime\"", ",", "\"#md5=\"", "]", "for", "junk", "in", "bad_stuff", ":", "if", "junk", "in", "url", ":", "url", "=", "url", ".", "split", "(", "junk", ")", "[", ...
Returns URL of specified file type 'source', 'egg', or 'all'
[ "Returns", "URL", "of", "specified", "file", "type", "source", "egg", "or", "all" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L288-L314
cakebread/yolk
yolk/pypi.py
ProxyTransport.request
def request(self, host, handler, request_body, verbose): '''Send xml-rpc request using proxy''' #We get a traceback if we don't have this attribute: self.verbose = verbose url = 'http://' + host + handler request = urllib2.Request(url) request.add_data(request_body) ...
python
def request(self, host, handler, request_body, verbose): '''Send xml-rpc request using proxy''' #We get a traceback if we don't have this attribute: self.verbose = verbose url = 'http://' + host + handler request = urllib2.Request(url) request.add_data(request_body) ...
[ "def", "request", "(", "self", ",", "host", ",", "handler", ",", "request_body", ",", "verbose", ")", ":", "#We get a traceback if we don't have this attribute:", "self", ".", "verbose", "=", "verbose", "url", "=", "'http://'", "+", "host", "+", "handler", "requ...
Send xml-rpc request using proxy
[ "Send", "xml", "-", "rpc", "request", "using", "proxy" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L79-L92
cakebread/yolk
yolk/pypi.py
CheeseShop.get_cache
def get_cache(self): """ Get a package name list from disk cache or PyPI """ #This is used by external programs that import `CheeseShop` and don't #want a cache file written to ~/.pypi and query PyPI every time. if self.no_cache: self.pkg_list = self.list_pack...
python
def get_cache(self): """ Get a package name list from disk cache or PyPI """ #This is used by external programs that import `CheeseShop` and don't #want a cache file written to ~/.pypi and query PyPI every time. if self.no_cache: self.pkg_list = self.list_pack...
[ "def", "get_cache", "(", "self", ")", ":", "#This is used by external programs that import `CheeseShop` and don't", "#want a cache file written to ~/.pypi and query PyPI every time.", "if", "self", ".", "no_cache", ":", "self", ".", "pkg_list", "=", "self", ".", "list_packages"...
Get a package name list from disk cache or PyPI
[ "Get", "a", "package", "name", "list", "from", "disk", "cache", "or", "PyPI" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L138-L154
cakebread/yolk
yolk/pypi.py
CheeseShop.get_xmlrpc_server
def get_xmlrpc_server(self): """ Returns PyPI's XML-RPC server instance """ check_proxy_setting() if os.environ.has_key('XMLRPC_DEBUG'): debug = 1 else: debug = 0 try: return xmlrpclib.Server(XML_RPC_SERVER, transport=ProxyTrans...
python
def get_xmlrpc_server(self): """ Returns PyPI's XML-RPC server instance """ check_proxy_setting() if os.environ.has_key('XMLRPC_DEBUG'): debug = 1 else: debug = 0 try: return xmlrpclib.Server(XML_RPC_SERVER, transport=ProxyTrans...
[ "def", "get_xmlrpc_server", "(", "self", ")", ":", "check_proxy_setting", "(", ")", "if", "os", ".", "environ", ".", "has_key", "(", "'XMLRPC_DEBUG'", ")", ":", "debug", "=", "1", "else", ":", "debug", "=", "0", "try", ":", "return", "xmlrpclib", ".", ...
Returns PyPI's XML-RPC server instance
[ "Returns", "PyPI", "s", "XML", "-", "RPC", "server", "instance" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L162-L175
cakebread/yolk
yolk/pypi.py
CheeseShop.query_versions_pypi
def query_versions_pypi(self, package_name): """Fetch list of available versions for a package from The CheeseShop""" if not package_name in self.pkg_list: self.logger.debug("Package %s not in cache, querying PyPI..." \ % package_name) self.fetch_pkg_list() ...
python
def query_versions_pypi(self, package_name): """Fetch list of available versions for a package from The CheeseShop""" if not package_name in self.pkg_list: self.logger.debug("Package %s not in cache, querying PyPI..." \ % package_name) self.fetch_pkg_list() ...
[ "def", "query_versions_pypi", "(", "self", ",", "package_name", ")", ":", "if", "not", "package_name", "in", "self", ".", "pkg_list", ":", "self", ".", "logger", ".", "debug", "(", "\"Package %s not in cache, querying PyPI...\"", "%", "package_name", ")", "self", ...
Fetch list of available versions for a package from The CheeseShop
[ "Fetch", "list", "of", "available", "versions", "for", "a", "package", "from", "The", "CheeseShop" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L183-L200
cakebread/yolk
yolk/pypi.py
CheeseShop.query_cached_package_list
def query_cached_package_list(self): """Return list of pickled package names from PYPI""" if self.debug: self.logger.debug("DEBUG: reading pickled cache file") return cPickle.load(open(self.pkg_cache_file, "r"))
python
def query_cached_package_list(self): """Return list of pickled package names from PYPI""" if self.debug: self.logger.debug("DEBUG: reading pickled cache file") return cPickle.load(open(self.pkg_cache_file, "r"))
[ "def", "query_cached_package_list", "(", "self", ")", ":", "if", "self", ".", "debug", ":", "self", ".", "logger", ".", "debug", "(", "\"DEBUG: reading pickled cache file\"", ")", "return", "cPickle", ".", "load", "(", "open", "(", "self", ".", "pkg_cache_file...
Return list of pickled package names from PYPI
[ "Return", "list", "of", "pickled", "package", "names", "from", "PYPI" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L202-L206
cakebread/yolk
yolk/pypi.py
CheeseShop.fetch_pkg_list
def fetch_pkg_list(self): """Fetch and cache master list of package names from PYPI""" self.logger.debug("DEBUG: Fetching package name list from PyPI") package_list = self.list_packages() cPickle.dump(package_list, open(self.pkg_cache_file, "w")) self.pkg_list = package_list
python
def fetch_pkg_list(self): """Fetch and cache master list of package names from PYPI""" self.logger.debug("DEBUG: Fetching package name list from PyPI") package_list = self.list_packages() cPickle.dump(package_list, open(self.pkg_cache_file, "w")) self.pkg_list = package_list
[ "def", "fetch_pkg_list", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"DEBUG: Fetching package name list from PyPI\"", ")", "package_list", "=", "self", ".", "list_packages", "(", ")", "cPickle", ".", "dump", "(", "package_list", ",", "open...
Fetch and cache master list of package names from PYPI
[ "Fetch", "and", "cache", "master", "list", "of", "package", "names", "from", "PYPI" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L208-L213
cakebread/yolk
yolk/pypi.py
CheeseShop.search
def search(self, spec, operator): '''Query PYPI via XMLRPC interface using search spec''' return self.xmlrpc.search(spec, operator.lower())
python
def search(self, spec, operator): '''Query PYPI via XMLRPC interface using search spec''' return self.xmlrpc.search(spec, operator.lower())
[ "def", "search", "(", "self", ",", "spec", ",", "operator", ")", ":", "return", "self", ".", "xmlrpc", ".", "search", "(", "spec", ",", "operator", ".", "lower", "(", ")", ")" ]
Query PYPI via XMLRPC interface using search spec
[ "Query", "PYPI", "via", "XMLRPC", "interface", "using", "search", "spec" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L215-L217
cakebread/yolk
yolk/pypi.py
CheeseShop.release_data
def release_data(self, package_name, version): """Query PYPI via XMLRPC interface for a pkg's metadata""" try: return self.xmlrpc.release_data(package_name, version) except xmlrpclib.Fault: #XXX Raises xmlrpclib.Fault if you give non-existant version #Could th...
python
def release_data(self, package_name, version): """Query PYPI via XMLRPC interface for a pkg's metadata""" try: return self.xmlrpc.release_data(package_name, version) except xmlrpclib.Fault: #XXX Raises xmlrpclib.Fault if you give non-existant version #Could th...
[ "def", "release_data", "(", "self", ",", "package_name", ",", "version", ")", ":", "try", ":", "return", "self", ".", "xmlrpc", ".", "release_data", "(", "package_name", ",", "version", ")", "except", "xmlrpclib", ".", "Fault", ":", "#XXX Raises xmlrpclib.Faul...
Query PYPI via XMLRPC interface for a pkg's metadata
[ "Query", "PYPI", "via", "XMLRPC", "interface", "for", "a", "pkg", "s", "metadata" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L236-L243
cakebread/yolk
yolk/pypi.py
CheeseShop.package_releases
def package_releases(self, package_name): """Query PYPI via XMLRPC interface for a pkg's available versions""" if self.debug: self.logger.debug("DEBUG: querying PyPI for versions of " \ + package_name) return self.xmlrpc.package_releases(package_name)
python
def package_releases(self, package_name): """Query PYPI via XMLRPC interface for a pkg's available versions""" if self.debug: self.logger.debug("DEBUG: querying PyPI for versions of " \ + package_name) return self.xmlrpc.package_releases(package_name)
[ "def", "package_releases", "(", "self", ",", "package_name", ")", ":", "if", "self", ".", "debug", ":", "self", ".", "logger", ".", "debug", "(", "\"DEBUG: querying PyPI for versions of \"", "+", "package_name", ")", "return", "self", ".", "xmlrpc", ".", "pack...
Query PYPI via XMLRPC interface for a pkg's available versions
[ "Query", "PYPI", "via", "XMLRPC", "interface", "for", "a", "pkg", "s", "available", "versions" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L245-L250
cakebread/yolk
yolk/pypi.py
CheeseShop.get_download_urls
def get_download_urls(self, package_name, version="", pkg_type="all"): """Query PyPI for pkg download URI for a packge""" if version: versions = [version] else: #If they don't specify version, show em all. (package_name, versions) = self.query_versions_pypi...
python
def get_download_urls(self, package_name, version="", pkg_type="all"): """Query PyPI for pkg download URI for a packge""" if version: versions = [version] else: #If they don't specify version, show em all. (package_name, versions) = self.query_versions_pypi...
[ "def", "get_download_urls", "(", "self", ",", "package_name", ",", "version", "=", "\"\"", ",", "pkg_type", "=", "\"all\"", ")", ":", "if", "version", ":", "versions", "=", "[", "version", "]", "else", ":", "#If they don't specify version, show em all.", "(", ...
Query PyPI for pkg download URI for a packge
[ "Query", "PyPI", "for", "pkg", "download", "URI", "for", "a", "packge" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/pypi.py#L252-L286
pyslackers/slack-sansio
slack/events.py
Event.clone
def clone(self) -> "Event": """ Clone the event Returns: :class:`slack.events.Event` """ return self.__class__(copy.deepcopy(self.event), copy.deepcopy(self.metadata))
python
def clone(self) -> "Event": """ Clone the event Returns: :class:`slack.events.Event` """ return self.__class__(copy.deepcopy(self.event), copy.deepcopy(self.metadata))
[ "def", "clone", "(", "self", ")", "->", "\"Event\"", ":", "return", "self", ".", "__class__", "(", "copy", ".", "deepcopy", "(", "self", ".", "event", ")", ",", "copy", ".", "deepcopy", "(", "self", ".", "metadata", ")", ")" ]
Clone the event Returns: :class:`slack.events.Event`
[ "Clone", "the", "event" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L48-L56
pyslackers/slack-sansio
slack/events.py
Event.from_rtm
def from_rtm(cls, raw_event: MutableMapping) -> "Event": """ Create an event with data coming from the RTM API. If the event type is a message a :class:`slack.events.Message` is returned. Args: raw_event: JSON decoded data from the RTM API Returns: :cla...
python
def from_rtm(cls, raw_event: MutableMapping) -> "Event": """ Create an event with data coming from the RTM API. If the event type is a message a :class:`slack.events.Message` is returned. Args: raw_event: JSON decoded data from the RTM API Returns: :cla...
[ "def", "from_rtm", "(", "cls", ",", "raw_event", ":", "MutableMapping", ")", "->", "\"Event\"", ":", "if", "raw_event", "[", "\"type\"", "]", ".", "startswith", "(", "\"message\"", ")", ":", "return", "Message", "(", "raw_event", ")", "else", ":", "return"...
Create an event with data coming from the RTM API. If the event type is a message a :class:`slack.events.Message` is returned. Args: raw_event: JSON decoded data from the RTM API Returns: :class:`slack.events.Event` or :class:`slack.events.Message`
[ "Create", "an", "event", "with", "data", "coming", "from", "the", "RTM", "API", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L59-L74
pyslackers/slack-sansio
slack/events.py
Event.from_http
def from_http( cls, raw_body: MutableMapping, verification_token: Optional[str] = None, team_id: Optional[str] = None, ) -> "Event": """ Create an event with data coming from the HTTP Event API. If the event type is a message a :class:`slack.events.Message` i...
python
def from_http( cls, raw_body: MutableMapping, verification_token: Optional[str] = None, team_id: Optional[str] = None, ) -> "Event": """ Create an event with data coming from the HTTP Event API. If the event type is a message a :class:`slack.events.Message` i...
[ "def", "from_http", "(", "cls", ",", "raw_body", ":", "MutableMapping", ",", "verification_token", ":", "Optional", "[", "str", "]", "=", "None", ",", "team_id", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", "\"Event\"", ":", "if", "ve...
Create an event with data coming from the HTTP Event API. If the event type is a message a :class:`slack.events.Message` is returned. Args: raw_body: Decoded body of the Event API request verification_token: Slack verification token used to verify the request came from slack ...
[ "Create", "an", "event", "with", "data", "coming", "from", "the", "HTTP", "Event", "API", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L77-L109
pyslackers/slack-sansio
slack/events.py
Message.response
def response(self, in_thread: Optional[bool] = None) -> "Message": """ Create a response message. Depending on the incoming message the response can be in a thread. By default the response follow where the incoming message was posted. Args: in_thread (boolean): Over...
python
def response(self, in_thread: Optional[bool] = None) -> "Message": """ Create a response message. Depending on the incoming message the response can be in a thread. By default the response follow where the incoming message was posted. Args: in_thread (boolean): Over...
[ "def", "response", "(", "self", ",", "in_thread", ":", "Optional", "[", "bool", "]", "=", "None", ")", "->", "\"Message\"", ":", "data", "=", "{", "\"channel\"", ":", "self", "[", "\"channel\"", "]", "}", "if", "in_thread", ":", "if", "\"message\"", "i...
Create a response message. Depending on the incoming message the response can be in a thread. By default the response follow where the incoming message was posted. Args: in_thread (boolean): Overwrite the `threading` behaviour Returns: a new :class:`slack.even...
[ "Create", "a", "response", "message", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L129-L157
pyslackers/slack-sansio
slack/events.py
Message.serialize
def serialize(self) -> dict: """ Serialize the message for sending to slack API Returns: serialized message """ data = {**self} if "attachments" in self: data["attachments"] = json.dumps(self["attachments"]) return data
python
def serialize(self) -> dict: """ Serialize the message for sending to slack API Returns: serialized message """ data = {**self} if "attachments" in self: data["attachments"] = json.dumps(self["attachments"]) return data
[ "def", "serialize", "(", "self", ")", "->", "dict", ":", "data", "=", "{", "*", "*", "self", "}", "if", "\"attachments\"", "in", "self", ":", "data", "[", "\"attachments\"", "]", "=", "json", ".", "dumps", "(", "self", "[", "\"attachments\"", "]", ")...
Serialize the message for sending to slack API Returns: serialized message
[ "Serialize", "the", "message", "for", "sending", "to", "slack", "API" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L159-L169
pyslackers/slack-sansio
slack/events.py
EventRouter.register
def register(self, event_type: str, handler: Any, **detail: Any) -> None: """ Register a new handler for a specific :class:`slack.events.Event` `type` (See `slack event types documentation <https://api.slack.com/events>`_ for a list of event types). The arbitrary keyword argument is use...
python
def register(self, event_type: str, handler: Any, **detail: Any) -> None: """ Register a new handler for a specific :class:`slack.events.Event` `type` (See `slack event types documentation <https://api.slack.com/events>`_ for a list of event types). The arbitrary keyword argument is use...
[ "def", "register", "(", "self", ",", "event_type", ":", "str", ",", "handler", ":", "Any", ",", "*", "*", "detail", ":", "Any", ")", "->", "None", ":", "LOG", ".", "info", "(", "\"Registering %s, %s to %s\"", ",", "event_type", ",", "detail", ",", "han...
Register a new handler for a specific :class:`slack.events.Event` `type` (See `slack event types documentation <https://api.slack.com/events>`_ for a list of event types). The arbitrary keyword argument is used as a key/value pair to compare against what is in the incoming :class:`slack.events....
[ "Register", "a", "new", "handler", "for", "a", "specific", ":", "class", ":", "slack", ".", "events", ".", "Event", "type", "(", "See", "slack", "event", "types", "documentation", "<https", ":", "//", "api", ".", "slack", ".", "com", "/", "events", ">"...
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L185-L212
pyslackers/slack-sansio
slack/events.py
EventRouter.dispatch
def dispatch(self, event: Event) -> Iterator[Any]: """ Yields handlers matching the routing of the incoming :class:`slack.events.Event`. Args: event: :class:`slack.events.Event` Yields: handler """ LOG.debug('Dispatching event "%s"', event.get("t...
python
def dispatch(self, event: Event) -> Iterator[Any]: """ Yields handlers matching the routing of the incoming :class:`slack.events.Event`. Args: event: :class:`slack.events.Event` Yields: handler """ LOG.debug('Dispatching event "%s"', event.get("t...
[ "def", "dispatch", "(", "self", ",", "event", ":", "Event", ")", "->", "Iterator", "[", "Any", "]", ":", "LOG", ".", "debug", "(", "'Dispatching event \"%s\"'", ",", "event", ".", "get", "(", "\"type\"", ")", ")", "if", "event", "[", "\"type\"", "]", ...
Yields handlers matching the routing of the incoming :class:`slack.events.Event`. Args: event: :class:`slack.events.Event` Yields: handler
[ "Yields", "handlers", "matching", "the", "routing", "of", "the", "incoming", ":", "class", ":", "slack", ".", "events", ".", "Event", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L214-L232
pyslackers/slack-sansio
slack/events.py
MessageRouter.register
def register( self, pattern: str, handler: Any, flags: int = 0, channel: str = "*", subtype: Optional[str] = None, ) -> None: """ Register a new handler for a specific :class:`slack.events.Message`. The routing is based on regex pattern matchi...
python
def register( self, pattern: str, handler: Any, flags: int = 0, channel: str = "*", subtype: Optional[str] = None, ) -> None: """ Register a new handler for a specific :class:`slack.events.Message`. The routing is based on regex pattern matchi...
[ "def", "register", "(", "self", ",", "pattern", ":", "str", ",", "handler", ":", "Any", ",", "flags", ":", "int", "=", "0", ",", "channel", ":", "str", "=", "\"*\"", ",", "subtype", ":", "Optional", "[", "str", "]", "=", "None", ",", ")", "->", ...
Register a new handler for a specific :class:`slack.events.Message`. The routing is based on regex pattern matching the message text and the incoming slack channel. Args: pattern: Regex pattern matching the message text. handler: Callback flags: Regex flags. ...
[ "Register", "a", "new", "handler", "for", "a", "specific", ":", "class", ":", "slack", ".", "events", ".", "Message", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L247-L276
pyslackers/slack-sansio
slack/events.py
MessageRouter.dispatch
def dispatch(self, message: Message) -> Iterator[Any]: """ Yields handlers matching the routing of the incoming :class:`slack.events.Message` Args: message: :class:`slack.events.Message` Yields: handler """ if "text" in message: text ...
python
def dispatch(self, message: Message) -> Iterator[Any]: """ Yields handlers matching the routing of the incoming :class:`slack.events.Message` Args: message: :class:`slack.events.Message` Yields: handler """ if "text" in message: text ...
[ "def", "dispatch", "(", "self", ",", "message", ":", "Message", ")", "->", "Iterator", "[", "Any", "]", ":", "if", "\"text\"", "in", "message", ":", "text", "=", "message", "[", "\"text\"", "]", "or", "\"\"", "elif", "\"message\"", "in", "message", ":"...
Yields handlers matching the routing of the incoming :class:`slack.events.Message` Args: message: :class:`slack.events.Message` Yields: handler
[ "Yields", "handlers", "matching", "the", "routing", "of", "the", "incoming", ":", "class", ":", "slack", ".", "events", ".", "Message" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/events.py#L278-L303
pyslackers/slack-sansio
slack/io/requests.py
SlackAPI.query
def query( # type: ignore self, url: Union[str, methods], data: Optional[MutableMapping] = None, headers: Optional[MutableMapping] = None, as_json: Optional[bool] = None, ) -> dict: """ Query the slack API When using :class:`slack.methods` the reques...
python
def query( # type: ignore self, url: Union[str, methods], data: Optional[MutableMapping] = None, headers: Optional[MutableMapping] = None, as_json: Optional[bool] = None, ) -> dict: """ Query the slack API When using :class:`slack.methods` the reques...
[ "def", "query", "(", "# type: ignore", "self", ",", "url", ":", "Union", "[", "str", ",", "methods", "]", ",", "data", ":", "Optional", "[", "MutableMapping", "]", "=", "None", ",", "headers", ":", "Optional", "[", "MutableMapping", "]", "=", "None", "...
Query the slack API When using :class:`slack.methods` the request is made `as_json` if available Args: url: :class:`slack.methods` or url string data: JSON encodable MutableMapping headers: Custom headers as_json: Post JSON to the slack API Retur...
[ "Query", "the", "slack", "API" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/io/requests.py#L65-L93
pyslackers/slack-sansio
slack/io/requests.py
SlackAPI.rtm
def rtm( # type: ignore self, url: Optional[str] = None, bot_id: Optional[str] = None ) -> Iterator[events.Event]: """ Iterate over event from the RTM API Args: url: Websocket connection url bot_id: Connecting bot ID Returns: :class:`sla...
python
def rtm( # type: ignore self, url: Optional[str] = None, bot_id: Optional[str] = None ) -> Iterator[events.Event]: """ Iterate over event from the RTM API Args: url: Websocket connection url bot_id: Connecting bot ID Returns: :class:`sla...
[ "def", "rtm", "(", "# type: ignore", "self", ",", "url", ":", "Optional", "[", "str", "]", "=", "None", ",", "bot_id", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Iterator", "[", "events", ".", "Event", "]", ":", "while", "True", ":"...
Iterate over event from the RTM API Args: url: Websocket connection url bot_id: Connecting bot ID Returns: :class:`slack.events.Event` or :class:`slack.events.Message`
[ "Iterate", "over", "event", "from", "the", "RTM", "API" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/io/requests.py#L159-L178
brutasse/django-ratelimit-backend
ratelimitbackend/admin.py
RateLimitAdminSite.login
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ context = { 'title': _('Log in'), 'app_path': request.get_full_path(), } if (REDIRECT_FIELD_NAME not in request.GET and REDIREC...
python
def login(self, request, extra_context=None): """ Displays the login form for the given HttpRequest. """ context = { 'title': _('Log in'), 'app_path': request.get_full_path(), } if (REDIRECT_FIELD_NAME not in request.GET and REDIREC...
[ "def", "login", "(", "self", ",", "request", ",", "extra_context", "=", "None", ")", ":", "context", "=", "{", "'title'", ":", "_", "(", "'Log in'", ")", ",", "'app_path'", ":", "request", ".", "get_full_path", "(", ")", ",", "}", "if", "(", "REDIREC...
Displays the login form for the given HttpRequest.
[ "Displays", "the", "login", "form", "for", "the", "given", "HttpRequest", "." ]
train
https://github.com/brutasse/django-ratelimit-backend/blob/1f8f485c139eb8067f0d821ff77df98038ab9448/ratelimitbackend/admin.py#L13-L31
crccheck/cloudwatch-to-graphite
leadbutt.py
get_config
def get_config(config_file): """Get configuration from a file.""" def load(fp): try: return yaml.safe_load(fp) except yaml.YAMLError as e: sys.stderr.write(text_type(e)) sys.exit(1) # TODO document exit codes if config_file == '-': return load(sy...
python
def get_config(config_file): """Get configuration from a file.""" def load(fp): try: return yaml.safe_load(fp) except yaml.YAMLError as e: sys.stderr.write(text_type(e)) sys.exit(1) # TODO document exit codes if config_file == '-': return load(sy...
[ "def", "get_config", "(", "config_file", ")", ":", "def", "load", "(", "fp", ")", ":", "try", ":", "return", "yaml", ".", "safe_load", "(", "fp", ")", "except", "yaml", ".", "YAMLError", "as", "e", ":", "sys", ".", "stderr", ".", "write", "(", "tex...
Get configuration from a file.
[ "Get", "configuration", "from", "a", "file", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/leadbutt.py#L51-L67
crccheck/cloudwatch-to-graphite
leadbutt.py
get_options
def get_options(config_options, local_options, cli_options): """ Figure out what options to use based on the four places it can come from. Order of precedence: * cli_options specified by the user at the command line * local_options specified in the config file for the metric * config_op...
python
def get_options(config_options, local_options, cli_options): """ Figure out what options to use based on the four places it can come from. Order of precedence: * cli_options specified by the user at the command line * local_options specified in the config file for the metric * config_op...
[ "def", "get_options", "(", "config_options", ",", "local_options", ",", "cli_options", ")", ":", "options", "=", "DEFAULT_OPTIONS", ".", "copy", "(", ")", "if", "config_options", "is", "not", "None", ":", "options", ".", "update", "(", "config_options", ")", ...
Figure out what options to use based on the four places it can come from. Order of precedence: * cli_options specified by the user at the command line * local_options specified in the config file for the metric * config_options specified in the config file at the base * DEFAULT_OPTIONS h...
[ "Figure", "out", "what", "options", "to", "use", "based", "on", "the", "four", "places", "it", "can", "come", "from", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/leadbutt.py#L70-L87
crccheck/cloudwatch-to-graphite
leadbutt.py
output_results
def output_results(results, metric, options): """ Output the results to stdout. TODO: add AMPQ support for efficiency """ formatter = options['Formatter'] context = metric.copy() # XXX might need to sanitize this try: context['dimension'] = list(metric['Dimensions'].values())[0] ...
python
def output_results(results, metric, options): """ Output the results to stdout. TODO: add AMPQ support for efficiency """ formatter = options['Formatter'] context = metric.copy() # XXX might need to sanitize this try: context['dimension'] = list(metric['Dimensions'].values())[0] ...
[ "def", "output_results", "(", "results", ",", "metric", ",", "options", ")", ":", "formatter", "=", "options", "[", "'Formatter'", "]", "context", "=", "metric", ".", "copy", "(", ")", "# XXX might need to sanitize this", "try", ":", "context", "[", "'dimensio...
Output the results to stdout. TODO: add AMPQ support for efficiency
[ "Output", "the", "results", "to", "stdout", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/leadbutt.py#L90-L117
hammerlab/cohorts
cohorts/io/gcloud_storage.py
GoogleStorageIO.download_to_path
def download_to_path(self, gsuri, localpath, binary_mode=False, tmpdir=None): """ This method is analogous to "gsutil cp gsuri localpath", but in a programatically accesible way. The only difference is that we have to make a guess about the encoding of the file to not upset downs...
python
def download_to_path(self, gsuri, localpath, binary_mode=False, tmpdir=None): """ This method is analogous to "gsutil cp gsuri localpath", but in a programatically accesible way. The only difference is that we have to make a guess about the encoding of the file to not upset downs...
[ "def", "download_to_path", "(", "self", ",", "gsuri", ",", "localpath", ",", "binary_mode", "=", "False", ",", "tmpdir", "=", "None", ")", ":", "bucket_name", ",", "gs_rel_path", "=", "self", ".", "parse_uri", "(", "gsuri", ")", "# And now request the handles ...
This method is analogous to "gsutil cp gsuri localpath", but in a programatically accesible way. The only difference is that we have to make a guess about the encoding of the file to not upset downstream file operations. If you are downloading a VCF, then "False" is great. If this is a B...
[ "This", "method", "is", "analogous", "to", "gsutil", "cp", "gsuri", "localpath", "but", "in", "a", "programatically", "accesible", "way", ".", "The", "only", "difference", "is", "that", "we", "have", "to", "make", "a", "guess", "about", "the", "encoding", ...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/io/gcloud_storage.py#L97-L136
hammerlab/cohorts
cohorts/rounding.py
round_float
def round_float(f, digits, rounding=ROUND_HALF_UP): """ Accurate float rounding from http://stackoverflow.com/a/15398691. """ return Decimal(str(f)).quantize(Decimal(10) ** (-1 * digits), rounding=rounding)
python
def round_float(f, digits, rounding=ROUND_HALF_UP): """ Accurate float rounding from http://stackoverflow.com/a/15398691. """ return Decimal(str(f)).quantize(Decimal(10) ** (-1 * digits), rounding=rounding)
[ "def", "round_float", "(", "f", ",", "digits", ",", "rounding", "=", "ROUND_HALF_UP", ")", ":", "return", "Decimal", "(", "str", "(", "f", ")", ")", ".", "quantize", "(", "Decimal", "(", "10", ")", "**", "(", "-", "1", "*", "digits", ")", ",", "r...
Accurate float rounding from http://stackoverflow.com/a/15398691.
[ "Accurate", "float", "rounding", "from", "http", ":", "//", "stackoverflow", ".", "com", "/", "a", "/", "15398691", "." ]
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/rounding.py#L17-L22
hammerlab/cohorts
cohorts/rounding.py
float_str
def float_str(f, min_digits=2, max_digits=6): """ Returns a string representing a float, where the number of significant digits is min_digits unless it takes more digits to hit a non-zero digit (and the number is 0 < x < 1). We stop looking for a non-zero digit after max_digits. """ if f >= ...
python
def float_str(f, min_digits=2, max_digits=6): """ Returns a string representing a float, where the number of significant digits is min_digits unless it takes more digits to hit a non-zero digit (and the number is 0 < x < 1). We stop looking for a non-zero digit after max_digits. """ if f >= ...
[ "def", "float_str", "(", "f", ",", "min_digits", "=", "2", ",", "max_digits", "=", "6", ")", ":", "if", "f", ">=", "1", "or", "f", "<=", "0", ":", "return", "str", "(", "round_float", "(", "f", ",", "min_digits", ")", ")", "start_str", "=", "str"...
Returns a string representing a float, where the number of significant digits is min_digits unless it takes more digits to hit a non-zero digit (and the number is 0 < x < 1). We stop looking for a non-zero digit after max_digits.
[ "Returns", "a", "string", "representing", "a", "float", "where", "the", "number", "of", "significant", "digits", "is", "min_digits", "unless", "it", "takes", "more", "digits", "to", "hit", "a", "non", "-", "zero", "digit", "(", "and", "the", "number", "is"...
train
https://github.com/hammerlab/cohorts/blob/278b05e609e6c4d4a77c57d49446460be53ea33e/cohorts/rounding.py#L24-L46
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.default_format
def default_format(self): """ Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string. """ user = self.user if user.first_name is not None: return self.full_n...
python
def default_format(self): """ Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string. """ user = self.user if user.first_name is not None: return self.full_n...
[ "def", "default_format", "(", "self", ")", ":", "user", "=", "self", ".", "user", "if", "user", ".", "first_name", "is", "not", "None", ":", "return", "self", ".", "full_name", "elif", "user", ".", "username", "is", "not", "None", ":", "return", "user"...
Returns full name (first and last) if name is available. If not, returns username if available. If not available too, returns the user id as a string.
[ "Returns", "full", "name", "(", "first", "and", "last", ")", "if", "name", "is", "available", ".", "If", "not", "returns", "username", "if", "available", ".", "If", "not", "available", "too", "returns", "the", "user", "id", "as", "a", "string", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L31-L43
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.full_name
def full_name(self): """ Returns the first and last name of the user separated by a space. """ formatted_user = [] if self.user.first_name is not None: formatted_user.append(self.user.first_name) if self.user.last_name is not None: formatted_user.a...
python
def full_name(self): """ Returns the first and last name of the user separated by a space. """ formatted_user = [] if self.user.first_name is not None: formatted_user.append(self.user.first_name) if self.user.last_name is not None: formatted_user.a...
[ "def", "full_name", "(", "self", ")", ":", "formatted_user", "=", "[", "]", "if", "self", ".", "user", ".", "first_name", "is", "not", "None", ":", "formatted_user", ".", "append", "(", "self", ".", "user", ".", "first_name", ")", "if", "self", ".", ...
Returns the first and last name of the user separated by a space.
[ "Returns", "the", "first", "and", "last", "name", "of", "the", "user", "separated", "by", "a", "space", "." ]
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L46-L55
alvarogzp/telegram-bot-framework
bot/action/util/format.py
UserFormatter.full_format
def full_format(self): """ Returns the full name (first and last parts), and the username between brackets if the user has it. If there is no info about the user, returns the user id between < and >. """ formatted_user = self.full_name if self.user.username is not None: ...
python
def full_format(self): """ Returns the full name (first and last parts), and the username between brackets if the user has it. If there is no info about the user, returns the user id between < and >. """ formatted_user = self.full_name if self.user.username is not None: ...
[ "def", "full_format", "(", "self", ")", ":", "formatted_user", "=", "self", ".", "full_name", "if", "self", ".", "user", ".", "username", "is", "not", "None", ":", "formatted_user", "+=", "\" [\"", "+", "self", ".", "user", ".", "username", "+", "\"]\"",...
Returns the full name (first and last parts), and the username between brackets if the user has it. If there is no info about the user, returns the user id between < and >.
[ "Returns", "the", "full", "name", "(", "first", "and", "last", "parts", ")", "and", "the", "username", "between", "brackets", "if", "the", "user", "has", "it", ".", "If", "there", "is", "no", "info", "about", "the", "user", "returns", "the", "user", "i...
train
https://github.com/alvarogzp/telegram-bot-framework/blob/7b597a415c1901901c677976cb13100fc3083107/bot/action/util/format.py#L66-L76