partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | SubtitleDecrypter._build_hash_secret | Build a seed for the hash based on the Fibonacci sequence
Take first `seq_len` + len(`seq_seed`) characters of Fibonacci
sequence, starting with `seq_seed`, and applying e % `mod_value` +
`HASH_SECRET_CHAR_OFFSET` to the resulting sequence, then return as
a string
@param tuple|... | crunchyroll/subtitles.py | def _build_hash_secret(self, seq_seed, seq_len=HASH_SECRET_LENGTH,
mod_value=HASH_SECRET_MOD_CONST):
"""Build a seed for the hash based on the Fibonacci sequence
Take first `seq_len` + len(`seq_seed`) characters of Fibonacci
sequence, starting with `seq_seed`, and applying e % `mod_... | def _build_hash_secret(self, seq_seed, seq_len=HASH_SECRET_LENGTH,
mod_value=HASH_SECRET_MOD_CONST):
"""Build a seed for the hash based on the Fibonacci sequence
Take first `seq_len` + len(`seq_seed`) characters of Fibonacci
sequence, starting with `seq_seed`, and applying e % `mod_... | [
"Build",
"a",
"seed",
"for",
"the",
"hash",
"based",
"on",
"the",
"Fibonacci",
"sequence"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L106-L128 | [
"def",
"_build_hash_secret",
"(",
"self",
",",
"seq_seed",
",",
"seq_len",
"=",
"HASH_SECRET_LENGTH",
",",
"mod_value",
"=",
"HASH_SECRET_MOD_CONST",
")",
":",
"# make sure we use a list, tuples are immutable",
"fbn_seq",
"=",
"list",
"(",
"seq_seed",
")",
"for",
"i",... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | SubtitleFormatter.format | Turn a string containing the subs xml document into the formatted
subtitle string
@param str|crunchyroll.models.StyledSubtitle sub_xml_text
@return str | crunchyroll/subtitles.py | def format(self, subtitles):
"""Turn a string containing the subs xml document into the formatted
subtitle string
@param str|crunchyroll.models.StyledSubtitle sub_xml_text
@return str
"""
logger.debug('Formatting subtitles (id=%s) with %s',
subtitles.id, self... | def format(self, subtitles):
"""Turn a string containing the subs xml document into the formatted
subtitle string
@param str|crunchyroll.models.StyledSubtitle sub_xml_text
@return str
"""
logger.debug('Formatting subtitles (id=%s) with %s',
subtitles.id, self... | [
"Turn",
"a",
"string",
"containing",
"the",
"subs",
"xml",
"document",
"into",
"the",
"formatted",
"subtitle",
"string"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L134-L143 | [
"def",
"format",
"(",
"self",
",",
"subtitles",
")",
":",
"logger",
".",
"debug",
"(",
"'Formatting subtitles (id=%s) with %s'",
",",
"subtitles",
".",
"id",
",",
"self",
".",
"__class__",
".",
"__name__",
")",
"return",
"self",
".",
"_format",
"(",
"subtitl... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | require_session_started | Check if API sessions are started and start them if not | crunchyroll/apis/meta.py | def require_session_started(func):
"""Check if API sessions are started and start them if not
"""
@functools.wraps(func)
def inner_func(self, *pargs, **kwargs):
if not self.session_started:
logger.info('Starting session for required meta method')
self.start_session()
... | def require_session_started(func):
"""Check if API sessions are started and start them if not
"""
@functools.wraps(func)
def inner_func(self, *pargs, **kwargs):
if not self.session_started:
logger.info('Starting session for required meta method')
self.start_session()
... | [
"Check",
"if",
"API",
"sessions",
"are",
"started",
"and",
"start",
"them",
"if",
"not"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L35-L44 | [
"def",
"require_session_started",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"inner_func",
"(",
"self",
",",
"*",
"pargs",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"session_started",
":",
"logger... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | require_android_logged_in | Check if andoid API is logged in and login if not, implies
`require_session_started` | crunchyroll/apis/meta.py | def require_android_logged_in(func):
"""Check if andoid API is logged in and login if not, implies
`require_session_started`
"""
@functools.wraps(func)
@require_session_started
def inner_func(self, *pargs, **kwargs):
if not self._android_api.logged_in:
logger.info('Logging in... | def require_android_logged_in(func):
"""Check if andoid API is logged in and login if not, implies
`require_session_started`
"""
@functools.wraps(func)
@require_session_started
def inner_func(self, *pargs, **kwargs):
if not self._android_api.logged_in:
logger.info('Logging in... | [
"Check",
"if",
"andoid",
"API",
"is",
"logged",
"in",
"and",
"login",
"if",
"not",
"implies",
"require_session_started"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L46-L61 | [
"def",
"require_android_logged_in",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"@",
"require_session_started",
"def",
"inner_func",
"(",
"self",
",",
"*",
"pargs",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | optional_manga_logged_in | Check if andoid manga API is logged in and login if credentials were provided,
implies `require_session_started` | crunchyroll/apis/meta.py | def optional_manga_logged_in(func):
"""Check if andoid manga API is logged in and login if credentials were provided,
implies `require_session_started`
"""
@functools.wraps(func)
@require_session_started
def inner_func(self, *pargs, **kwargs):
if not self._manga_api.logged_in and self.ha... | def optional_manga_logged_in(func):
"""Check if andoid manga API is logged in and login if credentials were provided,
implies `require_session_started`
"""
@functools.wraps(func)
@require_session_started
def inner_func(self, *pargs, **kwargs):
if not self._manga_api.logged_in and self.ha... | [
"Check",
"if",
"andoid",
"manga",
"API",
"is",
"logged",
"in",
"and",
"login",
"if",
"credentials",
"were",
"provided",
"implies",
"require_session_started"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L77-L89 | [
"def",
"optional_manga_logged_in",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"@",
"require_session_started",
"def",
"inner_func",
"(",
"self",
",",
"*",
"pargs",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | require_ajax_logged_in | Check if ajax API is logged in and login if not | crunchyroll/apis/meta.py | def require_ajax_logged_in(func):
"""Check if ajax API is logged in and login if not
"""
@functools.wraps(func)
def inner_func(self, *pargs, **kwargs):
if not self._ajax_api.logged_in:
logger.info('Logging into AJAX API for required meta method')
if not self.has_credentia... | def require_ajax_logged_in(func):
"""Check if ajax API is logged in and login if not
"""
@functools.wraps(func)
def inner_func(self, *pargs, **kwargs):
if not self._ajax_api.logged_in:
logger.info('Logging into AJAX API for required meta method')
if not self.has_credentia... | [
"Check",
"if",
"ajax",
"API",
"is",
"logged",
"in",
"and",
"login",
"if",
"not"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L91-L104 | [
"def",
"require_ajax_logged_in",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"inner_func",
"(",
"self",
",",
"*",
"pargs",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"_ajax_api",
".",
"logged_in",
... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.start_session | Start the underlying APIs sessions
Calling this is not required, it will be called automatically if
a method that needs a session is called
@return bool | crunchyroll/apis/meta.py | def start_session(self):
"""Start the underlying APIs sessions
Calling this is not required, it will be called automatically if
a method that needs a session is called
@return bool
"""
self._android_api.start_session()
self._manga_api.cr_start_session()
... | def start_session(self):
"""Start the underlying APIs sessions
Calling this is not required, it will be called automatically if
a method that needs a session is called
@return bool
"""
self._android_api.start_session()
self._manga_api.cr_start_session()
... | [
"Start",
"the",
"underlying",
"APIs",
"sessions"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L174-L184 | [
"def",
"start_session",
"(",
"self",
")",
":",
"self",
".",
"_android_api",
".",
"start_session",
"(",
")",
"self",
".",
"_manga_api",
".",
"cr_start_session",
"(",
")",
"return",
"self",
".",
"session_started"
] | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.login | Login with the given username/email and password
Calling this method is not required if credentials were provided in
the constructor, but it could be used to switch users or something maybe
@return bool | crunchyroll/apis/meta.py | def login(self, username, password):
"""Login with the given username/email and password
Calling this method is not required if credentials were provided in
the constructor, but it could be used to switch users or something maybe
@return bool
"""
# we could get stuck in... | def login(self, username, password):
"""Login with the given username/email and password
Calling this method is not required if credentials were provided in
the constructor, but it could be used to switch users or something maybe
@return bool
"""
# we could get stuck in... | [
"Login",
"with",
"the",
"given",
"username",
"/",
"email",
"and",
"password"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L187-L209 | [
"def",
"login",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"# we could get stuck in an inconsistent state if got an exception while",
"# trying to login with different credentials than what is stored so",
"# we rollback the state to prevent that",
"state_snapshot",
"=",
"... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.list_anime_series | Get a list of anime series
@param str sort pick how results should be sorted, should be one
of META.SORT_*
@param int limit limit number of series to return, there doesn't
seem to be an upper bound
@param int offset list s... | crunchyroll/apis/meta.py | def list_anime_series(self, sort=META.SORT_ALPHA, limit=META.MAX_SERIES, offset=0):
"""Get a list of anime series
@param str sort pick how results should be sorted, should be one
of META.SORT_*
@param int limit limit number of series to return, there doesn... | def list_anime_series(self, sort=META.SORT_ALPHA, limit=META.MAX_SERIES, offset=0):
"""Get a list of anime series
@param str sort pick how results should be sorted, should be one
of META.SORT_*
@param int limit limit number of series to return, there doesn... | [
"Get",
"a",
"list",
"of",
"anime",
"series"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L213-L228 | [
"def",
"list_anime_series",
"(",
"self",
",",
"sort",
"=",
"META",
".",
"SORT_ALPHA",
",",
"limit",
"=",
"META",
".",
"MAX_SERIES",
",",
"offset",
"=",
"0",
")",
":",
"result",
"=",
"self",
".",
"_android_api",
".",
"list_series",
"(",
"media_type",
"=",... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.list_drama_series | Get a list of drama series
@param str sort pick how results should be sorted, should be one
of META.SORT_*
@param int limit limit number of series to return, there doesn't
seem to be an upper bound
@param int offset list s... | crunchyroll/apis/meta.py | def list_drama_series(self, sort=META.SORT_ALPHA, limit=META.MAX_SERIES, offset=0):
"""Get a list of drama series
@param str sort pick how results should be sorted, should be one
of META.SORT_*
@param int limit limit number of series to return, there doesn... | def list_drama_series(self, sort=META.SORT_ALPHA, limit=META.MAX_SERIES, offset=0):
"""Get a list of drama series
@param str sort pick how results should be sorted, should be one
of META.SORT_*
@param int limit limit number of series to return, there doesn... | [
"Get",
"a",
"list",
"of",
"drama",
"series"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L232-L247 | [
"def",
"list_drama_series",
"(",
"self",
",",
"sort",
"=",
"META",
".",
"SORT_ALPHA",
",",
"limit",
"=",
"META",
".",
"MAX_SERIES",
",",
"offset",
"=",
"0",
")",
":",
"result",
"=",
"self",
".",
"_android_api",
".",
"list_series",
"(",
"media_type",
"=",... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.list_manga_series | Get a list of manga series | crunchyroll/apis/meta.py | def list_manga_series(self, filter=None, content_type='jp_manga'):
"""Get a list of manga series
"""
result = self._manga_api.list_series(filter, content_type)
return result | def list_manga_series(self, filter=None, content_type='jp_manga'):
"""Get a list of manga series
"""
result = self._manga_api.list_series(filter, content_type)
return result | [
"Get",
"a",
"list",
"of",
"manga",
"series"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L251-L256 | [
"def",
"list_manga_series",
"(",
"self",
",",
"filter",
"=",
"None",
",",
"content_type",
"=",
"'jp_manga'",
")",
":",
"result",
"=",
"self",
".",
"_manga_api",
".",
"list_series",
"(",
"filter",
",",
"content_type",
")",
"return",
"result"
] | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.search_anime_series | Search anime series list by series name, case-sensitive
@param str query_string string to search for, note that the search
is very simplistic and only matches against
the start of the series name, ex) search
... | crunchyroll/apis/meta.py | def search_anime_series(self, query_string):
"""Search anime series list by series name, case-sensitive
@param str query_string string to search for, note that the search
is very simplistic and only matches against
the ... | def search_anime_series(self, query_string):
"""Search anime series list by series name, case-sensitive
@param str query_string string to search for, note that the search
is very simplistic and only matches against
the ... | [
"Search",
"anime",
"series",
"list",
"by",
"series",
"name",
"case",
"-",
"sensitive"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L260-L273 | [
"def",
"search_anime_series",
"(",
"self",
",",
"query_string",
")",
":",
"result",
"=",
"self",
".",
"_android_api",
".",
"list_series",
"(",
"media_type",
"=",
"ANDROID",
".",
"MEDIA_TYPE_ANIME",
",",
"filter",
"=",
"ANDROID",
".",
"FILTER_PREFIX",
"+",
"que... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.search_drama_series | Search drama series list by series name, case-sensitive
@param str query_string string to search for, note that the search
is very simplistic and only matches against
the start of the series name, ex) search
... | crunchyroll/apis/meta.py | def search_drama_series(self, query_string):
"""Search drama series list by series name, case-sensitive
@param str query_string string to search for, note that the search
is very simplistic and only matches against
the ... | def search_drama_series(self, query_string):
"""Search drama series list by series name, case-sensitive
@param str query_string string to search for, note that the search
is very simplistic and only matches against
the ... | [
"Search",
"drama",
"series",
"list",
"by",
"series",
"name",
"case",
"-",
"sensitive"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L277-L290 | [
"def",
"search_drama_series",
"(",
"self",
",",
"query_string",
")",
":",
"result",
"=",
"self",
".",
"_android_api",
".",
"list_series",
"(",
"media_type",
"=",
"ANDROID",
".",
"MEDIA_TYPE_DRAMA",
",",
"filter",
"=",
"ANDROID",
".",
"FILTER_PREFIX",
"+",
"que... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.search_manga_series | Search the manga series list by name, case-insensitive
@param str query_string
@return list<crunchyroll.models.Series> | crunchyroll/apis/meta.py | def search_manga_series(self, query_string):
"""Search the manga series list by name, case-insensitive
@param str query_string
@return list<crunchyroll.models.Series>
"""
result = self._manga_api.list_series()
return [series for series in result \
if series... | def search_manga_series(self, query_string):
"""Search the manga series list by name, case-insensitive
@param str query_string
@return list<crunchyroll.models.Series>
"""
result = self._manga_api.list_series()
return [series for series in result \
if series... | [
"Search",
"the",
"manga",
"series",
"list",
"by",
"name",
"case",
"-",
"insensitive"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L294-L305 | [
"def",
"search_manga_series",
"(",
"self",
",",
"query_string",
")",
":",
"result",
"=",
"self",
".",
"_manga_api",
".",
"list_series",
"(",
")",
"return",
"[",
"series",
"for",
"series",
"in",
"result",
"if",
"series",
"[",
"'locale'",
"]",
"[",
"'enUS'",... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.list_media | List media for a given series or collection
@param crunchyroll.models.Series series the series to search for
@param str sort choose the ordering of the
results, only META.SORT_DESC
... | crunchyroll/apis/meta.py | def list_media(self, series, sort=META.SORT_DESC, limit=META.MAX_MEDIA, offset=0):
"""List media for a given series or collection
@param crunchyroll.models.Series series the series to search for
@param str sort choose the ordering of the
... | def list_media(self, series, sort=META.SORT_DESC, limit=META.MAX_MEDIA, offset=0):
"""List media for a given series or collection
@param crunchyroll.models.Series series the series to search for
@param str sort choose the ordering of the
... | [
"List",
"media",
"for",
"a",
"given",
"series",
"or",
"collection"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L309-L328 | [
"def",
"list_media",
"(",
"self",
",",
"series",
",",
"sort",
"=",
"META",
".",
"SORT_DESC",
",",
"limit",
"=",
"META",
".",
"MAX_MEDIA",
",",
"offset",
"=",
"0",
")",
":",
"params",
"=",
"{",
"'sort'",
":",
"sort",
",",
"'offset'",
":",
"offset",
... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.search_media | Search for media from a series starting with query_string, case-sensitive
@param crunchyroll.models.Series series the series to search in
@param str query_string the search query, same restrictions
as `search_anime_series`
... | crunchyroll/apis/meta.py | def search_media(self, series, query_string):
"""Search for media from a series starting with query_string, case-sensitive
@param crunchyroll.models.Series series the series to search in
@param str query_string the search query, same restrictions
... | def search_media(self, series, query_string):
"""Search for media from a series starting with query_string, case-sensitive
@param crunchyroll.models.Series series the series to search in
@param str query_string the search query, same restrictions
... | [
"Search",
"for",
"media",
"from",
"a",
"series",
"starting",
"with",
"query_string",
"case",
"-",
"sensitive"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L359-L372 | [
"def",
"search_media",
"(",
"self",
",",
"series",
",",
"query_string",
")",
":",
"params",
"=",
"{",
"'sort'",
":",
"ANDROID",
".",
"FILTER_PREFIX",
"+",
"query_string",
",",
"}",
"params",
".",
"update",
"(",
"self",
".",
"_get_series_query_dict",
"(",
"... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.get_media_stream | Get the stream data for a given media item
@param crunchyroll.models.Media media_item
@param int format
@param int quality
@return crunchyroll.models.MediaStream | crunchyroll/apis/meta.py | def get_media_stream(self, media_item, format, quality):
"""Get the stream data for a given media item
@param crunchyroll.models.Media media_item
@param int format
@param int quality
@return crunchyroll.models.MediaStream
"""
result = self._ajax_api.VideoPlayer_G... | def get_media_stream(self, media_item, format, quality):
"""Get the stream data for a given media item
@param crunchyroll.models.Media media_item
@param int format
@param int quality
@return crunchyroll.models.MediaStream
"""
result = self._ajax_api.VideoPlayer_G... | [
"Get",
"the",
"stream",
"data",
"for",
"a",
"given",
"media",
"item"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L375-L387 | [
"def",
"get_media_stream",
"(",
"self",
",",
"media_item",
",",
"format",
",",
"quality",
")",
":",
"result",
"=",
"self",
".",
"_ajax_api",
".",
"VideoPlayer_GetStandardConfig",
"(",
"media_id",
"=",
"media_item",
".",
"media_id",
",",
"video_format",
"=",
"f... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.unfold_subtitle_stub | Turn a SubtitleStub into a full Subtitle object
@param crunchyroll.models.SubtitleStub subtitle_stub
@return crunchyroll.models.Subtitle | crunchyroll/apis/meta.py | def unfold_subtitle_stub(self, subtitle_stub):
"""Turn a SubtitleStub into a full Subtitle object
@param crunchyroll.models.SubtitleStub subtitle_stub
@return crunchyroll.models.Subtitle
"""
return Subtitle(self._ajax_api.Subtitle_GetXml(
subtitle_script_id=int(subti... | def unfold_subtitle_stub(self, subtitle_stub):
"""Turn a SubtitleStub into a full Subtitle object
@param crunchyroll.models.SubtitleStub subtitle_stub
@return crunchyroll.models.Subtitle
"""
return Subtitle(self._ajax_api.Subtitle_GetXml(
subtitle_script_id=int(subti... | [
"Turn",
"a",
"SubtitleStub",
"into",
"a",
"full",
"Subtitle",
"object"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L402-L409 | [
"def",
"unfold_subtitle_stub",
"(",
"self",
",",
"subtitle_stub",
")",
":",
"return",
"Subtitle",
"(",
"self",
".",
"_ajax_api",
".",
"Subtitle_GetXml",
"(",
"subtitle_script_id",
"=",
"int",
"(",
"subtitle_stub",
".",
"id",
")",
")",
")"
] | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.get_stream_formats | Get the available media formats for a given media item
@param crunchyroll.models.Media
@return dict | crunchyroll/apis/meta.py | def get_stream_formats(self, media_item):
"""Get the available media formats for a given media item
@param crunchyroll.models.Media
@return dict
"""
scraper = ScraperApi(self._ajax_api._connector)
formats = scraper.get_media_formats(media_item.media_id)
return fo... | def get_stream_formats(self, media_item):
"""Get the available media formats for a given media item
@param crunchyroll.models.Media
@return dict
"""
scraper = ScraperApi(self._ajax_api._connector)
formats = scraper.get_media_formats(media_item.media_id)
return fo... | [
"Get",
"the",
"available",
"media",
"formats",
"for",
"a",
"given",
"media",
"item"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L412-L420 | [
"def",
"get_stream_formats",
"(",
"self",
",",
"media_item",
")",
":",
"scraper",
"=",
"ScraperApi",
"(",
"self",
".",
"_ajax_api",
".",
"_connector",
")",
"formats",
"=",
"scraper",
".",
"get_media_formats",
"(",
"media_item",
".",
"media_id",
")",
"return",
... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.list_queue | List the series in the queue, optionally filtering by type of media
@param list<str> media_types a list of media types to filter the queue
with, should be of META.TYPE_*
@return list<crunchyroll.models.Series> | crunchyroll/apis/meta.py | def list_queue(self, media_types=[META.TYPE_ANIME, META.TYPE_DRAMA]):
"""List the series in the queue, optionally filtering by type of media
@param list<str> media_types a list of media types to filter the queue
with, should be of META.TYPE_*
@retu... | def list_queue(self, media_types=[META.TYPE_ANIME, META.TYPE_DRAMA]):
"""List the series in the queue, optionally filtering by type of media
@param list<str> media_types a list of media types to filter the queue
with, should be of META.TYPE_*
@retu... | [
"List",
"the",
"series",
"in",
"the",
"queue",
"optionally",
"filtering",
"by",
"type",
"of",
"media"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L424-L432 | [
"def",
"list_queue",
"(",
"self",
",",
"media_types",
"=",
"[",
"META",
".",
"TYPE_ANIME",
",",
"META",
".",
"TYPE_DRAMA",
"]",
")",
":",
"result",
"=",
"self",
".",
"_android_api",
".",
"queue",
"(",
"media_types",
"=",
"'|'",
".",
"join",
"(",
"media... | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.add_to_queue | Add a series to the queue
@param crunchyroll.models.Series series
@return bool | crunchyroll/apis/meta.py | def add_to_queue(self, series):
"""Add a series to the queue
@param crunchyroll.models.Series series
@return bool
"""
result = self._android_api.add_to_queue(series_id=series.series_id)
return result | def add_to_queue(self, series):
"""Add a series to the queue
@param crunchyroll.models.Series series
@return bool
"""
result = self._android_api.add_to_queue(series_id=series.series_id)
return result | [
"Add",
"a",
"series",
"to",
"the",
"queue"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L435-L442 | [
"def",
"add_to_queue",
"(",
"self",
",",
"series",
")",
":",
"result",
"=",
"self",
".",
"_android_api",
".",
"add_to_queue",
"(",
"series_id",
"=",
"series",
".",
"series_id",
")",
"return",
"result"
] | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | MetaApi.remove_from_queue | Remove a series from the queue
@param crunchyroll.models.Series series
@return bool | crunchyroll/apis/meta.py | def remove_from_queue(self, series):
"""Remove a series from the queue
@param crunchyroll.models.Series series
@return bool
"""
result = self._android_api.remove_from_queue(series_id=series.series_id)
return result | def remove_from_queue(self, series):
"""Remove a series from the queue
@param crunchyroll.models.Series series
@return bool
"""
result = self._android_api.remove_from_queue(series_id=series.series_id)
return result | [
"Remove",
"a",
"series",
"from",
"the",
"queue"
] | aheadley/python-crunchyroll | python | https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L445-L452 | [
"def",
"remove_from_queue",
"(",
"self",
",",
"series",
")",
":",
"result",
"=",
"self",
".",
"_android_api",
".",
"remove_from_queue",
"(",
"series_id",
"=",
"series",
".",
"series_id",
")",
"return",
"result"
] | 9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178 |
train | schema | Create a compound tag schema.
This function is a short convenience function that makes it easy to
subclass the base `CompoundSchema` class.
The `name` argument is the name of the class and `dct` should be a
dictionnary containing the actual schema. The schema should map keys
to tag types or... | nbtlib/schema.py | def schema(name, dct, *, strict=False):
"""Create a compound tag schema.
This function is a short convenience function that makes it easy to
subclass the base `CompoundSchema` class.
The `name` argument is the name of the class and `dct` should be a
dictionnary containing the actual schema.... | def schema(name, dct, *, strict=False):
"""Create a compound tag schema.
This function is a short convenience function that makes it easy to
subclass the base `CompoundSchema` class.
The `name` argument is the name of the class and `dct` should be a
dictionnary containing the actual schema.... | [
"Create",
"a",
"compound",
"tag",
"schema",
".",
"This",
"function",
"is",
"a",
"short",
"convenience",
"function",
"that",
"makes",
"it",
"easy",
"to",
"subclass",
"the",
"base",
"CompoundSchema",
"class",
".",
"The",
"name",
"argument",
"is",
"the",
"name"... | vberlier/nbtlib | python | https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/schema.py#L17-L32 | [
"def",
"schema",
"(",
"name",
",",
"dct",
",",
"*",
",",
"strict",
"=",
"False",
")",
":",
"return",
"type",
"(",
"name",
",",
"(",
"CompoundSchema",
",",
")",
",",
"{",
"'__slots__'",
":",
"(",
")",
",",
"'schema'",
":",
"dct",
",",
"'strict'",
... | 9c9d58b5c4a530b0f1ffd76dda176f00406c3547 |
train | CompoundSchema.cast_item | Cast schema item to the appropriate tag type. | nbtlib/schema.py | def cast_item(cls, key, value):
"""Cast schema item to the appropriate tag type."""
schema_type = cls.schema.get(key)
if schema_type is None:
if cls.strict:
raise TypeError(f'Invalid key {key!r}')
elif not isinstance(value, schema_type):
try... | def cast_item(cls, key, value):
"""Cast schema item to the appropriate tag type."""
schema_type = cls.schema.get(key)
if schema_type is None:
if cls.strict:
raise TypeError(f'Invalid key {key!r}')
elif not isinstance(value, schema_type):
try... | [
"Cast",
"schema",
"item",
"to",
"the",
"appropriate",
"tag",
"type",
"."
] | vberlier/nbtlib | python | https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/schema.py#L73-L86 | [
"def",
"cast_item",
"(",
"cls",
",",
"key",
",",
"value",
")",
":",
"schema_type",
"=",
"cls",
".",
"schema",
".",
"get",
"(",
"key",
")",
"if",
"schema_type",
"is",
"None",
":",
"if",
"cls",
".",
"strict",
":",
"raise",
"TypeError",
"(",
"f'Invalid ... | 9c9d58b5c4a530b0f1ffd76dda176f00406c3547 |
train | obsolete_rename | Simple obsolete/removed method decorator
Parameters
----------
oldname : str
The name of the old obsolete name
newfunc : FunctionType
Replacement unbound member function. | AnyQt/_backport/_utils.py | def obsolete_rename(oldname, newfunc):
"""
Simple obsolete/removed method decorator
Parameters
----------
oldname : str
The name of the old obsolete name
newfunc : FunctionType
Replacement unbound member function.
"""
newname = newfunc.__name__
def __obsolete(*args, ... | def obsolete_rename(oldname, newfunc):
"""
Simple obsolete/removed method decorator
Parameters
----------
oldname : str
The name of the old obsolete name
newfunc : FunctionType
Replacement unbound member function.
"""
newname = newfunc.__name__
def __obsolete(*args, ... | [
"Simple",
"obsolete",
"/",
"removed",
"method",
"decorator"
] | ales-erjavec/anyqt | python | https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/_backport/_utils.py#L4-L25 | [
"def",
"obsolete_rename",
"(",
"oldname",
",",
"newfunc",
")",
":",
"newname",
"=",
"newfunc",
".",
"__name__",
"def",
"__obsolete",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"{oldname} is obsolete and is removed in P... | 07b73c5ccb8f73f70fc6566249c0c7228fc9b921 |
train | call | Runs a bash command safely, with shell=false, catches any non-zero
return codes. Raises slightly modified CalledProcessError exceptions
on failures.
Note: command is a string and cannot include pipes. | mongobackup/shell.py | def call(command, silent=False):
""" Runs a bash command safely, with shell=false, catches any non-zero
return codes. Raises slightly modified CalledProcessError exceptions
on failures.
Note: command is a string and cannot include pipes."""
try:
if silent:
with open(... | def call(command, silent=False):
""" Runs a bash command safely, with shell=false, catches any non-zero
return codes. Raises slightly modified CalledProcessError exceptions
on failures.
Note: command is a string and cannot include pipes."""
try:
if silent:
with open(... | [
"Runs",
"a",
"bash",
"command",
"safely",
"with",
"shell",
"=",
"false",
"catches",
"any",
"non",
"-",
"zero",
"return",
"codes",
".",
"Raises",
"slightly",
"modified",
"CalledProcessError",
"exceptions",
"on",
"failures",
".",
"Note",
":",
"command",
"is",
... | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/shell.py#L35-L54 | [
"def",
"call",
"(",
"command",
",",
"silent",
"=",
"False",
")",
":",
"try",
":",
"if",
"silent",
":",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"'w'",
")",
"as",
"FNULL",
":",
"return",
"subprocess",
".",
"check_call",
"(",
"command_to_array",
... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | tarbz | Tars and bzips a directory, preserving as much metadata as possible.
Adds '.tbz' to the provided output file name. | mongobackup/shell.py | def tarbz(source_directory_path, output_file_full_path, silent=False):
""" Tars and bzips a directory, preserving as much metadata as possible.
Adds '.tbz' to the provided output file name. """
output_directory_path = output_file_full_path.rsplit("/", 1)[0]
create_folders(output_directory_path)
... | def tarbz(source_directory_path, output_file_full_path, silent=False):
""" Tars and bzips a directory, preserving as much metadata as possible.
Adds '.tbz' to the provided output file name. """
output_directory_path = output_file_full_path.rsplit("/", 1)[0]
create_folders(output_directory_path)
... | [
"Tars",
"and",
"bzips",
"a",
"directory",
"preserving",
"as",
"much",
"metadata",
"as",
"possible",
".",
"Adds",
".",
"tbz",
"to",
"the",
"provided",
"output",
"file",
"name",
"."
] | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/shell.py#L64-L79 | [
"def",
"tarbz",
"(",
"source_directory_path",
",",
"output_file_full_path",
",",
"silent",
"=",
"False",
")",
":",
"output_directory_path",
"=",
"output_file_full_path",
".",
"rsplit",
"(",
"\"/\"",
",",
"1",
")",
"[",
"0",
"]",
"create_folders",
"(",
"output_di... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | untarbz | Restores your mongo database backup from a .tbz created using this library.
This function will ensure that a directory is created at the file path
if one does not exist already.
If used in conjunction with this library's mongodump operation, the backup
data will be extracted directly into the provi... | mongobackup/shell.py | def untarbz(source_file_path, output_directory_path, silent=False):
""" Restores your mongo database backup from a .tbz created using this library.
This function will ensure that a directory is created at the file path
if one does not exist already.
If used in conjunction with this library's mongod... | def untarbz(source_file_path, output_directory_path, silent=False):
""" Restores your mongo database backup from a .tbz created using this library.
This function will ensure that a directory is created at the file path
if one does not exist already.
If used in conjunction with this library's mongod... | [
"Restores",
"your",
"mongo",
"database",
"backup",
"from",
"a",
".",
"tbz",
"created",
"using",
"this",
"library",
".",
"This",
"function",
"will",
"ensure",
"that",
"a",
"directory",
"is",
"created",
"at",
"the",
"file",
"path",
"if",
"one",
"does",
"not"... | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/shell.py#L82-L108 | [
"def",
"untarbz",
"(",
"source_file_path",
",",
"output_directory_path",
",",
"silent",
"=",
"False",
")",
":",
"if",
"not",
"path",
".",
"exists",
"(",
"source_file_path",
")",
":",
"raise",
"Exception",
"(",
"\"the provided tar file %s does not exist.\"",
"%",
"... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | LDAPItem.value_contains | Determine if any of the items in the value list for the given
attribute contain value. | simpleldap/__init__.py | def value_contains(self, value, attribute):
"""
Determine if any of the items in the value list for the given
attribute contain value.
"""
for item in self[attribute]:
if value in item:
return True
return False | def value_contains(self, value, attribute):
"""
Determine if any of the items in the value list for the given
attribute contain value.
"""
for item in self[attribute]:
if value in item:
return True
return False | [
"Determine",
"if",
"any",
"of",
"the",
"items",
"in",
"the",
"value",
"list",
"for",
"the",
"given",
"attribute",
"contain",
"value",
"."
] | gdub/python-simpleldap | python | https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L64-L72 | [
"def",
"value_contains",
"(",
"self",
",",
"value",
",",
"attribute",
")",
":",
"for",
"item",
"in",
"self",
"[",
"attribute",
"]",
":",
"if",
"value",
"in",
"item",
":",
"return",
"True",
"return",
"False"
] | a833f444d90ad2f3fe779c3e2cb08350052fedc8 |
train | Connection.clear_search_defaults | Clear all search defaults specified by the list of parameter names
given as ``args``. If ``args`` is not given, then clear all existing
search defaults.
Examples::
conn.set_search_defaults(scope=ldap.SCOPE_BASE, attrs=['cn'])
conn.clear_search_defaults(['scope'])
... | simpleldap/__init__.py | def clear_search_defaults(self, args=None):
"""
Clear all search defaults specified by the list of parameter names
given as ``args``. If ``args`` is not given, then clear all existing
search defaults.
Examples::
conn.set_search_defaults(scope=ldap.SCOPE_BASE, attrs... | def clear_search_defaults(self, args=None):
"""
Clear all search defaults specified by the list of parameter names
given as ``args``. If ``args`` is not given, then clear all existing
search defaults.
Examples::
conn.set_search_defaults(scope=ldap.SCOPE_BASE, attrs... | [
"Clear",
"all",
"search",
"defaults",
"specified",
"by",
"the",
"list",
"of",
"parameter",
"names",
"given",
"as",
"args",
".",
"If",
"args",
"is",
"not",
"given",
"then",
"clear",
"all",
"existing",
"search",
"defaults",
"."
] | gdub/python-simpleldap | python | https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L188-L205 | [
"def",
"clear_search_defaults",
"(",
"self",
",",
"args",
"=",
"None",
")",
":",
"if",
"args",
"is",
"None",
":",
"self",
".",
"_search_defaults",
".",
"clear",
"(",
")",
"else",
":",
"for",
"arg",
"in",
"args",
":",
"if",
"arg",
"in",
"self",
".",
... | a833f444d90ad2f3fe779c3e2cb08350052fedc8 |
train | Connection.search | Search the directory. | simpleldap/__init__.py | def search(self, filter, base_dn=None, attrs=None, scope=None,
timeout=None, limit=None):
"""
Search the directory.
"""
if base_dn is None:
base_dn = self._search_defaults.get('base_dn', '')
if attrs is None:
attrs = self._search_defaults.ge... | def search(self, filter, base_dn=None, attrs=None, scope=None,
timeout=None, limit=None):
"""
Search the directory.
"""
if base_dn is None:
base_dn = self._search_defaults.get('base_dn', '')
if attrs is None:
attrs = self._search_defaults.ge... | [
"Search",
"the",
"directory",
"."
] | gdub/python-simpleldap | python | https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L219-L237 | [
"def",
"search",
"(",
"self",
",",
"filter",
",",
"base_dn",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"scope",
"=",
"None",
",",
"timeout",
"=",
"None",
",",
"limit",
"=",
"None",
")",
":",
"if",
"base_dn",
"is",
"None",
":",
"base_dn",
"=",
... | a833f444d90ad2f3fe779c3e2cb08350052fedc8 |
train | Connection.get | Get a single object.
This is a convenience wrapper for the search method that checks that
only one object was returned, and returns that single object instead
of a list. This method takes the exact same arguments as search. | simpleldap/__init__.py | def get(self, *args, **kwargs):
"""
Get a single object.
This is a convenience wrapper for the search method that checks that
only one object was returned, and returns that single object instead
of a list. This method takes the exact same arguments as search.
"""
... | def get(self, *args, **kwargs):
"""
Get a single object.
This is a convenience wrapper for the search method that checks that
only one object was returned, and returns that single object instead
of a list. This method takes the exact same arguments as search.
"""
... | [
"Get",
"a",
"single",
"object",
"."
] | gdub/python-simpleldap | python | https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L239-L253 | [
"def",
"get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"results",
"=",
"self",
".",
"search",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"num_results",
"=",
"len",
"(",
"results",
")",
"if",
"num_results",
"==",
"1",... | a833f444d90ad2f3fe779c3e2cb08350052fedc8 |
train | Connection.authenticate | Attempt to authenticate given dn and password using a bind operation.
Return True if the bind is successful, and return False there was an
exception raised that is contained in
self.failed_authentication_exceptions. | simpleldap/__init__.py | def authenticate(self, dn='', password=''):
"""
Attempt to authenticate given dn and password using a bind operation.
Return True if the bind is successful, and return False there was an
exception raised that is contained in
self.failed_authentication_exceptions.
"""
... | def authenticate(self, dn='', password=''):
"""
Attempt to authenticate given dn and password using a bind operation.
Return True if the bind is successful, and return False there was an
exception raised that is contained in
self.failed_authentication_exceptions.
"""
... | [
"Attempt",
"to",
"authenticate",
"given",
"dn",
"and",
"password",
"using",
"a",
"bind",
"operation",
".",
"Return",
"True",
"if",
"the",
"bind",
"is",
"successful",
"and",
"return",
"False",
"there",
"was",
"an",
"exception",
"raised",
"that",
"is",
"contai... | gdub/python-simpleldap | python | https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L262-L274 | [
"def",
"authenticate",
"(",
"self",
",",
"dn",
"=",
"''",
",",
"password",
"=",
"''",
")",
":",
"try",
":",
"self",
".",
"connection",
".",
"simple_bind_s",
"(",
"dn",
",",
"password",
")",
"except",
"tuple",
"(",
"self",
".",
"failed_authentication_exce... | a833f444d90ad2f3fe779c3e2cb08350052fedc8 |
train | Connection.compare | Compare the ``attr`` of the entry ``dn`` with given ``value``.
This is a convenience wrapper for the ldap library's ``compare``
function that returns a boolean value instead of 1 or 0. | simpleldap/__init__.py | def compare(self, dn, attr, value):
"""
Compare the ``attr`` of the entry ``dn`` with given ``value``.
This is a convenience wrapper for the ldap library's ``compare``
function that returns a boolean value instead of 1 or 0.
"""
return self.connection.compare_s(dn, attr,... | def compare(self, dn, attr, value):
"""
Compare the ``attr`` of the entry ``dn`` with given ``value``.
This is a convenience wrapper for the ldap library's ``compare``
function that returns a boolean value instead of 1 or 0.
"""
return self.connection.compare_s(dn, attr,... | [
"Compare",
"the",
"attr",
"of",
"the",
"entry",
"dn",
"with",
"given",
"value",
"."
] | gdub/python-simpleldap | python | https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L276-L283 | [
"def",
"compare",
"(",
"self",
",",
"dn",
",",
"attr",
",",
"value",
")",
":",
"return",
"self",
".",
"connection",
".",
"compare_s",
"(",
"dn",
",",
"attr",
",",
"value",
")",
"==",
"1"
] | a833f444d90ad2f3fe779c3e2cb08350052fedc8 |
train | get_property_func | Get the accessor function for an instance to look for `key`.
Look for it as an attribute, and if that does not work, look to see if it
is a tag. | plumbum.py | def get_property_func(key):
"""
Get the accessor function for an instance to look for `key`.
Look for it as an attribute, and if that does not work, look to see if it
is a tag.
"""
def get_it(obj):
try:
return getattr(obj, key)
except AttributeError:
retu... | def get_property_func(key):
"""
Get the accessor function for an instance to look for `key`.
Look for it as an attribute, and if that does not work, look to see if it
is a tag.
"""
def get_it(obj):
try:
return getattr(obj, key)
except AttributeError:
retu... | [
"Get",
"the",
"accessor",
"function",
"for",
"an",
"instance",
"to",
"look",
"for",
"key",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L59-L71 | [
"def",
"get_property_func",
"(",
"key",
")",
":",
"def",
"get_it",
"(",
"obj",
")",
":",
"try",
":",
"return",
"getattr",
"(",
"obj",
",",
"key",
")",
"except",
"AttributeError",
":",
"return",
"obj",
".",
"tags",
".",
"get",
"(",
"key",
")",
"return... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_billing | List available billing metrics | plumbum.py | def list_billing(region, filter_by_kwargs):
"""List available billing metrics"""
conn = boto.ec2.cloudwatch.connect_to_region(region)
metrics = conn.list_metrics(metric_name='EstimatedCharges')
# Filtering is based on metric Dimensions. Only really valuable one is
# ServiceName.
if filter_by_kw... | def list_billing(region, filter_by_kwargs):
"""List available billing metrics"""
conn = boto.ec2.cloudwatch.connect_to_region(region)
metrics = conn.list_metrics(metric_name='EstimatedCharges')
# Filtering is based on metric Dimensions. Only really valuable one is
# ServiceName.
if filter_by_kw... | [
"List",
"available",
"billing",
"metrics"
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L111-L127 | [
"def",
"list_billing",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"ec2",
".",
"cloudwatch",
".",
"connect_to_region",
"(",
"region",
")",
"metrics",
"=",
"conn",
".",
"list_metrics",
"(",
"metric_name",
"=",
"'EstimatedCharges'... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_cloudfront | List running ec2 instances. | plumbum.py | def list_cloudfront(region, filter_by_kwargs):
"""List running ec2 instances."""
conn = boto.connect_cloudfront()
instances = conn.get_all_distributions()
return lookup(instances, filter_by=filter_by_kwargs) | def list_cloudfront(region, filter_by_kwargs):
"""List running ec2 instances."""
conn = boto.connect_cloudfront()
instances = conn.get_all_distributions()
return lookup(instances, filter_by=filter_by_kwargs) | [
"List",
"running",
"ec2",
"instances",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L130-L134 | [
"def",
"list_cloudfront",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"connect_cloudfront",
"(",
")",
"instances",
"=",
"conn",
".",
"get_all_distributions",
"(",
")",
"return",
"lookup",
"(",
"instances",
",",
"filter_by",
"=",... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_ec2 | List running ec2 instances. | plumbum.py | def list_ec2(region, filter_by_kwargs):
"""List running ec2 instances."""
conn = boto.ec2.connect_to_region(region)
instances = conn.get_only_instances()
return lookup(instances, filter_by=filter_by_kwargs) | def list_ec2(region, filter_by_kwargs):
"""List running ec2 instances."""
conn = boto.ec2.connect_to_region(region)
instances = conn.get_only_instances()
return lookup(instances, filter_by=filter_by_kwargs) | [
"List",
"running",
"ec2",
"instances",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L137-L141 | [
"def",
"list_ec2",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"ec2",
".",
"connect_to_region",
"(",
"region",
")",
"instances",
"=",
"conn",
".",
"get_only_instances",
"(",
")",
"return",
"lookup",
"(",
"instances",
",",
"f... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_ebs | List running ebs volumes. | plumbum.py | def list_ebs(region, filter_by_kwargs):
"""List running ebs volumes."""
conn = boto.ec2.connect_to_region(region)
instances = conn.get_all_volumes()
return lookup(instances, filter_by=filter_by_kwargs) | def list_ebs(region, filter_by_kwargs):
"""List running ebs volumes."""
conn = boto.ec2.connect_to_region(region)
instances = conn.get_all_volumes()
return lookup(instances, filter_by=filter_by_kwargs) | [
"List",
"running",
"ebs",
"volumes",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L143-L147 | [
"def",
"list_ebs",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"ec2",
".",
"connect_to_region",
"(",
"region",
")",
"instances",
"=",
"conn",
".",
"get_all_volumes",
"(",
")",
"return",
"lookup",
"(",
"instances",
",",
"filt... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_elb | List all load balancers. | plumbum.py | def list_elb(region, filter_by_kwargs):
"""List all load balancers."""
conn = boto.ec2.elb.connect_to_region(region)
instances = conn.get_all_load_balancers()
return lookup(instances, filter_by=filter_by_kwargs) | def list_elb(region, filter_by_kwargs):
"""List all load balancers."""
conn = boto.ec2.elb.connect_to_region(region)
instances = conn.get_all_load_balancers()
return lookup(instances, filter_by=filter_by_kwargs) | [
"List",
"all",
"load",
"balancers",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L150-L154 | [
"def",
"list_elb",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"ec2",
".",
"elb",
".",
"connect_to_region",
"(",
"region",
")",
"instances",
"=",
"conn",
".",
"get_all_load_balancers",
"(",
")",
"return",
"lookup",
"(",
"ins... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_rds | List all RDS thingys. | plumbum.py | def list_rds(region, filter_by_kwargs):
"""List all RDS thingys."""
conn = boto.rds.connect_to_region(region)
instances = conn.get_all_dbinstances()
return lookup(instances, filter_by=filter_by_kwargs) | def list_rds(region, filter_by_kwargs):
"""List all RDS thingys."""
conn = boto.rds.connect_to_region(region)
instances = conn.get_all_dbinstances()
return lookup(instances, filter_by=filter_by_kwargs) | [
"List",
"all",
"RDS",
"thingys",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L157-L161 | [
"def",
"list_rds",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"rds",
".",
"connect_to_region",
"(",
"region",
")",
"instances",
"=",
"conn",
".",
"get_all_dbinstances",
"(",
")",
"return",
"lookup",
"(",
"instances",
",",
"... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_elasticache | List all ElastiCache Clusters. | plumbum.py | def list_elasticache(region, filter_by_kwargs):
"""List all ElastiCache Clusters."""
conn = boto.elasticache.connect_to_region(region)
req = conn.describe_cache_clusters()
data = req["DescribeCacheClustersResponse"]["DescribeCacheClustersResult"]["CacheClusters"]
if filter_by_kwargs:
cluster... | def list_elasticache(region, filter_by_kwargs):
"""List all ElastiCache Clusters."""
conn = boto.elasticache.connect_to_region(region)
req = conn.describe_cache_clusters()
data = req["DescribeCacheClustersResponse"]["DescribeCacheClustersResult"]["CacheClusters"]
if filter_by_kwargs:
cluster... | [
"List",
"all",
"ElastiCache",
"Clusters",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L164-L173 | [
"def",
"list_elasticache",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"elasticache",
".",
"connect_to_region",
"(",
"region",
")",
"req",
"=",
"conn",
".",
"describe_cache_clusters",
"(",
")",
"data",
"=",
"req",
"[",
"\"Desc... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_autoscaling_group | List all Auto Scaling Groups. | plumbum.py | def list_autoscaling_group(region, filter_by_kwargs):
"""List all Auto Scaling Groups."""
conn = boto.ec2.autoscale.connect_to_region(region)
groups = conn.get_all_groups()
return lookup(groups, filter_by=filter_by_kwargs) | def list_autoscaling_group(region, filter_by_kwargs):
"""List all Auto Scaling Groups."""
conn = boto.ec2.autoscale.connect_to_region(region)
groups = conn.get_all_groups()
return lookup(groups, filter_by=filter_by_kwargs) | [
"List",
"all",
"Auto",
"Scaling",
"Groups",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L176-L180 | [
"def",
"list_autoscaling_group",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"ec2",
".",
"autoscale",
".",
"connect_to_region",
"(",
"region",
")",
"groups",
"=",
"conn",
".",
"get_all_groups",
"(",
")",
"return",
"lookup",
"(... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_sqs | List all SQS Queues. | plumbum.py | def list_sqs(region, filter_by_kwargs):
"""List all SQS Queues."""
conn = boto.sqs.connect_to_region(region)
queues = conn.get_all_queues()
return lookup(queues, filter_by=filter_by_kwargs) | def list_sqs(region, filter_by_kwargs):
"""List all SQS Queues."""
conn = boto.sqs.connect_to_region(region)
queues = conn.get_all_queues()
return lookup(queues, filter_by=filter_by_kwargs) | [
"List",
"all",
"SQS",
"Queues",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L183-L187 | [
"def",
"list_sqs",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"sqs",
".",
"connect_to_region",
"(",
"region",
")",
"queues",
"=",
"conn",
".",
"get_all_queues",
"(",
")",
"return",
"lookup",
"(",
"queues",
",",
"filter_by",... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_kinesis_applications | List all the kinesis applications along with the shards for each stream | plumbum.py | def list_kinesis_applications(region, filter_by_kwargs):
"""List all the kinesis applications along with the shards for each stream"""
conn = boto.kinesis.connect_to_region(region)
streams = conn.list_streams()['StreamNames']
kinesis_streams = {}
for stream_name in streams:
shard_ids = []
... | def list_kinesis_applications(region, filter_by_kwargs):
"""List all the kinesis applications along with the shards for each stream"""
conn = boto.kinesis.connect_to_region(region)
streams = conn.list_streams()['StreamNames']
kinesis_streams = {}
for stream_name in streams:
shard_ids = []
... | [
"List",
"all",
"the",
"kinesis",
"applications",
"along",
"with",
"the",
"shards",
"for",
"each",
"stream"
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L190-L201 | [
"def",
"list_kinesis_applications",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"kinesis",
".",
"connect_to_region",
"(",
"region",
")",
"streams",
"=",
"conn",
".",
"list_streams",
"(",
")",
"[",
"'StreamNames'",
"]",
"kinesis_... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | list_dynamodb | List all DynamoDB tables. | plumbum.py | def list_dynamodb(region, filter_by_kwargs):
"""List all DynamoDB tables."""
conn = boto.dynamodb.connect_to_region(region)
tables = conn.list_tables()
return lookup(tables, filter_by=filter_by_kwargs) | def list_dynamodb(region, filter_by_kwargs):
"""List all DynamoDB tables."""
conn = boto.dynamodb.connect_to_region(region)
tables = conn.list_tables()
return lookup(tables, filter_by=filter_by_kwargs) | [
"List",
"all",
"DynamoDB",
"tables",
"."
] | crccheck/cloudwatch-to-graphite | python | https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L204-L208 | [
"def",
"list_dynamodb",
"(",
"region",
",",
"filter_by_kwargs",
")",
":",
"conn",
"=",
"boto",
".",
"dynamodb",
".",
"connect_to_region",
"(",
"region",
")",
"tables",
"=",
"conn",
".",
"list_tables",
"(",
")",
"return",
"lookup",
"(",
"tables",
",",
"filt... | 28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6 |
train | Router.register | Register a new handler for a specific :class:`slack.actions.Action` `callback_id`.
Optional routing based on the action name too.
The name argument is useful for actions of type `interactive_message` to provide
a different handler for each individual action.
Args:
callback_... | slack/actions.py | def register(self, callback_id: str, handler: Any, name: str = "*") -> None:
"""
Register a new handler for a specific :class:`slack.actions.Action` `callback_id`.
Optional routing based on the action name too.
The name argument is useful for actions of type `interactive_message` to pro... | def register(self, callback_id: str, handler: Any, name: str = "*") -> None:
"""
Register a new handler for a specific :class:`slack.actions.Action` `callback_id`.
Optional routing based on the action name too.
The name argument is useful for actions of type `interactive_message` to pro... | [
"Register",
"a",
"new",
"handler",
"for",
"a",
"specific",
":",
"class",
":",
"slack",
".",
"actions",
".",
"Action",
"callback_id",
".",
"Optional",
"routing",
"based",
"on",
"the",
"action",
"name",
"too",
"."
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/actions.py#L82-L99 | [
"def",
"register",
"(",
"self",
",",
"callback_id",
":",
"str",
",",
"handler",
":",
"Any",
",",
"name",
":",
"str",
"=",
"\"*\"",
")",
"->",
"None",
":",
"LOG",
".",
"info",
"(",
"\"Registering %s, %s to %s\"",
",",
"callback_id",
",",
"name",
",",
"h... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | Router.dispatch | Yields handlers matching the incoming :class:`slack.actions.Action` `callback_id`.
Args:
action: :class:`slack.actions.Action`
Yields:
handler | slack/actions.py | def dispatch(self, action: Action) -> Any:
"""
Yields handlers matching the incoming :class:`slack.actions.Action` `callback_id`.
Args:
action: :class:`slack.actions.Action`
Yields:
handler
"""
LOG.debug("Dispatching action %s, %s", action["type"... | def dispatch(self, action: Action) -> Any:
"""
Yields handlers matching the incoming :class:`slack.actions.Action` `callback_id`.
Args:
action: :class:`slack.actions.Action`
Yields:
handler
"""
LOG.debug("Dispatching action %s, %s", action["type"... | [
"Yields",
"handlers",
"matching",
"the",
"incoming",
":",
"class",
":",
"slack",
".",
"actions",
".",
"Action",
"callback_id",
"."
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/actions.py#L101-L118 | [
"def",
"dispatch",
"(",
"self",
",",
"action",
":",
"Action",
")",
"->",
"Any",
":",
"LOG",
".",
"debug",
"(",
"\"Dispatching action %s, %s\"",
",",
"action",
"[",
"\"type\"",
"]",
",",
"action",
"[",
"\"callback_id\"",
"]",
")",
"if",
"action",
"[",
"\"... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | comittoapi | Commit to the use of specified Qt api.
Raise an error if another Qt api is already loaded in sys.modules | AnyQt/_api.py | def comittoapi(api):
"""
Commit to the use of specified Qt api.
Raise an error if another Qt api is already loaded in sys.modules
"""
global USED_API
assert USED_API is None, "committoapi called again!"
check = ["PyQt4", "PyQt5", "PySide", "PySide2"]
assert api in [QT_API_PYQT5, QT_API... | def comittoapi(api):
"""
Commit to the use of specified Qt api.
Raise an error if another Qt api is already loaded in sys.modules
"""
global USED_API
assert USED_API is None, "committoapi called again!"
check = ["PyQt4", "PyQt5", "PySide", "PySide2"]
assert api in [QT_API_PYQT5, QT_API... | [
"Commit",
"to",
"the",
"use",
"of",
"specified",
"Qt",
"api",
"."
] | ales-erjavec/anyqt | python | https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/_api.py#L23-L44 | [
"def",
"comittoapi",
"(",
"api",
")",
":",
"global",
"USED_API",
"assert",
"USED_API",
"is",
"None",
",",
"\"committoapi called again!\"",
"check",
"=",
"[",
"\"PyQt4\"",
",",
"\"PyQt5\"",
",",
"\"PySide\"",
",",
"\"PySide2\"",
"]",
"assert",
"api",
"in",
"[",... | 07b73c5ccb8f73f70fc6566249c0c7228fc9b921 |
train | get_metadata | Return dictionary of metadata for given dist
@param dist: distribution
@type dist: pkg_resources Distribution object
@returns: dict of metadata or None | yolk/metadata.py | def get_metadata(dist):
"""
Return dictionary of metadata for given dist
@param dist: distribution
@type dist: pkg_resources Distribution object
@returns: dict of metadata or None
"""
if not dist.has_metadata('PKG-INFO'):
return
msg = email.message_from_string(dist.get_metada... | def get_metadata(dist):
"""
Return dictionary of metadata for given dist
@param dist: distribution
@type dist: pkg_resources Distribution object
@returns: dict of metadata or None
"""
if not dist.has_metadata('PKG-INFO'):
return
msg = email.message_from_string(dist.get_metada... | [
"Return",
"dictionary",
"of",
"metadata",
"for",
"given",
"dist"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/metadata.py#L25-L43 | [
"def",
"get_metadata",
"(",
"dist",
")",
":",
"if",
"not",
"dist",
".",
"has_metadata",
"(",
"'PKG-INFO'",
")",
":",
"return",
"msg",
"=",
"email",
".",
"message_from_string",
"(",
"dist",
".",
"get_metadata",
"(",
"'PKG-INFO'",
")",
")",
"metadata",
"=",
... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Plugin.add_options | Add command-line options for this plugin.
The base plugin class adds --with-$name by default, used to enable the
plugin. | yolk/plugins/base.py | def add_options(self, parser):
"""Add command-line options for this plugin.
The base plugin class adds --with-$name by default, used to enable the
plugin.
"""
parser.add_option("--with-%s" % self.name,
action="store_true",
des... | def add_options(self, parser):
"""Add command-line options for this plugin.
The base plugin class adds --with-$name by default, used to enable the
plugin.
"""
parser.add_option("--with-%s" % self.name,
action="store_true",
des... | [
"Add",
"command",
"-",
"line",
"options",
"for",
"this",
"plugin",
"."
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/base.py#L42-L53 | [
"def",
"add_options",
"(",
"self",
",",
"parser",
")",
":",
"parser",
".",
"add_option",
"(",
"\"--with-%s\"",
"%",
"self",
".",
"name",
",",
"action",
"=",
"\"store_true\"",
",",
"dest",
"=",
"self",
".",
"enable_opt",
",",
"help",
"=",
"\"Enable plugin %... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Plugin.configure | Configure the plugin and system, based on selected options.
The base plugin class sets the plugin to enabled if the enable option
for the plugin (self.enable_opt) is true. | yolk/plugins/base.py | def configure(self, options, conf):
"""Configure the plugin and system, based on selected options.
The base plugin class sets the plugin to enabled if the enable option
for the plugin (self.enable_opt) is true.
"""
self.conf = conf
if hasattr(options, self.enable_opt):
... | def configure(self, options, conf):
"""Configure the plugin and system, based on selected options.
The base plugin class sets the plugin to enabled if the enable option
for the plugin (self.enable_opt) is true.
"""
self.conf = conf
if hasattr(options, self.enable_opt):
... | [
"Configure",
"the",
"plugin",
"and",
"system",
"based",
"on",
"selected",
"options",
"."
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/base.py#L55-L63 | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"conf",
")",
":",
"self",
".",
"conf",
"=",
"conf",
"if",
"hasattr",
"(",
"options",
",",
"self",
".",
"enable_opt",
")",
":",
"self",
".",
"enabled",
"=",
"getattr",
"(",
"options",
",",
"self",
... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Plugin.help | Return help for this plugin. This will be output as the help
section of the --with-$name option that enables the plugin. | yolk/plugins/base.py | def help(self):
"""Return help for this plugin. This will be output as the help
section of the --with-$name option that enables the plugin.
"""
if self.__class__.__doc__:
# doc sections are often indented; compress the spaces
return textwrap.dedent(self.__class__.... | def help(self):
"""Return help for this plugin. This will be output as the help
section of the --with-$name option that enables the plugin.
"""
if self.__class__.__doc__:
# doc sections are often indented; compress the spaces
return textwrap.dedent(self.__class__.... | [
"Return",
"help",
"for",
"this",
"plugin",
".",
"This",
"will",
"be",
"output",
"as",
"the",
"help",
"section",
"of",
"the",
"--",
"with",
"-",
"$name",
"option",
"that",
"enables",
"the",
"plugin",
"."
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/base.py#L65-L72 | [
"def",
"help",
"(",
"self",
")",
":",
"if",
"self",
".",
"__class__",
".",
"__doc__",
":",
"# doc sections are often indented; compress the spaces",
"return",
"textwrap",
".",
"dedent",
"(",
"self",
".",
"__class__",
".",
"__doc__",
")",
"return",
"\"(no help avai... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | raise_for_status | Check request response status
Args:
status: Response status
headers: Response headers
data: Response data
Raises:
:class:`slack.exceptions.RateLimited`: For 429 status code
:class:`slack.exceptions:HTTPException`: | slack/sansio.py | def raise_for_status(
status: int, headers: MutableMapping, data: MutableMapping
) -> None:
"""
Check request response status
Args:
status: Response status
headers: Response headers
data: Response data
Raises:
:class:`slack.exceptions.RateLimited`: For 429 status co... | def raise_for_status(
status: int, headers: MutableMapping, data: MutableMapping
) -> None:
"""
Check request response status
Args:
status: Response status
headers: Response headers
data: Response data
Raises:
:class:`slack.exceptions.RateLimited`: For 429 status co... | [
"Check",
"request",
"response",
"status"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L28-L57 | [
"def",
"raise_for_status",
"(",
"status",
":",
"int",
",",
"headers",
":",
"MutableMapping",
",",
"data",
":",
"MutableMapping",
")",
"->",
"None",
":",
"if",
"status",
"!=",
"200",
":",
"if",
"status",
"==",
"429",
":",
"if",
"isinstance",
"(",
"data",
... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | raise_for_api_error | Check request response for Slack API error
Args:
headers: Response headers
data: Response data
Raises:
:class:`slack.exceptions.SlackAPIError` | slack/sansio.py | 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:
"""
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... | [
"Check",
"request",
"response",
"for",
"Slack",
"API",
"error"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L60-L76 | [
"def",
"raise_for_api_error",
"(",
"headers",
":",
"MutableMapping",
",",
"data",
":",
"MutableMapping",
")",
"->",
"None",
":",
"if",
"not",
"data",
"[",
"\"ok\"",
"]",
":",
"raise",
"exceptions",
".",
"SlackAPIError",
"(",
"data",
".",
"get",
"(",
"\"err... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | decode_body | 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 | slack/sansio.py | 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:
"""
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... | [
"Decode",
"the",
"response",
"body"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L79-L105 | [
"def",
"decode_body",
"(",
"headers",
":",
"MutableMapping",
",",
"body",
":",
"bytes",
")",
"->",
"dict",
":",
"type_",
",",
"encoding",
"=",
"parse_content_type",
"(",
"headers",
")",
"decoded_body",
"=",
"body",
".",
"decode",
"(",
"encoding",
")",
"# T... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | parse_content_type | Find content-type and encoding of the response
Args:
headers: Response headers
Returns:
:py:class:`tuple` (content-type, encoding) | slack/sansio.py | 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]:
"""
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... | [
"Find",
"content",
"-",
"type",
"and",
"encoding",
"of",
"the",
"response"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L108-L124 | [
"def",
"parse_content_type",
"(",
"headers",
":",
"MutableMapping",
")",
"->",
"Tuple",
"[",
"Optional",
"[",
"str",
"]",
",",
"str",
"]",
":",
"content_type",
"=",
"headers",
".",
"get",
"(",
"\"content-type\"",
")",
"if",
"not",
"content_type",
":",
"ret... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | prepare_request | 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... | slack/sansio.py | 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,
token: str,
as_json: Optional[bool] = None,
) -> Tuple[str, Union[str, MutableMapping], MutableMapping]:
"""
Prepare outgoing request
Cre... | [
"Prepare",
"outgoing",
"request"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L127-L172 | [
"def",
"prepare_request",
"(",
"url",
":",
"Union",
"[",
"str",
",",
"methods",
"]",
",",
"data",
":",
"Optional",
"[",
"MutableMapping",
"]",
",",
"headers",
":",
"Optional",
"[",
"MutableMapping",
"]",
",",
"global_headers",
":",
"MutableMapping",
",",
"... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | decode_response | Decode incoming response
Args:
status: Response status
headers: Response headers
body: Response body
Returns:
Response data | slack/sansio.py | 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:
"""
Decode incoming response
Args:
status: Response status
headers: Response headers
body: Response body
Returns:
Response data
"""
data = decode_body(headers, body)
raise_for_st... | [
"Decode",
"incoming",
"response"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L203-L219 | [
"def",
"decode_response",
"(",
"status",
":",
"int",
",",
"headers",
":",
"MutableMapping",
",",
"body",
":",
"bytes",
")",
"->",
"dict",
":",
"data",
"=",
"decode_body",
"(",
"headers",
",",
"body",
")",
"raise_for_status",
"(",
"status",
",",
"headers",
... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | find_iteration | 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) | slack/sansio.py | 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, str]:
"""
Find iteration mode and iteration key for a given :class:`slack.methods`
Args:
url: :class:`slack.methods` or string url
itermode: Custom iterat... | [
"Find",
"iteration",
"mode",
"and",
"iteration",
"key",
"for",
"a",
"given",
":",
"class",
":",
"slack",
".",
"methods"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L222-L249 | [
"def",
"find_iteration",
"(",
"url",
":",
"Union",
"[",
"methods",
",",
"str",
"]",
",",
"itermode",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"iterkey",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
")",
"->",
"Tuple",
"[",
"str",
... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | prepare_iter_request | 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... | slack/sansio.py | 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] = None,
limit: int = 200,
itervalue: Optional[Union[str, int]] = None,
) -> Tuple[MutableMapping, str, str]:
"""
Prepare outgoing iteration request
... | [
"Prepare",
"outgoing",
"iteration",
"request"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L252-L289 | [
"def",
"prepare_iter_request",
"(",
"url",
":",
"Union",
"[",
"methods",
",",
"str",
"]",
",",
"data",
":",
"MutableMapping",
",",
"*",
",",
"iterkey",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"itermode",
":",
"Optional",
"[",
"str",
"]",
... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | decode_iter_request | Decode incoming response from an iteration request
Args:
data: Response data
Returns:
Next itervalue | slack/sansio.py | 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]]:
"""
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... | [
"Decode",
"incoming",
"response",
"from",
"an",
"iteration",
"request"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L292-L313 | [
"def",
"decode_iter_request",
"(",
"data",
":",
"dict",
")",
"->",
"Optional",
"[",
"Union",
"[",
"str",
",",
"int",
"]",
"]",
":",
"if",
"\"response_metadata\"",
"in",
"data",
":",
"return",
"data",
"[",
"\"response_metadata\"",
"]",
".",
"get",
"(",
"\... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | discard_event | Check if the incoming event needs to be discarded
Args:
event: Incoming :class:`slack.events.Event`
bot_id: Id of connected bot
Returns:
boolean | slack/sansio.py | 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:
"""
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... | [
"Check",
"if",
"the",
"incoming",
"event",
"needs",
"to",
"be",
"discarded"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L316-L336 | [
"def",
"discard_event",
"(",
"event",
":",
"events",
".",
"Event",
",",
"bot_id",
":",
"str",
"=",
"None",
")",
"->",
"bool",
":",
"if",
"event",
"[",
"\"type\"",
"]",
"in",
"SKIP_EVENTS",
":",
"return",
"True",
"elif",
"bot_id",
"and",
"isinstance",
"... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | validate_request_signature | 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... | slack/sansio.py | 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:
"""
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... | [
"Validate",
"incoming",
"request",
"signature",
"using",
"the",
"application",
"signing",
"secret",
"."
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L355-L389 | [
"def",
"validate_request_signature",
"(",
"body",
":",
"str",
",",
"headers",
":",
"MutableMapping",
",",
"signing_secret",
":",
"str",
")",
"->",
"None",
":",
"request_timestamp",
"=",
"int",
"(",
"headers",
"[",
"\"X-Slack-Request-Timestamp\"",
"]",
")",
"if",... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | backup | 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... | mongobackup/backups.py | 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_dump",
s3_bucket=None, s3_access_key_id=None, s3_secret_key=None,
purge_local=None, purge_a... | [
"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",
... | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L37-L94 | [
"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_... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | restore | 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: ... | mongobackup/backups.py | 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_user_files=False):
"""
Runs mongorestore with source data from the provided .tbz backup, using
t... | [
"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",
... | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L97-L132 | [
"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... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | mongodump | 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. | mongobackup/backups.py | 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):
""" 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",
"."
] | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L135-L152 | [
"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... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | mongorestore | 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... | mongobackup/backups.py | 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):
""" 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
... | [
"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",... | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L155-L176 | [
"def",
"mongorestore",
"(",
"mongo_user",
",",
"mongo_password",
",",
"backup_directory_path",
",",
"drop_database",
"=",
"False",
",",
"silent",
"=",
"False",
")",
":",
"if",
"not",
"path",
".",
"exists",
"(",
"backup_directory_path",
")",
":",
"raise",
"Exce... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | get_backup_file_time_tag | Returns a datetime object computed from a file name string, with
formatting based on DATETIME_FORMAT. | mongobackup/backups.py | 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"):
""" 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... | [
"Returns",
"a",
"datetime",
"object",
"computed",
"from",
"a",
"file",
"name",
"string",
"with",
"formatting",
"based",
"on",
"DATETIME_FORMAT",
"."
] | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L184-L189 | [
"def",
"get_backup_file_time_tag",
"(",
"file_name",
",",
"custom_prefix",
"=",
"\"backup\"",
")",
":",
"name_string",
"=",
"file_name",
"[",
"len",
"(",
"custom_prefix",
")",
":",
"]",
"time_tag",
"=",
"name_string",
".",
"split",
"(",
"\".\"",
",",
"1",
")... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | purge_old_files | 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. | mongobackup/backups.py | 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"):
""" 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... | [
"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"... | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/backups.py#L192-L208 | [
"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... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | get_download_uri | Use setuptools to search for a package's URI
@returns: URI string | yolk/setuptools_support.py | 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):
"""
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:
... | [
"Use",
"setuptools",
"to",
"search",
"for",
"a",
"package",
"s",
"URI"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/setuptools_support.py#L50-L81 | [
"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... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | 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 | yolk/setuptools_support.py | 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():
"""
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... | [
"Return",
"list",
"of",
"all",
"installed",
"packages"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/setuptools_support.py#L83-L99 | [
"def",
"get_pkglist",
"(",
")",
":",
"dists",
"=",
"Distributions",
"(",
")",
"projects",
"=",
"[",
"]",
"for",
"(",
"dist",
",",
"_active",
")",
"in",
"dists",
".",
"get_distributions",
"(",
"\"all\"",
")",
":",
"if",
"dist",
".",
"project_name",
"not... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Router.register | Register a new handler for a specific slash command
Args:
command: Slash command
handler: Callback | slack/commands.py | 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):
"""
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 ... | [
"Register",
"a",
"new",
"handler",
"for",
"a",
"specific",
"slash",
"command"
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/commands.py#L71-L84 | [
"def",
"register",
"(",
"self",
",",
"command",
":",
"str",
",",
"handler",
":",
"Any",
")",
":",
"if",
"not",
"command",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"command",
"=",
"f\"/{command}\"",
"LOG",
".",
"info",
"(",
"\"Registering %s to %s\"",
"... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | Router.dispatch | Yields handlers matching the incoming :class:`slack.actions.Command`.
Args:
command: :class:`slack.actions.Command`
Yields:
handler | slack/commands.py | 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]:
"""
Yields handlers matching the incoming :class:`slack.actions.Command`.
Args:
command: :class:`slack.actions.Command`
Yields:
handler
"""
LOG.debug("Dispatching command %s", command["comman... | [
"Yields",
"handlers",
"matching",
"the",
"incoming",
":",
"class",
":",
"slack",
".",
"actions",
".",
"Command",
"."
] | pyslackers/slack-sansio | python | https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/commands.py#L86-L98 | [
"def",
"dispatch",
"(",
"self",
",",
"command",
":",
"Command",
")",
"->",
"Iterator",
"[",
"Any",
"]",
":",
"LOG",
".",
"debug",
"(",
"\"Dispatching command %s\"",
",",
"command",
"[",
"\"command\"",
"]",
")",
"for",
"callback",
"in",
"self",
".",
"_rou... | 068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab |
train | setpreferredapi | 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. | AnyQt/__init__.py | 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):
"""
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... | [
"Set",
"the",
"preferred",
"Qt",
"API",
"."
] | ales-erjavec/anyqt | python | https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/__init__.py#L11-L26 | [
"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",
".",
... | 07b73c5ccb8f73f70fc6566249c0c7228fc9b921 |
train | selectapi | Select an Qt API to use.
This can only be set once and before any of the Qt modules are explicitly
imported. | AnyQt/__init__.py | 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):
"""
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... | [
"Select",
"an",
"Qt",
"API",
"to",
"use",
"."
] | ales-erjavec/anyqt | python | https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/__init__.py#L29-L46 | [
"def",
"selectapi",
"(",
"api",
")",
":",
"global",
"__SELECTED_API",
",",
"USED_API",
"if",
"api",
".",
"lower",
"(",
")",
"not",
"in",
"{",
"\"pyqt4\"",
",",
"\"pyqt5\"",
",",
"\"pyside\"",
",",
"\"pyside2\"",
"}",
":",
"raise",
"ValueError",
"(",
"api... | 07b73c5ccb8f73f70fc6566249c0c7228fc9b921 |
train | get_highest_version | 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 | yolk/yolklib.py | 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):
"""
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... | [
"Returns",
"highest",
"available",
"version",
"for",
"a",
"package",
"in",
"a",
"list",
"of",
"versions",
"Uses",
"pkg_resources",
"to",
"parse",
"the",
"versions"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L154-L172 | [
"def",
"get_highest_version",
"(",
"versions",
")",
":",
"sorted_versions",
"=",
"[",
"]",
"for",
"ver",
"in",
"versions",
":",
"sorted_versions",
".",
"append",
"(",
"(",
"pkg_resources",
".",
"parse_version",
"(",
"ver",
")",
",",
"ver",
")",
")",
"sorte... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Distributions.get_distributions | 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
... | yolk/yolklib.py | 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=""):
"""
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
... | [
"Yield",
"installed",
"packages"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L49-L77 | [
"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",
"("... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Distributions.get_alpha | 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... | yolk/yolklib.py | 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=""):
"""
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... | [
"Return",
"list",
"of",
"alphabetized",
"packages"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L79-L105 | [
"def",
"get_alpha",
"(",
"self",
",",
"show",
",",
"pkg_name",
"=",
"\"\"",
",",
"version",
"=",
"\"\"",
")",
":",
"alpha_list",
"=",
"[",
"]",
"for",
"dist",
"in",
"self",
".",
"get_packages",
"(",
"show",
")",
":",
"if",
"pkg_name",
"and",
"dist",
... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Distributions.get_packages | 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 | yolk/yolklib.py | 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):
"""
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"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L107-L128 | [
"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... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Distributions.case_sensitive_name | Return case-sensitive package name given any-case package name
@param project_name: PyPI project name
@type project_name: string | yolk/yolklib.py | 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):
"""
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... | [
"Return",
"case",
"-",
"sensitive",
"package",
"name",
"given",
"any",
"-",
"case",
"package",
"name"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/yolklib.py#L130-L139 | [
"def",
"case_sensitive_name",
"(",
"self",
",",
"package_name",
")",
":",
"if",
"len",
"(",
"self",
".",
"environment",
"[",
"package_name",
"]",
")",
":",
"return",
"self",
".",
"environment",
"[",
"package_name",
"]",
"[",
"0",
"]",
".",
"project_name"
] | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | RateLimitMixin.cache_incr | Non-atomic cache increment operation. Not optimal but
consistent across different cache backends. | ratelimitbackend/backends.py | 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):
"""
Non-atomic cache increment operation. Not optimal but
consistent across different cache backends.
"""
cache.set(key, cache.get(key, 0) + 1, self.expire_after()) | [
"Non",
"-",
"atomic",
"cache",
"increment",
"operation",
".",
"Not",
"optimal",
"but",
"consistent",
"across",
"different",
"cache",
"backends",
"."
] | brutasse/django-ratelimit-backend | python | https://github.com/brutasse/django-ratelimit-backend/blob/1f8f485c139eb8067f0d821ff77df98038ab9448/ratelimitbackend/backends.py#L84-L89 | [
"def",
"cache_incr",
"(",
"self",
",",
"key",
")",
":",
"cache",
".",
"set",
"(",
"key",
",",
"cache",
".",
"get",
"(",
"key",
",",
"0",
")",
"+",
"1",
",",
"self",
".",
"expire_after",
"(",
")",
")"
] | 1f8f485c139eb8067f0d821ff77df98038ab9448 |
train | call_plugins | Call all method on plugins in list, that define it, with provided
arguments. The first response that is not None is returned. | yolk/plugins/__init__.py | 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):
"""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... | [
"Call",
"all",
"method",
"on",
"plugins",
"in",
"list",
"that",
"define",
"it",
"with",
"provided",
"arguments",
".",
"The",
"first",
"response",
"that",
"is",
"not",
"None",
"is",
"returned",
"."
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/__init__.py#L75-L87 | [
"def",
"call_plugins",
"(",
"plugins",
",",
"method",
",",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
":",
"for",
"plug",
"in",
"plugins",
":",
"func",
"=",
"getattr",
"(",
"plug",
",",
"method",
",",
"None",
")",
"if",
"func",
"is",
"None",
":",
"con... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | load_plugins | Load plugins, either builtin, others, or both. | yolk/plugins/__init__.py | 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):
"""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:
... | [
"Load",
"plugins",
"either",
"builtin",
"others",
"or",
"both",
"."
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/__init__.py#L89-L109 | [
"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",
... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | s3_connect | Returns a Boto connection to the provided S3 bucket. | mongobackup/s3.py | 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):
""" 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... | [
"Returns",
"a",
"Boto",
"connection",
"to",
"the",
"provided",
"S3",
"bucket",
"."
] | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L33-L41 | [
"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",
... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | s3_list | Lists the contents of the S3 bucket that end in .tbz and match
the passed prefix, if any. | mongobackup/s3.py | 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):
""" 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()
... | [
"Lists",
"the",
"contents",
"of",
"the",
"S3",
"bucket",
"that",
"end",
"in",
".",
"tbz",
"and",
"match",
"the",
"passed",
"prefix",
"if",
"any",
"."
] | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L49-L55 | [
"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",
"... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | s3_download | 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. | mongobackup/s3.py | 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):
""" 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... | [
"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",... | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L58-L74 | [
"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",
",",
... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | s3_upload | Uploads the to Amazon S3 the contents of the provided file, keyed
with the name of the file. | mongobackup/s3.py | 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):
""" 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... | [
"Uploads",
"the",
"to",
"Amazon",
"S3",
"the",
"contents",
"of",
"the",
"provided",
"file",
"keyed",
"with",
"the",
"name",
"of",
"the",
"file",
"."
] | zagaran/mongobackup | python | https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/s3.py#L77-L86 | [
"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... | d090d0cca44ecd066974c4de80edca5f26b7eeea |
train | fix_pyqt5_QGraphicsItem_itemChange | Attempt to remedy:
https://www.riverbankcomputing.com/pipermail/pyqt/2016-February/037015.html | AnyQt/_fixes.py | 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():
"""
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... | [
"Attempt",
"to",
"remedy",
":",
"https",
":",
"//",
"www",
".",
"riverbankcomputing",
".",
"com",
"/",
"pipermail",
"/",
"pyqt",
"/",
"2016",
"-",
"February",
"/",
"037015",
".",
"html"
] | ales-erjavec/anyqt | python | https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/_fixes.py#L4-L49 | [
"def",
"fix_pyqt5_QGraphicsItem_itemChange",
"(",
")",
":",
"from",
"PyQt5",
".",
"QtWidgets",
"import",
"QGraphicsObject",
",",
"QGraphicsItem",
"class",
"Obj",
"(",
"QGraphicsObject",
")",
":",
"def",
"itemChange",
"(",
"self",
",",
"change",
",",
"value",
")"... | 07b73c5ccb8f73f70fc6566249c0c7228fc9b921 |
train | setup_opt_parser | Setup the optparser
@returns: opt_parser.OptionParser | yolk/cli.py | 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():
"""
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=
... | [
"Setup",
"the",
"optparser"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L928-L1063 | [
"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... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | validate_pypi_opts | Check parse options that require pkg_spec
@returns: pkg_spec | yolk/cli.py | 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):
"""
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,
... | [
"Check",
"parse",
"options",
"that",
"require",
"pkg_spec"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L1075-L1093 | [
"def",
"validate_pypi_opts",
"(",
"opt_parser",
")",
":",
"(",
"options",
",",
"remaining_args",
")",
"=",
"opt_parser",
".",
"parse_args",
"(",
")",
"options_pkg_specs",
"=",
"[",
"options",
".",
"versions_available",
",",
"options",
".",
"query_metadata_pypi",
... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | StdOut.write | 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 | yolk/cli.py | 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):
"""
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"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L75-L89 | [
"def",
"write",
"(",
"self",
",",
"inline",
")",
":",
"frame",
"=",
"inspect",
".",
"currentframe",
"(",
")",
".",
"f_back",
"if",
"frame",
":",
"mod",
"=",
"frame",
".",
"f_globals",
".",
"get",
"(",
"'__name__'",
")",
"else",
":",
"mod",
"=",
"sy... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Yolk.get_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` | yolk/cli.py | 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):
"""
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... | [
"Return",
"plugin",
"object",
"if",
"CLI",
"option",
"is",
"activated",
"and",
"method",
"exists"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L121-L142 | [
"def",
"get_plugin",
"(",
"self",
",",
"method",
")",
":",
"all_plugins",
"=",
"[",
"]",
"for",
"entry_point",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"'yolk.plugins'",
")",
":",
"plugin_obj",
"=",
"entry_point",
".",
"load",
"(",
")",
"plugin"... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Yolk.set_log_level | Set log level according to command-line options
@returns: logger object | yolk/cli.py | 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):
"""
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:
... | [
"Set",
"log",
"level",
"according",
"to",
"command",
"-",
"line",
"options"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L144-L158 | [
"def",
"set_log_level",
"(",
"self",
")",
":",
"if",
"self",
".",
"options",
".",
"debug",
":",
"self",
".",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"elif",
"self",
".",
"options",
".",
"quiet",
":",
"self",
".",
"logger",
".",
... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Yolk.run | Perform actions based on CLI options
@returns: status code | yolk/cli.py | 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):
"""
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 ... | [
"Perform",
"actions",
"based",
"on",
"CLI",
"options"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L160-L215 | [
"def",
"run",
"(",
"self",
")",
":",
"opt_parser",
"=",
"setup_opt_parser",
"(",
")",
"(",
"self",
".",
"options",
",",
"remaining_args",
")",
"=",
"opt_parser",
".",
"parse_args",
"(",
")",
"logger",
"=",
"self",
".",
"set_log_level",
"(",
")",
"pkg_spe... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Yolk.show_updates | 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 | yolk/cli.py | 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):
"""
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... | [
"Check",
"installed",
"packages",
"for",
"available",
"updates",
"on",
"PyPI"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L236-L279 | [
"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",... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Yolk.show_distributions | 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 | yolk/cli.py | 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 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... | [
"Show",
"list",
"of",
"installed",
"activated",
"OR",
"non",
"-",
"activated",
"packages"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L282-L344 | [
"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\"",
... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Yolk.print_metadata | 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... | yolk/cli.py | 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):
"""
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
... | [
"Print",
"out",
"formatted",
"metadata",
"@param",
"metadata",
":",
"package",
"s",
"metadata",
"@type",
"metadata",
":",
"pkg_resources",
"Distribution",
"obj"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L347-L411 | [
"def",
"print_metadata",
"(",
"self",
",",
"metadata",
",",
"develop",
",",
"active",
",",
"installed_by",
")",
":",
"show_metadata",
"=",
"self",
".",
"options",
".",
"metadata",
"if",
"self",
".",
"options",
".",
"fields",
":",
"fields",
"=",
"self",
"... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Yolk.show_deps | Show dependencies for package(s)
@returns: 0 - sucess 1 - No dependency info supplied | yolk/cli.py | 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):
"""
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... | [
"Show",
"dependencies",
"for",
"package",
"(",
"s",
")"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L413-L439 | [
"def",
"show_deps",
"(",
"self",
")",
":",
"pkgs",
"=",
"pkg_resources",
".",
"Environment",
"(",
")",
"for",
"pkg",
"in",
"pkgs",
"[",
"self",
".",
"project_name",
"]",
":",
"if",
"not",
"self",
".",
"version",
":",
"print",
"(",
"pkg",
".",
"projec... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
train | Yolk.show_pypi_changelog | Show detailed PyPI ChangeLog for the last `hours`
@returns: 0 = sucess or 1 if failed to retrieve from XML-RPC server | yolk/cli.py | 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):
"""
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... | [
"Show",
"detailed",
"PyPI",
"ChangeLog",
"for",
"the",
"last",
"hours"
] | cakebread/yolk | python | https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/cli.py#L441-L469 | [
"def",
"show_pypi_changelog",
"(",
"self",
")",
":",
"hours",
"=",
"self",
".",
"options",
".",
"show_pypi_changelog",
"if",
"not",
"hours",
".",
"isdigit",
"(",
")",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"Error: You must supply an integer.\"",
")",... | ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.