repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
Buttons.register_button_handler
def register_button_handler(self, button_handler, buttons): """ Register a handler function which will be called when a button is pressed :param button_handler: A function which will be called when any of the specified buttons are pressed. The function is called with the...
python
def register_button_handler(self, button_handler, buttons): """ Register a handler function which will be called when a button is pressed :param button_handler: A function which will be called when any of the specified buttons are pressed. The function is called with the...
[ "def", "register_button_handler", "(", "self", ",", "button_handler", ",", "buttons", ")", ":", "if", "not", "isinstance", "(", "buttons", ",", "list", ")", ":", "buttons", "=", "[", "buttons", "]", "for", "button", "in", "buttons", ":", "state", "=", "s...
Register a handler function which will be called when a button is pressed :param button_handler: A function which will be called when any of the specified buttons are pressed. The function is called with the Button that was pressed as the sole argument. :param [Button] buttons: ...
[ "Register", "a", "handler", "function", "which", "will", "be", "called", "when", "a", "button", "is", "pressed" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L1011-L1039
python-useful-helpers/threaded
threaded/class_decorator.py
BaseDecorator._func
def _func(self) -> typing.Optional[typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]]]: """Get wrapped function. :rtype: typing.Optional[typing.Callable[..., typing.Union[typing.Awaitable, typing.Any]]] """ return self.__func
python
def _func(self) -> typing.Optional[typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]]]: """Get wrapped function. :rtype: typing.Optional[typing.Callable[..., typing.Union[typing.Awaitable, typing.Any]]] """ return self.__func
[ "def", "_func", "(", "self", ")", "->", "typing", ".", "Optional", "[", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Union", "[", "\"typing.Awaitable[typing.Any]\"", ",", "typing", ".", "Any", "]", "]", "]", ":", "return", "self", ".", "...
Get wrapped function. :rtype: typing.Optional[typing.Callable[..., typing.Union[typing.Awaitable, typing.Any]]]
[ "Get", "wrapped", "function", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/class_decorator.py#L89-L94
python-useful-helpers/threaded
threaded/class_decorator.py
BaseDecorator._get_function_wrapper
def _get_function_wrapper( self, func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]] ) -> typing.Callable[..., typing.Any]: """Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[..., typi...
python
def _get_function_wrapper( self, func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]] ) -> typing.Callable[..., typing.Any]: """Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[..., typi...
[ "def", "_get_function_wrapper", "(", "self", ",", "func", ":", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Union", "[", "\"typing.Awaitable[typing.Any]\"", ",", "typing", ".", "Any", "]", "]", ")", "->", "typing", ".", "Callable", "[", "......
Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[..., typing.Union[typing.Awaitable, typing.Any]] :rtype: typing.Callable
[ "Here", "should", "be", "constructed", "and", "returned", "real", "decorator", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/class_decorator.py#L97-L106
python-useful-helpers/threaded
threaded/class_decorator.py
BaseDecorator._await_if_required
def _await_if_required( target: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]] ) -> typing.Callable[..., typing.Any]: """Await result if coroutine was returned.""" @functools.wraps(target) def wrapper(*args, **kwargs): # type: (typing.Any, typing.Any...
python
def _await_if_required( target: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]] ) -> typing.Callable[..., typing.Any]: """Await result if coroutine was returned.""" @functools.wraps(target) def wrapper(*args, **kwargs): # type: (typing.Any, typing.Any...
[ "def", "_await_if_required", "(", "target", ":", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Union", "[", "\"typing.Awaitable[typing.Any]\"", ",", "typing", ".", "Any", "]", "]", ")", "->", "typing", ".", "Callable", "[", "...", ",", "typin...
Await result if coroutine was returned.
[ "Await", "result", "if", "coroutine", "was", "returned", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/class_decorator.py#L127-L142
ApproxEng/approxeng.input
src/python/approxeng/input/controllers.py
unique_name
def unique_name(device: InputDevice) -> str: """ Construct a unique name for the device based on, in order if available, the uniq ID, the phys ID and finally a concatenation of vendor, product, version and filename. :param device: An InputDevice instance to query :return: A string c...
python
def unique_name(device: InputDevice) -> str: """ Construct a unique name for the device based on, in order if available, the uniq ID, the phys ID and finally a concatenation of vendor, product, version and filename. :param device: An InputDevice instance to query :return: A string c...
[ "def", "unique_name", "(", "device", ":", "InputDevice", ")", "->", "str", ":", "if", "device", ".", "uniq", ":", "return", "device", ".", "uniq", "elif", "device", ".", "phys", ":", "return", "device", ".", "phys", ".", "split", "(", "'/'", ")", "["...
Construct a unique name for the device based on, in order if available, the uniq ID, the phys ID and finally a concatenation of vendor, product, version and filename. :param device: An InputDevice instance to query :return: A string containing as unique as possible a name for the physical e...
[ "Construct", "a", "unique", "name", "for", "the", "device", "based", "on", "in", "order", "if", "available", "the", "uniq", "ID", "the", "phys", "ID", "and", "finally", "a", "concatenation", "of", "vendor", "product", "version", "and", "filename", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/controllers.py#L115-L129
ApproxEng/approxeng.input
src/python/approxeng/input/controllers.py
find_matching_controllers
def find_matching_controllers(*requirements, **kwargs) -> [ControllerDiscovery]: """ Find a sequence of controllers which match the supplied requirements, or raise an error if no such controllers exist. :param requirements: Zero or more ControllerRequirement instances defining the requirements ...
python
def find_matching_controllers(*requirements, **kwargs) -> [ControllerDiscovery]: """ Find a sequence of controllers which match the supplied requirements, or raise an error if no such controllers exist. :param requirements: Zero or more ControllerRequirement instances defining the requirements ...
[ "def", "find_matching_controllers", "(", "*", "requirements", ",", "*", "*", "kwargs", ")", "->", "[", "ControllerDiscovery", "]", ":", "requirements", "=", "list", "(", "requirements", ")", "if", "requirements", "is", "None", "or", "len", "(", "requirements",...
Find a sequence of controllers which match the supplied requirements, or raise an error if no such controllers exist. :param requirements: Zero or more ControllerRequirement instances defining the requirements for controllers. If no item is passed it will be treated as a single requirement with...
[ "Find", "a", "sequence", "of", "controllers", "which", "match", "the", "supplied", "requirements", "or", "raise", "an", "error", "if", "no", "such", "controllers", "exist", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/controllers.py#L132-L176
ApproxEng/approxeng.input
src/python/approxeng/input/controllers.py
find_all_controllers
def find_all_controllers(**kwargs) -> [ControllerDiscovery]: """ :return: A list of :class:`~approxeng.input.controllers.ControllerDiscovery` instances corresponding to controllers attached to this host, ordered by the ordering on ControllerDiscovery. Any controllers found will be constr...
python
def find_all_controllers(**kwargs) -> [ControllerDiscovery]: """ :return: A list of :class:`~approxeng.input.controllers.ControllerDiscovery` instances corresponding to controllers attached to this host, ordered by the ordering on ControllerDiscovery. Any controllers found will be constr...
[ "def", "find_all_controllers", "(", "*", "*", "kwargs", ")", "->", "[", "ControllerDiscovery", "]", ":", "def", "get_controller_classes", "(", ")", "->", "[", "{", "}", "]", ":", "\"\"\"\n Scans for subclasses of :class:`~approxeng.input.Controller` and reads out d...
:return: A list of :class:`~approxeng.input.controllers.ControllerDiscovery` instances corresponding to controllers attached to this host, ordered by the ordering on ControllerDiscovery. Any controllers found will be constructed with kwargs passed to their constructor function, particularly usef...
[ ":", "return", ":", "A", "list", "of", ":", "class", ":", "~approxeng", ".", "input", ".", "controllers", ".", "ControllerDiscovery", "instances", "corresponding", "to", "controllers", "attached", "to", "this", "host", "ordered", "by", "the", "ordering", "on",...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/controllers.py#L179-L223
ApproxEng/approxeng.input
src/python/approxeng/input/controllers.py
print_devices
def print_devices(): """ Simple test function which prints out all devices found by evdev """ def device_verbose_info(device: InputDevice) -> {}: """ Gather and format as much info as possible about the supplied InputDevice. Used mostly for debugging at this point. :param devic...
python
def print_devices(): """ Simple test function which prints out all devices found by evdev """ def device_verbose_info(device: InputDevice) -> {}: """ Gather and format as much info as possible about the supplied InputDevice. Used mostly for debugging at this point. :param devic...
[ "def", "print_devices", "(", ")", ":", "def", "device_verbose_info", "(", "device", ":", "InputDevice", ")", "->", "{", "}", ":", "\"\"\"\n Gather and format as much info as possible about the supplied InputDevice. Used mostly for debugging at this point.\n\n :param dev...
Simple test function which prints out all devices found by evdev
[ "Simple", "test", "function", "which", "prints", "out", "all", "devices", "found", "by", "evdev" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/controllers.py#L226-L291
ApproxEng/approxeng.input
src/python/approxeng/input/controllers.py
print_controllers
def print_controllers(): """ Pretty-print all controllers found """ _check_import() pp = pprint.PrettyPrinter(indent=2) for discovery in find_all_controllers(): pp.pprint(discovery.controller)
python
def print_controllers(): """ Pretty-print all controllers found """ _check_import() pp = pprint.PrettyPrinter(indent=2) for discovery in find_all_controllers(): pp.pprint(discovery.controller)
[ "def", "print_controllers", "(", ")", ":", "_check_import", "(", ")", "pp", "=", "pprint", ".", "PrettyPrinter", "(", "indent", "=", "2", ")", "for", "discovery", "in", "find_all_controllers", "(", ")", ":", "pp", ".", "pprint", "(", "discovery", ".", "c...
Pretty-print all controllers found
[ "Pretty", "-", "print", "all", "controllers", "found" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/controllers.py#L294-L301
ApproxEng/approxeng.input
src/python/approxeng/input/controllers.py
ControllerRequirement.accept
def accept(self, discovery: ControllerDiscovery): """ Returns True if the supplied ControllerDiscovery matches this requirement, False otherwise """ if self.require_class is not None and not isinstance(discovery.controller, self.require_class): return False if self.sn...
python
def accept(self, discovery: ControllerDiscovery): """ Returns True if the supplied ControllerDiscovery matches this requirement, False otherwise """ if self.require_class is not None and not isinstance(discovery.controller, self.require_class): return False if self.sn...
[ "def", "accept", "(", "self", ",", "discovery", ":", "ControllerDiscovery", ")", ":", "if", "self", ".", "require_class", "is", "not", "None", "and", "not", "isinstance", "(", "discovery", ".", "controller", ",", "self", ".", "require_class", ")", ":", "re...
Returns True if the supplied ControllerDiscovery matches this requirement, False otherwise
[ "Returns", "True", "if", "the", "supplied", "ControllerDiscovery", "matches", "this", "requirement", "False", "otherwise" ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/controllers.py#L94-L105
TadLeonard/tfatool
tfatool/config.py
config
def config(param_map, mastercode=DEFAULT_MASTERCODE): """Takes a dictionary of {Config.key: value} and returns a dictionary of processed keys and values to be used in the construction of a POST request to FlashAir's config.cgi""" pmap = {Config.mastercode: mastercode} pmap.update(param_map) proc...
python
def config(param_map, mastercode=DEFAULT_MASTERCODE): """Takes a dictionary of {Config.key: value} and returns a dictionary of processed keys and values to be used in the construction of a POST request to FlashAir's config.cgi""" pmap = {Config.mastercode: mastercode} pmap.update(param_map) proc...
[ "def", "config", "(", "param_map", ",", "mastercode", "=", "DEFAULT_MASTERCODE", ")", ":", "pmap", "=", "{", "Config", ".", "mastercode", ":", "mastercode", "}", "pmap", ".", "update", "(", "param_map", ")", "processed_params", "=", "dict", "(", "_process_pa...
Takes a dictionary of {Config.key: value} and returns a dictionary of processed keys and values to be used in the construction of a POST request to FlashAir's config.cgi
[ "Takes", "a", "dictionary", "of", "{", "Config", ".", "key", ":", "value", "}", "and", "returns", "a", "dictionary", "of", "processed", "keys", "and", "values", "to", "be", "used", "in", "the", "construction", "of", "a", "POST", "request", "to", "FlashAi...
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/config.py#L8-L15
TadLeonard/tfatool
tfatool/config.py
post
def post(param_map, url=URL): """Posts a `param_map` created with `config` to the FlashAir config.cgi entrypoint""" prepped_request = _prep_post(url=url, **param_map) return cgi.send(prepped_request)
python
def post(param_map, url=URL): """Posts a `param_map` created with `config` to the FlashAir config.cgi entrypoint""" prepped_request = _prep_post(url=url, **param_map) return cgi.send(prepped_request)
[ "def", "post", "(", "param_map", ",", "url", "=", "URL", ")", ":", "prepped_request", "=", "_prep_post", "(", "url", "=", "url", ",", "*", "*", "param_map", ")", "return", "cgi", ".", "send", "(", "prepped_request", ")" ]
Posts a `param_map` created with `config` to the FlashAir config.cgi entrypoint
[ "Posts", "a", "param_map", "created", "with", "config", "to", "the", "FlashAir", "config", ".", "cgi", "entrypoint" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/config.py#L24-L28
TadLeonard/tfatool
tfatool/config.py
_validate_timeout
def _validate_timeout(seconds: float): """Creates an int from 60000 to 4294967294 that represents a valid millisecond wireless LAN timeout""" val = int(seconds * 1000) assert 60000 <= val <= 4294967294, "Bad value: {}".format(val) return val
python
def _validate_timeout(seconds: float): """Creates an int from 60000 to 4294967294 that represents a valid millisecond wireless LAN timeout""" val = int(seconds * 1000) assert 60000 <= val <= 4294967294, "Bad value: {}".format(val) return val
[ "def", "_validate_timeout", "(", "seconds", ":", "float", ")", ":", "val", "=", "int", "(", "seconds", "*", "1000", ")", "assert", "60000", "<=", "val", "<=", "4294967294", ",", "\"Bad value: {}\"", ".", "format", "(", "val", ")", "return", "val" ]
Creates an int from 60000 to 4294967294 that represents a valid millisecond wireless LAN timeout
[ "Creates", "an", "int", "from", "60000", "to", "4294967294", "that", "represents", "a", "valid", "millisecond", "wireless", "LAN", "timeout" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/config.py#L48-L53
TadLeonard/tfatool
tfatool/util.py
parse_datetime
def parse_datetime(datetime_input): """The arrow library is sadly not good enough to parse certain date strings. It even gives unexpected results for partial date strings such as '2015-01' or just '2015', which I think should be seen as 'the first moment of 2014'. This function should overcome those...
python
def parse_datetime(datetime_input): """The arrow library is sadly not good enough to parse certain date strings. It even gives unexpected results for partial date strings such as '2015-01' or just '2015', which I think should be seen as 'the first moment of 2014'. This function should overcome those...
[ "def", "parse_datetime", "(", "datetime_input", ")", ":", "date_els", ",", "time_els", "=", "_split_datetime", "(", "datetime_input", ")", "date_vals", "=", "_parse_date", "(", "date_els", ")", "time_vals", "=", "_parse_time", "(", "time_els", ")", "vals", "=", ...
The arrow library is sadly not good enough to parse certain date strings. It even gives unexpected results for partial date strings such as '2015-01' or just '2015', which I think should be seen as 'the first moment of 2014'. This function should overcome those limitations.
[ "The", "arrow", "library", "is", "sadly", "not", "good", "enough", "to", "parse", "certain", "date", "strings", ".", "It", "even", "gives", "unexpected", "results", "for", "partial", "date", "strings", "such", "as", "2015", "-", "01", "or", "just", "2015",...
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/util.py#L7-L17
ApproxEng/approxeng.input
src/python/approxeng/input/dualshock3.py
DualShock3.set_led
def set_led(self, led_number, led_value): """ Set front-panel controller LEDs. The DS3 controller has four, labelled, LEDs on the front panel that can be either on or off. :param led_number: Integer between 1 and 4 :param led_value: Value, set to 0 to tur...
python
def set_led(self, led_number, led_value): """ Set front-panel controller LEDs. The DS3 controller has four, labelled, LEDs on the front panel that can be either on or off. :param led_number: Integer between 1 and 4 :param led_value: Value, set to 0 to tur...
[ "def", "set_led", "(", "self", ",", "led_number", ",", "led_value", ")", ":", "if", "1", ">", "led_number", ">", "4", ":", "return", "write_led_value", "(", "hw_id", "=", "self", ".", "device_unique_name", ",", "led_name", "=", "'sony{}'", ".", "format", ...
Set front-panel controller LEDs. The DS3 controller has four, labelled, LEDs on the front panel that can be either on or off. :param led_number: Integer between 1 and 4 :param led_value: Value, set to 0 to turn the LED off, 1 to turn it on
[ "Set", "front", "-", "panel", "controller", "LEDs", ".", "The", "DS3", "controller", "has", "four", "labelled", "LEDs", "on", "the", "front", "panel", "that", "can", "be", "either", "on", "or", "off", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/dualshock3.py#L64-L76
ApproxEng/approxeng.input
scripts/tiny4wd_drive.py
mixer
def mixer(yaw, throttle, max_power=100): """ Mix a pair of joystick axes, returning a pair of wheel speeds. This is where the mapping from joystick positions to wheel powers is defined, so any changes to how the robot drives should be made here, everything else is really just plumbing. :param y...
python
def mixer(yaw, throttle, max_power=100): """ Mix a pair of joystick axes, returning a pair of wheel speeds. This is where the mapping from joystick positions to wheel powers is defined, so any changes to how the robot drives should be made here, everything else is really just plumbing. :param y...
[ "def", "mixer", "(", "yaw", ",", "throttle", ",", "max_power", "=", "100", ")", ":", "left", "=", "throttle", "+", "yaw", "right", "=", "throttle", "-", "yaw", "scale", "=", "float", "(", "max_power", ")", "/", "max", "(", "1", ",", "abs", "(", "...
Mix a pair of joystick axes, returning a pair of wheel speeds. This is where the mapping from joystick positions to wheel powers is defined, so any changes to how the robot drives should be made here, everything else is really just plumbing. :param yaw: Yaw axis value, ranges from -1.0 to 1.0 ...
[ "Mix", "a", "pair", "of", "joystick", "axes", "returning", "a", "pair", "of", "wheel", "speeds", ".", "This", "is", "where", "the", "mapping", "from", "joystick", "positions", "to", "wheel", "powers", "is", "defined", "so", "any", "changes", "to", "how", ...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/scripts/tiny4wd_drive.py#L72-L90
alfredodeza/remoto
remoto/util.py
admin_command
def admin_command(sudo, command): """ If sudo is needed, make sure the command is prepended correctly, otherwise return the command as it came. :param sudo: A boolean representing the intention of having a sudo command (or not) :param command: A list of the actual command to execute...
python
def admin_command(sudo, command): """ If sudo is needed, make sure the command is prepended correctly, otherwise return the command as it came. :param sudo: A boolean representing the intention of having a sudo command (or not) :param command: A list of the actual command to execute...
[ "def", "admin_command", "(", "sudo", ",", "command", ")", ":", "if", "sudo", ":", "if", "not", "isinstance", "(", "command", ",", "list", ")", ":", "command", "=", "[", "command", "]", "return", "[", "'sudo'", "]", "+", "[", "cmd", "for", "cmd", "i...
If sudo is needed, make sure the command is prepended correctly, otherwise return the command as it came. :param sudo: A boolean representing the intention of having a sudo command (or not) :param command: A list of the actual command to execute with Popen.
[ "If", "sudo", "is", "needed", "make", "sure", "the", "command", "is", "prepended", "correctly", "otherwise", "return", "the", "command", "as", "it", "came", "." ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/util.py#L3-L16
ApproxEng/approxeng.input
src/python/approxeng/input/sys.py
scan_system
def scan_system(): """ Scans /sys/class/leds looking for entries, then examining their .../device/uevent file to obtain unique hardware IDs corresponding to the associated hardware. This then allows us to associate InputDevice based controllers with sets of zero or more LEDs. The result is a dict from h...
python
def scan_system(): """ Scans /sys/class/leds looking for entries, then examining their .../device/uevent file to obtain unique hardware IDs corresponding to the associated hardware. This then allows us to associate InputDevice based controllers with sets of zero or more LEDs. The result is a dict from h...
[ "def", "scan_system", "(", ")", ":", "def", "find_device_hardware_id", "(", "uevent_file_path", ")", ":", "hid_uniq", "=", "None", "phys", "=", "None", "for", "line", "in", "open", "(", "uevent_file_path", ",", "'r'", ")", ".", "read", "(", ")", ".", "sp...
Scans /sys/class/leds looking for entries, then examining their .../device/uevent file to obtain unique hardware IDs corresponding to the associated hardware. This then allows us to associate InputDevice based controllers with sets of zero or more LEDs. The result is a dict from hardware address to a dict of na...
[ "Scans", "/", "sys", "/", "class", "/", "leds", "looking", "for", "entries", "then", "examining", "their", "...", "/", "device", "/", "uevent", "file", "to", "obtain", "unique", "hardware", "IDs", "corresponding", "to", "the", "associated", "hardware", ".", ...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/sys.py#L46-L102
ApproxEng/approxeng.input
src/python/approxeng/input/selectbinder.py
bind_controllers
def bind_controllers(*discoveries, print_events=False): """ Bind a controller or controllers to a set of evdev InputDevice instances, starting a thread to keep those controllers in sync with the state of the hardware. :param discoveries: ControllerDiscovery instances specifying the controll...
python
def bind_controllers(*discoveries, print_events=False): """ Bind a controller or controllers to a set of evdev InputDevice instances, starting a thread to keep those controllers in sync with the state of the hardware. :param discoveries: ControllerDiscovery instances specifying the controll...
[ "def", "bind_controllers", "(", "*", "discoveries", ",", "print_events", "=", "False", ")", ":", "discoveries", "=", "list", "(", "discoveries", ")", "class", "SelectThread", "(", "Thread", ")", ":", "def", "__init__", "(", "self", ")", ":", "Thread", ".",...
Bind a controller or controllers to a set of evdev InputDevice instances, starting a thread to keep those controllers in sync with the state of the hardware. :param discoveries: ControllerDiscovery instances specifying the controllers and their associated input devices :param print_events: ...
[ "Bind", "a", "controller", "or", "controllers", "to", "a", "set", "of", "evdev", "InputDevice", "instances", "starting", "a", "thread", "to", "keep", "those", "controllers", "in", "sync", "with", "the", "state", "of", "the", "hardware", ".", ":", "param", ...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/selectbinder.py#L58-L146
TadLeonard/tfatool
tfatool/upload.py
_encode_time
def _encode_time(mtime: float): """Encode a mtime float as a 32-bit FAT time""" dt = arrow.get(mtime) dt = dt.to("local") date_val = ((dt.year - 1980) << 9) | (dt.month << 5) | dt.day secs = dt.second + dt.microsecond / 10**6 time_val = (dt.hour << 11) | (dt.minute << 5) | math.floor(secs / 2) ...
python
def _encode_time(mtime: float): """Encode a mtime float as a 32-bit FAT time""" dt = arrow.get(mtime) dt = dt.to("local") date_val = ((dt.year - 1980) << 9) | (dt.month << 5) | dt.day secs = dt.second + dt.microsecond / 10**6 time_val = (dt.hour << 11) | (dt.minute << 5) | math.floor(secs / 2) ...
[ "def", "_encode_time", "(", "mtime", ":", "float", ")", ":", "dt", "=", "arrow", ".", "get", "(", "mtime", ")", "dt", "=", "dt", ".", "to", "(", "\"local\"", ")", "date_val", "=", "(", "(", "dt", ".", "year", "-", "1980", ")", "<<", "9", ")", ...
Encode a mtime float as a 32-bit FAT time
[ "Encode", "a", "mtime", "float", "as", "a", "32", "-", "bit", "FAT", "time" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/upload.py#L84-L91
python-useful-helpers/threaded
threaded/_threadpooled.py
threadpooled
def threadpooled( func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]], *, loop_getter: None = None, loop_getter_need_context: bool = False, ) -> typing.Callable[..., "concurrent.futures.Future[typing.Any]"]: """Overload: function callable, no loop getter."""
python
def threadpooled( func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]], *, loop_getter: None = None, loop_getter_need_context: bool = False, ) -> typing.Callable[..., "concurrent.futures.Future[typing.Any]"]: """Overload: function callable, no loop getter."""
[ "def", "threadpooled", "(", "func", ":", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Union", "[", "\"typing.Awaitable[typing.Any]\"", ",", "typing", ".", "Any", "]", "]", ",", "*", ",", "loop_getter", ":", "None", "=", "None", ",", "loop_...
Overload: function callable, no loop getter.
[ "Overload", ":", "function", "callable", "no", "loop", "getter", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L178-L184
python-useful-helpers/threaded
threaded/_threadpooled.py
threadpooled
def threadpooled( func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]], *, loop_getter: typing.Union[typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop], loop_getter_need_context: bool = False, ) -> typing.Callable[..., "asyncio.Task[typing.Any]"]:...
python
def threadpooled( func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]], *, loop_getter: typing.Union[typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop], loop_getter_need_context: bool = False, ) -> typing.Callable[..., "asyncio.Task[typing.Any]"]:...
[ "def", "threadpooled", "(", "func", ":", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Union", "[", "\"typing.Awaitable[typing.Any]\"", ",", "typing", ".", "Any", "]", "]", ",", "*", ",", "loop_getter", ":", "typing", ".", "Union", "[", "ty...
Overload: function callable, loop getter available.
[ "Overload", ":", "function", "callable", "loop", "getter", "available", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L188-L194
python-useful-helpers/threaded
threaded/_threadpooled.py
threadpooled
def threadpooled( func: None = None, *, loop_getter: typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop] = None, loop_getter_need_context: bool = False, ) -> ThreadPooled: """Overload: No function."""
python
def threadpooled( func: None = None, *, loop_getter: typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop] = None, loop_getter_need_context: bool = False, ) -> ThreadPooled: """Overload: No function."""
[ "def", "threadpooled", "(", "func", ":", "None", "=", "None", ",", "*", ",", "loop_getter", ":", "typing", ".", "Union", "[", "None", ",", "typing", ".", "Callable", "[", "...", ",", "asyncio", ".", "AbstractEventLoop", "]", ",", "asyncio", ".", "Abstr...
Overload: No function.
[ "Overload", ":", "No", "function", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L198-L204
python-useful-helpers/threaded
threaded/_threadpooled.py
threadpooled
def threadpooled( # noqa: F811 func: typing.Optional[typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]]] = None, *, loop_getter: typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop] = None, loop_getter_need_context: bool = False, ) -...
python
def threadpooled( # noqa: F811 func: typing.Optional[typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]]] = None, *, loop_getter: typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop] = None, loop_getter_need_context: bool = False, ) -...
[ "def", "threadpooled", "(", "# noqa: F811", "func", ":", "typing", ".", "Optional", "[", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Union", "[", "\"typing.Awaitable[typing.Any]\"", ",", "typing", ".", "Any", "]", "]", "]", "=", "None", ","...
Post function to ThreadPoolExecutor. :param func: function to wrap :type func: typing.Optional[typing.Callable[..., typing.Union[typing.Awaitable, typing.Any]]] :param loop_getter: Method to get event loop, if wrap in asyncio task :type loop_getter: typing.Union[ None, ...
[ "Post", "function", "to", "ThreadPoolExecutor", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L208-L236
python-useful-helpers/threaded
threaded/_threadpooled.py
ThreadPooled.configure
def configure(cls: typing.Type["ThreadPooled"], max_workers: typing.Optional[int] = None) -> None: """Pool executor create and configure. :param max_workers: Maximum workers :type max_workers: typing.Optional[int] """ if isinstance(cls.__executor, ThreadPoolExecutor): ...
python
def configure(cls: typing.Type["ThreadPooled"], max_workers: typing.Optional[int] = None) -> None: """Pool executor create and configure. :param max_workers: Maximum workers :type max_workers: typing.Optional[int] """ if isinstance(cls.__executor, ThreadPoolExecutor): ...
[ "def", "configure", "(", "cls", ":", "typing", ".", "Type", "[", "\"ThreadPooled\"", "]", ",", "max_workers", ":", "typing", ".", "Optional", "[", "int", "]", "=", "None", ")", "->", "None", ":", "if", "isinstance", "(", "cls", ".", "__executor", ",", ...
Pool executor create and configure. :param max_workers: Maximum workers :type max_workers: typing.Optional[int]
[ "Pool", "executor", "create", "and", "configure", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L40-L51
python-useful-helpers/threaded
threaded/_threadpooled.py
ThreadPooled.executor
def executor(self) -> "ThreadPoolExecutor": """Executor instance. :rtype: ThreadPoolExecutor """ if not isinstance(self.__executor, ThreadPoolExecutor) or self.__executor.is_shutdown: self.configure() return self.__executor
python
def executor(self) -> "ThreadPoolExecutor": """Executor instance. :rtype: ThreadPoolExecutor """ if not isinstance(self.__executor, ThreadPoolExecutor) or self.__executor.is_shutdown: self.configure() return self.__executor
[ "def", "executor", "(", "self", ")", "->", "\"ThreadPoolExecutor\"", ":", "if", "not", "isinstance", "(", "self", ".", "__executor", ",", "ThreadPoolExecutor", ")", "or", "self", ".", "__executor", ".", "is_shutdown", ":", "self", ".", "configure", "(", ")",...
Executor instance. :rtype: ThreadPoolExecutor
[ "Executor", "instance", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L60-L67
python-useful-helpers/threaded
threaded/_threadpooled.py
ThreadPooled.loop_getter
def loop_getter( self ) -> typing.Optional[typing.Union[typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]]: """Loop getter. :rtype: typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop] """ return self.__loop...
python
def loop_getter( self ) -> typing.Optional[typing.Union[typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]]: """Loop getter. :rtype: typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop] """ return self.__loop...
[ "def", "loop_getter", "(", "self", ")", "->", "typing", ".", "Optional", "[", "typing", ".", "Union", "[", "typing", ".", "Callable", "[", "...", ",", "asyncio", ".", "AbstractEventLoop", "]", ",", "asyncio", ".", "AbstractEventLoop", "]", "]", ":", "ret...
Loop getter. :rtype: typing.Union[None, typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop]
[ "Loop", "getter", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L98-L105
python-useful-helpers/threaded
threaded/_threadpooled.py
ThreadPooled._get_loop
def _get_loop(self, *args: typing.Any, **kwargs: typing.Any) -> typing.Optional[asyncio.AbstractEventLoop]: """Get event loop in decorator class.""" if callable(self.loop_getter): if self.loop_getter_need_context: return self.loop_getter(*args, **kwargs) # pylint: disable=no...
python
def _get_loop(self, *args: typing.Any, **kwargs: typing.Any) -> typing.Optional[asyncio.AbstractEventLoop]: """Get event loop in decorator class.""" if callable(self.loop_getter): if self.loop_getter_need_context: return self.loop_getter(*args, **kwargs) # pylint: disable=no...
[ "def", "_get_loop", "(", "self", ",", "*", "args", ":", "typing", ".", "Any", ",", "*", "*", "kwargs", ":", "typing", ".", "Any", ")", "->", "typing", ".", "Optional", "[", "asyncio", ".", "AbstractEventLoop", "]", ":", "if", "callable", "(", "self",...
Get event loop in decorator class.
[ "Get", "event", "loop", "in", "decorator", "class", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L115-L121
python-useful-helpers/threaded
threaded/_threadpooled.py
ThreadPooled._get_function_wrapper
def _get_function_wrapper( self, func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]] ) -> typing.Callable[..., "typing.Union[concurrent.futures.Future[typing.Any], typing.Awaitable[typing.Any]]"]: """Here should be constructed and returned real decorator. :p...
python
def _get_function_wrapper( self, func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]] ) -> typing.Callable[..., "typing.Union[concurrent.futures.Future[typing.Any], typing.Awaitable[typing.Any]]"]: """Here should be constructed and returned real decorator. :p...
[ "def", "_get_function_wrapper", "(", "self", ",", "func", ":", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Union", "[", "\"typing.Awaitable[typing.Any]\"", ",", "typing", ".", "Any", "]", "]", ")", "->", "typing", ".", "Callable", "[", "......
Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable :return: wrapped coroutine or function :rtype: typing.Callable[..., typing.Union[typing.Awaitable, concurrent.futures.Future]]
[ "Here", "should", "be", "constructed", "and", "returned", "real", "decorator", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threadpooled.py#L123-L151
alfredodeza/remoto
remoto/backends/__init__.py
needs_ssh
def needs_ssh(hostname, _socket=None): """ Obtains remote hostname of the socket and cuts off the domain part of its FQDN. """ if hostname.lower() in ['localhost', '127.0.0.1', '127.0.1.1']: return False _socket = _socket or socket fqdn = _socket.getfqdn() if hostname == fqdn: ...
python
def needs_ssh(hostname, _socket=None): """ Obtains remote hostname of the socket and cuts off the domain part of its FQDN. """ if hostname.lower() in ['localhost', '127.0.0.1', '127.0.1.1']: return False _socket = _socket or socket fqdn = _socket.getfqdn() if hostname == fqdn: ...
[ "def", "needs_ssh", "(", "hostname", ",", "_socket", "=", "None", ")", ":", "if", "hostname", ".", "lower", "(", ")", "in", "[", "'localhost'", ",", "'127.0.0.1'", ",", "'127.0.1.1'", "]", ":", "return", "False", "_socket", "=", "_socket", "or", "socket"...
Obtains remote hostname of the socket and cuts off the domain part of its FQDN.
[ "Obtains", "remote", "hostname", "of", "the", "socket", "and", "cuts", "off", "the", "domain", "part", "of", "its", "FQDN", "." ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/backends/__init__.py#L277-L292
alfredodeza/remoto
remoto/backends/__init__.py
get_python_executable
def get_python_executable(conn): """ Try to determine the remote Python version so that it can be used when executing. Avoids the problem of different Python versions, or distros that do not use ``python`` but do ``python3`` """ # executables in order of preference: executables = ['python3',...
python
def get_python_executable(conn): """ Try to determine the remote Python version so that it can be used when executing. Avoids the problem of different Python versions, or distros that do not use ``python`` but do ``python3`` """ # executables in order of preference: executables = ['python3',...
[ "def", "get_python_executable", "(", "conn", ")", ":", "# executables in order of preference:", "executables", "=", "[", "'python3'", ",", "'python'", ",", "'python2.7'", "]", "for", "executable", "in", "executables", ":", "conn", ".", "logger", ".", "debug", "(",...
Try to determine the remote Python version so that it can be used when executing. Avoids the problem of different Python versions, or distros that do not use ``python`` but do ``python3``
[ "Try", "to", "determine", "the", "remote", "Python", "version", "so", "that", "it", "can", "be", "used", "when", "executing", ".", "Avoids", "the", "problem", "of", "different", "Python", "versions", "or", "distros", "that", "do", "not", "use", "python", "...
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/backends/__init__.py#L295-L316
alfredodeza/remoto
remoto/backends/__init__.py
BaseConnection._detect_sudo
def _detect_sudo(self, _execnet=None): """ ``sudo`` detection has to create a different connection to the remote host so that we can reliably ensure that ``getuser()`` will return the right information. After getting the user info it closes the connection and returns a b...
python
def _detect_sudo(self, _execnet=None): """ ``sudo`` detection has to create a different connection to the remote host so that we can reliably ensure that ``getuser()`` will return the right information. After getting the user info it closes the connection and returns a b...
[ "def", "_detect_sudo", "(", "self", ",", "_execnet", "=", "None", ")", ":", "exc", "=", "_execnet", "or", "execnet", "gw", "=", "exc", ".", "makegateway", "(", "self", ".", "_make_connection_string", "(", "self", ".", "hostname", ",", "use_sudo", "=", "F...
``sudo`` detection has to create a different connection to the remote host so that we can reliably ensure that ``getuser()`` will return the right information. After getting the user info it closes the connection and returns a boolean
[ "sudo", "detection", "has", "to", "create", "a", "different", "connection", "to", "the", "remote", "host", "so", "that", "we", "can", "reliably", "ensure", "that", "getuser", "()", "will", "return", "the", "right", "information", "." ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/backends/__init__.py#L49-L73
alfredodeza/remoto
remoto/backends/__init__.py
BaseConnection.import_module
def import_module(self, module): """ Allows remote execution of a local module. Depending on the ``remote_import_system`` attribute it may use execnet's implementation or remoto's own based on JSON. .. note:: It is not possible to use execnet's remote execution model on ...
python
def import_module(self, module): """ Allows remote execution of a local module. Depending on the ``remote_import_system`` attribute it may use execnet's implementation or remoto's own based on JSON. .. note:: It is not possible to use execnet's remote execution model on ...
[ "def", "import_module", "(", "self", ",", "module", ")", ":", "if", "self", ".", "remote_import_system", "is", "not", "None", ":", "if", "self", ".", "remote_import_system", "==", "'json'", ":", "self", ".", "remote_module", "=", "JsonModuleExecute", "(", "s...
Allows remote execution of a local module. Depending on the ``remote_import_system`` attribute it may use execnet's implementation or remoto's own based on JSON. .. note:: It is not possible to use execnet's remote execution model on connections that aren't SSH or Local.
[ "Allows", "remote", "execution", "of", "a", "local", "module", ".", "Depending", "on", "the", "remote_import_system", "attribute", "it", "may", "use", "execnet", "s", "implementation", "or", "remoto", "s", "own", "based", "on", "JSON", "." ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/backends/__init__.py#L114-L130
alfredodeza/remoto
remoto/connection.py
get
def get(name, fallback='ssh'): """ Retrieve the matching backend class from a string. If no backend can be matched, it raises an error. >>> get('ssh') <class 'remoto.backends.BaseConnection'> >>> get() <class 'remoto.backends.BaseConnection'> >>> get('non-existent') <class 'remoto.b...
python
def get(name, fallback='ssh'): """ Retrieve the matching backend class from a string. If no backend can be matched, it raises an error. >>> get('ssh') <class 'remoto.backends.BaseConnection'> >>> get() <class 'remoto.backends.BaseConnection'> >>> get('non-existent') <class 'remoto.b...
[ "def", "get", "(", "name", ",", "fallback", "=", "'ssh'", ")", ":", "mapping", "=", "{", "'ssh'", ":", "ssh", ".", "SshConnection", ",", "'oc'", ":", "openshift", ".", "OpenshiftConnection", ",", "'openshift'", ":", "openshift", ".", "OpenshiftConnection", ...
Retrieve the matching backend class from a string. If no backend can be matched, it raises an error. >>> get('ssh') <class 'remoto.backends.BaseConnection'> >>> get() <class 'remoto.backends.BaseConnection'> >>> get('non-existent') <class 'remoto.backends.BaseConnection'> >>> get('non-e...
[ "Retrieve", "the", "matching", "backend", "class", "from", "a", "string", ".", "If", "no", "backend", "can", "be", "matched", "it", "raises", "an", "error", "." ]
train
https://github.com/alfredodeza/remoto/blob/b7625e571a4b6c83f9589a1e9ad07354e42bf0d3/remoto/connection.py#L10-L48
ApproxEng/approxeng.input
src/python/approxeng/input/dualshock4.py
DualShock4.set_leds
def set_leds(self, hue: float = 0.0, saturation: float = 1.0, value: float = 1.0): """ The DualShock4 has an LED bar on the front of the controller. This function allows you to set the value of this bar. Note that the controller must be connected for this to work, if it's not the call will just ...
python
def set_leds(self, hue: float = 0.0, saturation: float = 1.0, value: float = 1.0): """ The DualShock4 has an LED bar on the front of the controller. This function allows you to set the value of this bar. Note that the controller must be connected for this to work, if it's not the call will just ...
[ "def", "set_leds", "(", "self", ",", "hue", ":", "float", "=", "0.0", ",", "saturation", ":", "float", "=", "1.0", ",", "value", ":", "float", "=", "1.0", ")", ":", "r", ",", "g", ",", "b", "=", "hsv_to_rgb", "(", "hue", ",", "saturation", ",", ...
The DualShock4 has an LED bar on the front of the controller. This function allows you to set the value of this bar. Note that the controller must be connected for this to work, if it's not the call will just be ignored. :param hue: The hue of the colour, defaults to 0, specified as a float...
[ "The", "DualShock4", "has", "an", "LED", "bar", "on", "the", "front", "of", "the", "controller", ".", "This", "function", "allows", "you", "to", "set", "the", "value", "of", "this", "bar", ".", "Note", "that", "the", "controller", "must", "be", "connecte...
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/dualshock4.py#L78-L94
ghickman/django-cache-url
django_cache_url.py
config
def config(env=DEFAULT_ENV, default='locmem://'): """Returns configured CACHES dictionary from CACHE_URL""" config = {} s = os.environ.get(env, default) if s: config = parse(s) return config
python
def config(env=DEFAULT_ENV, default='locmem://'): """Returns configured CACHES dictionary from CACHE_URL""" config = {} s = os.environ.get(env, default) if s: config = parse(s) return config
[ "def", "config", "(", "env", "=", "DEFAULT_ENV", ",", "default", "=", "'locmem://'", ")", ":", "config", "=", "{", "}", "s", "=", "os", ".", "environ", ".", "get", "(", "env", ",", "default", ")", "if", "s", ":", "config", "=", "parse", "(", "s",...
Returns configured CACHES dictionary from CACHE_URL
[ "Returns", "configured", "CACHES", "dictionary", "from", "CACHE_URL" ]
train
https://github.com/ghickman/django-cache-url/blob/aba81916a3e0b6e49007eb514b690bcd2ccca118/django_cache_url.py#L41-L50
ghickman/django-cache-url
django_cache_url.py
parse
def parse(url): """Parses a cache URL.""" config = {} url = urlparse.urlparse(url) # Handle python 2.6 broken url parsing path, query = url.path, url.query if '?' in path and query == '': path, query = path.split('?', 1) cache_args = dict([(key.upper(), ';'.join(val)) for key, val ...
python
def parse(url): """Parses a cache URL.""" config = {} url = urlparse.urlparse(url) # Handle python 2.6 broken url parsing path, query = url.path, url.query if '?' in path and query == '': path, query = path.split('?', 1) cache_args = dict([(key.upper(), ';'.join(val)) for key, val ...
[ "def", "parse", "(", "url", ")", ":", "config", "=", "{", "}", "url", "=", "urlparse", ".", "urlparse", "(", "url", ")", "# Handle python 2.6 broken url parsing", "path", ",", "query", "=", "url", ".", "path", ",", "url", ".", "query", "if", "'?'", "in...
Parses a cache URL.
[ "Parses", "a", "cache", "URL", "." ]
train
https://github.com/ghickman/django-cache-url/blob/aba81916a3e0b6e49007eb514b690bcd2ccca118/django_cache_url.py#L53-L123
TadLeonard/tfatool
tfatool/command.py
memory_changed
def memory_changed(url=URL): """Returns True if memory has been written to, False otherwise""" response = _get(Operation.memory_changed, url) try: return int(response.text) == 1 except ValueError: raise IOError("Likely no FlashAir connection, " "memory changed CGI c...
python
def memory_changed(url=URL): """Returns True if memory has been written to, False otherwise""" response = _get(Operation.memory_changed, url) try: return int(response.text) == 1 except ValueError: raise IOError("Likely no FlashAir connection, " "memory changed CGI c...
[ "def", "memory_changed", "(", "url", "=", "URL", ")", ":", "response", "=", "_get", "(", "Operation", ".", "memory_changed", ",", "url", ")", "try", ":", "return", "int", "(", "response", ".", "text", ")", "==", "1", "except", "ValueError", ":", "raise...
Returns True if memory has been written to, False otherwise
[ "Returns", "True", "if", "memory", "has", "been", "written", "to", "False", "otherwise" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/command.py#L46-L53
TadLeonard/tfatool
tfatool/command.py
_get
def _get(operation: Operation, url=URL, **params): """HTTP GET of the FlashAir command.cgi entrypoint""" prepped_request = _prep_get(operation, url=url, **params) return cgi.send(prepped_request)
python
def _get(operation: Operation, url=URL, **params): """HTTP GET of the FlashAir command.cgi entrypoint""" prepped_request = _prep_get(operation, url=url, **params) return cgi.send(prepped_request)
[ "def", "_get", "(", "operation", ":", "Operation", ",", "url", "=", "URL", ",", "*", "*", "params", ")", ":", "prepped_request", "=", "_prep_get", "(", "operation", ",", "url", "=", "url", ",", "*", "*", "params", ")", "return", "cgi", ".", "send", ...
HTTP GET of the FlashAir command.cgi entrypoint
[ "HTTP", "GET", "of", "the", "FlashAir", "command", ".", "cgi", "entrypoint" ]
train
https://github.com/TadLeonard/tfatool/blob/12da2807b5fb538c5317ef255d846b32ceb174d0/tfatool/command.py#L147-L150
phrase/django-phrase
phrase/templatetags/phrase_i18n.py
do_translate
def do_translate(parser, token): """ This will mark a string for translation and will translate the string for the current language. Usage:: {% trans "this is a test" %} This will mark the string for translation so it will be pulled out by mark-messages.py into the .po files and will...
python
def do_translate(parser, token): """ This will mark a string for translation and will translate the string for the current language. Usage:: {% trans "this is a test" %} This will mark the string for translation so it will be pulled out by mark-messages.py into the .po files and will...
[ "def", "do_translate", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "2", ":", "raise", "TemplateSyntaxError", "(", "\"'%s' takes at least one argument\"", "%", "bits", "[", ...
This will mark a string for translation and will translate the string for the current language. Usage:: {% trans "this is a test" %} This will mark the string for translation so it will be pulled out by mark-messages.py into the .po files and will run the string through the translation engin...
[ "This", "will", "mark", "a", "string", "for", "translation", "and", "will", "translate", "the", "string", "for", "the", "current", "language", ".", "Usage", "::", "{", "%", "trans", "this", "is", "a", "test", "%", "}", "This", "will", "mark", "the", "s...
train
https://github.com/phrase/django-phrase/blob/10dbd53513edd30da3fd6c020bcd7f0a1b7338b9/phrase/templatetags/phrase_i18n.py#L21-L98
python-useful-helpers/threaded
threaded/_asynciotask.py
asynciotask
def asynciotask( func: None = None, *, loop_getter: typing.Union[ typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop ] = asyncio.get_event_loop, loop_getter_need_context: bool = False, ) -> AsyncIOTask: """Overload: no function."""
python
def asynciotask( func: None = None, *, loop_getter: typing.Union[ typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop ] = asyncio.get_event_loop, loop_getter_need_context: bool = False, ) -> AsyncIOTask: """Overload: no function."""
[ "def", "asynciotask", "(", "func", ":", "None", "=", "None", ",", "*", ",", "loop_getter", ":", "typing", ".", "Union", "[", "typing", ".", "Callable", "[", "...", ",", "asyncio", ".", "AbstractEventLoop", "]", ",", "asyncio", ".", "AbstractEventLoop", "...
Overload: no function.
[ "Overload", ":", "no", "function", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_asynciotask.py#L123-L131
python-useful-helpers/threaded
threaded/_asynciotask.py
asynciotask
def asynciotask( # noqa: F811 func: typing.Optional[typing.Callable[..., "typing.Awaitable[typing.Any]"]] = None, *, loop_getter: typing.Union[ typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop ] = asyncio.get_event_loop, loop_getter_need_context: bool = False, ) ->...
python
def asynciotask( # noqa: F811 func: typing.Optional[typing.Callable[..., "typing.Awaitable[typing.Any]"]] = None, *, loop_getter: typing.Union[ typing.Callable[..., asyncio.AbstractEventLoop], asyncio.AbstractEventLoop ] = asyncio.get_event_loop, loop_getter_need_context: bool = False, ) ->...
[ "def", "asynciotask", "(", "# noqa: F811", "func", ":", "typing", ".", "Optional", "[", "typing", ".", "Callable", "[", "...", ",", "\"typing.Awaitable[typing.Any]\"", "]", "]", "=", "None", ",", "*", ",", "loop_getter", ":", "typing", ".", "Union", "[", "...
Wrap function in future and return. :param func: Function to wrap :type func: typing.Optional[typing.Callable[..., typing.Awaitable]] :param loop_getter: Method to get event loop, if wrap in asyncio task :type loop_getter: typing.Union[ typing.Callable[..., asyncio.AbstractEv...
[ "Wrap", "function", "in", "future", "and", "return", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_asynciotask.py#L147-L173
python-useful-helpers/threaded
threaded/_asynciotask.py
AsyncIOTask.get_loop
def get_loop(self, *args, **kwargs): # type: (typing.Any, typing.Any) -> asyncio.AbstractEventLoop """Get event loop in decorator class.""" if callable(self.loop_getter): if self.loop_getter_need_context: return self.loop_getter(*args, **kwargs) # pylint: disable=not-callab...
python
def get_loop(self, *args, **kwargs): # type: (typing.Any, typing.Any) -> asyncio.AbstractEventLoop """Get event loop in decorator class.""" if callable(self.loop_getter): if self.loop_getter_need_context: return self.loop_getter(*args, **kwargs) # pylint: disable=not-callab...
[ "def", "get_loop", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# type: (typing.Any, typing.Any) -> asyncio.AbstractEventLoop", "if", "callable", "(", "self", ".", "loop_getter", ")", ":", "if", "self", ".", "loop_getter_need_context", ":", ...
Get event loop in decorator class.
[ "Get", "event", "loop", "in", "decorator", "class", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_asynciotask.py#L76-L82
python-useful-helpers/threaded
threaded/_asynciotask.py
AsyncIOTask._get_function_wrapper
def _get_function_wrapper( self, func: typing.Callable[..., "typing.Awaitable[typing.Any]"] ) -> typing.Callable[..., "asyncio.Task[typing.Any]"]: """Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[..., typing.Awaitab...
python
def _get_function_wrapper( self, func: typing.Callable[..., "typing.Awaitable[typing.Any]"] ) -> typing.Callable[..., "asyncio.Task[typing.Any]"]: """Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[..., typing.Awaitab...
[ "def", "_get_function_wrapper", "(", "self", ",", "func", ":", "typing", ".", "Callable", "[", "...", ",", "\"typing.Awaitable[typing.Any]\"", "]", ")", "->", "typing", ".", "Callable", "[", "...", ",", "\"asyncio.Task[typing.Any]\"", "]", ":", "# noinspection PyM...
Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[..., typing.Awaitable] :return: wrapper, which will produce asyncio.Task on call with function called inside it :rtype: typing.Callable[..., asyncio.Task]
[ "Here", "should", "be", "constructed", "and", "returned", "real", "decorator", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_asynciotask.py#L84-L100
python-useful-helpers/threaded
threaded/_threaded.py
threaded
def threaded( name: typing.Callable[..., typing.Any], daemon: bool = False, started: bool = False ) -> typing.Callable[..., threading.Thread]: """Overload: Call decorator without arguments."""
python
def threaded( name: typing.Callable[..., typing.Any], daemon: bool = False, started: bool = False ) -> typing.Callable[..., threading.Thread]: """Overload: Call decorator without arguments."""
[ "def", "threaded", "(", "name", ":", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Any", "]", ",", "daemon", ":", "bool", "=", "False", ",", "started", ":", "bool", "=", "False", ")", "->", "typing", ".", "Callable", "[", "...", ",", ...
Overload: Call decorator without arguments.
[ "Overload", ":", "Call", "decorator", "without", "arguments", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threaded.py#L130-L133
python-useful-helpers/threaded
threaded/_threaded.py
threaded
def threaded( # noqa: F811 name: typing.Optional[typing.Union[str, typing.Callable[..., typing.Any]]] = None, daemon: bool = False, started: bool = False, ) -> typing.Union[Threaded, typing.Callable[..., threading.Thread]]: """Run function in separate thread. :param name: New thread name. ...
python
def threaded( # noqa: F811 name: typing.Optional[typing.Union[str, typing.Callable[..., typing.Any]]] = None, daemon: bool = False, started: bool = False, ) -> typing.Union[Threaded, typing.Callable[..., threading.Thread]]: """Run function in separate thread. :param name: New thread name. ...
[ "def", "threaded", "(", "# noqa: F811", "name", ":", "typing", ".", "Optional", "[", "typing", ".", "Union", "[", "str", ",", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Any", "]", "]", "]", "=", "None", ",", "daemon", ":", "bool", ...
Run function in separate thread. :param name: New thread name. If callable: use as wrapped function. If none: use wrapped function name. :type name: typing.Union[None, str, typing.Callable] :param daemon: Daemonize thread. :type daemon: bool :param started: Return ...
[ "Run", "function", "in", "separate", "thread", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threaded.py#L142-L163
python-useful-helpers/threaded
threaded/_threaded.py
Threaded._get_function_wrapper
def _get_function_wrapper( self, func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]] ) -> typing.Callable[..., threading.Thread]: """Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[......
python
def _get_function_wrapper( self, func: typing.Callable[..., typing.Union["typing.Awaitable[typing.Any]", typing.Any]] ) -> typing.Callable[..., threading.Thread]: """Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[......
[ "def", "_get_function_wrapper", "(", "self", ",", "func", ":", "typing", ".", "Callable", "[", "...", ",", "typing", ".", "Union", "[", "\"typing.Awaitable[typing.Any]\"", ",", "typing", ".", "Any", "]", "]", ")", "->", "typing", ".", "Callable", "[", "......
Here should be constructed and returned real decorator. :param func: Wrapped function :type func: typing.Callable[..., typing.Union[typing.Awaitable, typing.Any]] :return: wrapped function :rtype: typing.Callable[..., threading.Thread]
[ "Here", "should", "be", "constructed", "and", "returned", "real", "decorator", "." ]
train
https://github.com/python-useful-helpers/threaded/blob/c1aa5a631ab3e2904b915ed6c6a8be03a9673a1a/threaded/_threaded.py#L94-L117
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPRequestBuilder.issuer
def issuer(self, value): """ An asn1crypto.x509.Certificate or oscrypto.asymmetric.Certificate object of the issuer. """ is_oscrypto = isinstance(value, asymmetric.Certificate) if not is_oscrypto and not isinstance(value, x509.Certificate): raise TypeError(_p...
python
def issuer(self, value): """ An asn1crypto.x509.Certificate or oscrypto.asymmetric.Certificate object of the issuer. """ is_oscrypto = isinstance(value, asymmetric.Certificate) if not is_oscrypto and not isinstance(value, x509.Certificate): raise TypeError(_p...
[ "def", "issuer", "(", "self", ",", "value", ")", ":", "is_oscrypto", "=", "isinstance", "(", "value", ",", "asymmetric", ".", "Certificate", ")", "if", "not", "is_oscrypto", "and", "not", "isinstance", "(", "value", ",", "x509", ".", "Certificate", ")", ...
An asn1crypto.x509.Certificate or oscrypto.asymmetric.Certificate object of the issuer.
[ "An", "asn1crypto", ".", "x509", ".", "Certificate", "or", "oscrypto", ".", "asymmetric", ".", "Certificate", "object", "of", "the", "issuer", "." ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L95-L114
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPRequestBuilder.key_hash_algo
def key_hash_algo(self, value): """ A unicode string of the hash algorithm to use when creating the certificate identifier - "sha1" (default), or "sha256". """ if value not in set(['sha1', 'sha256']): raise ValueError(_pretty_message( ''' ...
python
def key_hash_algo(self, value): """ A unicode string of the hash algorithm to use when creating the certificate identifier - "sha1" (default), or "sha256". """ if value not in set(['sha1', 'sha256']): raise ValueError(_pretty_message( ''' ...
[ "def", "key_hash_algo", "(", "self", ",", "value", ")", ":", "if", "value", "not", "in", "set", "(", "[", "'sha1'", ",", "'sha256'", "]", ")", ":", "raise", "ValueError", "(", "_pretty_message", "(", "'''\n hash_algo must be one of \"sha1\", \"sha25...
A unicode string of the hash algorithm to use when creating the certificate identifier - "sha1" (default), or "sha256".
[ "A", "unicode", "string", "of", "the", "hash", "algorithm", "to", "use", "when", "creating", "the", "certificate", "identifier", "-", "sha1", "(", "default", ")", "or", "sha256", "." ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L134-L148
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPRequestBuilder.nonce
def nonce(self, value): """ A bool - if the nonce extension should be used to prevent replay attacks. """ if not isinstance(value, bool): raise TypeError(_pretty_message( ''' nonce must be a boolean, not %s ''', ...
python
def nonce(self, value): """ A bool - if the nonce extension should be used to prevent replay attacks. """ if not isinstance(value, bool): raise TypeError(_pretty_message( ''' nonce must be a boolean, not %s ''', ...
[ "def", "nonce", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "bool", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n nonce must be a boolean, not %s\n '''", ",", "_type_name", "(...
A bool - if the nonce extension should be used to prevent replay attacks.
[ "A", "bool", "-", "if", "the", "nonce", "extension", "should", "be", "used", "to", "prevent", "replay", "attacks", "." ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L151-L165
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPRequestBuilder.set_extension
def set_extension(self, name, value): """ Sets the value for an extension using a fully constructed asn1crypto.core.Asn1Value object. Normally this should not be needed, and the convenience attributes should be sufficient. See the definition of asn1crypto.ocsp.TBSRequestExtensio...
python
def set_extension(self, name, value): """ Sets the value for an extension using a fully constructed asn1crypto.core.Asn1Value object. Normally this should not be needed, and the convenience attributes should be sufficient. See the definition of asn1crypto.ocsp.TBSRequestExtensio...
[ "def", "set_extension", "(", "self", ",", "name", ",", "value", ")", ":", "if", "isinstance", "(", "name", ",", "str_cls", ")", ":", "request_extension_oids", "=", "set", "(", "[", "'service_locator'", ",", "'1.3.6.1.5.5.7.48.1.7'", "]", ")", "tbs_request_exte...
Sets the value for an extension using a fully constructed asn1crypto.core.Asn1Value object. Normally this should not be needed, and the convenience attributes should be sufficient. See the definition of asn1crypto.ocsp.TBSRequestExtension and asn1crypto.ocsp.RequestExtension to determin...
[ "Sets", "the", "value", "for", "an", "extension", "using", "a", "fully", "constructed", "asn1crypto", ".", "core", ".", "Asn1Value", "object", ".", "Normally", "this", "should", "not", "be", "needed", "and", "the", "convenience", "attributes", "should", "be", ...
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L167-L259
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPRequestBuilder.build
def build(self, requestor_private_key=None, requestor_certificate=None, other_certificates=None): """ Validates the request information, constructs the ASN.1 structure and then optionally signs it. The requestor_private_key, requestor_certificate and other_certificates params ar...
python
def build(self, requestor_private_key=None, requestor_certificate=None, other_certificates=None): """ Validates the request information, constructs the ASN.1 structure and then optionally signs it. The requestor_private_key, requestor_certificate and other_certificates params ar...
[ "def", "build", "(", "self", ",", "requestor_private_key", "=", "None", ",", "requestor_certificate", "=", "None", ",", "other_certificates", "=", "None", ")", ":", "def", "_make_extension", "(", "name", ",", "value", ")", ":", "return", "{", "'extn_id'", ":...
Validates the request information, constructs the ASN.1 structure and then optionally signs it. The requestor_private_key, requestor_certificate and other_certificates params are all optional and only necessary if the request needs to be signed. Signing a request is uncommon for OCSP re...
[ "Validates", "the", "request", "information", "constructs", "the", "ASN", ".", "1", "structure", "and", "then", "optionally", "signs", "it", "." ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L261-L420
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.response_status
def response_status(self, value): """ The overall status of the response. Only a "successful" response will include information about the certificate. Other response types are for signaling info about the OCSP responder. Valid values include: - "successful" - when the response ...
python
def response_status(self, value): """ The overall status of the response. Only a "successful" response will include information about the certificate. Other response types are for signaling info about the OCSP responder. Valid values include: - "successful" - when the response ...
[ "def", "response_status", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "str_cls", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n response_status must be a unicode string, not %s\n '''...
The overall status of the response. Only a "successful" response will include information about the certificate. Other response types are for signaling info about the OCSP responder. Valid values include: - "successful" - when the response includes information about the certificate - ...
[ "The", "overall", "status", "of", "the", "response", ".", "Only", "a", "successful", "response", "will", "include", "information", "about", "the", "certificate", ".", "Other", "response", "types", "are", "for", "signaling", "info", "about", "the", "OCSP", "res...
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L491-L531
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.certificate
def certificate(self, value): """ An asn1crypto.x509.Certificate or oscrypto.asymmetric.Certificate object of the certificate the response is about. """ if value is not None: is_oscrypto = isinstance(value, asymmetric.Certificate) if not is_oscrypto and n...
python
def certificate(self, value): """ An asn1crypto.x509.Certificate or oscrypto.asymmetric.Certificate object of the certificate the response is about. """ if value is not None: is_oscrypto = isinstance(value, asymmetric.Certificate) if not is_oscrypto and n...
[ "def", "certificate", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "is_oscrypto", "=", "isinstance", "(", "value", ",", "asymmetric", ".", "Certificate", ")", "if", "not", "is_oscrypto", "and", "not", "isinstance", "(", "...
An asn1crypto.x509.Certificate or oscrypto.asymmetric.Certificate object of the certificate the response is about.
[ "An", "asn1crypto", ".", "x509", ".", "Certificate", "or", "oscrypto", ".", "asymmetric", ".", "Certificate", "object", "of", "the", "certificate", "the", "response", "is", "about", "." ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L534-L554
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.certificate_status
def certificate_status(self, value): """ A unicode string of the status of the certificate. Valid values include: - "good" - when the certificate is in good standing - "revoked" - when the certificate is revoked without a reason code - "key_compromise" - when a private key is...
python
def certificate_status(self, value): """ A unicode string of the status of the certificate. Valid values include: - "good" - when the certificate is in good standing - "revoked" - when the certificate is revoked without a reason code - "key_compromise" - when a private key is...
[ "def", "certificate_status", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "if", "not", "isinstance", "(", "value", ",", "str_cls", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n certifica...
A unicode string of the status of the certificate. Valid values include: - "good" - when the certificate is in good standing - "revoked" - when the certificate is revoked without a reason code - "key_compromise" - when a private key is compromised - "ca_compromise" - when the CA iss...
[ "A", "unicode", "string", "of", "the", "status", "of", "the", "certificate", ".", "Valid", "values", "include", ":" ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L557-L607
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.revocation_date
def revocation_date(self, value): """ A datetime.datetime object of when the certificate was revoked, if the status is not "good" or "unknown". """ if value is not None and not isinstance(value, datetime): raise TypeError(_pretty_message( ''' ...
python
def revocation_date(self, value): """ A datetime.datetime object of when the certificate was revoked, if the status is not "good" or "unknown". """ if value is not None and not isinstance(value, datetime): raise TypeError(_pretty_message( ''' ...
[ "def", "revocation_date", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", "and", "not", "isinstance", "(", "value", ",", "datetime", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n revocation_date must ...
A datetime.datetime object of when the certificate was revoked, if the status is not "good" or "unknown".
[ "A", "datetime", ".", "datetime", "object", "of", "when", "the", "certificate", "was", "revoked", "if", "the", "status", "is", "not", "good", "or", "unknown", "." ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L610-L624
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.certificate_issuer
def certificate_issuer(self, value): """ An asn1crypto.x509.Certificate object of the issuer of the certificate. This should only be set if the OCSP responder is not the issuer of the certificate, but instead a special certificate only for OCSP responses. """ if ...
python
def certificate_issuer(self, value): """ An asn1crypto.x509.Certificate object of the issuer of the certificate. This should only be set if the OCSP responder is not the issuer of the certificate, but instead a special certificate only for OCSP responses. """ if ...
[ "def", "certificate_issuer", "(", "self", ",", "value", ")", ":", "if", "value", "is", "not", "None", ":", "is_oscrypto", "=", "isinstance", "(", "value", ",", "asymmetric", ".", "Certificate", ")", "if", "not", "is_oscrypto", "and", "not", "isinstance", "...
An asn1crypto.x509.Certificate object of the issuer of the certificate. This should only be set if the OCSP responder is not the issuer of the certificate, but instead a special certificate only for OCSP responses.
[ "An", "asn1crypto", ".", "x509", ".", "Certificate", "object", "of", "the", "issuer", "of", "the", "certificate", ".", "This", "should", "only", "be", "set", "if", "the", "OCSP", "responder", "is", "not", "the", "issuer", "of", "the", "certificate", "but",...
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L627-L650
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.this_update
def this_update(self, value): """ A datetime.datetime object of when the response was generated. """ if not isinstance(value, datetime): raise TypeError(_pretty_message( ''' this_update must be an instance of datetime.datetime, not %s ...
python
def this_update(self, value): """ A datetime.datetime object of when the response was generated. """ if not isinstance(value, datetime): raise TypeError(_pretty_message( ''' this_update must be an instance of datetime.datetime, not %s ...
[ "def", "this_update", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "datetime", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n this_update must be an instance of datetime.datetime, not %s\n ...
A datetime.datetime object of when the response was generated.
[ "A", "datetime", ".", "datetime", "object", "of", "when", "the", "response", "was", "generated", "." ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L703-L716
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.next_update
def next_update(self, value): """ A datetime.datetime object of when the response may next change. This should only be set if responses are cached. If responses are generated fresh on every request, this should not be set. """ if not isinstance(value, datetime): ...
python
def next_update(self, value): """ A datetime.datetime object of when the response may next change. This should only be set if responses are cached. If responses are generated fresh on every request, this should not be set. """ if not isinstance(value, datetime): ...
[ "def", "next_update", "(", "self", ",", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "datetime", ")", ":", "raise", "TypeError", "(", "_pretty_message", "(", "'''\n next_update must be an instance of datetime.datetime, not %s\n ...
A datetime.datetime object of when the response may next change. This should only be set if responses are cached. If responses are generated fresh on every request, this should not be set.
[ "A", "datetime", ".", "datetime", "object", "of", "when", "the", "response", "may", "next", "change", ".", "This", "should", "only", "be", "set", "if", "responses", "are", "cached", ".", "If", "responses", "are", "generated", "fresh", "on", "every", "reque...
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L719-L734
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.set_extension
def set_extension(self, name, value): """ Sets the value for an extension using a fully constructed asn1crypto.core.Asn1Value object. Normally this should not be needed, and the convenience attributes should be sufficient. See the definition of asn1crypto.ocsp.SingleResponseExte...
python
def set_extension(self, name, value): """ Sets the value for an extension using a fully constructed asn1crypto.core.Asn1Value object. Normally this should not be needed, and the convenience attributes should be sufficient. See the definition of asn1crypto.ocsp.SingleResponseExte...
[ "def", "set_extension", "(", "self", ",", "name", ",", "value", ")", ":", "if", "isinstance", "(", "name", ",", "str_cls", ")", ":", "response_data_extension_oids", "=", "set", "(", "[", "'nonce'", ",", "'extended_revoke'", ",", "'1.3.6.1.5.5.7.48.1.2'", ",", ...
Sets the value for an extension using a fully constructed asn1crypto.core.Asn1Value object. Normally this should not be needed, and the convenience attributes should be sufficient. See the definition of asn1crypto.ocsp.SingleResponseExtension and asn1crypto.ocsp.ResponseDataExtension to...
[ "Sets", "the", "value", "for", "an", "extension", "using", "a", "fully", "constructed", "asn1crypto", ".", "core", ".", "Asn1Value", "object", ".", "Normally", "this", "should", "not", "be", "needed", "and", "the", "convenience", "attributes", "should", "be", ...
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L736-L860
wbond/ocspbuilder
ocspbuilder/__init__.py
OCSPResponseBuilder.build
def build(self, responder_private_key=None, responder_certificate=None): """ Validates the request information, constructs the ASN.1 structure and signs it. The responder_private_key and responder_certificate parameters are only required if the response_status is "successful". ...
python
def build(self, responder_private_key=None, responder_certificate=None): """ Validates the request information, constructs the ASN.1 structure and signs it. The responder_private_key and responder_certificate parameters are only required if the response_status is "successful". ...
[ "def", "build", "(", "self", ",", "responder_private_key", "=", "None", ",", "responder_certificate", "=", "None", ")", ":", "if", "self", ".", "_response_status", "!=", "'successful'", ":", "return", "ocsp", ".", "OCSPResponse", "(", "{", "'response_status'", ...
Validates the request information, constructs the ASN.1 structure and signs it. The responder_private_key and responder_certificate parameters are only required if the response_status is "successful". :param responder_private_key: An asn1crypto.keys.PrivateKeyInfo or oscryp...
[ "Validates", "the", "request", "information", "constructs", "the", "ASN", ".", "1", "structure", "and", "signs", "it", "." ]
train
https://github.com/wbond/ocspbuilder/blob/0b853af4ed6bf8bded1ddf235e9e64ea78708456/ocspbuilder/__init__.py#L862-L1060
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/oidc/__init__.py
make_openid_request
def make_openid_request(arq, keys, issuer, request_object_signing_alg, recv): """ Construct the JWT to be passed by value (the request parameter) or by reference (request_uri). The request will be signed :param arq: The Authorization request :param keys: Keys to use for signing/encrypting. A Ke...
python
def make_openid_request(arq, keys, issuer, request_object_signing_alg, recv): """ Construct the JWT to be passed by value (the request parameter) or by reference (request_uri). The request will be signed :param arq: The Authorization request :param keys: Keys to use for signing/encrypting. A Ke...
[ "def", "make_openid_request", "(", "arq", ",", "keys", ",", "issuer", ",", "request_object_signing_alg", ",", "recv", ")", ":", "_jwt", "=", "JWT", "(", "key_jar", "=", "keys", ",", "iss", "=", "issuer", ",", "sign_alg", "=", "request_object_signing_alg", ")...
Construct the JWT to be passed by value (the request parameter) or by reference (request_uri). The request will be signed :param arq: The Authorization request :param keys: Keys to use for signing/encrypting. A KeyJar instance :param issuer: Who is signing this JSON Web Token :param request_obj...
[ "Construct", "the", "JWT", "to", "be", "passed", "by", "value", "(", "the", "request", "parameter", ")", "or", "by", "reference", "(", "request_uri", ")", ".", "The", "request", "will", "be", "signed" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/oidc/__init__.py#L1175-L1190
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/oidc/__init__.py
AuthorizationRequest.verify
def verify(self, **kwargs): """Authorization Request parameters that are OPTIONAL in the OAuth 2.0 specification MAY be included in the OpenID Request Object without also passing them as OAuth 2.0 Authorization Request parameters, with one exception: The scope parameter MUST always be pr...
python
def verify(self, **kwargs): """Authorization Request parameters that are OPTIONAL in the OAuth 2.0 specification MAY be included in the OpenID Request Object without also passing them as OAuth 2.0 Authorization Request parameters, with one exception: The scope parameter MUST always be pr...
[ "def", "verify", "(", "self", ",", "*", "*", "kwargs", ")", ":", "super", "(", "AuthorizationRequest", ",", "self", ")", ".", "verify", "(", "*", "*", "kwargs", ")", "clear_verified_claims", "(", "self", ")", "args", "=", "{", "}", "for", "arg", "in"...
Authorization Request parameters that are OPTIONAL in the OAuth 2.0 specification MAY be included in the OpenID Request Object without also passing them as OAuth 2.0 Authorization Request parameters, with one exception: The scope parameter MUST always be present in OAuth 2.0 Authorizatio...
[ "Authorization", "Request", "parameters", "that", "are", "OPTIONAL", "in", "the", "OAuth", "2", ".", "0", "specification", "MAY", "be", "included", "in", "the", "OpenID", "Request", "Object", "without", "also", "passing", "them", "as", "OAuth", "2", ".", "0"...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/oidc/__init__.py#L429-L509
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/oidc/__init__.py
RegistrationResponse.verify
def verify(self, **kwargs): """ Implementations MUST either return both a Client Configuration Endpoint and a Registration Access Token or neither of them. :param kwargs: :return: True if the message is OK otherwise False """ super(RegistrationResponse, self).veri...
python
def verify(self, **kwargs): """ Implementations MUST either return both a Client Configuration Endpoint and a Registration Access Token or neither of them. :param kwargs: :return: True if the message is OK otherwise False """ super(RegistrationResponse, self).veri...
[ "def", "verify", "(", "self", ",", "*", "*", "kwargs", ")", ":", "super", "(", "RegistrationResponse", ",", "self", ")", ".", "verify", "(", "*", "*", "kwargs", ")", "has_reg_uri", "=", "\"registration_client_uri\"", "in", "self", "has_reg_at", "=", "\"reg...
Implementations MUST either return both a Client Configuration Endpoint and a Registration Access Token or neither of them. :param kwargs: :return: True if the message is OK otherwise False
[ "Implementations", "MUST", "either", "return", "both", "a", "Client", "Configuration", "Endpoint", "and", "a", "Registration", "Access", "Token", "or", "neither", "of", "them", ".", ":", "param", "kwargs", ":", ":", "return", ":", "True", "if", "the", "messa...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/oidc/__init__.py#L677-L693
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/time_util.py
in_a_while
def in_a_while(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0, time_format=TIME_FORMAT): """ :param days: :param seconds: :param microseconds: :param milliseconds: :param minutes: :param hours: :param weeks: :param time_format: :retu...
python
def in_a_while(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0, time_format=TIME_FORMAT): """ :param days: :param seconds: :param microseconds: :param milliseconds: :param minutes: :param hours: :param weeks: :param time_format: :retu...
[ "def", "in_a_while", "(", "days", "=", "0", ",", "seconds", "=", "0", ",", "microseconds", "=", "0", ",", "milliseconds", "=", "0", ",", "minutes", "=", "0", ",", "hours", "=", "0", ",", "weeks", "=", "0", ",", "time_format", "=", "TIME_FORMAT", ")...
:param days: :param seconds: :param microseconds: :param milliseconds: :param minutes: :param hours: :param weeks: :param time_format: :return: Formatet string
[ ":", "param", "days", ":", ":", "param", "seconds", ":", ":", "param", "microseconds", ":", ":", "param", "milliseconds", ":", ":", "param", "minutes", ":", ":", "param", "hours", ":", ":", "param", "weeks", ":", ":", "param", "time_format", ":", ":", ...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/time_util.py#L208-L225
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/time_util.py
before
def before(point): """ True if point datetime specification is before now """ if not point: return True if isinstance(point, str): point = str_to_time(point) elif isinstance(point, int): point = time.gmtime(point) return time.gmtime() < point
python
def before(point): """ True if point datetime specification is before now """ if not point: return True if isinstance(point, str): point = str_to_time(point) elif isinstance(point, int): point = time.gmtime(point) return time.gmtime() < point
[ "def", "before", "(", "point", ")", ":", "if", "not", "point", ":", "return", "True", "if", "isinstance", "(", "point", ",", "str", ")", ":", "point", "=", "str_to_time", "(", "point", ")", "elif", "isinstance", "(", "point", ",", "int", ")", ":", ...
True if point datetime specification is before now
[ "True", "if", "point", "datetime", "specification", "is", "before", "now" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/time_util.py#L291-L301
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/time_util.py
later_than
def later_than(after, before): """ True if then is later or equal to that """ if isinstance(after, str): after = str_to_time(after) elif isinstance(after, int): after = time.gmtime(after) if isinstance(before, str): before = str_to_time(before) elif isinstance(before, int): ...
python
def later_than(after, before): """ True if then is later or equal to that """ if isinstance(after, str): after = str_to_time(after) elif isinstance(after, int): after = time.gmtime(after) if isinstance(before, str): before = str_to_time(before) elif isinstance(before, int): ...
[ "def", "later_than", "(", "after", ",", "before", ")", ":", "if", "isinstance", "(", "after", ",", "str", ")", ":", "after", "=", "str_to_time", "(", "after", ")", "elif", "isinstance", "(", "after", ",", "int", ")", ":", "after", "=", "time", ".", ...
True if then is later or equal to that
[ "True", "if", "then", "is", "later", "or", "equal", "to", "that" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/time_util.py#L322-L334
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/time_util.py
epoch_in_a_while
def epoch_in_a_while(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0): """ Return the number of seconds since epoch a while from now. :param days: :param seconds: :param microseconds: :param milliseconds: :param minutes: :param hours: ...
python
def epoch_in_a_while(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0): """ Return the number of seconds since epoch a while from now. :param days: :param seconds: :param microseconds: :param milliseconds: :param minutes: :param hours: ...
[ "def", "epoch_in_a_while", "(", "days", "=", "0", ",", "seconds", "=", "0", ",", "microseconds", "=", "0", ",", "milliseconds", "=", "0", ",", "minutes", "=", "0", ",", "hours", "=", "0", ",", "weeks", "=", "0", ")", ":", "dt", "=", "time_in_a_whil...
Return the number of seconds since epoch a while from now. :param days: :param seconds: :param microseconds: :param milliseconds: :param minutes: :param hours: :param weeks: :return: Seconds since epoch (1970-01-01)
[ "Return", "the", "number", "of", "seconds", "since", "epoch", "a", "while", "from", "now", "." ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/time_util.py#L345-L362
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.set_defaults
def set_defaults(self): """ Based on specification set a parameters value to the default value. """ for key, val in self.c_default.items(): self._dict[key] = val
python
def set_defaults(self): """ Based on specification set a parameters value to the default value. """ for key, val in self.c_default.items(): self._dict[key] = val
[ "def", "set_defaults", "(", "self", ")", ":", "for", "key", ",", "val", "in", "self", ".", "c_default", ".", "items", "(", ")", ":", "self", ".", "_dict", "[", "key", "]", "=", "val" ]
Based on specification set a parameters value to the default value.
[ "Based", "on", "specification", "set", "a", "parameters", "value", "to", "the", "default", "value", "." ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L72-L77
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.to_urlencoded
def to_urlencoded(self, lev=0): """ Creates a string using the application/x-www-form-urlencoded format :return: A string of the application/x-www-form-urlencoded format """ _spec = self.c_param if not self.lax: for attribute, (_, req, _ser, _, na) in _spec....
python
def to_urlencoded(self, lev=0): """ Creates a string using the application/x-www-form-urlencoded format :return: A string of the application/x-www-form-urlencoded format """ _spec = self.c_param if not self.lax: for attribute, (_, req, _ser, _, na) in _spec....
[ "def", "to_urlencoded", "(", "self", ",", "lev", "=", "0", ")", ":", "_spec", "=", "self", ".", "c_param", "if", "not", "self", ".", "lax", ":", "for", "attribute", ",", "(", "_", ",", "req", ",", "_ser", ",", "_", ",", "na", ")", "in", "_spec"...
Creates a string using the application/x-www-form-urlencoded format :return: A string of the application/x-www-form-urlencoded format
[ "Creates", "a", "string", "using", "the", "application", "/", "x", "-", "www", "-", "form", "-", "urlencoded", "format" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L79-L144
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.serialize
def serialize(self, method="urlencoded", lev=0, **kwargs): """ Convert this instance to another representation. Which representation is given by the choice of serialization method. :param method: A serialization method. Presently 'urlencoded', 'json', 'jwt' and 'dic...
python
def serialize(self, method="urlencoded", lev=0, **kwargs): """ Convert this instance to another representation. Which representation is given by the choice of serialization method. :param method: A serialization method. Presently 'urlencoded', 'json', 'jwt' and 'dic...
[ "def", "serialize", "(", "self", ",", "method", "=", "\"urlencoded\"", ",", "lev", "=", "0", ",", "*", "*", "kwargs", ")", ":", "return", "getattr", "(", "self", ",", "\"to_%s\"", "%", "method", ")", "(", "lev", "=", "lev", ",", "*", "*", "kwargs",...
Convert this instance to another representation. Which representation is given by the choice of serialization method. :param method: A serialization method. Presently 'urlencoded', 'json', 'jwt' and 'dict' is supported. :param lev: :param kwargs: Extra key word arg...
[ "Convert", "this", "instance", "to", "another", "representation", ".", "Which", "representation", "is", "given", "by", "the", "choice", "of", "serialization", "method", ".", ":", "param", "method", ":", "A", "serialization", "method", ".", "Presently", "urlencod...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L146-L157
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.deserialize
def deserialize(self, info, method="urlencoded", **kwargs): """ Convert from an external representation to an internal. :param info: The input :param method: The method used to deserialize the info :param kwargs: extra Keyword arguments :return: In the normal c...
python
def deserialize(self, info, method="urlencoded", **kwargs): """ Convert from an external representation to an internal. :param info: The input :param method: The method used to deserialize the info :param kwargs: extra Keyword arguments :return: In the normal c...
[ "def", "deserialize", "(", "self", ",", "info", ",", "method", "=", "\"urlencoded\"", ",", "*", "*", "kwargs", ")", ":", "try", ":", "func", "=", "getattr", "(", "self", ",", "\"from_%s\"", "%", "method", ")", "except", "AttributeError", ":", "raise", ...
Convert from an external representation to an internal. :param info: The input :param method: The method used to deserialize the info :param kwargs: extra Keyword arguments :return: In the normal case the Message instance
[ "Convert", "from", "an", "external", "representation", "to", "an", "internal", ".", ":", "param", "info", ":", "The", "input", ":", "param", "method", ":", "The", "method", "used", "to", "deserialize", "the", "info", ":", "param", "kwargs", ":", "extra", ...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L159-L173
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.from_urlencoded
def from_urlencoded(self, urlencoded, **kwargs): """ Starting with a string of the application/x-www-form-urlencoded format this method creates a class instance :param urlencoded: The string :return: A class instance or raise an exception on error """ # parse_q...
python
def from_urlencoded(self, urlencoded, **kwargs): """ Starting with a string of the application/x-www-form-urlencoded format this method creates a class instance :param urlencoded: The string :return: A class instance or raise an exception on error """ # parse_q...
[ "def", "from_urlencoded", "(", "self", ",", "urlencoded", ",", "*", "*", "kwargs", ")", ":", "# parse_qs returns a dictionary with keys and values. The values are", "# always lists even if there is only one value in the list.", "# keys only appears once.", "if", "isinstance", "(", ...
Starting with a string of the application/x-www-form-urlencoded format this method creates a class instance :param urlencoded: The string :return: A class instance or raise an exception on error
[ "Starting", "with", "a", "string", "of", "the", "application", "/", "x", "-", "www", "-", "form", "-", "urlencoded", "format", "this", "method", "creates", "a", "class", "instance" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L175-L232
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.to_dict
def to_dict(self, lev=0): """ Return a dictionary representation of the class :return: A dict """ _spec = self.c_param _res = {} lev += 1 for key, val in self._dict.items(): try: (_, req, _ser, _, null_allowed) = _spec[str(ke...
python
def to_dict(self, lev=0): """ Return a dictionary representation of the class :return: A dict """ _spec = self.c_param _res = {} lev += 1 for key, val in self._dict.items(): try: (_, req, _ser, _, null_allowed) = _spec[str(ke...
[ "def", "to_dict", "(", "self", ",", "lev", "=", "0", ")", ":", "_spec", "=", "self", ".", "c_param", "_res", "=", "{", "}", "lev", "+=", "1", "for", "key", ",", "val", "in", "self", ".", "_dict", ".", "items", "(", ")", ":", "try", ":", "(", ...
Return a dictionary representation of the class :return: A dict
[ "Return", "a", "dictionary", "representation", "of", "the", "class" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L234-L269
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.from_dict
def from_dict(self, dictionary, **kwargs): """ Direct translation, so the value for one key might be a list or a single value. :param dictionary: The info :return: A class instance or raise an exception on error """ _spec = self.c_param for key, val in ...
python
def from_dict(self, dictionary, **kwargs): """ Direct translation, so the value for one key might be a list or a single value. :param dictionary: The info :return: A class instance or raise an exception on error """ _spec = self.c_param for key, val in ...
[ "def", "from_dict", "(", "self", ",", "dictionary", ",", "*", "*", "kwargs", ")", ":", "_spec", "=", "self", ".", "c_param", "for", "key", ",", "val", "in", "dictionary", ".", "items", "(", ")", ":", "# Earlier versions of python don't like unicode strings as"...
Direct translation, so the value for one key might be a list or a single value. :param dictionary: The info :return: A class instance or raise an exception on error
[ "Direct", "translation", "so", "the", "value", "for", "one", "key", "might", "be", "a", "list", "or", "a", "single", "value", "." ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L271-L318
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message._add_value
def _add_value(self, skey, vtyp, key, val, _deser, null_allowed): """ Main method for adding a value to the instance. Does all the checking on type of value and if among allowed values. :param skey: string version of the key :param vtyp: Type of value :param key...
python
def _add_value(self, skey, vtyp, key, val, _deser, null_allowed): """ Main method for adding a value to the instance. Does all the checking on type of value and if among allowed values. :param skey: string version of the key :param vtyp: Type of value :param key...
[ "def", "_add_value", "(", "self", ",", "skey", ",", "vtyp", ",", "key", ",", "val", ",", "_deser", ",", "null_allowed", ")", ":", "if", "isinstance", "(", "val", ",", "list", ")", ":", "if", "(", "len", "(", "val", ")", "==", "0", "or", "val", ...
Main method for adding a value to the instance. Does all the checking on type of value and if among allowed values. :param skey: string version of the key :param vtyp: Type of value :param key: original representation of the key :param val: The value to add :par...
[ "Main", "method", "for", "adding", "a", "value", "to", "the", "instance", ".", "Does", "all", "the", "checking", "on", "type", "of", "value", "and", "if", "among", "allowed", "values", ".", ":", "param", "skey", ":", "string", "version", "of", "the", "...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L320-L435
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.to_json
def to_json(self, lev=0, indent=None): """ Serialize the content of this instance into a JSON string. :param lev: :param indent: Number of spaces that should be used for indentation :return: """ if lev: return self.to_dict(lev + 1) ...
python
def to_json(self, lev=0, indent=None): """ Serialize the content of this instance into a JSON string. :param lev: :param indent: Number of spaces that should be used for indentation :return: """ if lev: return self.to_dict(lev + 1) ...
[ "def", "to_json", "(", "self", ",", "lev", "=", "0", ",", "indent", "=", "None", ")", ":", "if", "lev", ":", "return", "self", ".", "to_dict", "(", "lev", "+", "1", ")", "else", ":", "return", "json", ".", "dumps", "(", "self", ".", "to_dict", ...
Serialize the content of this instance into a JSON string. :param lev: :param indent: Number of spaces that should be used for indentation :return:
[ "Serialize", "the", "content", "of", "this", "instance", "into", "a", "JSON", "string", ".", ":", "param", "lev", ":", ":", "param", "indent", ":", "Number", "of", "spaces", "that", "should", "be", "used", "for", "indentation", ":", "return", ":" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L437-L448
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.from_json
def from_json(self, txt, **kwargs): """ Convert from a JSON string to an instance of this class. :param txt: The JSON string (a ``str``, ``bytes`` or ``bytearray`` instance containing a JSON document) :param kwargs: extra keyword arguments :return: The instan...
python
def from_json(self, txt, **kwargs): """ Convert from a JSON string to an instance of this class. :param txt: The JSON string (a ``str``, ``bytes`` or ``bytearray`` instance containing a JSON document) :param kwargs: extra keyword arguments :return: The instan...
[ "def", "from_json", "(", "self", ",", "txt", ",", "*", "*", "kwargs", ")", ":", "_dict", "=", "json", ".", "loads", "(", "txt", ")", "return", "self", ".", "from_dict", "(", "_dict", ")" ]
Convert from a JSON string to an instance of this class. :param txt: The JSON string (a ``str``, ``bytes`` or ``bytearray`` instance containing a JSON document) :param kwargs: extra keyword arguments :return: The instantiated instance
[ "Convert", "from", "a", "JSON", "string", "to", "an", "instance", "of", "this", "class", ".", ":", "param", "txt", ":", "The", "JSON", "string", "(", "a", "str", "bytes", "or", "bytearray", "instance", "containing", "a", "JSON", "document", ")", ":", "...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L450-L460
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.to_jwt
def to_jwt(self, key=None, algorithm="", lev=0, lifetime=0): """ Create a signed JWT representation of the class instance :param key: The signing key :param algorithm: The signature algorithm to use :param lev: :param lifetime: The lifetime of the JWS :return: A ...
python
def to_jwt(self, key=None, algorithm="", lev=0, lifetime=0): """ Create a signed JWT representation of the class instance :param key: The signing key :param algorithm: The signature algorithm to use :param lev: :param lifetime: The lifetime of the JWS :return: A ...
[ "def", "to_jwt", "(", "self", ",", "key", "=", "None", ",", "algorithm", "=", "\"\"", ",", "lev", "=", "0", ",", "lifetime", "=", "0", ")", ":", "_jws", "=", "JWS", "(", "self", ".", "to_json", "(", "lev", ")", ",", "alg", "=", "algorithm", ")"...
Create a signed JWT representation of the class instance :param key: The signing key :param algorithm: The signature algorithm to use :param lev: :param lifetime: The lifetime of the JWS :return: A signed JWT
[ "Create", "a", "signed", "JWT", "representation", "of", "the", "class", "instance" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L462-L474
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.from_jwt
def from_jwt(self, txt, keyjar, verify=True, **kwargs): """ Given a signed and/or encrypted JWT, verify its correctness and then create a class instance from the content. :param txt: The JWT :param key: keys that might be used to decrypt and/or verify the signature o...
python
def from_jwt(self, txt, keyjar, verify=True, **kwargs): """ Given a signed and/or encrypted JWT, verify its correctness and then create a class instance from the content. :param txt: The JWT :param key: keys that might be used to decrypt and/or verify the signature o...
[ "def", "from_jwt", "(", "self", ",", "txt", ",", "keyjar", ",", "verify", "=", "True", ",", "*", "*", "kwargs", ")", ":", "algarg", "=", "{", "}", "if", "'encalg'", "in", "kwargs", ":", "algarg", "[", "'alg'", "]", "=", "kwargs", "[", "'encalg'", ...
Given a signed and/or encrypted JWT, verify its correctness and then create a class instance from the content. :param txt: The JWT :param key: keys that might be used to decrypt and/or verify the signature of the JWT :param verify: Whether the signature should be verified or...
[ "Given", "a", "signed", "and", "/", "or", "encrypted", "JWT", "verify", "its", "correctness", "and", "then", "create", "a", "class", "instance", "from", "the", "content", "." ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L476-L558
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.verify
def verify(self, **kwargs): """ Make sure all the required values are there and that the values are of the correct type """ _spec = self.c_param try: _allowed = self.c_allowed_values except KeyError: _allowed = {} for (attribute, (...
python
def verify(self, **kwargs): """ Make sure all the required values are there and that the values are of the correct type """ _spec = self.c_param try: _allowed = self.c_allowed_values except KeyError: _allowed = {} for (attribute, (...
[ "def", "verify", "(", "self", ",", "*", "*", "kwargs", ")", ":", "_spec", "=", "self", ".", "c_param", "try", ":", "_allowed", "=", "self", ".", "c_allowed_values", "except", "KeyError", ":", "_allowed", "=", "{", "}", "for", "(", "attribute", ",", "...
Make sure all the required values are there and that the values are of the correct type
[ "Make", "sure", "all", "the", "required", "values", "are", "there", "and", "that", "the", "values", "are", "of", "the", "correct", "type" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L585-L622
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.request
def request(self, location, fragment_enc=False): """ Given a URL this method will add a fragment, a query part or extend a query part if it already exists with the information in this instance. :param location: A URL :param fragment_enc: Whether the information should b...
python
def request(self, location, fragment_enc=False): """ Given a URL this method will add a fragment, a query part or extend a query part if it already exists with the information in this instance. :param location: A URL :param fragment_enc: Whether the information should b...
[ "def", "request", "(", "self", ",", "location", ",", "fragment_enc", "=", "False", ")", ":", "_l", "=", "as_unicode", "(", "location", ")", "_qp", "=", "as_unicode", "(", "self", ".", "to_urlencoded", "(", ")", ")", "if", "fragment_enc", ":", "return", ...
Given a URL this method will add a fragment, a query part or extend a query part if it already exists with the information in this instance. :param location: A URL :param fragment_enc: Whether the information should be placed in a fragment (True) or in a query part (False) ...
[ "Given", "a", "URL", "this", "method", "will", "add", "a", "fragment", "a", "query", "part", "or", "extend", "a", "query", "part", "if", "it", "already", "exists", "with", "the", "information", "in", "this", "instance", ".", ":", "param", "location", ":"...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L678-L696
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.extra
def extra(self): """ Return the extra parameters that this instance. Extra meaning those that are not listed in the c_params specification. :return: The key,value pairs for keys that are not in the c_params specification, """ return dict([(key, val) f...
python
def extra(self): """ Return the extra parameters that this instance. Extra meaning those that are not listed in the c_params specification. :return: The key,value pairs for keys that are not in the c_params specification, """ return dict([(key, val) f...
[ "def", "extra", "(", "self", ")", ":", "return", "dict", "(", "[", "(", "key", ",", "val", ")", "for", "key", ",", "val", "in", "self", ".", "_dict", ".", "items", "(", ")", "if", "key", "not", "in", "self", ".", "c_param", "]", ")" ]
Return the extra parameters that this instance. Extra meaning those that are not listed in the c_params specification. :return: The key,value pairs for keys that are not in the c_params specification,
[ "Return", "the", "extra", "parameters", "that", "this", "instance", ".", "Extra", "meaning", "those", "that", "are", "not", "listed", "in", "the", "c_params", "specification", ".", ":", "return", ":", "The", "key", "value", "pairs", "for", "keys", "that", ...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L736-L745
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.only_extras
def only_extras(self): """ Return True if this instance only has key,value pairs for keys that are not defined in c_params. :return: True/False """ known = [key for key in self._dict.keys() if key in self.c_param] if not known: return True ...
python
def only_extras(self): """ Return True if this instance only has key,value pairs for keys that are not defined in c_params. :return: True/False """ known = [key for key in self._dict.keys() if key in self.c_param] if not known: return True ...
[ "def", "only_extras", "(", "self", ")", ":", "known", "=", "[", "key", "for", "key", "in", "self", ".", "_dict", ".", "keys", "(", ")", "if", "key", "in", "self", ".", "c_param", "]", "if", "not", "known", ":", "return", "True", "else", ":", "ret...
Return True if this instance only has key,value pairs for keys that are not defined in c_params. :return: True/False
[ "Return", "True", "if", "this", "instance", "only", "has", "key", "value", "pairs", "for", "keys", "that", "are", "not", "defined", "in", "c_params", ".", ":", "return", ":", "True", "/", "False" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L747-L758
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.update
def update(self, item, **kwargs): """ Update the information in this instance. :param item: a dictionary or a Message instance """ if isinstance(item, dict): self._dict.update(item) elif isinstance(item, Message): for key, val in item.ite...
python
def update(self, item, **kwargs): """ Update the information in this instance. :param item: a dictionary or a Message instance """ if isinstance(item, dict): self._dict.update(item) elif isinstance(item, Message): for key, val in item.ite...
[ "def", "update", "(", "self", ",", "item", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "item", ",", "dict", ")", ":", "self", ".", "_dict", ".", "update", "(", "item", ")", "elif", "isinstance", "(", "item", ",", "Message", ")", "...
Update the information in this instance. :param item: a dictionary or a Message instance
[ "Update", "the", "information", "in", "this", "instance", ".", ":", "param", "item", ":", "a", "dictionary", "or", "a", "Message", "instance" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L760-L772
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.to_jwe
def to_jwe(self, keys, enc, alg, lev=0): """ Place the information in this instance in a JSON object. Make that JSON object the body of a JWT. Then encrypt that JWT using the specified algorithms and the given keys. Return the encrypted JWT. :param keys: list or KeyJar instance ...
python
def to_jwe(self, keys, enc, alg, lev=0): """ Place the information in this instance in a JSON object. Make that JSON object the body of a JWT. Then encrypt that JWT using the specified algorithms and the given keys. Return the encrypted JWT. :param keys: list or KeyJar instance ...
[ "def", "to_jwe", "(", "self", ",", "keys", ",", "enc", ",", "alg", ",", "lev", "=", "0", ")", ":", "_jwe", "=", "JWE", "(", "self", ".", "to_json", "(", "lev", ")", ",", "alg", "=", "alg", ",", "enc", "=", "enc", ")", "return", "_jwe", ".", ...
Place the information in this instance in a JSON object. Make that JSON object the body of a JWT. Then encrypt that JWT using the specified algorithms and the given keys. Return the encrypted JWT. :param keys: list or KeyJar instance :param enc: Content Encryption Algorithm :par...
[ "Place", "the", "information", "in", "this", "instance", "in", "a", "JSON", "object", ".", "Make", "that", "JSON", "object", "the", "body", "of", "a", "JWT", ".", "Then", "encrypt", "that", "JWT", "using", "the", "specified", "algorithms", "and", "the", ...
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L774-L789
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.from_jwe
def from_jwe(self, msg, keys): """ Decrypt an encrypted JWT and load the JSON object that was the body of the JWT into this object. :param msg: An encrypted JWT :param keys: Possibly usable keys. :type keys: list or KeyJar instance :return: The decrypted message....
python
def from_jwe(self, msg, keys): """ Decrypt an encrypted JWT and load the JSON object that was the body of the JWT into this object. :param msg: An encrypted JWT :param keys: Possibly usable keys. :type keys: list or KeyJar instance :return: The decrypted message....
[ "def", "from_jwe", "(", "self", ",", "msg", ",", "keys", ")", ":", "jwe", "=", "JWE", "(", ")", "_res", "=", "jwe", ".", "decrypt", "(", "msg", ",", "keys", ")", "return", "self", ".", "from_json", "(", "_res", ".", "decode", "(", ")", ")" ]
Decrypt an encrypted JWT and load the JSON object that was the body of the JWT into this object. :param msg: An encrypted JWT :param keys: Possibly usable keys. :type keys: list or KeyJar instance :return: The decrypted message. If decryption failed an exception will...
[ "Decrypt", "an", "encrypted", "JWT", "and", "load", "the", "JSON", "object", "that", "was", "the", "body", "of", "the", "JWT", "into", "this", "object", "." ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L791-L805
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.weed
def weed(self): """ Get rid of key value pairs that are not standard """ _ext = [k for k in self._dict.keys() if k not in self.c_param] for k in _ext: del self._dict[k]
python
def weed(self): """ Get rid of key value pairs that are not standard """ _ext = [k for k in self._dict.keys() if k not in self.c_param] for k in _ext: del self._dict[k]
[ "def", "weed", "(", "self", ")", ":", "_ext", "=", "[", "k", "for", "k", "in", "self", ".", "_dict", ".", "keys", "(", ")", "if", "k", "not", "in", "self", ".", "c_param", "]", "for", "k", "in", "_ext", ":", "del", "self", ".", "_dict", "[", ...
Get rid of key value pairs that are not standard
[ "Get", "rid", "of", "key", "value", "pairs", "that", "are", "not", "standard" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L810-L816
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/message.py
Message.rm_blanks
def rm_blanks(self): """ Get rid of parameters that has no value. """ _blanks = [k for k in self._dict.keys() if not self._dict[k]] for key in _blanks: del self._dict[key]
python
def rm_blanks(self): """ Get rid of parameters that has no value. """ _blanks = [k for k in self._dict.keys() if not self._dict[k]] for key in _blanks: del self._dict[key]
[ "def", "rm_blanks", "(", "self", ")", ":", "_blanks", "=", "[", "k", "for", "k", "in", "self", ".", "_dict", ".", "keys", "(", ")", "if", "not", "self", ".", "_dict", "[", "k", "]", "]", "for", "key", "in", "_blanks", ":", "del", "self", ".", ...
Get rid of parameters that has no value.
[ "Get", "rid", "of", "parameters", "that", "has", "no", "value", "." ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/message.py#L818-L824
openid/JWTConnect-Python-OidcMsg
src/oidcmsg/__init__.py
proper_path
def proper_path(path): """ Clean up the path specification so it looks like something I could use. "./" <path> "/" """ if path.startswith("./"): pass elif path.startswith("/"): path = ".%s" % path elif path.startswith("."): while path.startswith("."): path...
python
def proper_path(path): """ Clean up the path specification so it looks like something I could use. "./" <path> "/" """ if path.startswith("./"): pass elif path.startswith("/"): path = ".%s" % path elif path.startswith("."): while path.startswith("."): path...
[ "def", "proper_path", "(", "path", ")", ":", "if", "path", ".", "startswith", "(", "\"./\"", ")", ":", "pass", "elif", "path", ".", "startswith", "(", "\"/\"", ")", ":", "path", "=", "\".%s\"", "%", "path", "elif", "path", ".", "startswith", "(", "\"...
Clean up the path specification so it looks like something I could use. "./" <path> "/"
[ "Clean", "up", "the", "path", "specification", "so", "it", "looks", "like", "something", "I", "could", "use", ".", ".", "/", "<path", ">", "/" ]
train
https://github.com/openid/JWTConnect-Python-OidcMsg/blob/58ade5eb67131abfb99f38b6a92d43b697c9f2fa/src/oidcmsg/__init__.py#L5-L25
noirbizarre/bumpr
bumpr/log.py
ansi
def ansi(color, text): """Wrap text in an ansi escape sequence""" code = COLOR_CODES[color] return '\033[1;{0}m{1}{2}'.format(code, text, RESET_TERM)
python
def ansi(color, text): """Wrap text in an ansi escape sequence""" code = COLOR_CODES[color] return '\033[1;{0}m{1}{2}'.format(code, text, RESET_TERM)
[ "def", "ansi", "(", "color", ",", "text", ")", ":", "code", "=", "COLOR_CODES", "[", "color", "]", "return", "'\\033[1;{0}m{1}{2}'", ".", "format", "(", "code", ",", "text", ",", "RESET_TERM", ")" ]
Wrap text in an ansi escape sequence
[ "Wrap", "text", "in", "an", "ansi", "escape", "sequence" ]
train
https://github.com/noirbizarre/bumpr/blob/221dbb3deaf1cae7922f6a477f3d29d6bf0c0035/bumpr/log.py#L39-L42
abilian/abilian-core
abilian/services/security/service.py
require_flush
def require_flush(fun): """Decorator for methods that need to query security. It ensures all security related operations are flushed to DB, but avoids unneeded flushes. """ @wraps(fun) def ensure_flushed(service, *args, **kwargs): if service.app_state.needs_db_flush: sessio...
python
def require_flush(fun): """Decorator for methods that need to query security. It ensures all security related operations are flushed to DB, but avoids unneeded flushes. """ @wraps(fun) def ensure_flushed(service, *args, **kwargs): if service.app_state.needs_db_flush: sessio...
[ "def", "require_flush", "(", "fun", ")", ":", "@", "wraps", "(", "fun", ")", "def", "ensure_flushed", "(", "service", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "service", ".", "app_state", ".", "needs_db_flush", ":", "session", "=", ...
Decorator for methods that need to query security. It ensures all security related operations are flushed to DB, but avoids unneeded flushes.
[ "Decorator", "for", "methods", "that", "need", "to", "query", "security", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L57-L78
abilian/abilian-core
abilian/services/security/service.py
query_pa_no_flush
def query_pa_no_flush(session, permission, role, obj): """Query for a :class:`PermissionAssignment` using `session` without any `flush()`. It works by looking in session `new`, `dirty` and `deleted`, and issuing a query with no autoflush. .. note:: This function is used by `add_permission...
python
def query_pa_no_flush(session, permission, role, obj): """Query for a :class:`PermissionAssignment` using `session` without any `flush()`. It works by looking in session `new`, `dirty` and `deleted`, and issuing a query with no autoflush. .. note:: This function is used by `add_permission...
[ "def", "query_pa_no_flush", "(", "session", ",", "permission", ",", "role", ",", "obj", ")", ":", "to_visit", "=", "[", "session", ".", "deleted", ",", "session", ".", "dirty", ",", "session", ".", "new", "]", "with", "session", ".", "no_autoflush", ":",...
Query for a :class:`PermissionAssignment` using `session` without any `flush()`. It works by looking in session `new`, `dirty` and `deleted`, and issuing a query with no autoflush. .. note:: This function is used by `add_permission` and `delete_permission` to allow to add/remove the s...
[ "Query", "for", "a", ":", "class", ":", "PermissionAssignment", "using", "session", "without", "any", "flush", "()", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L81-L130
abilian/abilian-core
abilian/services/security/service.py
SecurityService._current_user_manager
def _current_user_manager(self, session=None): """Return the current user, or SYSTEM user.""" if session is None: session = db.session() try: user = g.user except Exception: return session.query(User).get(0) if sa.orm.object_session(user) is ...
python
def _current_user_manager(self, session=None): """Return the current user, or SYSTEM user.""" if session is None: session = db.session() try: user = g.user except Exception: return session.query(User).get(0) if sa.orm.object_session(user) is ...
[ "def", "_current_user_manager", "(", "self", ",", "session", "=", "None", ")", ":", "if", "session", "is", "None", ":", "session", "=", "db", ".", "session", "(", ")", "try", ":", "user", "=", "g", ".", "user", "except", "Exception", ":", "return", "...
Return the current user, or SYSTEM user.
[ "Return", "the", "current", "user", "or", "SYSTEM", "user", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L150-L168
abilian/abilian-core
abilian/services/security/service.py
SecurityService.get_roles
def get_roles(self, principal, object=None, no_group_roles=False): """Get all the roles attached to given `principal`, on a given `object`. :param principal: a :class:`User` or :class:`Group` :param object: an :class:`Entity` :param no_group_roles: If `True`, return only direc...
python
def get_roles(self, principal, object=None, no_group_roles=False): """Get all the roles attached to given `principal`, on a given `object`. :param principal: a :class:`User` or :class:`Group` :param object: an :class:`Entity` :param no_group_roles: If `True`, return only direc...
[ "def", "get_roles", "(", "self", ",", "principal", ",", "object", "=", "None", ",", "no_group_roles", "=", "False", ")", ":", "assert", "principal", "if", "hasattr", "(", "principal", ",", "\"is_anonymous\"", ")", "and", "principal", ".", "is_anonymous", ":"...
Get all the roles attached to given `principal`, on a given `object`. :param principal: a :class:`User` or :class:`Group` :param object: an :class:`Entity` :param no_group_roles: If `True`, return only direct roles, not roles acquired through group membership.
[ "Get", "all", "the", "roles", "attached", "to", "given", "principal", "on", "a", "given", "object", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L210-L247
abilian/abilian-core
abilian/services/security/service.py
SecurityService.get_principals
def get_principals( self, role, anonymous=True, users=True, groups=True, object=None, as_list=True ): """Return all users which are assigned given role.""" if not isinstance(role, Role): role = Role(role) assert role assert users or groups query = RoleAssi...
python
def get_principals( self, role, anonymous=True, users=True, groups=True, object=None, as_list=True ): """Return all users which are assigned given role.""" if not isinstance(role, Role): role = Role(role) assert role assert users or groups query = RoleAssi...
[ "def", "get_principals", "(", "self", ",", "role", ",", "anonymous", "=", "True", ",", "users", "=", "True", ",", "groups", "=", "True", ",", "object", "=", "None", ",", "as_list", "=", "True", ")", ":", "if", "not", "isinstance", "(", "role", ",", ...
Return all users which are assigned given role.
[ "Return", "all", "users", "which", "are", "assigned", "given", "role", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L250-L278
abilian/abilian-core
abilian/services/security/service.py
SecurityService._fill_role_cache
def _fill_role_cache(self, principal, overwrite=False): """Fill role cache for `principal` (User or Group), in order to avoid too many queries when checking role access with 'has_role'. Return role_cache of `principal` """ if not self.app_state.use_cache: return None...
python
def _fill_role_cache(self, principal, overwrite=False): """Fill role cache for `principal` (User or Group), in order to avoid too many queries when checking role access with 'has_role'. Return role_cache of `principal` """ if not self.app_state.use_cache: return None...
[ "def", "_fill_role_cache", "(", "self", ",", "principal", ",", "overwrite", "=", "False", ")", ":", "if", "not", "self", ".", "app_state", ".", "use_cache", ":", "return", "None", "if", "not", "self", ".", "_has_role_cache", "(", "principal", ")", "or", ...
Fill role cache for `principal` (User or Group), in order to avoid too many queries when checking role access with 'has_role'. Return role_cache of `principal`
[ "Fill", "role", "cache", "for", "principal", "(", "User", "or", "Group", ")", "in", "order", "to", "avoid", "too", "many", "queries", "when", "checking", "role", "access", "with", "has_role", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L322-L333
abilian/abilian-core
abilian/services/security/service.py
SecurityService._fill_role_cache_batch
def _fill_role_cache_batch(self, principals, overwrite=False): """Fill role cache for `principals` (Users and/or Groups), in order to avoid too many queries when checking role access with 'has_role'.""" if not self.app_state.use_cache: return query = db.session.query(RoleAss...
python
def _fill_role_cache_batch(self, principals, overwrite=False): """Fill role cache for `principals` (Users and/or Groups), in order to avoid too many queries when checking role access with 'has_role'.""" if not self.app_state.use_cache: return query = db.session.query(RoleAss...
[ "def", "_fill_role_cache_batch", "(", "self", ",", "principals", ",", "overwrite", "=", "False", ")", ":", "if", "not", "self", ".", "app_state", ".", "use_cache", ":", "return", "query", "=", "db", ".", "session", ".", "query", "(", "RoleAssignment", ")",...
Fill role cache for `principals` (Users and/or Groups), in order to avoid too many queries when checking role access with 'has_role'.
[ "Fill", "role", "cache", "for", "principals", "(", "Users", "and", "/", "or", "Groups", ")", "in", "order", "to", "avoid", "too", "many", "queries", "when", "checking", "role", "access", "with", "has_role", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L336-L392
abilian/abilian-core
abilian/services/security/service.py
SecurityService.has_role
def has_role(self, principal, role, object=None): """True if `principal` has `role` (either globally, if `object` is None, or on the specific `object`). :param:role: can be a list or tuple of strings or a :class:`Role` instance `object` can be an :class:`Entity`, a string, ...
python
def has_role(self, principal, role, object=None): """True if `principal` has `role` (either globally, if `object` is None, or on the specific `object`). :param:role: can be a list or tuple of strings or a :class:`Role` instance `object` can be an :class:`Entity`, a string, ...
[ "def", "has_role", "(", "self", ",", "principal", ",", "role", ",", "object", "=", "None", ")", ":", "if", "not", "principal", ":", "return", "False", "principal", "=", "unwrap", "(", "principal", ")", "if", "not", "self", ".", "running", ":", "return"...
True if `principal` has `role` (either globally, if `object` is None, or on the specific `object`). :param:role: can be a list or tuple of strings or a :class:`Role` instance `object` can be an :class:`Entity`, a string, or `None`. Note: we're using a cache for efficiency ...
[ "True", "if", "principal", "has", "role", "(", "either", "globally", "if", "object", "is", "None", "or", "on", "the", "specific", "object", ")", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L403-L472
abilian/abilian-core
abilian/services/security/service.py
SecurityService.grant_role
def grant_role(self, principal, role, obj=None): """Grant `role` to `user` (either globally, if `obj` is None, or on the specific `obj`).""" assert principal principal = unwrap(principal) session = object_session(obj) if obj is not None else db.session manager = self._cur...
python
def grant_role(self, principal, role, obj=None): """Grant `role` to `user` (either globally, if `obj` is None, or on the specific `obj`).""" assert principal principal = unwrap(principal) session = object_session(obj) if obj is not None else db.session manager = self._cur...
[ "def", "grant_role", "(", "self", ",", "principal", ",", "role", ",", "obj", "=", "None", ")", ":", "assert", "principal", "principal", "=", "unwrap", "(", "principal", ")", "session", "=", "object_session", "(", "obj", ")", "if", "obj", "is", "not", "...
Grant `role` to `user` (either globally, if `obj` is None, or on the specific `obj`).
[ "Grant", "role", "to", "user", "(", "either", "globally", "if", "obj", "is", "None", "or", "on", "the", "specific", "obj", ")", "." ]
train
https://github.com/abilian/abilian-core/blob/0a71275bf108c3d51e13ca9e093c0249235351e3/abilian/services/security/service.py#L474-L532