repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
ihiji/version_utils
version_utils/rpm.py
_pop_arch
def _pop_arch(char_list): """Pop the architecture from a version string and return it Returns any portion of a string following the final period. In rpm version strings, this corresponds to the package architecture. :param list char_list: an rpm version string in character list form :return: the p...
python
def _pop_arch(char_list): """Pop the architecture from a version string and return it Returns any portion of a string following the final period. In rpm version strings, this corresponds to the package architecture. :param list char_list: an rpm version string in character list form :return: the p...
[ "def", "_pop_arch", "(", "char_list", ")", ":", "logger", ".", "debug", "(", "'_pop_arch(%s)'", ",", "char_list", ")", "arch_list", "=", "[", "]", "char", "=", "char_list", ".", "pop", "(", ")", "while", "char", "!=", "'.'", ":", "arch_list", ".", "ins...
Pop the architecture from a version string and return it Returns any portion of a string following the final period. In rpm version strings, this corresponds to the package architecture. :param list char_list: an rpm version string in character list form :return: the parsed architecture as a string ...
[ "Pop", "the", "architecture", "from", "a", "version", "string", "and", "return", "it" ]
7f63d80faca8e76274b6e8dff7637cc7cb8d848c
https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L255-L276
train
Pop the architecture from a version string and return it.
ihiji/version_utils
version_utils/rpm.py
_check_leading
def _check_leading(*char_lists): """Remove any non-alphanumeric or non-~ leading characters Checks the beginning of any provided lists for non-alphanumeric or non-~ (tilde) leading characters and removes them if found. Operates on (and possibly alters) the passed list. :param list char_list: a lis...
python
def _check_leading(*char_lists): """Remove any non-alphanumeric or non-~ leading characters Checks the beginning of any provided lists for non-alphanumeric or non-~ (tilde) leading characters and removes them if found. Operates on (and possibly alters) the passed list. :param list char_list: a lis...
[ "def", "_check_leading", "(", "*", "char_lists", ")", ":", "logger", ".", "debug", "(", "'_check_leading(%s)'", ",", "char_lists", ")", "for", "char_list", "in", "char_lists", ":", "while", "(", "len", "(", "char_list", ")", "!=", "0", "and", "not", "char_...
Remove any non-alphanumeric or non-~ leading characters Checks the beginning of any provided lists for non-alphanumeric or non-~ (tilde) leading characters and removes them if found. Operates on (and possibly alters) the passed list. :param list char_list: a list or lists of characters :return: No...
[ "Remove", "any", "non", "-", "alphanumeric", "or", "non", "-", "~", "leading", "characters" ]
7f63d80faca8e76274b6e8dff7637cc7cb8d848c
https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L279-L295
train
Removes any non - alphanumeric or non - ~ leading characters from the beginning of any provided list.
ihiji/version_utils
version_utils/rpm.py
_trim_zeros
def _trim_zeros(*char_lists): """Trim any zeros from provided character lists Checks the beginning of any provided lists for '0's and removes any such leading zeros. Operates on (and possibly) alters the passed list :param list char_lists: a list or lists of characters :return: None :rtype...
python
def _trim_zeros(*char_lists): """Trim any zeros from provided character lists Checks the beginning of any provided lists for '0's and removes any such leading zeros. Operates on (and possibly) alters the passed list :param list char_lists: a list or lists of characters :return: None :rtype...
[ "def", "_trim_zeros", "(", "*", "char_lists", ")", ":", "logger", ".", "debug", "(", "'_trim_zeros(%s)'", ",", "char_lists", ")", "for", "char_list", "in", "char_lists", ":", "while", "len", "(", "char_list", ")", "!=", "0", "and", "char_list", "[", "0", ...
Trim any zeros from provided character lists Checks the beginning of any provided lists for '0's and removes any such leading zeros. Operates on (and possibly) alters the passed list :param list char_lists: a list or lists of characters :return: None :rtype: None
[ "Trim", "any", "zeros", "from", "provided", "character", "lists" ]
7f63d80faca8e76274b6e8dff7637cc7cb8d848c
https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L298-L313
train
Removes any leading zeros from the passed list of characters and returns the new list of the passed list of the passed list of characters.
ihiji/version_utils
version_utils/rpm.py
_pop_digits
def _pop_digits(char_list): """Pop consecutive digits from the front of list and return them Pops any and all consecutive digits from the start of the provided character list and returns them as a list of string digits. Operates on (and possibly alters) the passed list. :param list char_list: a li...
python
def _pop_digits(char_list): """Pop consecutive digits from the front of list and return them Pops any and all consecutive digits from the start of the provided character list and returns them as a list of string digits. Operates on (and possibly alters) the passed list. :param list char_list: a li...
[ "def", "_pop_digits", "(", "char_list", ")", ":", "logger", ".", "debug", "(", "'_pop_digits(%s)'", ",", "char_list", ")", "digits", "=", "[", "]", "while", "len", "(", "char_list", ")", "!=", "0", "and", "char_list", "[", "0", "]", ".", "isdigit", "("...
Pop consecutive digits from the front of list and return them Pops any and all consecutive digits from the start of the provided character list and returns them as a list of string digits. Operates on (and possibly alters) the passed list. :param list char_list: a list of characters :return: a lis...
[ "Pop", "consecutive", "digits", "from", "the", "front", "of", "list", "and", "return", "them" ]
7f63d80faca8e76274b6e8dff7637cc7cb8d848c
https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L316-L333
train
Pops any and all consecutive digits from the front of the provided character list and returns them as a list of string digits.
ihiji/version_utils
version_utils/rpm.py
_pop_letters
def _pop_letters(char_list): """Pop consecutive letters from the front of a list and return them Pops any and all consecutive letters from the start of the provided character list and returns them as a list of characters. Operates on (and possibly alters) the passed list :param list char_list: a l...
python
def _pop_letters(char_list): """Pop consecutive letters from the front of a list and return them Pops any and all consecutive letters from the start of the provided character list and returns them as a list of characters. Operates on (and possibly alters) the passed list :param list char_list: a l...
[ "def", "_pop_letters", "(", "char_list", ")", ":", "logger", ".", "debug", "(", "'_pop_letters(%s)'", ",", "char_list", ")", "letters", "=", "[", "]", "while", "len", "(", "char_list", ")", "!=", "0", "and", "char_list", "[", "0", "]", ".", "isalpha", ...
Pop consecutive letters from the front of a list and return them Pops any and all consecutive letters from the start of the provided character list and returns them as a list of characters. Operates on (and possibly alters) the passed list :param list char_list: a list of characters :return: a lis...
[ "Pop", "consecutive", "letters", "from", "the", "front", "of", "a", "list", "and", "return", "them" ]
7f63d80faca8e76274b6e8dff7637cc7cb8d848c
https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L336-L353
train
Pop consecutive letters from the front of a list and return them as a list of characters.
ihiji/version_utils
version_utils/rpm.py
_compare_blocks
def _compare_blocks(block_a, block_b): """Compare two blocks of characters Compares two blocks of characters of the form returned by either the :any:`_pop_digits` or :any:`_pop_letters` function. Blocks should be character lists containing only digits or only letters. Both blocks should contain the...
python
def _compare_blocks(block_a, block_b): """Compare two blocks of characters Compares two blocks of characters of the form returned by either the :any:`_pop_digits` or :any:`_pop_letters` function. Blocks should be character lists containing only digits or only letters. Both blocks should contain the...
[ "def", "_compare_blocks", "(", "block_a", ",", "block_b", ")", ":", "logger", ".", "debug", "(", "'_compare_blocks(%s, %s)'", ",", "block_a", ",", "block_b", ")", "if", "block_a", "[", "0", "]", ".", "isdigit", "(", ")", ":", "_trim_zeros", "(", "block_a",...
Compare two blocks of characters Compares two blocks of characters of the form returned by either the :any:`_pop_digits` or :any:`_pop_letters` function. Blocks should be character lists containing only digits or only letters. Both blocks should contain the same character type (digits or letters). ...
[ "Compare", "two", "blocks", "of", "characters" ]
7f63d80faca8e76274b6e8dff7637cc7cb8d848c
https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L356-L393
train
Compare two blocks of characters in the order of the character type.
ihiji/version_utils
version_utils/rpm.py
_get_block_result
def _get_block_result(chars_a, chars_b): """Get the first block from two character lists and compare If character list ``a`` begins with a digit, the :any:`_pop_digit` function is called on both lists to get blocks of all consecutive digits at the start of each list. If the length of the block retu...
python
def _get_block_result(chars_a, chars_b): """Get the first block from two character lists and compare If character list ``a`` begins with a digit, the :any:`_pop_digit` function is called on both lists to get blocks of all consecutive digits at the start of each list. If the length of the block retu...
[ "def", "_get_block_result", "(", "chars_a", ",", "chars_b", ")", ":", "logger", ".", "debug", "(", "'_get_block_result(%s, %s)'", ",", "chars_a", ",", "chars_b", ")", "first_is_digit", "=", "chars_a", "[", "0", "]", ".", "isdigit", "(", ")", "pop_func", "=",...
Get the first block from two character lists and compare If character list ``a`` begins with a digit, the :any:`_pop_digit` function is called on both lists to get blocks of all consecutive digits at the start of each list. If the length of the block returned when popping digits for ``b`` is zero (``b`...
[ "Get", "the", "first", "block", "from", "two", "character", "lists", "and", "compare" ]
7f63d80faca8e76274b6e8dff7637cc7cb8d848c
https://github.com/ihiji/version_utils/blob/7f63d80faca8e76274b6e8dff7637cc7cb8d848c/version_utils/rpm.py#L396-L430
train
Get the first block from two character lists and compare .
ariebovenberg/snug
examples/slack/channels.py
list_
def list_(*, cursor: str=None, exclude_archived: bool=None, exclude_members: bool=None, limit: int=None) -> snug.Query[Page[t.List[Channel]]]: """list all channels""" kwargs = { 'exclude_archived': exclude_archived, 'exclude_members': exclude_members, 'limi...
python
def list_(*, cursor: str=None, exclude_archived: bool=None, exclude_members: bool=None, limit: int=None) -> snug.Query[Page[t.List[Channel]]]: """list all channels""" kwargs = { 'exclude_archived': exclude_archived, 'exclude_members': exclude_members, 'limi...
[ "def", "list_", "(", "*", ",", "cursor", ":", "str", "=", "None", ",", "exclude_archived", ":", "bool", "=", "None", ",", "exclude_members", ":", "bool", "=", "None", ",", "limit", ":", "int", "=", "None", ")", "->", "snug", ".", "Query", "[", "Pag...
list all channels
[ "list", "all", "channels" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/slack/channels.py#L14-L34
train
list all channels
ariebovenberg/snug
examples/slack/channels.py
create
def create(name: str, *, validate: bool=None) -> snug.Query[Channel]: """create a new channel""" return {'name': name, 'validate': validate}
python
def create(name: str, *, validate: bool=None) -> snug.Query[Channel]: """create a new channel""" return {'name': name, 'validate': validate}
[ "def", "create", "(", "name", ":", "str", ",", "*", ",", "validate", ":", "bool", "=", "None", ")", "->", "snug", ".", "Query", "[", "Channel", "]", ":", "return", "{", "'name'", ":", "name", ",", "'validate'", ":", "validate", "}" ]
create a new channel
[ "create", "a", "new", "channel" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/examples/slack/channels.py#L38-L41
train
create a new channel
igorcoding/asynctnt-queue
asynctnt_queue/queue.py
Queue.tube
def tube(self, name): """ Returns tube by its name :param name: Tube name :returns: ``self.tube_cls`` instance (by default :class:`asynctnt_queue.Tube`) """ if name in self._tubes: return self._tubes[name] assert name, 'Tu...
python
def tube(self, name): """ Returns tube by its name :param name: Tube name :returns: ``self.tube_cls`` instance (by default :class:`asynctnt_queue.Tube`) """ if name in self._tubes: return self._tubes[name] assert name, 'Tu...
[ "def", "tube", "(", "self", ",", "name", ")", ":", "if", "name", "in", "self", ".", "_tubes", ":", "return", "self", ".", "_tubes", "[", "name", "]", "assert", "name", ",", "'Tube name must be specified'", "t", "=", "self", ".", "_tube_cls", "(", "self...
Returns tube by its name :param name: Tube name :returns: ``self.tube_cls`` instance (by default :class:`asynctnt_queue.Tube`)
[ "Returns", "tube", "by", "its", "name" ]
75719b2dd27e8314ae924aea6a7a85be8f48ecc5
https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/queue.py#L58-L72
train
Returns a tube by its name
igorcoding/asynctnt-queue
asynctnt_queue/queue.py
Queue.statistics
async def statistics(self, tube_name=None): """ Returns queue statistics (coroutine) :param tube_name: If specified, statistics by a specific tube is returned, else statistics about all tubes is returned """ args = None if tube_nam...
python
async def statistics(self, tube_name=None): """ Returns queue statistics (coroutine) :param tube_name: If specified, statistics by a specific tube is returned, else statistics about all tubes is returned """ args = None if tube_nam...
[ "async", "def", "statistics", "(", "self", ",", "tube_name", "=", "None", ")", ":", "args", "=", "None", "if", "tube_name", "is", "not", "None", ":", "args", "=", "(", "tube_name", ",", ")", "res", "=", "await", "self", ".", "_conn", ".", "call", "...
Returns queue statistics (coroutine) :param tube_name: If specified, statistics by a specific tube is returned, else statistics about all tubes is returned
[ "Returns", "queue", "statistics", "(", "coroutine", ")" ]
75719b2dd27e8314ae924aea6a7a85be8f48ecc5
https://github.com/igorcoding/asynctnt-queue/blob/75719b2dd27e8314ae924aea6a7a85be8f48ecc5/asynctnt_queue/queue.py#L74-L89
train
Returns queue statistics
pyros-dev/pyzmp
pyzmp/service.py
Service.call
def call(self, args=None, kwargs=None, node=None, send_timeout=1000, recv_timeout=5000, zmq_ctx=None): """ Calls a service on a node with req as arguments. if node is None, a node is chosen by zmq. if zmq_ctx is passed, it will use the existing context Uses a REQ socket. Ref : http://api...
python
def call(self, args=None, kwargs=None, node=None, send_timeout=1000, recv_timeout=5000, zmq_ctx=None): """ Calls a service on a node with req as arguments. if node is None, a node is chosen by zmq. if zmq_ctx is passed, it will use the existing context Uses a REQ socket. Ref : http://api...
[ "def", "call", "(", "self", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "node", "=", "None", ",", "send_timeout", "=", "1000", ",", "recv_timeout", "=", "5000", ",", "zmq_ctx", "=", "None", ")", ":", "context", "=", "zmq_ctx", "or", ...
Calls a service on a node with req as arguments. if node is None, a node is chosen by zmq. if zmq_ctx is passed, it will use the existing context Uses a REQ socket. Ref : http://api.zeromq.org/2-1:zmq-socket :param node : the node name
[ "Calls", "a", "service", "on", "a", "node", "with", "req", "as", "arguments", ".", "if", "node", "is", "None", "a", "node", "is", "chosen", "by", "zmq", ".", "if", "zmq_ctx", "is", "passed", "it", "will", "use", "the", "existing", "context", "Uses", ...
fac0b719b25996ce94a80ca2118f3eba5779d53d
https://github.com/pyros-dev/pyzmp/blob/fac0b719b25996ce94a80ca2118f3eba5779d53d/pyzmp/service.py#L97-L150
train
Calls a service on a node with req as arguments.
eclipse/unide.python
src/unide/measurement.py
device_measurement
def device_measurement(device, ts=None, part=None, result=None, code=None, **kwargs): """Returns a JSON MeasurementPayload ready to be send through a transport. If `ts` is not given, the curre...
python
def device_measurement(device, ts=None, part=None, result=None, code=None, **kwargs): """Returns a JSON MeasurementPayload ready to be send through a transport. If `ts` is not given, the curre...
[ "def", "device_measurement", "(", "device", ",", "ts", "=", "None", ",", "part", "=", "None", ",", "result", "=", "None", ",", "code", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "ts", "is", "None", ":", "ts", "=", "local_now", "(", ")"...
Returns a JSON MeasurementPayload ready to be send through a transport. If `ts` is not given, the current time is used. `part` is an optional `Part` object, and `result` and `code` are the respective fields of the `Measurement` object. All other arguments are interpreted as dimensions. Minimal...
[ "Returns", "a", "JSON", "MeasurementPayload", "ready", "to", "be", "send", "through", "a", "transport", "." ]
b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493
https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/measurement.py#L272-L303
train
Returns a JSON MeasurementPayload ready to be sent through a transport.
eclipse/unide.python
src/unide/measurement.py
Measurement.add_sample
def add_sample(self, ts, **kwargs): """Add a sample to this measurements.""" if not self.series.offsets: self.ts = ts offset = 0 else: dt = ts - self.ts offset = (dt.days * 24 * 60 * 60 * 1000 + dt.seconds * 1000 + dt.microsec...
python
def add_sample(self, ts, **kwargs): """Add a sample to this measurements.""" if not self.series.offsets: self.ts = ts offset = 0 else: dt = ts - self.ts offset = (dt.days * 24 * 60 * 60 * 1000 + dt.seconds * 1000 + dt.microsec...
[ "def", "add_sample", "(", "self", ",", "ts", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "series", ".", "offsets", ":", "self", ".", "ts", "=", "ts", "offset", "=", "0", "else", ":", "dt", "=", "ts", "-", "self", ".", "ts", "...
Add a sample to this measurements.
[ "Add", "a", "sample", "to", "this", "measurements", "." ]
b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493
https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/measurement.py#L203-L212
train
Add a sample to this measurements.
eclipse/unide.python
src/unide/measurement.py
Measurement.samples
def samples(self): """Yield samples as dictionaries, keyed by dimensions.""" names = self.series.dimensions for n, offset in enumerate(self.series.offsets): dt = datetime.timedelta(microseconds=offset * 1000) d = {"ts": self.ts + dt} for name in names: ...
python
def samples(self): """Yield samples as dictionaries, keyed by dimensions.""" names = self.series.dimensions for n, offset in enumerate(self.series.offsets): dt = datetime.timedelta(microseconds=offset * 1000) d = {"ts": self.ts + dt} for name in names: ...
[ "def", "samples", "(", "self", ")", ":", "names", "=", "self", ".", "series", ".", "dimensions", "for", "n", ",", "offset", "in", "enumerate", "(", "self", ".", "series", ".", "offsets", ")", ":", "dt", "=", "datetime", ".", "timedelta", "(", "micros...
Yield samples as dictionaries, keyed by dimensions.
[ "Yield", "samples", "as", "dictionaries", "keyed", "by", "dimensions", "." ]
b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493
https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/measurement.py#L214-L222
train
Yields samples as dictionaries keyed by dimensions.
thebigmunch/audio-metadata
src/audio_metadata/api.py
determine_format
def determine_format(data, extension=None): """Determine the format of an audio file. Parameters: data (bytes-like object, str, os.PathLike, or file-like object): A bytes-like object, filepath, path-like object or file-like object of an audio file. extension (str): The file extension of the file. Used a...
python
def determine_format(data, extension=None): """Determine the format of an audio file. Parameters: data (bytes-like object, str, os.PathLike, or file-like object): A bytes-like object, filepath, path-like object or file-like object of an audio file. extension (str): The file extension of the file. Used a...
[ "def", "determine_format", "(", "data", ",", "extension", "=", "None", ")", ":", "if", "isinstance", "(", "data", ",", "(", "os", ".", "PathLike", ",", "str", ")", ")", ":", "data", "=", "open", "(", "data", ",", "'rb'", ")", "data_reader", "=", "D...
Determine the format of an audio file. Parameters: data (bytes-like object, str, os.PathLike, or file-like object): A bytes-like object, filepath, path-like object or file-like object of an audio file. extension (str): The file extension of the file. Used as a tie-breaker for formats that can be used ...
[ "Determine", "the", "format", "of", "an", "audio", "file", "." ]
d17bdbdb71db79c1568d54438d42dcd940b76074
https://github.com/thebigmunch/audio-metadata/blob/d17bdbdb71db79c1568d54438d42dcd940b76074/src/audio_metadata/api.py#L14-L45
train
Determine the format of an audio file.
thebigmunch/audio-metadata
src/audio_metadata/api.py
load
def load(f): """Load audio metadata from filepath or file-like object. Parameters: f (str, os.PathLike, or file-like object): A filepath, path-like object or file-like object of an audio file. Returns: Format: An audio format object. Raises: UnsupportedFormat: If file is not of a supported format. Val...
python
def load(f): """Load audio metadata from filepath or file-like object. Parameters: f (str, os.PathLike, or file-like object): A filepath, path-like object or file-like object of an audio file. Returns: Format: An audio format object. Raises: UnsupportedFormat: If file is not of a supported format. Val...
[ "def", "load", "(", "f", ")", ":", "if", "isinstance", "(", "f", ",", "(", "os", ".", "PathLike", ",", "str", ")", ")", ":", "fileobj", "=", "open", "(", "f", ",", "'rb'", ")", "else", ":", "try", ":", "f", ".", "read", "(", "0", ")", "exce...
Load audio metadata from filepath or file-like object. Parameters: f (str, os.PathLike, or file-like object): A filepath, path-like object or file-like object of an audio file. Returns: Format: An audio format object. Raises: UnsupportedFormat: If file is not of a supported format. ValueError: If filep...
[ "Load", "audio", "metadata", "from", "filepath", "or", "file", "-", "like", "object", "." ]
d17bdbdb71db79c1568d54438d42dcd940b76074
https://github.com/thebigmunch/audio-metadata/blob/d17bdbdb71db79c1568d54438d42dcd940b76074/src/audio_metadata/api.py#L48-L82
train
Load audio metadata from file - like object.
thebigmunch/audio-metadata
src/audio_metadata/api.py
loads
def loads(b): """Load audio metadata from a bytes-like object. Parameters: b (bytes-like object): A bytes-like object of an audio file. Returns: Format: An audio format object. Raises: UnsupportedFormat: If file is not of a supported format. """ parser_cls = determine_format(b) if parser_cls is None: ...
python
def loads(b): """Load audio metadata from a bytes-like object. Parameters: b (bytes-like object): A bytes-like object of an audio file. Returns: Format: An audio format object. Raises: UnsupportedFormat: If file is not of a supported format. """ parser_cls = determine_format(b) if parser_cls is None: ...
[ "def", "loads", "(", "b", ")", ":", "parser_cls", "=", "determine_format", "(", "b", ")", "if", "parser_cls", "is", "None", ":", "raise", "UnsupportedFormat", "(", "\"Supported format signature not found.\"", ")", "return", "parser_cls", ".", "load", "(", "b", ...
Load audio metadata from a bytes-like object. Parameters: b (bytes-like object): A bytes-like object of an audio file. Returns: Format: An audio format object. Raises: UnsupportedFormat: If file is not of a supported format.
[ "Load", "audio", "metadata", "from", "a", "bytes", "-", "like", "object", "." ]
d17bdbdb71db79c1568d54438d42dcd940b76074
https://github.com/thebigmunch/audio-metadata/blob/d17bdbdb71db79c1568d54438d42dcd940b76074/src/audio_metadata/api.py#L85-L103
train
Load audio metadata from a bytes - like object.
ariebovenberg/snug
snug/clients.py
_urllib_send
def _urllib_send(opener, req, **kwargs): """Send a request with an :mod:`urllib` opener""" if req.content and not any(h.lower() == 'content-type' for h in req.headers): req = req.with_headers({'Content-Type': 'application/octet-stream'}) url = req.url + '?' + urlencode...
python
def _urllib_send(opener, req, **kwargs): """Send a request with an :mod:`urllib` opener""" if req.content and not any(h.lower() == 'content-type' for h in req.headers): req = req.with_headers({'Content-Type': 'application/octet-stream'}) url = req.url + '?' + urlencode...
[ "def", "_urllib_send", "(", "opener", ",", "req", ",", "*", "*", "kwargs", ")", ":", "if", "req", ".", "content", "and", "not", "any", "(", "h", ".", "lower", "(", ")", "==", "'content-type'", "for", "h", "in", "req", ".", "headers", ")", ":", "r...
Send a request with an :mod:`urllib` opener
[ "Send", "a", "request", "with", "an", ":", "mod", ":", "urllib", "opener" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/snug/clients.py#L90-L102
train
Send a request with an urllib opener
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/NoteNode.py
NoteNode.Find
def Find(self, node_type, item_type): ''' method for finding specific types of notation from nodes. will currently return the first one it encounters because this method's only really intended for some types of notation for which the exact value doesn't really matter. :...
python
def Find(self, node_type, item_type): ''' method for finding specific types of notation from nodes. will currently return the first one it encounters because this method's only really intended for some types of notation for which the exact value doesn't really matter. :...
[ "def", "Find", "(", "self", ",", "node_type", ",", "item_type", ")", ":", "if", "node_type", "==", "OtherNodes", ".", "DirectionNode", ":", "child", "=", "self", ".", "GetChild", "(", "len", "(", "self", ".", "children", ")", "-", "1", ")", "while", ...
method for finding specific types of notation from nodes. will currently return the first one it encounters because this method's only really intended for some types of notation for which the exact value doesn't really matter. :param node_type: the type of node to look under :...
[ "method", "for", "finding", "specific", "types", "of", "notation", "from", "nodes", ".", "will", "currently", "return", "the", "first", "one", "it", "encounters", "because", "this", "method", "s", "only", "really", "intended", "for", "some", "types", "of", "...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/NoteNode.py#L41-L71
train
method for finding specific types of notation from nodes.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/NoteNode.py
NoteNode.UpdateArpeggiates
def UpdateArpeggiates(self, type="start"): ''' method which searches for all arpeggiates and updates the top one of each chord to be a start, and the bottom one to be a stop ready for lilypond output :param type: :return: ''' result = self.item.Search(Arpeggiate) ...
python
def UpdateArpeggiates(self, type="start"): ''' method which searches for all arpeggiates and updates the top one of each chord to be a start, and the bottom one to be a stop ready for lilypond output :param type: :return: ''' result = self.item.Search(Arpeggiate) ...
[ "def", "UpdateArpeggiates", "(", "self", ",", "type", "=", "\"start\"", ")", ":", "result", "=", "self", ".", "item", ".", "Search", "(", "Arpeggiate", ")", "if", "result", "is", "not", "None", ":", "if", "type", "==", "\"start\"", ":", "result", ".", ...
method which searches for all arpeggiates and updates the top one of each chord to be a start, and the bottom one to be a stop ready for lilypond output :param type: :return:
[ "method", "which", "searches", "for", "all", "arpeggiates", "and", "updates", "the", "top", "one", "of", "each", "chord", "to", "be", "a", "start", "and", "the", "bottom", "one", "to", "be", "a", "stop", "ready", "for", "lilypond", "output", ":", "param"...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/NoteNode.py#L82-L118
train
method which searches for all arpeggiates and updates the top one of each chord to be a start ready for lilypond output
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/NoteNode.py
NoteNode.toLily
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "" if self.item is not None: if not isinstance(self.GetChild(0), NoteNode): ...
python
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "" if self.item is not None: if not isinstance(self.GetChild(0), NoteNode): ...
[ "def", "toLily", "(", "self", ")", ":", "lilystring", "=", "\"\"", "if", "self", ".", "item", "is", "not", "None", ":", "if", "not", "isinstance", "(", "self", ".", "GetChild", "(", "0", ")", ",", "NoteNode", ")", ":", "if", "hasattr", "(", "self",...
Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code
[ "Method", "which", "converts", "the", "object", "instance", "its", "attributes", "and", "children", "to", "a", "string", "of", "lilypond", "code" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/NoteNode.py#L226-L258
train
Method which converts the object instance its attributes and children to a string of lilypond code.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/NoteNode.py
Placeholder.toLily
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "" if self.duration > 0: lilystring += "r" + str(self.duration) return lilystring
python
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "" if self.duration > 0: lilystring += "r" + str(self.duration) return lilystring
[ "def", "toLily", "(", "self", ")", ":", "lilystring", "=", "\"\"", "if", "self", ".", "duration", ">", "0", ":", "lilystring", "+=", "\"r\"", "+", "str", "(", "self", ".", "duration", ")", "return", "lilystring" ]
Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code
[ "Method", "which", "converts", "the", "object", "instance", "its", "attributes", "and", "children", "to", "a", "string", "of", "lilypond", "code" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/NoteNode.py#L276-L285
train
Method which converts the object instance its attributes and children to a string of lilypond code
MacHu-GWU/single_file_module-project
sfm/lines_count.py
count_lines
def count_lines(abspath): """Count how many lines in a pure text file. """ with open(abspath, "rb") as f: i = 0 for line in f: i += 1 pass return i
python
def count_lines(abspath): """Count how many lines in a pure text file. """ with open(abspath, "rb") as f: i = 0 for line in f: i += 1 pass return i
[ "def", "count_lines", "(", "abspath", ")", ":", "with", "open", "(", "abspath", ",", "\"rb\"", ")", "as", "f", ":", "i", "=", "0", "for", "line", "in", "f", ":", "i", "+=", "1", "pass", "return", "i" ]
Count how many lines in a pure text file.
[ "Count", "how", "many", "lines", "in", "a", "pure", "text", "file", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/lines_count.py#L21-L29
train
Count how many lines in a pure text file.
MacHu-GWU/single_file_module-project
sfm/lines_count.py
lines_stats
def lines_stats(dir_path, file_filter): """Lines count of selected files under a directory. :return n_files: number of files :return n_lines: number of lines """ n_files = 0 n_lines = 0 for p in Path(dir_path).select_file(file_filter): n_files += 1 n_lines += count_lines(p.a...
python
def lines_stats(dir_path, file_filter): """Lines count of selected files under a directory. :return n_files: number of files :return n_lines: number of lines """ n_files = 0 n_lines = 0 for p in Path(dir_path).select_file(file_filter): n_files += 1 n_lines += count_lines(p.a...
[ "def", "lines_stats", "(", "dir_path", ",", "file_filter", ")", ":", "n_files", "=", "0", "n_lines", "=", "0", "for", "p", "in", "Path", "(", "dir_path", ")", ".", "select_file", "(", "file_filter", ")", ":", "n_files", "+=", "1", "n_lines", "+=", "cou...
Lines count of selected files under a directory. :return n_files: number of files :return n_lines: number of lines
[ "Lines", "count", "of", "selected", "files", "under", "a", "directory", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/lines_count.py#L32-L43
train
Lines count of selected files under a directory.
TylerTemp/docpie
docpie/parser.py
OptionParser.parse_content
def parse_content(self, text): """parse section to formal format raw_content: {title: section(with title)}. For `help` access. formal_content: {title: section} but the section has been dedented without title. For parse instance""" raw_content = self.raw_content ...
python
def parse_content(self, text): """parse section to formal format raw_content: {title: section(with title)}. For `help` access. formal_content: {title: section} but the section has been dedented without title. For parse instance""" raw_content = self.raw_content ...
[ "def", "parse_content", "(", "self", ",", "text", ")", ":", "raw_content", "=", "self", ".", "raw_content", "raw_content", ".", "clear", "(", ")", "formal_collect", "=", "{", "}", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", ...
parse section to formal format raw_content: {title: section(with title)}. For `help` access. formal_content: {title: section} but the section has been dedented without title. For parse instance
[ "parse", "section", "to", "formal", "format", "raw_content", ":", "{", "title", ":", "section", "(", "with", "title", ")", "}", ".", "For", "help", "access", ".", "formal_content", ":", "{", "title", ":", "section", "}", "but", "the", "section", "has", ...
e658454b81b6c79a020d499f12ad73496392c09a
https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/parser.py#L413-L476
train
parse section to formal format ecords. For help access. For parse instance. For help access.
TylerTemp/docpie
docpie/parser.py
OptionParser.parse_names_and_default
def parse_names_and_default(self): """parse for `parse_content` {title: [('-a, --all=STH', 'default'), ...]}""" result = {} for title, text in self.formal_content.items(): if not text: result[title] = [] continue logger....
python
def parse_names_and_default(self): """parse for `parse_content` {title: [('-a, --all=STH', 'default'), ...]}""" result = {} for title, text in self.formal_content.items(): if not text: result[title] = [] continue logger....
[ "def", "parse_names_and_default", "(", "self", ")", ":", "result", "=", "{", "}", "for", "title", ",", "text", "in", "self", ".", "formal_content", ".", "items", "(", ")", ":", "if", "not", "text", ":", "result", "[", "title", "]", "=", "[", "]", "...
parse for `parse_content` {title: [('-a, --all=STH', 'default'), ...]}
[ "parse", "for", "parse_content", "{", "title", ":", "[", "(", "-", "a", "--", "all", "=", "STH", "default", ")", "...", "]", "}" ]
e658454b81b6c79a020d499f12ad73496392c09a
https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/parser.py#L478-L521
train
parse for parse_content
TylerTemp/docpie
docpie/parser.py
OptionParser.parse_to_instance
def parse_to_instance(self, title_of_name_and_default): """{title: [Option(), ...]}""" result = {} for title, name_and_default in title_of_name_and_default.items(): logger.debug((title, name_and_default)) result[title] = opts = [] for opt_str, default in...
python
def parse_to_instance(self, title_of_name_and_default): """{title: [Option(), ...]}""" result = {} for title, name_and_default in title_of_name_and_default.items(): logger.debug((title, name_and_default)) result[title] = opts = [] for opt_str, default in...
[ "def", "parse_to_instance", "(", "self", ",", "title_of_name_and_default", ")", ":", "result", "=", "{", "}", "for", "title", ",", "name_and_default", "in", "title_of_name_and_default", ".", "items", "(", ")", ":", "logger", ".", "debug", "(", "(", "title", ...
{title: [Option(), ...]}
[ "{", "title", ":", "[", "Option", "()", "...", "]", "}" ]
e658454b81b6c79a020d499f12ad73496392c09a
https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/parser.py#L577-L592
train
Parse the options from a dictionary of title - > name - > default - > instance
TylerTemp/docpie
docpie/parser.py
UsageParser.set_option_name_2_instance
def set_option_name_2_instance(self, options): """{title: {'-a': Option(), '--all': Option()}}""" title_opt_2_ins = self.titled_opt_to_ins title_opt_2_ins.clear() for title, opts in options.items(): title_opt_2_ins[title] = opt_2_ins = {} for each in opts: ...
python
def set_option_name_2_instance(self, options): """{title: {'-a': Option(), '--all': Option()}}""" title_opt_2_ins = self.titled_opt_to_ins title_opt_2_ins.clear() for title, opts in options.items(): title_opt_2_ins[title] = opt_2_ins = {} for each in opts: ...
[ "def", "set_option_name_2_instance", "(", "self", ",", "options", ")", ":", "title_opt_2_ins", "=", "self", ".", "titled_opt_to_ins", "title_opt_2_ins", ".", "clear", "(", ")", "for", "title", ",", "opts", "in", "options", ".", "items", "(", ")", ":", "title...
{title: {'-a': Option(), '--all': Option()}}
[ "{", "title", ":", "{", "-", "a", ":", "Option", "()", "--", "all", ":", "Option", "()", "}}" ]
e658454b81b6c79a020d499f12ad73496392c09a
https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/parser.py#L761-L770
train
Set the option name to instance of the last option.
TylerTemp/docpie
docpie/parser.py
UsageParser.parse_content
def parse_content(self, text): """get Usage section and set to `raw_content`, `formal_content` of no title and empty-line version""" match = re.search( self.usage_re_str.format(self.usage_name), text, flags=(re.DOTALL if self.case_sen...
python
def parse_content(self, text): """get Usage section and set to `raw_content`, `formal_content` of no title and empty-line version""" match = re.search( self.usage_re_str.format(self.usage_name), text, flags=(re.DOTALL if self.case_sen...
[ "def", "parse_content", "(", "self", ",", "text", ")", ":", "match", "=", "re", ".", "search", "(", "self", ".", "usage_re_str", ".", "format", "(", "self", ".", "usage_name", ")", ",", "text", ",", "flags", "=", "(", "re", ".", "DOTALL", "if", "se...
get Usage section and set to `raw_content`, `formal_content` of no title and empty-line version
[ "get", "Usage", "section", "and", "set", "to", "raw_content", "formal_content", "of", "no", "title", "and", "empty", "-", "line", "version" ]
e658454b81b6c79a020d499f12ad73496392c09a
https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/parser.py#L772-L795
train
get Usage section and set to raw_content self. formal_content self. title and empty - line version
koszullab/metaTOR
metator/scripts/figures.py
spaceless_pdf_plot_maker
def spaceless_pdf_plot_maker(array, filename, vmax=None, dpi=DEFAULT_DPI): """Draw a pretty plot from an array A function that performs all the tedious matplotlib magic to draw a 2D array with as few parameters and as little whitespace as possible. Parameters ---------- array : array_like ...
python
def spaceless_pdf_plot_maker(array, filename, vmax=None, dpi=DEFAULT_DPI): """Draw a pretty plot from an array A function that performs all the tedious matplotlib magic to draw a 2D array with as few parameters and as little whitespace as possible. Parameters ---------- array : array_like ...
[ "def", "spaceless_pdf_plot_maker", "(", "array", ",", "filename", ",", "vmax", "=", "None", ",", "dpi", "=", "DEFAULT_DPI", ")", ":", "if", "vmax", "is", "None", ":", "vmax", "=", "np", ".", "percentile", "(", "array", ",", "DEFAULT_SATURATION_THRESHOLD", ...
Draw a pretty plot from an array A function that performs all the tedious matplotlib magic to draw a 2D array with as few parameters and as little whitespace as possible. Parameters ---------- array : array_like The input array to draw. filename : file, str or pathlib.Path ...
[ "Draw", "a", "pretty", "plot", "from", "an", "array" ]
0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a
https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/figures.py#L38-L72
train
This function is a function that creates a pretty plot from an array.
koszullab/metaTOR
metator/scripts/figures.py
draw_sparse_matrix
def draw_sparse_matrix( array_filename, output_image, vmax=DEFAULT_SATURATION_THRESHOLD, max_size_matrix=DEFAULT_MAX_SIZE_MATRIX, ): """Draw a quick preview of a sparse matrix with automated binning and normalization. """ matrix = np.loadtxt(array_filename, dtype=np.int32, skiprows=1) ...
python
def draw_sparse_matrix( array_filename, output_image, vmax=DEFAULT_SATURATION_THRESHOLD, max_size_matrix=DEFAULT_MAX_SIZE_MATRIX, ): """Draw a quick preview of a sparse matrix with automated binning and normalization. """ matrix = np.loadtxt(array_filename, dtype=np.int32, skiprows=1) ...
[ "def", "draw_sparse_matrix", "(", "array_filename", ",", "output_image", ",", "vmax", "=", "DEFAULT_SATURATION_THRESHOLD", ",", "max_size_matrix", "=", "DEFAULT_MAX_SIZE_MATRIX", ",", ")", ":", "matrix", "=", "np", ".", "loadtxt", "(", "array_filename", ",", "dtype"...
Draw a quick preview of a sparse matrix with automated binning and normalization.
[ "Draw", "a", "quick", "preview", "of", "a", "sparse", "matrix", "with", "automated", "binning", "and", "normalization", "." ]
0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a
https://github.com/koszullab/metaTOR/blob/0c1203d1dffedfa5ea380c0335b4baa9cfb7e89a/metator/scripts/figures.py#L75-L100
train
Draw a quick preview of a sparse matrix with automated binning and normalization.
MacHu-GWU/single_file_module-project
sfm/iterable.py
flatten_all
def flatten_all(nested_iterable): """Flatten arbitrary depth of nesting. Good for unknown nesting structure iterable object. Example:: >>> list(flatten_all([[1, 2], "abc", [3, ["x", "y", "z"]], 4])) [1, 2, "abc", 3, "x", "y", "z", 4] **中文文档** 将任意维度的列表压平成一维列表。 注: 使用hasattr(i,...
python
def flatten_all(nested_iterable): """Flatten arbitrary depth of nesting. Good for unknown nesting structure iterable object. Example:: >>> list(flatten_all([[1, 2], "abc", [3, ["x", "y", "z"]], 4])) [1, 2, "abc", 3, "x", "y", "z", 4] **中文文档** 将任意维度的列表压平成一维列表。 注: 使用hasattr(i,...
[ "def", "flatten_all", "(", "nested_iterable", ")", ":", "for", "item", "in", "nested_iterable", ":", "if", "hasattr", "(", "item", ",", "\"__iter__\"", ")", "and", "not", "isinstance", "(", "item", ",", "string_types", ")", ":", "for", "i", "in", "flatten_...
Flatten arbitrary depth of nesting. Good for unknown nesting structure iterable object. Example:: >>> list(flatten_all([[1, 2], "abc", [3, ["x", "y", "z"]], 4])) [1, 2, "abc", 3, "x", "y", "z", 4] **中文文档** 将任意维度的列表压平成一维列表。 注: 使用hasattr(i, "__iter__")方法做是否是可循环对象的判断, 性能要高于其他 任...
[ "Flatten", "arbitrary", "depth", "of", "nesting", ".", "Good", "for", "unknown", "nesting", "structure", "iterable", "object", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L41-L62
train
Flatten arbitrary depth of nesting. Good for unknown nesting structure iterable object.
MacHu-GWU/single_file_module-project
sfm/iterable.py
nth
def nth(iterable, n, default=None): """Returns the nth item or a default value. Example:: >>> nth([0, 1, 2], 1) 1 >>> nth([0, 1, 2], 100) None **中文文档** 取出一个可循环对象中的第n个元素。等效于list(iterable)[n], 但占用极小的内存。 因为list(iterable)要将所有元素放在内存中并生成一个新列表。该方法常用语对于 那些取index操作被改写...
python
def nth(iterable, n, default=None): """Returns the nth item or a default value. Example:: >>> nth([0, 1, 2], 1) 1 >>> nth([0, 1, 2], 100) None **中文文档** 取出一个可循环对象中的第n个元素。等效于list(iterable)[n], 但占用极小的内存。 因为list(iterable)要将所有元素放在内存中并生成一个新列表。该方法常用语对于 那些取index操作被改写...
[ "def", "nth", "(", "iterable", ",", "n", ",", "default", "=", "None", ")", ":", "return", "next", "(", "itertools", ".", "islice", "(", "iterable", ",", "n", ",", "None", ")", ",", "default", ")" ]
Returns the nth item or a default value. Example:: >>> nth([0, 1, 2], 1) 1 >>> nth([0, 1, 2], 100) None **中文文档** 取出一个可循环对象中的第n个元素。等效于list(iterable)[n], 但占用极小的内存。 因为list(iterable)要将所有元素放在内存中并生成一个新列表。该方法常用语对于 那些取index操作被改写了的可循环对象。
[ "Returns", "the", "nth", "item", "or", "a", "default", "value", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L65-L82
train
Returns the nth item or a default value.
MacHu-GWU/single_file_module-project
sfm/iterable.py
pull
def pull(iterable, n): """Return last n items of the iterable as a list. Example:: >>> pull([0, 1, 2], 3) [1, 2] **中文文档** 取出可循环对象中的最后n个元素。等效于list(iterable)[-n:], 但占用极小的内存。 因为list(iterable)要将所有元素放在内存中并生成一个新列表。该方法常用语对于 那些取index操作被改写了的可循环对象。 """ fifo = collections.deque(...
python
def pull(iterable, n): """Return last n items of the iterable as a list. Example:: >>> pull([0, 1, 2], 3) [1, 2] **中文文档** 取出可循环对象中的最后n个元素。等效于list(iterable)[-n:], 但占用极小的内存。 因为list(iterable)要将所有元素放在内存中并生成一个新列表。该方法常用语对于 那些取index操作被改写了的可循环对象。 """ fifo = collections.deque(...
[ "def", "pull", "(", "iterable", ",", "n", ")", ":", "fifo", "=", "collections", ".", "deque", "(", "maxlen", "=", "n", ")", "for", "i", "in", "iterable", ":", "fifo", ".", "append", "(", "i", ")", "return", "list", "(", "fifo", ")" ]
Return last n items of the iterable as a list. Example:: >>> pull([0, 1, 2], 3) [1, 2] **中文文档** 取出可循环对象中的最后n个元素。等效于list(iterable)[-n:], 但占用极小的内存。 因为list(iterable)要将所有元素放在内存中并生成一个新列表。该方法常用语对于 那些取index操作被改写了的可循环对象。
[ "Return", "last", "n", "items", "of", "the", "iterable", "as", "a", "list", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L102-L119
train
Return last n items of the iterable as a list.
MacHu-GWU/single_file_module-project
sfm/iterable.py
running_window
def running_window(iterable, size): """Generate n-size running window. Example:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5] **中文文档** 简单滑窗函数。 """ if size > len(iterable): raise ValueErro...
python
def running_window(iterable, size): """Generate n-size running window. Example:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5] **中文文档** 简单滑窗函数。 """ if size > len(iterable): raise ValueErro...
[ "def", "running_window", "(", "iterable", ",", "size", ")", ":", "if", "size", ">", "len", "(", "iterable", ")", ":", "raise", "ValueError", "(", "\"size can not be greater than length of iterable.\"", ")", "fifo", "=", "collections", ".", "deque", "(", "maxlen"...
Generate n-size running window. Example:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5] **中文文档** 简单滑窗函数。
[ "Generate", "n", "-", "size", "running", "window", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L215-L237
train
Generate n - size running window.
MacHu-GWU/single_file_module-project
sfm/iterable.py
cycle_running_window
def cycle_running_window(iterable, size): """Generate n-size cycle running window. Example:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 1] [5, 1, 2] **中文文档** 循环位移滑窗函数。 """ ...
python
def cycle_running_window(iterable, size): """Generate n-size cycle running window. Example:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 1] [5, 1, 2] **中文文档** 循环位移滑窗函数。 """ ...
[ "def", "cycle_running_window", "(", "iterable", ",", "size", ")", ":", "if", "size", ">", "len", "(", "iterable", ")", ":", "raise", "ValueError", "(", "\"size can not be greater than length of iterable.\"", ")", "fifo", "=", "collections", ".", "deque", "(", "m...
Generate n-size cycle running window. Example:: >>> for i in running_windows([1, 2, 3, 4, 5], size=3): ... print(i) [1, 2, 3] [2, 3, 4] [3, 4, 5] [4, 5, 1] [5, 1, 2] **中文文档** 循环位移滑窗函数。
[ "Generate", "n", "-", "size", "cycle", "running", "window", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L240-L269
train
Generate n - size cycle running window.
MacHu-GWU/single_file_module-project
sfm/iterable.py
cycle_slice
def cycle_slice(sliceable, start, end): """Given a list, return right hand cycle direction slice from start to end. Example:: >>> array = [0, 1, 2, 3] >>> cycle_slice(array, 1, 3) # from array[1] to array[3] [1, 2] >>> cycle_slice(array, 3, 1) # from array[3] to array[1] ...
python
def cycle_slice(sliceable, start, end): """Given a list, return right hand cycle direction slice from start to end. Example:: >>> array = [0, 1, 2, 3] >>> cycle_slice(array, 1, 3) # from array[1] to array[3] [1, 2] >>> cycle_slice(array, 3, 1) # from array[3] to array[1] ...
[ "def", "cycle_slice", "(", "sliceable", ",", "start", ",", "end", ")", ":", "if", "type", "(", "sliceable", ")", "!=", "list", ":", "sliceable", "=", "list", "(", "sliceable", ")", "length", "=", "len", "(", "sliceable", ")", "if", "length", "==", "0...
Given a list, return right hand cycle direction slice from start to end. Example:: >>> array = [0, 1, 2, 3] >>> cycle_slice(array, 1, 3) # from array[1] to array[3] [1, 2] >>> cycle_slice(array, 3, 1) # from array[3] to array[1] [3, 0] **中文文档**
[ "Given", "a", "list", "return", "right", "hand", "cycle", "direction", "slice", "from", "start", "to", "end", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L274-L301
train
Given a list return a right hand cycle direction slice from start to end.
MacHu-GWU/single_file_module-project
sfm/iterable.py
cycle_dist
def cycle_dist(x, y, perimeter): """Find Distance between x, y by means of a n-length cycle. :param x: :param y: :param perimeter: Example: >>> cycle_dist(1, 23, 24) = 2 >>> cycle_dist(5, 13, 24) = 8 >>> cycle_dist(0.0, 2.4, 1.0) = 0.4 >>> cycle_dist(0.0, 2.6, 1.0)...
python
def cycle_dist(x, y, perimeter): """Find Distance between x, y by means of a n-length cycle. :param x: :param y: :param perimeter: Example: >>> cycle_dist(1, 23, 24) = 2 >>> cycle_dist(5, 13, 24) = 8 >>> cycle_dist(0.0, 2.4, 1.0) = 0.4 >>> cycle_dist(0.0, 2.6, 1.0)...
[ "def", "cycle_dist", "(", "x", ",", "y", ",", "perimeter", ")", ":", "dist", "=", "abs", "(", "x", "-", "y", ")", "%", "perimeter", "if", "dist", ">", "0.5", "*", "perimeter", ":", "dist", "=", "perimeter", "-", "dist", "return", "dist" ]
Find Distance between x, y by means of a n-length cycle. :param x: :param y: :param perimeter: Example: >>> cycle_dist(1, 23, 24) = 2 >>> cycle_dist(5, 13, 24) = 8 >>> cycle_dist(0.0, 2.4, 1.0) = 0.4 >>> cycle_dist(0.0, 2.6, 1.0) = 0.4 **中文文档** 假设坐标轴是一个环, 计算两...
[ "Find", "Distance", "between", "x", "y", "by", "means", "of", "a", "n", "-", "length", "cycle", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L304-L325
train
Find Distance between x y by means of a n - length cycle.
MacHu-GWU/single_file_module-project
sfm/iterable.py
shift_and_trim
def shift_and_trim(array, dist): """Shift and trim unneeded item. :params array: list like iterable object :params dist: int Example:: >>> array = [0, 1, 2] >>> shift_and_trim(array, 0) [0, 1, 2] >>> shift_and_trim(array, 1) [0, 1] >>> shift_and_trim(...
python
def shift_and_trim(array, dist): """Shift and trim unneeded item. :params array: list like iterable object :params dist: int Example:: >>> array = [0, 1, 2] >>> shift_and_trim(array, 0) [0, 1, 2] >>> shift_and_trim(array, 1) [0, 1] >>> shift_and_trim(...
[ "def", "shift_and_trim", "(", "array", ",", "dist", ")", ":", "length", "=", "len", "(", "array", ")", "if", "length", "==", "0", ":", "return", "[", "]", "if", "(", "dist", ">=", "length", ")", "or", "(", "dist", "<=", "-", "length", ")", ":", ...
Shift and trim unneeded item. :params array: list like iterable object :params dist: int Example:: >>> array = [0, 1, 2] >>> shift_and_trim(array, 0) [0, 1, 2] >>> shift_and_trim(array, 1) [0, 1] >>> shift_and_trim(array, -1) [1, 2] >>> s...
[ "Shift", "and", "trim", "unneeded", "item", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L351-L386
train
Shift and trim unneeded item.
MacHu-GWU/single_file_module-project
sfm/iterable.py
shift_and_pad
def shift_and_pad(array, dist, pad="__null__"): """Shift and pad with item. :params array: list like iterable object :params dist: int :params pad: any value Example:: >>> array = [0, 1, 2] >>> shift_and_pad(array, 0) [0, 1, 2] >>> shift_and_pad(array, 1) ...
python
def shift_and_pad(array, dist, pad="__null__"): """Shift and pad with item. :params array: list like iterable object :params dist: int :params pad: any value Example:: >>> array = [0, 1, 2] >>> shift_and_pad(array, 0) [0, 1, 2] >>> shift_and_pad(array, 1) ...
[ "def", "shift_and_pad", "(", "array", ",", "dist", ",", "pad", "=", "\"__null__\"", ")", ":", "length", "=", "len", "(", "array", ")", "if", "length", "==", "0", ":", "return", "[", "]", "if", "pad", "==", "\"__null__\"", ":", "if", "dist", ">", "0...
Shift and pad with item. :params array: list like iterable object :params dist: int :params pad: any value Example:: >>> array = [0, 1, 2] >>> shift_and_pad(array, 0) [0, 1, 2] >>> shift_and_pad(array, 1) [0, 0, 1] >>> shift_and_pad(array, -1) ...
[ "Shift", "and", "pad", "with", "item", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L389-L440
train
Shift and pad with item.
MacHu-GWU/single_file_module-project
sfm/iterable.py
size_of_generator
def size_of_generator(generator, memory_efficient=True): """Get number of items in a generator function. - memory_efficient = True, 3 times slower, but memory_efficient. - memory_efficient = False, faster, but cost more memory. **中文文档** 计算一个生成器函数中的元素的个数。使用memory_efficient=True的方法可以避免将生成器中的 所有...
python
def size_of_generator(generator, memory_efficient=True): """Get number of items in a generator function. - memory_efficient = True, 3 times slower, but memory_efficient. - memory_efficient = False, faster, but cost more memory. **中文文档** 计算一个生成器函数中的元素的个数。使用memory_efficient=True的方法可以避免将生成器中的 所有...
[ "def", "size_of_generator", "(", "generator", ",", "memory_efficient", "=", "True", ")", ":", "if", "memory_efficient", ":", "counter", "=", "0", "for", "_", "in", "generator", ":", "counter", "+=", "1", "return", "counter", "else", ":", "return", "len", "...
Get number of items in a generator function. - memory_efficient = True, 3 times slower, but memory_efficient. - memory_efficient = False, faster, but cost more memory. **中文文档** 计算一个生成器函数中的元素的个数。使用memory_efficient=True的方法可以避免将生成器中的 所有元素放入内存, 但是速度稍慢于memory_efficient=False的方法。
[ "Get", "number", "of", "items", "in", "a", "generator", "function", "." ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L443-L460
train
Get the size of a generator function.
MacHu-GWU/single_file_module-project
sfm/iterable.py
difference
def difference(array, k=1): """Calculate l[n] - l[n-k] """ if (len(array) - k) < 1: raise ValueError() if k < 0: raise ValueError("k has to be greater or equal than zero!") elif k == 0: return [i - i for i in array] else: return [j - i for i, j in zip(array[:-k], ...
python
def difference(array, k=1): """Calculate l[n] - l[n-k] """ if (len(array) - k) < 1: raise ValueError() if k < 0: raise ValueError("k has to be greater or equal than zero!") elif k == 0: return [i - i for i in array] else: return [j - i for i, j in zip(array[:-k], ...
[ "def", "difference", "(", "array", ",", "k", "=", "1", ")", ":", "if", "(", "len", "(", "array", ")", "-", "k", ")", "<", "1", ":", "raise", "ValueError", "(", ")", "if", "k", "<", "0", ":", "raise", "ValueError", "(", "\"k has to be greater or equ...
Calculate l[n] - l[n-k]
[ "Calculate", "l", "[", "n", "]", "-", "l", "[", "n", "-", "k", "]" ]
01f7a6b250853bebfd73de275895bf274325cfc1
https://github.com/MacHu-GWU/single_file_module-project/blob/01f7a6b250853bebfd73de275895bf274325cfc1/sfm/iterable.py#L465-L475
train
Calculate the difference between two lists of n - k elements.
JanHendrikDolling/configvalidator
configvalidator/validators/__init__.py
AndValidator.validate
def validate(self, value): """validate function form OrValidator Returns: True if at least one of the validators validate function return True """ errors = [] self._used_validator = [] for val in self._validators: try: ...
python
def validate(self, value): """validate function form OrValidator Returns: True if at least one of the validators validate function return True """ errors = [] self._used_validator = [] for val in self._validators: try: ...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "errors", "=", "[", "]", "self", ".", "_used_validator", "=", "[", "]", "for", "val", "in", "self", ".", "_validators", ":", "try", ":", "val", ".", "validate", "(", "value", ")", "self", ".",...
validate function form OrValidator Returns: True if at least one of the validators validate function return True
[ "validate", "function", "form", "OrValidator" ]
efde23a9352ae1fd6702b04ad964783ce11cbca5
https://github.com/JanHendrikDolling/configvalidator/blob/efde23a9352ae1fd6702b04ad964783ce11cbca5/configvalidator/validators/__init__.py#L598-L617
train
validate function form OrValidator
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py
MeasureNode.GetTotalValue
def GetTotalValue(self): """Gets the total value of the bar according to it's time signature""" value = "" if hasattr(self, "meter"): top_value = self.meter.beats bottom = self.meter.type fraction = top_value / bottom if fraction == 1: ...
python
def GetTotalValue(self): """Gets the total value of the bar according to it's time signature""" value = "" if hasattr(self, "meter"): top_value = self.meter.beats bottom = self.meter.type fraction = top_value / bottom if fraction == 1: ...
[ "def", "GetTotalValue", "(", "self", ")", ":", "value", "=", "\"\"", "if", "hasattr", "(", "self", ",", "\"meter\"", ")", ":", "top_value", "=", "self", ".", "meter", ".", "beats", "bottom", "=", "self", ".", "meter", ".", "type", "fraction", "=", "t...
Gets the total value of the bar according to it's time signature
[ "Gets", "the", "total", "value", "of", "the", "bar", "according", "to", "it", "s", "time", "signature" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py#L133-L151
train
Gets the total value of the bar according to its time signature
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py
MeasureNode.GetLastKey
def GetLastKey(self, voice=1): """key as in musical key, not index""" voice_obj = self.GetChild(voice) if voice_obj is not None: key = BackwardSearch(KeyNode, voice_obj, 1) if key is not None: return key else: if hasattr(self, ...
python
def GetLastKey(self, voice=1): """key as in musical key, not index""" voice_obj = self.GetChild(voice) if voice_obj is not None: key = BackwardSearch(KeyNode, voice_obj, 1) if key is not None: return key else: if hasattr(self, ...
[ "def", "GetLastKey", "(", "self", ",", "voice", "=", "1", ")", ":", "voice_obj", "=", "self", ".", "GetChild", "(", "voice", ")", "if", "voice_obj", "is", "not", "None", ":", "key", "=", "BackwardSearch", "(", "KeyNode", ",", "voice_obj", ",", "1", "...
key as in musical key, not index
[ "key", "as", "in", "musical", "key", "not", "index" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py#L165-L178
train
returns the last key in the tree
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py
MeasureNode.addClef
def addClef(self, item, voice=1): ''' method to use when adding a clef. will either add it to the node itself or add it onto the first voice's children list :param item: :param voice: :return: ''' if not hasattr(self, "clef"): self.clef = item ...
python
def addClef(self, item, voice=1): ''' method to use when adding a clef. will either add it to the node itself or add it onto the first voice's children list :param item: :param voice: :return: ''' if not hasattr(self, "clef"): self.clef = item ...
[ "def", "addClef", "(", "self", ",", "item", ",", "voice", "=", "1", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"clef\"", ")", ":", "self", ".", "clef", "=", "item", "else", ":", "voice_obj", "=", "self", ".", "GetChild", "(", "voice", ...
method to use when adding a clef. will either add it to the node itself or add it onto the first voice's children list :param item: :param voice: :return:
[ "method", "to", "use", "when", "adding", "a", "clef", ".", "will", "either", "add", "it", "to", "the", "node", "itself", "or", "add", "it", "onto", "the", "first", "voice", "s", "children", "list", ":", "param", "item", ":", ":", "param", "voice", ":...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py#L205-L221
train
add a clef to the node if it doesn t exist
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py
MeasureNode.Forward
def Forward(self, duration=0): ''' method to use when forward tag is encountered in musicXML. jumps forward in the bar by <duration> :param duration: number of beats to move forward :return: ''' for voice in self.GetChildrenIndexes(): voice_obj = self.getVoice...
python
def Forward(self, duration=0): ''' method to use when forward tag is encountered in musicXML. jumps forward in the bar by <duration> :param duration: number of beats to move forward :return: ''' for voice in self.GetChildrenIndexes(): voice_obj = self.getVoice...
[ "def", "Forward", "(", "self", ",", "duration", "=", "0", ")", ":", "for", "voice", "in", "self", ".", "GetChildrenIndexes", "(", ")", ":", "voice_obj", "=", "self", ".", "getVoice", "(", "voice", ")", "if", "voice_obj", ".", "GetChild", "(", "self", ...
method to use when forward tag is encountered in musicXML. jumps forward in the bar by <duration> :param duration: number of beats to move forward :return:
[ "method", "to", "use", "when", "forward", "tag", "is", "encountered", "in", "musicXML", ".", "jumps", "forward", "in", "the", "bar", "by", "<duration", ">", ":", "param", "duration", ":", "number", "of", "beats", "to", "move", "forward", ":", "return", "...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py#L235-L245
train
method to use when forward tag is encountered in musicXML. jumps forward in the bar by duration
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py
MeasureNode.Backup
def Backup(self, duration=0): ''' method to use when a backup tag is encountered in musicXML. Moves back in the bar by <duration> :param duration: :return: ''' total = 0 duration_total = duration * 4 children = self.GetChildrenIndexes() notes = 0 ...
python
def Backup(self, duration=0): ''' method to use when a backup tag is encountered in musicXML. Moves back in the bar by <duration> :param duration: :return: ''' total = 0 duration_total = duration * 4 children = self.GetChildrenIndexes() notes = 0 ...
[ "def", "Backup", "(", "self", ",", "duration", "=", "0", ")", ":", "total", "=", "0", "duration_total", "=", "duration", "*", "4", "children", "=", "self", ".", "GetChildrenIndexes", "(", ")", "notes", "=", "0", "for", "voice", "in", "children", ":", ...
method to use when a backup tag is encountered in musicXML. Moves back in the bar by <duration> :param duration: :return:
[ "method", "to", "use", "when", "a", "backup", "tag", "is", "encountered", "in", "musicXML", ".", "Moves", "back", "in", "the", "bar", "by", "<duration", ">", ":", "param", "duration", ":", ":", "return", ":" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py#L247-L284
train
method to use when a backup tag is encountered in musicXML. Moves back in the bar by <duration >.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py
MeasureNode.getPartialLength
def getPartialLength(self): """ method to calculate how much to give the "partial" indicator where a measure is a pickup :return: str which is the lilypond bar length """ indexes = self.GetChildrenIndexes() length = 0 divider = 0 total = 0 result = "" ...
python
def getPartialLength(self): """ method to calculate how much to give the "partial" indicator where a measure is a pickup :return: str which is the lilypond bar length """ indexes = self.GetChildrenIndexes() length = 0 divider = 0 total = 0 result = "" ...
[ "def", "getPartialLength", "(", "self", ")", ":", "indexes", "=", "self", ".", "GetChildrenIndexes", "(", ")", "length", "=", "0", "divider", "=", "0", "total", "=", "0", "result", "=", "\"\"", "for", "v", "in", "indexes", ":", "voice", "=", "self", ...
method to calculate how much to give the "partial" indicator where a measure is a pickup :return: str which is the lilypond bar length
[ "method", "to", "calculate", "how", "much", "to", "give", "the", "partial", "indicator", "where", "a", "measure", "is", "a", "pickup", ":", "return", ":", "str", "which", "is", "the", "lilypond", "bar", "length" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py#L419-L457
train
method to calculate the length of a pickup by looking at the children of the pickup object.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py
MeasureNode.toLily
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "" left_barline = self.GetBarline("left") other_lefts = self.GetBarline("left-1") if o...
python
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "" left_barline = self.GetBarline("left") other_lefts = self.GetBarline("left-1") if o...
[ "def", "toLily", "(", "self", ")", ":", "lilystring", "=", "\"\"", "left_barline", "=", "self", ".", "GetBarline", "(", "\"left\"", ")", "other_lefts", "=", "self", ".", "GetBarline", "(", "\"left-1\"", ")", "if", "other_lefts", "is", "not", "None", ":", ...
Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code
[ "Method", "which", "converts", "the", "object", "instance", "its", "attributes", "and", "children", "to", "a", "string", "of", "lilypond", "code" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/MeasureNode.py#L541-L593
train
Method which converts the object instance its attributes and children to a string of lilypond code.
Godley/MuseParse
MuseParse/helpers.py
SplitString
def SplitString(value): """simple method that puts in spaces every 10 characters""" string_length = len(value) chunks = int(string_length / 10) string_list = list(value) lstring = "" if chunks > 1: lstring = "\\markup { \n\r \column { " for i in range(int(chunks)): l...
python
def SplitString(value): """simple method that puts in spaces every 10 characters""" string_length = len(value) chunks = int(string_length / 10) string_list = list(value) lstring = "" if chunks > 1: lstring = "\\markup { \n\r \column { " for i in range(int(chunks)): l...
[ "def", "SplitString", "(", "value", ")", ":", "string_length", "=", "len", "(", "value", ")", "chunks", "=", "int", "(", "string_length", "/", "10", ")", "string_list", "=", "list", "(", "value", ")", "lstring", "=", "\"\"", "if", "chunks", ">", "1", ...
simple method that puts in spaces every 10 characters
[ "simple", "method", "that", "puts", "in", "spaces", "every", "10", "characters" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/helpers.py#L4-L46
train
simple method that puts in spaces every 10 characters
Godley/MuseParse
MuseParse/helpers.py
GetID
def GetID(attrs, tag, val): """ handy method which pulls out a nested id: attrs refers to a dictionary holding the id tag refers to the tag we're looking at (e.g measure, part etc) val refers to the exact index of the tag we're looking for (e.g number, id etc) example case: attrs = self.attribs, tag...
python
def GetID(attrs, tag, val): """ handy method which pulls out a nested id: attrs refers to a dictionary holding the id tag refers to the tag we're looking at (e.g measure, part etc) val refers to the exact index of the tag we're looking for (e.g number, id etc) example case: attrs = self.attribs, tag...
[ "def", "GetID", "(", "attrs", ",", "tag", ",", "val", ")", ":", "if", "tag", "in", "attrs", ":", "if", "val", "in", "attrs", "[", "tag", "]", ":", "return", "attrs", "[", "tag", "]", "[", "val", "]" ]
handy method which pulls out a nested id: attrs refers to a dictionary holding the id tag refers to the tag we're looking at (e.g measure, part etc) val refers to the exact index of the tag we're looking for (e.g number, id etc) example case: attrs = self.attribs, tag=measure and val=number would return...
[ "handy", "method", "which", "pulls", "out", "a", "nested", "id", ":", "attrs", "refers", "to", "a", "dictionary", "holding", "the", "id", "tag", "refers", "to", "the", "tag", "we", "re", "looking", "at", "(", "e", ".", "g", "measure", "part", "etc", ...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/helpers.py#L49-L60
train
getID - Gets the id of a nested element
Godley/MuseParse
MuseParse/helpers.py
NumbersToWords
def NumbersToWords(number): """ little function that converts numbers to words. This could be more efficient, and won't work if the number is bigger than 999 but it's for stave names, and I doubt any part would have more than 10 staves let alone 999. """ units = [ 'one', 'two', ...
python
def NumbersToWords(number): """ little function that converts numbers to words. This could be more efficient, and won't work if the number is bigger than 999 but it's for stave names, and I doubt any part would have more than 10 staves let alone 999. """ units = [ 'one', 'two', ...
[ "def", "NumbersToWords", "(", "number", ")", ":", "units", "=", "[", "'one'", ",", "'two'", ",", "'three'", ",", "'four'", ",", "'five'", ",", "'six'", ",", "'seven'", ",", "'eight'", ",", "'nine'", "]", "tens", "=", "[", "'ten'", ",", "'twenty'", ",...
little function that converts numbers to words. This could be more efficient, and won't work if the number is bigger than 999 but it's for stave names, and I doubt any part would have more than 10 staves let alone 999.
[ "little", "function", "that", "converts", "numbers", "to", "words", ".", "This", "could", "be", "more", "efficient", "and", "won", "t", "work", "if", "the", "number", "is", "bigger", "than", "999", "but", "it", "s", "for", "stave", "names", "and", "I", ...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/helpers.py#L63-L108
train
This function converts a number to a list of words.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/PartNode.py
PartNode.CheckTotals
def CheckTotals(self): """method to calculate the maximum total lilypond value for a measure without a time signature""" staves = self.GetChildrenIndexes() for staff in staves: child = self.getStaff(staff) child.CheckTotals()
python
def CheckTotals(self): """method to calculate the maximum total lilypond value for a measure without a time signature""" staves = self.GetChildrenIndexes() for staff in staves: child = self.getStaff(staff) child.CheckTotals()
[ "def", "CheckTotals", "(", "self", ")", ":", "staves", "=", "self", ".", "GetChildrenIndexes", "(", ")", "for", "staff", "in", "staves", ":", "child", "=", "self", ".", "getStaff", "(", "staff", ")", "child", ".", "CheckTotals", "(", ")" ]
method to calculate the maximum total lilypond value for a measure without a time signature
[ "method", "to", "calculate", "the", "maximum", "total", "lilypond", "value", "for", "a", "measure", "without", "a", "time", "signature" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/PartNode.py#L60-L65
train
method to calculate the maximum total lilypond value for a measure without a time signature
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/PartNode.py
PartNode.CheckPreviousBarline
def CheckPreviousBarline(self, staff): """method which checks the bar before the current for changes we need to make to it's barlines""" measure_before_last = self.getMeasureAtPosition(-2, staff) last_measure = self.getMeasureAtPosition(-1, staff) if last_measure is not None and measure_...
python
def CheckPreviousBarline(self, staff): """method which checks the bar before the current for changes we need to make to it's barlines""" measure_before_last = self.getMeasureAtPosition(-2, staff) last_measure = self.getMeasureAtPosition(-1, staff) if last_measure is not None and measure_...
[ "def", "CheckPreviousBarline", "(", "self", ",", "staff", ")", ":", "measure_before_last", "=", "self", ".", "getMeasureAtPosition", "(", "-", "2", ",", "staff", ")", "last_measure", "=", "self", ".", "getMeasureAtPosition", "(", "-", "1", ",", "staff", ")",...
method which checks the bar before the current for changes we need to make to it's barlines
[ "method", "which", "checks", "the", "bar", "before", "the", "current", "for", "changes", "we", "need", "to", "make", "to", "it", "s", "barlines" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/PartNode.py#L78-L91
train
method which checks the bar before the current for changes we need to make to it s barlines
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/PartNode.py
PartNode.toLily
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' self.CheckDivisions() self.CheckTotals() staves = self.GetChildrenIndexes() name = "" short...
python
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' self.CheckDivisions() self.CheckTotals() staves = self.GetChildrenIndexes() name = "" short...
[ "def", "toLily", "(", "self", ")", ":", "self", ".", "CheckDivisions", "(", ")", "self", ".", "CheckTotals", "(", ")", "staves", "=", "self", ".", "GetChildrenIndexes", "(", ")", "name", "=", "\"\"", "shortname", "=", "\"\"", "if", "hasattr", "(", "sel...
Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code
[ "Method", "which", "converts", "the", "object", "instance", "its", "attributes", "and", "children", "to", "a", "string", "of", "lilypond", "code" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/PartNode.py#L200-L250
train
Method which converts the object instance its attributes and children to a string of lilypond code.
TylerTemp/docpie
docpie/__init__.py
docpie
def docpie(doc, argv=None, help=True, version=None, stdopt=True, attachopt=True, attachvalue=True, helpstyle='python', auto2dashes=True, name=None, case_sensitive=False, optionsfirst=False, appearedonly=False, namedoptions=False, extra=None): """ Parse `arg...
python
def docpie(doc, argv=None, help=True, version=None, stdopt=True, attachopt=True, attachvalue=True, helpstyle='python', auto2dashes=True, name=None, case_sensitive=False, optionsfirst=False, appearedonly=False, namedoptions=False, extra=None): """ Parse `arg...
[ "def", "docpie", "(", "doc", ",", "argv", "=", "None", ",", "help", "=", "True", ",", "version", "=", "None", ",", "stdopt", "=", "True", ",", "attachopt", "=", "True", ",", "attachvalue", "=", "True", ",", "helpstyle", "=", "'python'", ",", "auto2da...
Parse `argv` based on command-line interface described in `doc`. `docpie` creates your command-line interface based on its description that you pass as `doc`. Such description can contain --options, <positional-argument>, commands, which could be [optional], (required), (mutually | exclusive) or repeat...
[ "Parse", "argv", "based", "on", "command", "-", "line", "interface", "described", "in", "doc", "." ]
e658454b81b6c79a020d499f12ad73496392c09a
https://github.com/TylerTemp/docpie/blob/e658454b81b6c79a020d499f12ad73496392c09a/docpie/__init__.py#L34-L133
train
Parse a doc string into a sequence of command - line interface objects.
eweast/BencodePy
build/lib/bencodepy/decoder.py
decode_from_file
def decode_from_file(path: str) -> Iterable: """Convenience function. Reads file and calls decode().""" with open(path, 'rb') as f: b = f.read() return decode(b)
python
def decode_from_file(path: str) -> Iterable: """Convenience function. Reads file and calls decode().""" with open(path, 'rb') as f: b = f.read() return decode(b)
[ "def", "decode_from_file", "(", "path", ":", "str", ")", "->", "Iterable", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "b", "=", "f", ".", "read", "(", ")", "return", "decode", "(", "b", ")" ]
Convenience function. Reads file and calls decode().
[ "Convenience", "function", ".", "Reads", "file", "and", "calls", "decode", "()", "." ]
a9c145bd087c61dd8fb28a9dfad46d085c8b8290
https://github.com/eweast/BencodePy/blob/a9c145bd087c61dd8fb28a9dfad46d085c8b8290/build/lib/bencodepy/decoder.py#L90-L94
train
Convenience function. Reads file and calls decode method.
eweast/BencodePy
build/lib/bencodepy/decoder.py
Decoder.__read
def __read(self, i: int) -> bytes: """Returns a set number (i) of bytes from self.data.""" b = self.data[self.idx: self.idx + i] self.idx += i if len(b) != i: raise bencodepy.DecodingError( "Incorrect byte length returned between indexes of {0} and {1}. Possib...
python
def __read(self, i: int) -> bytes: """Returns a set number (i) of bytes from self.data.""" b = self.data[self.idx: self.idx + i] self.idx += i if len(b) != i: raise bencodepy.DecodingError( "Incorrect byte length returned between indexes of {0} and {1}. Possib...
[ "def", "__read", "(", "self", ",", "i", ":", "int", ")", "->", "bytes", ":", "b", "=", "self", ".", "data", "[", "self", ".", "idx", ":", "self", ".", "idx", "+", "i", "]", "self", ".", "idx", "+=", "i", "if", "len", "(", "b", ")", "!=", ...
Returns a set number (i) of bytes from self.data.
[ "Returns", "a", "set", "number", "(", "i", ")", "of", "bytes", "from", "self", ".", "data", "." ]
a9c145bd087c61dd8fb28a9dfad46d085c8b8290
https://github.com/eweast/BencodePy/blob/a9c145bd087c61dd8fb28a9dfad46d085c8b8290/build/lib/bencodepy/decoder.py#L11-L19
train
Returns a set number ( i ) of bytes from self. data.
eweast/BencodePy
build/lib/bencodepy/decoder.py
Decoder.__read_to
def __read_to(self, terminator: bytes) -> bytes: """Returns bytes from self.data starting at index (self.idx) until terminator character.""" try: # noinspection PyTypeChecker i = self.data.index(terminator, self.idx) b = self.data[self.idx:i] self.idx = i ...
python
def __read_to(self, terminator: bytes) -> bytes: """Returns bytes from self.data starting at index (self.idx) until terminator character.""" try: # noinspection PyTypeChecker i = self.data.index(terminator, self.idx) b = self.data[self.idx:i] self.idx = i ...
[ "def", "__read_to", "(", "self", ",", "terminator", ":", "bytes", ")", "->", "bytes", ":", "try", ":", "# noinspection PyTypeChecker", "i", "=", "self", ".", "data", ".", "index", "(", "terminator", ",", "self", ".", "idx", ")", "b", "=", "self", ".", ...
Returns bytes from self.data starting at index (self.idx) until terminator character.
[ "Returns", "bytes", "from", "self", ".", "data", "starting", "at", "index", "(", "self", ".", "idx", ")", "until", "terminator", "character", "." ]
a9c145bd087c61dd8fb28a9dfad46d085c8b8290
https://github.com/eweast/BencodePy/blob/a9c145bd087c61dd8fb28a9dfad46d085c8b8290/build/lib/bencodepy/decoder.py#L21-L31
train
Reads bytes from self. data starting at index self. idx until terminator character.
eweast/BencodePy
build/lib/bencodepy/decoder.py
Decoder.__parse
def __parse(self) -> object: """Selects the appropriate method to decode next bencode element and returns the result.""" char = self.data[self.idx: self.idx + 1] if char in [b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'0']: str_len = int(self.__read_to(b':')) r...
python
def __parse(self) -> object: """Selects the appropriate method to decode next bencode element and returns the result.""" char = self.data[self.idx: self.idx + 1] if char in [b'1', b'2', b'3', b'4', b'5', b'6', b'7', b'8', b'9', b'0']: str_len = int(self.__read_to(b':')) r...
[ "def", "__parse", "(", "self", ")", "->", "object", ":", "char", "=", "self", ".", "data", "[", "self", ".", "idx", ":", "self", ".", "idx", "+", "1", "]", "if", "char", "in", "[", "b'1'", ",", "b'2'", ",", "b'3'", ",", "b'4'", ",", "b'5'", "...
Selects the appropriate method to decode next bencode element and returns the result.
[ "Selects", "the", "appropriate", "method", "to", "decode", "next", "bencode", "element", "and", "returns", "the", "result", "." ]
a9c145bd087c61dd8fb28a9dfad46d085c8b8290
https://github.com/eweast/BencodePy/blob/a9c145bd087c61dd8fb28a9dfad46d085c8b8290/build/lib/bencodepy/decoder.py#L33-L50
train
Selects the appropriate method to decode next bencode element and returns the result.
eweast/BencodePy
build/lib/bencodepy/decoder.py
Decoder.decode
def decode(self) -> Iterable: """Start of decode process. Returns final results.""" if self.data[0:1] not in (b'd', b'l'): return self.__wrap_with_tuple() return self.__parse()
python
def decode(self) -> Iterable: """Start of decode process. Returns final results.""" if self.data[0:1] not in (b'd', b'l'): return self.__wrap_with_tuple() return self.__parse()
[ "def", "decode", "(", "self", ")", "->", "Iterable", ":", "if", "self", ".", "data", "[", "0", ":", "1", "]", "not", "in", "(", "b'd'", ",", "b'l'", ")", ":", "return", "self", ".", "__wrap_with_tuple", "(", ")", "return", "self", ".", "__parse", ...
Start of decode process. Returns final results.
[ "Start", "of", "decode", "process", ".", "Returns", "final", "results", "." ]
a9c145bd087c61dd8fb28a9dfad46d085c8b8290
https://github.com/eweast/BencodePy/blob/a9c145bd087c61dd8fb28a9dfad46d085c8b8290/build/lib/bencodepy/decoder.py#L52-L56
train
Start of decode process. Returns final results.
eweast/BencodePy
build/lib/bencodepy/decoder.py
Decoder.__wrap_with_tuple
def __wrap_with_tuple(self) -> tuple: """Returns a tuple of all nested bencode elements.""" l = list() length = len(self.data) while self.idx < length: l.append(self.__parse()) return tuple(l)
python
def __wrap_with_tuple(self) -> tuple: """Returns a tuple of all nested bencode elements.""" l = list() length = len(self.data) while self.idx < length: l.append(self.__parse()) return tuple(l)
[ "def", "__wrap_with_tuple", "(", "self", ")", "->", "tuple", ":", "l", "=", "list", "(", ")", "length", "=", "len", "(", "self", ".", "data", ")", "while", "self", ".", "idx", "<", "length", ":", "l", ".", "append", "(", "self", ".", "__parse", "...
Returns a tuple of all nested bencode elements.
[ "Returns", "a", "tuple", "of", "all", "nested", "bencode", "elements", "." ]
a9c145bd087c61dd8fb28a9dfad46d085c8b8290
https://github.com/eweast/BencodePy/blob/a9c145bd087c61dd8fb28a9dfad46d085c8b8290/build/lib/bencodepy/decoder.py#L58-L64
train
Returns a tuple of all nested bencode elements.
eweast/BencodePy
build/lib/bencodepy/decoder.py
Decoder.__parse_dict
def __parse_dict(self) -> OrderedDict: """Returns an Ordered Dictionary of nested bencode elements.""" self.idx += 1 d = OrderedDict() key_name = None while self.data[self.idx: self.idx + 1] != b'e': if key_name is None: key_name = self.__parse() ...
python
def __parse_dict(self) -> OrderedDict: """Returns an Ordered Dictionary of nested bencode elements.""" self.idx += 1 d = OrderedDict() key_name = None while self.data[self.idx: self.idx + 1] != b'e': if key_name is None: key_name = self.__parse() ...
[ "def", "__parse_dict", "(", "self", ")", "->", "OrderedDict", ":", "self", ".", "idx", "+=", "1", "d", "=", "OrderedDict", "(", ")", "key_name", "=", "None", "while", "self", ".", "data", "[", "self", ".", "idx", ":", "self", ".", "idx", "+", "1", ...
Returns an Ordered Dictionary of nested bencode elements.
[ "Returns", "an", "Ordered", "Dictionary", "of", "nested", "bencode", "elements", "." ]
a9c145bd087c61dd8fb28a9dfad46d085c8b8290
https://github.com/eweast/BencodePy/blob/a9c145bd087c61dd8fb28a9dfad46d085c8b8290/build/lib/bencodepy/decoder.py#L66-L78
train
Returns an OrderedDict of nested bencode elements.
eweast/BencodePy
build/lib/bencodepy/decoder.py
Decoder.__parse_list
def __parse_list(self) -> list: """Returns an list of nested bencode elements.""" self.idx += 1 l = [] while self.data[self.idx: self.idx + 1] != b'e': l.append(self.__parse()) self.idx += 1 return l
python
def __parse_list(self) -> list: """Returns an list of nested bencode elements.""" self.idx += 1 l = [] while self.data[self.idx: self.idx + 1] != b'e': l.append(self.__parse()) self.idx += 1 return l
[ "def", "__parse_list", "(", "self", ")", "->", "list", ":", "self", ".", "idx", "+=", "1", "l", "=", "[", "]", "while", "self", ".", "data", "[", "self", ".", "idx", ":", "self", ".", "idx", "+", "1", "]", "!=", "b'e'", ":", "l", ".", "append...
Returns an list of nested bencode elements.
[ "Returns", "an", "list", "of", "nested", "bencode", "elements", "." ]
a9c145bd087c61dd8fb28a9dfad46d085c8b8290
https://github.com/eweast/BencodePy/blob/a9c145bd087c61dd8fb28a9dfad46d085c8b8290/build/lib/bencodepy/decoder.py#L80-L87
train
Returns an array of nested bencode elements.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/VoiceNode.py
VoiceNode.toLily
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "" children = self.GetChildrenIndexes() total = self.note_total counter = 0 f...
python
def toLily(self): ''' Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code ''' lilystring = "" children = self.GetChildrenIndexes() total = self.note_total counter = 0 f...
[ "def", "toLily", "(", "self", ")", ":", "lilystring", "=", "\"\"", "children", "=", "self", ".", "GetChildrenIndexes", "(", ")", "total", "=", "self", ".", "note_total", "counter", "=", "0", "for", "child", "in", "range", "(", "len", "(", "children", "...
Method which converts the object instance, its attributes and children to a string of lilypond code :return: str of lilypond code
[ "Method", "which", "converts", "the", "object", "instance", "its", "attributes", "and", "children", "to", "a", "string", "of", "lilypond", "code" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/VoiceNode.py#L110-L142
train
Method which converts the object instance its attributes and children to a string of lilypond code.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py
BackwardSearch
def BackwardSearch(cls_type, node, index, depth=0, start_index=0): ''' Helper method which backwards-recursively searches for objects :param cls_type: class type of the object we are in search of :param node: object instance to start at :param index: number of the object to look for e.g <cls_type> n...
python
def BackwardSearch(cls_type, node, index, depth=0, start_index=0): ''' Helper method which backwards-recursively searches for objects :param cls_type: class type of the object we are in search of :param node: object instance to start at :param index: number of the object to look for e.g <cls_type> n...
[ "def", "BackwardSearch", "(", "cls_type", ",", "node", ",", "index", ",", "depth", "=", "0", ",", "start_index", "=", "0", ")", ":", "counter", "=", "depth", "if", "isinstance", "(", "node", ",", "cls_type", ")", ":", "counter", "+=", "1", "if", "cou...
Helper method which backwards-recursively searches for objects :param cls_type: class type of the object we are in search of :param node: object instance to start at :param index: number of the object to look for e.g <cls_type> num 1 :param depth: current depth in the tree :param start_index: index ...
[ "Helper", "method", "which", "backwards", "-", "recursively", "searches", "for", "objects", ":", "param", "cls_type", ":", "class", "type", "of", "the", "object", "we", "are", "in", "search", "of", ":", "param", "node", ":", "object", "instance", "to", "st...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py#L13-L52
train
This method is used to search backwards - recursively for objects of the given type.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py
FindByIndex
def FindByIndex(node, index): ''' Method which finds child according to index. Applies only to nodes whose children are sorted into a dict, so if the current node's children are in a list it will recursively search - similarly if the index is not found in the current node's dictionary indexes. :para...
python
def FindByIndex(node, index): ''' Method which finds child according to index. Applies only to nodes whose children are sorted into a dict, so if the current node's children are in a list it will recursively search - similarly if the index is not found in the current node's dictionary indexes. :para...
[ "def", "FindByIndex", "(", "node", ",", "index", ")", ":", "result", "=", "None", "if", "isinstance", "(", "node", ".", "children", ",", "dict", ")", ":", "result", "=", "node", ".", "GetChild", "(", "index", ")", "if", "result", "is", "None", ":", ...
Method which finds child according to index. Applies only to nodes whose children are sorted into a dict, so if the current node's children are in a list it will recursively search - similarly if the index is not found in the current node's dictionary indexes. :param node: current node to search for :pa...
[ "Method", "which", "finds", "child", "according", "to", "index", ".", "Applies", "only", "to", "nodes", "whose", "children", "are", "sorted", "into", "a", "dict", "so", "if", "the", "current", "node", "s", "children", "are", "in", "a", "list", "it", "wil...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py#L97-L125
train
Method which finds a node in a list according to index.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py
FindPosition
def FindPosition(node, addition, index=0): ''' Method to search for children according to their position in list. Similar functionality to above method, except this is for adding items to the tree according to the nodes limits on children or types of children they can have :param node: current node bein...
python
def FindPosition(node, addition, index=0): ''' Method to search for children according to their position in list. Similar functionality to above method, except this is for adding items to the tree according to the nodes limits on children or types of children they can have :param node: current node bein...
[ "def", "FindPosition", "(", "node", ",", "addition", ",", "index", "=", "0", ")", ":", "if", "node", "is", "None", ":", "return", "None", "if", "type", "(", "addition", ")", "in", "node", ".", "rules", ":", "if", "len", "(", "node", ".", "children"...
Method to search for children according to their position in list. Similar functionality to above method, except this is for adding items to the tree according to the nodes limits on children or types of children they can have :param node: current node being searched :param addition: the thing being added ...
[ "Method", "to", "search", "for", "children", "according", "to", "their", "position", "in", "list", ".", "Similar", "functionality", "to", "above", "method", "except", "this", "is", "for", "adding", "items", "to", "the", "tree", "according", "to", "the", "nod...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py#L128-L177
train
Method to search for children according to their position in list.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py
Node.PopAllChildren
def PopAllChildren(self): ''' Method to remove and return all children of current node :return: list of children ''' indexes = self.GetChildrenIndexes() children = [] for c in indexes: child = self.PopChild(c) children.append(child) ...
python
def PopAllChildren(self): ''' Method to remove and return all children of current node :return: list of children ''' indexes = self.GetChildrenIndexes() children = [] for c in indexes: child = self.PopChild(c) children.append(child) ...
[ "def", "PopAllChildren", "(", "self", ")", ":", "indexes", "=", "self", ".", "GetChildrenIndexes", "(", ")", "children", "=", "[", "]", "for", "c", "in", "indexes", ":", "child", "=", "self", ".", "PopChild", "(", "c", ")", "children", ".", "append", ...
Method to remove and return all children of current node :return: list of children
[ "Method", "to", "remove", "and", "return", "all", "children", "of", "current", "node" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py#L215-L226
train
Method to remove and return all children of current node
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py
Node.ReplaceChild
def ReplaceChild(self, key, item): ''' Method to remove child at <key> and replace it with <item>, then put the child back onto the end of the list :param key: index to position <item> :param item: child object to add :return: ''' if key in self.GetChildrenInde...
python
def ReplaceChild(self, key, item): ''' Method to remove child at <key> and replace it with <item>, then put the child back onto the end of the list :param key: index to position <item> :param item: child object to add :return: ''' if key in self.GetChildrenInde...
[ "def", "ReplaceChild", "(", "self", ",", "key", ",", "item", ")", ":", "if", "key", "in", "self", ".", "GetChildrenIndexes", "(", ")", ":", "node", "=", "self", ".", "GetChild", "(", "key", ")", "children", "=", "node", ".", "GetChildrenIndexes", "(", ...
Method to remove child at <key> and replace it with <item>, then put the child back onto the end of the list :param key: index to position <item> :param item: child object to add :return:
[ "Method", "to", "remove", "child", "at", "<key", ">", "and", "replace", "it", "with", "<item", ">", "then", "put", "the", "child", "back", "onto", "the", "end", "of", "the", "list" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/TreeClasses/BaseTree.py#L240-L256
train
Method to remove a child at a given index and replace it with item.
ariebovenberg/snug
tutorial/composed2.py
handle_errors
def handle_errors(resp): """raise a descriptive exception on a "bad request" response""" if resp.status_code == 400: raise ApiException(json.loads(resp.content).get('message')) return resp
python
def handle_errors(resp): """raise a descriptive exception on a "bad request" response""" if resp.status_code == 400: raise ApiException(json.loads(resp.content).get('message')) return resp
[ "def", "handle_errors", "(", "resp", ")", ":", "if", "resp", ".", "status_code", "==", "400", ":", "raise", "ApiException", "(", "json", ".", "loads", "(", "resp", ".", "content", ")", ".", "get", "(", "'message'", ")", ")", "return", "resp" ]
raise a descriptive exception on a "bad request" response
[ "raise", "a", "descriptive", "exception", "on", "a", "bad", "request", "response" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/tutorial/composed2.py#L14-L18
train
raise an exception on a bad request response
vasilcovsky/pytinypng
pytinypng/pytinypng.py
_process_file
def _process_file(input_file, output_file, apikey): """Shrinks input_file to output_file. This function should be used only inside process_directory. It takes input_file, tries to shrink it and if shrink was successful save compressed image to output_file. Otherwise raise exception. @return compre...
python
def _process_file(input_file, output_file, apikey): """Shrinks input_file to output_file. This function should be used only inside process_directory. It takes input_file, tries to shrink it and if shrink was successful save compressed image to output_file. Otherwise raise exception. @return compre...
[ "def", "_process_file", "(", "input_file", ",", "output_file", ",", "apikey", ")", ":", "bytes_", "=", "read_binary", "(", "input_file", ")", "compressed", "=", "shrink", "(", "bytes_", ",", "apikey", ")", "if", "compressed", ".", "success", "and", "compress...
Shrinks input_file to output_file. This function should be used only inside process_directory. It takes input_file, tries to shrink it and if shrink was successful save compressed image to output_file. Otherwise raise exception. @return compressed: PNGResponse
[ "Shrinks", "input_file", "to", "output_file", "." ]
ac633e4aa41122c49a806f411e43a76d8f73058e
https://github.com/vasilcovsky/pytinypng/blob/ac633e4aa41122c49a806f411e43a76d8f73058e/pytinypng/pytinypng.py#L29-L49
train
This function takes input_file tries to shrink it and saves compressed image to output_file if it fails raise exception.
vasilcovsky/pytinypng
pytinypng/pytinypng.py
process_directory
def process_directory(source, target, apikey, handler, overwrite=False): """Optimize and save png files form source to target directory. @param source: path to input directory @param target: path to output directory @param handler: callback holder, instance of handlers.BaseHandler @param overwrite:...
python
def process_directory(source, target, apikey, handler, overwrite=False): """Optimize and save png files form source to target directory. @param source: path to input directory @param target: path to output directory @param handler: callback holder, instance of handlers.BaseHandler @param overwrite:...
[ "def", "process_directory", "(", "source", ",", "target", ",", "apikey", ",", "handler", ",", "overwrite", "=", "False", ")", ":", "handler", ".", "on_start", "(", ")", "attempts", "=", "defaultdict", "(", "lambda", ":", "0", ")", "input_files", "=", "fi...
Optimize and save png files form source to target directory. @param source: path to input directory @param target: path to output directory @param handler: callback holder, instance of handlers.BaseHandler @param overwrite: boolean flag to allow overwrite already existing files in...
[ "Optimize", "and", "save", "png", "files", "form", "source", "to", "target", "directory", "." ]
ac633e4aa41122c49a806f411e43a76d8f73058e
https://github.com/vasilcovsky/pytinypng/blob/ac633e4aa41122c49a806f411e43a76d8f73058e/pytinypng/pytinypng.py#L52-L104
train
Optimize and save png files form source to target directory.
vasilcovsky/pytinypng
pytinypng/pytinypng.py
_main
def _main(args): """Batch compression. args contains: * input - path to input directory * output - path to output directory or None * apikey - TinyPNG API key * overwrite - boolean flag """ if not args.apikey: print("\nPlease provide TinyPNG API key") print("To obta...
python
def _main(args): """Batch compression. args contains: * input - path to input directory * output - path to output directory or None * apikey - TinyPNG API key * overwrite - boolean flag """ if not args.apikey: print("\nPlease provide TinyPNG API key") print("To obta...
[ "def", "_main", "(", "args", ")", ":", "if", "not", "args", ".", "apikey", ":", "print", "(", "\"\\nPlease provide TinyPNG API key\"", ")", "print", "(", "\"To obtain key visit https://api.tinypng.com/developers\\n\"", ")", "sys", ".", "exit", "(", "1", ")", "inpu...
Batch compression. args contains: * input - path to input directory * output - path to output directory or None * apikey - TinyPNG API key * overwrite - boolean flag
[ "Batch", "compression", "." ]
ac633e4aa41122c49a806f411e43a76d8f73058e
https://github.com/vasilcovsky/pytinypng/blob/ac633e4aa41122c49a806f411e43a76d8f73058e/pytinypng/pytinypng.py#L107-L138
train
Main function for batch compression.
vasilcovsky/pytinypng
pytinypng/pytinypng.py
main
def main(): """Program entry point""" parser = argparse.ArgumentParser() parser.add_argument('input', metavar='INPUT', help='Input directory with PNG files') parser.add_argument('output', nargs='?', metavar='OUTPUT', ...
python
def main(): """Program entry point""" parser = argparse.ArgumentParser() parser.add_argument('input', metavar='INPUT', help='Input directory with PNG files') parser.add_argument('output', nargs='?', metavar='OUTPUT', ...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'input'", ",", "metavar", "=", "'INPUT'", ",", "help", "=", "'Input directory with PNG files'", ")", "parser", ".", "add_argument", ...
Program entry point
[ "Program", "entry", "point" ]
ac633e4aa41122c49a806f411e43a76d8f73058e
https://github.com/vasilcovsky/pytinypng/blob/ac633e4aa41122c49a806f411e43a76d8f73058e/pytinypng/pytinypng.py#L141-L156
train
Entry point for the applet program.
envi-idl/envipyengine
envipyengine/taskengine/engine.py
Engine.task
def task(self, task_name): """ Returns an ENVI Py Engine Task object. See ENVI Py Engine Task for examples. :param task_name: The name of the task to retrieve. :return: An ENVI Py Engine Task object. """ return Task(uri=':'.join((self._engine_name, task_name)), cwd=self....
python
def task(self, task_name): """ Returns an ENVI Py Engine Task object. See ENVI Py Engine Task for examples. :param task_name: The name of the task to retrieve. :return: An ENVI Py Engine Task object. """ return Task(uri=':'.join((self._engine_name, task_name)), cwd=self....
[ "def", "task", "(", "self", ",", "task_name", ")", ":", "return", "Task", "(", "uri", "=", "':'", ".", "join", "(", "(", "self", ".", "_engine_name", ",", "task_name", ")", ")", ",", "cwd", "=", "self", ".", "_cwd", ")" ]
Returns an ENVI Py Engine Task object. See ENVI Py Engine Task for examples. :param task_name: The name of the task to retrieve. :return: An ENVI Py Engine Task object.
[ "Returns", "an", "ENVI", "Py", "Engine", "Task", "object", ".", "See", "ENVI", "Py", "Engine", "Task", "for", "examples", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/taskengine/engine.py#L27-L34
train
Returns an ENVI Engine Task object. See ENVI Engine Task for examples.
envi-idl/envipyengine
envipyengine/taskengine/engine.py
Engine.tasks
def tasks(self): """ Returns a list of all tasks known to the engine. :return: A list of task names. """ task_input = {'taskName': 'QueryTaskCatalog'} output = taskengine.execute(task_input, self._engine_name, cwd=self._cwd) return output['outputParameters']['TAS...
python
def tasks(self): """ Returns a list of all tasks known to the engine. :return: A list of task names. """ task_input = {'taskName': 'QueryTaskCatalog'} output = taskengine.execute(task_input, self._engine_name, cwd=self._cwd) return output['outputParameters']['TAS...
[ "def", "tasks", "(", "self", ")", ":", "task_input", "=", "{", "'taskName'", ":", "'QueryTaskCatalog'", "}", "output", "=", "taskengine", ".", "execute", "(", "task_input", ",", "self", ".", "_engine_name", ",", "cwd", "=", "self", ".", "_cwd", ")", "ret...
Returns a list of all tasks known to the engine. :return: A list of task names.
[ "Returns", "a", "list", "of", "all", "tasks", "known", "to", "the", "engine", "." ]
567b639d6592deec3289f6122a9e3d18f2f98432
https://github.com/envi-idl/envipyengine/blob/567b639d6592deec3289f6122a9e3d18f2f98432/envipyengine/taskengine/engine.py#L37-L45
train
Returns a list of all tasks known to the engine.
ariebovenberg/snug
snug/query.py
execute
def execute(query, auth=None, client=urllib_request.build_opener()): """Execute a query, returning its result Parameters ---------- query: Query[T] The query to resolve auth: ~typing.Tuple[str, str] \ or ~typing.Callable[[Request], Request] or None This may be: * A ...
python
def execute(query, auth=None, client=urllib_request.build_opener()): """Execute a query, returning its result Parameters ---------- query: Query[T] The query to resolve auth: ~typing.Tuple[str, str] \ or ~typing.Callable[[Request], Request] or None This may be: * A ...
[ "def", "execute", "(", "query", ",", "auth", "=", "None", ",", "client", "=", "urllib_request", ".", "build_opener", "(", ")", ")", ":", "exec_fn", "=", "getattr", "(", "type", "(", "query", ")", ",", "'__execute__'", ",", "_default_execute_method", ")", ...
Execute a query, returning its result Parameters ---------- query: Query[T] The query to resolve auth: ~typing.Tuple[str, str] \ or ~typing.Callable[[Request], Request] or None This may be: * A (username, password)-tuple for basic authentication * A callable to ...
[ "Execute", "a", "query", "returning", "its", "result" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/snug/query.py#L192-L218
train
Execute a query returning its result
ariebovenberg/snug
snug/query.py
execute_async
def execute_async(query, auth=None, client=event_loop): """Execute a query asynchronously, returning its result Parameters ---------- query: Query[T] The query to resolve auth: ~typing.Tuple[str, str] \ or ~typing.Callable[[Request], Request] or None This may be: * ...
python
def execute_async(query, auth=None, client=event_loop): """Execute a query asynchronously, returning its result Parameters ---------- query: Query[T] The query to resolve auth: ~typing.Tuple[str, str] \ or ~typing.Callable[[Request], Request] or None This may be: * ...
[ "def", "execute_async", "(", "query", ",", "auth", "=", "None", ",", "client", "=", "event_loop", ")", ":", "exc_fn", "=", "getattr", "(", "type", "(", "query", ")", ",", "'__execute_async__'", ",", "Query", ".", "__execute_async__", ")", "return", "exc_fn...
Execute a query asynchronously, returning its result Parameters ---------- query: Query[T] The query to resolve auth: ~typing.Tuple[str, str] \ or ~typing.Callable[[Request], Request] or None This may be: * A (username, password)-tuple for basic authentication *...
[ "Execute", "a", "query", "asynchronously", "returning", "its", "result" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/snug/query.py#L221-L252
train
Execute a query asynchronously returning its result
blockstack/python-utilitybelt
utilitybelt/entropy.py
dev_random_entropy
def dev_random_entropy(numbytes, fallback_to_urandom=True): """ Reads random bytes from the /dev/random entropy pool. NOTE: /dev/random is a blocking pseudorandom number generator. If the entropy pool runs out, this function will block until more environmental noise is gathered. If ...
python
def dev_random_entropy(numbytes, fallback_to_urandom=True): """ Reads random bytes from the /dev/random entropy pool. NOTE: /dev/random is a blocking pseudorandom number generator. If the entropy pool runs out, this function will block until more environmental noise is gathered. If ...
[ "def", "dev_random_entropy", "(", "numbytes", ",", "fallback_to_urandom", "=", "True", ")", ":", "if", "os", ".", "name", "==", "'nt'", "and", "fallback_to_urandom", ":", "return", "dev_urandom_entropy", "(", "numbytes", ")", "return", "open", "(", "\"/dev/rando...
Reads random bytes from the /dev/random entropy pool. NOTE: /dev/random is a blocking pseudorandom number generator. If the entropy pool runs out, this function will block until more environmental noise is gathered. If entropy re-use is unnacceptable use this over "dev_urandom_entropy"....
[ "Reads", "random", "bytes", "from", "the", "/", "dev", "/", "random", "entropy", "pool", "." ]
13d3502aa1a486c9d775ad2c551fb8e7e48b0d96
https://github.com/blockstack/python-utilitybelt/blob/13d3502aa1a486c9d775ad2c551fb8e7e48b0d96/utilitybelt/entropy.py#L25-L38
train
Reads random bytes from the system s random entropy pool.
blockstack/python-utilitybelt
utilitybelt/entropy.py
secure_randint
def secure_randint(min_value, max_value, system_random=None): """ Return a random integer N such that a <= N <= b. Uses SystemRandom for generating random numbers. (which uses os.urandom(), which pulls from /dev/urandom) """ if not system_random: system_random = random.SystemRandom(...
python
def secure_randint(min_value, max_value, system_random=None): """ Return a random integer N such that a <= N <= b. Uses SystemRandom for generating random numbers. (which uses os.urandom(), which pulls from /dev/urandom) """ if not system_random: system_random = random.SystemRandom(...
[ "def", "secure_randint", "(", "min_value", ",", "max_value", ",", "system_random", "=", "None", ")", ":", "if", "not", "system_random", ":", "system_random", "=", "random", ".", "SystemRandom", "(", ")", "return", "system_random", ".", "randint", "(", "min_val...
Return a random integer N such that a <= N <= b. Uses SystemRandom for generating random numbers. (which uses os.urandom(), which pulls from /dev/urandom)
[ "Return", "a", "random", "integer", "N", "such", "that", "a", "<", "=", "N", "<", "=", "b", "." ]
13d3502aa1a486c9d775ad2c551fb8e7e48b0d96
https://github.com/blockstack/python-utilitybelt/blob/13d3502aa1a486c9d775ad2c551fb8e7e48b0d96/utilitybelt/entropy.py#L41-L49
train
Return a random integer N such that a < = N < = max_value.
ariebovenberg/snug
snug/http.py
_merge_maps
def _merge_maps(m1, m2): """merge two Mapping objects, keeping the type of the first mapping""" return type(m1)(chain(m1.items(), m2.items()))
python
def _merge_maps(m1, m2): """merge two Mapping objects, keeping the type of the first mapping""" return type(m1)(chain(m1.items(), m2.items()))
[ "def", "_merge_maps", "(", "m1", ",", "m2", ")", ":", "return", "type", "(", "m1", ")", "(", "chain", "(", "m1", ".", "items", "(", ")", ",", "m2", ".", "items", "(", ")", ")", ")" ]
merge two Mapping objects, keeping the type of the first mapping
[ "merge", "two", "Mapping", "objects", "keeping", "the", "type", "of", "the", "first", "mapping" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/snug/http.py#L64-L66
train
merge two Mapping objects keeping the type of the first mapping
ariebovenberg/snug
snug/http.py
basic_auth
def basic_auth(credentials): """Create an HTTP basic authentication callable Parameters ---------- credentials: ~typing.Tuple[str, str] The (username, password)-tuple Returns ------- ~typing.Callable[[Request], Request] A callable which adds basic authentication to a :class...
python
def basic_auth(credentials): """Create an HTTP basic authentication callable Parameters ---------- credentials: ~typing.Tuple[str, str] The (username, password)-tuple Returns ------- ~typing.Callable[[Request], Request] A callable which adds basic authentication to a :class...
[ "def", "basic_auth", "(", "credentials", ")", ":", "encoded", "=", "b64encode", "(", "':'", ".", "join", "(", "credentials", ")", ".", "encode", "(", "'ascii'", ")", ")", ".", "decode", "(", ")", "return", "header_adder", "(", "{", "'Authorization'", ":"...
Create an HTTP basic authentication callable Parameters ---------- credentials: ~typing.Tuple[str, str] The (username, password)-tuple Returns ------- ~typing.Callable[[Request], Request] A callable which adds basic authentication to a :class:`Request`.
[ "Create", "an", "HTTP", "basic", "authentication", "callable" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/snug/http.py#L156-L170
train
Create an HTTP basic authentication callable which returns a request object which will be used to add a basic authentication to the request.
ariebovenberg/snug
snug/http.py
Request.with_headers
def with_headers(self, headers): """Create a new request with added headers Parameters ---------- headers: Mapping the headers to add """ return self.replace(headers=_merge_maps(self.headers, headers))
python
def with_headers(self, headers): """Create a new request with added headers Parameters ---------- headers: Mapping the headers to add """ return self.replace(headers=_merge_maps(self.headers, headers))
[ "def", "with_headers", "(", "self", ",", "headers", ")", ":", "return", "self", ".", "replace", "(", "headers", "=", "_merge_maps", "(", "self", ".", "headers", ",", "headers", ")", ")" ]
Create a new request with added headers Parameters ---------- headers: Mapping the headers to add
[ "Create", "a", "new", "request", "with", "added", "headers" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/snug/http.py#L96-L104
train
Create a new request with added headers
ariebovenberg/snug
snug/http.py
Request.with_params
def with_params(self, params): """Create a new request with added query parameters Parameters ---------- params: Mapping the query parameters to add """ return self.replace(params=_merge_maps(self.params, params))
python
def with_params(self, params): """Create a new request with added query parameters Parameters ---------- params: Mapping the query parameters to add """ return self.replace(params=_merge_maps(self.params, params))
[ "def", "with_params", "(", "self", ",", "params", ")", ":", "return", "self", ".", "replace", "(", "params", "=", "_merge_maps", "(", "self", ".", "params", ",", "params", ")", ")" ]
Create a new request with added query parameters Parameters ---------- params: Mapping the query parameters to add
[ "Create", "a", "new", "request", "with", "added", "query", "parameters" ]
4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef
https://github.com/ariebovenberg/snug/blob/4f5cd30e6b7b2c3f0ad3cc10be865bd8900b38ef/snug/http.py#L116-L124
train
Create a new request with added query parameters.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py
AddSlur
def AddSlur(self, item): ''' Very simple method which is used for adding slurs. :param item: :return: ''' if not hasattr(self, "slurs"): self.slurs = [] self.slurs.append(item)
python
def AddSlur(self, item): ''' Very simple method which is used for adding slurs. :param item: :return: ''' if not hasattr(self, "slurs"): self.slurs = [] self.slurs.append(item)
[ "def", "AddSlur", "(", "self", ",", "item", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"slurs\"", ")", ":", "self", ".", "slurs", "=", "[", "]", "self", ".", "slurs", ".", "append", "(", "item", ")" ]
Very simple method which is used for adding slurs. :param item: :return:
[ "Very", "simple", "method", "which", "is", "used", "for", "adding", "slurs", ".", ":", "param", "item", ":", ":", "return", ":" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py#L233-L241
train
Very simple method which is used for adding slurs.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py
GetNotation
def GetNotation(self, id, type): ''' method which searches for notation from <type> list at position <id> :param id: the number to look for - i.e if you're looking for the first one in wrap notation, id will be 0 :param type: post, pre or wrap :return: the notation class searched...
python
def GetNotation(self, id, type): ''' method which searches for notation from <type> list at position <id> :param id: the number to look for - i.e if you're looking for the first one in wrap notation, id will be 0 :param type: post, pre or wrap :return: the notation class searched...
[ "def", "GetNotation", "(", "self", ",", "id", ",", "type", ")", ":", "if", "type", "==", "\"post\"", ":", "if", "(", "id", "==", "-", "1", "and", "len", "(", "self", ".", "postnotation", ")", ">", "0", ")", "or", "(", "id", "!=", "-", "1", "a...
method which searches for notation from <type> list at position <id> :param id: the number to look for - i.e if you're looking for the first one in wrap notation, id will be 0 :param type: post, pre or wrap :return: the notation class searched for or none
[ "method", "which", "searches", "for", "notation", "from", "<type", ">", "list", "at", "position", "<id", ">", ":", "param", "id", ":", "the", "number", "to", "look", "for", "-", "i", ".", "e", "if", "you", "re", "looking", "for", "the", "first", "one...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py#L246-L267
train
method which searches for the notation class at the given id and type.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py
GetClosingNotationLilies
def GetClosingNotationLilies(self): ''' Converts notation in closing_notation into a lilypond string. :return: str ''' lstring = "" for notation in self.closing_notation: result = notation.toLily() if type(result) == list: result = ...
python
def GetClosingNotationLilies(self): ''' Converts notation in closing_notation into a lilypond string. :return: str ''' lstring = "" for notation in self.closing_notation: result = notation.toLily() if type(result) == list: result = ...
[ "def", "GetClosingNotationLilies", "(", "self", ")", ":", "lstring", "=", "\"\"", "for", "notation", "in", "self", ".", "closing_notation", ":", "result", "=", "notation", ".", "toLily", "(", ")", "if", "type", "(", "result", ")", "==", "list", ":", "res...
Converts notation in closing_notation into a lilypond string. :return: str
[ "Converts", "notation", "in", "closing_notation", "into", "a", "lilypond", "string", ".", ":", "return", ":", "str" ]
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py#L275-L286
train
Converts the closing_notation into a lilypond string.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py
addNotation
def addNotation(self, obj): ''' Method to add new notation. Use this rather than adding directly so new classes can be added automatically without needing to know which list to add it to in the main code. :param obj: the object to add :return: None ''' add = True ...
python
def addNotation(self, obj): ''' Method to add new notation. Use this rather than adding directly so new classes can be added automatically without needing to know which list to add it to in the main code. :param obj: the object to add :return: None ''' add = True ...
[ "def", "addNotation", "(", "self", ",", "obj", ")", ":", "add", "=", "True", "wrap_notation", "=", "[", "Arpeggiate", ",", "NonArpeggiate", ",", "Slide", ",", "Glissando", ",", "Mark", ".", "Caesura", ",", "Mark", ".", "BreathMark", ",", "GraceNote", "]"...
Method to add new notation. Use this rather than adding directly so new classes can be added automatically without needing to know which list to add it to in the main code. :param obj: the object to add :return: None
[ "Method", "to", "add", "new", "notation", ".", "Use", "this", "rather", "than", "adding", "directly", "so", "new", "classes", "can", "be", "added", "automatically", "without", "needing", "to", "know", "which", "list", "to", "add", "it", "to", "in", "the", ...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py#L288-L337
train
Method to add new notation to the internal list.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py
SetType
def SetType(self, vtype): ''' Sets the type, i.e duration of the note. Types are given as keys inside options :param vtype: str - see keys in options for full list :return: None, side effects modifying the class ''' self.val_type = vtype options = { "1...
python
def SetType(self, vtype): ''' Sets the type, i.e duration of the note. Types are given as keys inside options :param vtype: str - see keys in options for full list :return: None, side effects modifying the class ''' self.val_type = vtype options = { "1...
[ "def", "SetType", "(", "self", ",", "vtype", ")", ":", "self", ".", "val_type", "=", "vtype", "options", "=", "{", "\"128th\"", ":", "128", ",", "\"64th\"", ":", "64", ",", "\"32nd\"", ":", "32", ",", "\"16th\"", ":", "16", ",", "\"eighth\"", ":", ...
Sets the type, i.e duration of the note. Types are given as keys inside options :param vtype: str - see keys in options for full list :return: None, side effects modifying the class
[ "Sets", "the", "type", "i", ".", "e", "duration", "of", "the", "note", ".", "Types", "are", "given", "as", "keys", "inside", "options", ":", "param", "vtype", ":", "str", "-", "see", "keys", "in", "options", "for", "full", "list", ":", "return", ":",...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py#L339-L359
train
Sets the type of the class.
Godley/MuseParse
MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py
CheckDivisions
def CheckDivisions(self, measure_div): ''' Method which is called from voice/measure to update the divisions for each note which are stored at measure level, but needed at lilypond time to figure out lilypond notation :param measure_div: number of divisions per note. Indicator of how big...
python
def CheckDivisions(self, measure_div): ''' Method which is called from voice/measure to update the divisions for each note which are stored at measure level, but needed at lilypond time to figure out lilypond notation :param measure_div: number of divisions per note. Indicator of how big...
[ "def", "CheckDivisions", "(", "self", ",", "measure_div", ")", ":", "if", "hasattr", "(", "self", ",", "\"val_type\"", ")", ":", "self", ".", "divisions", "=", "1", "else", ":", "self", ".", "divisions", "=", "measure_div" ]
Method which is called from voice/measure to update the divisions for each note which are stored at measure level, but needed at lilypond time to figure out lilypond notation :param measure_div: number of divisions per note. Indicator of how big or small a quarter note is :return: None, side eff...
[ "Method", "which", "is", "called", "from", "voice", "/", "measure", "to", "update", "the", "divisions", "for", "each", "note", "which", "are", "stored", "at", "measure", "level", "but", "needed", "at", "lilypond", "time", "to", "figure", "out", "lilypond", ...
23cecafa1fdc0f2d6a87760553572b459f3c9904
https://github.com/Godley/MuseParse/blob/23cecafa1fdc0f2d6a87760553572b459f3c9904/MuseParse/classes/ObjectHierarchy/ItemClasses/Note.py#L361-L371
train
Method which is called by voice and measure to update the divisions of each note in the measure level.
azaghal/pydenticon
pydenticon/__init__.py
Generator._get_bit
def _get_bit(self, n, hash_bytes): """ Determines if the n-th bit of passed bytes is 1 or 0. Arguments: hash_bytes - List of hash byte values for which the n-th bit value should be checked. Each element of the list should be an integer from 0 to 255. Retu...
python
def _get_bit(self, n, hash_bytes): """ Determines if the n-th bit of passed bytes is 1 or 0. Arguments: hash_bytes - List of hash byte values for which the n-th bit value should be checked. Each element of the list should be an integer from 0 to 255. Retu...
[ "def", "_get_bit", "(", "self", ",", "n", ",", "hash_bytes", ")", ":", "if", "hash_bytes", "[", "n", "//", "8", "]", ">>", "int", "(", "8", "-", "(", "(", "n", "%", "8", ")", "+", "1", ")", ")", "&", "1", "==", "1", ":", "return", "True", ...
Determines if the n-th bit of passed bytes is 1 or 0. Arguments: hash_bytes - List of hash byte values for which the n-th bit value should be checked. Each element of the list should be an integer from 0 to 255. Returns: True if the bit is 1. False if the bit ...
[ "Determines", "if", "the", "n", "-", "th", "bit", "of", "passed", "bytes", "is", "1", "or", "0", "." ]
002ad10fd58adedfb465b5ef96eacbe6a595c2ac
https://github.com/azaghal/pydenticon/blob/002ad10fd58adedfb465b5ef96eacbe6a595c2ac/pydenticon/__init__.py#L88-L106
train
Determines if the n - th bit of passed bytes is 1 or 0.
azaghal/pydenticon
pydenticon/__init__.py
Generator._generate_matrix
def _generate_matrix(self, hash_bytes): """ Generates matrix that describes which blocks should be coloured. Arguments: hash_bytes - List of hash byte values for which the identicon is being generated. Each element of the list should be an integer from 0 to 255. ...
python
def _generate_matrix(self, hash_bytes): """ Generates matrix that describes which blocks should be coloured. Arguments: hash_bytes - List of hash byte values for which the identicon is being generated. Each element of the list should be an integer from 0 to 255. ...
[ "def", "_generate_matrix", "(", "self", ",", "hash_bytes", ")", ":", "# Since the identicon needs to be symmetric, we'll need to work on half", "# the columns (rounded-up), and reflect where necessary.", "half_columns", "=", "self", ".", "columns", "//", "2", "+", "self", ".", ...
Generates matrix that describes which blocks should be coloured. Arguments: hash_bytes - List of hash byte values for which the identicon is being generated. Each element of the list should be an integer from 0 to 255. Returns: List of rows, where each element i...
[ "Generates", "matrix", "that", "describes", "which", "blocks", "should", "be", "coloured", "." ]
002ad10fd58adedfb465b5ef96eacbe6a595c2ac
https://github.com/azaghal/pydenticon/blob/002ad10fd58adedfb465b5ef96eacbe6a595c2ac/pydenticon/__init__.py#L108-L148
train
Generates the matrix that describes which blocks should be coloured.
azaghal/pydenticon
pydenticon/__init__.py
Generator._data_to_digest_byte_list
def _data_to_digest_byte_list(self, data): """ Creates digest of data, returning it as a list where every element is a single byte of digest (an integer between 0 and 255). No digest will be calculated on the data if the passed data is already a valid hex string representation o...
python
def _data_to_digest_byte_list(self, data): """ Creates digest of data, returning it as a list where every element is a single byte of digest (an integer between 0 and 255). No digest will be calculated on the data if the passed data is already a valid hex string representation o...
[ "def", "_data_to_digest_byte_list", "(", "self", ",", "data", ")", ":", "# If data seems to provide identical amount of entropy as digest, it", "# could be a hex digest already.", "if", "len", "(", "data", ")", "//", "2", "==", "self", ".", "digest_entropy", "//", "8", ...
Creates digest of data, returning it as a list where every element is a single byte of digest (an integer between 0 and 255). No digest will be calculated on the data if the passed data is already a valid hex string representation of digest, and the passed value will be used as digest i...
[ "Creates", "digest", "of", "data", "returning", "it", "as", "a", "list", "where", "every", "element", "is", "a", "single", "byte", "of", "digest", "(", "an", "integer", "between", "0", "and", "255", ")", "." ]
002ad10fd58adedfb465b5ef96eacbe6a595c2ac
https://github.com/azaghal/pydenticon/blob/002ad10fd58adedfb465b5ef96eacbe6a595c2ac/pydenticon/__init__.py#L150-L185
train
Creates a digest of data returning it as a list where every element is a single byte of digest.
azaghal/pydenticon
pydenticon/__init__.py
Generator._generate_image
def _generate_image(self, matrix, width, height, padding, foreground, background, image_format): """ Generates an identicon image in requested image format out of the passed block matrix, with the requested width, height, padding, foreground colour, background colour, and image format. ...
python
def _generate_image(self, matrix, width, height, padding, foreground, background, image_format): """ Generates an identicon image in requested image format out of the passed block matrix, with the requested width, height, padding, foreground colour, background colour, and image format. ...
[ "def", "_generate_image", "(", "self", ",", "matrix", ",", "width", ",", "height", ",", "padding", ",", "foreground", ",", "background", ",", "image_format", ")", ":", "# Set-up a new image object, setting the background to provided value.", "image", "=", "Image", "."...
Generates an identicon image in requested image format out of the passed block matrix, with the requested width, height, padding, foreground colour, background colour, and image format. Arguments: matrix - Matrix describing which blocks in the identicon should be painted wi...
[ "Generates", "an", "identicon", "image", "in", "requested", "image", "format", "out", "of", "the", "passed", "block", "matrix", "with", "the", "requested", "width", "height", "padding", "foreground", "colour", "background", "colour", "and", "image", "format", "....
002ad10fd58adedfb465b5ef96eacbe6a595c2ac
https://github.com/azaghal/pydenticon/blob/002ad10fd58adedfb465b5ef96eacbe6a595c2ac/pydenticon/__init__.py#L187-L261
train
Generate an image from the passed matrix width height padding foreground colour background and image format.
azaghal/pydenticon
pydenticon/__init__.py
Generator._generate_ascii
def _generate_ascii(self, matrix, foreground, background): """ Generates an identicon "image" in the ASCII format. The image will just output the matrix used to generate the identicon. Arguments: matrix - Matrix describing which blocks in the identicon should be pai...
python
def _generate_ascii(self, matrix, foreground, background): """ Generates an identicon "image" in the ASCII format. The image will just output the matrix used to generate the identicon. Arguments: matrix - Matrix describing which blocks in the identicon should be pai...
[ "def", "_generate_ascii", "(", "self", ",", "matrix", ",", "foreground", ",", "background", ")", ":", "return", "\"\\n\"", ".", "join", "(", "[", "\"\"", ".", "join", "(", "[", "foreground", "if", "cell", "else", "background", "for", "cell", "in", "row",...
Generates an identicon "image" in the ASCII format. The image will just output the matrix used to generate the identicon. Arguments: matrix - Matrix describing which blocks in the identicon should be painted with foreground (background if inverted) colour. foreground - C...
[ "Generates", "an", "identicon", "image", "in", "the", "ASCII", "format", ".", "The", "image", "will", "just", "output", "the", "matrix", "used", "to", "generate", "the", "identicon", "." ]
002ad10fd58adedfb465b5ef96eacbe6a595c2ac
https://github.com/azaghal/pydenticon/blob/002ad10fd58adedfb465b5ef96eacbe6a595c2ac/pydenticon/__init__.py#L263-L285
train
Generates an ASCII image from the matrix.
azaghal/pydenticon
pydenticon/__init__.py
Generator.generate
def generate(self, data, width, height, padding=(0, 0, 0, 0), output_format="png", inverted=False): """ Generates an identicon image with requested width, height, padding, and output format, optionally inverting the colours in the indeticon (swapping background and foreground colours) if...
python
def generate(self, data, width, height, padding=(0, 0, 0, 0), output_format="png", inverted=False): """ Generates an identicon image with requested width, height, padding, and output format, optionally inverting the colours in the indeticon (swapping background and foreground colours) if...
[ "def", "generate", "(", "self", ",", "data", ",", "width", ",", "height", ",", "padding", "=", "(", "0", ",", "0", ",", "0", ",", "0", ")", ",", "output_format", "=", "\"png\"", ",", "inverted", "=", "False", ")", ":", "# Calculate the digest, and get ...
Generates an identicon image with requested width, height, padding, and output format, optionally inverting the colours in the indeticon (swapping background and foreground colours) if requested. Arguments: data - Hashed or raw data that will be used for generating the iden...
[ "Generates", "an", "identicon", "image", "with", "requested", "width", "height", "padding", "and", "output", "format", "optionally", "inverting", "the", "colours", "in", "the", "indeticon", "(", "swapping", "background", "and", "foreground", "colours", ")", "if", ...
002ad10fd58adedfb465b5ef96eacbe6a595c2ac
https://github.com/azaghal/pydenticon/blob/002ad10fd58adedfb465b5ef96eacbe6a595c2ac/pydenticon/__init__.py#L287-L341
train
Generates an identicon image with the given data width height padding and output_format.
eclipse/unide.python
src/unide/util.py
local_timezone
def local_timezone(value): """Add the local timezone to `value` to make it aware.""" if hasattr(value, "tzinfo") and value.tzinfo is None: return value.replace(tzinfo=dateutil.tz.tzlocal()) return value
python
def local_timezone(value): """Add the local timezone to `value` to make it aware.""" if hasattr(value, "tzinfo") and value.tzinfo is None: return value.replace(tzinfo=dateutil.tz.tzlocal()) return value
[ "def", "local_timezone", "(", "value", ")", ":", "if", "hasattr", "(", "value", ",", "\"tzinfo\"", ")", "and", "value", ".", "tzinfo", "is", "None", ":", "return", "value", ".", "replace", "(", "tzinfo", "=", "dateutil", ".", "tz", ".", "tzlocal", "(",...
Add the local timezone to `value` to make it aware.
[ "Add", "the", "local", "timezone", "to", "value", "to", "make", "it", "aware", "." ]
b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493
https://github.com/eclipse/unide.python/blob/b82e6a0bf7cc44a463c5d7cdb3d2199f8320c493/src/unide/util.py#L37-L41
train
Add the local timezone to value to make it aware.