partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
Plugin.register
Register a model in self.
muffin_peewee/plugin.py
def register(self, model): """Register a model in self.""" self.models[model._meta.table_name] = model model._meta.database = self.database return model
def register(self, model): """Register a model in self.""" self.models[model._meta.table_name] = model model._meta.database = self.database return model
[ "Register", "a", "model", "in", "self", "." ]
klen/muffin-peewee
python
https://github.com/klen/muffin-peewee/blob/8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e/muffin_peewee/plugin.py#L140-L144
[ "def", "register", "(", "self", ",", "model", ")", ":", "self", ".", "models", "[", "model", ".", "_meta", ".", "table_name", "]", "=", "model", "model", ".", "_meta", ".", "database", "=", "self", ".", "database", "return", "model" ]
8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e
valid
Plugin.manage
Manage a database connection.
muffin_peewee/plugin.py
async def manage(self): """Manage a database connection.""" cm = _ContextManager(self.database) if isinstance(self.database.obj, AIODatabase): cm.connection = await self.database.async_connect() else: cm.connection = self.database.connect() return cm
async def manage(self): """Manage a database connection.""" cm = _ContextManager(self.database) if isinstance(self.database.obj, AIODatabase): cm.connection = await self.database.async_connect() else: cm.connection = self.database.connect() return cm
[ "Manage", "a", "database", "connection", "." ]
klen/muffin-peewee
python
https://github.com/klen/muffin-peewee/blob/8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e/muffin_peewee/plugin.py#L146-L155
[ "async", "def", "manage", "(", "self", ")", ":", "cm", "=", "_ContextManager", "(", "self", ".", "database", ")", "if", "isinstance", "(", "self", ".", "database", ".", "obj", ",", "AIODatabase", ")", ":", "cm", ".", "connection", "=", "await", "self",...
8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e
valid
migrate
Write your migrations here. > Model = migrator.orm['name'] > migrator.sql(sql) > migrator.create_table(Model) > migrator.drop_table(Model, cascade=True) > migrator.add_columns(Model, **fields) > migrator.change_columns(Model, **fields) > migrator.drop_columns(Model, *field_names, cascade=T...
example/migrations/000_initial.py
def migrate(migrator, database, **kwargs): """ Write your migrations here. > Model = migrator.orm['name'] > migrator.sql(sql) > migrator.create_table(Model) > migrator.drop_table(Model, cascade=True) > migrator.add_columns(Model, **fields) > migrator.change_columns(Model, **fields) > m...
def migrate(migrator, database, **kwargs): """ Write your migrations here. > Model = migrator.orm['name'] > migrator.sql(sql) > migrator.create_table(Model) > migrator.drop_table(Model, cascade=True) > migrator.add_columns(Model, **fields) > migrator.change_columns(Model, **fields) > m...
[ "Write", "your", "migrations", "here", "." ]
klen/muffin-peewee
python
https://github.com/klen/muffin-peewee/blob/8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e/example/migrations/000_initial.py#L7-L30
[ "def", "migrate", "(", "migrator", ",", "database", ",", "*", "*", "kwargs", ")", ":", "@", "migrator", ".", "create_table", "class", "DataItem", "(", "pw", ".", "Model", ")", ":", "created", "=", "pw", ".", "DateTimeField", "(", "default", "=", "dt", ...
8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e
valid
chain
Runs a series of parsers in sequence passing the result of each parser to the next. The result of the last parser is returned.
picoparse/__init__.py
def chain(*args): """Runs a series of parsers in sequence passing the result of each parser to the next. The result of the last parser is returned. """ def chain_block(*args, **kwargs): v = args[0](*args, **kwargs) for p in args[1:]: v = p(v) return v return chain...
def chain(*args): """Runs a series of parsers in sequence passing the result of each parser to the next. The result of the last parser is returned. """ def chain_block(*args, **kwargs): v = args[0](*args, **kwargs) for p in args[1:]: v = p(v) return v return chain...
[ "Runs", "a", "series", "of", "parsers", "in", "sequence", "passing", "the", "result", "of", "each", "parser", "to", "the", "next", ".", "The", "result", "of", "the", "last", "parser", "is", "returned", "." ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L303-L312
[ "def", "chain", "(", "*", "args", ")", ":", "def", "chain_block", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "v", "=", "args", "[", "0", "]", "(", "*", "args", ",", "*", "*", "kwargs", ")", "for", "p", "in", "args", "[", "1", ":",...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
one_of
Returns the current token if is found in the collection provided. Fails otherwise.
picoparse/__init__.py
def one_of(these): """Returns the current token if is found in the collection provided. Fails otherwise. """ ch = peek() try: if (ch is EndOfFile) or (ch not in these): fail(list(these)) except TypeError: if ch != these: fail([these]) next() r...
def one_of(these): """Returns the current token if is found in the collection provided. Fails otherwise. """ ch = peek() try: if (ch is EndOfFile) or (ch not in these): fail(list(these)) except TypeError: if ch != these: fail([these]) next() r...
[ "Returns", "the", "current", "token", "if", "is", "found", "in", "the", "collection", "provided", ".", "Fails", "otherwise", "." ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L325-L338
[ "def", "one_of", "(", "these", ")", ":", "ch", "=", "peek", "(", ")", "try", ":", "if", "(", "ch", "is", "EndOfFile", ")", "or", "(", "ch", "not", "in", "these", ")", ":", "fail", "(", "list", "(", "these", ")", ")", "except", "TypeError", ":",...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
not_one_of
Returns the current token if it is not found in the collection provided. The negative of one_of.
picoparse/__init__.py
def not_one_of(these): """Returns the current token if it is not found in the collection provided. The negative of one_of. """ ch = peek() desc = "not_one_of" + repr(these) try: if (ch is EndOfFile) or (ch in these): fail([desc]) except TypeError: if ch != t...
def not_one_of(these): """Returns the current token if it is not found in the collection provided. The negative of one_of. """ ch = peek() desc = "not_one_of" + repr(these) try: if (ch is EndOfFile) or (ch in these): fail([desc]) except TypeError: if ch != t...
[ "Returns", "the", "current", "token", "if", "it", "is", "not", "found", "in", "the", "collection", "provided", ".", "The", "negative", "of", "one_of", "." ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L340-L354
[ "def", "not_one_of", "(", "these", ")", ":", "ch", "=", "peek", "(", ")", "desc", "=", "\"not_one_of\"", "+", "repr", "(", "these", ")", "try", ":", "if", "(", "ch", "is", "EndOfFile", ")", "or", "(", "ch", "in", "these", ")", ":", "fail", "(", ...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
satisfies
Returns the current token if it satisfies the guard function provided. Fails otherwise. This is the a generalisation of one_of.
picoparse/__init__.py
def satisfies(guard): """Returns the current token if it satisfies the guard function provided. Fails otherwise. This is the a generalisation of one_of. """ i = peek() if (i is EndOfFile) or (not guard(i)): fail(["<satisfies predicate " + _fun_to_str(guard) + ">"]) next() re...
def satisfies(guard): """Returns the current token if it satisfies the guard function provided. Fails otherwise. This is the a generalisation of one_of. """ i = peek() if (i is EndOfFile) or (not guard(i)): fail(["<satisfies predicate " + _fun_to_str(guard) + ">"]) next() re...
[ "Returns", "the", "current", "token", "if", "it", "satisfies", "the", "guard", "function", "provided", ".", "Fails", "otherwise", ".", "This", "is", "the", "a", "generalisation", "of", "one_of", "." ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L365-L375
[ "def", "satisfies", "(", "guard", ")", ":", "i", "=", "peek", "(", ")", "if", "(", "i", "is", "EndOfFile", ")", "or", "(", "not", "guard", "(", "i", ")", ")", ":", "fail", "(", "[", "\"<satisfies predicate \"", "+", "_fun_to_str", "(", "guard", ")"...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
not_followed_by
Succeeds if the given parser cannot consume input
picoparse/__init__.py
def not_followed_by(parser): """Succeeds if the given parser cannot consume input""" @tri def not_followed_by_block(): failed = object() result = optional(tri(parser), failed) if result != failed: fail(["not " + _fun_to_str(parser)]) choice(not_followed_by_block)
def not_followed_by(parser): """Succeeds if the given parser cannot consume input""" @tri def not_followed_by_block(): failed = object() result = optional(tri(parser), failed) if result != failed: fail(["not " + _fun_to_str(parser)]) choice(not_followed_by_block)
[ "Succeeds", "if", "the", "given", "parser", "cannot", "consume", "input" ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L382-L390
[ "def", "not_followed_by", "(", "parser", ")", ":", "@", "tri", "def", "not_followed_by_block", "(", ")", ":", "failed", "=", "object", "(", ")", "result", "=", "optional", "(", "tri", "(", "parser", ")", ",", "failed", ")", "if", "result", "!=", "faile...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
many
Applies the parser to input zero or more times. Returns a list of parser results.
picoparse/__init__.py
def many(parser): """Applies the parser to input zero or more times. Returns a list of parser results. """ results = [] terminate = object() while local_ps.value: result = optional(parser, terminate) if result == terminate: break results.append(result) ...
def many(parser): """Applies the parser to input zero or more times. Returns a list of parser results. """ results = [] terminate = object() while local_ps.value: result = optional(parser, terminate) if result == terminate: break results.append(result) ...
[ "Applies", "the", "parser", "to", "input", "zero", "or", "more", "times", ".", "Returns", "a", "list", "of", "parser", "results", "." ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L394-L406
[ "def", "many", "(", "parser", ")", ":", "results", "=", "[", "]", "terminate", "=", "object", "(", ")", "while", "local_ps", ".", "value", ":", "result", "=", "optional", "(", "parser", ",", "terminate", ")", "if", "result", "==", "terminate", ":", "...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
many_until
Consumes as many of these as it can until it term is encountered. Returns a tuple of the list of these results and the term result
picoparse/__init__.py
def many_until(these, term): """Consumes as many of these as it can until it term is encountered. Returns a tuple of the list of these results and the term result """ results = [] while True: stop, result = choice(_tag(True, term), _tag(False, these)) ...
def many_until(these, term): """Consumes as many of these as it can until it term is encountered. Returns a tuple of the list of these results and the term result """ results = [] while True: stop, result = choice(_tag(True, term), _tag(False, these)) ...
[ "Consumes", "as", "many", "of", "these", "as", "it", "can", "until", "it", "term", "is", "encountered", ".", "Returns", "a", "tuple", "of", "the", "list", "of", "these", "results", "and", "the", "term", "result" ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L417-L429
[ "def", "many_until", "(", "these", ",", "term", ")", ":", "results", "=", "[", "]", "while", "True", ":", "stop", ",", "result", "=", "choice", "(", "_tag", "(", "True", ",", "term", ")", ",", "_tag", "(", "False", ",", "these", ")", ")", "if", ...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
many_until1
Like many_until but must consume at least one of these.
picoparse/__init__.py
def many_until1(these, term): """Like many_until but must consume at least one of these. """ first = [these()] these_results, term_result = many_until(these, term) return (first + these_results, term_result)
def many_until1(these, term): """Like many_until but must consume at least one of these. """ first = [these()] these_results, term_result = many_until(these, term) return (first + these_results, term_result)
[ "Like", "many_until", "but", "must", "consume", "at", "least", "one", "of", "these", "." ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L431-L436
[ "def", "many_until1", "(", "these", ",", "term", ")", ":", "first", "=", "[", "these", "(", ")", "]", "these_results", ",", "term_result", "=", "many_until", "(", "these", ",", "term", ")", "return", "(", "first", "+", "these_results", ",", "term_result"...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
sep1
Like sep but must consume at least one of parser.
picoparse/__init__.py
def sep1(parser, separator): """Like sep but must consume at least one of parser. """ first = [parser()] def inner(): separator() return parser() return first + many(tri(inner))
def sep1(parser, separator): """Like sep but must consume at least one of parser. """ first = [parser()] def inner(): separator() return parser() return first + many(tri(inner))
[ "Like", "sep", "but", "must", "consume", "at", "least", "one", "of", "parser", "." ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L438-L445
[ "def", "sep1", "(", "parser", ",", "separator", ")", ":", "first", "=", "[", "parser", "(", ")", "]", "def", "inner", "(", ")", ":", "separator", "(", ")", "return", "parser", "(", ")", "return", "first", "+", "many", "(", "tri", "(", "inner", ")...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
string
Iterates over string, matching input to the items provided. The most obvious usage of this is to accept an entire string of characters, However this is function is more general than that. It takes an iterable and for each item, it tries one_of for that set. For example, string(['aA','bB','cC'])...
picoparse/__init__.py
def string(string): """Iterates over string, matching input to the items provided. The most obvious usage of this is to accept an entire string of characters, However this is function is more general than that. It takes an iterable and for each item, it tries one_of for that set. For example, ...
def string(string): """Iterates over string, matching input to the items provided. The most obvious usage of this is to accept an entire string of characters, However this is function is more general than that. It takes an iterable and for each item, it tries one_of for that set. For example, ...
[ "Iterates", "over", "string", "matching", "input", "to", "the", "items", "provided", ".", "The", "most", "obvious", "usage", "of", "this", "is", "to", "accept", "an", "entire", "string", "of", "characters", "However", "this", "is", "function", "is", "more", ...
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L459-L474
[ "def", "string", "(", "string", ")", ":", "found", "=", "[", "]", "for", "c", "in", "string", ":", "found", ".", "append", "(", "one_of", "(", "c", ")", ")", "return", "found" ]
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
seq
Runs a series of parsers in sequence optionally storing results in a returned dictionary. For example: seq(whitespace, ('phone', digits), whitespace, ('name', remaining))
picoparse/__init__.py
def seq(*sequence): """Runs a series of parsers in sequence optionally storing results in a returned dictionary. For example: seq(whitespace, ('phone', digits), whitespace, ('name', remaining)) """ results = {} for p in sequence: if callable(p): p() continue...
def seq(*sequence): """Runs a series of parsers in sequence optionally storing results in a returned dictionary. For example: seq(whitespace, ('phone', digits), whitespace, ('name', remaining)) """ results = {} for p in sequence: if callable(p): p() continue...
[ "Runs", "a", "series", "of", "parsers", "in", "sequence", "optionally", "storing", "results", "in", "a", "returned", "dictionary", ".", "For", "example", ":", "seq", "(", "whitespace", "(", "phone", "digits", ")", "whitespace", "(", "name", "remaining", "))"...
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L504-L517
[ "def", "seq", "(", "*", "sequence", ")", ":", "results", "=", "{", "}", "for", "p", "in", "sequence", ":", "if", "callable", "(", "p", ")", ":", "p", "(", ")", "continue", "k", ",", "v", "=", "p", "results", "[", "k", "]", "=", "v", "(", ")...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
BufferWalker._fill
fills the internal buffer from the source iterator
picoparse/__init__.py
def _fill(self, size): """fills the internal buffer from the source iterator""" try: for i in range(size): self.buffer.append(self.source.next()) except StopIteration: self.buffer.append((EndOfFile, EndOfFile)) self.len = len(self.buffer)
def _fill(self, size): """fills the internal buffer from the source iterator""" try: for i in range(size): self.buffer.append(self.source.next()) except StopIteration: self.buffer.append((EndOfFile, EndOfFile)) self.len = len(self.buffer)
[ "fills", "the", "internal", "buffer", "from", "the", "source", "iterator" ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L146-L153
[ "def", "_fill", "(", "self", ",", "size", ")", ":", "try", ":", "for", "i", "in", "range", "(", "size", ")", ":", "self", ".", "buffer", ".", "append", "(", "self", ".", "source", ".", "next", "(", ")", ")", "except", "StopIteration", ":", "self"...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
BufferWalker.next
Advances to and returns the next token or returns EndOfFile
picoparse/__init__.py
def next(self): """Advances to and returns the next token or returns EndOfFile""" self.index += 1 t = self.peek() if not self.depth: self._cut() return t
def next(self): """Advances to and returns the next token or returns EndOfFile""" self.index += 1 t = self.peek() if not self.depth: self._cut() return t
[ "Advances", "to", "and", "returns", "the", "next", "token", "or", "returns", "EndOfFile" ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L155-L161
[ "def", "next", "(", "self", ")", ":", "self", ".", "index", "+=", "1", "t", "=", "self", ".", "peek", "(", ")", "if", "not", "self", ".", "depth", ":", "self", ".", "_cut", "(", ")", "return", "t" ]
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
BufferWalker.current
Returns the current (token, position) or (EndOfFile, EndOfFile)
picoparse/__init__.py
def current(self): """Returns the current (token, position) or (EndOfFile, EndOfFile)""" if self.index >= self.len: self._fill((self.index - self.len) + 1) return self.index < self.len and self.buffer[self.index] or (EndOfFile, EndOfFile)
def current(self): """Returns the current (token, position) or (EndOfFile, EndOfFile)""" if self.index >= self.len: self._fill((self.index - self.len) + 1) return self.index < self.len and self.buffer[self.index] or (EndOfFile, EndOfFile)
[ "Returns", "the", "current", "(", "token", "position", ")", "or", "(", "EndOfFile", "EndOfFile", ")" ]
brehaut/picoparse
python
https://github.com/brehaut/picoparse/blob/5e07c8e687a021bba58a5a2a76696c7a7ff35a1c/picoparse/__init__.py#L163-L167
[ "def", "current", "(", "self", ")", ":", "if", "self", ".", "index", ">=", "self", ".", "len", ":", "self", ".", "_fill", "(", "(", "self", ".", "index", "-", "self", ".", "len", ")", "+", "1", ")", "return", "self", ".", "index", "<", "self", ...
5e07c8e687a021bba58a5a2a76696c7a7ff35a1c
valid
main
Run a game being developed with the kxg game engine. Usage: {exe_name} sandbox [<num_ais>] [-v...] {exe_name} client [--host HOST] [--port PORT] [-v...] {exe_name} server <num_guis> [<num_ais>] [--host HOST] [--port PORT] [-v...] {exe_name} debug <num_guis> [<num_ais>] [--host HOST] [--port PORT] [-v....
kxg/quickstart.py
def main(world_cls, referee_cls, gui_cls, gui_actor_cls, ai_actor_cls, theater_cls=PygletTheater, default_host=DEFAULT_HOST, default_port=DEFAULT_PORT, argv=None): """ Run a game being developed with the kxg game engine. Usage: {exe_name} sandbox [<num_ais>] [-v...] {exe_name} client [--hos...
def main(world_cls, referee_cls, gui_cls, gui_actor_cls, ai_actor_cls, theater_cls=PygletTheater, default_host=DEFAULT_HOST, default_port=DEFAULT_PORT, argv=None): """ Run a game being developed with the kxg game engine. Usage: {exe_name} sandbox [<num_ais>] [-v...] {exe_name} client [--hos...
[ "Run", "a", "game", "being", "developed", "with", "the", "kxg", "game", "engine", "." ]
kxgames/kxg
python
https://github.com/kxgames/kxg/blob/a68c01dc4aa1abf6b3780ba2c65a7828282566aa/kxg/quickstart.py#L277-L387
[ "def", "main", "(", "world_cls", ",", "referee_cls", ",", "gui_cls", ",", "gui_actor_cls", ",", "ai_actor_cls", ",", "theater_cls", "=", "PygletTheater", ",", "default_host", "=", "DEFAULT_HOST", ",", "default_port", "=", "DEFAULT_PORT", ",", "argv", "=", "None"...
a68c01dc4aa1abf6b3780ba2c65a7828282566aa
valid
ProcessPool._run_supervisor
Poll the queues that the worker can use to communicate with the supervisor, until all the workers are done and all the queues are empty. Handle messages as they appear.
kxg/quickstart.py
def _run_supervisor(self): """ Poll the queues that the worker can use to communicate with the supervisor, until all the workers are done and all the queues are empty. Handle messages as they appear. """ import time still_supervising = lambda: ( ...
def _run_supervisor(self): """ Poll the queues that the worker can use to communicate with the supervisor, until all the workers are done and all the queues are empty. Handle messages as they appear. """ import time still_supervising = lambda: ( ...
[ "Poll", "the", "queues", "that", "the", "worker", "can", "use", "to", "communicate", "with", "the", "supervisor", "until", "all", "the", "workers", "are", "done", "and", "all", "the", "queues", "are", "empty", ".", "Handle", "messages", "as", "they", "appe...
kxgames/kxg
python
https://github.com/kxgames/kxg/blob/a68c01dc4aa1abf6b3780ba2c65a7828282566aa/kxg/quickstart.py#L143-L192
[ "def", "_run_supervisor", "(", "self", ")", ":", "import", "time", "still_supervising", "=", "lambda", ":", "(", "multiprocessing", ".", "active_children", "(", ")", "or", "not", "self", ".", "log_queue", ".", "empty", "(", ")", "or", "not", "self", ".", ...
a68c01dc4aa1abf6b3780ba2c65a7828282566aa
valid
JSONField.field_type
Return database field type.
muffin_peewee/fields.py
def field_type(self): """Return database field type.""" if not self.model: return 'JSON' database = self.model._meta.database if isinstance(database, Proxy): database = database.obj if Json and isinstance(database, PostgresqlDatabase): return '...
def field_type(self): """Return database field type.""" if not self.model: return 'JSON' database = self.model._meta.database if isinstance(database, Proxy): database = database.obj if Json and isinstance(database, PostgresqlDatabase): return '...
[ "Return", "database", "field", "type", "." ]
klen/muffin-peewee
python
https://github.com/klen/muffin-peewee/blob/8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e/muffin_peewee/fields.py#L25-L34
[ "def", "field_type", "(", "self", ")", ":", "if", "not", "self", ".", "model", ":", "return", "'JSON'", "database", "=", "self", ".", "model", ".", "_meta", ".", "database", "if", "isinstance", "(", "database", ",", "Proxy", ")", ":", "database", "=", ...
8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e
valid
JSONField.python_value
Parse value from database.
muffin_peewee/fields.py
def python_value(self, value): """Parse value from database.""" if self.field_type == 'TEXT' and isinstance(value, str): return self.loads(value) return value
def python_value(self, value): """Parse value from database.""" if self.field_type == 'TEXT' and isinstance(value, str): return self.loads(value) return value
[ "Parse", "value", "from", "database", "." ]
klen/muffin-peewee
python
https://github.com/klen/muffin-peewee/blob/8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e/muffin_peewee/fields.py#L46-L50
[ "def", "python_value", "(", "self", ",", "value", ")", ":", "if", "self", ".", "field_type", "==", "'TEXT'", "and", "isinstance", "(", "value", ",", "str", ")", ":", "return", "self", ".", "loads", "(", "value", ")", "return", "value" ]
8e893e3ea1dfc82fbcfc6efe784308c8d4e2852e
valid
AFSAPI.get_fsapi_endpoint
Parse the fsapi endpoint from the device url.
afsapi/__init__.py
def get_fsapi_endpoint(self): """Parse the fsapi endpoint from the device url.""" endpoint = yield from self.__session.get(self.fsapi_device_url, timeout = self.timeout) text = yield from endpoint.text(encoding='utf-8') doc = objectify.fromstring(text) return doc.webfsapi.text
def get_fsapi_endpoint(self): """Parse the fsapi endpoint from the device url.""" endpoint = yield from self.__session.get(self.fsapi_device_url, timeout = self.timeout) text = yield from endpoint.text(encoding='utf-8') doc = objectify.fromstring(text) return doc.webfsapi.text
[ "Parse", "the", "fsapi", "endpoint", "from", "the", "device", "url", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L79-L84
[ "def", "get_fsapi_endpoint", "(", "self", ")", ":", "endpoint", "=", "yield", "from", "self", ".", "__session", ".", "get", "(", "self", ".", "fsapi_device_url", ",", "timeout", "=", "self", ".", "timeout", ")", "text", "=", "yield", "from", "endpoint", ...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.create_session
Create a session on the frontier silicon device.
afsapi/__init__.py
def create_session(self): """Create a session on the frontier silicon device.""" req_url = '%s/%s' % (self.__webfsapi, 'CREATE_SESSION') sid = yield from self.__session.get(req_url, params=dict(pin=self.pin), timeout = self.timeout) text = yiel...
def create_session(self): """Create a session on the frontier silicon device.""" req_url = '%s/%s' % (self.__webfsapi, 'CREATE_SESSION') sid = yield from self.__session.get(req_url, params=dict(pin=self.pin), timeout = self.timeout) text = yiel...
[ "Create", "a", "session", "on", "the", "frontier", "silicon", "device", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L87-L94
[ "def", "create_session", "(", "self", ")", ":", "req_url", "=", "'%s/%s'", "%", "(", "self", ".", "__webfsapi", ",", "'CREATE_SESSION'", ")", "sid", "=", "yield", "from", "self", ".", "__session", ".", "get", "(", "req_url", ",", "params", "=", "dict", ...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.call
Execute a frontier silicon API call.
afsapi/__init__.py
def call(self, path, extra=None): """Execute a frontier silicon API call.""" try: if not self.__webfsapi: self.__webfsapi = yield from self.get_fsapi_endpoint() if not self.sid: self.sid = yield from self.create_session() if not isins...
def call(self, path, extra=None): """Execute a frontier silicon API call.""" try: if not self.__webfsapi: self.__webfsapi = yield from self.get_fsapi_endpoint() if not self.sid: self.sid = yield from self.create_session() if not isins...
[ "Execute", "a", "frontier", "silicon", "API", "call", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L97-L129
[ "def", "call", "(", "self", ",", "path", ",", "extra", "=", "None", ")", ":", "try", ":", "if", "not", "self", ".", "__webfsapi", ":", "self", ".", "__webfsapi", "=", "yield", "from", "self", ".", "get_fsapi_endpoint", "(", ")", "if", "not", "self", ...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.handle_set
Helper method for setting a value by using the fsapi API.
afsapi/__init__.py
def handle_set(self, item, value): """Helper method for setting a value by using the fsapi API.""" doc = yield from self.call('SET/{}'.format(item), dict(value=value)) if doc is None: return None return doc.status == 'FS_OK'
def handle_set(self, item, value): """Helper method for setting a value by using the fsapi API.""" doc = yield from self.call('SET/{}'.format(item), dict(value=value)) if doc is None: return None return doc.status == 'FS_OK'
[ "Helper", "method", "for", "setting", "a", "value", "by", "using", "the", "fsapi", "API", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L141-L147
[ "def", "handle_set", "(", "self", ",", "item", ",", "value", ")", ":", "doc", "=", "yield", "from", "self", ".", "call", "(", "'SET/{}'", ".", "format", "(", "item", ")", ",", "dict", "(", "value", "=", "value", ")", ")", "if", "doc", "is", "None...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.handle_text
Helper method for fetching a text value.
afsapi/__init__.py
def handle_text(self, item): """Helper method for fetching a text value.""" doc = yield from self.handle_get(item) if doc is None: return None return doc.value.c8_array.text or None
def handle_text(self, item): """Helper method for fetching a text value.""" doc = yield from self.handle_get(item) if doc is None: return None return doc.value.c8_array.text or None
[ "Helper", "method", "for", "fetching", "a", "text", "value", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L150-L156
[ "def", "handle_text", "(", "self", ",", "item", ")", ":", "doc", "=", "yield", "from", "self", ".", "handle_get", "(", "item", ")", "if", "doc", "is", "None", ":", "return", "None", "return", "doc", ".", "value", ".", "c8_array", ".", "text", "or", ...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.handle_int
Helper method for fetching a integer value.
afsapi/__init__.py
def handle_int(self, item): """Helper method for fetching a integer value.""" doc = yield from self.handle_get(item) if doc is None: return None return int(doc.value.u8.text) or None
def handle_int(self, item): """Helper method for fetching a integer value.""" doc = yield from self.handle_get(item) if doc is None: return None return int(doc.value.u8.text) or None
[ "Helper", "method", "for", "fetching", "a", "integer", "value", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L159-L165
[ "def", "handle_int", "(", "self", ",", "item", ")", ":", "doc", "=", "yield", "from", "self", ".", "handle_get", "(", "item", ")", "if", "doc", "is", "None", ":", "return", "None", "return", "int", "(", "doc", ".", "value", ".", "u8", ".", "text", ...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.handle_long
Helper method for fetching a long value. Result is integer.
afsapi/__init__.py
def handle_long(self, item): """Helper method for fetching a long value. Result is integer.""" doc = yield from self.handle_get(item) if doc is None: return None return int(doc.value.u32.text) or None
def handle_long(self, item): """Helper method for fetching a long value. Result is integer.""" doc = yield from self.handle_get(item) if doc is None: return None return int(doc.value.u32.text) or None
[ "Helper", "method", "for", "fetching", "a", "long", "value", ".", "Result", "is", "integer", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L169-L175
[ "def", "handle_long", "(", "self", ",", "item", ")", ":", "doc", "=", "yield", "from", "self", ".", "handle_get", "(", "item", ")", "if", "doc", "is", "None", ":", "return", "None", "return", "int", "(", "doc", ".", "value", ".", "u32", ".", "text"...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.handle_list
Helper method for fetching a list(map) value.
afsapi/__init__.py
def handle_list(self, item): """Helper method for fetching a list(map) value.""" doc = yield from self.call('LIST_GET_NEXT/'+item+'/-1', dict( maxItems=100, )) if doc is None: return [] if not doc.status == 'FS_OK': return [] ret = l...
def handle_list(self, item): """Helper method for fetching a list(map) value.""" doc = yield from self.call('LIST_GET_NEXT/'+item+'/-1', dict( maxItems=100, )) if doc is None: return [] if not doc.status == 'FS_OK': return [] ret = l...
[ "Helper", "method", "for", "fetching", "a", "list", "(", "map", ")", "value", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L178-L197
[ "def", "handle_list", "(", "self", ",", "item", ")", ":", "doc", "=", "yield", "from", "self", ".", "call", "(", "'LIST_GET_NEXT/'", "+", "item", "+", "'/-1'", ",", "dict", "(", "maxItems", "=", "100", ",", ")", ")", "if", "doc", "is", "None", ":",...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_power
Check if the device is on.
afsapi/__init__.py
def get_power(self): """Check if the device is on.""" power = (yield from self.handle_int(self.API.get('power'))) return bool(power)
def get_power(self): """Check if the device is on.""" power = (yield from self.handle_int(self.API.get('power'))) return bool(power)
[ "Check", "if", "the", "device", "is", "on", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L222-L225
[ "def", "get_power", "(", "self", ")", ":", "power", "=", "(", "yield", "from", "self", ".", "handle_int", "(", "self", ".", "API", ".", "get", "(", "'power'", ")", ")", ")", "return", "bool", "(", "power", ")" ]
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.set_power
Power on or off the device.
afsapi/__init__.py
def set_power(self, value=False): """Power on or off the device.""" power = (yield from self.handle_set( self.API.get('power'), int(value))) return bool(power)
def set_power(self, value=False): """Power on or off the device.""" power = (yield from self.handle_set( self.API.get('power'), int(value))) return bool(power)
[ "Power", "on", "or", "off", "the", "device", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L228-L232
[ "def", "set_power", "(", "self", ",", "value", "=", "False", ")", ":", "power", "=", "(", "yield", "from", "self", ".", "handle_set", "(", "self", ".", "API", ".", "get", "(", "'power'", ")", ",", "int", "(", "value", ")", ")", ")", "return", "bo...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_modes
Get the modes supported by this device.
afsapi/__init__.py
def get_modes(self): """Get the modes supported by this device.""" if not self.__modes: self.__modes = yield from self.handle_list( self.API.get('valid_modes')) return self.__modes
def get_modes(self): """Get the modes supported by this device.""" if not self.__modes: self.__modes = yield from self.handle_list( self.API.get('valid_modes')) return self.__modes
[ "Get", "the", "modes", "supported", "by", "this", "device", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L235-L241
[ "def", "get_modes", "(", "self", ")", ":", "if", "not", "self", ".", "__modes", ":", "self", ".", "__modes", "=", "yield", "from", "self", ".", "handle_list", "(", "self", ".", "API", ".", "get", "(", "'valid_modes'", ")", ")", "return", "self", ".",...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_mode_list
Get the label list of the supported modes.
afsapi/__init__.py
def get_mode_list(self): """Get the label list of the supported modes.""" self.__modes = yield from self.get_modes() return (yield from self.collect_labels(self.__modes))
def get_mode_list(self): """Get the label list of the supported modes.""" self.__modes = yield from self.get_modes() return (yield from self.collect_labels(self.__modes))
[ "Get", "the", "label", "list", "of", "the", "supported", "modes", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L244-L247
[ "def", "get_mode_list", "(", "self", ")", ":", "self", ".", "__modes", "=", "yield", "from", "self", ".", "get_modes", "(", ")", "return", "(", "yield", "from", "self", ".", "collect_labels", "(", "self", ".", "__modes", ")", ")" ]
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_mode
Get the currently active mode on the device (DAB, FM, Spotify).
afsapi/__init__.py
def get_mode(self): """Get the currently active mode on the device (DAB, FM, Spotify).""" mode = None int_mode = (yield from self.handle_long(self.API.get('mode'))) modes = yield from self.get_modes() for temp_mode in modes: if temp_mode['band'] == int_mode: ...
def get_mode(self): """Get the currently active mode on the device (DAB, FM, Spotify).""" mode = None int_mode = (yield from self.handle_long(self.API.get('mode'))) modes = yield from self.get_modes() for temp_mode in modes: if temp_mode['band'] == int_mode: ...
[ "Get", "the", "currently", "active", "mode", "on", "the", "device", "(", "DAB", "FM", "Spotify", ")", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L250-L259
[ "def", "get_mode", "(", "self", ")", ":", "mode", "=", "None", "int_mode", "=", "(", "yield", "from", "self", ".", "handle_long", "(", "self", ".", "API", ".", "get", "(", "'mode'", ")", ")", ")", "modes", "=", "yield", "from", "self", ".", "get_mo...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.set_mode
Set the currently active mode on the device (DAB, FM, Spotify).
afsapi/__init__.py
def set_mode(self, value): """Set the currently active mode on the device (DAB, FM, Spotify).""" mode = -1 modes = yield from self.get_modes() for temp_mode in modes: if temp_mode['label'] == value: mode = temp_mode['band'] return (yield from self.han...
def set_mode(self, value): """Set the currently active mode on the device (DAB, FM, Spotify).""" mode = -1 modes = yield from self.get_modes() for temp_mode in modes: if temp_mode['label'] == value: mode = temp_mode['band'] return (yield from self.han...
[ "Set", "the", "currently", "active", "mode", "on", "the", "device", "(", "DAB", "FM", "Spotify", ")", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L262-L270
[ "def", "set_mode", "(", "self", ",", "value", ")", ":", "mode", "=", "-", "1", "modes", "=", "yield", "from", "self", ".", "get_modes", "(", ")", "for", "temp_mode", "in", "modes", ":", "if", "temp_mode", "[", "'label'", "]", "==", "value", ":", "m...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_volume_steps
Read the maximum volume level of the device.
afsapi/__init__.py
def get_volume_steps(self): """Read the maximum volume level of the device.""" if not self.__volume_steps: self.__volume_steps = yield from self.handle_int( self.API.get('volume_steps')) return self.__volume_steps
def get_volume_steps(self): """Read the maximum volume level of the device.""" if not self.__volume_steps: self.__volume_steps = yield from self.handle_int( self.API.get('volume_steps')) return self.__volume_steps
[ "Read", "the", "maximum", "volume", "level", "of", "the", "device", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L273-L279
[ "def", "get_volume_steps", "(", "self", ")", ":", "if", "not", "self", ".", "__volume_steps", ":", "self", ".", "__volume_steps", "=", "yield", "from", "self", ".", "handle_int", "(", "self", ".", "API", ".", "get", "(", "'volume_steps'", ")", ")", "retu...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_mute
Check if the device is muted.
afsapi/__init__.py
def get_mute(self): """Check if the device is muted.""" mute = (yield from self.handle_int(self.API.get('mute'))) return bool(mute)
def get_mute(self): """Check if the device is muted.""" mute = (yield from self.handle_int(self.API.get('mute'))) return bool(mute)
[ "Check", "if", "the", "device", "is", "muted", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L294-L297
[ "def", "get_mute", "(", "self", ")", ":", "mute", "=", "(", "yield", "from", "self", ".", "handle_int", "(", "self", ".", "API", ".", "get", "(", "'mute'", ")", ")", ")", "return", "bool", "(", "mute", ")" ]
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.set_mute
Mute or unmute the device.
afsapi/__init__.py
def set_mute(self, value=False): """Mute or unmute the device.""" mute = (yield from self.handle_set(self.API.get('mute'), int(value))) return bool(mute)
def set_mute(self, value=False): """Mute or unmute the device.""" mute = (yield from self.handle_set(self.API.get('mute'), int(value))) return bool(mute)
[ "Mute", "or", "unmute", "the", "device", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L300-L303
[ "def", "set_mute", "(", "self", ",", "value", "=", "False", ")", ":", "mute", "=", "(", "yield", "from", "self", ".", "handle_set", "(", "self", ".", "API", ".", "get", "(", "'mute'", ")", ",", "int", "(", "value", ")", ")", ")", "return", "bool"...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_play_status
Get the play status of the device.
afsapi/__init__.py
def get_play_status(self): """Get the play status of the device.""" status = yield from self.handle_int(self.API.get('status')) return self.PLAY_STATES.get(status)
def get_play_status(self): """Get the play status of the device.""" status = yield from self.handle_int(self.API.get('status')) return self.PLAY_STATES.get(status)
[ "Get", "the", "play", "status", "of", "the", "device", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L306-L309
[ "def", "get_play_status", "(", "self", ")", ":", "status", "=", "yield", "from", "self", ".", "handle_int", "(", "self", ".", "API", ".", "get", "(", "'status'", ")", ")", "return", "self", ".", "PLAY_STATES", ".", "get", "(", "status", ")" ]
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_equalisers
Get the equaliser modes supported by this device.
afsapi/__init__.py
def get_equalisers(self): """Get the equaliser modes supported by this device.""" if not self.__equalisers: self.__equalisers = yield from self.handle_list( self.API.get('equalisers')) return self.__equalisers
def get_equalisers(self): """Get the equaliser modes supported by this device.""" if not self.__equalisers: self.__equalisers = yield from self.handle_list( self.API.get('equalisers')) return self.__equalisers
[ "Get", "the", "equaliser", "modes", "supported", "by", "this", "device", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L373-L379
[ "def", "get_equalisers", "(", "self", ")", ":", "if", "not", "self", ".", "__equalisers", ":", "self", ".", "__equalisers", "=", "yield", "from", "self", ".", "handle_list", "(", "self", ".", "API", ".", "get", "(", "'equalisers'", ")", ")", "return", ...
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.get_equaliser_list
Get the label list of the supported modes.
afsapi/__init__.py
def get_equaliser_list(self): """Get the label list of the supported modes.""" self.__equalisers = yield from self.get_equalisers() return (yield from self.collect_labels(self.__equalisers))
def get_equaliser_list(self): """Get the label list of the supported modes.""" self.__equalisers = yield from self.get_equalisers() return (yield from self.collect_labels(self.__equalisers))
[ "Get", "the", "label", "list", "of", "the", "supported", "modes", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L382-L385
[ "def", "get_equaliser_list", "(", "self", ")", ":", "self", ".", "__equalisers", "=", "yield", "from", "self", ".", "get_equalisers", "(", ")", "return", "(", "yield", "from", "self", ".", "collect_labels", "(", "self", ".", "__equalisers", ")", ")" ]
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
AFSAPI.set_sleep
Set device sleep timer.
afsapi/__init__.py
def set_sleep(self, value=False): """Set device sleep timer.""" return (yield from self.handle_set(self.API.get('sleep'), int(value)))
def set_sleep(self, value=False): """Set device sleep timer.""" return (yield from self.handle_set(self.API.get('sleep'), int(value)))
[ "Set", "device", "sleep", "timer", "." ]
zhelev/python-afsapi
python
https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L394-L396
[ "def", "set_sleep", "(", "self", ",", "value", "=", "False", ")", ":", "return", "(", "yield", "from", "self", ".", "handle_set", "(", "self", ".", "API", ".", "get", "(", "'sleep'", ")", ",", "int", "(", "value", ")", ")", ")" ]
bb1990cf1460ae42f2dde75f2291625ddac2c0e4
valid
BitAwareByteArray._set_range
Assumes that start and stop are already in 'buffer' coordinates. value is a byte iterable. value_len is fractional.
src/infi/instruct/buffer/io_buffer.py
def _set_range(self, start, stop, value, value_len): """ Assumes that start and stop are already in 'buffer' coordinates. value is a byte iterable. value_len is fractional. """ assert stop >= start and value_len >= 0 range_len = stop - start if range_len < value_l...
def _set_range(self, start, stop, value, value_len): """ Assumes that start and stop are already in 'buffer' coordinates. value is a byte iterable. value_len is fractional. """ assert stop >= start and value_len >= 0 range_len = stop - start if range_len < value_l...
[ "Assumes", "that", "start", "and", "stop", "are", "already", "in", "buffer", "coordinates", ".", "value", "is", "a", "byte", "iterable", ".", "value_len", "is", "fractional", "." ]
Infinidat/infi.instruct
python
https://github.com/Infinidat/infi.instruct/blob/93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8/src/infi/instruct/buffer/io_buffer.py#L167-L181
[ "def", "_set_range", "(", "self", ",", "start", ",", "stop", ",", "value", ",", "value_len", ")", ":", "assert", "stop", ">=", "start", "and", "value_len", ">=", "0", "range_len", "=", "stop", "-", "start", "if", "range_len", "<", "value_len", ":", "se...
93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8
valid
GenomeVCFLine._parse_genotype
Parse genotype from VCF line data
vcf2clinvar/genome.py
def _parse_genotype(self, vcf_fields): """Parse genotype from VCF line data""" format_col = vcf_fields[8].split(':') genome_data = vcf_fields[9].split(':') try: gt_idx = format_col.index('GT') except ValueError: return [] return [int(x) for x in re...
def _parse_genotype(self, vcf_fields): """Parse genotype from VCF line data""" format_col = vcf_fields[8].split(':') genome_data = vcf_fields[9].split(':') try: gt_idx = format_col.index('GT') except ValueError: return [] return [int(x) for x in re...
[ "Parse", "genotype", "from", "VCF", "line", "data" ]
madprime/vcf2clinvar
python
https://github.com/madprime/vcf2clinvar/blob/d5bbf6df2902c6cabe9ef1894cfac527e90fa32a/vcf2clinvar/genome.py#L19-L28
[ "def", "_parse_genotype", "(", "self", ",", "vcf_fields", ")", ":", "format_col", "=", "vcf_fields", "[", "8", "]", ".", "split", "(", "':'", ")", "genome_data", "=", "vcf_fields", "[", "9", "]", ".", "split", "(", "':'", ")", "try", ":", "gt_idx", "...
d5bbf6df2902c6cabe9ef1894cfac527e90fa32a
valid
setDefaultIREncoding
setDefaultIREncoding - Sets the default encoding used by IndexedRedis. This will be the default encoding used for field data. You can override this on a per-field basis by using an IRField (such as IRUnicodeField or IRRawField) @param encoding - An encoding (like utf-8)
IndexedRedis/compat_str.py
def setDefaultIREncoding(encoding): ''' setDefaultIREncoding - Sets the default encoding used by IndexedRedis. This will be the default encoding used for field data. You can override this on a per-field basis by using an IRField (such as IRUnicodeField or IRRawField) @param encoding - An encoding (like ut...
def setDefaultIREncoding(encoding): ''' setDefaultIREncoding - Sets the default encoding used by IndexedRedis. This will be the default encoding used for field data. You can override this on a per-field basis by using an IRField (such as IRUnicodeField or IRRawField) @param encoding - An encoding (like ut...
[ "setDefaultIREncoding", "-", "Sets", "the", "default", "encoding", "used", "by", "IndexedRedis", ".", "This", "will", "be", "the", "default", "encoding", "used", "for", "field", "data", ".", "You", "can", "override", "this", "on", "a", "per", "-", "field", ...
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/compat_str.py#L22-L36
[ "def", "setDefaultIREncoding", "(", "encoding", ")", ":", "try", ":", "b''", ".", "decode", "(", "encoding", ")", "except", ":", "raise", "ValueError", "(", "'setDefaultIREncoding was provided an invalid codec. Got (encoding=\"%s\")'", "%", "(", "str", "(", "encoding"...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRField.toIndex
toIndex - An optional method which will return the value prepped for index. By default, "toStorage" will be called. If you provide "hashIndex=True" on the constructor, the field will be md5summed for indexing purposes. This is useful for large strings, etc.
IndexedRedis/fields/__init__.py
def toIndex(self, value): ''' toIndex - An optional method which will return the value prepped for index. By default, "toStorage" will be called. If you provide "hashIndex=True" on the constructor, the field will be md5summed for indexing purposes. This is useful for large strings, etc. ''' if self._isI...
def toIndex(self, value): ''' toIndex - An optional method which will return the value prepped for index. By default, "toStorage" will be called. If you provide "hashIndex=True" on the constructor, the field will be md5summed for indexing purposes. This is useful for large strings, etc. ''' if self._isI...
[ "toIndex", "-", "An", "optional", "method", "which", "will", "return", "the", "value", "prepped", "for", "index", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/__init__.py#L250-L265
[ "def", "toIndex", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_isIrNull", "(", "value", ")", ":", "ret", "=", "IR_NULL_STR", "else", ":", "ret", "=", "self", ".", "_toIndex", "(", "value", ")", "if", "self", ".", "isIndexHashed", "is", ...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRField._getReprProperties
_getReprProperties - Get the properties of this field to display in repr(). These should be in the form of $propertyName=$propertyRepr The default IRField implementation handles just the "hashIndex" property. defaultValue is part of "__repr__" impl. You should just extend this method with your object...
IndexedRedis/fields/__init__.py
def _getReprProperties(self): ''' _getReprProperties - Get the properties of this field to display in repr(). These should be in the form of $propertyName=$propertyRepr The default IRField implementation handles just the "hashIndex" property. defaultValue is part of "__repr__" impl. You should just ...
def _getReprProperties(self): ''' _getReprProperties - Get the properties of this field to display in repr(). These should be in the form of $propertyName=$propertyRepr The default IRField implementation handles just the "hashIndex" property. defaultValue is part of "__repr__" impl. You should just ...
[ "_getReprProperties", "-", "Get", "the", "properties", "of", "this", "field", "to", "display", "in", "repr", "()", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/__init__.py#L331-L349
[ "def", "_getReprProperties", "(", "self", ")", ":", "ret", "=", "[", "]", "if", "getattr", "(", "self", ",", "'valueType'", ",", "None", ")", "is", "not", "None", ":", "ret", ".", "append", "(", "'valueType=%s'", "%", "(", "self", ".", "valueType", "...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRField.copy
copy - Create a copy of this IRField. Each subclass should implement this, as you'll need to pass in the args to constructor. @return <IRField (or subclass)> - Another IRField that has all the same values as this one.
IndexedRedis/fields/__init__.py
def copy(self): ''' copy - Create a copy of this IRField. Each subclass should implement this, as you'll need to pass in the args to constructor. @return <IRField (or subclass)> - Another IRField that has all the same values as this one. ''' return self.__class__(name=self.name, valueType=self.valueT...
def copy(self): ''' copy - Create a copy of this IRField. Each subclass should implement this, as you'll need to pass in the args to constructor. @return <IRField (or subclass)> - Another IRField that has all the same values as this one. ''' return self.__class__(name=self.name, valueType=self.valueT...
[ "copy", "-", "Create", "a", "copy", "of", "this", "IRField", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/__init__.py#L379-L387
[ "def", "copy", "(", "self", ")", ":", "return", "self", ".", "__class__", "(", "name", "=", "self", ".", "name", ",", "valueType", "=", "self", ".", "valueType", ",", "defaultValue", "=", "self", ".", "defaultValue", ",", "hashIndex", "=", "self", ".",...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
ForeignLinkData.getObj
getObj - Fetch (if not fetched) and return the obj associated with this data.
IndexedRedis/fields/foreign.py
def getObj(self): ''' getObj - Fetch (if not fetched) and return the obj associated with this data. ''' if self.obj is None: if not self.pk: return None self.obj = self.foreignModel.objects.get(self.pk) return self.obj
def getObj(self): ''' getObj - Fetch (if not fetched) and return the obj associated with this data. ''' if self.obj is None: if not self.pk: return None self.obj = self.foreignModel.objects.get(self.pk) return self.obj
[ "getObj", "-", "Fetch", "(", "if", "not", "fetched", ")", "and", "return", "the", "obj", "associated", "with", "this", "data", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L79-L88
[ "def", "getObj", "(", "self", ")", ":", "if", "self", ".", "obj", "is", "None", ":", "if", "not", "self", ".", "pk", ":", "return", "None", "self", ".", "obj", "=", "self", ".", "foreignModel", ".", "objects", ".", "get", "(", "self", ".", "pk", ...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
ForeignLinkData.getPk
getPk - Resolve any absent pk's off the obj's (like if an obj has been saved), and return the pk.
IndexedRedis/fields/foreign.py
def getPk(self): ''' getPk - Resolve any absent pk's off the obj's (like if an obj has been saved), and return the pk. ''' if not self.pk and self.obj: if self.obj._id: self.pk = self.obj._id return self.pk
def getPk(self): ''' getPk - Resolve any absent pk's off the obj's (like if an obj has been saved), and return the pk. ''' if not self.pk and self.obj: if self.obj._id: self.pk = self.obj._id return self.pk
[ "getPk", "-", "Resolve", "any", "absent", "pk", "s", "off", "the", "obj", "s", "(", "like", "if", "an", "obj", "has", "been", "saved", ")", "and", "return", "the", "pk", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L98-L106
[ "def", "getPk", "(", "self", ")", ":", "if", "not", "self", ".", "pk", "and", "self", ".", "obj", ":", "if", "self", ".", "obj", ".", "_id", ":", "self", ".", "pk", "=", "self", ".", "obj", ".", "_id", "return", "self", ".", "pk" ]
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
ForeignLinkData.objHasUnsavedChanges
objHasUnsavedChanges - Check if any object has unsaved changes, cascading.
IndexedRedis/fields/foreign.py
def objHasUnsavedChanges(self): ''' objHasUnsavedChanges - Check if any object has unsaved changes, cascading. ''' if not self.obj: return False return self.obj.hasUnsavedChanges(cascadeObjects=True)
def objHasUnsavedChanges(self): ''' objHasUnsavedChanges - Check if any object has unsaved changes, cascading. ''' if not self.obj: return False return self.obj.hasUnsavedChanges(cascadeObjects=True)
[ "objHasUnsavedChanges", "-", "Check", "if", "any", "object", "has", "unsaved", "changes", "cascading", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L135-L142
[ "def", "objHasUnsavedChanges", "(", "self", ")", ":", "if", "not", "self", ".", "obj", ":", "return", "False", "return", "self", ".", "obj", ".", "hasUnsavedChanges", "(", "cascadeObjects", "=", "True", ")" ]
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
ForeignLinkMultiData.getPk
getPk - @see ForeignLinkData.getPk
IndexedRedis/fields/foreign.py
def getPk(self): ''' getPk - @see ForeignLinkData.getPk ''' if not self.pk or None in self.pk: for i in range( len(self.pk) ): if self.pk[i]: continue if self.obj[i] and self.obj[i]._id: self.pk[i] = self.obj[i]._id return self.pk
def getPk(self): ''' getPk - @see ForeignLinkData.getPk ''' if not self.pk or None in self.pk: for i in range( len(self.pk) ): if self.pk[i]: continue if self.obj[i] and self.obj[i]._id: self.pk[i] = self.obj[i]._id return self.pk
[ "getPk", "-" ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L186-L198
[ "def", "getPk", "(", "self", ")", ":", "if", "not", "self", ".", "pk", "or", "None", "in", "self", ".", "pk", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "pk", ")", ")", ":", "if", "self", ".", "pk", "[", "i", "]", ":", ...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
ForeignLinkMultiData.getObj
getObj - @see ForeignLinkData.getObj Except this always returns a list
IndexedRedis/fields/foreign.py
def getObj(self): ''' getObj - @see ForeignLinkData.getObj Except this always returns a list ''' if self.obj: needPks = [ (i, self.pk[i]) for i in range(len(self.obj)) if self.obj[i] is None] if not needPks: return self.obj fetched = list(self.foreignModel.objects.getMultiple([needPk[1] for...
def getObj(self): ''' getObj - @see ForeignLinkData.getObj Except this always returns a list ''' if self.obj: needPks = [ (i, self.pk[i]) for i in range(len(self.obj)) if self.obj[i] is None] if not needPks: return self.obj fetched = list(self.foreignModel.objects.getMultiple([needPk[1] for...
[ "getObj", "-", "@see", "ForeignLinkData", ".", "getObj" ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L204-L223
[ "def", "getObj", "(", "self", ")", ":", "if", "self", ".", "obj", ":", "needPks", "=", "[", "(", "i", ",", "self", ".", "pk", "[", "i", "]", ")", "for", "i", "in", "range", "(", "len", "(", "self", ".", "obj", ")", ")", "if", "self", ".", ...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
ForeignLinkMultiData.isFetched
isFetched - @see ForeignLinkData.isFetched
IndexedRedis/fields/foreign.py
def isFetched(self): ''' isFetched - @see ForeignLinkData.isFetched ''' if not self.obj: return False if not self.pk or None in self.obj: return False return not bool(self.obj is None)
def isFetched(self): ''' isFetched - @see ForeignLinkData.isFetched ''' if not self.obj: return False if not self.pk or None in self.obj: return False return not bool(self.obj is None)
[ "isFetched", "-" ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L231-L240
[ "def", "isFetched", "(", "self", ")", ":", "if", "not", "self", ".", "obj", ":", "return", "False", "if", "not", "self", ".", "pk", "or", "None", "in", "self", ".", "obj", ":", "return", "False", "return", "not", "bool", "(", "self", ".", "obj", ...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
ForeignLinkMultiData.objHasUnsavedChanges
objHasUnsavedChanges - @see ForeignLinkData.objHasUnsavedChanges True if ANY object has unsaved changes.
IndexedRedis/fields/foreign.py
def objHasUnsavedChanges(self): ''' objHasUnsavedChanges - @see ForeignLinkData.objHasUnsavedChanges True if ANY object has unsaved changes. ''' if not self.obj: return False for thisObj in self.obj: if not thisObj: continue if thisObj.hasUnsavedChanges(cascadeObjects=True): return True...
def objHasUnsavedChanges(self): ''' objHasUnsavedChanges - @see ForeignLinkData.objHasUnsavedChanges True if ANY object has unsaved changes. ''' if not self.obj: return False for thisObj in self.obj: if not thisObj: continue if thisObj.hasUnsavedChanges(cascadeObjects=True): return True...
[ "objHasUnsavedChanges", "-", "@see", "ForeignLinkData", ".", "objHasUnsavedChanges" ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/foreign.py#L243-L258
[ "def", "objHasUnsavedChanges", "(", "self", ")", ":", "if", "not", "self", ".", "obj", ":", "return", "False", "for", "thisObj", "in", "self", ".", "obj", ":", "if", "not", "thisObj", ":", "continue", "if", "thisObj", ".", "hasUnsavedChanges", "(", "casc...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
assert_json_type
Check that a value has a certain JSON type. Raise TypeError if the type does not match. Supported types: str, int, float, bool, list, dict, and None. float will match any number, int will only match numbers without fractional part. The special type JList(x) will match a list value where each ...
jsonget/__init__.py
def assert_json_type(value: JsonValue, expected_type: JsonCheckType) -> None: """Check that a value has a certain JSON type. Raise TypeError if the type does not match. Supported types: str, int, float, bool, list, dict, and None. float will match any number, int will only match numbers without fr...
def assert_json_type(value: JsonValue, expected_type: JsonCheckType) -> None: """Check that a value has a certain JSON type. Raise TypeError if the type does not match. Supported types: str, int, float, bool, list, dict, and None. float will match any number, int will only match numbers without fr...
[ "Check", "that", "a", "value", "has", "a", "certain", "JSON", "type", "." ]
srittau/python-json-get
python
https://github.com/srittau/python-json-get/blob/eb21fa7a4ed7fbd324de1cb3ad73876297e49bf8/jsonget/__init__.py#L20-L59
[ "def", "assert_json_type", "(", "value", ":", "JsonValue", ",", "expected_type", ":", "JsonCheckType", ")", "->", "None", ":", "def", "type_name", "(", "t", ":", "Union", "[", "JsonCheckType", ",", "Type", "[", "None", "]", "]", ")", "->", "str", ":", ...
eb21fa7a4ed7fbd324de1cb3ad73876297e49bf8
valid
json_get
Get a JSON value by path, optionally checking its type. >>> j = {"foo": {"num": 3.4, "s": "Text"}, "arr": [10, 20, 30]} >>> json_get(j, "/foo/num") 3.4 >>> json_get(j, "/arr[1]") 20 Raise ValueError if the path is not found: >>> json_get(j, "/foo/unknown") Traceback (most recent call ...
jsonget/__init__.py
def json_get(json: JsonValue, path: str, expected_type: Any = ANY) -> Any: """Get a JSON value by path, optionally checking its type. >>> j = {"foo": {"num": 3.4, "s": "Text"}, "arr": [10, 20, 30]} >>> json_get(j, "/foo/num") 3.4 >>> json_get(j, "/arr[1]") 20 Raise ValueError if the path i...
def json_get(json: JsonValue, path: str, expected_type: Any = ANY) -> Any: """Get a JSON value by path, optionally checking its type. >>> j = {"foo": {"num": 3.4, "s": "Text"}, "arr": [10, 20, 30]} >>> json_get(j, "/foo/num") 3.4 >>> json_get(j, "/arr[1]") 20 Raise ValueError if the path i...
[ "Get", "a", "JSON", "value", "by", "path", "optionally", "checking", "its", "type", "." ]
srittau/python-json-get
python
https://github.com/srittau/python-json-get/blob/eb21fa7a4ed7fbd324de1cb3ad73876297e49bf8/jsonget/__init__.py#L127-L208
[ "def", "json_get", "(", "json", ":", "JsonValue", ",", "path", ":", "str", ",", "expected_type", ":", "Any", "=", "ANY", ")", "->", "Any", ":", "elements", "=", "_parse_json_path", "(", "path", ")", "current", "=", "json", "current_path", "=", "\"\"", ...
eb21fa7a4ed7fbd324de1cb3ad73876297e49bf8
valid
json_get_default
Get a JSON value by path, optionally checking its type. This works exactly like json_get(), but instead of raising ValueError or IndexError when a path part is not found, return the provided default value: >>> json_get_default({}, "/foo", "I am a default value") 'I am a default value' TypeErr...
jsonget/__init__.py
def json_get_default(json: JsonValue, path: str, default: Any, expected_type: Any = ANY) -> Any: """Get a JSON value by path, optionally checking its type. This works exactly like json_get(), but instead of raising ValueError or IndexError when a path part is not found, return the ...
def json_get_default(json: JsonValue, path: str, default: Any, expected_type: Any = ANY) -> Any: """Get a JSON value by path, optionally checking its type. This works exactly like json_get(), but instead of raising ValueError or IndexError when a path part is not found, return the ...
[ "Get", "a", "JSON", "value", "by", "path", "optionally", "checking", "its", "type", "." ]
srittau/python-json-get
python
https://github.com/srittau/python-json-get/blob/eb21fa7a4ed7fbd324de1cb3ad73876297e49bf8/jsonget/__init__.py#L282-L304
[ "def", "json_get_default", "(", "json", ":", "JsonValue", ",", "path", ":", "str", ",", "default", ":", "Any", ",", "expected_type", ":", "Any", "=", "ANY", ")", "->", "Any", ":", "try", ":", "return", "json_get", "(", "json", ",", "path", ",", "expe...
eb21fa7a4ed7fbd324de1cb3ad73876297e49bf8
valid
composite.load
Load json or yaml data from file handle. Args: fh (file): File handle to load from. Examlple: >>> with open('data.json', 'r') as json: >>> jsdata = composite.load(json) >>> >>> with open('data.yml', 'r') as yml: >>> ymldata ...
gems/datatypes.py
def load(cls, fh): """ Load json or yaml data from file handle. Args: fh (file): File handle to load from. Examlple: >>> with open('data.json', 'r') as json: >>> jsdata = composite.load(json) >>> >>> with open('data.yml', '...
def load(cls, fh): """ Load json or yaml data from file handle. Args: fh (file): File handle to load from. Examlple: >>> with open('data.json', 'r') as json: >>> jsdata = composite.load(json) >>> >>> with open('data.yml', '...
[ "Load", "json", "or", "yaml", "data", "from", "file", "handle", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L79-L98
[ "def", "load", "(", "cls", ",", "fh", ")", ":", "dat", "=", "fh", ".", "read", "(", ")", "try", ":", "ret", "=", "cls", ".", "from_json", "(", "dat", ")", "except", ":", "ret", "=", "cls", ".", "from_yaml", "(", "dat", ")", "return", "ret" ]
3ff76407af0e71621dada744cd964611e998699c
valid
composite.from_json
Load json from file handle. Args: fh (file): File handle to load from. Examlple: >>> with open('data.json', 'r') as json: >>> data = composite.load(json)
gems/datatypes.py
def from_json(cls, fh): """ Load json from file handle. Args: fh (file): File handle to load from. Examlple: >>> with open('data.json', 'r') as json: >>> data = composite.load(json) """ if isinstance(fh, str): return cl...
def from_json(cls, fh): """ Load json from file handle. Args: fh (file): File handle to load from. Examlple: >>> with open('data.json', 'r') as json: >>> data = composite.load(json) """ if isinstance(fh, str): return cl...
[ "Load", "json", "from", "file", "handle", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L101-L115
[ "def", "from_json", "(", "cls", ",", "fh", ")", ":", "if", "isinstance", "(", "fh", ",", "str", ")", ":", "return", "cls", "(", "json", ".", "loads", "(", "fh", ")", ")", "else", ":", "return", "cls", "(", "json", ".", "load", "(", "fh", ")", ...
3ff76407af0e71621dada744cd964611e998699c
valid
composite.intersection
Recursively compute intersection of data. For dictionaries, items for specific keys will be reduced to unique items. For lists, items will be reduced to unique items. This method is meant to be analogous to set.intersection for composite objects. Args: other (composite): Oth...
gems/datatypes.py
def intersection(self, other, recursive=True): """ Recursively compute intersection of data. For dictionaries, items for specific keys will be reduced to unique items. For lists, items will be reduced to unique items. This method is meant to be analogous to set.intersection for c...
def intersection(self, other, recursive=True): """ Recursively compute intersection of data. For dictionaries, items for specific keys will be reduced to unique items. For lists, items will be reduced to unique items. This method is meant to be analogous to set.intersection for c...
[ "Recursively", "compute", "intersection", "of", "data", ".", "For", "dictionaries", "items", "for", "specific", "keys", "will", "be", "reduced", "to", "unique", "items", ".", "For", "lists", "items", "will", "be", "reduced", "to", "unique", "items", ".", "Th...
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L253-L292
[ "def", "intersection", "(", "self", ",", "other", ",", "recursive", "=", "True", ")", ":", "if", "not", "isinstance", "(", "other", ",", "composite", ")", ":", "raise", "AssertionError", "(", "'Cannot intersect composite and {} types'", ".", "format", "(", "ty...
3ff76407af0e71621dada744cd964611e998699c
valid
composite.union
Recursively compute union of data. For dictionaries, items for specific keys will be combined into a list, depending on the status of the overwrite= parameter. For lists, items will be appended and reduced to unique items. This method is meant to be analogous to set.union for composite o...
gems/datatypes.py
def union(self, other, recursive=True, overwrite=False): """ Recursively compute union of data. For dictionaries, items for specific keys will be combined into a list, depending on the status of the overwrite= parameter. For lists, items will be appended and reduced to unique ite...
def union(self, other, recursive=True, overwrite=False): """ Recursively compute union of data. For dictionaries, items for specific keys will be combined into a list, depending on the status of the overwrite= parameter. For lists, items will be appended and reduced to unique ite...
[ "Recursively", "compute", "union", "of", "data", ".", "For", "dictionaries", "items", "for", "specific", "keys", "will", "be", "combined", "into", "a", "list", "depending", "on", "the", "status", "of", "the", "overwrite", "=", "parameter", ".", "For", "lists...
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L337-L386
[ "def", "union", "(", "self", ",", "other", ",", "recursive", "=", "True", ",", "overwrite", "=", "False", ")", ":", "if", "not", "isinstance", "(", "other", ",", "composite", ")", ":", "raise", "AssertionError", "(", "'Cannot union composite and {} types'", ...
3ff76407af0e71621dada744cd964611e998699c
valid
composite.update
Update internal dictionary object. This is meant to be an analog for dict.update().
gems/datatypes.py
def update(self, other): """ Update internal dictionary object. This is meant to be an analog for dict.update(). """ if self.meta_type == 'list': raise AssertionError('Cannot update object of `list` base type!') elif self.meta_type == 'dict': self....
def update(self, other): """ Update internal dictionary object. This is meant to be an analog for dict.update(). """ if self.meta_type == 'list': raise AssertionError('Cannot update object of `list` base type!') elif self.meta_type == 'dict': self....
[ "Update", "internal", "dictionary", "object", ".", "This", "is", "meant", "to", "be", "an", "analog", "for", "dict", ".", "update", "()", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L408-L417
[ "def", "update", "(", "self", ",", "other", ")", ":", "if", "self", ".", "meta_type", "==", "'list'", ":", "raise", "AssertionError", "(", "'Cannot update object of `list` base type!'", ")", "elif", "self", ".", "meta_type", "==", "'dict'", ":", "self", ".", ...
3ff76407af0e71621dada744cd964611e998699c
valid
composite.items
Return keys for object, if they are available.
gems/datatypes.py
def items(self): """ Return keys for object, if they are available. """ if self.meta_type == 'list': return self._list elif self.meta_type == 'dict': return self._dict.items()
def items(self): """ Return keys for object, if they are available. """ if self.meta_type == 'list': return self._list elif self.meta_type == 'dict': return self._dict.items()
[ "Return", "keys", "for", "object", "if", "they", "are", "available", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L428-L435
[ "def", "items", "(", "self", ")", ":", "if", "self", ".", "meta_type", "==", "'list'", ":", "return", "self", ".", "_list", "elif", "self", ".", "meta_type", "==", "'dict'", ":", "return", "self", ".", "_dict", ".", "items", "(", ")" ]
3ff76407af0e71621dada744cd964611e998699c
valid
composite.values
Return keys for object, if they are available.
gems/datatypes.py
def values(self): """ Return keys for object, if they are available. """ if self.meta_type == 'list': return self._list elif self.meta_type == 'dict': return self._dict.values()
def values(self): """ Return keys for object, if they are available. """ if self.meta_type == 'list': return self._list elif self.meta_type == 'dict': return self._dict.values()
[ "Return", "keys", "for", "object", "if", "they", "are", "available", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L437-L444
[ "def", "values", "(", "self", ")", ":", "if", "self", ".", "meta_type", "==", "'list'", ":", "return", "self", ".", "_list", "elif", "self", ".", "meta_type", "==", "'dict'", ":", "return", "self", ".", "_dict", ".", "values", "(", ")" ]
3ff76407af0e71621dada744cd964611e998699c
valid
composite.append
Append to object, if object is list.
gems/datatypes.py
def append(self, item): """ Append to object, if object is list. """ if self.meta_type == 'dict': raise AssertionError('Cannot append to object of `dict` base type!') if self.meta_type == 'list': self._list.append(item) return
def append(self, item): """ Append to object, if object is list. """ if self.meta_type == 'dict': raise AssertionError('Cannot append to object of `dict` base type!') if self.meta_type == 'list': self._list.append(item) return
[ "Append", "to", "object", "if", "object", "is", "list", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L446-L454
[ "def", "append", "(", "self", ",", "item", ")", ":", "if", "self", ".", "meta_type", "==", "'dict'", ":", "raise", "AssertionError", "(", "'Cannot append to object of `dict` base type!'", ")", "if", "self", ".", "meta_type", "==", "'list'", ":", "self", ".", ...
3ff76407af0e71621dada744cd964611e998699c
valid
composite.extend
Extend list from object, if object is list.
gems/datatypes.py
def extend(self, item): """ Extend list from object, if object is list. """ if self.meta_type == 'dict': raise AssertionError('Cannot extend to object of `dict` base type!') if self.meta_type == 'list': self._list.extend(item) return
def extend(self, item): """ Extend list from object, if object is list. """ if self.meta_type == 'dict': raise AssertionError('Cannot extend to object of `dict` base type!') if self.meta_type == 'list': self._list.extend(item) return
[ "Extend", "list", "from", "object", "if", "object", "is", "list", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L456-L464
[ "def", "extend", "(", "self", ",", "item", ")", ":", "if", "self", ".", "meta_type", "==", "'dict'", ":", "raise", "AssertionError", "(", "'Cannot extend to object of `dict` base type!'", ")", "if", "self", ".", "meta_type", "==", "'list'", ":", "self", ".", ...
3ff76407af0e71621dada744cd964611e998699c
valid
composite.json
Return JSON representation of object.
gems/datatypes.py
def json(self): """ Return JSON representation of object. """ if self.meta_type == 'list': ret = [] for dat in self._list: if not isinstance(dat, composite): ret.append(dat) else: ret.append(d...
def json(self): """ Return JSON representation of object. """ if self.meta_type == 'list': ret = [] for dat in self._list: if not isinstance(dat, composite): ret.append(dat) else: ret.append(d...
[ "Return", "JSON", "representation", "of", "object", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L466-L486
[ "def", "json", "(", "self", ")", ":", "if", "self", ".", "meta_type", "==", "'list'", ":", "ret", "=", "[", "]", "for", "dat", "in", "self", ".", "_list", ":", "if", "not", "isinstance", "(", "dat", ",", "composite", ")", ":", "ret", ".", "append...
3ff76407af0e71621dada744cd964611e998699c
valid
composite.write_json
Write composite object to file handle in JSON format. Args: fh (file): File handle to write to. pretty (bool): Sort keys and indent in output.
gems/datatypes.py
def write_json(self, fh, pretty=True): """ Write composite object to file handle in JSON format. Args: fh (file): File handle to write to. pretty (bool): Sort keys and indent in output. """ sjson = json.JSONEncoder().encode(self.json()) if pretty:...
def write_json(self, fh, pretty=True): """ Write composite object to file handle in JSON format. Args: fh (file): File handle to write to. pretty (bool): Sort keys and indent in output. """ sjson = json.JSONEncoder().encode(self.json()) if pretty:...
[ "Write", "composite", "object", "to", "file", "handle", "in", "JSON", "format", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L488-L501
[ "def", "write_json", "(", "self", ",", "fh", ",", "pretty", "=", "True", ")", ":", "sjson", "=", "json", ".", "JSONEncoder", "(", ")", ".", "encode", "(", "self", ".", "json", "(", ")", ")", "if", "pretty", ":", "json", ".", "dump", "(", "json", ...
3ff76407af0e71621dada744cd964611e998699c
valid
composite.write
API niceness defaulting to composite.write_json().
gems/datatypes.py
def write(self, fh, pretty=True): """ API niceness defaulting to composite.write_json(). """ return self.write_json(fh, pretty=pretty)
def write(self, fh, pretty=True): """ API niceness defaulting to composite.write_json(). """ return self.write_json(fh, pretty=pretty)
[ "API", "niceness", "defaulting", "to", "composite", ".", "write_json", "()", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L513-L517
[ "def", "write", "(", "self", ",", "fh", ",", "pretty", "=", "True", ")", ":", "return", "self", ".", "write_json", "(", "fh", ",", "pretty", "=", "pretty", ")" ]
3ff76407af0e71621dada744cd964611e998699c
valid
filetree.json
Return JSON representation of object.
gems/datatypes.py
def json(self): """ Return JSON representation of object. """ data = {} for item in self._data: if isinstance(self._data[item], filetree): data[item] = self._data[item].json() else: data[item] = self._data[item] retu...
def json(self): """ Return JSON representation of object. """ data = {} for item in self._data: if isinstance(self._data[item], filetree): data[item] = self._data[item].json() else: data[item] = self._data[item] retu...
[ "Return", "JSON", "representation", "of", "object", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L648-L658
[ "def", "json", "(", "self", ")", ":", "data", "=", "{", "}", "for", "item", "in", "self", ".", "_data", ":", "if", "isinstance", "(", "self", ".", "_data", "[", "item", "]", ",", "filetree", ")", ":", "data", "[", "item", "]", "=", "self", ".",...
3ff76407af0e71621dada744cd964611e998699c
valid
filetree.filelist
Return list of files in filetree.
gems/datatypes.py
def filelist(self): """ Return list of files in filetree. """ if len(self._filelist) == 0: for item in self._data: if isinstance(self._data[item], filetree): self._filelist.extend(self._data[item].filelist()) else: ...
def filelist(self): """ Return list of files in filetree. """ if len(self._filelist) == 0: for item in self._data: if isinstance(self._data[item], filetree): self._filelist.extend(self._data[item].filelist()) else: ...
[ "Return", "list", "of", "files", "in", "filetree", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L664-L674
[ "def", "filelist", "(", "self", ")", ":", "if", "len", "(", "self", ".", "_filelist", ")", "==", "0", ":", "for", "item", "in", "self", ".", "_data", ":", "if", "isinstance", "(", "self", ".", "_data", "[", "item", "]", ",", "filetree", ")", ":",...
3ff76407af0e71621dada744cd964611e998699c
valid
filetree.prune
Prune leaves of filetree according to specified regular expression. Args: regex (str): Regular expression to use in pruning tree.
gems/datatypes.py
def prune(self, regex=r".*"): """ Prune leaves of filetree according to specified regular expression. Args: regex (str): Regular expression to use in pruning tree. """ return filetree(self.root, ignore=self.ignore, regex=regex)
def prune(self, regex=r".*"): """ Prune leaves of filetree according to specified regular expression. Args: regex (str): Regular expression to use in pruning tree. """ return filetree(self.root, ignore=self.ignore, regex=regex)
[ "Prune", "leaves", "of", "filetree", "according", "to", "specified", "regular", "expression", "." ]
bprinty/gems
python
https://github.com/bprinty/gems/blob/3ff76407af0e71621dada744cd964611e998699c/gems/datatypes.py#L676-L684
[ "def", "prune", "(", "self", ",", "regex", "=", "r\".*\"", ")", ":", "return", "filetree", "(", "self", ".", "root", ",", "ignore", "=", "self", ".", "ignore", ",", "regex", "=", "regex", ")" ]
3ff76407af0e71621dada744cd964611e998699c
valid
Reference.deref
Returns the value this reference is pointing to. This method uses 'ctx' to resolve the reference and return the value this reference references. If the call was already made, it returns a cached result. It also makes sure there's no cyclic reference, and if so raises CyclicReferenceError.
src/infi/instruct/buffer/reference/reference.py
def deref(self, ctx): """ Returns the value this reference is pointing to. This method uses 'ctx' to resolve the reference and return the value this reference references. If the call was already made, it returns a cached result. It also makes sure there's no cyclic reference, and...
def deref(self, ctx): """ Returns the value this reference is pointing to. This method uses 'ctx' to resolve the reference and return the value this reference references. If the call was already made, it returns a cached result. It also makes sure there's no cyclic reference, and...
[ "Returns", "the", "value", "this", "reference", "is", "pointing", "to", ".", "This", "method", "uses", "ctx", "to", "resolve", "the", "reference", "and", "return", "the", "value", "this", "reference", "references", ".", "If", "the", "call", "was", "already",...
Infinidat/infi.instruct
python
https://github.com/Infinidat/infi.instruct/blob/93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8/src/infi/instruct/buffer/reference/reference.py#L70-L96
[ "def", "deref", "(", "self", ",", "ctx", ")", ":", "if", "self", "in", "ctx", ".", "call_nodes", ":", "raise", "CyclicReferenceError", "(", "ctx", ",", "self", ")", "if", "self", "in", "ctx", ".", "cached_results", ":", "return", "ctx", ".", "cached_re...
93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8
valid
IRQueryableList.getModel
getModel - get the IndexedRedisModel associated with this list. If one was not provided in constructor, it will be inferred from the first item in the list (if present) @return <None/IndexedRedisModel> - None if none could be found, otherwise the IndexedRedisModel type of the items in this list. @raises ...
IndexedRedis/IRQueryableList.py
def getModel(self): ''' getModel - get the IndexedRedisModel associated with this list. If one was not provided in constructor, it will be inferred from the first item in the list (if present) @return <None/IndexedRedisModel> - None if none could be found, otherwise the IndexedRedisModel type of the ite...
def getModel(self): ''' getModel - get the IndexedRedisModel associated with this list. If one was not provided in constructor, it will be inferred from the first item in the list (if present) @return <None/IndexedRedisModel> - None if none could be found, otherwise the IndexedRedisModel type of the ite...
[ "getModel", "-", "get", "the", "IndexedRedisModel", "associated", "with", "this", "list", ".", "If", "one", "was", "not", "provided", "in", "constructor", "it", "will", "be", "inferred", "from", "the", "first", "item", "in", "the", "list", "(", "if", "pres...
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/IRQueryableList.py#L70-L85
[ "def", "getModel", "(", "self", ")", ":", "if", "not", "self", ".", "mdl", "and", "len", "(", "self", ")", ">", "0", ":", "mdl", "=", "self", "[", "0", "]", ".", "__class__", "self", ".", "__validate_model", "(", "mdl", ")", "self", ".", "mdl", ...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRQueryableList.delete
delete - Delete all objects in this list. @return <int> - Number of objects deleted
IndexedRedis/IRQueryableList.py
def delete(self): ''' delete - Delete all objects in this list. @return <int> - Number of objects deleted ''' if len(self) == 0: return 0 mdl = self.getModel() return mdl.deleter.deleteMultiple(self)
def delete(self): ''' delete - Delete all objects in this list. @return <int> - Number of objects deleted ''' if len(self) == 0: return 0 mdl = self.getModel() return mdl.deleter.deleteMultiple(self)
[ "delete", "-", "Delete", "all", "objects", "in", "this", "list", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/IRQueryableList.py#L88-L97
[ "def", "delete", "(", "self", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "return", "0", "mdl", "=", "self", ".", "getModel", "(", ")", "return", "mdl", ".", "deleter", ".", "deleteMultiple", "(", "self", ")" ]
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRQueryableList.save
save - Save all objects in this list
IndexedRedis/IRQueryableList.py
def save(self): ''' save - Save all objects in this list ''' if len(self) == 0: return [] mdl = self.getModel() return mdl.saver.save(self)
def save(self): ''' save - Save all objects in this list ''' if len(self) == 0: return [] mdl = self.getModel() return mdl.saver.save(self)
[ "save", "-", "Save", "all", "objects", "in", "this", "list" ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/IRQueryableList.py#L100-L107
[ "def", "save", "(", "self", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "return", "[", "]", "mdl", "=", "self", ".", "getModel", "(", ")", "return", "mdl", ".", "saver", ".", "save", "(", "self", ")" ]
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRQueryableList.reload
reload - Reload all objects in this list. Updates in-place. To just fetch all these objects again, use "refetch" @return - List (same order as current objects) of either exception (KeyError) if operation failed, or a dict of fields changed -> (old, new)
IndexedRedis/IRQueryableList.py
def reload(self): ''' reload - Reload all objects in this list. Updates in-place. To just fetch all these objects again, use "refetch" @return - List (same order as current objects) of either exception (KeyError) if operation failed, or a dict of fields changed -> (old, new) ''' if len(self) == 0...
def reload(self): ''' reload - Reload all objects in this list. Updates in-place. To just fetch all these objects again, use "refetch" @return - List (same order as current objects) of either exception (KeyError) if operation failed, or a dict of fields changed -> (old, new) ''' if len(self) == 0...
[ "reload", "-", "Reload", "all", "objects", "in", "this", "list", ".", "Updates", "in", "-", "place", ".", "To", "just", "fetch", "all", "these", "objects", "again", "use", "refetch" ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/IRQueryableList.py#L110-L131
[ "def", "reload", "(", "self", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "return", "[", "]", "ret", "=", "[", "]", "for", "obj", "in", "self", ":", "res", "=", "None", "try", ":", "res", "=", "obj", ".", "reload", "(", ")", "e...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRQueryableList.refetch
refetch - Fetch a fresh copy of all items in this list. Returns a new list. To update in-place, use "reload". @return IRQueryableList<IndexedRedisModel> - List of fetched items
IndexedRedis/IRQueryableList.py
def refetch(self): ''' refetch - Fetch a fresh copy of all items in this list. Returns a new list. To update in-place, use "reload". @return IRQueryableList<IndexedRedisModel> - List of fetched items ''' if len(self) == 0: return IRQueryableList() mdl = self.getModel() pks = [item._id for item...
def refetch(self): ''' refetch - Fetch a fresh copy of all items in this list. Returns a new list. To update in-place, use "reload". @return IRQueryableList<IndexedRedisModel> - List of fetched items ''' if len(self) == 0: return IRQueryableList() mdl = self.getModel() pks = [item._id for item...
[ "refetch", "-", "Fetch", "a", "fresh", "copy", "of", "all", "items", "in", "this", "list", ".", "Returns", "a", "new", "list", ".", "To", "update", "in", "-", "place", "use", "reload", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/IRQueryableList.py#L134-L148
[ "def", "refetch", "(", "self", ")", ":", "if", "len", "(", "self", ")", "==", "0", ":", "return", "IRQueryableList", "(", ")", "mdl", "=", "self", ".", "getModel", "(", ")", "pks", "=", "[", "item", ".", "_id", "for", "item", "in", "self", "if", ...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
hashDictOneLevel
A function which can generate a hash of a one-level dict containing strings (like REDIS_CONNECTION_PARAMS) @param myDict <dict> - Dict with string keys and values @return <long> - Hash of myDict
IndexedRedis/utils.py
def hashDictOneLevel(myDict): ''' A function which can generate a hash of a one-level dict containing strings (like REDIS_CONNECTION_PARAMS) @param myDict <dict> - Dict with string keys and values @return <long> - Hash of myDict ''' keys = [str(x) for x in myDict.keys()] keys.sort() lst = [] for key...
def hashDictOneLevel(myDict): ''' A function which can generate a hash of a one-level dict containing strings (like REDIS_CONNECTION_PARAMS) @param myDict <dict> - Dict with string keys and values @return <long> - Hash of myDict ''' keys = [str(x) for x in myDict.keys()] keys.sort() lst = [] for key...
[ "A", "function", "which", "can", "generate", "a", "hash", "of", "a", "one", "-", "level", "dict", "containing", "strings", "(", "like", "REDIS_CONNECTION_PARAMS", ")" ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/utils.py#L9-L25
[ "def", "hashDictOneLevel", "(", "myDict", ")", ":", "keys", "=", "[", "str", "(", "x", ")", "for", "x", "in", "myDict", ".", "keys", "(", ")", "]", "keys", ".", "sort", "(", ")", "lst", "=", "[", "]", "for", "key", "in", "keys", ":", "lst", "...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
Blox.output
Outputs to a stream (like a file or request)
blox/base.py
def output(self, to=None, *args, **kwargs): '''Outputs to a stream (like a file or request)''' for blok in self: blok.output(to, *args, **kwargs) return self
def output(self, to=None, *args, **kwargs): '''Outputs to a stream (like a file or request)''' for blok in self: blok.output(to, *args, **kwargs) return self
[ "Outputs", "to", "a", "stream", "(", "like", "a", "file", "or", "request", ")" ]
timothycrosley/blox
python
https://github.com/timothycrosley/blox/blob/dc410783d2a2ecad918d1e19c6ee000d20e42d35/blox/base.py#L58-L62
[ "def", "output", "(", "self", ",", "to", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "blok", "in", "self", ":", "blok", ".", "output", "(", "to", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self" ]
dc410783d2a2ecad918d1e19c6ee000d20e42d35
valid
Blox.render
Renders as a str
blox/base.py
def render(self, *args, **kwargs): '''Renders as a str''' render_to = StringIO() self.output(render_to, *args, **kwargs) return render_to.getvalue()
def render(self, *args, **kwargs): '''Renders as a str''' render_to = StringIO() self.output(render_to, *args, **kwargs) return render_to.getvalue()
[ "Renders", "as", "a", "str" ]
timothycrosley/blox
python
https://github.com/timothycrosley/blox/blob/dc410783d2a2ecad918d1e19c6ee000d20e42d35/blox/base.py#L64-L68
[ "def", "render", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "render_to", "=", "StringIO", "(", ")", "self", ".", "output", "(", "render_to", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "render_to", ".", "getvalu...
dc410783d2a2ecad918d1e19c6ee000d20e42d35
valid
Container.output
Outputs to a stream (like a file or request)
blox/base.py
def output(self, to=None, formatted=False, indent=0, indentation=' ', *args, **kwargs): '''Outputs to a stream (like a file or request)''' if formatted and self.blox: self.blox[0].output(to=to, formatted=True, indent=indent, indentation=indentation, *args, **kwargs) for blok in ...
def output(self, to=None, formatted=False, indent=0, indentation=' ', *args, **kwargs): '''Outputs to a stream (like a file or request)''' if formatted and self.blox: self.blox[0].output(to=to, formatted=True, indent=indent, indentation=indentation, *args, **kwargs) for blok in ...
[ "Outputs", "to", "a", "stream", "(", "like", "a", "file", "or", "request", ")" ]
timothycrosley/blox
python
https://github.com/timothycrosley/blox/blob/dc410783d2a2ecad918d1e19c6ee000d20e42d35/blox/base.py#L313-L327
[ "def", "output", "(", "self", ",", "to", "=", "None", ",", "formatted", "=", "False", ",", "indent", "=", "0", ",", "indentation", "=", "' '", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "formatted", "and", "self", ".", "blox", ":...
dc410783d2a2ecad918d1e19c6ee000d20e42d35
valid
AbstractTag.start_tag
Returns the elements HTML start tag
blox/base.py
def start_tag(self): '''Returns the elements HTML start tag''' direct_attributes = (attribute.render(self) for attribute in self.render_attributes) attributes = () if hasattr(self, '_attributes'): attributes = ('{0}="{1}"'.format(key, value) ...
def start_tag(self): '''Returns the elements HTML start tag''' direct_attributes = (attribute.render(self) for attribute in self.render_attributes) attributes = () if hasattr(self, '_attributes'): attributes = ('{0}="{1}"'.format(key, value) ...
[ "Returns", "the", "elements", "HTML", "start", "tag" ]
timothycrosley/blox
python
https://github.com/timothycrosley/blox/blob/dc410783d2a2ecad918d1e19c6ee000d20e42d35/blox/base.py#L365-L375
[ "def", "start_tag", "(", "self", ")", ":", "direct_attributes", "=", "(", "attribute", ".", "render", "(", "self", ")", "for", "attribute", "in", "self", ".", "render_attributes", ")", "attributes", "=", "(", ")", "if", "hasattr", "(", "self", ",", "'_at...
dc410783d2a2ecad918d1e19c6ee000d20e42d35
valid
AbstractTag.output
Outputs to a stream (like a file or request)
blox/base.py
def output(self, to=None, *args, **kwargs): '''Outputs to a stream (like a file or request)''' to.write(self.start_tag) if not self.tag_self_closes: to.write(self.end_tag)
def output(self, to=None, *args, **kwargs): '''Outputs to a stream (like a file or request)''' to.write(self.start_tag) if not self.tag_self_closes: to.write(self.end_tag)
[ "Outputs", "to", "a", "stream", "(", "like", "a", "file", "or", "request", ")" ]
timothycrosley/blox
python
https://github.com/timothycrosley/blox/blob/dc410783d2a2ecad918d1e19c6ee000d20e42d35/blox/base.py#L385-L389
[ "def", "output", "(", "self", ",", "to", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "to", ".", "write", "(", "self", ".", "start_tag", ")", "if", "not", "self", ".", "tag_self_closes", ":", "to", ".", "write", "(", "self", ...
dc410783d2a2ecad918d1e19c6ee000d20e42d35
valid
TagWithChildren.output
Outputs to a stream (like a file or request)
blox/base.py
def output(self, to=None, formatted=False, indent=0, indentation=' ', *args, **kwargs): '''Outputs to a stream (like a file or request)''' if formatted: to.write(self.start_tag) to.write('\n') if not self.tag_self_closes: for blok in self.blox: ...
def output(self, to=None, formatted=False, indent=0, indentation=' ', *args, **kwargs): '''Outputs to a stream (like a file or request)''' if formatted: to.write(self.start_tag) to.write('\n') if not self.tag_self_closes: for blok in self.blox: ...
[ "Outputs", "to", "a", "stream", "(", "like", "a", "file", "or", "request", ")" ]
timothycrosley/blox
python
https://github.com/timothycrosley/blox/blob/dc410783d2a2ecad918d1e19c6ee000d20e42d35/blox/base.py#L450-L470
[ "def", "output", "(", "self", ",", "to", "=", "None", ",", "formatted", "=", "False", ",", "indent", "=", "0", ",", "indentation", "=", "' '", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "formatted", ":", "to", ".", "write", "(", ...
dc410783d2a2ecad918d1e19c6ee000d20e42d35
valid
safe_repr
Returns a repr of an object and falls back to a minimal representation of type and ID if the call to repr raised an error. :param obj: object to safe repr :returns: repr string or '(type<id> repr error)' string :rtype: str
src/infi/instruct/utils/safe_repr.py
def safe_repr(obj): """Returns a repr of an object and falls back to a minimal representation of type and ID if the call to repr raised an error. :param obj: object to safe repr :returns: repr string or '(type<id> repr error)' string :rtype: str """ try: obj_repr = repr(obj) exc...
def safe_repr(obj): """Returns a repr of an object and falls back to a minimal representation of type and ID if the call to repr raised an error. :param obj: object to safe repr :returns: repr string or '(type<id> repr error)' string :rtype: str """ try: obj_repr = repr(obj) exc...
[ "Returns", "a", "repr", "of", "an", "object", "and", "falls", "back", "to", "a", "minimal", "representation", "of", "type", "and", "ID", "if", "the", "call", "to", "repr", "raised", "an", "error", "." ]
Infinidat/infi.instruct
python
https://github.com/Infinidat/infi.instruct/blob/93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8/src/infi/instruct/utils/safe_repr.py#L1-L13
[ "def", "safe_repr", "(", "obj", ")", ":", "try", ":", "obj_repr", "=", "repr", "(", "obj", ")", "except", ":", "obj_repr", "=", "\"({0}<{1}> repr error)\"", ".", "format", "(", "type", "(", "obj", ")", ",", "id", "(", "obj", ")", ")", "return", "obj_...
93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8
valid
DocType.output
Outputs the set text
blox/dom.py
def output(self, to=None, formatted=False, *args, **kwargs): '''Outputs the set text''' to.write('<!DOCTYPE {0}>'.format(self.type))
def output(self, to=None, formatted=False, *args, **kwargs): '''Outputs the set text''' to.write('<!DOCTYPE {0}>'.format(self.type))
[ "Outputs", "the", "set", "text" ]
timothycrosley/blox
python
https://github.com/timothycrosley/blox/blob/dc410783d2a2ecad918d1e19c6ee000d20e42d35/blox/dom.py#L49-L51
[ "def", "output", "(", "self", ",", "to", "=", "None", ",", "formatted", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "to", ".", "write", "(", "'<!DOCTYPE {0}>'", ".", "format", "(", "self", ".", "type", ")", ")" ]
dc410783d2a2ecad918d1e19c6ee000d20e42d35
valid
match_to_clinvar
Match a genome VCF to variants in the ClinVar VCF file Acts as a generator, yielding tuples of: (ClinVarVCFLine, ClinVarAllele, zygosity) 'zygosity' is a string and corresponds to the genome's zygosity for that ClinVarAllele. It can be either: 'Het' (heterozygous), 'Hom' (homozygous), or 'Hem' (he...
vcf2clinvar/__init__.py
def match_to_clinvar(genome_file, clin_file): """ Match a genome VCF to variants in the ClinVar VCF file Acts as a generator, yielding tuples of: (ClinVarVCFLine, ClinVarAllele, zygosity) 'zygosity' is a string and corresponds to the genome's zygosity for that ClinVarAllele. It can be either: ...
def match_to_clinvar(genome_file, clin_file): """ Match a genome VCF to variants in the ClinVar VCF file Acts as a generator, yielding tuples of: (ClinVarVCFLine, ClinVarAllele, zygosity) 'zygosity' is a string and corresponds to the genome's zygosity for that ClinVarAllele. It can be either: ...
[ "Match", "a", "genome", "VCF", "to", "variants", "in", "the", "ClinVar", "VCF", "file" ]
madprime/vcf2clinvar
python
https://github.com/madprime/vcf2clinvar/blob/d5bbf6df2902c6cabe9ef1894cfac527e90fa32a/vcf2clinvar/__init__.py#L22-L115
[ "def", "match_to_clinvar", "(", "genome_file", ",", "clin_file", ")", ":", "clin_curr_line", "=", "_next_line", "(", "clin_file", ")", "genome_curr_line", "=", "_next_line", "(", "genome_file", ")", "# Ignores all the lines that start with a hashtag", "while", "clin_curr_...
d5bbf6df2902c6cabe9ef1894cfac527e90fa32a
valid
Allele.as_dict
Return Allele data as dict object.
vcf2clinvar/common.py
def as_dict(self): """Return Allele data as dict object.""" self_as_dict = dict() self_as_dict['sequence'] = self.sequence if hasattr(self, 'frequency'): self_as_dict['frequency'] = self.frequency return self_as_dict
def as_dict(self): """Return Allele data as dict object.""" self_as_dict = dict() self_as_dict['sequence'] = self.sequence if hasattr(self, 'frequency'): self_as_dict['frequency'] = self.frequency return self_as_dict
[ "Return", "Allele", "data", "as", "dict", "object", "." ]
madprime/vcf2clinvar
python
https://github.com/madprime/vcf2clinvar/blob/d5bbf6df2902c6cabe9ef1894cfac527e90fa32a/vcf2clinvar/common.py#L78-L84
[ "def", "as_dict", "(", "self", ")", ":", "self_as_dict", "=", "dict", "(", ")", "self_as_dict", "[", "'sequence'", "]", "=", "self", ".", "sequence", "if", "hasattr", "(", "self", ",", "'frequency'", ")", ":", "self_as_dict", "[", "'frequency'", "]", "="...
d5bbf6df2902c6cabe9ef1894cfac527e90fa32a
valid
VCFLine._parse_allele_data
Create list of Alleles from VCF line data
vcf2clinvar/common.py
def _parse_allele_data(self): """Create list of Alleles from VCF line data""" return [Allele(sequence=x) for x in [self.ref_allele] + self.alt_alleles]
def _parse_allele_data(self): """Create list of Alleles from VCF line data""" return [Allele(sequence=x) for x in [self.ref_allele] + self.alt_alleles]
[ "Create", "list", "of", "Alleles", "from", "VCF", "line", "data" ]
madprime/vcf2clinvar
python
https://github.com/madprime/vcf2clinvar/blob/d5bbf6df2902c6cabe9ef1894cfac527e90fa32a/vcf2clinvar/common.py#L111-L114
[ "def", "_parse_allele_data", "(", "self", ")", ":", "return", "[", "Allele", "(", "sequence", "=", "x", ")", "for", "x", "in", "[", "self", ".", "ref_allele", "]", "+", "self", ".", "alt_alleles", "]" ]
d5bbf6df2902c6cabe9ef1894cfac527e90fa32a
valid
VCFLine._parse_info
Parse the VCF info field
vcf2clinvar/common.py
def _parse_info(self, info_field): """Parse the VCF info field""" info = dict() for item in info_field.split(';'): # Info fields may be "foo=bar" or just "foo". # For the first case, store key "foo" with value "bar" # For the second case, store key "foo" with ...
def _parse_info(self, info_field): """Parse the VCF info field""" info = dict() for item in info_field.split(';'): # Info fields may be "foo=bar" or just "foo". # For the first case, store key "foo" with value "bar" # For the second case, store key "foo" with ...
[ "Parse", "the", "VCF", "info", "field" ]
madprime/vcf2clinvar
python
https://github.com/madprime/vcf2clinvar/blob/d5bbf6df2902c6cabe9ef1894cfac527e90fa32a/vcf2clinvar/common.py#L116-L129
[ "def", "_parse_info", "(", "self", ",", "info_field", ")", ":", "info", "=", "dict", "(", ")", "for", "item", "in", "info_field", ".", "split", "(", "';'", ")", ":", "# Info fields may be \"foo=bar\" or just \"foo\".", "# For the first case, store key \"foo\" with val...
d5bbf6df2902c6cabe9ef1894cfac527e90fa32a
valid
VCFLine.as_dict
Dict representation of parsed VCF data
vcf2clinvar/common.py
def as_dict(self): """Dict representation of parsed VCF data""" self_as_dict = {'chrom': self.chrom, 'start': self.start, 'ref_allele': self.ref_allele, 'alt_alleles': self.alt_alleles, 'alleles': [x.as_dict(...
def as_dict(self): """Dict representation of parsed VCF data""" self_as_dict = {'chrom': self.chrom, 'start': self.start, 'ref_allele': self.ref_allele, 'alt_alleles': self.alt_alleles, 'alleles': [x.as_dict(...
[ "Dict", "representation", "of", "parsed", "VCF", "data" ]
madprime/vcf2clinvar
python
https://github.com/madprime/vcf2clinvar/blob/d5bbf6df2902c6cabe9ef1894cfac527e90fa32a/vcf2clinvar/common.py#L135-L146
[ "def", "as_dict", "(", "self", ")", ":", "self_as_dict", "=", "{", "'chrom'", ":", "self", ".", "chrom", ",", "'start'", ":", "self", ".", "start", ",", "'ref_allele'", ":", "self", ".", "ref_allele", ",", "'alt_alleles'", ":", "self", ".", "alt_alleles"...
d5bbf6df2902c6cabe9ef1894cfac527e90fa32a
valid
VCFLine.get_pos
Very lightweight parsing of a vcf line to get position. Returns a dict containing: 'chrom': index of chromosome (int), indicates sort order 'pos': position on chromosome (int)
vcf2clinvar/common.py
def get_pos(vcf_line): """ Very lightweight parsing of a vcf line to get position. Returns a dict containing: 'chrom': index of chromosome (int), indicates sort order 'pos': position on chromosome (int) """ if not vcf_line: return None vcf_dat...
def get_pos(vcf_line): """ Very lightweight parsing of a vcf line to get position. Returns a dict containing: 'chrom': index of chromosome (int), indicates sort order 'pos': position on chromosome (int) """ if not vcf_line: return None vcf_dat...
[ "Very", "lightweight", "parsing", "of", "a", "vcf", "line", "to", "get", "position", "." ]
madprime/vcf2clinvar
python
https://github.com/madprime/vcf2clinvar/blob/d5bbf6df2902c6cabe9ef1894cfac527e90fa32a/vcf2clinvar/common.py#L149-L163
[ "def", "get_pos", "(", "vcf_line", ")", ":", "if", "not", "vcf_line", ":", "return", "None", "vcf_data", "=", "vcf_line", ".", "strip", "(", ")", ".", "split", "(", "'\\t'", ")", "return_data", "=", "dict", "(", ")", "return_data", "[", "'chrom'", "]",...
d5bbf6df2902c6cabe9ef1894cfac527e90fa32a
valid
IRFieldChain._toStorage
_toStorage - Convert the value to a string representation for storage. @param value - The value of the item to convert @return A string value suitable for storing.
IndexedRedis/fields/chain.py
def _toStorage(self, value): ''' _toStorage - Convert the value to a string representation for storage. @param value - The value of the item to convert @return A string value suitable for storing. ''' for chainedField in self.chainedFields: value = chainedField.toStorage(value) return value
def _toStorage(self, value): ''' _toStorage - Convert the value to a string representation for storage. @param value - The value of the item to convert @return A string value suitable for storing. ''' for chainedField in self.chainedFields: value = chainedField.toStorage(value) return value
[ "_toStorage", "-", "Convert", "the", "value", "to", "a", "string", "representation", "for", "storage", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/chain.py#L81-L92
[ "def", "_toStorage", "(", "self", ",", "value", ")", ":", "for", "chainedField", "in", "self", ".", "chainedFields", ":", "value", "=", "chainedField", ".", "toStorage", "(", "value", ")", "return", "value" ]
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRFieldChain._fromStorage
_fromStorage - Convert the value from storage (string) to the value type. @return - The converted value, or "irNull" if no value was defined (and field type is not default/string)
IndexedRedis/fields/chain.py
def _fromStorage(self, value): ''' _fromStorage - Convert the value from storage (string) to the value type. @return - The converted value, or "irNull" if no value was defined (and field type is not default/string) ''' for chainedField in reversed(self.chainedFields): value = chainedField._fromStorage(...
def _fromStorage(self, value): ''' _fromStorage - Convert the value from storage (string) to the value type. @return - The converted value, or "irNull" if no value was defined (and field type is not default/string) ''' for chainedField in reversed(self.chainedFields): value = chainedField._fromStorage(...
[ "_fromStorage", "-", "Convert", "the", "value", "from", "storage", "(", "string", ")", "to", "the", "value", "type", "." ]
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/chain.py#L94-L104
[ "def", "_fromStorage", "(", "self", ",", "value", ")", ":", "for", "chainedField", "in", "reversed", "(", "self", ".", "chainedFields", ")", ":", "value", "=", "chainedField", ".", "_fromStorage", "(", "value", ")", "return", "value" ]
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
IRFieldChain._checkCanIndex
_checkCanIndex - Check if we CAN index (if all fields are indexable). Also checks the right-most field for "hashIndex" - if it needs to hash we will hash.
IndexedRedis/fields/chain.py
def _checkCanIndex(self): ''' _checkCanIndex - Check if we CAN index (if all fields are indexable). Also checks the right-most field for "hashIndex" - if it needs to hash we will hash. ''' # NOTE: We can't just check the right-most field. For types like pickle that don't support indexing, they don't # ...
def _checkCanIndex(self): ''' _checkCanIndex - Check if we CAN index (if all fields are indexable). Also checks the right-most field for "hashIndex" - if it needs to hash we will hash. ''' # NOTE: We can't just check the right-most field. For types like pickle that don't support indexing, they don't # ...
[ "_checkCanIndex", "-", "Check", "if", "we", "CAN", "index", "(", "if", "all", "fields", "are", "indexable", ")", ".", "Also", "checks", "the", "right", "-", "most", "field", "for", "hashIndex", "-", "if", "it", "needs", "to", "hash", "we", "will", "has...
kata198/indexedredis
python
https://github.com/kata198/indexedredis/blob/f9c85adcf5218dac25acb06eedc63fc2950816fa/IndexedRedis/fields/chain.py#L131-L147
[ "def", "_checkCanIndex", "(", "self", ")", ":", "# NOTE: We can't just check the right-most field. For types like pickle that don't support indexing, they don't", "# support it because python2 and python3 have different results for pickle.dumps on the same object.", "# So if we have a field chai...
f9c85adcf5218dac25acb06eedc63fc2950816fa
valid
SequentialRangeList.byte_length
:returns: sum of lengthes of all ranges or None if one of the ranges is open :rtype: int, float or None
src/infi/instruct/buffer/range.py
def byte_length(self): """ :returns: sum of lengthes of all ranges or None if one of the ranges is open :rtype: int, float or None """ sum = 0 for r in self: if r.is_open(): return None sum += r.byte_length() return sum
def byte_length(self): """ :returns: sum of lengthes of all ranges or None if one of the ranges is open :rtype: int, float or None """ sum = 0 for r in self: if r.is_open(): return None sum += r.byte_length() return sum
[ ":", "returns", ":", "sum", "of", "lengthes", "of", "all", "ranges", "or", "None", "if", "one", "of", "the", "ranges", "is", "open", ":", "rtype", ":", "int", "float", "or", "None" ]
Infinidat/infi.instruct
python
https://github.com/Infinidat/infi.instruct/blob/93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8/src/infi/instruct/buffer/range.py#L124-L134
[ "def", "byte_length", "(", "self", ")", ":", "sum", "=", "0", "for", "r", "in", "self", ":", "if", "r", ".", "is_open", "(", ")", ":", "return", "None", "sum", "+=", "r", ".", "byte_length", "(", ")", "return", "sum" ]
93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8
valid
SequentialRangeList.has_overlaps
:returns: True if one or more range in the list overlaps with another :rtype: bool
src/infi/instruct/buffer/range.py
def has_overlaps(self): """ :returns: True if one or more range in the list overlaps with another :rtype: bool """ sorted_list = sorted(self) for i in range(0, len(sorted_list) - 1): if sorted_list[i].overlaps(sorted_list[i + 1]): return True ...
def has_overlaps(self): """ :returns: True if one or more range in the list overlaps with another :rtype: bool """ sorted_list = sorted(self) for i in range(0, len(sorted_list) - 1): if sorted_list[i].overlaps(sorted_list[i + 1]): return True ...
[ ":", "returns", ":", "True", "if", "one", "or", "more", "range", "in", "the", "list", "overlaps", "with", "another", ":", "rtype", ":", "bool" ]
Infinidat/infi.instruct
python
https://github.com/Infinidat/infi.instruct/blob/93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8/src/infi/instruct/buffer/range.py#L136-L145
[ "def", "has_overlaps", "(", "self", ")", ":", "sorted_list", "=", "sorted", "(", "self", ")", "for", "i", "in", "range", "(", "0", ",", "len", "(", "sorted_list", ")", "-", "1", ")", ":", "if", "sorted_list", "[", "i", "]", ".", "overlaps", "(", ...
93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8
valid
SequentialRangeList.max_stop
:returns: maximum stop in list or None if there's at least one open range :type: int, float or None
src/infi/instruct/buffer/range.py
def max_stop(self): """ :returns: maximum stop in list or None if there's at least one open range :type: int, float or None """ m = 0 for r in self: if r.is_open(): return None m = max(m, r.stop) return m
def max_stop(self): """ :returns: maximum stop in list or None if there's at least one open range :type: int, float or None """ m = 0 for r in self: if r.is_open(): return None m = max(m, r.stop) return m
[ ":", "returns", ":", "maximum", "stop", "in", "list", "or", "None", "if", "there", "s", "at", "least", "one", "open", "range", ":", "type", ":", "int", "float", "or", "None" ]
Infinidat/infi.instruct
python
https://github.com/Infinidat/infi.instruct/blob/93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8/src/infi/instruct/buffer/range.py#L147-L157
[ "def", "max_stop", "(", "self", ")", ":", "m", "=", "0", "for", "r", "in", "self", ":", "if", "r", ".", "is_open", "(", ")", ":", "return", "None", "m", "=", "max", "(", "m", ",", "r", ".", "stop", ")", "return", "m" ]
93b1ab725cfd8d13227960dbf9e3ca1e7f9eebe8