repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
welbornprod/colr
colr/colr.py
Colr.rstrip
def rstrip(self, chars=None): """ Like str.rstrip, except it returns the Colr instance. """ return self.__class__( self._str_strip('rstrip', chars), no_closing=chars and (closing_code in chars), )
python
def rstrip(self, chars=None): """ Like str.rstrip, except it returns the Colr instance. """ return self.__class__( self._str_strip('rstrip', chars), no_closing=chars and (closing_code in chars), )
[ "def", "rstrip", "(", "self", ",", "chars", "=", "None", ")", ":", "return", "self", ".", "__class__", "(", "self", ".", "_str_strip", "(", "'rstrip'", ",", "chars", ")", ",", "no_closing", "=", "chars", "and", "(", "closing_code", "in", "chars", ")", ...
Like str.rstrip, except it returns the Colr instance.
[ "Like", "str", ".", "rstrip", "except", "it", "returns", "the", "Colr", "instance", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1862-L1867
welbornprod/colr
colr/colr.py
Colr.strip
def strip(self, chars=None): """ Like str.strip, except it returns the Colr instance. """ return self.__class__( self._str_strip('strip', chars), no_closing=chars and (closing_code in chars), )
python
def strip(self, chars=None): """ Like str.strip, except it returns the Colr instance. """ return self.__class__( self._str_strip('strip', chars), no_closing=chars and (closing_code in chars), )
[ "def", "strip", "(", "self", ",", "chars", "=", "None", ")", ":", "return", "self", ".", "__class__", "(", "self", ".", "_str_strip", "(", "'strip'", ",", "chars", ")", ",", "no_closing", "=", "chars", "and", "(", "closing_code", "in", "chars", ")", ...
Like str.strip, except it returns the Colr instance.
[ "Like", "str", ".", "strip", "except", "it", "returns", "the", "Colr", "instance", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1869-L1874
welbornprod/colr
colr/colr.py
InvalidArg.as_colr
def as_colr(self, label_args=None, value_args=None): """ Like __str__, except it returns a colorized Colr instance. """ label_args = label_args or {'fore': 'red'} value_args = value_args or {'fore': 'blue', 'style': 'bright'} return Colr(self.default_format.format( label=Colr...
python
def as_colr(self, label_args=None, value_args=None): """ Like __str__, except it returns a colorized Colr instance. """ label_args = label_args or {'fore': 'red'} value_args = value_args or {'fore': 'blue', 'style': 'bright'} return Colr(self.default_format.format( label=Colr...
[ "def", "as_colr", "(", "self", ",", "label_args", "=", "None", ",", "value_args", "=", "None", ")", ":", "label_args", "=", "label_args", "or", "{", "'fore'", ":", "'red'", "}", "value_args", "=", "value_args", "or", "{", "'fore'", ":", "'blue'", ",", ...
Like __str__, except it returns a colorized Colr instance.
[ "Like", "__str__", "except", "it", "returns", "a", "colorized", "Colr", "instance", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1896-L1903
welbornprod/colr
colr/colr.py
InvalidColr.as_colr
def as_colr( self, label_args=None, type_args=None, type_val_args=None, value_args=None): """ Like __str__, except it returns a colorized Colr instance. """ label_args = label_args or {'fore': 'red'} type_args = type_args or {'fore': 'yellow'} type_val_args = type...
python
def as_colr( self, label_args=None, type_args=None, type_val_args=None, value_args=None): """ Like __str__, except it returns a colorized Colr instance. """ label_args = label_args or {'fore': 'red'} type_args = type_args or {'fore': 'yellow'} type_val_args = type...
[ "def", "as_colr", "(", "self", ",", "label_args", "=", "None", ",", "type_args", "=", "None", ",", "type_val_args", "=", "None", ",", "value_args", "=", "None", ")", ":", "label_args", "=", "label_args", "or", "{", "'fore'", ":", "'red'", "}", "type_args...
Like __str__, except it returns a colorized Colr instance.
[ "Like", "__str__", "except", "it", "returns", "a", "colorized", "Colr", "instance", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1923-L1944
welbornprod/colr
colr/colr.py
InvalidFormatColr.as_colr
def as_colr( self, label_args=None, type_args=None, type_val_args=None, value_args=None, spec_args=None): """ Like __str__, except it returns a colorized Colr instance. """ label_args = label_args or {'fore': 'red'} type_args = type_args or {'fore': 'yellow'} type...
python
def as_colr( self, label_args=None, type_args=None, type_val_args=None, value_args=None, spec_args=None): """ Like __str__, except it returns a colorized Colr instance. """ label_args = label_args or {'fore': 'red'} type_args = type_args or {'fore': 'yellow'} type...
[ "def", "as_colr", "(", "self", ",", "label_args", "=", "None", ",", "type_args", "=", "None", ",", "type_val_args", "=", "None", ",", "value_args", "=", "None", ",", "spec_args", "=", "None", ")", ":", "label_args", "=", "label_args", "or", "{", "'fore'"...
Like __str__, except it returns a colorized Colr instance.
[ "Like", "__str__", "except", "it", "returns", "a", "colorized", "Colr", "instance", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L1976-L2008
welbornprod/colr
colr/colr.py
InvalidStyle.as_colr
def as_colr( self, label_args=None, type_args=None, value_args=None): """ Like __str__, except it returns a colorized Colr instance. """ label_args = label_args or {'fore': 'red'} type_args = type_args or {'fore': 'yellow'} value_args = value_args or {'fore': 'blue', 'style':...
python
def as_colr( self, label_args=None, type_args=None, value_args=None): """ Like __str__, except it returns a colorized Colr instance. """ label_args = label_args or {'fore': 'red'} type_args = type_args or {'fore': 'yellow'} value_args = value_args or {'fore': 'blue', 'style':...
[ "def", "as_colr", "(", "self", ",", "label_args", "=", "None", ",", "type_args", "=", "None", ",", "value_args", "=", "None", ")", ":", "label_args", "=", "label_args", "or", "{", "'fore'", ":", "'red'", "}", "type_args", "=", "type_args", "or", "{", "...
Like __str__, except it returns a colorized Colr instance.
[ "Like", "__str__", "except", "it", "returns", "a", "colorized", "Colr", "instance", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/colr.py#L2039-L2058
welbornprod/colr
colr/controls.py
ensure_tty
def ensure_tty(file=sys.stdout): """ Ensure a file object is a tty. It must have an `isatty` method that returns True. TypeError is raised if the method doesn't exist, or returns False. """ isatty = getattr(file, 'isatty', None) if isatty is None: raise TypeError( 'Ca...
python
def ensure_tty(file=sys.stdout): """ Ensure a file object is a tty. It must have an `isatty` method that returns True. TypeError is raised if the method doesn't exist, or returns False. """ isatty = getattr(file, 'isatty', None) if isatty is None: raise TypeError( 'Ca...
[ "def", "ensure_tty", "(", "file", "=", "sys", ".", "stdout", ")", ":", "isatty", "=", "getattr", "(", "file", ",", "'isatty'", ",", "None", ")", "if", "isatty", "is", "None", ":", "raise", "TypeError", "(", "'Cannot detect tty, file has no `isatty` method: {}'...
Ensure a file object is a tty. It must have an `isatty` method that returns True. TypeError is raised if the method doesn't exist, or returns False.
[ "Ensure", "a", "file", "object", "is", "a", "tty", ".", "It", "must", "have", "an", "isatty", "method", "that", "returns", "True", ".", "TypeError", "is", "raised", "if", "the", "method", "doesn", "t", "exist", "or", "returns", "False", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L64-L82
welbornprod/colr
colr/controls.py
erase_display
def erase_display(method=EraseMethod.ALL_MOVE, file=sys.stdout): """ Clear the screen or part of the screen, and possibly moves the cursor to the "home" position (1, 1). See `method` argument below. Esc[<method>J Arguments: method: One of these possible values: ...
python
def erase_display(method=EraseMethod.ALL_MOVE, file=sys.stdout): """ Clear the screen or part of the screen, and possibly moves the cursor to the "home" position (1, 1). See `method` argument below. Esc[<method>J Arguments: method: One of these possible values: ...
[ "def", "erase_display", "(", "method", "=", "EraseMethod", ".", "ALL_MOVE", ",", "file", "=", "sys", ".", "stdout", ")", ":", "erase", ".", "display", "(", "method", ")", ".", "write", "(", "file", "=", "file", ")" ]
Clear the screen or part of the screen, and possibly moves the cursor to the "home" position (1, 1). See `method` argument below. Esc[<method>J Arguments: method: One of these possible values: EraseMethod.END or 0: Clear from curs...
[ "Clear", "the", "screen", "or", "part", "of", "the", "screen", "and", "possibly", "moves", "the", "cursor", "to", "the", "home", "position", "(", "1", "1", ")", ".", "See", "method", "argument", "below", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L85-L106
welbornprod/colr
colr/controls.py
erase_line
def erase_line(method=EraseMethod.ALL, file=sys.stdout): """ Erase a line, or part of a line. See `method` argument below. Cursor position does not change. Esc[<method>K Arguments: method : One of these possible values: EraseMethod.END or 0: ...
python
def erase_line(method=EraseMethod.ALL, file=sys.stdout): """ Erase a line, or part of a line. See `method` argument below. Cursor position does not change. Esc[<method>K Arguments: method : One of these possible values: EraseMethod.END or 0: ...
[ "def", "erase_line", "(", "method", "=", "EraseMethod", ".", "ALL", ",", "file", "=", "sys", ".", "stdout", ")", ":", "erase", ".", "line", "(", "method", ")", ".", "write", "(", "file", "=", "file", ")" ]
Erase a line, or part of a line. See `method` argument below. Cursor position does not change. Esc[<method>K Arguments: method : One of these possible values: EraseMethod.END or 0: Clear from cursor to the end of the line. ...
[ "Erase", "a", "line", "or", "part", "of", "a", "line", ".", "See", "method", "argument", "below", ".", "Cursor", "position", "does", "not", "change", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L109-L125
welbornprod/colr
colr/controls.py
move_back
def move_back(columns=1, file=sys.stdout): """ Move the cursor back a number of columns. Esc[<columns>D: Moves the cursor back by the specified number of columns without changing lines. If the cursor is already in the leftmost column, ANSI.SYS ignores this sequence. """ move...
python
def move_back(columns=1, file=sys.stdout): """ Move the cursor back a number of columns. Esc[<columns>D: Moves the cursor back by the specified number of columns without changing lines. If the cursor is already in the leftmost column, ANSI.SYS ignores this sequence. """ move...
[ "def", "move_back", "(", "columns", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "move", ".", "back", "(", "columns", ")", ".", "write", "(", "file", "=", "file", ")" ]
Move the cursor back a number of columns. Esc[<columns>D: Moves the cursor back by the specified number of columns without changing lines. If the cursor is already in the leftmost column, ANSI.SYS ignores this sequence.
[ "Move", "the", "cursor", "back", "a", "number", "of", "columns", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L128-L136
welbornprod/colr
colr/controls.py
move_column
def move_column(column=1, file=sys.stdout): """ Move the cursor to the specified column, default 1. Esc[<column>G """ move.column(column).write(file=file)
python
def move_column(column=1, file=sys.stdout): """ Move the cursor to the specified column, default 1. Esc[<column>G """ move.column(column).write(file=file)
[ "def", "move_column", "(", "column", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "move", ".", "column", "(", "column", ")", ".", "write", "(", "file", "=", "file", ")" ]
Move the cursor to the specified column, default 1. Esc[<column>G
[ "Move", "the", "cursor", "to", "the", "specified", "column", "default", "1", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L139-L144
welbornprod/colr
colr/controls.py
move_down
def move_down(lines=1, file=sys.stdout): """ Move the cursor down a number of lines. Esc[<lines>B: Moves the cursor down by the specified number of lines without changing columns. If the cursor is already on the bottom line, ANSI.SYS ignores this sequence. """ move.down(line...
python
def move_down(lines=1, file=sys.stdout): """ Move the cursor down a number of lines. Esc[<lines>B: Moves the cursor down by the specified number of lines without changing columns. If the cursor is already on the bottom line, ANSI.SYS ignores this sequence. """ move.down(line...
[ "def", "move_down", "(", "lines", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "move", ".", "down", "(", "lines", ")", ".", "write", "(", "file", "=", "file", ")" ]
Move the cursor down a number of lines. Esc[<lines>B: Moves the cursor down by the specified number of lines without changing columns. If the cursor is already on the bottom line, ANSI.SYS ignores this sequence.
[ "Move", "the", "cursor", "down", "a", "number", "of", "lines", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L147-L155
welbornprod/colr
colr/controls.py
move_forward
def move_forward(columns=1, file=sys.stdout): """ Move the cursor forward a number of columns. Esc[<columns>C: Moves the cursor forward by the specified number of columns without changing lines. If the cursor is already in the rightmost column, ANSI.SYS ignores this sequence. ""...
python
def move_forward(columns=1, file=sys.stdout): """ Move the cursor forward a number of columns. Esc[<columns>C: Moves the cursor forward by the specified number of columns without changing lines. If the cursor is already in the rightmost column, ANSI.SYS ignores this sequence. ""...
[ "def", "move_forward", "(", "columns", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "move", ".", "forward", "(", "columns", ")", ".", "write", "(", "file", "=", "file", ")" ]
Move the cursor forward a number of columns. Esc[<columns>C: Moves the cursor forward by the specified number of columns without changing lines. If the cursor is already in the rightmost column, ANSI.SYS ignores this sequence.
[ "Move", "the", "cursor", "forward", "a", "number", "of", "columns", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L158-L166
welbornprod/colr
colr/controls.py
move_next
def move_next(lines=1, file=sys.stdout): """ Move the cursor to the beginning of the line, a number of lines down. Default: 1 Esc[<lines>E """ move.next(lines).write(file=file)
python
def move_next(lines=1, file=sys.stdout): """ Move the cursor to the beginning of the line, a number of lines down. Default: 1 Esc[<lines>E """ move.next(lines).write(file=file)
[ "def", "move_next", "(", "lines", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "move", ".", "next", "(", "lines", ")", ".", "write", "(", "file", "=", "file", ")" ]
Move the cursor to the beginning of the line, a number of lines down. Default: 1 Esc[<lines>E
[ "Move", "the", "cursor", "to", "the", "beginning", "of", "the", "line", "a", "number", "of", "lines", "down", ".", "Default", ":", "1" ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L169-L175
welbornprod/colr
colr/controls.py
move_pos
def move_pos(line=1, column=1, file=sys.stdout): """ Move the cursor to a new position. Values are 1-based, and default to 1. Esc[<line>;<column>H or Esc[<line>;<column>f """ move.pos(line=line, col=column).write(file=file)
python
def move_pos(line=1, column=1, file=sys.stdout): """ Move the cursor to a new position. Values are 1-based, and default to 1. Esc[<line>;<column>H or Esc[<line>;<column>f """ move.pos(line=line, col=column).write(file=file)
[ "def", "move_pos", "(", "line", "=", "1", ",", "column", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "move", ".", "pos", "(", "line", "=", "line", ",", "col", "=", "column", ")", ".", "write", "(", "file", "=", "file", ")" ]
Move the cursor to a new position. Values are 1-based, and default to 1. Esc[<line>;<column>H or Esc[<line>;<column>f
[ "Move", "the", "cursor", "to", "a", "new", "position", ".", "Values", "are", "1", "-", "based", "and", "default", "to", "1", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L178-L186
welbornprod/colr
colr/controls.py
move_prev
def move_prev(lines=1, file=sys.stdout): """ Move the cursor to the beginning of the line, a number of lines up. Default: 1 Esc[<lines>F """ move.prev(lines).write(file=file)
python
def move_prev(lines=1, file=sys.stdout): """ Move the cursor to the beginning of the line, a number of lines up. Default: 1 Esc[<lines>F """ move.prev(lines).write(file=file)
[ "def", "move_prev", "(", "lines", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "move", ".", "prev", "(", "lines", ")", ".", "write", "(", "file", "=", "file", ")" ]
Move the cursor to the beginning of the line, a number of lines up. Default: 1 Esc[<lines>F
[ "Move", "the", "cursor", "to", "the", "beginning", "of", "the", "line", "a", "number", "of", "lines", "up", ".", "Default", ":", "1" ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L189-L195
welbornprod/colr
colr/controls.py
move_up
def move_up(lines=1, file=sys.stdout): """ Move the cursor up a number of lines. Esc[ValueA: Moves the cursor up by the specified number of lines without changing columns. If the cursor is already on the top line, ANSI.SYS ignores this sequence. """ move.up(lines).write(file...
python
def move_up(lines=1, file=sys.stdout): """ Move the cursor up a number of lines. Esc[ValueA: Moves the cursor up by the specified number of lines without changing columns. If the cursor is already on the top line, ANSI.SYS ignores this sequence. """ move.up(lines).write(file...
[ "def", "move_up", "(", "lines", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "move", ".", "up", "(", "lines", ")", ".", "write", "(", "file", "=", "file", ")" ]
Move the cursor up a number of lines. Esc[ValueA: Moves the cursor up by the specified number of lines without changing columns. If the cursor is already on the top line, ANSI.SYS ignores this sequence.
[ "Move", "the", "cursor", "up", "a", "number", "of", "lines", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L208-L216
welbornprod/colr
colr/controls.py
print_inplace
def print_inplace(*args, **kwargs): """ Save cursor position, write some text, and then restore the position. Arguments: Same as `print()`. Keyword Arguments: Same as `print()`, except `end` defaults to '' (empty str), and these: delay : Time in s...
python
def print_inplace(*args, **kwargs): """ Save cursor position, write some text, and then restore the position. Arguments: Same as `print()`. Keyword Arguments: Same as `print()`, except `end` defaults to '' (empty str), and these: delay : Time in s...
[ "def", "print_inplace", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'file'", ",", "sys", ".", "stdout", ")", "kwargs", ".", "setdefault", "(", "'end'", ",", "''", ")", "pos_save", "(", "file", "=", "kwargs"...
Save cursor position, write some text, and then restore the position. Arguments: Same as `print()`. Keyword Arguments: Same as `print()`, except `end` defaults to '' (empty str), and these: delay : Time in seconds between character writes.
[ "Save", "cursor", "position", "write", "some", "text", "and", "then", "restore", "the", "position", ".", "Arguments", ":", "Same", "as", "print", "()", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L244-L271
welbornprod/colr
colr/controls.py
print_flush
def print_flush(*args, **kwargs): """ Like `print()`, except the file is `.flush()`ed afterwards. """ kwargs.setdefault('file', sys.stdout) print(*args, **kwargs) kwargs['file'].flush()
python
def print_flush(*args, **kwargs): """ Like `print()`, except the file is `.flush()`ed afterwards. """ kwargs.setdefault('file', sys.stdout) print(*args, **kwargs) kwargs['file'].flush()
[ "def", "print_flush", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'file'", ",", "sys", ".", "stdout", ")", "print", "(", "*", "args", ",", "*", "*", "kwargs", ")", "kwargs", "[", "'file'", "]", ".", "fl...
Like `print()`, except the file is `.flush()`ed afterwards.
[ "Like", "print", "()", "except", "the", "file", "is", ".", "flush", "()", "ed", "afterwards", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L274-L278
welbornprod/colr
colr/controls.py
print_overwrite
def print_overwrite(*args, **kwargs): """ Move to the beginning of the current line, and print some text. Arguments: Same as `print()`. Keyword Arguments: Same as `print()`, except `end` defaults to '' (empty str), and these: delay : Time in secon...
python
def print_overwrite(*args, **kwargs): """ Move to the beginning of the current line, and print some text. Arguments: Same as `print()`. Keyword Arguments: Same as `print()`, except `end` defaults to '' (empty str), and these: delay : Time in secon...
[ "def", "print_overwrite", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'file'", ",", "sys", ".", "stdout", ")", "kwargs", ".", "setdefault", "(", "'end'", ",", "''", ")", "delay", "=", "None", "with", "suppr...
Move to the beginning of the current line, and print some text. Arguments: Same as `print()`. Keyword Arguments: Same as `print()`, except `end` defaults to '' (empty str), and these: delay : Time in seconds between character writes.
[ "Move", "to", "the", "beginning", "of", "the", "current", "line", "and", "print", "some", "text", ".", "Arguments", ":", "Same", "as", "print", "()", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L281-L308
welbornprod/colr
colr/controls.py
scroll_down
def scroll_down(lines=1, file=sys.stdout): """ Scroll the whole page down a number of lines, new lines are added to the top. Esc[<lines>T """ scroll.down(lines).write(file=file)
python
def scroll_down(lines=1, file=sys.stdout): """ Scroll the whole page down a number of lines, new lines are added to the top. Esc[<lines>T """ scroll.down(lines).write(file=file)
[ "def", "scroll_down", "(", "lines", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "scroll", ".", "down", "(", "lines", ")", ".", "write", "(", "file", "=", "file", ")" ]
Scroll the whole page down a number of lines, new lines are added to the top. Esc[<lines>T
[ "Scroll", "the", "whole", "page", "down", "a", "number", "of", "lines", "new", "lines", "are", "added", "to", "the", "top", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L311-L317
welbornprod/colr
colr/controls.py
scroll_up
def scroll_up(lines=1, file=sys.stdout): """ Scroll the whole page up a number of lines, new lines are added to the bottom. Esc[<lines>S """ scroll.up(lines).write(file=file)
python
def scroll_up(lines=1, file=sys.stdout): """ Scroll the whole page up a number of lines, new lines are added to the bottom. Esc[<lines>S """ scroll.up(lines).write(file=file)
[ "def", "scroll_up", "(", "lines", "=", "1", ",", "file", "=", "sys", ".", "stdout", ")", ":", "scroll", ".", "up", "(", "lines", ")", ".", "write", "(", "file", "=", "file", ")" ]
Scroll the whole page up a number of lines, new lines are added to the bottom. Esc[<lines>S
[ "Scroll", "the", "whole", "page", "up", "a", "number", "of", "lines", "new", "lines", "are", "added", "to", "the", "bottom", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L320-L326
welbornprod/colr
colr/controls.py
Control.erase_display
def erase_display(self, method=EraseMethod.ALL_MOVE): """ Clear the screen or part of the screen. Arguments: method: One of these possible values: EraseMethod.END or 0: Clear from cursor to the end of the screen. ...
python
def erase_display(self, method=EraseMethod.ALL_MOVE): """ Clear the screen or part of the screen. Arguments: method: One of these possible values: EraseMethod.END or 0: Clear from cursor to the end of the screen. ...
[ "def", "erase_display", "(", "self", ",", "method", "=", "EraseMethod", ".", "ALL_MOVE", ")", ":", "return", "self", ".", "chained", "(", "erase", ".", "display", "(", "method", ")", ")" ]
Clear the screen or part of the screen. Arguments: method: One of these possible values: EraseMethod.END or 0: Clear from cursor to the end of the screen. EraseMethod.START or 1: ...
[ "Clear", "the", "screen", "or", "part", "of", "the", "screen", ".", "Arguments", ":", "method", ":", "One", "of", "these", "possible", "values", ":", "EraseMethod", ".", "END", "or", "0", ":", "Clear", "from", "cursor", "to", "the", "end", "of", "the",...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L351-L368
welbornprod/colr
colr/controls.py
Control.erase_line
def erase_line(self, method=EraseMethod.ALL): """ Erase a line, or part of a line. Arguments: method : One of these possible values: EraseMethod.END or 0: Clear from cursor to the end of the line. ...
python
def erase_line(self, method=EraseMethod.ALL): """ Erase a line, or part of a line. Arguments: method : One of these possible values: EraseMethod.END or 0: Clear from cursor to the end of the line. ...
[ "def", "erase_line", "(", "self", ",", "method", "=", "EraseMethod", ".", "ALL", ")", ":", "return", "self", ".", "chained", "(", "erase", ".", "line", "(", "method", "=", "method", ")", ")" ]
Erase a line, or part of a line. Arguments: method : One of these possible values: EraseMethod.END or 0: Clear from cursor to the end of the line. EraseMethod.START or 1: C...
[ "Erase", "a", "line", "or", "part", "of", "a", "line", ".", "Arguments", ":", "method", ":", "One", "of", "these", "possible", "values", ":", "EraseMethod", ".", "END", "or", "0", ":", "Clear", "from", "cursor", "to", "the", "end", "of", "the", "line...
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L370-L382
welbornprod/colr
colr/controls.py
Control.last_code
def last_code(self): """ Return the last escape code in `self.data`. If no escape codes are found, '' is returned. """ codes = self.data.split(escape_sequence) if not codes: return '' return ''.join((escape_sequence, codes[-1]))
python
def last_code(self): """ Return the last escape code in `self.data`. If no escape codes are found, '' is returned. """ codes = self.data.split(escape_sequence) if not codes: return '' return ''.join((escape_sequence, codes[-1]))
[ "def", "last_code", "(", "self", ")", ":", "codes", "=", "self", ".", "data", ".", "split", "(", "escape_sequence", ")", "if", "not", "codes", ":", "return", "''", "return", "''", ".", "join", "(", "(", "escape_sequence", ",", "codes", "[", "-", "1",...
Return the last escape code in `self.data`. If no escape codes are found, '' is returned.
[ "Return", "the", "last", "escape", "code", "in", "self", ".", "data", ".", "If", "no", "escape", "codes", "are", "found", "is", "returned", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L384-L391
welbornprod/colr
colr/controls.py
Control.move_pos
def move_pos(self, line=1, column=1): """ Move the cursor to a new position. Default: line 1, column 1 """ return self.chained(move.pos(line=line, column=column))
python
def move_pos(self, line=1, column=1): """ Move the cursor to a new position. Default: line 1, column 1 """ return self.chained(move.pos(line=line, column=column))
[ "def", "move_pos", "(", "self", ",", "line", "=", "1", ",", "column", "=", "1", ")", ":", "return", "self", ".", "chained", "(", "move", ".", "pos", "(", "line", "=", "line", ",", "column", "=", "column", ")", ")" ]
Move the cursor to a new position. Default: line 1, column 1
[ "Move", "the", "cursor", "to", "a", "new", "position", ".", "Default", ":", "line", "1", "column", "1" ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L430-L434
welbornprod/colr
colr/controls.py
Control.repeat
def repeat(self, count=2): """ Repeat the last control code a number of times. Returns a new Control with this one's data and the repeated code. """ # Subtracting one from the count means the code mentioned is # truly repeated exactly `count` times. # Control().move_u...
python
def repeat(self, count=2): """ Repeat the last control code a number of times. Returns a new Control with this one's data and the repeated code. """ # Subtracting one from the count means the code mentioned is # truly repeated exactly `count` times. # Control().move_u...
[ "def", "repeat", "(", "self", ",", "count", "=", "2", ")", ":", "# Subtracting one from the count means the code mentioned is", "# truly repeated exactly `count` times.", "# Control().move_up().repeat(3) ==", "# Control().move_up().move_up().move_up()", "try", ":", "return", "self"...
Repeat the last control code a number of times. Returns a new Control with this one's data and the repeated code.
[ "Repeat", "the", "last", "control", "code", "a", "number", "of", "times", ".", "Returns", "a", "new", "Control", "with", "this", "one", "s", "data", "and", "the", "repeated", "code", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L460-L476
welbornprod/colr
colr/controls.py
Control.repeat_all
def repeat_all(self, count=2): """ Repeat this entire Control code a number of times. Returns a new Control with this one's data repeated. """ try: return self.__class__(''.join(str(self) * count)) except TypeError: raise TypeError( '`c...
python
def repeat_all(self, count=2): """ Repeat this entire Control code a number of times. Returns a new Control with this one's data repeated. """ try: return self.__class__(''.join(str(self) * count)) except TypeError: raise TypeError( '`c...
[ "def", "repeat_all", "(", "self", ",", "count", "=", "2", ")", ":", "try", ":", "return", "self", ".", "__class__", "(", "''", ".", "join", "(", "str", "(", "self", ")", "*", "count", ")", ")", "except", "TypeError", ":", "raise", "TypeError", "(",...
Repeat this entire Control code a number of times. Returns a new Control with this one's data repeated.
[ "Repeat", "this", "entire", "Control", "code", "a", "number", "of", "times", ".", "Returns", "a", "new", "Control", "with", "this", "one", "s", "data", "repeated", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/controls.py#L478-L487
welbornprod/colr
colr/trans.py
hex2rgb
def hex2rgb(hexval: str, allow_short: bool = False) -> RGB: """ Return a tuple of (R, G, B) from a hex color. """ if not hexval: raise ValueError( 'Expecting hex string (#RGB, #RRGGBB), got nothing: {!r}'.format( hexval ) ) try: hexval = hexval...
python
def hex2rgb(hexval: str, allow_short: bool = False) -> RGB: """ Return a tuple of (R, G, B) from a hex color. """ if not hexval: raise ValueError( 'Expecting hex string (#RGB, #RRGGBB), got nothing: {!r}'.format( hexval ) ) try: hexval = hexval...
[ "def", "hex2rgb", "(", "hexval", ":", "str", ",", "allow_short", ":", "bool", "=", "False", ")", "->", "RGB", ":", "if", "not", "hexval", ":", "raise", "ValueError", "(", "'Expecting hex string (#RGB, #RRGGBB), got nothing: {!r}'", ".", "format", "(", "hexval", ...
Return a tuple of (R, G, B) from a hex color.
[ "Return", "a", "tuple", "of", "(", "R", "G", "B", ")", "from", "a", "hex", "color", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L342-L377
welbornprod/colr
colr/trans.py
hex2term
def hex2term(hexval: str, allow_short: bool = False) -> str: """ Convert a hex value into the nearest terminal code number. """ return rgb2term(*hex2rgb(hexval, allow_short=allow_short))
python
def hex2term(hexval: str, allow_short: bool = False) -> str: """ Convert a hex value into the nearest terminal code number. """ return rgb2term(*hex2rgb(hexval, allow_short=allow_short))
[ "def", "hex2term", "(", "hexval", ":", "str", ",", "allow_short", ":", "bool", "=", "False", ")", "->", "str", ":", "return", "rgb2term", "(", "*", "hex2rgb", "(", "hexval", ",", "allow_short", "=", "allow_short", ")", ")" ]
Convert a hex value into the nearest terminal code number.
[ "Convert", "a", "hex", "value", "into", "the", "nearest", "terminal", "code", "number", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L380-L382
welbornprod/colr
colr/trans.py
hex2termhex
def hex2termhex(hexval: str, allow_short: bool = False) -> str: """ Convert a hex value into the nearest terminal color matched hex. """ return rgb2termhex(*hex2rgb(hexval, allow_short=allow_short))
python
def hex2termhex(hexval: str, allow_short: bool = False) -> str: """ Convert a hex value into the nearest terminal color matched hex. """ return rgb2termhex(*hex2rgb(hexval, allow_short=allow_short))
[ "def", "hex2termhex", "(", "hexval", ":", "str", ",", "allow_short", ":", "bool", "=", "False", ")", "->", "str", ":", "return", "rgb2termhex", "(", "*", "hex2rgb", "(", "hexval", ",", "allow_short", "=", "allow_short", ")", ")" ]
Convert a hex value into the nearest terminal color matched hex.
[ "Convert", "a", "hex", "value", "into", "the", "nearest", "terminal", "color", "matched", "hex", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L385-L387
welbornprod/colr
colr/trans.py
print_all
def print_all() -> None: """ Print all 256 xterm color codes. """ for code in sorted(term2hex_map): print(' '.join(( '\033[48;5;{code}m{code:<3}:{hexval:<6}\033[0m', '\033[38;5;{code}m{code:<3}:{hexval:<6}\033[0m' )).format(code=code, hexval=term2hex_map[code]))
python
def print_all() -> None: """ Print all 256 xterm color codes. """ for code in sorted(term2hex_map): print(' '.join(( '\033[48;5;{code}m{code:<3}:{hexval:<6}\033[0m', '\033[38;5;{code}m{code:<3}:{hexval:<6}\033[0m' )).format(code=code, hexval=term2hex_map[code]))
[ "def", "print_all", "(", ")", "->", "None", ":", "for", "code", "in", "sorted", "(", "term2hex_map", ")", ":", "print", "(", "' '", ".", "join", "(", "(", "'\\033[48;5;{code}m{code:<3}:{hexval:<6}\\033[0m'", ",", "'\\033[38;5;{code}m{code:<3}:{hexval:<6}\\033[0m'", ...
Print all 256 xterm color codes.
[ "Print", "all", "256", "xterm", "color", "codes", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L407-L413
welbornprod/colr
colr/trans.py
rgb2hex
def rgb2hex(r: int, g: int, b: int) -> str: """ Convert rgb values to a hex code. """ return '{:02x}{:02x}{:02x}'.format(r, g, b)
python
def rgb2hex(r: int, g: int, b: int) -> str: """ Convert rgb values to a hex code. """ return '{:02x}{:02x}{:02x}'.format(r, g, b)
[ "def", "rgb2hex", "(", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ")", "->", "str", ":", "return", "'{:02x}{:02x}{:02x}'", ".", "format", "(", "r", ",", "g", ",", "b", ")" ]
Convert rgb values to a hex code.
[ "Convert", "rgb", "values", "to", "a", "hex", "code", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L416-L418
welbornprod/colr
colr/trans.py
rgb2term
def rgb2term(r: int, g: int, b: int) -> str: """ Convert an rgb value to a terminal code. """ return hex2term_map[rgb2termhex(r, g, b)]
python
def rgb2term(r: int, g: int, b: int) -> str: """ Convert an rgb value to a terminal code. """ return hex2term_map[rgb2termhex(r, g, b)]
[ "def", "rgb2term", "(", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ")", "->", "str", ":", "return", "hex2term_map", "[", "rgb2termhex", "(", "r", ",", "g", ",", "b", ")", "]" ]
Convert an rgb value to a terminal code.
[ "Convert", "an", "rgb", "value", "to", "a", "terminal", "code", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L421-L423
welbornprod/colr
colr/trans.py
rgb2termhex
def rgb2termhex(r: int, g: int, b: int) -> str: """ Convert an rgb value to the nearest hex value that matches a term code. The hex value will be one in `hex2term_map`. """ incs = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff] res = [] parts = r, g, b for part in parts: if (part < 0) or (...
python
def rgb2termhex(r: int, g: int, b: int) -> str: """ Convert an rgb value to the nearest hex value that matches a term code. The hex value will be one in `hex2term_map`. """ incs = [0x00, 0x5f, 0x87, 0xaf, 0xd7, 0xff] res = [] parts = r, g, b for part in parts: if (part < 0) or (...
[ "def", "rgb2termhex", "(", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ")", "->", "str", ":", "incs", "=", "[", "0x00", ",", "0x5f", ",", "0x87", ",", "0xaf", ",", "0xd7", ",", "0xff", "]", "res", "=", "[", "]", "parts", "=...
Convert an rgb value to the nearest hex value that matches a term code. The hex value will be one in `hex2term_map`.
[ "Convert", "an", "rgb", "value", "to", "the", "nearest", "hex", "value", "that", "matches", "a", "term", "code", ".", "The", "hex", "value", "will", "be", "one", "in", "hex2term_map", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L426-L454
welbornprod/colr
colr/trans.py
term2hex
def term2hex(code: Numeric, default: Optional[str] = None) -> str: """ Convenience function for term2hex_map.get(code, None). Accepts strs or ints in the form of: 1, 01, 123. Returns `default` if the code is not found. """ try: val = term2hex_map.get('{:02}'.format(int(code), default...
python
def term2hex(code: Numeric, default: Optional[str] = None) -> str: """ Convenience function for term2hex_map.get(code, None). Accepts strs or ints in the form of: 1, 01, 123. Returns `default` if the code is not found. """ try: val = term2hex_map.get('{:02}'.format(int(code), default...
[ "def", "term2hex", "(", "code", ":", "Numeric", ",", "default", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "str", ":", "try", ":", "val", "=", "term2hex_map", ".", "get", "(", "'{:02}'", ".", "format", "(", "int", "(", "code", ")", ...
Convenience function for term2hex_map.get(code, None). Accepts strs or ints in the form of: 1, 01, 123. Returns `default` if the code is not found.
[ "Convenience", "function", "for", "term2hex_map", ".", "get", "(", "code", "None", ")", ".", "Accepts", "strs", "or", "ints", "in", "the", "form", "of", ":", "1", "01", "123", ".", "Returns", "default", "if", "the", "code", "is", "not", "found", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L457-L469
welbornprod/colr
colr/trans.py
ColorCode._init_code
def _init_code(self, code: int) -> None: """ Initialize from an int terminal code. """ if -1 < code < 256: self.code = '{:02}'.format(code) self.hexval = term2hex(code) self.rgb = hex2rgb(self.hexval) else: raise ValueError(' '.join(( ...
python
def _init_code(self, code: int) -> None: """ Initialize from an int terminal code. """ if -1 < code < 256: self.code = '{:02}'.format(code) self.hexval = term2hex(code) self.rgb = hex2rgb(self.hexval) else: raise ValueError(' '.join(( ...
[ "def", "_init_code", "(", "self", ",", "code", ":", "int", ")", "->", "None", ":", "if", "-", "1", "<", "code", "<", "256", ":", "self", ".", "code", "=", "'{:02}'", ".", "format", "(", "code", ")", "self", ".", "hexval", "=", "term2hex", "(", ...
Initialize from an int terminal code.
[ "Initialize", "from", "an", "int", "terminal", "code", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L540-L550
welbornprod/colr
colr/trans.py
ColorCode._init_hex
def _init_hex(self, hexval: str) -> None: """ Initialize from a hex value string. """ self.hexval = hex2termhex(fix_hex(hexval)) self.code = hex2term(self.hexval) self.rgb = hex2rgb(self.hexval)
python
def _init_hex(self, hexval: str) -> None: """ Initialize from a hex value string. """ self.hexval = hex2termhex(fix_hex(hexval)) self.code = hex2term(self.hexval) self.rgb = hex2rgb(self.hexval)
[ "def", "_init_hex", "(", "self", ",", "hexval", ":", "str", ")", "->", "None", ":", "self", ".", "hexval", "=", "hex2termhex", "(", "fix_hex", "(", "hexval", ")", ")", "self", ".", "code", "=", "hex2term", "(", "self", ".", "hexval", ")", "self", "...
Initialize from a hex value string.
[ "Initialize", "from", "a", "hex", "value", "string", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L552-L556
welbornprod/colr
colr/trans.py
ColorCode._init_rgb
def _init_rgb(self, r: int, g: int, b: int) -> None: """ Initialize from red, green, blue args. """ if self.rgb_mode: self.rgb = (r, g, b) self.hexval = rgb2hex(r, g, b) else: self.rgb = hex2rgb(rgb2termhex(r, g, b)) self.hexval = rgb2termhex(r, g,...
python
def _init_rgb(self, r: int, g: int, b: int) -> None: """ Initialize from red, green, blue args. """ if self.rgb_mode: self.rgb = (r, g, b) self.hexval = rgb2hex(r, g, b) else: self.rgb = hex2rgb(rgb2termhex(r, g, b)) self.hexval = rgb2termhex(r, g,...
[ "def", "_init_rgb", "(", "self", ",", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ")", "->", "None", ":", "if", "self", ".", "rgb_mode", ":", "self", ".", "rgb", "=", "(", "r", ",", "g", ",", "b", ")", "self", ".", "hexval"...
Initialize from red, green, blue args.
[ "Initialize", "from", "red", "green", "blue", "args", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L558-L567
welbornprod/colr
colr/trans.py
ColorCode.example
def example(self) -> str: """ Same as str(self), except the color codes are actually used. """ if self.rgb_mode: colorcode = '\033[38;2;{};{};{}m'.format(*self.rgb) else: colorcode = '\033[38;5;{}m'.format(self.code) return '{code}{s}\033[0m'.format(code=colorcode...
python
def example(self) -> str: """ Same as str(self), except the color codes are actually used. """ if self.rgb_mode: colorcode = '\033[38;2;{};{};{}m'.format(*self.rgb) else: colorcode = '\033[38;5;{}m'.format(self.code) return '{code}{s}\033[0m'.format(code=colorcode...
[ "def", "example", "(", "self", ")", "->", "str", ":", "if", "self", ".", "rgb_mode", ":", "colorcode", "=", "'\\033[38;2;{};{};{}m'", ".", "format", "(", "*", "self", ".", "rgb", ")", "else", ":", "colorcode", "=", "'\\033[38;5;{}m'", ".", "format", "(",...
Same as str(self), except the color codes are actually used.
[ "Same", "as", "str", "(", "self", ")", "except", "the", "color", "codes", "are", "actually", "used", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L569-L575
welbornprod/colr
colr/trans.py
ColorCode.from_code
def from_code(cls, code: int) -> 'ColorCode': """ Return a ColorCode from a terminal code. """ c = cls() c._init_code(code) return c
python
def from_code(cls, code: int) -> 'ColorCode': """ Return a ColorCode from a terminal code. """ c = cls() c._init_code(code) return c
[ "def", "from_code", "(", "cls", ",", "code", ":", "int", ")", "->", "'ColorCode'", ":", "c", "=", "cls", "(", ")", "c", ".", "_init_code", "(", "code", ")", "return", "c" ]
Return a ColorCode from a terminal code.
[ "Return", "a", "ColorCode", "from", "a", "terminal", "code", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L578-L582
welbornprod/colr
colr/trans.py
ColorCode.from_hex
def from_hex(cls, hexval: str) -> 'ColorCode': """ Return a ColorCode from a hex string. """ c = cls() c._init_hex(hexval) return c
python
def from_hex(cls, hexval: str) -> 'ColorCode': """ Return a ColorCode from a hex string. """ c = cls() c._init_hex(hexval) return c
[ "def", "from_hex", "(", "cls", ",", "hexval", ":", "str", ")", "->", "'ColorCode'", ":", "c", "=", "cls", "(", ")", "c", ".", "_init_hex", "(", "hexval", ")", "return", "c" ]
Return a ColorCode from a hex string.
[ "Return", "a", "ColorCode", "from", "a", "hex", "string", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L585-L589
welbornprod/colr
colr/trans.py
ColorCode.from_rgb
def from_rgb(cls, r: int, g: int, b: int) -> 'ColorCode': """ Return a ColorCode from a RGB tuple. """ c = cls() c._init_rgb(r, g, b) return c
python
def from_rgb(cls, r: int, g: int, b: int) -> 'ColorCode': """ Return a ColorCode from a RGB tuple. """ c = cls() c._init_rgb(r, g, b) return c
[ "def", "from_rgb", "(", "cls", ",", "r", ":", "int", ",", "g", ":", "int", ",", "b", ":", "int", ")", "->", "'ColorCode'", ":", "c", "=", "cls", "(", ")", "c", ".", "_init_rgb", "(", "r", ",", "g", ",", "b", ")", "return", "c" ]
Return a ColorCode from a RGB tuple.
[ "Return", "a", "ColorCode", "from", "a", "RGB", "tuple", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/trans.py#L592-L596
unique1o1/Meta-Music
Metamusic/database.py
commit
def commit(func): '''Used as a decorator for automatically making session commits''' def wrap(**kwarg): with session_withcommit() as session: a = func(**kwarg) session.add(a) return session.query(songs).order_by( songs.song_id.desc()).first().song_id retur...
python
def commit(func): '''Used as a decorator for automatically making session commits''' def wrap(**kwarg): with session_withcommit() as session: a = func(**kwarg) session.add(a) return session.query(songs).order_by( songs.song_id.desc()).first().song_id retur...
[ "def", "commit", "(", "func", ")", ":", "def", "wrap", "(", "*", "*", "kwarg", ")", ":", "with", "session_withcommit", "(", ")", "as", "session", ":", "a", "=", "func", "(", "*", "*", "kwarg", ")", "session", ".", "add", "(", "a", ")", "return", ...
Used as a decorator for automatically making session commits
[ "Used", "as", "a", "decorator", "for", "automatically", "making", "session", "commits" ]
train
https://github.com/unique1o1/Meta-Music/blob/8cd1b04011ae3671ece44cc6338d748f8d095eaf/Metamusic/database.py#L51-L59
unique1o1/Meta-Music
Metamusic/database.py
get_songs
def get_songs()->Iterator: """ Return songs that have the fingerprinted flag set TRUE (1). """ with session_withcommit() as session: val = session.query(songs).all() for row in val: yield row
python
def get_songs()->Iterator: """ Return songs that have the fingerprinted flag set TRUE (1). """ with session_withcommit() as session: val = session.query(songs).all() for row in val: yield row
[ "def", "get_songs", "(", ")", "->", "Iterator", ":", "with", "session_withcommit", "(", ")", "as", "session", ":", "val", "=", "session", ".", "query", "(", "songs", ")", ".", "all", "(", ")", "for", "row", "in", "val", ":", "yield", "row" ]
Return songs that have the fingerprinted flag set TRUE (1).
[ "Return", "songs", "that", "have", "the", "fingerprinted", "flag", "set", "TRUE", "(", "1", ")", "." ]
train
https://github.com/unique1o1/Meta-Music/blob/8cd1b04011ae3671ece44cc6338d748f8d095eaf/Metamusic/database.py#L93-L100
geertj/gruvi
lib/gruvi/hub.py
get_hub
def get_hub(): """Return the instance of the hub.""" try: hub = _local.hub except AttributeError: # The Hub can only be instantiated from the root fiber. No other fibers # can run until the Hub is there, so the root will always be the first # one to call get_hub(). as...
python
def get_hub(): """Return the instance of the hub.""" try: hub = _local.hub except AttributeError: # The Hub can only be instantiated from the root fiber. No other fibers # can run until the Hub is there, so the root will always be the first # one to call get_hub(). as...
[ "def", "get_hub", "(", ")", ":", "try", ":", "hub", "=", "_local", ".", "hub", "except", "AttributeError", ":", "# The Hub can only be instantiated from the root fiber. No other fibers", "# can run until the Hub is there, so the root will always be the first", "# one to call get_hu...
Return the instance of the hub.
[ "Return", "the", "instance", "of", "the", "hub", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/hub.py#L197-L207
geertj/gruvi
lib/gruvi/hub.py
sleep
def sleep(secs): """Sleep for *secs* seconds. The *secs* argument can be an int or a float.""" hub = get_hub() try: with switch_back(secs, hub): hub.switch() except Timeout: pass
python
def sleep(secs): """Sleep for *secs* seconds. The *secs* argument can be an int or a float.""" hub = get_hub() try: with switch_back(secs, hub): hub.switch() except Timeout: pass
[ "def", "sleep", "(", "secs", ")", ":", "hub", "=", "get_hub", "(", ")", "try", ":", "with", "switch_back", "(", "secs", ",", "hub", ")", ":", "hub", ".", "switch", "(", ")", "except", "Timeout", ":", "pass" ]
Sleep for *secs* seconds. The *secs* argument can be an int or a float.
[ "Sleep", "for", "*", "secs", "*", "seconds", ".", "The", "*", "secs", "*", "argument", "can", "be", "an", "int", "or", "a", "float", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/hub.py#L437-L444
geertj/gruvi
lib/gruvi/hub.py
switch_back.switch
def switch(self, value=None): """Switch back to the origin fiber. The fiber is switch in next time the event loop runs.""" if self._hub is None or not self._fiber.is_alive(): return self._hub.run_callback(self._fiber.switch, value) self._hub = self._fiber = None
python
def switch(self, value=None): """Switch back to the origin fiber. The fiber is switch in next time the event loop runs.""" if self._hub is None or not self._fiber.is_alive(): return self._hub.run_callback(self._fiber.switch, value) self._hub = self._fiber = None
[ "def", "switch", "(", "self", ",", "value", "=", "None", ")", ":", "if", "self", ".", "_hub", "is", "None", "or", "not", "self", ".", "_fiber", ".", "is_alive", "(", ")", ":", "return", "self", ".", "_hub", ".", "run_callback", "(", "self", ".", ...
Switch back to the origin fiber. The fiber is switch in next time the event loop runs.
[ "Switch", "back", "to", "the", "origin", "fiber", ".", "The", "fiber", "is", "switch", "in", "next", "time", "the", "event", "loop", "runs", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/hub.py#L133-L139
geertj/gruvi
lib/gruvi/hub.py
switch_back.throw
def throw(self, typ, val=None, tb=None): """Throw an exception into the origin fiber. The exception is thrown the next time the event loop runs.""" # The might seem redundant with self._fiber.cancel(exc), but it isn't # as self._fiber might be a "raw" fibers.Fiber() that doesn't have a ...
python
def throw(self, typ, val=None, tb=None): """Throw an exception into the origin fiber. The exception is thrown the next time the event loop runs.""" # The might seem redundant with self._fiber.cancel(exc), but it isn't # as self._fiber might be a "raw" fibers.Fiber() that doesn't have a ...
[ "def", "throw", "(", "self", ",", "typ", ",", "val", "=", "None", ",", "tb", "=", "None", ")", ":", "# The might seem redundant with self._fiber.cancel(exc), but it isn't", "# as self._fiber might be a \"raw\" fibers.Fiber() that doesn't have a", "# cancel() method.", "if", "...
Throw an exception into the origin fiber. The exception is thrown the next time the event loop runs.
[ "Throw", "an", "exception", "into", "the", "origin", "fiber", ".", "The", "exception", "is", "thrown", "the", "next", "time", "the", "event", "loop", "runs", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/hub.py#L141-L150
geertj/gruvi
lib/gruvi/hub.py
Hub.close
def close(self): """Close the hub and wait for it to be closed. This may only be called in the root fiber. After this call returned, Gruvi cannot be used anymore in the current thread. The main use case for calling this method is to clean up resources in a multi-threaded program...
python
def close(self): """Close the hub and wait for it to be closed. This may only be called in the root fiber. After this call returned, Gruvi cannot be used anymore in the current thread. The main use case for calling this method is to clean up resources in a multi-threaded program...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_loop", "is", "None", ":", "return", "if", "fibers", ".", "current", "(", ")", ".", "parent", "is", "not", "None", ":", "raise", "RuntimeError", "(", "'close() may only be called in the root fiber'",...
Close the hub and wait for it to be closed. This may only be called in the root fiber. After this call returned, Gruvi cannot be used anymore in the current thread. The main use case for calling this method is to clean up resources in a multi-threaded program where you want to exit a th...
[ "Close", "the", "hub", "and", "wait", "for", "it", "to", "be", "closed", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/hub.py#L314-L333
geertj/gruvi
lib/gruvi/hub.py
Hub.switch
def switch(self): """Switch to the hub. This method pauses the current fiber and runs the event loop. The caller should ensure that it has set up appropriate callbacks so that it will get scheduled again, preferably using :class:`switch_back`. In this case then return value of t...
python
def switch(self): """Switch to the hub. This method pauses the current fiber and runs the event loop. The caller should ensure that it has set up appropriate callbacks so that it will get scheduled again, preferably using :class:`switch_back`. In this case then return value of t...
[ "def", "switch", "(", "self", ")", ":", "if", "self", ".", "_loop", "is", "None", "or", "not", "self", ".", "is_alive", "(", ")", ":", "raise", "RuntimeError", "(", "'hub is closed/dead'", ")", "elif", "fibers", ".", "current", "(", ")", "is", "self", ...
Switch to the hub. This method pauses the current fiber and runs the event loop. The caller should ensure that it has set up appropriate callbacks so that it will get scheduled again, preferably using :class:`switch_back`. In this case then return value of this method will be an ``(args...
[ "Switch", "to", "the", "hub", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/hub.py#L377-L406
geertj/gruvi
lib/gruvi/hub.py
Hub._run_callbacks
def _run_callbacks(self): """Run registered callbacks.""" for i in range(len(self._callbacks)): callback, args = self._callbacks.popleft() try: callback(*args) except Exception: self._log.exception('Ignoring exception in callback:')
python
def _run_callbacks(self): """Run registered callbacks.""" for i in range(len(self._callbacks)): callback, args = self._callbacks.popleft() try: callback(*args) except Exception: self._log.exception('Ignoring exception in callback:')
[ "def", "_run_callbacks", "(", "self", ")", ":", "for", "i", "in", "range", "(", "len", "(", "self", ".", "_callbacks", ")", ")", ":", "callback", ",", "args", "=", "self", ".", "_callbacks", ".", "popleft", "(", ")", "try", ":", "callback", "(", "*...
Run registered callbacks.
[ "Run", "registered", "callbacks", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/hub.py#L408-L415
geertj/gruvi
lib/gruvi/hub.py
Hub.run_callback
def run_callback(self, callback, *args): """Queue a callback. The *callback* will be called with positional arguments *args* in the next iteration of the event loop. If you add multiple callbacks, they will be called in the order that you added them. The callback will run in the...
python
def run_callback(self, callback, *args): """Queue a callback. The *callback* will be called with positional arguments *args* in the next iteration of the event loop. If you add multiple callbacks, they will be called in the order that you added them. The callback will run in the...
[ "def", "run_callback", "(", "self", ",", "callback", ",", "*", "args", ")", ":", "if", "self", ".", "_loop", "is", "None", ":", "raise", "RuntimeError", "(", "'hub is closed'", ")", "elif", "not", "callable", "(", "callback", ")", ":", "raise", "TypeErro...
Queue a callback. The *callback* will be called with positional arguments *args* in the next iteration of the event loop. If you add multiple callbacks, they will be called in the order that you added them. The callback will run in the Hub's fiber. This method is thread-safe: i...
[ "Queue", "a", "callback", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/hub.py#L417-L433
geertj/gruvi
lib/gruvi/jsonrpc.py
message_info
def message_info(message): """Return a string describing a message, for debugging purposes.""" method = message.get('method') msgid = message.get('id') error = message.get('error') if method and msgid is not None: return 'method call "{}", id = "{}"'.format(method, msgid) elif method: ...
python
def message_info(message): """Return a string describing a message, for debugging purposes.""" method = message.get('method') msgid = message.get('id') error = message.get('error') if method and msgid is not None: return 'method call "{}", id = "{}"'.format(method, msgid) elif method: ...
[ "def", "message_info", "(", "message", ")", ":", "method", "=", "message", ".", "get", "(", "'method'", ")", "msgid", "=", "message", ".", "get", "(", "'id'", ")", "error", "=", "message", ".", "get", "(", "'error'", ")", "if", "method", "and", "msgi...
Return a string describing a message, for debugging purposes.
[ "Return", "a", "string", "describing", "a", "message", "for", "debugging", "purposes", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/jsonrpc.py#L260-L275
geertj/gruvi
lib/gruvi/jsonrpc.py
JsonRpcVersion.next_id
def next_id(self): """Return a unique message ID.""" msgid = self._id_template.format(self._next_id) self._next_id += 1 return msgid
python
def next_id(self): """Return a unique message ID.""" msgid = self._id_template.format(self._next_id) self._next_id += 1 return msgid
[ "def", "next_id", "(", "self", ")", ":", "msgid", "=", "self", ".", "_id_template", ".", "format", "(", "self", ".", "_next_id", ")", "self", ".", "_next_id", "+=", "1", "return", "msgid" ]
Return a unique message ID.
[ "Return", "a", "unique", "message", "ID", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/jsonrpc.py#L123-L127
geertj/gruvi
lib/gruvi/jsonrpc.py
JsonRpcVersion.create
def create(version): """Return a new instance for *version*, which can be either `'1.0'` or `'2.0'`.""" clsname = 'JsonRpcV{}'.format(version.rstrip('.0')) cls = globals()[clsname] return cls(version)
python
def create(version): """Return a new instance for *version*, which can be either `'1.0'` or `'2.0'`.""" clsname = 'JsonRpcV{}'.format(version.rstrip('.0')) cls = globals()[clsname] return cls(version)
[ "def", "create", "(", "version", ")", ":", "clsname", "=", "'JsonRpcV{}'", ".", "format", "(", "version", ".", "rstrip", "(", "'.0'", ")", ")", "cls", "=", "globals", "(", ")", "[", "clsname", "]", "return", "cls", "(", "version", ")" ]
Return a new instance for *version*, which can be either `'1.0'` or `'2.0'`.
[ "Return", "a", "new", "instance", "for", "*", "version", "*", "which", "can", "be", "either", "1", ".", "0", "or", "2", ".", "0", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/jsonrpc.py#L130-L135
geertj/gruvi
lib/gruvi/jsonrpc.py
JsonRpcProtocol.send_message
def send_message(self, message): """Send a raw JSON-RPC message. The *message* argument must be a dictionary containing a valid JSON-RPC message according to the version passed into the constructor. """ if self._error: raise compat.saved_exc(self._error) elif...
python
def send_message(self, message): """Send a raw JSON-RPC message. The *message* argument must be a dictionary containing a valid JSON-RPC message according to the version passed into the constructor. """ if self._error: raise compat.saved_exc(self._error) elif...
[ "def", "send_message", "(", "self", ",", "message", ")", ":", "if", "self", ".", "_error", ":", "raise", "compat", ".", "saved_exc", "(", "self", ".", "_error", ")", "elif", "self", ".", "_transport", "is", "None", ":", "raise", "JsonRpcError", "(", "'...
Send a raw JSON-RPC message. The *message* argument must be a dictionary containing a valid JSON-RPC message according to the version passed into the constructor.
[ "Send", "a", "raw", "JSON", "-", "RPC", "message", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/jsonrpc.py#L403-L414
geertj/gruvi
lib/gruvi/jsonrpc.py
JsonRpcProtocol.call_method
def call_method(self, method, *args): """Call a JSON-RPC method and wait for its result. The *method* is called with positional arguments *args*. On success, the ``result`` field from the JSON-RPC response is returned. On error, a :class:`JsonRpcError` is raised, which you can ...
python
def call_method(self, method, *args): """Call a JSON-RPC method and wait for its result. The *method* is called with positional arguments *args*. On success, the ``result`` field from the JSON-RPC response is returned. On error, a :class:`JsonRpcError` is raised, which you can ...
[ "def", "call_method", "(", "self", ",", "method", ",", "*", "args", ")", ":", "message", "=", "self", ".", "_version", ".", "create_request", "(", "method", ",", "args", ")", "msgid", "=", "message", "[", "'id'", "]", "try", ":", "with", "switch_back",...
Call a JSON-RPC method and wait for its result. The *method* is called with positional arguments *args*. On success, the ``result`` field from the JSON-RPC response is returned. On error, a :class:`JsonRpcError` is raised, which you can use to access the ``error`` field of the JSON-RP...
[ "Call", "a", "JSON", "-", "RPC", "method", "and", "wait", "for", "its", "result", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/jsonrpc.py#L417-L440
geertj/gruvi
lib/gruvi/jsonrpc.py
JsonRpcProtocol.send_notification
def send_notification(self, method, *args): """Send a JSON-RPC notification. The notification *method* is sent with positional arguments *args*. """ message = self._version.create_request(method, args, notification=True) self.send_message(message)
python
def send_notification(self, method, *args): """Send a JSON-RPC notification. The notification *method* is sent with positional arguments *args*. """ message = self._version.create_request(method, args, notification=True) self.send_message(message)
[ "def", "send_notification", "(", "self", ",", "method", ",", "*", "args", ")", ":", "message", "=", "self", ".", "_version", ".", "create_request", "(", "method", ",", "args", ",", "notification", "=", "True", ")", "self", ".", "send_message", "(", "mess...
Send a JSON-RPC notification. The notification *method* is sent with positional arguments *args*.
[ "Send", "a", "JSON", "-", "RPC", "notification", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/jsonrpc.py#L443-L449
geertj/gruvi
lib/gruvi/jsonrpc.py
JsonRpcProtocol.send_response
def send_response(self, request, result=None, error=None): """Respond to a JSON-RPC method call. This is a response to the message in *request*. If *error* is not provided, then this is a succesful response, and the value in *result*, which may be ``None``, is passed back to the client....
python
def send_response(self, request, result=None, error=None): """Respond to a JSON-RPC method call. This is a response to the message in *request*. If *error* is not provided, then this is a succesful response, and the value in *result*, which may be ``None``, is passed back to the client....
[ "def", "send_response", "(", "self", ",", "request", ",", "result", "=", "None", ",", "error", "=", "None", ")", ":", "message", "=", "self", ".", "_version", ".", "create_response", "(", "request", ",", "result", ",", "error", ")", "self", ".", "send_...
Respond to a JSON-RPC method call. This is a response to the message in *request*. If *error* is not provided, then this is a succesful response, and the value in *result*, which may be ``None``, is passed back to the client. if *error* is provided and not ``None`` then an error is sent...
[ "Respond", "to", "a", "JSON", "-", "RPC", "method", "call", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/jsonrpc.py#L452-L462
geertj/gruvi
vendor/txdbus/marshal.py
sigFromPy
def sigFromPy( pobj ): """ Returns the DBus signature type for the argument. If the argument is an instance of one of the type wrapper classes, the exact type signature corresponding to the wrapper class will be used. If the object has a variable named 'dbusSignature', the value of that variable wil...
python
def sigFromPy( pobj ): """ Returns the DBus signature type for the argument. If the argument is an instance of one of the type wrapper classes, the exact type signature corresponding to the wrapper class will be used. If the object has a variable named 'dbusSignature', the value of that variable wil...
[ "def", "sigFromPy", "(", "pobj", ")", ":", "sig", "=", "getattr", "(", "pobj", ",", "'dbusSignature'", ",", "None", ")", "if", "sig", "is", "not", "None", ":", "return", "sig", "elif", "isinstance", "(", "pobj", ",", "int", ")", ":", "return", "'i'",...
Returns the DBus signature type for the argument. If the argument is an instance of one of the type wrapper classes, the exact type signature corresponding to the wrapper class will be used. If the object has a variable named 'dbusSignature', the value of that variable will be used. Otherwise, a generic...
[ "Returns", "the", "DBus", "signature", "type", "for", "the", "argument", ".", "If", "the", "argument", "is", "an", "instance", "of", "one", "of", "the", "type", "wrapper", "classes", "the", "exact", "type", "signature", "corresponding", "to", "the", "wrapper...
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/vendor/txdbus/marshal.py#L229-L275
geertj/gruvi
vendor/txdbus/marshal.py
genCompleteTypes
def genCompleteTypes( compoundSig ): """ Generator function used to iterate over each complete, top-level type contained in in a signature. Ex:: "iii" => [ 'i', 'i', 'i' ] "i(ii)i" => [ 'i', '(ii)', 'i' ] "i(i(ii))i" => [ 'i', '(i(ii))', 'i' ] """ i = 0 s...
python
def genCompleteTypes( compoundSig ): """ Generator function used to iterate over each complete, top-level type contained in in a signature. Ex:: "iii" => [ 'i', 'i', 'i' ] "i(ii)i" => [ 'i', '(ii)', 'i' ] "i(i(ii))i" => [ 'i', '(i(ii))', 'i' ] """ i = 0 s...
[ "def", "genCompleteTypes", "(", "compoundSig", ")", ":", "i", "=", "0", "start", "=", "0", "end", "=", "len", "(", "compoundSig", ")", "def", "find_end", "(", "idx", ",", "b", ",", "e", ")", ":", "depth", "=", "1", "while", "idx", "<", "end", ":"...
Generator function used to iterate over each complete, top-level type contained in in a signature. Ex:: "iii" => [ 'i', 'i', 'i' ] "i(ii)i" => [ 'i', '(ii)', 'i' ] "i(i(ii))i" => [ 'i', '(i(ii))', 'i' ]
[ "Generator", "function", "used", "to", "iterate", "over", "each", "complete", "top", "-", "level", "type", "contained", "in", "in", "a", "signature", ".", "Ex", "::", "iii", "=", ">", "[", "i", "i", "i", "]", "i", "(", "ii", ")", "i", "=", ">", "...
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/vendor/txdbus/marshal.py#L307-L354
geertj/gruvi
vendor/txdbus/marshal.py
marshal
def marshal( compoundSignature, variableList, startByte = 0, lendian=True ): """ Encodes the Python objects in variableList into the DBus wire-format matching the supplied compoundSignature. This function retuns a list of binary strings is rather than a single string to simplify the recursive marsha...
python
def marshal( compoundSignature, variableList, startByte = 0, lendian=True ): """ Encodes the Python objects in variableList into the DBus wire-format matching the supplied compoundSignature. This function retuns a list of binary strings is rather than a single string to simplify the recursive marsha...
[ "def", "marshal", "(", "compoundSignature", ",", "variableList", ",", "startByte", "=", "0", ",", "lendian", "=", "True", ")", ":", "chunks", "=", "list", "(", ")", "bstart", "=", "startByte", "if", "hasattr", "(", "variableList", ",", "'dbusOrder'", ")", ...
Encodes the Python objects in variableList into the DBus wire-format matching the supplied compoundSignature. This function retuns a list of binary strings is rather than a single string to simplify the recursive marshalling algorithm. A single string may be easily obtained from the result via: ''.join(...
[ "Encodes", "the", "Python", "objects", "in", "variableList", "into", "the", "DBus", "wire", "-", "format", "matching", "the", "supplied", "compoundSignature", ".", "This", "function", "retuns", "a", "list", "of", "binary", "strings", "is", "rather", "than", "a...
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/vendor/txdbus/marshal.py#L567-L618
geertj/gruvi
vendor/txdbus/marshal.py
unmarshal
def unmarshal( compoundSignature, data, offset = 0, lendian = True ): """ Unmarshals DBus encoded data. @type compoundSignature: C{string} @param compoundSignature: DBus signature specifying the encoded value types @type data: C{string} @param data: Binary data @type offset: C{int} @p...
python
def unmarshal( compoundSignature, data, offset = 0, lendian = True ): """ Unmarshals DBus encoded data. @type compoundSignature: C{string} @param compoundSignature: DBus signature specifying the encoded value types @type data: C{string} @param data: Binary data @type offset: C{int} @p...
[ "def", "unmarshal", "(", "compoundSignature", ",", "data", ",", "offset", "=", "0", ",", "lendian", "=", "True", ")", ":", "values", "=", "list", "(", ")", "start_offset", "=", "offset", "for", "ct", "in", "genCompleteTypes", "(", "compoundSignature", ")",...
Unmarshals DBus encoded data. @type compoundSignature: C{string} @param compoundSignature: DBus signature specifying the encoded value types @type data: C{string} @param data: Binary data @type offset: C{int} @param offset: Offset within data at which data for compoundSignature ...
[ "Unmarshals", "DBus", "encoded", "data", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/vendor/txdbus/marshal.py#L783-L815
geertj/gruvi
lib/gruvi/fibers.py
spawn
def spawn(func, *args, **kwargs): """Spawn a new fiber. A new :class:`Fiber` is created with main function *func* and positional arguments *args*. The keyword arguments are passed to the :class:`Fiber` constructor, not to the main function. The fiber is then scheduled to start by calling its :meth:...
python
def spawn(func, *args, **kwargs): """Spawn a new fiber. A new :class:`Fiber` is created with main function *func* and positional arguments *args*. The keyword arguments are passed to the :class:`Fiber` constructor, not to the main function. The fiber is then scheduled to start by calling its :meth:...
[ "def", "spawn", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "fiber", "=", "Fiber", "(", "func", ",", "args", ",", "*", "*", "kwargs", ")", "fiber", ".", "start", "(", ")", "return", "fiber" ]
Spawn a new fiber. A new :class:`Fiber` is created with main function *func* and positional arguments *args*. The keyword arguments are passed to the :class:`Fiber` constructor, not to the main function. The fiber is then scheduled to start by calling its :meth:`~Fiber.start` method. The fiber ins...
[ "Spawn", "a", "new", "fiber", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/fibers.py#L150-L162
geertj/gruvi
lib/gruvi/fibers.py
Fiber.start
def start(self): """Schedule the fiber to be started in the next iteration of the event loop.""" target = getattr(self._target, '__qualname__', self._target.__name__) self._log.debug('starting fiber {}, target {}', self.name, target) self._hub.run_callback(self.switch)
python
def start(self): """Schedule the fiber to be started in the next iteration of the event loop.""" target = getattr(self._target, '__qualname__', self._target.__name__) self._log.debug('starting fiber {}, target {}', self.name, target) self._hub.run_callback(self.switch)
[ "def", "start", "(", "self", ")", ":", "target", "=", "getattr", "(", "self", ".", "_target", ",", "'__qualname__'", ",", "self", ".", "_target", ".", "__name__", ")", "self", ".", "_log", ".", "debug", "(", "'starting fiber {}, target {}'", ",", "self", ...
Schedule the fiber to be started in the next iteration of the event loop.
[ "Schedule", "the", "fiber", "to", "be", "started", "in", "the", "next", "iteration", "of", "the", "event", "loop", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/fibers.py#L81-L86
geertj/gruvi
lib/gruvi/fibers.py
Fiber.cancel
def cancel(self, message=None): """Schedule the fiber to be cancelled in the next iteration of the event loop. Cancellation works by throwing a :class:`~gruvi.Cancelled` exception into the fiber. If *message* is provided, it will be set as the value of the exception. """...
python
def cancel(self, message=None): """Schedule the fiber to be cancelled in the next iteration of the event loop. Cancellation works by throwing a :class:`~gruvi.Cancelled` exception into the fiber. If *message* is provided, it will be set as the value of the exception. """...
[ "def", "cancel", "(", "self", ",", "message", "=", "None", ")", ":", "if", "not", "self", ".", "is_alive", "(", ")", ":", "return", "if", "message", "is", "None", ":", "message", "=", "'cancelled by Fiber.cancel()'", "self", ".", "_hub", ".", "run_callba...
Schedule the fiber to be cancelled in the next iteration of the event loop. Cancellation works by throwing a :class:`~gruvi.Cancelled` exception into the fiber. If *message* is provided, it will be set as the value of the exception.
[ "Schedule", "the", "fiber", "to", "be", "cancelled", "in", "the", "next", "iteration", "of", "the", "event", "loop", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/fibers.py#L105-L117
unique1o1/Meta-Music
Metamusic/__init__.py
MetaMusic.align_matches
def align_matches(self, matches: list)->Optional[dict]: """ Finds hash matches that align in time with other matches and finds consensus about which hashes are "true" signal from the audio. Returns a dictionary with match information. """ # align by diffs ...
python
def align_matches(self, matches: list)->Optional[dict]: """ Finds hash matches that align in time with other matches and finds consensus about which hashes are "true" signal from the audio. Returns a dictionary with match information. """ # align by diffs ...
[ "def", "align_matches", "(", "self", ",", "matches", ":", "list", ")", "->", "Optional", "[", "dict", "]", ":", "# align by diffs", "diff_counter", ":", "dict", "=", "{", "}", "largest", "=", "0", "largest_count", "=", "0", "song_id", "=", "-", "1", "f...
Finds hash matches that align in time with other matches and finds consensus about which hashes are "true" signal from the audio. Returns a dictionary with match information.
[ "Finds", "hash", "matches", "that", "align", "in", "time", "with", "other", "matches", "and", "finds", "consensus", "about", "which", "hashes", "are", "true", "signal", "from", "the", "audio", ".", "Returns", "a", "dictionary", "with", "match", "information", ...
train
https://github.com/unique1o1/Meta-Music/blob/8cd1b04011ae3671ece44cc6338d748f8d095eaf/Metamusic/__init__.py#L127-L172
geertj/gruvi
lib/gruvi/address.py
saddr
def saddr(address): """Return a string representation for an address. The *address* paramater can be a pipe name, an IP address tuple, or a socket address. The return value is always a ``str`` instance. """ if isinstance(address, six.string_types): return address elif isinstance(ad...
python
def saddr(address): """Return a string representation for an address. The *address* paramater can be a pipe name, an IP address tuple, or a socket address. The return value is always a ``str`` instance. """ if isinstance(address, six.string_types): return address elif isinstance(ad...
[ "def", "saddr", "(", "address", ")", ":", "if", "isinstance", "(", "address", ",", "six", ".", "string_types", ")", ":", "return", "address", "elif", "isinstance", "(", "address", ",", "tuple", ")", "and", "len", "(", "address", ")", ">=", "2", "and", ...
Return a string representation for an address. The *address* paramater can be a pipe name, an IP address tuple, or a socket address. The return value is always a ``str`` instance.
[ "Return", "a", "string", "representation", "for", "an", "address", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/address.py#L19-L34
geertj/gruvi
lib/gruvi/address.py
paddr
def paddr(address): """Parse a string representation of an address. This function is the inverse of :func:`saddr`. """ if not isinstance(address, six.string_types): raise TypeError('expecting a string') if address.startswith('['): p1 = address.find(']:') if p1 == -1: ...
python
def paddr(address): """Parse a string representation of an address. This function is the inverse of :func:`saddr`. """ if not isinstance(address, six.string_types): raise TypeError('expecting a string') if address.startswith('['): p1 = address.find(']:') if p1 == -1: ...
[ "def", "paddr", "(", "address", ")", ":", "if", "not", "isinstance", "(", "address", ",", "six", ".", "string_types", ")", ":", "raise", "TypeError", "(", "'expecting a string'", ")", "if", "address", ".", "startswith", "(", "'['", ")", ":", "p1", "=", ...
Parse a string representation of an address. This function is the inverse of :func:`saddr`.
[ "Parse", "a", "string", "representation", "of", "an", "address", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/address.py#L37-L53
geertj/gruvi
lib/gruvi/address.py
getaddrinfo
def getaddrinfo(node, service=0, family=0, socktype=0, protocol=0, flags=0, timeout=30): """Resolve an Internet *node* name and *service* into a socket address. The *family*, *socktype* and *protocol* are optional arguments that specify the address family, socket type and protocol, respectively. The *flags...
python
def getaddrinfo(node, service=0, family=0, socktype=0, protocol=0, flags=0, timeout=30): """Resolve an Internet *node* name and *service* into a socket address. The *family*, *socktype* and *protocol* are optional arguments that specify the address family, socket type and protocol, respectively. The *flags...
[ "def", "getaddrinfo", "(", "node", ",", "service", "=", "0", ",", "family", "=", "0", ",", "socktype", "=", "0", ",", "protocol", "=", "0", ",", "flags", "=", "0", ",", "timeout", "=", "30", ")", ":", "hub", "=", "get_hub", "(", ")", "with", "s...
Resolve an Internet *node* name and *service* into a socket address. The *family*, *socktype* and *protocol* are optional arguments that specify the address family, socket type and protocol, respectively. The *flags* argument allows you to pass flags to further modify the resolution process. See the :f...
[ "Resolve", "an", "Internet", "*", "node", "*", "name", "and", "*", "service", "*", "into", "a", "socket", "address", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/address.py#L57-L83
geertj/gruvi
lib/gruvi/address.py
getnameinfo
def getnameinfo(sockaddr, flags=0, timeout=30): """Resolve a socket address *sockaddr* back to a ``(node, service)`` tuple. The *flags* argument can be used to modify the resolution process. See the :func:`socket.getnameinfo` function for more information. The address resolution is performed in the li...
python
def getnameinfo(sockaddr, flags=0, timeout=30): """Resolve a socket address *sockaddr* back to a ``(node, service)`` tuple. The *flags* argument can be used to modify the resolution process. See the :func:`socket.getnameinfo` function for more information. The address resolution is performed in the li...
[ "def", "getnameinfo", "(", "sockaddr", ",", "flags", "=", "0", ",", "timeout", "=", "30", ")", ":", "hub", "=", "get_hub", "(", ")", "with", "switch_back", "(", "timeout", ")", "as", "switcher", ":", "request", "=", "pyuv", ".", "dns", ".", "getnamei...
Resolve a socket address *sockaddr* back to a ``(node, service)`` tuple. The *flags* argument can be used to modify the resolution process. See the :func:`socket.getnameinfo` function for more information. The address resolution is performed in the libuv thread pool.
[ "Resolve", "a", "socket", "address", "*", "sockaddr", "*", "back", "to", "a", "(", "node", "service", ")", "tuple", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/address.py#L87-L104
welbornprod/colr
colr/base.py
get_codes
def get_codes(s: Union[str, 'ChainedBase']) -> List[str]: """ Grab all escape codes from a string. Returns a list of all escape codes. """ return codegrabpat.findall(str(s))
python
def get_codes(s: Union[str, 'ChainedBase']) -> List[str]: """ Grab all escape codes from a string. Returns a list of all escape codes. """ return codegrabpat.findall(str(s))
[ "def", "get_codes", "(", "s", ":", "Union", "[", "str", ",", "'ChainedBase'", "]", ")", "->", "List", "[", "str", "]", ":", "return", "codegrabpat", ".", "findall", "(", "str", "(", "s", ")", ")" ]
Grab all escape codes from a string. Returns a list of all escape codes.
[ "Grab", "all", "escape", "codes", "from", "a", "string", ".", "Returns", "a", "list", "of", "all", "escape", "codes", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/base.py#L72-L76
welbornprod/colr
colr/base.py
get_code_indices
def get_code_indices(s: Union[str, 'ChainedBase']) -> Dict[int, str]: """ Retrieve a dict of {index: escape_code} for a given string. If no escape codes are found, an empty dict is returned. """ indices = {} i = 0 codes = get_codes(s) for code in codes: codeindex = s.index(code) ...
python
def get_code_indices(s: Union[str, 'ChainedBase']) -> Dict[int, str]: """ Retrieve a dict of {index: escape_code} for a given string. If no escape codes are found, an empty dict is returned. """ indices = {} i = 0 codes = get_codes(s) for code in codes: codeindex = s.index(code) ...
[ "def", "get_code_indices", "(", "s", ":", "Union", "[", "str", ",", "'ChainedBase'", "]", ")", "->", "Dict", "[", "int", ",", "str", "]", ":", "indices", "=", "{", "}", "i", "=", "0", "codes", "=", "get_codes", "(", "s", ")", "for", "code", "in",...
Retrieve a dict of {index: escape_code} for a given string. If no escape codes are found, an empty dict is returned.
[ "Retrieve", "a", "dict", "of", "{", "index", ":", "escape_code", "}", "for", "a", "given", "string", ".", "If", "no", "escape", "codes", "are", "found", "an", "empty", "dict", "is", "returned", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/base.py#L79-L93
welbornprod/colr
colr/base.py
get_indices
def get_indices(s: Union[str, 'ChainedBase']) -> Dict[int, str]: """ Retrieve a dict of characters and escape codes with their real index into the string as the key. """ codes = get_code_indices(s) if not codes: # This function is not for non-escape-code stuff, but okay. return {...
python
def get_indices(s: Union[str, 'ChainedBase']) -> Dict[int, str]: """ Retrieve a dict of characters and escape codes with their real index into the string as the key. """ codes = get_code_indices(s) if not codes: # This function is not for non-escape-code stuff, but okay. return {...
[ "def", "get_indices", "(", "s", ":", "Union", "[", "str", ",", "'ChainedBase'", "]", ")", "->", "Dict", "[", "int", ",", "str", "]", ":", "codes", "=", "get_code_indices", "(", "s", ")", "if", "not", "codes", ":", "# This function is not for non-escape-cod...
Retrieve a dict of characters and escape codes with their real index into the string as the key.
[ "Retrieve", "a", "dict", "of", "characters", "and", "escape", "codes", "with", "their", "real", "index", "into", "the", "string", "as", "the", "key", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/base.py#L96-L127
welbornprod/colr
colr/base.py
strip_codes
def strip_codes(s: Union[str, 'ChainedBase']) -> str: """ Strip all color codes from a string. Returns empty string for "falsey" inputs (except 0). """ return codepat.sub('', str(s) if (s or (s == 0)) else '')
python
def strip_codes(s: Union[str, 'ChainedBase']) -> str: """ Strip all color codes from a string. Returns empty string for "falsey" inputs (except 0). """ return codepat.sub('', str(s) if (s or (s == 0)) else '')
[ "def", "strip_codes", "(", "s", ":", "Union", "[", "str", ",", "'ChainedBase'", "]", ")", "->", "str", ":", "return", "codepat", ".", "sub", "(", "''", ",", "str", "(", "s", ")", "if", "(", "s", "or", "(", "s", "==", "0", ")", ")", "else", "'...
Strip all color codes from a string. Returns empty string for "falsey" inputs (except 0).
[ "Strip", "all", "color", "codes", "from", "a", "string", ".", "Returns", "empty", "string", "for", "falsey", "inputs", "(", "except", "0", ")", "." ]
train
https://github.com/welbornprod/colr/blob/417117fdbddbc53142096685ac2af006b2bd0220/colr/base.py#L146-L150
geertj/gruvi
lib/gruvi/poll.py
MultiPoll.add_callback
def add_callback(self, events, callback): """Add a new callback.""" if self._poll is None: raise RuntimeError('poll instance is closed') if events & ~(READABLE|WRITABLE): raise ValueError('illegal event mask: {}'.format(events)) if events & READABLE: s...
python
def add_callback(self, events, callback): """Add a new callback.""" if self._poll is None: raise RuntimeError('poll instance is closed') if events & ~(READABLE|WRITABLE): raise ValueError('illegal event mask: {}'.format(events)) if events & READABLE: s...
[ "def", "add_callback", "(", "self", ",", "events", ",", "callback", ")", ":", "if", "self", ".", "_poll", "is", "None", ":", "raise", "RuntimeError", "(", "'poll instance is closed'", ")", "if", "events", "&", "~", "(", "READABLE", "|", "WRITABLE", ")", ...
Add a new callback.
[ "Add", "a", "new", "callback", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L105-L117
geertj/gruvi
lib/gruvi/poll.py
MultiPoll.remove_callback
def remove_callback(self, handle): """Remove a callback.""" if self._poll is None: raise RuntimeError('poll instance is closed') remove_callback(self, handle) if handle.extra & READABLE: self._readers -= 1 if handle.extra & WRITABLE: self._writ...
python
def remove_callback(self, handle): """Remove a callback.""" if self._poll is None: raise RuntimeError('poll instance is closed') remove_callback(self, handle) if handle.extra & READABLE: self._readers -= 1 if handle.extra & WRITABLE: self._writ...
[ "def", "remove_callback", "(", "self", ",", "handle", ")", ":", "if", "self", ".", "_poll", "is", "None", ":", "raise", "RuntimeError", "(", "'poll instance is closed'", ")", "remove_callback", "(", "self", ",", "handle", ")", "if", "handle", ".", "extra", ...
Remove a callback.
[ "Remove", "a", "callback", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L119-L128
geertj/gruvi
lib/gruvi/poll.py
MultiPoll.update_callback
def update_callback(self, handle, events): """Update the event mask for a callback.""" if self._poll is None: raise RuntimeError('poll instance is closed') if not has_callback(self, handle): raise ValueError('no such callback') if events & ~(READABLE|WRITABLE): ...
python
def update_callback(self, handle, events): """Update the event mask for a callback.""" if self._poll is None: raise RuntimeError('poll instance is closed') if not has_callback(self, handle): raise ValueError('no such callback') if events & ~(READABLE|WRITABLE): ...
[ "def", "update_callback", "(", "self", ",", "handle", ",", "events", ")", ":", "if", "self", ".", "_poll", "is", "None", ":", "raise", "RuntimeError", "(", "'poll instance is closed'", ")", "if", "not", "has_callback", "(", "self", ",", "handle", ")", ":",...
Update the event mask for a callback.
[ "Update", "the", "event", "mask", "for", "a", "callback", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L130-L149
geertj/gruvi
lib/gruvi/poll.py
MultiPoll.close
def close(self): """Close the poll instance.""" if self._poll is None: return self._poll.close() self._poll = None self._readers = 0 self._writers = 0 self._events = 0 clear_callbacks(self)
python
def close(self): """Close the poll instance.""" if self._poll is None: return self._poll.close() self._poll = None self._readers = 0 self._writers = 0 self._events = 0 clear_callbacks(self)
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_poll", "is", "None", ":", "return", "self", ".", "_poll", ".", "close", "(", ")", "self", ".", "_poll", "=", "None", "self", ".", "_readers", "=", "0", "self", ".", "_writers", "=", "0",...
Close the poll instance.
[ "Close", "the", "poll", "instance", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L151-L160
geertj/gruvi
lib/gruvi/poll.py
Poller.add_callback
def add_callback(self, fd, events, callback): """Add a new callback. The file descriptor *fd* will be watched for the events specified by the *events* parameter, which should be a bitwise OR of the constants ``READABLE`` and ``WRITABLE``. Whenever one or more of the specified ev...
python
def add_callback(self, fd, events, callback): """Add a new callback. The file descriptor *fd* will be watched for the events specified by the *events* parameter, which should be a bitwise OR of the constants ``READABLE`` and ``WRITABLE``. Whenever one or more of the specified ev...
[ "def", "add_callback", "(", "self", ",", "fd", ",", "events", ",", "callback", ")", ":", "if", "self", ".", "_mpoll", "is", "None", ":", "raise", "RuntimeError", "(", "'Poller instance is closed'", ")", "try", ":", "mpoll", "=", "self", ".", "_mpoll", "[...
Add a new callback. The file descriptor *fd* will be watched for the events specified by the *events* parameter, which should be a bitwise OR of the constants ``READABLE`` and ``WRITABLE``. Whenever one or more of the specified events occur, *callback* will be called with a single integ...
[ "Add", "a", "new", "callback", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L181-L200
geertj/gruvi
lib/gruvi/poll.py
Poller.remove_callback
def remove_callback(self, fd, handle): """Remove a callback added by :meth:`~Poller.add_callback`. If this is the last callback that is registered for the fd then this will deallocate the ``MultiPoll`` instance and close the libuv handle. """ if self._mpoll is None: ...
python
def remove_callback(self, fd, handle): """Remove a callback added by :meth:`~Poller.add_callback`. If this is the last callback that is registered for the fd then this will deallocate the ``MultiPoll`` instance and close the libuv handle. """ if self._mpoll is None: ...
[ "def", "remove_callback", "(", "self", ",", "fd", ",", "handle", ")", ":", "if", "self", ".", "_mpoll", "is", "None", ":", "raise", "RuntimeError", "(", "'Poller instance is closed'", ")", "mpoll", "=", "self", ".", "_mpoll", ".", "get", "(", "fd", ")", ...
Remove a callback added by :meth:`~Poller.add_callback`. If this is the last callback that is registered for the fd then this will deallocate the ``MultiPoll`` instance and close the libuv handle.
[ "Remove", "a", "callback", "added", "by", ":", "meth", ":", "~Poller", ".", "add_callback", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L202-L213
geertj/gruvi
lib/gruvi/poll.py
Poller.update_callback
def update_callback(self, fd, handle, events): """Update the event mask associated with an existing callback. If you want to temporarily disable a callback then you can use this method with an *events* argument of ``0``. This is more efficient than removing the callback and adding it ag...
python
def update_callback(self, fd, handle, events): """Update the event mask associated with an existing callback. If you want to temporarily disable a callback then you can use this method with an *events* argument of ``0``. This is more efficient than removing the callback and adding it ag...
[ "def", "update_callback", "(", "self", ",", "fd", ",", "handle", ",", "events", ")", ":", "if", "self", ".", "_mpoll", "is", "None", ":", "raise", "RuntimeError", "(", "'Poller instance is closed'", ")", "mpoll", "=", "self", ".", "_mpoll", ".", "get", "...
Update the event mask associated with an existing callback. If you want to temporarily disable a callback then you can use this method with an *events* argument of ``0``. This is more efficient than removing the callback and adding it again later.
[ "Update", "the", "event", "mask", "associated", "with", "an", "existing", "callback", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L215-L227
geertj/gruvi
lib/gruvi/poll.py
Poller.close
def close(self): """Close all active poll instances and remove all callbacks.""" if self._mpoll is None: return for mpoll in self._mpoll.values(): mpoll.close() self._mpoll.clear() self._mpoll = None
python
def close(self): """Close all active poll instances and remove all callbacks.""" if self._mpoll is None: return for mpoll in self._mpoll.values(): mpoll.close() self._mpoll.clear() self._mpoll = None
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_mpoll", "is", "None", ":", "return", "for", "mpoll", "in", "self", ".", "_mpoll", ".", "values", "(", ")", ":", "mpoll", ".", "close", "(", ")", "self", ".", "_mpoll", ".", "clear", "(",...
Close all active poll instances and remove all callbacks.
[ "Close", "all", "active", "poll", "instances", "and", "remove", "all", "callbacks", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/poll.py#L229-L236
geertj/gruvi
vendor/txdbus/authentication.py
ClientAuthenticator.authTryNextMethod
def authTryNextMethod(self): """ Tries the next authentication method or raises a failure if all mechanisms have been tried. """ if not self.authOrder: raise DBusAuthenticationFailed() self.authMech = self.authOrder.pop() if self...
python
def authTryNextMethod(self): """ Tries the next authentication method or raises a failure if all mechanisms have been tried. """ if not self.authOrder: raise DBusAuthenticationFailed() self.authMech = self.authOrder.pop() if self...
[ "def", "authTryNextMethod", "(", "self", ")", ":", "if", "not", "self", ".", "authOrder", ":", "raise", "DBusAuthenticationFailed", "(", ")", "self", ".", "authMech", "=", "self", ".", "authOrder", ".", "pop", "(", ")", "if", "self", ".", "authMech", "==...
Tries the next authentication method or raises a failure if all mechanisms have been tried.
[ "Tries", "the", "next", "authentication", "method", "or", "raises", "a", "failure", "if", "all", "mechanisms", "have", "been", "tried", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/vendor/txdbus/authentication.py#L82-L99
geertj/gruvi
vendor/txdbus/authentication.py
ClientAuthenticator._authGetDBusCookie
def _authGetDBusCookie(self, cookie_context, cookie_id): """ Reads the requested cookie_id from the cookie_context file """ # XXX Ensure we obtain the correct directory for the # authenticating user and that that user actually # owns the keyrings directory ...
python
def _authGetDBusCookie(self, cookie_context, cookie_id): """ Reads the requested cookie_id from the cookie_context file """ # XXX Ensure we obtain the correct directory for the # authenticating user and that that user actually # owns the keyrings directory ...
[ "def", "_authGetDBusCookie", "(", "self", ",", "cookie_context", ",", "cookie_id", ")", ":", "# XXX Ensure we obtain the correct directory for the", "# authenticating user and that that user actually", "# owns the keyrings directory", "if", "self", ".", "cookie_dir", ...
Reads the requested cookie_id from the cookie_context file
[ "Reads", "the", "requested", "cookie_id", "from", "the", "cookie_context", "file" ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/vendor/txdbus/authentication.py#L159-L192
geertj/gruvi
lib/gruvi/callbacks.py
add_callback
def add_callback(obj, callback, args=()): """Add a callback to an object.""" callbacks = obj._callbacks node = Node(callback, args) # Store a single callback directly in _callbacks if callbacks is None: obj._callbacks = node return node # Otherwise use a dllist. if not isinst...
python
def add_callback(obj, callback, args=()): """Add a callback to an object.""" callbacks = obj._callbacks node = Node(callback, args) # Store a single callback directly in _callbacks if callbacks is None: obj._callbacks = node return node # Otherwise use a dllist. if not isinst...
[ "def", "add_callback", "(", "obj", ",", "callback", ",", "args", "=", "(", ")", ")", ":", "callbacks", "=", "obj", ".", "_callbacks", "node", "=", "Node", "(", "callback", ",", "args", ")", "# Store a single callback directly in _callbacks", "if", "callbacks",...
Add a callback to an object.
[ "Add", "a", "callback", "to", "an", "object", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/callbacks.py#L27-L41
geertj/gruvi
lib/gruvi/callbacks.py
remove_callback
def remove_callback(obj, handle): """Remove a callback from an object.""" callbacks = obj._callbacks if callbacks is handle: obj._callbacks = None elif isinstance(callbacks, dllist): callbacks.remove(handle) if not callbacks: obj._callbacks = None
python
def remove_callback(obj, handle): """Remove a callback from an object.""" callbacks = obj._callbacks if callbacks is handle: obj._callbacks = None elif isinstance(callbacks, dllist): callbacks.remove(handle) if not callbacks: obj._callbacks = None
[ "def", "remove_callback", "(", "obj", ",", "handle", ")", ":", "callbacks", "=", "obj", ".", "_callbacks", "if", "callbacks", "is", "handle", ":", "obj", ".", "_callbacks", "=", "None", "elif", "isinstance", "(", "callbacks", ",", "dllist", ")", ":", "ca...
Remove a callback from an object.
[ "Remove", "a", "callback", "from", "an", "object", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/callbacks.py#L44-L52
geertj/gruvi
lib/gruvi/callbacks.py
has_callback
def has_callback(obj, handle): """Return whether a callback is currently registered for an object.""" callbacks = obj._callbacks if not callbacks: return False if isinstance(callbacks, Node): return handle is callbacks else: return handle in callbacks
python
def has_callback(obj, handle): """Return whether a callback is currently registered for an object.""" callbacks = obj._callbacks if not callbacks: return False if isinstance(callbacks, Node): return handle is callbacks else: return handle in callbacks
[ "def", "has_callback", "(", "obj", ",", "handle", ")", ":", "callbacks", "=", "obj", ".", "_callbacks", "if", "not", "callbacks", ":", "return", "False", "if", "isinstance", "(", "callbacks", ",", "Node", ")", ":", "return", "handle", "is", "callbacks", ...
Return whether a callback is currently registered for an object.
[ "Return", "whether", "a", "callback", "is", "currently", "registered", "for", "an", "object", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/callbacks.py#L55-L63
geertj/gruvi
lib/gruvi/callbacks.py
pop_callback
def pop_callback(obj): """Pop a single callback.""" callbacks = obj._callbacks if not callbacks: return if isinstance(callbacks, Node): node = callbacks obj._callbacks = None else: node = callbacks.first callbacks.remove(node) if not callbacks: ...
python
def pop_callback(obj): """Pop a single callback.""" callbacks = obj._callbacks if not callbacks: return if isinstance(callbacks, Node): node = callbacks obj._callbacks = None else: node = callbacks.first callbacks.remove(node) if not callbacks: ...
[ "def", "pop_callback", "(", "obj", ")", ":", "callbacks", "=", "obj", ".", "_callbacks", "if", "not", "callbacks", ":", "return", "if", "isinstance", "(", "callbacks", ",", "Node", ")", ":", "node", "=", "callbacks", "obj", ".", "_callbacks", "=", "None"...
Pop a single callback.
[ "Pop", "a", "single", "callback", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/callbacks.py#L66-L79
geertj/gruvi
lib/gruvi/callbacks.py
clear_callbacks
def clear_callbacks(obj): """Remove all callbacks from an object.""" callbacks = obj._callbacks if isinstance(callbacks, dllist): # Help the garbage collector by clearing all links. callbacks.clear() obj._callbacks = None
python
def clear_callbacks(obj): """Remove all callbacks from an object.""" callbacks = obj._callbacks if isinstance(callbacks, dllist): # Help the garbage collector by clearing all links. callbacks.clear() obj._callbacks = None
[ "def", "clear_callbacks", "(", "obj", ")", ":", "callbacks", "=", "obj", ".", "_callbacks", "if", "isinstance", "(", "callbacks", ",", "dllist", ")", ":", "# Help the garbage collector by clearing all links.", "callbacks", ".", "clear", "(", ")", "obj", ".", "_c...
Remove all callbacks from an object.
[ "Remove", "all", "callbacks", "from", "an", "object", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/callbacks.py#L82-L88
geertj/gruvi
lib/gruvi/callbacks.py
walk_callbacks
def walk_callbacks(obj, func, log=None): """Call func(callback, args) for all callbacks and keep only those callbacks for which the function returns True.""" callbacks = obj._callbacks if isinstance(callbacks, Node): node = callbacks try: if not func(node.data, node.extra): ...
python
def walk_callbacks(obj, func, log=None): """Call func(callback, args) for all callbacks and keep only those callbacks for which the function returns True.""" callbacks = obj._callbacks if isinstance(callbacks, Node): node = callbacks try: if not func(node.data, node.extra): ...
[ "def", "walk_callbacks", "(", "obj", ",", "func", ",", "log", "=", "None", ")", ":", "callbacks", "=", "obj", ".", "_callbacks", "if", "isinstance", "(", "callbacks", ",", "Node", ")", ":", "node", "=", "callbacks", "try", ":", "if", "not", "func", "...
Call func(callback, args) for all callbacks and keep only those callbacks for which the function returns True.
[ "Call", "func", "(", "callback", "args", ")", "for", "all", "callbacks", "and", "keep", "only", "those", "callbacks", "for", "which", "the", "function", "returns", "True", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/callbacks.py#L91-L115
geertj/gruvi
lib/gruvi/callbacks.py
run_callbacks
def run_callbacks(obj, log=None): """Run callbacks.""" def run_callback(callback, args): return callback(*args) return walk_callbacks(obj, run_callback, log)
python
def run_callbacks(obj, log=None): """Run callbacks.""" def run_callback(callback, args): return callback(*args) return walk_callbacks(obj, run_callback, log)
[ "def", "run_callbacks", "(", "obj", ",", "log", "=", "None", ")", ":", "def", "run_callback", "(", "callback", ",", "args", ")", ":", "return", "callback", "(", "*", "args", ")", "return", "walk_callbacks", "(", "obj", ",", "run_callback", ",", "log", ...
Run callbacks.
[ "Run", "callbacks", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/callbacks.py#L118-L122
edx/django-config-models
config_models/utils.py
get_serializer_class
def get_serializer_class(configuration_model): """ Returns a ConfigurationModel serializer class for the supplied configuration_model. """ class AutoConfigModelSerializer(ModelSerializer): """Serializer class for configuration models.""" class Meta(object): """Meta information for A...
python
def get_serializer_class(configuration_model): """ Returns a ConfigurationModel serializer class for the supplied configuration_model. """ class AutoConfigModelSerializer(ModelSerializer): """Serializer class for configuration models.""" class Meta(object): """Meta information for A...
[ "def", "get_serializer_class", "(", "configuration_model", ")", ":", "class", "AutoConfigModelSerializer", "(", "ModelSerializer", ")", ":", "\"\"\"Serializer class for configuration models.\"\"\"", "class", "Meta", "(", "object", ")", ":", "\"\"\"Meta information for AutoConfi...
Returns a ConfigurationModel serializer class for the supplied configuration_model.
[ "Returns", "a", "ConfigurationModel", "serializer", "class", "for", "the", "supplied", "configuration_model", "." ]
train
https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/utils.py#L12-L28
edx/django-config-models
config_models/utils.py
deserialize_json
def deserialize_json(stream, username): """ Given a stream containing JSON, deserializers the JSON into ConfigurationModel instances. The stream is expected to be in the following format: { "model": "config_models.ExampleConfigurationModel", "data": [ { "enabled"...
python
def deserialize_json(stream, username): """ Given a stream containing JSON, deserializers the JSON into ConfigurationModel instances. The stream is expected to be in the following format: { "model": "config_models.ExampleConfigurationModel", "data": [ { "enabled"...
[ "def", "deserialize_json", "(", "stream", ",", "username", ")", ":", "parsed_json", "=", "JSONParser", "(", ")", ".", "parse", "(", "stream", ")", "serializer_class", "=", "get_serializer_class", "(", "apps", ".", "get_model", "(", "parsed_json", "[", "\"model...
Given a stream containing JSON, deserializers the JSON into ConfigurationModel instances. The stream is expected to be in the following format: { "model": "config_models.ExampleConfigurationModel", "data": [ { "enabled": True, "color": "black" ...
[ "Given", "a", "stream", "containing", "JSON", "deserializers", "the", "JSON", "into", "ConfigurationModel", "instances", "." ]
train
https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/utils.py#L31-L73
edx/django-config-models
config_models/admin.py
ConfigurationModelAdmin.get_displayable_field_names
def get_displayable_field_names(self): """ Return all field names, excluding reverse foreign key relationships. """ return [ f.name for f in self.model._meta.get_fields() if not f.one_to_many ]
python
def get_displayable_field_names(self): """ Return all field names, excluding reverse foreign key relationships. """ return [ f.name for f in self.model._meta.get_fields() if not f.one_to_many ]
[ "def", "get_displayable_field_names", "(", "self", ")", ":", "return", "[", "f", ".", "name", "for", "f", "in", "self", ".", "model", ".", "_meta", ".", "get_fields", "(", ")", "if", "not", "f", ".", "one_to_many", "]" ]
Return all field names, excluding reverse foreign key relationships.
[ "Return", "all", "field", "names", "excluding", "reverse", "foreign", "key", "relationships", "." ]
train
https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/admin.py#L45-L53
edx/django-config-models
config_models/admin.py
ConfigurationModelAdmin.revert
def revert(self, request, queryset): """ Admin action to revert a configuration back to the selected value """ if queryset.count() != 1: self.message_user(request, _("Please select a single configuration to revert to.")) return target = queryset[0] ...
python
def revert(self, request, queryset): """ Admin action to revert a configuration back to the selected value """ if queryset.count() != 1: self.message_user(request, _("Please select a single configuration to revert to.")) return target = queryset[0] ...
[ "def", "revert", "(", "self", ",", "request", ",", "queryset", ")", ":", "if", "queryset", ".", "count", "(", ")", "!=", "1", ":", "self", ".", "message_user", "(", "request", ",", "_", "(", "\"Please select a single configuration to revert to.\"", ")", ")",...
Admin action to revert a configuration back to the selected value
[ "Admin", "action", "to", "revert", "a", "configuration", "back", "to", "the", "selected", "value" ]
train
https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/admin.py#L89-L110
edx/django-config-models
config_models/admin.py
ShowHistoryFilter.choices
def choices(self, changelist): """ Returns choices ready to be output in the template. """ show_all = self.used_parameters.get(self.parameter_name) == "1" return ( { 'display': _('Current Configuration'), 'selected': not show_all, 'quer...
python
def choices(self, changelist): """ Returns choices ready to be output in the template. """ show_all = self.used_parameters.get(self.parameter_name) == "1" return ( { 'display': _('Current Configuration'), 'selected': not show_all, 'quer...
[ "def", "choices", "(", "self", ",", "changelist", ")", ":", "show_all", "=", "self", ".", "used_parameters", ".", "get", "(", "self", ".", "parameter_name", ")", "==", "\"1\"", "return", "(", "{", "'display'", ":", "_", "(", "'Current Configuration'", ")",...
Returns choices ready to be output in the template.
[ "Returns", "choices", "ready", "to", "be", "output", "in", "the", "template", "." ]
train
https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/admin.py#L131-L145
edx/django-config-models
config_models/admin.py
KeyedConfigurationModelAdmin.get_queryset
def get_queryset(self, request): """ Annote the queryset with an 'is_active' property that's true iff that row is the most recently added row for that particular set of KEY_FIELDS values. Filter the queryset to show only is_active rows by default. """ if request.GET.get(S...
python
def get_queryset(self, request): """ Annote the queryset with an 'is_active' property that's true iff that row is the most recently added row for that particular set of KEY_FIELDS values. Filter the queryset to show only is_active rows by default. """ if request.GET.get(S...
[ "def", "get_queryset", "(", "self", ",", "request", ")", ":", "if", "request", ".", "GET", ".", "get", "(", "ShowHistoryFilter", ".", "parameter_name", ")", "==", "'1'", ":", "queryset", "=", "self", ".", "model", ".", "objects", ".", "with_active_flag", ...
Annote the queryset with an 'is_active' property that's true iff that row is the most recently added row for that particular set of KEY_FIELDS values. Filter the queryset to show only is_active rows by default.
[ "Annote", "the", "queryset", "with", "an", "is_active", "property", "that", "s", "true", "iff", "that", "row", "is", "the", "most", "recently", "added", "row", "for", "that", "particular", "set", "of", "KEY_FIELDS", "values", ".", "Filter", "the", "queryset"...
train
https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/admin.py#L164-L178
edx/django-config-models
config_models/admin.py
KeyedConfigurationModelAdmin.edit_link
def edit_link(self, inst): """ Edit link for the change view """ if not inst.is_active: return u'--' update_url = reverse('admin:{}_{}_add'.format(self.model._meta.app_label, self.model._meta.model_name)) update_url += "?source={}".format(inst.pk) return u'<a href="{}...
python
def edit_link(self, inst): """ Edit link for the change view """ if not inst.is_active: return u'--' update_url = reverse('admin:{}_{}_add'.format(self.model._meta.app_label, self.model._meta.model_name)) update_url += "?source={}".format(inst.pk) return u'<a href="{}...
[ "def", "edit_link", "(", "self", ",", "inst", ")", ":", "if", "not", "inst", ".", "is_active", ":", "return", "u'--'", "update_url", "=", "reverse", "(", "'admin:{}_{}_add'", ".", "format", "(", "self", ".", "model", ".", "_meta", ".", "app_label", ",", ...
Edit link for the change view
[ "Edit", "link", "for", "the", "change", "view" ]
train
https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/admin.py#L207-L213