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_documentation_string stringlengths 1 47.2k | 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),
) | Like str.rstrip, except it returns the Colr instance. | 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),
) | Like str.strip, except it returns the Colr instance. | 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... | Like __str__, except it returns a colorized Colr instance. | 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... | Like __str__, except it returns a colorized Colr instance. | 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... | Like __str__, except it returns a colorized Colr instance. | 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':... | Like __str__, except it returns a colorized Colr instance. | 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... | 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. | 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:
... | 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... | 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:
... | 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.
... | 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... | 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. | 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) | Move the cursor to the specified column, default 1.
Esc[<column>G | 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... | 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. | 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.
""... | 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. | 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) | Move the cursor to the beginning of the line, a number of lines down.
Default: 1
Esc[<lines>E | 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) | Move the cursor to a new position. Values are 1-based, and default
to 1.
Esc[<line>;<column>H
or
Esc[<line>;<column>f | 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) | Move the cursor to the beginning of the line, a number of lines up.
Default: 1
Esc[<lines>F | 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... | 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. | 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... | 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. | 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() | Like `print()`, except the file is `.flush()`ed afterwards. | 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... | 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. | 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) | Scroll the whole page down a number of lines, new lines are added to
the top.
Esc[<lines>T | 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) | Scroll the whole page up a number of lines, new lines are added to
the bottom.
Esc[<lines>S | 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.
... | 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:
... | 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.
... | 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... | 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])) | Return the last escape code in `self.data`.
If no escape codes are found, '' is returned. | 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)) | Move the cursor to a new position.
Default: line 1, column 1 | 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... | Repeat the last control code a number of times.
Returns a new Control with this one's data and the repeated code. | 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... | Repeat this entire Control code a number of times.
Returns a new Control with this one's data repeated. | 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... | Return a tuple of (R, G, B) from a hex color. | 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)) | Convert a hex value into the nearest terminal code number. | 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)) | Convert a hex value into the nearest terminal color matched hex. | 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])) | Print all 256 xterm color codes. | 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) | Convert rgb values to a hex code. | 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)] | Convert an rgb value to a terminal code. | 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 (... | Convert an rgb value to the nearest hex value that matches a term code.
The hex value will be one in `hex2term_map`. | 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... | 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. | 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((
... | Initialize from an int terminal code. | 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) | Initialize from a hex value string. | 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,... | Initialize from red, green, blue args. | 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... | Same as str(self), except the color codes are actually used. | 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 | Return a ColorCode from a terminal code. | 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 | Return a ColorCode from a hex string. | 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 | Return a ColorCode from a RGB tuple. | 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... | Used as a decorator for automatically making session commits | 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 | Return songs that have the fingerprinted flag set TRUE (1). | 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... | Return the instance of the hub. | 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 | Sleep for *secs* seconds. The *secs* argument can be an int or a float. | 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 | Switch back to the origin fiber. The fiber is switch in next time
the event loop runs. | 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
... | Throw an exception into the origin fiber. The exception is thrown
the next time the event loop runs. | 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... | 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... | 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... | 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... | 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:') | Run registered callbacks. | 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... | 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... | 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:
... | Return a string describing a message, for debugging purposes. | 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 | Return a unique message ID. | 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) | Return a new instance for *version*, which can be either `'1.0'`
or `'2.0'`. | 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... | 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. | 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
... | 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... | 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) | Send a JSON-RPC notification.
The notification *method* is sent with positional arguments *args*. | 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.... | 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... | 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... | 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... | 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... | 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' ] | 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... | 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(... | 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... | 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
... | 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:... | 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... | 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) | Schedule the fiber to be started in the next iteration of the
event loop. | 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.
"""... | 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. | 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
... | 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. | 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... | 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. | 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:
... | Parse a string representation of an address.
This function is the inverse of :func:`saddr`. | 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... | 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... | 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... | 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. | 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)) | Grab all escape codes from a string.
Returns a list of all escape codes. | 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)
... | Retrieve a dict of {index: escape_code} for a given string.
If no escape codes are found, an empty dict is returned. | 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 {... | Retrieve a dict of characters and escape codes with their real index
into the string as the key. | 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 '') | Strip all color codes from a string.
Returns empty string for "falsey" inputs (except 0). | 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... | Add a new callback. | 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... | Remove a callback. | 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):
... | Update the event mask for a callback. | 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) | Close the poll instance. | 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... | 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... | 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:
... | 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. | 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... | 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. | 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 | Close all active poll instances and remove all callbacks. | 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... | Tries the next authentication method or raises a failure if all mechanisms
have been tried. | 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
... | Reads the requested cookie_id from the cookie_context file | 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... | Add a callback to an object. | 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 | Remove a callback from an object. | 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 | Return whether a callback is currently registered for an object. | 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:
... | Pop a single callback. | 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 | Remove all callbacks from an object. | 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):
... | Call func(callback, args) for all callbacks and keep only those
callbacks for which the function returns True. | 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) | Run callbacks. | 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... | Returns a ConfigurationModel serializer class for the supplied configuration_model. | 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"... | 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"
... | 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
] | Return all field names, excluding reverse foreign key relationships. | 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]
... | Admin action to revert a configuration back to the selected value | 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... | Returns choices ready to be output in the template. | 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... | 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. | 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="{}... | Edit link for the change view | https://github.com/edx/django-config-models/blob/f22c05fe3ccb182a6be4dbe313e9d6749dffd3e4/config_models/admin.py#L207-L213 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.