repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
ppinard/matplotlib-colorbar
matplotlib_colorbar/colorbar.py
ColorbarCalculator.calculate_colorbar
def calculate_colorbar(self): """ Returns the positions and colors of all intervals inside the colorbar. """ self._base._process_values() self._base._find_range() X, Y = self._base._mesh() C = self._base._values[:, np.newaxis] return X, Y, C
python
def calculate_colorbar(self): """ Returns the positions and colors of all intervals inside the colorbar. """ self._base._process_values() self._base._find_range() X, Y = self._base._mesh() C = self._base._values[:, np.newaxis] return X, Y, C
[ "def", "calculate_colorbar", "(", "self", ")", ":", "self", ".", "_base", ".", "_process_values", "(", ")", "self", ".", "_base", ".", "_find_range", "(", ")", "X", ",", "Y", "=", "self", ".", "_base", ".", "_mesh", "(", ")", "C", "=", "self", ".",...
Returns the positions and colors of all intervals inside the colorbar.
[ "Returns", "the", "positions", "and", "colors", "of", "all", "intervals", "inside", "the", "colorbar", "." ]
train
https://github.com/ppinard/matplotlib-colorbar/blob/d53748c54dd18ba5183bff8da3f11cfd107282e6/matplotlib_colorbar/colorbar.py#L152-L160
ppinard/matplotlib-colorbar
matplotlib_colorbar/colorbar.py
ColorbarCalculator.calculate_ticks
def calculate_ticks(self): """ Returns the sequence of ticks (colorbar data locations), ticklabels (strings), and the corresponding offset string. """ current_version = packaging.version.parse(matplotlib.__version__) critical_version = packaging.version.parse('3.0.0') ...
python
def calculate_ticks(self): """ Returns the sequence of ticks (colorbar data locations), ticklabels (strings), and the corresponding offset string. """ current_version = packaging.version.parse(matplotlib.__version__) critical_version = packaging.version.parse('3.0.0') ...
[ "def", "calculate_ticks", "(", "self", ")", ":", "current_version", "=", "packaging", ".", "version", ".", "parse", "(", "matplotlib", ".", "__version__", ")", "critical_version", "=", "packaging", ".", "version", ".", "parse", "(", "'3.0.0'", ")", "if", "cu...
Returns the sequence of ticks (colorbar data locations), ticklabels (strings), and the corresponding offset string.
[ "Returns", "the", "sequence", "of", "ticks", "(", "colorbar", "data", "locations", ")", "ticklabels", "(", "strings", ")", "and", "the", "corresponding", "offset", "string", "." ]
train
https://github.com/ppinard/matplotlib-colorbar/blob/d53748c54dd18ba5183bff8da3f11cfd107282e6/matplotlib_colorbar/colorbar.py#L162-L174
aheadley/python-crunchyroll
crunchyroll/apis/scraper.py
ScraperApi.get_media_formats
def get_media_formats(self, media_id): """CR doesn't seem to provide the video_format and video_quality params through any of the APIs so we have to scrape the video page """ url = (SCRAPER.API_URL + 'media-' + media_id).format( protocol=SCRAPER.PROTOCOL_INSECURE) for...
python
def get_media_formats(self, media_id): """CR doesn't seem to provide the video_format and video_quality params through any of the APIs so we have to scrape the video page """ url = (SCRAPER.API_URL + 'media-' + media_id).format( protocol=SCRAPER.PROTOCOL_INSECURE) for...
[ "def", "get_media_formats", "(", "self", ",", "media_id", ")", ":", "url", "=", "(", "SCRAPER", ".", "API_URL", "+", "'media-'", "+", "media_id", ")", ".", "format", "(", "protocol", "=", "SCRAPER", ".", "PROTOCOL_INSECURE", ")", "format_pattern", "=", "re...
CR doesn't seem to provide the video_format and video_quality params through any of the APIs so we have to scrape the video page
[ "CR", "doesn", "t", "seem", "to", "provide", "the", "video_format", "and", "video_quality", "params", "through", "any", "of", "the", "APIs", "so", "we", "have", "to", "scrape", "the", "video", "page" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/scraper.py#L34-L53
vberlier/nbtlib
nbtlib/literal/parser.py
parse_nbt
def parse_nbt(literal): """Parse a literal nbt string and return the resulting tag.""" parser = Parser(tokenize(literal)) tag = parser.parse() cursor = parser.token_span[1] leftover = literal[cursor:] if leftover.strip(): parser.token_span = cursor, cursor + len(leftover) raise ...
python
def parse_nbt(literal): """Parse a literal nbt string and return the resulting tag.""" parser = Parser(tokenize(literal)) tag = parser.parse() cursor = parser.token_span[1] leftover = literal[cursor:] if leftover.strip(): parser.token_span = cursor, cursor + len(leftover) raise ...
[ "def", "parse_nbt", "(", "literal", ")", ":", "parser", "=", "Parser", "(", "tokenize", "(", "literal", ")", ")", "tag", "=", "parser", ".", "parse", "(", ")", "cursor", "=", "parser", ".", "token_span", "[", "1", "]", "leftover", "=", "literal", "["...
Parse a literal nbt string and return the resulting tag.
[ "Parse", "a", "literal", "nbt", "string", "and", "return", "the", "resulting", "tag", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L85-L96
vberlier/nbtlib
nbtlib/literal/parser.py
tokenize
def tokenize(string): """Match and yield all the tokens of the input string.""" for match in TOKENS_REGEX.finditer(string): yield Token(match.lastgroup, match.group().strip(), match.span())
python
def tokenize(string): """Match and yield all the tokens of the input string.""" for match in TOKENS_REGEX.finditer(string): yield Token(match.lastgroup, match.group().strip(), match.span())
[ "def", "tokenize", "(", "string", ")", ":", "for", "match", "in", "TOKENS_REGEX", ".", "finditer", "(", "string", ")", ":", "yield", "Token", "(", "match", ".", "lastgroup", ",", "match", ".", "group", "(", ")", ".", "strip", "(", ")", ",", "match", ...
Match and yield all the tokens of the input string.
[ "Match", "and", "yield", "all", "the", "tokens", "of", "the", "input", "string", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L104-L107
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.next
def next(self): """Move to the next token in the token stream.""" self.current_token = next(self.token_stream, None) if self.current_token is None: self.token_span = self.token_span[1], self.token_span[1] raise self.error('Unexpected end of input') self.token_span...
python
def next(self): """Move to the next token in the token stream.""" self.current_token = next(self.token_stream, None) if self.current_token is None: self.token_span = self.token_span[1], self.token_span[1] raise self.error('Unexpected end of input') self.token_span...
[ "def", "next", "(", "self", ")", ":", "self", ".", "current_token", "=", "next", "(", "self", ".", "token_stream", ",", "None", ")", "if", "self", ".", "current_token", "is", "None", ":", "self", ".", "token_span", "=", "self", ".", "token_span", "[", ...
Move to the next token in the token stream.
[ "Move", "to", "the", "next", "token", "in", "the", "token", "stream", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L133-L140
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.parse
def parse(self): """Parse and return an nbt literal from the token stream.""" token_type = self.current_token.type.lower() handler = getattr(self, f'parse_{token_type}', None) if handler is None: raise self.error(f'Invalid literal {self.current_token.value!r}') return...
python
def parse(self): """Parse and return an nbt literal from the token stream.""" token_type = self.current_token.type.lower() handler = getattr(self, f'parse_{token_type}', None) if handler is None: raise self.error(f'Invalid literal {self.current_token.value!r}') return...
[ "def", "parse", "(", "self", ")", ":", "token_type", "=", "self", ".", "current_token", ".", "type", ".", "lower", "(", ")", "handler", "=", "getattr", "(", "self", ",", "f'parse_{token_type}'", ",", "None", ")", "if", "handler", "is", "None", ":", "ra...
Parse and return an nbt literal from the token stream.
[ "Parse", "and", "return", "an", "nbt", "literal", "from", "the", "token", "stream", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L142-L148
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.parse_number
def parse_number(self): """Parse a number from the token stream.""" value = self.current_token.value suffix = value[-1].lower() try: if suffix in NUMBER_SUFFIXES: return NUMBER_SUFFIXES[suffix](value[:-1]) return Double(value) if '.' in value else...
python
def parse_number(self): """Parse a number from the token stream.""" value = self.current_token.value suffix = value[-1].lower() try: if suffix in NUMBER_SUFFIXES: return NUMBER_SUFFIXES[suffix](value[:-1]) return Double(value) if '.' in value else...
[ "def", "parse_number", "(", "self", ")", ":", "value", "=", "self", ".", "current_token", ".", "value", "suffix", "=", "value", "[", "-", "1", "]", ".", "lower", "(", ")", "try", ":", "if", "suffix", "in", "NUMBER_SUFFIXES", ":", "return", "NUMBER_SUFF...
Parse a number from the token stream.
[ "Parse", "a", "number", "from", "the", "token", "stream", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L154-L164
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.parse_string
def parse_string(self): """Parse a regular unquoted string from the token stream.""" aliased_value = LITERAL_ALIASES.get(self.current_token.value.lower()) if aliased_value is not None: return aliased_value return String(self.current_token.value)
python
def parse_string(self): """Parse a regular unquoted string from the token stream.""" aliased_value = LITERAL_ALIASES.get(self.current_token.value.lower()) if aliased_value is not None: return aliased_value return String(self.current_token.value)
[ "def", "parse_string", "(", "self", ")", ":", "aliased_value", "=", "LITERAL_ALIASES", ".", "get", "(", "self", ".", "current_token", ".", "value", ".", "lower", "(", ")", ")", "if", "aliased_value", "is", "not", "None", ":", "return", "aliased_value", "re...
Parse a regular unquoted string from the token stream.
[ "Parse", "a", "regular", "unquoted", "string", "from", "the", "token", "stream", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L166-L171
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.collect_tokens_until
def collect_tokens_until(self, token_type): """Yield the item tokens in a comma-separated tag collection.""" self.next() if self.current_token.type == token_type: return while True: yield self.current_token self.next() if self.current_tok...
python
def collect_tokens_until(self, token_type): """Yield the item tokens in a comma-separated tag collection.""" self.next() if self.current_token.type == token_type: return while True: yield self.current_token self.next() if self.current_tok...
[ "def", "collect_tokens_until", "(", "self", ",", "token_type", ")", ":", "self", ".", "next", "(", ")", "if", "self", ".", "current_token", ".", "type", "==", "token_type", ":", "return", "while", "True", ":", "yield", "self", ".", "current_token", "self",...
Yield the item tokens in a comma-separated tag collection.
[ "Yield", "the", "item", "tokens", "in", "a", "comma", "-", "separated", "tag", "collection", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L173-L189
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.parse_compound
def parse_compound(self): """Parse a compound from the token stream.""" compound_tag = Compound() for token in self.collect_tokens_until('CLOSE_COMPOUND'): item_key = token.value if token.type not in ('NUMBER', 'STRING', 'QUOTED_STRING'): raise self.error...
python
def parse_compound(self): """Parse a compound from the token stream.""" compound_tag = Compound() for token in self.collect_tokens_until('CLOSE_COMPOUND'): item_key = token.value if token.type not in ('NUMBER', 'STRING', 'QUOTED_STRING'): raise self.error...
[ "def", "parse_compound", "(", "self", ")", ":", "compound_tag", "=", "Compound", "(", ")", "for", "token", "in", "self", ".", "collect_tokens_until", "(", "'CLOSE_COMPOUND'", ")", ":", "item_key", "=", "token", ".", "value", "if", "token", ".", "type", "no...
Parse a compound from the token stream.
[ "Parse", "a", "compound", "from", "the", "token", "stream", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L191-L208
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.array_items
def array_items(self, number_type, *, number_suffix=''): """Parse and yield array items from the token stream.""" for token in self.collect_tokens_until('CLOSE_BRACKET'): is_number = token.type == 'NUMBER' value = token.value.lower() if not (is_number and value.endswi...
python
def array_items(self, number_type, *, number_suffix=''): """Parse and yield array items from the token stream.""" for token in self.collect_tokens_until('CLOSE_BRACKET'): is_number = token.type == 'NUMBER' value = token.value.lower() if not (is_number and value.endswi...
[ "def", "array_items", "(", "self", ",", "number_type", ",", "*", ",", "number_suffix", "=", "''", ")", ":", "for", "token", "in", "self", ".", "collect_tokens_until", "(", "'CLOSE_BRACKET'", ")", ":", "is_number", "=", "token", ".", "type", "==", "'NUMBER'...
Parse and yield array items from the token stream.
[ "Parse", "and", "yield", "array", "items", "from", "the", "token", "stream", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L210-L218
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.parse_list
def parse_list(self): """Parse a list from the token stream.""" try: return List([self.parse() for _ in self.collect_tokens_until('CLOSE_BRACKET')]) except IncompatibleItemType as exc: raise self.error(f'Item {str(exc.item)!r} is not a ' ...
python
def parse_list(self): """Parse a list from the token stream.""" try: return List([self.parse() for _ in self.collect_tokens_until('CLOSE_BRACKET')]) except IncompatibleItemType as exc: raise self.error(f'Item {str(exc.item)!r} is not a ' ...
[ "def", "parse_list", "(", "self", ")", ":", "try", ":", "return", "List", "(", "[", "self", ".", "parse", "(", ")", "for", "_", "in", "self", ".", "collect_tokens_until", "(", "'CLOSE_BRACKET'", ")", "]", ")", "except", "IncompatibleItemType", "as", "exc...
Parse a list from the token stream.
[ "Parse", "a", "list", "from", "the", "token", "stream", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L232-L239
vberlier/nbtlib
nbtlib/literal/parser.py
Parser.unquote_string
def unquote_string(self, string): """Return the unquoted value of a quoted string.""" value = string[1:-1] forbidden_sequences = {ESCAPE_SUBS[STRING_QUOTES[string[0]]]} valid_sequences = set(ESCAPE_SEQUENCES) - forbidden_sequences for seq in ESCAPE_REGEX.findall(value): ...
python
def unquote_string(self, string): """Return the unquoted value of a quoted string.""" value = string[1:-1] forbidden_sequences = {ESCAPE_SUBS[STRING_QUOTES[string[0]]]} valid_sequences = set(ESCAPE_SEQUENCES) - forbidden_sequences for seq in ESCAPE_REGEX.findall(value): ...
[ "def", "unquote_string", "(", "self", ",", "string", ")", ":", "value", "=", "string", "[", "1", ":", "-", "1", "]", "forbidden_sequences", "=", "{", "ESCAPE_SUBS", "[", "STRING_QUOTES", "[", "string", "[", "0", "]", "]", "]", "}", "valid_sequences", "...
Return the unquoted value of a quoted string.
[ "Return", "the", "unquoted", "value", "of", "a", "quoted", "string", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/parser.py#L245-L259
tulsawebdevs/django-multi-gtfs
multigtfs/compat.py
opener_from_zipfile
def opener_from_zipfile(zipfile): """ Returns a function that will open a file in a zipfile by name. For Python3 compatibility, the raw file will be converted to text. """ def opener(filename): inner_file = zipfile.open(filename) if PY3: from io import TextIOWrapper ...
python
def opener_from_zipfile(zipfile): """ Returns a function that will open a file in a zipfile by name. For Python3 compatibility, the raw file will be converted to text. """ def opener(filename): inner_file = zipfile.open(filename) if PY3: from io import TextIOWrapper ...
[ "def", "opener_from_zipfile", "(", "zipfile", ")", ":", "def", "opener", "(", "filename", ")", ":", "inner_file", "=", "zipfile", ".", "open", "(", "filename", ")", "if", "PY3", ":", "from", "io", "import", "TextIOWrapper", "return", "TextIOWrapper", "(", ...
Returns a function that will open a file in a zipfile by name. For Python3 compatibility, the raw file will be converted to text.
[ "Returns", "a", "function", "that", "will", "open", "a", "file", "in", "a", "zipfile", "by", "name", "." ]
train
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/compat.py#L73-L88
tulsawebdevs/django-multi-gtfs
multigtfs/compat.py
write_text_rows
def write_text_rows(writer, rows): '''Write CSV row data which may include text.''' for row in rows: try: writer.writerow(row) except UnicodeEncodeError: # Python 2 csv does badly with unicode outside of ASCII new_row = [] for item in row: ...
python
def write_text_rows(writer, rows): '''Write CSV row data which may include text.''' for row in rows: try: writer.writerow(row) except UnicodeEncodeError: # Python 2 csv does badly with unicode outside of ASCII new_row = [] for item in row: ...
[ "def", "write_text_rows", "(", "writer", ",", "rows", ")", ":", "for", "row", "in", "rows", ":", "try", ":", "writer", ".", "writerow", "(", "row", ")", "except", "UnicodeEncodeError", ":", "# Python 2 csv does badly with unicode outside of ASCII", "new_row", "=",...
Write CSV row data which may include text.
[ "Write", "CSV", "row", "data", "which", "may", "include", "text", "." ]
train
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/compat.py#L91-L104
vberlier/nbtlib
nbtlib/literal/serializer.py
serialize_tag
def serialize_tag(tag, *, indent=None, compact=False, quote=None): """Serialize an nbt tag to its literal representation.""" serializer = Serializer(indent=indent, compact=compact, quote=quote) return serializer.serialize(tag)
python
def serialize_tag(tag, *, indent=None, compact=False, quote=None): """Serialize an nbt tag to its literal representation.""" serializer = Serializer(indent=indent, compact=compact, quote=quote) return serializer.serialize(tag)
[ "def", "serialize_tag", "(", "tag", ",", "*", ",", "indent", "=", "None", ",", "compact", "=", "False", ",", "quote", "=", "None", ")", ":", "serializer", "=", "Serializer", "(", "indent", "=", "indent", ",", "compact", "=", "compact", ",", "quote", ...
Serialize an nbt tag to its literal representation.
[ "Serialize", "an", "nbt", "tag", "to", "its", "literal", "representation", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L48-L51
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.depth
def depth(self): """Increase the level of indentation by one.""" if self.indentation is None: yield else: previous = self.previous_indent self.previous_indent = self.indent self.indent += self.indentation yield self.indent =...
python
def depth(self): """Increase the level of indentation by one.""" if self.indentation is None: yield else: previous = self.previous_indent self.previous_indent = self.indent self.indent += self.indentation yield self.indent =...
[ "def", "depth", "(", "self", ")", ":", "if", "self", ".", "indentation", "is", "None", ":", "yield", "else", ":", "previous", "=", "self", ".", "previous_indent", "self", ".", "previous_indent", "=", "self", ".", "indent", "self", ".", "indent", "+=", ...
Increase the level of indentation by one.
[ "Increase", "the", "level", "of", "indentation", "by", "one", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L71-L81
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.should_expand
def should_expand(self, tag): """Return whether the specified tag should be expanded.""" return self.indentation is not None and tag and ( not self.previous_indent or ( tag.serializer == 'list' and tag.subtype.serializer in ('array', 'list', 'compound') ...
python
def should_expand(self, tag): """Return whether the specified tag should be expanded.""" return self.indentation is not None and tag and ( not self.previous_indent or ( tag.serializer == 'list' and tag.subtype.serializer in ('array', 'list', 'compound') ...
[ "def", "should_expand", "(", "self", ",", "tag", ")", ":", "return", "self", ".", "indentation", "is", "not", "None", "and", "tag", "and", "(", "not", "self", ".", "previous_indent", "or", "(", "tag", ".", "serializer", "==", "'list'", "and", "tag", "....
Return whether the specified tag should be expanded.
[ "Return", "whether", "the", "specified", "tag", "should", "be", "expanded", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L83-L92
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.escape_string
def escape_string(self, string): """Return the escaped literal representation of an nbt string.""" if self.quote: quote = self.quote else: found = QUOTE_REGEX.search(string) quote = STRING_QUOTES[found.group()] if found else next(iter(STRING_QUOTES)) ...
python
def escape_string(self, string): """Return the escaped literal representation of an nbt string.""" if self.quote: quote = self.quote else: found = QUOTE_REGEX.search(string) quote = STRING_QUOTES[found.group()] if found else next(iter(STRING_QUOTES)) ...
[ "def", "escape_string", "(", "self", ",", "string", ")", ":", "if", "self", ".", "quote", ":", "quote", "=", "self", ".", "quote", "else", ":", "found", "=", "QUOTE_REGEX", ".", "search", "(", "string", ")", "quote", "=", "STRING_QUOTES", "[", "found",...
Return the escaped literal representation of an nbt string.
[ "Return", "the", "escaped", "literal", "representation", "of", "an", "nbt", "string", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L101-L113
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.stringify_compound_key
def stringify_compound_key(self, key): """Escape the compound key if it can't be represented unquoted.""" if UNQUOTED_COMPOUND_KEY.match(key): return key return self.escape_string(key)
python
def stringify_compound_key(self, key): """Escape the compound key if it can't be represented unquoted.""" if UNQUOTED_COMPOUND_KEY.match(key): return key return self.escape_string(key)
[ "def", "stringify_compound_key", "(", "self", ",", "key", ")", ":", "if", "UNQUOTED_COMPOUND_KEY", ".", "match", "(", "key", ")", ":", "return", "key", "return", "self", ".", "escape_string", "(", "key", ")" ]
Escape the compound key if it can't be represented unquoted.
[ "Escape", "the", "compound", "key", "if", "it", "can", "t", "be", "represented", "unquoted", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L115-L119
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.serialize
def serialize(self, tag): """Return the literal representation of a tag.""" handler = getattr(self, f'serialize_{tag.serializer}', None) if handler is None: raise TypeError(f'Can\'t serialize {type(tag)!r} instance') return handler(tag)
python
def serialize(self, tag): """Return the literal representation of a tag.""" handler = getattr(self, f'serialize_{tag.serializer}', None) if handler is None: raise TypeError(f'Can\'t serialize {type(tag)!r} instance') return handler(tag)
[ "def", "serialize", "(", "self", ",", "tag", ")", ":", "handler", "=", "getattr", "(", "self", ",", "f'serialize_{tag.serializer}'", ",", "None", ")", "if", "handler", "is", "None", ":", "raise", "TypeError", "(", "f'Can\\'t serialize {type(tag)!r} instance'", "...
Return the literal representation of a tag.
[ "Return", "the", "literal", "representation", "of", "a", "tag", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L121-L126
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.serialize_numeric
def serialize_numeric(self, tag): """Return the literal representation of a numeric tag.""" str_func = int.__str__ if isinstance(tag, int) else float.__str__ return str_func(tag) + tag.suffix
python
def serialize_numeric(self, tag): """Return the literal representation of a numeric tag.""" str_func = int.__str__ if isinstance(tag, int) else float.__str__ return str_func(tag) + tag.suffix
[ "def", "serialize_numeric", "(", "self", ",", "tag", ")", ":", "str_func", "=", "int", ".", "__str__", "if", "isinstance", "(", "tag", ",", "int", ")", "else", "float", ".", "__str__", "return", "str_func", "(", "tag", ")", "+", "tag", ".", "suffix" ]
Return the literal representation of a numeric tag.
[ "Return", "the", "literal", "representation", "of", "a", "numeric", "tag", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L128-L131
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.serialize_array
def serialize_array(self, tag): """Return the literal representation of an array tag.""" elements = self.comma.join(f'{el}{tag.item_suffix}' for el in tag) return f'[{tag.array_prefix}{self.semicolon}{elements}]'
python
def serialize_array(self, tag): """Return the literal representation of an array tag.""" elements = self.comma.join(f'{el}{tag.item_suffix}' for el in tag) return f'[{tag.array_prefix}{self.semicolon}{elements}]'
[ "def", "serialize_array", "(", "self", ",", "tag", ")", ":", "elements", "=", "self", ".", "comma", ".", "join", "(", "f'{el}{tag.item_suffix}'", "for", "el", "in", "tag", ")", "return", "f'[{tag.array_prefix}{self.semicolon}{elements}]'" ]
Return the literal representation of an array tag.
[ "Return", "the", "literal", "representation", "of", "an", "array", "tag", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L133-L136
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.serialize_list
def serialize_list(self, tag): """Return the literal representation of a list tag.""" separator, fmt = self.comma, '[{}]' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.join(map(sel...
python
def serialize_list(self, tag): """Return the literal representation of a list tag.""" separator, fmt = self.comma, '[{}]' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.join(map(sel...
[ "def", "serialize_list", "(", "self", ",", "tag", ")", ":", "separator", ",", "fmt", "=", "self", ".", "comma", ",", "'[{}]'", "with", "self", ".", "depth", "(", ")", ":", "if", "self", ".", "should_expand", "(", "tag", ")", ":", "separator", ",", ...
Return the literal representation of a list tag.
[ "Return", "the", "literal", "representation", "of", "a", "list", "tag", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L142-L150
vberlier/nbtlib
nbtlib/literal/serializer.py
Serializer.serialize_compound
def serialize_compound(self, tag): """Return the literal representation of a compound tag.""" separator, fmt = self.comma, '{{{}}}' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.jo...
python
def serialize_compound(self, tag): """Return the literal representation of a compound tag.""" separator, fmt = self.comma, '{{{}}}' with self.depth(): if self.should_expand(tag): separator, fmt = self.expand(separator, fmt) return fmt.format(separator.jo...
[ "def", "serialize_compound", "(", "self", ",", "tag", ")", ":", "separator", ",", "fmt", "=", "self", ".", "comma", ",", "'{{{}}}'", "with", "self", ".", "depth", "(", ")", ":", "if", "self", ".", "should_expand", "(", "tag", ")", ":", "separator", "...
Return the literal representation of a compound tag.
[ "Return", "the", "literal", "representation", "of", "a", "compound", "tag", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/literal/serializer.py#L152-L163
tulsawebdevs/django-multi-gtfs
multigtfs/models/base.py
BaseQuerySet.populated_column_map
def populated_column_map(self): '''Return the _column_map without unused optional fields''' column_map = [] cls = self.model for csv_name, field_pattern in cls._column_map: # Separate the local field name from foreign columns if '__' in field_pattern: ...
python
def populated_column_map(self): '''Return the _column_map without unused optional fields''' column_map = [] cls = self.model for csv_name, field_pattern in cls._column_map: # Separate the local field name from foreign columns if '__' in field_pattern: ...
[ "def", "populated_column_map", "(", "self", ")", ":", "column_map", "=", "[", "]", "cls", "=", "self", ".", "model", "for", "csv_name", ",", "field_pattern", "in", "cls", ".", "_column_map", ":", "# Separate the local field name from foreign columns", "if", "'__'"...
Return the _column_map without unused optional fields
[ "Return", "the", "_column_map", "without", "unused", "optional", "fields" ]
train
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/base.py#L37-L62
tulsawebdevs/django-multi-gtfs
multigtfs/models/base.py
BaseManager.in_feed
def in_feed(self, feed): '''Return the objects in the target feed''' kwargs = {self.model._rel_to_feed: feed} return self.filter(**kwargs)
python
def in_feed(self, feed): '''Return the objects in the target feed''' kwargs = {self.model._rel_to_feed: feed} return self.filter(**kwargs)
[ "def", "in_feed", "(", "self", ",", "feed", ")", ":", "kwargs", "=", "{", "self", ".", "model", ".", "_rel_to_feed", ":", "feed", "}", "return", "self", ".", "filter", "(", "*", "*", "kwargs", ")" ]
Return the objects in the target feed
[ "Return", "the", "objects", "in", "the", "target", "feed" ]
train
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/base.py#L70-L73
tulsawebdevs/django-multi-gtfs
multigtfs/models/base.py
Base.import_txt
def import_txt(cls, txt_file, feed, filter_func=None): '''Import from the GTFS text file''' # Setup the conversion from GTFS to Django Format # Conversion functions def no_convert(value): return value def date_convert(value): return datetime.strptime(value, '%Y%m%d') d...
python
def import_txt(cls, txt_file, feed, filter_func=None): '''Import from the GTFS text file''' # Setup the conversion from GTFS to Django Format # Conversion functions def no_convert(value): return value def date_convert(value): return datetime.strptime(value, '%Y%m%d') d...
[ "def", "import_txt", "(", "cls", ",", "txt_file", ",", "feed", ",", "filter_func", "=", "None", ")", ":", "# Setup the conversion from GTFS to Django Format", "# Conversion functions", "def", "no_convert", "(", "value", ")", ":", "return", "value", "def", "date_conv...
Import from the GTFS text file
[ "Import", "from", "the", "GTFS", "text", "file" ]
train
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/base.py#L108-L300
tulsawebdevs/django-multi-gtfs
multigtfs/models/base.py
Base.export_txt
def export_txt(cls, feed): '''Export records as a GTFS comma-separated file''' objects = cls.objects.in_feed(feed) # If no records, return None if not objects.exists(): return # Get the columns used in the dataset column_map = objects.populated_column_map() ...
python
def export_txt(cls, feed): '''Export records as a GTFS comma-separated file''' objects = cls.objects.in_feed(feed) # If no records, return None if not objects.exists(): return # Get the columns used in the dataset column_map = objects.populated_column_map() ...
[ "def", "export_txt", "(", "cls", ",", "feed", ")", ":", "objects", "=", "cls", ".", "objects", ".", "in_feed", "(", "feed", ")", "# If no records, return None", "if", "not", "objects", ".", "exists", "(", ")", ":", "return", "# Get the columns used in the data...
Export records as a GTFS comma-separated file
[ "Export", "records", "as", "a", "GTFS", "comma", "-", "separated", "file" ]
train
https://github.com/tulsawebdevs/django-multi-gtfs/blob/8c442bfb67e87566c24a7364d8fa0aacd4a0a652/multigtfs/models/base.py#L303-L410
aheadley/python-crunchyroll
crunchyroll/apis/android.py
make_android_api_method
def make_android_api_method(req_method, secure=True, version=0): """Turn an AndroidApi's method into a function that builds the request, sends it, then passes the response to the actual method. Should be used as a decorator. """ def outer_func(func): def inner_func(self, **kwargs): ...
python
def make_android_api_method(req_method, secure=True, version=0): """Turn an AndroidApi's method into a function that builds the request, sends it, then passes the response to the actual method. Should be used as a decorator. """ def outer_func(func): def inner_func(self, **kwargs): ...
[ "def", "make_android_api_method", "(", "req_method", ",", "secure", "=", "True", ",", "version", "=", "0", ")", ":", "def", "outer_func", "(", "func", ")", ":", "def", "inner_func", "(", "self", ",", "*", "*", "kwargs", ")", ":", "req_url", "=", "self"...
Turn an AndroidApi's method into a function that builds the request, sends it, then passes the response to the actual method. Should be used as a decorator.
[ "Turn", "an", "AndroidApi", "s", "method", "into", "a", "function", "that", "builds", "the", "request", "sends", "it", "then", "passes", "the", "response", "to", "the", "actual", "method", ".", "Should", "be", "used", "as", "a", "decorator", "." ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L32-L45
aheadley/python-crunchyroll
crunchyroll/apis/android.py
AndroidApi._get_base_params
def _get_base_params(self): """Get the params that will be included with every request """ base_params = { 'locale': self._get_locale(), 'device_id': ANDROID.DEVICE_ID, 'device_type': ANDROID.APP_PACKAGE, 'access_token': ANDROID.ACCESS_TO...
python
def _get_base_params(self): """Get the params that will be included with every request """ base_params = { 'locale': self._get_locale(), 'device_id': ANDROID.DEVICE_ID, 'device_type': ANDROID.APP_PACKAGE, 'access_token': ANDROID.ACCESS_TO...
[ "def", "_get_base_params", "(", "self", ")", ":", "base_params", "=", "{", "'locale'", ":", "self", ".", "_get_locale", "(", ")", ",", "'device_id'", ":", "ANDROID", ".", "DEVICE_ID", ",", "'device_type'", ":", "ANDROID", ".", "APP_PACKAGE", ",", "'access_to...
Get the params that will be included with every request
[ "Get", "the", "params", "that", "will", "be", "included", "with", "every", "request" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L105-L118
aheadley/python-crunchyroll
crunchyroll/apis/android.py
AndroidApi._build_request_url
def _build_request_url(self, secure, api_method, version): """Build a URL for a API method request """ if secure: proto = ANDROID.PROTOCOL_SECURE else: proto = ANDROID.PROTOCOL_INSECURE req_url = ANDROID.API_URL.format( protocol=proto, ...
python
def _build_request_url(self, secure, api_method, version): """Build a URL for a API method request """ if secure: proto = ANDROID.PROTOCOL_SECURE else: proto = ANDROID.PROTOCOL_INSECURE req_url = ANDROID.API_URL.format( protocol=proto, ...
[ "def", "_build_request_url", "(", "self", ",", "secure", ",", "api_method", ",", "version", ")", ":", "if", "secure", ":", "proto", "=", "ANDROID", ".", "PROTOCOL_SECURE", "else", ":", "proto", "=", "ANDROID", ".", "PROTOCOL_INSECURE", "req_url", "=", "ANDRO...
Build a URL for a API method request
[ "Build", "a", "URL", "for", "a", "API", "method", "request" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L174-L186
aheadley/python-crunchyroll
crunchyroll/apis/android.py
AndroidApi.is_premium
def is_premium(self, media_type): """Get if the session is premium for a given media type @param str media_type Should be one of ANDROID.MEDIA_TYPE_* @return bool """ if self.logged_in: if media_type in self._user_data['premium']: return True ...
python
def is_premium(self, media_type): """Get if the session is premium for a given media type @param str media_type Should be one of ANDROID.MEDIA_TYPE_* @return bool """ if self.logged_in: if media_type in self._user_data['premium']: return True ...
[ "def", "is_premium", "(", "self", ",", "media_type", ")", ":", "if", "self", ".", "logged_in", ":", "if", "media_type", "in", "self", ".", "_user_data", "[", "'premium'", "]", ":", "return", "True", "return", "False" ]
Get if the session is premium for a given media type @param str media_type Should be one of ANDROID.MEDIA_TYPE_* @return bool
[ "Get", "if", "the", "session", "is", "premium", "for", "a", "given", "media", "type" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L196-L205
aheadley/python-crunchyroll
crunchyroll/apis/android.py
AndroidApi.login
def login(self, response): """ Login using email/username and password, used to get the auth token @param str account @param str password @param int duration (optional) """ self._state_params['auth'] = response['auth'] self._user_data = response['user'] ...
python
def login(self, response): """ Login using email/username and password, used to get the auth token @param str account @param str password @param int duration (optional) """ self._state_params['auth'] = response['auth'] self._user_data = response['user'] ...
[ "def", "login", "(", "self", ",", "response", ")", ":", "self", ".", "_state_params", "[", "'auth'", "]", "=", "response", "[", "'auth'", "]", "self", ".", "_user_data", "=", "response", "[", "'user'", "]", "if", "not", "self", ".", "logged_in", ":", ...
Login using email/username and password, used to get the auth token @param str account @param str password @param int duration (optional)
[ "Login", "using", "email", "/", "username", "and", "password", "used", "to", "get", "the", "auth", "token" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/android.py#L242-L253
vberlier/nbtlib
nbtlib/tag.py
read_numeric
def read_numeric(fmt, buff, byteorder='big'): """Read a numeric value from a file-like object.""" try: fmt = fmt[byteorder] return fmt.unpack(buff.read(fmt.size))[0] except StructError: return 0 except KeyError as exc: raise ValueError('Invalid byte order') from e...
python
def read_numeric(fmt, buff, byteorder='big'): """Read a numeric value from a file-like object.""" try: fmt = fmt[byteorder] return fmt.unpack(buff.read(fmt.size))[0] except StructError: return 0 except KeyError as exc: raise ValueError('Invalid byte order') from e...
[ "def", "read_numeric", "(", "fmt", ",", "buff", ",", "byteorder", "=", "'big'", ")", ":", "try", ":", "fmt", "=", "fmt", "[", "byteorder", "]", "return", "fmt", ".", "unpack", "(", "buff", ".", "read", "(", "fmt", ".", "size", ")", ")", "[", "0",...
Read a numeric value from a file-like object.
[ "Read", "a", "numeric", "value", "from", "a", "file", "-", "like", "object", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L99-L107
vberlier/nbtlib
nbtlib/tag.py
write_numeric
def write_numeric(fmt, value, buff, byteorder='big'): """Write a numeric value to a file-like object.""" try: buff.write(fmt[byteorder].pack(value)) except KeyError as exc: raise ValueError('Invalid byte order') from exc
python
def write_numeric(fmt, value, buff, byteorder='big'): """Write a numeric value to a file-like object.""" try: buff.write(fmt[byteorder].pack(value)) except KeyError as exc: raise ValueError('Invalid byte order') from exc
[ "def", "write_numeric", "(", "fmt", ",", "value", ",", "buff", ",", "byteorder", "=", "'big'", ")", ":", "try", ":", "buff", ".", "write", "(", "fmt", "[", "byteorder", "]", ".", "pack", "(", "value", ")", ")", "except", "KeyError", "as", "exc", ":...
Write a numeric value to a file-like object.
[ "Write", "a", "numeric", "value", "to", "a", "file", "-", "like", "object", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L110-L115
vberlier/nbtlib
nbtlib/tag.py
read_string
def read_string(buff, byteorder='big'): """Read a string from a file-like object.""" length = read_numeric(USHORT, buff, byteorder) return buff.read(length).decode('utf-8')
python
def read_string(buff, byteorder='big'): """Read a string from a file-like object.""" length = read_numeric(USHORT, buff, byteorder) return buff.read(length).decode('utf-8')
[ "def", "read_string", "(", "buff", ",", "byteorder", "=", "'big'", ")", ":", "length", "=", "read_numeric", "(", "USHORT", ",", "buff", ",", "byteorder", ")", "return", "buff", ".", "read", "(", "length", ")", ".", "decode", "(", "'utf-8'", ")" ]
Read a string from a file-like object.
[ "Read", "a", "string", "from", "a", "file", "-", "like", "object", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L118-L121
vberlier/nbtlib
nbtlib/tag.py
write_string
def write_string(value, buff, byteorder='big'): """Write a string to a file-like object.""" data = value.encode('utf-8') write_numeric(USHORT, len(data), buff, byteorder) buff.write(data)
python
def write_string(value, buff, byteorder='big'): """Write a string to a file-like object.""" data = value.encode('utf-8') write_numeric(USHORT, len(data), buff, byteorder) buff.write(data)
[ "def", "write_string", "(", "value", ",", "buff", ",", "byteorder", "=", "'big'", ")", ":", "data", "=", "value", ".", "encode", "(", "'utf-8'", ")", "write_numeric", "(", "USHORT", ",", "len", "(", "data", ")", ",", "buff", ",", "byteorder", ")", "b...
Write a string to a file-like object.
[ "Write", "a", "string", "to", "a", "file", "-", "like", "object", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L124-L128
vberlier/nbtlib
nbtlib/tag.py
List.infer_list_subtype
def infer_list_subtype(items): """Infer a list subtype from a collection of items.""" subtype = End for item in items: item_type = type(item) if not issubclass(item_type, Base): continue if subtype is End: subtype = ...
python
def infer_list_subtype(items): """Infer a list subtype from a collection of items.""" subtype = End for item in items: item_type = type(item) if not issubclass(item_type, Base): continue if subtype is End: subtype = ...
[ "def", "infer_list_subtype", "(", "items", ")", ":", "subtype", "=", "End", "for", "item", "in", "items", ":", "item_type", "=", "type", "(", "item", ")", "if", "not", "issubclass", "(", "item_type", ",", "Base", ")", ":", "continue", "if", "subtype", ...
Infer a list subtype from a collection of items.
[ "Infer", "a", "list", "subtype", "from", "a", "collection", "of", "items", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L414-L438
vberlier/nbtlib
nbtlib/tag.py
List.cast_item
def cast_item(cls, item): """Cast list item to the appropriate tag type.""" if not isinstance(item, cls.subtype): incompatible = isinstance(item, Base) and not any( issubclass(cls.subtype, tag_type) and isinstance(item, tag_type) for tag_type in cls.all_t...
python
def cast_item(cls, item): """Cast list item to the appropriate tag type.""" if not isinstance(item, cls.subtype): incompatible = isinstance(item, Base) and not any( issubclass(cls.subtype, tag_type) and isinstance(item, tag_type) for tag_type in cls.all_t...
[ "def", "cast_item", "(", "cls", ",", "item", ")", ":", "if", "not", "isinstance", "(", "item", ",", "cls", ".", "subtype", ")", ":", "incompatible", "=", "isinstance", "(", "item", ",", "Base", ")", "and", "not", "any", "(", "issubclass", "(", "cls",...
Cast list item to the appropriate tag type.
[ "Cast", "list", "item", "to", "the", "appropriate", "tag", "type", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L465-L486
vberlier/nbtlib
nbtlib/tag.py
Compound.merge
def merge(self, other): """Recursively merge tags from another compound.""" for key, value in other.items(): if key in self and (isinstance(self[key], Compound) and isinstance(value, dict)): self[key].merge(value) else: ...
python
def merge(self, other): """Recursively merge tags from another compound.""" for key, value in other.items(): if key in self and (isinstance(self[key], Compound) and isinstance(value, dict)): self[key].merge(value) else: ...
[ "def", "merge", "(", "self", ",", "other", ")", ":", "for", "key", ",", "value", "in", "other", ".", "items", "(", ")", ":", "if", "key", "in", "self", "and", "(", "isinstance", "(", "self", "[", "key", "]", ",", "Compound", ")", "and", "isinstan...
Recursively merge tags from another compound.
[ "Recursively", "merge", "tags", "from", "another", "compound", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/tag.py#L522-L529
aheadley/python-crunchyroll
crunchyroll/subtitles.py
SubtitleDecrypter.decrypt_subtitle
def decrypt_subtitle(self, subtitle): """Decrypt encrypted subtitle data in high level model object @param crunchyroll.models.Subtitle subtitle @return str """ return self.decrypt(self._build_encryption_key(int(subtitle.id)), subtitle['iv'][0].text.decode('base64'), ...
python
def decrypt_subtitle(self, subtitle): """Decrypt encrypted subtitle data in high level model object @param crunchyroll.models.Subtitle subtitle @return str """ return self.decrypt(self._build_encryption_key(int(subtitle.id)), subtitle['iv'][0].text.decode('base64'), ...
[ "def", "decrypt_subtitle", "(", "self", ",", "subtitle", ")", ":", "return", "self", ".", "decrypt", "(", "self", ".", "_build_encryption_key", "(", "int", "(", "subtitle", ".", "id", ")", ")", ",", "subtitle", "[", "'iv'", "]", "[", "0", "]", ".", "...
Decrypt encrypted subtitle data in high level model object @param crunchyroll.models.Subtitle subtitle @return str
[ "Decrypt", "encrypted", "subtitle", "data", "in", "high", "level", "model", "object" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L51-L59
aheadley/python-crunchyroll
crunchyroll/subtitles.py
SubtitleDecrypter.decrypt
def decrypt(self, encryption_key, iv, encrypted_data): """Decrypt encrypted subtitle data @param int subtitle_id @param str iv @param str encrypted_data @return str """ logger.info('Decrypting subtitles with length (%d bytes), key=%r', len(encrypted_...
python
def decrypt(self, encryption_key, iv, encrypted_data): """Decrypt encrypted subtitle data @param int subtitle_id @param str iv @param str encrypted_data @return str """ logger.info('Decrypting subtitles with length (%d bytes), key=%r', len(encrypted_...
[ "def", "decrypt", "(", "self", ",", "encryption_key", ",", "iv", ",", "encrypted_data", ")", ":", "logger", ".", "info", "(", "'Decrypting subtitles with length (%d bytes), key=%r'", ",", "len", "(", "encrypted_data", ")", ",", "encryption_key", ")", "return", "zl...
Decrypt encrypted subtitle data @param int subtitle_id @param str iv @param str encrypted_data @return str
[ "Decrypt", "encrypted", "subtitle", "data" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L61-L72
aheadley/python-crunchyroll
crunchyroll/subtitles.py
SubtitleDecrypter._build_encryption_key
def _build_encryption_key(self, subtitle_id, key_size=ENCRYPTION_KEY_SIZE): """Generate the encryption key for a given media item Encryption key is basically just sha1(<magic value based on subtitle_id> + '"#$&).6CXzPHw=2N_+isZK') then padded with 0s to 32 chars @param int subt...
python
def _build_encryption_key(self, subtitle_id, key_size=ENCRYPTION_KEY_SIZE): """Generate the encryption key for a given media item Encryption key is basically just sha1(<magic value based on subtitle_id> + '"#$&).6CXzPHw=2N_+isZK') then padded with 0s to 32 chars @param int subt...
[ "def", "_build_encryption_key", "(", "self", ",", "subtitle_id", ",", "key_size", "=", "ENCRYPTION_KEY_SIZE", ")", ":", "# generate a 160-bit SHA1 hash", "sha1_hash", "=", "hashlib", ".", "new", "(", "'sha1'", ",", "self", ".", "_build_hash_secret", "(", "(", "1",...
Generate the encryption key for a given media item Encryption key is basically just sha1(<magic value based on subtitle_id> + '"#$&).6CXzPHw=2N_+isZK') then padded with 0s to 32 chars @param int subtitle_id @param int key_size @return str
[ "Generate", "the", "encryption", "key", "for", "a", "given", "media", "item" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L74-L91
aheadley/python-crunchyroll
crunchyroll/subtitles.py
SubtitleDecrypter._build_hash_magic
def _build_hash_magic(self, subtitle_id): """Build the other half of the encryption key hash I have no idea what is going on here @param int subtitle_id @return str """ media_magic = self.HASH_MAGIC_CONST ^ subtitle_id hash_magic = media_magic ^ media_magic >> ...
python
def _build_hash_magic(self, subtitle_id): """Build the other half of the encryption key hash I have no idea what is going on here @param int subtitle_id @return str """ media_magic = self.HASH_MAGIC_CONST ^ subtitle_id hash_magic = media_magic ^ media_magic >> ...
[ "def", "_build_hash_magic", "(", "self", ",", "subtitle_id", ")", ":", "media_magic", "=", "self", ".", "HASH_MAGIC_CONST", "^", "subtitle_id", "hash_magic", "=", "media_magic", "^", "media_magic", ">>", "3", "^", "media_magic", "*", "32", "return", "str", "("...
Build the other half of the encryption key hash I have no idea what is going on here @param int subtitle_id @return str
[ "Build", "the", "other", "half", "of", "the", "encryption", "key", "hash" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L93-L104
aheadley/python-crunchyroll
crunchyroll/subtitles.py
SubtitleDecrypter._build_hash_secret
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_...
python
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", ")", ":", "# make sure we use a list, tuples are immutable", "fbn_seq", "=", "list", "(", "seq_seed", ")", "for", "i",...
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|...
[ "Build", "a", "seed", "for", "the", "hash", "based", "on", "the", "Fibonacci", "sequence" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L106-L128
aheadley/python-crunchyroll
crunchyroll/subtitles.py
SubtitleFormatter.format
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...
python
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", ")", ":", "logger", ".", "debug", "(", "'Formatting subtitles (id=%s) with %s'", ",", "subtitles", ".", "id", ",", "self", ".", "__class__", ".", "__name__", ")", "return", "self", ".", "_format", "(", "subtitl...
Turn a string containing the subs xml document into the formatted subtitle string @param str|crunchyroll.models.StyledSubtitle sub_xml_text @return str
[ "Turn", "a", "string", "containing", "the", "subs", "xml", "document", "into", "the", "formatted", "subtitle", "string" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/subtitles.py#L134-L143
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
require_session_started
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() ...
python
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", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "inner_func", "(", "self", ",", "*", "pargs", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "session_started", ":", "logger...
Check if API sessions are started and start them if not
[ "Check", "if", "API", "sessions", "are", "started", "and", "start", "them", "if", "not" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L35-L44
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
require_android_logged_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...
python
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", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "@", "require_session_started", "def", "inner_func", "(", "self", ",", "*", "pargs", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".",...
Check if andoid API is logged in and login if not, implies `require_session_started`
[ "Check", "if", "andoid", "API", "is", "logged", "in", "and", "login", "if", "not", "implies", "require_session_started" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L46-L61
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
optional_manga_logged_in
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...
python
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", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "@", "require_session_started", "def", "inner_func", "(", "self", ",", "*", "pargs", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", ...
Check if andoid manga API is logged in and login if credentials were provided, implies `require_session_started`
[ "Check", "if", "andoid", "manga", "API", "is", "logged", "in", "and", "login", "if", "credentials", "were", "provided", "implies", "require_session_started" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L77-L89
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
require_ajax_logged_in
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...
python
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", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "inner_func", "(", "self", ",", "*", "pargs", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_ajax_api", ".", "logged_in", ...
Check if ajax API is logged in and login if not
[ "Check", "if", "ajax", "API", "is", "logged", "in", "and", "login", "if", "not" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L91-L104
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.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() ...
python
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", ")", ":", "self", ".", "_android_api", ".", "start_session", "(", ")", "self", ".", "_manga_api", ".", "cr_start_session", "(", ")", "return", "self", ".", "session_started" ]
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
[ "Start", "the", "underlying", "APIs", "sessions" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L174-L184
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.login
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...
python
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", ")", ":", "# 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", "=", "...
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
[ "Login", "with", "the", "given", "username", "/", "email", "and", "password" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L187-L209
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.list_anime_series
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...
python
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", ")", ":", "result", "=", "self", ".", "_android_api", ".", "list_series", "(", "media_type", "=",...
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...
[ "Get", "a", "list", "of", "anime", "series" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L213-L228
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.list_drama_series
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...
python
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", ")", ":", "result", "=", "self", ".", "_android_api", ".", "list_series", "(", "media_type", "=",...
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...
[ "Get", "a", "list", "of", "drama", "series" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L232-L247
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.list_manga_series
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
python
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'", ")", ":", "result", "=", "self", ".", "_manga_api", ".", "list_series", "(", "filter", ",", "content_type", ")", "return", "result" ]
Get a list of manga series
[ "Get", "a", "list", "of", "manga", "series" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L251-L256
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.search_anime_series
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 ...
python
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", ")", ":", "result", "=", "self", ".", "_android_api", ".", "list_series", "(", "media_type", "=", "ANDROID", ".", "MEDIA_TYPE_ANIME", ",", "filter", "=", "ANDROID", ".", "FILTER_PREFIX", "+", "que...
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 ...
[ "Search", "anime", "series", "list", "by", "series", "name", "case", "-", "sensitive" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L260-L273
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.search_drama_series
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 ...
python
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", ")", ":", "result", "=", "self", ".", "_android_api", ".", "list_series", "(", "media_type", "=", "ANDROID", ".", "MEDIA_TYPE_DRAMA", ",", "filter", "=", "ANDROID", ".", "FILTER_PREFIX", "+", "que...
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 ...
[ "Search", "drama", "series", "list", "by", "series", "name", "case", "-", "sensitive" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L277-L290
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.search_manga_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...
python
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", ")", ":", "result", "=", "self", ".", "_manga_api", ".", "list_series", "(", ")", "return", "[", "series", "for", "series", "in", "result", "if", "series", "[", "'locale'", "]", "[", "'enUS'",...
Search the manga series list by name, case-insensitive @param str query_string @return list<crunchyroll.models.Series>
[ "Search", "the", "manga", "series", "list", "by", "name", "case", "-", "insensitive" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L294-L305
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.list_media
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 ...
python
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", ")", ":", "params", "=", "{", "'sort'", ":", "sort", ",", "'offset'", ":", "offset", ...
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 ...
[ "List", "media", "for", "a", "given", "series", "or", "collection" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L309-L328
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.search_media
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 ...
python
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", ")", ":", "params", "=", "{", "'sort'", ":", "ANDROID", ".", "FILTER_PREFIX", "+", "query_string", ",", "}", "params", ".", "update", "(", "self", ".", "_get_series_query_dict", "(", "...
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` ...
[ "Search", "for", "media", "from", "a", "series", "starting", "with", "query_string", "case", "-", "sensitive" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L359-L372
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.get_media_stream
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...
python
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", ")", ":", "result", "=", "self", ".", "_ajax_api", ".", "VideoPlayer_GetStandardConfig", "(", "media_id", "=", "media_item", ".", "media_id", ",", "video_format", "=", "f...
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
[ "Get", "the", "stream", "data", "for", "a", "given", "media", "item" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L375-L387
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.unfold_subtitle_stub
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...
python
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", ")", ":", "return", "Subtitle", "(", "self", ".", "_ajax_api", ".", "Subtitle_GetXml", "(", "subtitle_script_id", "=", "int", "(", "subtitle_stub", ".", "id", ")", ")", ")" ]
Turn a SubtitleStub into a full Subtitle object @param crunchyroll.models.SubtitleStub subtitle_stub @return crunchyroll.models.Subtitle
[ "Turn", "a", "SubtitleStub", "into", "a", "full", "Subtitle", "object" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L402-L409
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.get_stream_formats
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...
python
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", ")", ":", "scraper", "=", "ScraperApi", "(", "self", ".", "_ajax_api", ".", "_connector", ")", "formats", "=", "scraper", ".", "get_media_formats", "(", "media_item", ".", "media_id", ")", "return", ...
Get the available media formats for a given media item @param crunchyroll.models.Media @return dict
[ "Get", "the", "available", "media", "formats", "for", "a", "given", "media", "item" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L412-L420
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.list_queue
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...
python
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", "]", ")", ":", "result", "=", "self", ".", "_android_api", ".", "queue", "(", "media_types", "=", "'|'", ".", "join", "(", "media...
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>
[ "List", "the", "series", "in", "the", "queue", "optionally", "filtering", "by", "type", "of", "media" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L424-L432
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.add_to_queue
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
python
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", ")", ":", "result", "=", "self", ".", "_android_api", ".", "add_to_queue", "(", "series_id", "=", "series", ".", "series_id", ")", "return", "result" ]
Add a series to the queue @param crunchyroll.models.Series series @return bool
[ "Add", "a", "series", "to", "the", "queue" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L435-L442
aheadley/python-crunchyroll
crunchyroll/apis/meta.py
MetaApi.remove_from_queue
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
python
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", ")", ":", "result", "=", "self", ".", "_android_api", ".", "remove_from_queue", "(", "series_id", "=", "series", ".", "series_id", ")", "return", "result" ]
Remove a series from the queue @param crunchyroll.models.Series series @return bool
[ "Remove", "a", "series", "from", "the", "queue" ]
train
https://github.com/aheadley/python-crunchyroll/blob/9bf2eb644f0d0f3e9dc21b95b8e355c6e2050178/crunchyroll/apis/meta.py#L445-L452
vberlier/nbtlib
nbtlib/schema.py
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....
python
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", ")", ":", "return", "type", "(", "name", ",", "(", "CompoundSchema", ",", ")", ",", "{", "'__slots__'", ":", "(", ")", ",", "'schema'", ":", "dct", ",", "'strict'", ...
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...
[ "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"...
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/schema.py#L17-L32
vberlier/nbtlib
nbtlib/schema.py
CompoundSchema.cast_item
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...
python
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", ")", ":", "schema_type", "=", "cls", ".", "schema", ".", "get", "(", "key", ")", "if", "schema_type", "is", "None", ":", "if", "cls", ".", "strict", ":", "raise", "TypeError", "(", "f'Invalid ...
Cast schema item to the appropriate tag type.
[ "Cast", "schema", "item", "to", "the", "appropriate", "tag", "type", "." ]
train
https://github.com/vberlier/nbtlib/blob/9c9d58b5c4a530b0f1ffd76dda176f00406c3547/nbtlib/schema.py#L73-L86
ales-erjavec/anyqt
AnyQt/_backport/_utils.py
obsolete_rename
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, ...
python
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", ")", ":", "newname", "=", "newfunc", ".", "__name__", "def", "__obsolete", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "warnings", ".", "warn", "(", "\"{oldname} is obsolete and is removed in P...
Simple obsolete/removed method decorator Parameters ---------- oldname : str The name of the old obsolete name newfunc : FunctionType Replacement unbound member function.
[ "Simple", "obsolete", "/", "removed", "method", "decorator" ]
train
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/_backport/_utils.py#L4-L25
zagaran/mongobackup
mongobackup/shell.py
call
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(...
python
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", ")", ":", "try", ":", "if", "silent", ":", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "FNULL", ":", "return", "subprocess", ".", "check_call", "(", "command_to_array", ...
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.
[ "Runs", "a", "bash", "command", "safely", "with", "shell", "=", "false", "catches", "any", "non", "-", "zero", "return", "codes", ".", "Raises", "slightly", "modified", "CalledProcessError", "exceptions", "on", "failures", ".", "Note", ":", "command", "is", ...
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/shell.py#L35-L54
zagaran/mongobackup
mongobackup/shell.py
tarbz
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) ...
python
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", ")", ":", "output_directory_path", "=", "output_file_full_path", ".", "rsplit", "(", "\"/\"", ",", "1", ")", "[", "0", "]", "create_folders", "(", "output_di...
Tars and bzips a directory, preserving as much metadata as possible. Adds '.tbz' to the provided output file name.
[ "Tars", "and", "bzips", "a", "directory", "preserving", "as", "much", "metadata", "as", "possible", ".", "Adds", ".", "tbz", "to", "the", "provided", "output", "file", "name", "." ]
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/shell.py#L64-L79
zagaran/mongobackup
mongobackup/shell.py
untarbz
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...
python
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", ")", ":", "if", "not", "path", ".", "exists", "(", "source_file_path", ")", ":", "raise", "Exception", "(", "\"the provided tar file %s does not exist.\"", "%", "...
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...
[ "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"...
train
https://github.com/zagaran/mongobackup/blob/d090d0cca44ecd066974c4de80edca5f26b7eeea/mongobackup/shell.py#L82-L108
gdub/python-simpleldap
simpleldap/__init__.py
LDAPItem.value_contains
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
python
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", ")", ":", "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.
[ "Determine", "if", "any", "of", "the", "items", "in", "the", "value", "list", "for", "the", "given", "attribute", "contain", "value", "." ]
train
https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L64-L72
gdub/python-simpleldap
simpleldap/__init__.py
Connection.clear_search_defaults
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...
python
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", ")", ":", "if", "args", "is", "None", ":", "self", ".", "_search_defaults", ".", "clear", "(", ")", "else", ":", "for", "arg", "in", "args", ":", "if", "arg", "in", "self", ".", ...
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']) ...
[ "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", "." ]
train
https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L188-L205
gdub/python-simpleldap
simpleldap/__init__.py
Connection.search
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...
python
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", ")", ":", "if", "base_dn", "is", "None", ":", "base_dn", "=", ...
Search the directory.
[ "Search", "the", "directory", "." ]
train
https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L219-L237
gdub/python-simpleldap
simpleldap/__init__.py
Connection.get
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. """ ...
python
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", ")", ":", "results", "=", "self", ".", "search", "(", "*", "args", ",", "*", "*", "kwargs", ")", "num_results", "=", "len", "(", "results", ")", "if", "num_results", "==", "1",...
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", "." ]
train
https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L239-L253
gdub/python-simpleldap
simpleldap/__init__.py
Connection.authenticate
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. """ ...
python
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", "=", "''", ")", ":", "try", ":", "self", ".", "connection", ".", "simple_bind_s", "(", "dn", ",", "password", ")", "except", "tuple", "(", "self", ".", "failed_authentication_exce...
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...
train
https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L262-L274
gdub/python-simpleldap
simpleldap/__init__.py
Connection.compare
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,...
python
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", ")", ":", "return", "self", ".", "connection", ".", "compare_s", "(", "dn", ",", "attr", ",", "value", ")", "==", "1" ]
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.
[ "Compare", "the", "attr", "of", "the", "entry", "dn", "with", "given", "value", "." ]
train
https://github.com/gdub/python-simpleldap/blob/a833f444d90ad2f3fe779c3e2cb08350052fedc8/simpleldap/__init__.py#L276-L283
crccheck/cloudwatch-to-graphite
plumbum.py
get_property_func
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...
python
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", ")", ":", "def", "get_it", "(", "obj", ")", ":", "try", ":", "return", "getattr", "(", "obj", ",", "key", ")", "except", "AttributeError", ":", "return", "obj", ".", "tags", ".", "get", "(", "key", ")", "return...
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.
[ "Get", "the", "accessor", "function", "for", "an", "instance", "to", "look", "for", "key", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L59-L71
crccheck/cloudwatch-to-graphite
plumbum.py
list_billing
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...
python
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", ")", ":", "conn", "=", "boto", ".", "ec2", ".", "cloudwatch", ".", "connect_to_region", "(", "region", ")", "metrics", "=", "conn", ".", "list_metrics", "(", "metric_name", "=", "'EstimatedCharges'...
List available billing metrics
[ "List", "available", "billing", "metrics" ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L111-L127
crccheck/cloudwatch-to-graphite
plumbum.py
list_cloudfront
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)
python
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", ")", ":", "conn", "=", "boto", ".", "connect_cloudfront", "(", ")", "instances", "=", "conn", ".", "get_all_distributions", "(", ")", "return", "lookup", "(", "instances", ",", "filter_by", "=",...
List running ec2 instances.
[ "List", "running", "ec2", "instances", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L130-L134
crccheck/cloudwatch-to-graphite
plumbum.py
list_ec2
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)
python
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", ")", ":", "conn", "=", "boto", ".", "ec2", ".", "connect_to_region", "(", "region", ")", "instances", "=", "conn", ".", "get_only_instances", "(", ")", "return", "lookup", "(", "instances", ",", "f...
List running ec2 instances.
[ "List", "running", "ec2", "instances", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L137-L141
crccheck/cloudwatch-to-graphite
plumbum.py
list_ebs
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)
python
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", ")", ":", "conn", "=", "boto", ".", "ec2", ".", "connect_to_region", "(", "region", ")", "instances", "=", "conn", ".", "get_all_volumes", "(", ")", "return", "lookup", "(", "instances", ",", "filt...
List running ebs volumes.
[ "List", "running", "ebs", "volumes", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L143-L147
crccheck/cloudwatch-to-graphite
plumbum.py
list_elb
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)
python
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", ")", ":", "conn", "=", "boto", ".", "ec2", ".", "elb", ".", "connect_to_region", "(", "region", ")", "instances", "=", "conn", ".", "get_all_load_balancers", "(", ")", "return", "lookup", "(", "ins...
List all load balancers.
[ "List", "all", "load", "balancers", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L150-L154
crccheck/cloudwatch-to-graphite
plumbum.py
list_rds
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)
python
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", ")", ":", "conn", "=", "boto", ".", "rds", ".", "connect_to_region", "(", "region", ")", "instances", "=", "conn", ".", "get_all_dbinstances", "(", ")", "return", "lookup", "(", "instances", ",", "...
List all RDS thingys.
[ "List", "all", "RDS", "thingys", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L157-L161
crccheck/cloudwatch-to-graphite
plumbum.py
list_elasticache
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...
python
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", ")", ":", "conn", "=", "boto", ".", "elasticache", ".", "connect_to_region", "(", "region", ")", "req", "=", "conn", ".", "describe_cache_clusters", "(", ")", "data", "=", "req", "[", "\"Desc...
List all ElastiCache Clusters.
[ "List", "all", "ElastiCache", "Clusters", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L164-L173
crccheck/cloudwatch-to-graphite
plumbum.py
list_autoscaling_group
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)
python
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", ")", ":", "conn", "=", "boto", ".", "ec2", ".", "autoscale", ".", "connect_to_region", "(", "region", ")", "groups", "=", "conn", ".", "get_all_groups", "(", ")", "return", "lookup", "(...
List all Auto Scaling Groups.
[ "List", "all", "Auto", "Scaling", "Groups", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L176-L180
crccheck/cloudwatch-to-graphite
plumbum.py
list_sqs
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)
python
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", ")", ":", "conn", "=", "boto", ".", "sqs", ".", "connect_to_region", "(", "region", ")", "queues", "=", "conn", ".", "get_all_queues", "(", ")", "return", "lookup", "(", "queues", ",", "filter_by",...
List all SQS Queues.
[ "List", "all", "SQS", "Queues", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L183-L187
crccheck/cloudwatch-to-graphite
plumbum.py
list_kinesis_applications
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 = [] ...
python
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", ")", ":", "conn", "=", "boto", ".", "kinesis", ".", "connect_to_region", "(", "region", ")", "streams", "=", "conn", ".", "list_streams", "(", ")", "[", "'StreamNames'", "]", "kinesis_...
List all the kinesis applications along with the shards for each stream
[ "List", "all", "the", "kinesis", "applications", "along", "with", "the", "shards", "for", "each", "stream" ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L190-L201
crccheck/cloudwatch-to-graphite
plumbum.py
list_dynamodb
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)
python
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", ")", ":", "conn", "=", "boto", ".", "dynamodb", ".", "connect_to_region", "(", "region", ")", "tables", "=", "conn", ".", "list_tables", "(", ")", "return", "lookup", "(", "tables", ",", "filt...
List all DynamoDB tables.
[ "List", "all", "DynamoDB", "tables", "." ]
train
https://github.com/crccheck/cloudwatch-to-graphite/blob/28a11ee56f7231cef6b6f8af142a8aab3d2eb5a6/plumbum.py#L204-L208
pyslackers/slack-sansio
slack/actions.py
Router.register
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...
python
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", ":", "LOG", ".", "info", "(", "\"Registering %s, %s to %s\"", ",", "callback_id", ",", "name", ",", "h...
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_...
[ "Register", "a", "new", "handler", "for", "a", "specific", ":", "class", ":", "slack", ".", "actions", ".", "Action", "callback_id", ".", "Optional", "routing", "based", "on", "the", "action", "name", "too", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/actions.py#L82-L99
pyslackers/slack-sansio
slack/actions.py
Router.dispatch
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"...
python
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", ":", "LOG", ".", "debug", "(", "\"Dispatching action %s, %s\"", ",", "action", "[", "\"type\"", "]", ",", "action", "[", "\"callback_id\"", "]", ")", "if", "action", "[", "\"...
Yields handlers matching the incoming :class:`slack.actions.Action` `callback_id`. Args: action: :class:`slack.actions.Action` Yields: handler
[ "Yields", "handlers", "matching", "the", "incoming", ":", "class", ":", "slack", ".", "actions", ".", "Action", "callback_id", "." ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/actions.py#L101-L118
ales-erjavec/anyqt
AnyQt/_api.py
comittoapi
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...
python
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", ")", ":", "global", "USED_API", "assert", "USED_API", "is", "None", ",", "\"committoapi called again!\"", "check", "=", "[", "\"PyQt4\"", ",", "\"PyQt5\"", ",", "\"PySide\"", ",", "\"PySide2\"", "]", "assert", "api", "in", "[",...
Commit to the use of specified Qt api. Raise an error if another Qt api is already loaded in sys.modules
[ "Commit", "to", "the", "use", "of", "specified", "Qt", "api", "." ]
train
https://github.com/ales-erjavec/anyqt/blob/07b73c5ccb8f73f70fc6566249c0c7228fc9b921/AnyQt/_api.py#L23-L44
cakebread/yolk
yolk/metadata.py
get_metadata
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...
python
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", ")", ":", "if", "not", "dist", ".", "has_metadata", "(", "'PKG-INFO'", ")", ":", "return", "msg", "=", "email", ".", "message_from_string", "(", "dist", ".", "get_metadata", "(", "'PKG-INFO'", ")", ")", "metadata", "=", ...
Return dictionary of metadata for given dist @param dist: distribution @type dist: pkg_resources Distribution object @returns: dict of metadata or None
[ "Return", "dictionary", "of", "metadata", "for", "given", "dist" ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/metadata.py#L25-L43
cakebread/yolk
yolk/plugins/base.py
Plugin.add_options
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...
python
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", ")", ":", "parser", ".", "add_option", "(", "\"--with-%s\"", "%", "self", ".", "name", ",", "action", "=", "\"store_true\"", ",", "dest", "=", "self", ".", "enable_opt", ",", "help", "=", "\"Enable plugin %...
Add command-line options for this plugin. The base plugin class adds --with-$name by default, used to enable the plugin.
[ "Add", "command", "-", "line", "options", "for", "this", "plugin", "." ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/base.py#L42-L53
cakebread/yolk
yolk/plugins/base.py
Plugin.configure
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): ...
python
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", ")", ":", "self", ".", "conf", "=", "conf", "if", "hasattr", "(", "options", ",", "self", ".", "enable_opt", ")", ":", "self", ".", "enabled", "=", "getattr", "(", "options", ",", "self", ...
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.
[ "Configure", "the", "plugin", "and", "system", "based", "on", "selected", "options", "." ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/base.py#L55-L63
cakebread/yolk
yolk/plugins/base.py
Plugin.help
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__....
python
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", ")", ":", "if", "self", ".", "__class__", ".", "__doc__", ":", "# doc sections are often indented; compress the spaces", "return", "textwrap", ".", "dedent", "(", "self", ".", "__class__", ".", "__doc__", ")", "return", "\"(no help avai...
Return help for this plugin. This will be output as the help section of the --with-$name option that enables the plugin.
[ "Return", "help", "for", "this", "plugin", ".", "This", "will", "be", "output", "as", "the", "help", "section", "of", "the", "--", "with", "-", "$name", "option", "that", "enables", "the", "plugin", "." ]
train
https://github.com/cakebread/yolk/blob/ee8c9f529a542d9c5eff4fe69b9c7906c802e4d8/yolk/plugins/base.py#L65-L72
pyslackers/slack-sansio
slack/sansio.py
raise_for_status
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...
python
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", ":", "if", "status", "!=", "200", ":", "if", "status", "==", "429", ":", "if", "isinstance", "(", "data", ...
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`:
[ "Check", "request", "response", "status" ]
train
https://github.com/pyslackers/slack-sansio/blob/068ddd6480c6d2f9bf14fa4db498c9fe1017f4ab/slack/sansio.py#L28-L57