repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
tonyseek/html5lib-truncation | html5lib_truncation/utils.py | truncate_sentence | def truncate_sentence(text, max_chars, break_words=False, padding=0):
"""Truncates a sentence.
:param max_chars: The maximum characters of truncated sentence.
:param break_words: If you wish to truncate given sentence strictly even
if it breaks a word, set it to ``True``. It default... | python | def truncate_sentence(text, max_chars, break_words=False, padding=0):
"""Truncates a sentence.
:param max_chars: The maximum characters of truncated sentence.
:param break_words: If you wish to truncate given sentence strictly even
if it breaks a word, set it to ``True``. It default... | [
"def",
"truncate_sentence",
"(",
"text",
",",
"max_chars",
",",
"break_words",
"=",
"False",
",",
"padding",
"=",
"0",
")",
":",
"if",
"break_words",
":",
"return",
"text",
"[",
":",
"-",
"abs",
"(",
"max_chars",
"-",
"len",
"(",
"text",
")",
")",
"-... | Truncates a sentence.
:param max_chars: The maximum characters of truncated sentence.
:param break_words: If you wish to truncate given sentence strictly even
if it breaks a word, set it to ``True``. It defaults
to ``False`` which means truncating given sentence
... | [
"Truncates",
"a",
"sentence",
"."
] | train | https://github.com/tonyseek/html5lib-truncation/blob/b5551e345e583d04dbdf6b97dc2a43a266eec8d6/html5lib_truncation/utils.py#L4-L29 |
quasipedia/swaggery | examples/async/async.py | AlwaysWin.always_win | def always_win(cls, request) -> [(200, 'Ok', String)]:
'''Perform an always succeeding task.'''
task_id = uuid4().hex.upper()[:5]
log.info('Starting always OK task {}'.format(task_id))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
log.info('Finished always OK t... | python | def always_win(cls, request) -> [(200, 'Ok', String)]:
'''Perform an always succeeding task.'''
task_id = uuid4().hex.upper()[:5]
log.info('Starting always OK task {}'.format(task_id))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
log.info('Finished always OK t... | [
"def",
"always_win",
"(",
"cls",
",",
"request",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"String",
")",
"]",
":",
"task_id",
"=",
"uuid4",
"(",
")",
".",
"hex",
".",
"upper",
"(",
")",
"[",
":",
"5",
"]",
"log",
".",
"info",
"(",
"'Star... | Perform an always succeeding task. | [
"Perform",
"an",
"always",
"succeeding",
"task",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/examples/async/async.py#L49-L57 |
quasipedia/swaggery | examples/async/async.py | AlwaysFail.always_fail | def always_fail(cls, request) -> [
(200, 'Ok', String),
(406, 'Not Acceptable', Void)]:
'''Perform an always failing task.'''
task_id = uuid4().hex.upper()[:5]
log.info('Starting always FAILING task {}'.format(task_id))
for i in range(randint(0, MAX_LOOP_DURATION)... | python | def always_fail(cls, request) -> [
(200, 'Ok', String),
(406, 'Not Acceptable', Void)]:
'''Perform an always failing task.'''
task_id = uuid4().hex.upper()[:5]
log.info('Starting always FAILING task {}'.format(task_id))
for i in range(randint(0, MAX_LOOP_DURATION)... | [
"def",
"always_fail",
"(",
"cls",
",",
"request",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"String",
")",
",",
"(",
"406",
",",
"'Not Acceptable'",
",",
"Void",
")",
"]",
":",
"task_id",
"=",
"uuid4",
"(",
")",
".",
"hex",
".",
"upper",
"(",... | Perform an always failing task. | [
"Perform",
"an",
"always",
"failing",
"task",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/examples/async/async.py#L68-L77 |
quasipedia/swaggery | examples/async/async.py | Fibonacci.fibonacci | def fibonacci(cls, request,
limit: (Ptypes.path,
Integer('Upper limit of the series'))) -> [
(200, 'Ok', FibonacciFragment)]:
'''Return Fibonacci sequence whose last number is <= limit.'''
def fibonacci_generator():
last_two = (0, 1)
... | python | def fibonacci(cls, request,
limit: (Ptypes.path,
Integer('Upper limit of the series'))) -> [
(200, 'Ok', FibonacciFragment)]:
'''Return Fibonacci sequence whose last number is <= limit.'''
def fibonacci_generator():
last_two = (0, 1)
... | [
"def",
"fibonacci",
"(",
"cls",
",",
"request",
",",
"limit",
":",
"(",
"Ptypes",
".",
"path",
",",
"Integer",
"(",
"'Upper limit of the series'",
")",
")",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"FibonacciFragment",
")",
"]",
":",
"def",
"fibon... | Return Fibonacci sequence whose last number is <= limit. | [
"Return",
"Fibonacci",
"sequence",
"whose",
"last",
"number",
"is",
"<",
"=",
"limit",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/examples/async/async.py#L106-L119 |
quasipedia/swaggery | examples/async/async.py | QueryEcho.query_echo | def query_echo(cls, request,
foo: (Ptypes.query, String('A query parameter'))) -> [
(200, 'Ok', String)]:
'''Echo the query parameter.'''
log.info('Echoing query param, value is: {}'.format(foo))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
... | python | def query_echo(cls, request,
foo: (Ptypes.query, String('A query parameter'))) -> [
(200, 'Ok', String)]:
'''Echo the query parameter.'''
log.info('Echoing query param, value is: {}'.format(foo))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
... | [
"def",
"query_echo",
"(",
"cls",
",",
"request",
",",
"foo",
":",
"(",
"Ptypes",
".",
"query",
",",
"String",
"(",
"'A query parameter'",
")",
")",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"String",
")",
"]",
":",
"log",
".",
"info",
"(",
"'... | Echo the query parameter. | [
"Echo",
"the",
"query",
"parameter",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/examples/async/async.py#L130-L138 |
quasipedia/swaggery | examples/async/async.py | BodyEcho.body_echo | def body_echo(cls, request,
foo: (Ptypes.body, String('A body parameter'))) -> [
(200, 'Ok', String)]:
'''Echo the body parameter.'''
log.info('Echoing body param, value is: {}'.format(foo))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
ms... | python | def body_echo(cls, request,
foo: (Ptypes.body, String('A body parameter'))) -> [
(200, 'Ok', String)]:
'''Echo the body parameter.'''
log.info('Echoing body param, value is: {}'.format(foo))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
ms... | [
"def",
"body_echo",
"(",
"cls",
",",
"request",
",",
"foo",
":",
"(",
"Ptypes",
".",
"body",
",",
"String",
"(",
"'A body parameter'",
")",
")",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"String",
")",
"]",
":",
"log",
".",
"info",
"(",
"'Ech... | Echo the body parameter. | [
"Echo",
"the",
"body",
"parameter",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/examples/async/async.py#L149-L157 |
quasipedia/swaggery | examples/async/async.py | HeaderEcho.header_echo | def header_echo(cls, request,
api_key: (Ptypes.header, String('API key'))) -> [
(200, 'Ok', String)]:
'''Echo the header parameter.'''
log.info('Echoing header param, value is: {}'.format(api_key))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
... | python | def header_echo(cls, request,
api_key: (Ptypes.header, String('API key'))) -> [
(200, 'Ok', String)]:
'''Echo the header parameter.'''
log.info('Echoing header param, value is: {}'.format(api_key))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
... | [
"def",
"header_echo",
"(",
"cls",
",",
"request",
",",
"api_key",
":",
"(",
"Ptypes",
".",
"header",
",",
"String",
"(",
"'API key'",
")",
")",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"String",
")",
"]",
":",
"log",
".",
"info",
"(",
"'Echo... | Echo the header parameter. | [
"Echo",
"the",
"header",
"parameter",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/examples/async/async.py#L168-L176 |
quasipedia/swaggery | examples/async/async.py | FormEcho.form_echo | def form_echo(cls, request,
foo: (Ptypes.form, String('A form parameter'))) -> [
(200, 'Ok', String)]:
'''Echo the form parameter.'''
log.info('Echoing form param, value is: {}'.format(foo))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
ms... | python | def form_echo(cls, request,
foo: (Ptypes.form, String('A form parameter'))) -> [
(200, 'Ok', String)]:
'''Echo the form parameter.'''
log.info('Echoing form param, value is: {}'.format(foo))
for i in range(randint(0, MAX_LOOP_DURATION)):
yield
ms... | [
"def",
"form_echo",
"(",
"cls",
",",
"request",
",",
"foo",
":",
"(",
"Ptypes",
".",
"form",
",",
"String",
"(",
"'A form parameter'",
")",
")",
")",
"->",
"[",
"(",
"200",
",",
"'Ok'",
",",
"String",
")",
"]",
":",
"log",
".",
"info",
"(",
"'Ech... | Echo the form parameter. | [
"Echo",
"the",
"form",
"parameter",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/examples/async/async.py#L187-L195 |
christophercrouzet/nani | nani.py | resolve | def resolve(data_type, name=None, listify_default=False):
"""Retrieve the properties for a given data type.
This is the main routine where most of the work is done. It converts
Nani's data types into properties that can be used to define a new NumPy
array and to wrap it into a view object.
Use :fu... | python | def resolve(data_type, name=None, listify_default=False):
"""Retrieve the properties for a given data type.
This is the main routine where most of the work is done. It converts
Nani's data types into properties that can be used to define a new NumPy
array and to wrap it into a view object.
Use :fu... | [
"def",
"resolve",
"(",
"data_type",
",",
"name",
"=",
"None",
",",
"listify_default",
"=",
"False",
")",
":",
"data_type",
"=",
"_consolidate",
"(",
"data_type",
")",
"return",
"Nani",
"(",
"dtype",
"=",
"numpy",
".",
"dtype",
"(",
"_resolve_dtype",
"(",
... | Retrieve the properties for a given data type.
This is the main routine where most of the work is done. It converts
Nani's data types into properties that can be used to define a new NumPy
array and to wrap it into a view object.
Use :func:`validate` to check if the input data type is well-formed.
... | [
"Retrieve",
"the",
"properties",
"for",
"a",
"given",
"data",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L619-L669 |
christophercrouzet/nani | nani.py | _validate | def _validate(data_type, parent_path):
"""Implementation for the `validate` function."""
if isinstance(data_type, _CLASS_TYPES):
raise TypeError(
"The data type is expected to be an instance object, but got the "
"type '%s' instead." % (_format_type(data_type),))
base = _fin... | python | def _validate(data_type, parent_path):
"""Implementation for the `validate` function."""
if isinstance(data_type, _CLASS_TYPES):
raise TypeError(
"The data type is expected to be an instance object, but got the "
"type '%s' instead." % (_format_type(data_type),))
base = _fin... | [
"def",
"_validate",
"(",
"data_type",
",",
"parent_path",
")",
":",
"if",
"isinstance",
"(",
"data_type",
",",
"_CLASS_TYPES",
")",
":",
"raise",
"TypeError",
"(",
"\"The data type is expected to be an instance object, but got the \"",
"\"type '%s' instead.\"",
"%",
"(",
... | Implementation for the `validate` function. | [
"Implementation",
"for",
"the",
"validate",
"function",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L765-L885 |
christophercrouzet/nani | nani.py | _consolidate | def _consolidate(data_type):
"""Enforce the structure of the data type.
Specifically, ensure that if a field is defined as a generic tuple, then it
will be converted into an instance of `Field`.
"""
if isinstance(data_type, _ATOMIC):
out = data_type
elif isinstance(data_type, Array):
... | python | def _consolidate(data_type):
"""Enforce the structure of the data type.
Specifically, ensure that if a field is defined as a generic tuple, then it
will be converted into an instance of `Field`.
"""
if isinstance(data_type, _ATOMIC):
out = data_type
elif isinstance(data_type, Array):
... | [
"def",
"_consolidate",
"(",
"data_type",
")",
":",
"if",
"isinstance",
"(",
"data_type",
",",
"_ATOMIC",
")",
":",
"out",
"=",
"data_type",
"elif",
"isinstance",
"(",
"data_type",
",",
"Array",
")",
":",
"element_type",
"=",
"_consolidate",
"(",
"data_type",... | Enforce the structure of the data type.
Specifically, ensure that if a field is defined as a generic tuple, then it
will be converted into an instance of `Field`. | [
"Enforce",
"the",
"structure",
"of",
"the",
"data",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L888-L907 |
christophercrouzet/nani | nani.py | _resolve_dtype | def _resolve_dtype(data_type):
"""Retrieve the corresponding NumPy's `dtype` for a given data type."""
if isinstance(data_type, _FIXED_ATOMIC):
out = _get_atomic_dtype(data_type)
elif isinstance(data_type, _FLEXIBLE_ATOMIC):
out = (_get_atomic_dtype(data_type), data_type.length)
elif isi... | python | def _resolve_dtype(data_type):
"""Retrieve the corresponding NumPy's `dtype` for a given data type."""
if isinstance(data_type, _FIXED_ATOMIC):
out = _get_atomic_dtype(data_type)
elif isinstance(data_type, _FLEXIBLE_ATOMIC):
out = (_get_atomic_dtype(data_type), data_type.length)
elif isi... | [
"def",
"_resolve_dtype",
"(",
"data_type",
")",
":",
"if",
"isinstance",
"(",
"data_type",
",",
"_FIXED_ATOMIC",
")",
":",
"out",
"=",
"_get_atomic_dtype",
"(",
"data_type",
")",
"elif",
"isinstance",
"(",
"data_type",
",",
"_FLEXIBLE_ATOMIC",
")",
":",
"out",... | Retrieve the corresponding NumPy's `dtype` for a given data type. | [
"Retrieve",
"the",
"corresponding",
"NumPy",
"s",
"dtype",
"for",
"a",
"given",
"data",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L910-L929 |
christophercrouzet/nani | nani.py | _resolve_default | def _resolve_default(data_type, listify=False):
"""Retrieve the default value for a given data type."""
if isinstance(data_type, _ATOMIC):
# A Python's object type needs to be left as is instead of being
# wrapped into a NumPy type.
out = (data_type.default if isinstance(data_type, Objec... | python | def _resolve_default(data_type, listify=False):
"""Retrieve the default value for a given data type."""
if isinstance(data_type, _ATOMIC):
# A Python's object type needs to be left as is instead of being
# wrapped into a NumPy type.
out = (data_type.default if isinstance(data_type, Objec... | [
"def",
"_resolve_default",
"(",
"data_type",
",",
"listify",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"data_type",
",",
"_ATOMIC",
")",
":",
"# A Python's object type needs to be left as is instead of being",
"# wrapped into a NumPy type.",
"out",
"=",
"(",
"dat... | Retrieve the default value for a given data type. | [
"Retrieve",
"the",
"default",
"value",
"for",
"a",
"given",
"data",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L932-L961 |
christophercrouzet/nani | nani.py | _resolve_view | def _resolve_view(data_type):
"""Retrieve the view for a given data type.
Only one view class is returned, that is the one representing the root data
type, but more class objects might be dynamically created if the input
data type has nested elements, such as for the `Array` and `Structure`
types.
... | python | def _resolve_view(data_type):
"""Retrieve the view for a given data type.
Only one view class is returned, that is the one representing the root data
type, but more class objects might be dynamically created if the input
data type has nested elements, such as for the `Array` and `Structure`
types.
... | [
"def",
"_resolve_view",
"(",
"data_type",
")",
":",
"view",
"=",
"getattr",
"(",
"data_type",
",",
"'view'",
",",
"None",
")",
"if",
"view",
"is",
"not",
"None",
":",
"return",
"view",
"if",
"isinstance",
"(",
"data_type",
",",
"_ATOMIC",
")",
":",
"ou... | Retrieve the view for a given data type.
Only one view class is returned, that is the one representing the root data
type, but more class objects might be dynamically created if the input
data type has nested elements, such as for the `Array` and `Structure`
types.
The default behaviour of dynamic... | [
"Retrieve",
"the",
"view",
"for",
"a",
"given",
"data",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L964-L986 |
christophercrouzet/nani | nani.py | _define_array_view | def _define_array_view(data_type):
"""Define a new view object for a `Array` type."""
element_type = data_type.element_type
element_view = _resolve_view(element_type)
if element_view is None:
mixins = (_DirectArrayViewMixin,)
attributes = _get_mixin_attributes(mixins)
elif isinstance... | python | def _define_array_view(data_type):
"""Define a new view object for a `Array` type."""
element_type = data_type.element_type
element_view = _resolve_view(element_type)
if element_view is None:
mixins = (_DirectArrayViewMixin,)
attributes = _get_mixin_attributes(mixins)
elif isinstance... | [
"def",
"_define_array_view",
"(",
"data_type",
")",
":",
"element_type",
"=",
"data_type",
".",
"element_type",
"element_view",
"=",
"_resolve_view",
"(",
"element_type",
")",
"if",
"element_view",
"is",
"None",
":",
"mixins",
"=",
"(",
"_DirectArrayViewMixin",
",... | Define a new view object for a `Array` type. | [
"Define",
"a",
"new",
"view",
"object",
"for",
"a",
"Array",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L989-L1010 |
christophercrouzet/nani | nani.py | _define_structure_view | def _define_structure_view(data_type):
"""Define a new view object for a `Structure` type."""
def define_getter(field_index, field_type, field_view):
if field_view is None:
def getter(self):
return self._data[field_index]
elif isinstance(field_type, _ATOMIC):
... | python | def _define_structure_view(data_type):
"""Define a new view object for a `Structure` type."""
def define_getter(field_index, field_type, field_view):
if field_view is None:
def getter(self):
return self._data[field_index]
elif isinstance(field_type, _ATOMIC):
... | [
"def",
"_define_structure_view",
"(",
"data_type",
")",
":",
"def",
"define_getter",
"(",
"field_index",
",",
"field_type",
",",
"field_view",
")",
":",
"if",
"field_view",
"is",
"None",
":",
"def",
"getter",
"(",
"self",
")",
":",
"return",
"self",
".",
"... | Define a new view object for a `Structure` type. | [
"Define",
"a",
"new",
"view",
"object",
"for",
"a",
"Structure",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1013-L1048 |
christophercrouzet/nani | nani.py | _get_mixin_attributes | def _get_mixin_attributes(mixins):
"""Retrieve the attributes for a given set of mixin classes.
The attributes of each mixin class are being merged into a single
dictionary.
"""
return {attribute: mixin.__dict__[attribute]
for mixin in mixins
for attribute in _MIXIN_ATTRIBUT... | python | def _get_mixin_attributes(mixins):
"""Retrieve the attributes for a given set of mixin classes.
The attributes of each mixin class are being merged into a single
dictionary.
"""
return {attribute: mixin.__dict__[attribute]
for mixin in mixins
for attribute in _MIXIN_ATTRIBUT... | [
"def",
"_get_mixin_attributes",
"(",
"mixins",
")",
":",
"return",
"{",
"attribute",
":",
"mixin",
".",
"__dict__",
"[",
"attribute",
"]",
"for",
"mixin",
"in",
"mixins",
"for",
"attribute",
"in",
"_MIXIN_ATTRIBUTES",
"[",
"mixin",
"]",
"}"
] | Retrieve the attributes for a given set of mixin classes.
The attributes of each mixin class are being merged into a single
dictionary. | [
"Retrieve",
"the",
"attributes",
"for",
"a",
"given",
"set",
"of",
"mixin",
"classes",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1051-L1059 |
christophercrouzet/nani | nani.py | _get_atomic_dtype | def _get_atomic_dtype(data_type):
"""Retrieve the NumPy's `dtype` for a given atomic data type."""
atomic_type = getattr(data_type, 'type', None)
if atomic_type is not None:
return atomic_type
return _PREDEFINED_ATOMIC_NUMPY_TYPES[_find_base_type(data_type)] | python | def _get_atomic_dtype(data_type):
"""Retrieve the NumPy's `dtype` for a given atomic data type."""
atomic_type = getattr(data_type, 'type', None)
if atomic_type is not None:
return atomic_type
return _PREDEFINED_ATOMIC_NUMPY_TYPES[_find_base_type(data_type)] | [
"def",
"_get_atomic_dtype",
"(",
"data_type",
")",
":",
"atomic_type",
"=",
"getattr",
"(",
"data_type",
",",
"'type'",
",",
"None",
")",
"if",
"atomic_type",
"is",
"not",
"None",
":",
"return",
"atomic_type",
"return",
"_PREDEFINED_ATOMIC_NUMPY_TYPES",
"[",
"_f... | Retrieve the NumPy's `dtype` for a given atomic data type. | [
"Retrieve",
"the",
"NumPy",
"s",
"dtype",
"for",
"a",
"given",
"atomic",
"data",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1062-L1068 |
christophercrouzet/nani | nani.py | _find_base_type | def _find_base_type(data_type):
"""Find the Nani's base type for a given data type.
This is useful when Nani's data types were subclassed and the original type
is required.
"""
bases = type(data_type).__mro__
for base in bases:
if base in _ALL:
return base
return None | python | def _find_base_type(data_type):
"""Find the Nani's base type for a given data type.
This is useful when Nani's data types were subclassed and the original type
is required.
"""
bases = type(data_type).__mro__
for base in bases:
if base in _ALL:
return base
return None | [
"def",
"_find_base_type",
"(",
"data_type",
")",
":",
"bases",
"=",
"type",
"(",
"data_type",
")",
".",
"__mro__",
"for",
"base",
"in",
"bases",
":",
"if",
"base",
"in",
"_ALL",
":",
"return",
"base",
"return",
"None"
] | Find the Nani's base type for a given data type.
This is useful when Nani's data types were subclassed and the original type
is required. | [
"Find",
"the",
"Nani",
"s",
"base",
"type",
"for",
"a",
"given",
"data",
"type",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1071-L1082 |
christophercrouzet/nani | nani.py | _find_duplicates | def _find_duplicates(seq):
"""Find the duplicate elements from a sequence."""
seen = set()
return [element for element in seq
if seq.count(element) > 1
and element not in seen and seen.add(element) is None] | python | def _find_duplicates(seq):
"""Find the duplicate elements from a sequence."""
seen = set()
return [element for element in seq
if seq.count(element) > 1
and element not in seen and seen.add(element) is None] | [
"def",
"_find_duplicates",
"(",
"seq",
")",
":",
"seen",
"=",
"set",
"(",
")",
"return",
"[",
"element",
"for",
"element",
"in",
"seq",
"if",
"seq",
".",
"count",
"(",
"element",
")",
">",
"1",
"and",
"element",
"not",
"in",
"seen",
"and",
"seen",
... | Find the duplicate elements from a sequence. | [
"Find",
"the",
"duplicate",
"elements",
"from",
"a",
"sequence",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1085-L1090 |
christophercrouzet/nani | nani.py | _format_type | def _format_type(cls):
"""Format a type name for printing."""
if cls.__module__ == _BUILTIN_MODULE:
return cls.__name__
else:
return '%s.%s' % (cls.__module__, cls.__name__) | python | def _format_type(cls):
"""Format a type name for printing."""
if cls.__module__ == _BUILTIN_MODULE:
return cls.__name__
else:
return '%s.%s' % (cls.__module__, cls.__name__) | [
"def",
"_format_type",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"__module__",
"==",
"_BUILTIN_MODULE",
":",
"return",
"cls",
".",
"__name__",
"else",
":",
"return",
"'%s.%s'",
"%",
"(",
"cls",
".",
"__module__",
",",
"cls",
".",
"__name__",
")"
] | Format a type name for printing. | [
"Format",
"a",
"type",
"name",
"for",
"printing",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1093-L1098 |
christophercrouzet/nani | nani.py | _format_element | def _format_element(element, count, index, last_separator):
"""Format an element from a sequence.
This only prepends a separator for the last element and wraps each element
with single quotes.
"""
return ("%s'%s'" % (last_separator, element)
if count > 1 and index == count - 1
... | python | def _format_element(element, count, index, last_separator):
"""Format an element from a sequence.
This only prepends a separator for the last element and wraps each element
with single quotes.
"""
return ("%s'%s'" % (last_separator, element)
if count > 1 and index == count - 1
... | [
"def",
"_format_element",
"(",
"element",
",",
"count",
",",
"index",
",",
"last_separator",
")",
":",
"return",
"(",
"\"%s'%s'\"",
"%",
"(",
"last_separator",
",",
"element",
")",
"if",
"count",
">",
"1",
"and",
"index",
"==",
"count",
"-",
"1",
"else",... | Format an element from a sequence.
This only prepends a separator for the last element and wraps each element
with single quotes. | [
"Format",
"an",
"element",
"from",
"a",
"sequence",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1101-L1109 |
christophercrouzet/nani | nani.py | _join_sequence | def _join_sequence(seq, last_separator=''):
"""Join a sequence into a string."""
count = len(seq)
return ', '.join(_format_element(element, count, i, last_separator)
for i, element in enumerate(seq)) | python | def _join_sequence(seq, last_separator=''):
"""Join a sequence into a string."""
count = len(seq)
return ', '.join(_format_element(element, count, i, last_separator)
for i, element in enumerate(seq)) | [
"def",
"_join_sequence",
"(",
"seq",
",",
"last_separator",
"=",
"''",
")",
":",
"count",
"=",
"len",
"(",
"seq",
")",
"return",
"', '",
".",
"join",
"(",
"_format_element",
"(",
"element",
",",
"count",
",",
"i",
",",
"last_separator",
")",
"for",
"i"... | Join a sequence into a string. | [
"Join",
"a",
"sequence",
"into",
"a",
"string",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1112-L1116 |
christophercrouzet/nani | nani.py | _join_types | def _join_types(seq, last_separator=''):
"""Join class object names into a string."""
class_names = [_format_type(cls) for cls in seq]
return _join_sequence(class_names, last_separator) | python | def _join_types(seq, last_separator=''):
"""Join class object names into a string."""
class_names = [_format_type(cls) for cls in seq]
return _join_sequence(class_names, last_separator) | [
"def",
"_join_types",
"(",
"seq",
",",
"last_separator",
"=",
"''",
")",
":",
"class_names",
"=",
"[",
"_format_type",
"(",
"cls",
")",
"for",
"cls",
"in",
"seq",
"]",
"return",
"_join_sequence",
"(",
"class_names",
",",
"last_separator",
")"
] | Join class object names into a string. | [
"Join",
"class",
"object",
"names",
"into",
"a",
"string",
"."
] | train | https://github.com/christophercrouzet/nani/blob/296ae50c0cdcfd3ed0cba23a4d2edea0d124bcb1/nani.py#L1119-L1122 |
tomi77/python-t77-date | t77_date/timedelta.py | timedelta_to_seconds | def timedelta_to_seconds(value, with_microseconds=False):
"""
Convert datetime.timedelta to seconds
:param value: timedelta to convert
:type value: datetime.timedelta
:param with_microseconds:
:type with_microseconds: bool
:return: seconds/seconds with microseconds or None if val is None
... | python | def timedelta_to_seconds(value, with_microseconds=False):
"""
Convert datetime.timedelta to seconds
:param value: timedelta to convert
:type value: datetime.timedelta
:param with_microseconds:
:type with_microseconds: bool
:return: seconds/seconds with microseconds or None if val is None
... | [
"def",
"timedelta_to_seconds",
"(",
"value",
",",
"with_microseconds",
"=",
"False",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"value",
",",
"timedelta",
")",
":",
"raise",
"TypeError",
"(",
"'value must be... | Convert datetime.timedelta to seconds
:param value: timedelta to convert
:type value: datetime.timedelta
:param with_microseconds:
:type with_microseconds: bool
:return: seconds/seconds with microseconds or None if val is None
:rtype: int/float/None
:raise: TypeError when val is not timedelt... | [
"Convert",
"datetime",
".",
"timedelta",
"to",
"seconds",
":",
"param",
"value",
":",
"timedelta",
"to",
"convert",
":",
"type",
"value",
":",
"datetime",
".",
"timedelta",
":",
"param",
"with_microseconds",
":",
":",
"type",
"with_microseconds",
":",
"bool",
... | train | https://github.com/tomi77/python-t77-date/blob/b4b12ce6a02884fb62460f6b9068e7fa28979fce/t77_date/timedelta.py#L15-L35 |
tomi77/python-t77-date | t77_date/timedelta.py | timedelta_to_str | def timedelta_to_str(value, with_microseconds=False):
"""
String representation of datetime.timedelta
:param value: timedelta to convert
:type value: datetime.timedelta
:param with_microseconds:
:type with_microseconds: bool
:return: String representation of datetime.timedelta or None if val... | python | def timedelta_to_str(value, with_microseconds=False):
"""
String representation of datetime.timedelta
:param value: timedelta to convert
:type value: datetime.timedelta
:param with_microseconds:
:type with_microseconds: bool
:return: String representation of datetime.timedelta or None if val... | [
"def",
"timedelta_to_str",
"(",
"value",
",",
"with_microseconds",
"=",
"False",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"value",
",",
"timedelta",
")",
":",
"raise",
"TypeError",
"(",
"'value must be a d... | String representation of datetime.timedelta
:param value: timedelta to convert
:type value: datetime.timedelta
:param with_microseconds:
:type with_microseconds: bool
:return: String representation of datetime.timedelta or None if val is None
:rtype: string/None
:raise: TypeError when val is... | [
"String",
"representation",
"of",
"datetime",
".",
"timedelta",
":",
"param",
"value",
":",
"timedelta",
"to",
"convert",
":",
"type",
"value",
":",
"datetime",
".",
"timedelta",
":",
"param",
"with_microseconds",
":",
":",
"type",
"with_microseconds",
":",
"b... | train | https://github.com/tomi77/python-t77-date/blob/b4b12ce6a02884fb62460f6b9068e7fa28979fce/t77_date/timedelta.py#L38-L63 |
tomi77/python-t77-date | t77_date/timedelta.py | parse_timedelta | def parse_timedelta(value):
"""
Parses a string and return a datetime.timedelta.
:param value: string to parse
:type value: str
:return: timedelta object or None if value is None
:rtype: timedelta/None
:raise: TypeError when value is not string
:raise: ValueError when value is not proper... | python | def parse_timedelta(value):
"""
Parses a string and return a datetime.timedelta.
:param value: string to parse
:type value: str
:return: timedelta object or None if value is None
:rtype: timedelta/None
:raise: TypeError when value is not string
:raise: ValueError when value is not proper... | [
"def",
"parse_timedelta",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'value must be a string type'",
")",
"match"... | Parses a string and return a datetime.timedelta.
:param value: string to parse
:type value: str
:return: timedelta object or None if value is None
:rtype: timedelta/None
:raise: TypeError when value is not string
:raise: ValueError when value is not proper timedelta string | [
"Parses",
"a",
"string",
"and",
"return",
"a",
"datetime",
".",
"timedelta",
".",
":",
"param",
"value",
":",
"string",
"to",
"parse",
":",
"type",
"value",
":",
"str",
":",
"return",
":",
"timedelta",
"object",
"or",
"None",
"if",
"value",
"is",
"None... | train | https://github.com/tomi77/python-t77-date/blob/b4b12ce6a02884fb62460f6b9068e7fa28979fce/t77_date/timedelta.py#L66-L89 |
bwesterb/tkbd | src/cometApi.py | prepare_roomMap | def prepare_roomMap(roomMap):
""" Prepares the roomMap to be JSONified. That is: convert the non
JSON serializable objects such as set() """
ret = {}
for room in roomMap:
ret[room] = [roomMap[room].name, list(roomMap[room].pcs)]
return ret | python | def prepare_roomMap(roomMap):
""" Prepares the roomMap to be JSONified. That is: convert the non
JSON serializable objects such as set() """
ret = {}
for room in roomMap:
ret[room] = [roomMap[room].name, list(roomMap[room].pcs)]
return ret | [
"def",
"prepare_roomMap",
"(",
"roomMap",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"room",
"in",
"roomMap",
":",
"ret",
"[",
"room",
"]",
"=",
"[",
"roomMap",
"[",
"room",
"]",
".",
"name",
",",
"list",
"(",
"roomMap",
"[",
"room",
"]",
".",
"pcs",... | Prepares the roomMap to be JSONified. That is: convert the non
JSON serializable objects such as set() | [
"Prepares",
"the",
"roomMap",
"to",
"be",
"JSONified",
".",
"That",
"is",
":",
"convert",
"the",
"non",
"JSON",
"serializable",
"objects",
"such",
"as",
"set",
"()"
] | train | https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/cometApi.py#L7-L13 |
bwesterb/tkbd | src/cometApi.py | prepare_schedule | def prepare_schedule(schedule):
""" Prepares the schedule to be JSONified. That is: convert the non
JSON serializable objects such as the datetime.time's """
ret = {}
for room in schedule:
ret[room] = []
for event in schedule[room]:
ret[room].append(((event[0].hour,
... | python | def prepare_schedule(schedule):
""" Prepares the schedule to be JSONified. That is: convert the non
JSON serializable objects such as the datetime.time's """
ret = {}
for room in schedule:
ret[room] = []
for event in schedule[room]:
ret[room].append(((event[0].hour,
... | [
"def",
"prepare_schedule",
"(",
"schedule",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"room",
"in",
"schedule",
":",
"ret",
"[",
"room",
"]",
"=",
"[",
"]",
"for",
"event",
"in",
"schedule",
"[",
"room",
"]",
":",
"ret",
"[",
"room",
"]",
".",
"appe... | Prepares the schedule to be JSONified. That is: convert the non
JSON serializable objects such as the datetime.time's | [
"Prepares",
"the",
"schedule",
"to",
"be",
"JSONified",
".",
"That",
"is",
":",
"convert",
"the",
"non",
"JSON",
"serializable",
"objects",
"such",
"as",
"the",
"datetime",
".",
"time",
"s"
] | train | https://github.com/bwesterb/tkbd/blob/fcf16977d38a93fe9b7fa198513007ab9921b650/src/cometApi.py#L15-L27 |
lambdalisue/maidenhair | src/maidenhair/loaders/base.py | slice_columns | def slice_columns(x, using=None):
"""
Slice a numpy array to make columns
Parameters
----------
x : ndarray
A numpy array instance
using : list of integer or slice instance or None, optional
A list of index or slice instance
Returns
-------
ndarray
A list of... | python | def slice_columns(x, using=None):
"""
Slice a numpy array to make columns
Parameters
----------
x : ndarray
A numpy array instance
using : list of integer or slice instance or None, optional
A list of index or slice instance
Returns
-------
ndarray
A list of... | [
"def",
"slice_columns",
"(",
"x",
",",
"using",
"=",
"None",
")",
":",
"if",
"using",
"is",
"None",
":",
"using",
"=",
"range",
"(",
"0",
",",
"len",
"(",
"x",
"[",
"0",
"]",
")",
")",
"return",
"[",
"x",
"[",
":",
",",
"s",
"]",
"for",
"s"... | Slice a numpy array to make columns
Parameters
----------
x : ndarray
A numpy array instance
using : list of integer or slice instance or None, optional
A list of index or slice instance
Returns
-------
ndarray
A list of numpy array columns sliced | [
"Slice",
"a",
"numpy",
"array",
"to",
"make",
"columns"
] | train | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/loaders/base.py#L156-L175 |
lambdalisue/maidenhair | src/maidenhair/loaders/base.py | unite_dataset | def unite_dataset(dataset, basecolumn=0):
"""
Unite dataset into a single data
Parameters
----------
dataset : list of ndarray
A data list of a column list of a numpy arrays
basecolumn : integer, optional
An index of base column.
All data will be trimmed based on the ord... | python | def unite_dataset(dataset, basecolumn=0):
"""
Unite dataset into a single data
Parameters
----------
dataset : list of ndarray
A data list of a column list of a numpy arrays
basecolumn : integer, optional
An index of base column.
All data will be trimmed based on the ord... | [
"def",
"unite_dataset",
"(",
"dataset",
",",
"basecolumn",
"=",
"0",
")",
":",
"ndata",
"=",
"[",
"None",
"]",
"*",
"len",
"(",
"dataset",
"[",
"0",
"]",
")",
"for",
"pdata",
"in",
"dataset",
":",
"# select basecolumn",
"bnx",
"=",
"ndata",
"[",
"bas... | Unite dataset into a single data
Parameters
----------
dataset : list of ndarray
A data list of a column list of a numpy arrays
basecolumn : integer, optional
An index of base column.
All data will be trimmed based on the order of this column when the
number of samples a... | [
"Unite",
"dataset",
"into",
"a",
"single",
"data"
] | train | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/loaders/base.py#L177-L222 |
lambdalisue/maidenhair | src/maidenhair/loaders/base.py | BaseLoader.load | def load(self, filename, using=None, parser=None, **kwargs):
"""
Load data from file using a specified parser.
Return value will be separated or sliced into a column list
Parameters
----------
filename : string
A data file path
using : list of intege... | python | def load(self, filename, using=None, parser=None, **kwargs):
"""
Load data from file using a specified parser.
Return value will be separated or sliced into a column list
Parameters
----------
filename : string
A data file path
using : list of intege... | [
"def",
"load",
"(",
"self",
",",
"filename",
",",
"using",
"=",
"None",
",",
"parser",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"using",
"=",
"using",
"or",
"self",
".",
"using",
"parser",
"=",
"parser",
"or",
"self",
".",
"parser",
"if",
... | Load data from file using a specified parser.
Return value will be separated or sliced into a column list
Parameters
----------
filename : string
A data file path
using : list of integer, slice instance, or None, optional
A list of index or slice instanc... | [
"Load",
"data",
"from",
"file",
"using",
"a",
"specified",
"parser",
"."
] | train | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/loaders/base.py#L40-L72 |
lambdalisue/maidenhair | src/maidenhair/loaders/base.py | BaseLoader.glob | def glob(self, pathname, using=None,
unite=False, basecolumn=0, parser=None,
with_filename=False,
recursive=False, natsort=True, **kwargs):
"""
Load data from file matched with given glob pattern.
Return value will be a list of data unless :attr:`unite` is... | python | def glob(self, pathname, using=None,
unite=False, basecolumn=0, parser=None,
with_filename=False,
recursive=False, natsort=True, **kwargs):
"""
Load data from file matched with given glob pattern.
Return value will be a list of data unless :attr:`unite` is... | [
"def",
"glob",
"(",
"self",
",",
"pathname",
",",
"using",
"=",
"None",
",",
"unite",
"=",
"False",
",",
"basecolumn",
"=",
"0",
",",
"parser",
"=",
"None",
",",
"with_filename",
"=",
"False",
",",
"recursive",
"=",
"False",
",",
"natsort",
"=",
"Tru... | Load data from file matched with given glob pattern.
Return value will be a list of data unless :attr:`unite` is `True`.
If :attr:`unite` is `True`, all dataset will be united into a single
data.
Parameters
----------
pathname : string
A glob pattern
... | [
"Load",
"data",
"from",
"file",
"matched",
"with",
"given",
"glob",
"pattern",
"."
] | train | https://github.com/lambdalisue/maidenhair/blob/d5095c1087d1f4d71cc57410492151d2803a9f0d/src/maidenhair/loaders/base.py#L74-L154 |
matthewdeanmartin/jiggle_version | jiggle_version/parse_dunder_version.py | find_by_ast | def find_by_ast(line, version_token="__version__"): # type: (str,str) -> Optional[str]
"""
Safer way to 'execute' python code to get a simple value
:param line:
:param version_token:
:return:
"""
if not line:
return ""
# clean up line.
simplified_line = simplify_line(line)
... | python | def find_by_ast(line, version_token="__version__"): # type: (str,str) -> Optional[str]
"""
Safer way to 'execute' python code to get a simple value
:param line:
:param version_token:
:return:
"""
if not line:
return ""
# clean up line.
simplified_line = simplify_line(line)
... | [
"def",
"find_by_ast",
"(",
"line",
",",
"version_token",
"=",
"\"__version__\"",
")",
":",
"# type: (str,str) -> Optional[str]",
"if",
"not",
"line",
":",
"return",
"\"\"",
"# clean up line.",
"simplified_line",
"=",
"simplify_line",
"(",
"line",
")",
"if",
"simplif... | Safer way to 'execute' python code to get a simple value
:param line:
:param version_token:
:return: | [
"Safer",
"way",
"to",
"execute",
"python",
"code",
"to",
"get",
"a",
"simple",
"value",
":",
"param",
"line",
":",
":",
"param",
"version_token",
":",
":",
"return",
":"
] | train | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/parse_dunder_version.py#L38-L70 |
matthewdeanmartin/jiggle_version | jiggle_version/parse_dunder_version.py | simplify_line | def simplify_line(line, keep_comma=False): # type: (str, bool)->str
"""
Change ' to "
Remove tabs and spaces (assume no significant whitespace inside a version string!)
"""
if not line:
return ""
if "#" in line:
parts = line.split("#")
simplified_line = parts[0]
else... | python | def simplify_line(line, keep_comma=False): # type: (str, bool)->str
"""
Change ' to "
Remove tabs and spaces (assume no significant whitespace inside a version string!)
"""
if not line:
return ""
if "#" in line:
parts = line.split("#")
simplified_line = parts[0]
else... | [
"def",
"simplify_line",
"(",
"line",
",",
"keep_comma",
"=",
"False",
")",
":",
"# type: (str, bool)->str",
"if",
"not",
"line",
":",
"return",
"\"\"",
"if",
"\"#\"",
"in",
"line",
":",
"parts",
"=",
"line",
".",
"split",
"(",
"\"#\"",
")",
"simplified_lin... | Change ' to "
Remove tabs and spaces (assume no significant whitespace inside a version string!) | [
"Change",
"to",
"Remove",
"tabs",
"and",
"spaces",
"(",
"assume",
"no",
"significant",
"whitespace",
"inside",
"a",
"version",
"string!",
")"
] | train | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/parse_dunder_version.py#L73-L96 |
matthewdeanmartin/jiggle_version | jiggle_version/parse_dunder_version.py | find_version_by_regex | def find_version_by_regex(
file_source, version_token="__version__"
): # type: (str,str)->Optional[str]
"""
Regex for dunder version
"""
if not file_source:
return None
version_match = re.search(
r"^" + version_token + r" = ['\"]([^'\"]*)['\"]", file_source, re.M
)
if ve... | python | def find_version_by_regex(
file_source, version_token="__version__"
): # type: (str,str)->Optional[str]
"""
Regex for dunder version
"""
if not file_source:
return None
version_match = re.search(
r"^" + version_token + r" = ['\"]([^'\"]*)['\"]", file_source, re.M
)
if ve... | [
"def",
"find_version_by_regex",
"(",
"file_source",
",",
"version_token",
"=",
"\"__version__\"",
")",
":",
"# type: (str,str)->Optional[str]",
"if",
"not",
"file_source",
":",
"return",
"None",
"version_match",
"=",
"re",
".",
"search",
"(",
"r\"^\"",
"+",
"version... | Regex for dunder version | [
"Regex",
"for",
"dunder",
"version"
] | train | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/parse_dunder_version.py#L99-L115 |
matthewdeanmartin/jiggle_version | jiggle_version/parse_dunder_version.py | find_version_by_string_lib | def find_version_by_string_lib(
line, version_token="__version__"
): # type: (str,str)->Optional[str]
"""
No regex parsing. Or at least, mostly, not regex.
"""
if not line:
return None
simplified_line = simplify_line(line)
version = None
if simplified_line.strip().startswith(ver... | python | def find_version_by_string_lib(
line, version_token="__version__"
): # type: (str,str)->Optional[str]
"""
No regex parsing. Or at least, mostly, not regex.
"""
if not line:
return None
simplified_line = simplify_line(line)
version = None
if simplified_line.strip().startswith(ver... | [
"def",
"find_version_by_string_lib",
"(",
"line",
",",
"version_token",
"=",
"\"__version__\"",
")",
":",
"# type: (str,str)->Optional[str]",
"if",
"not",
"line",
":",
"return",
"None",
"simplified_line",
"=",
"simplify_line",
"(",
"line",
")",
"version",
"=",
"None... | No regex parsing. Or at least, mostly, not regex. | [
"No",
"regex",
"parsing",
".",
"Or",
"at",
"least",
"mostly",
"not",
"regex",
"."
] | train | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/parse_dunder_version.py#L118-L141 |
matthewdeanmartin/jiggle_version | jiggle_version/parse_dunder_version.py | find_in_line | def find_in_line(line): # type: (str)->Tuple[Optional[str],Optional[str]]
"""
Use three strategies to parse version string
:param line:
:return:
"""
if not line:
return None, None
for version_token in version_tokens:
by_ast = find_by_ast(line, version_token)
by_ast ... | python | def find_in_line(line): # type: (str)->Tuple[Optional[str],Optional[str]]
"""
Use three strategies to parse version string
:param line:
:return:
"""
if not line:
return None, None
for version_token in version_tokens:
by_ast = find_by_ast(line, version_token)
by_ast ... | [
"def",
"find_in_line",
"(",
"line",
")",
":",
"# type: (str)->Tuple[Optional[str],Optional[str]]",
"if",
"not",
"line",
":",
"return",
"None",
",",
"None",
"for",
"version_token",
"in",
"version_tokens",
":",
"by_ast",
"=",
"find_by_ast",
"(",
"line",
",",
"versio... | Use three strategies to parse version string
:param line:
:return: | [
"Use",
"three",
"strategies",
"to",
"parse",
"version",
"string",
":",
"param",
"line",
":",
":",
"return",
":"
] | train | https://github.com/matthewdeanmartin/jiggle_version/blob/963656a0a47b7162780a5f6c8f4b8bbbebc148f5/jiggle_version/parse_dunder_version.py#L159-L183 |
lambdalisue/django-roughpages | src/roughpages/backends/auth.py | AuthTemplateFilenameBackend.prepare_filenames | def prepare_filenames(self, normalized_url, request):
"""
Prepare template filename list based on the user authenticated state
If user is authenticated user, it use '_authenticated' as a suffix.
Otherwise it use '_anonymous' as a suffix to produce the template
filename list. The... | python | def prepare_filenames(self, normalized_url, request):
"""
Prepare template filename list based on the user authenticated state
If user is authenticated user, it use '_authenticated' as a suffix.
Otherwise it use '_anonymous' as a suffix to produce the template
filename list. The... | [
"def",
"prepare_filenames",
"(",
"self",
",",
"normalized_url",
",",
"request",
")",
":",
"filenames",
"=",
"[",
"normalized_url",
"]",
"if",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
":",
"filenames",
".",
"insert",
"(",
"0",
",",
"normal... | Prepare template filename list based on the user authenticated state
If user is authenticated user, it use '_authenticated' as a suffix.
Otherwise it use '_anonymous' as a suffix to produce the template
filename list. The list include original filename at the end of the
list.
A... | [
"Prepare",
"template",
"filename",
"list",
"based",
"on",
"the",
"user",
"authenticated",
"state"
] | train | https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/backends/auth.py#L16-L70 |
bfontaine/p7magma | magma/base.py | Student.fetch | def fetch(self):
"""
Fetch this student's courses page. It's recommended to do that when
creating the object (this is the default) because the remote sessions
are short.
"""
soup = self.session.get_results_soup()
self.courses = CoursesList(soup) | python | def fetch(self):
"""
Fetch this student's courses page. It's recommended to do that when
creating the object (this is the default) because the remote sessions
are short.
"""
soup = self.session.get_results_soup()
self.courses = CoursesList(soup) | [
"def",
"fetch",
"(",
"self",
")",
":",
"soup",
"=",
"self",
".",
"session",
".",
"get_results_soup",
"(",
")",
"self",
".",
"courses",
"=",
"CoursesList",
"(",
"soup",
")"
] | Fetch this student's courses page. It's recommended to do that when
creating the object (this is the default) because the remote sessions
are short. | [
"Fetch",
"this",
"student",
"s",
"courses",
"page",
".",
"It",
"s",
"recommended",
"to",
"do",
"that",
"when",
"creating",
"the",
"object",
"(",
"this",
"is",
"the",
"default",
")",
"because",
"the",
"remote",
"sessions",
"are",
"short",
"."
] | train | https://github.com/bfontaine/p7magma/blob/713647aa9e3187c93c2577ef812f33ec42ae5494/magma/base.py#L25-L32 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | GetWSAActionFault | def GetWSAActionFault(operation, name):
"""Find wsa:Action attribute, and return value or WSA.FAULT
for the default.
"""
attr = operation.faults[name].action
if attr is not None:
return attr
return WSA.FAULT | python | def GetWSAActionFault(operation, name):
"""Find wsa:Action attribute, and return value or WSA.FAULT
for the default.
"""
attr = operation.faults[name].action
if attr is not None:
return attr
return WSA.FAULT | [
"def",
"GetWSAActionFault",
"(",
"operation",
",",
"name",
")",
":",
"attr",
"=",
"operation",
".",
"faults",
"[",
"name",
"]",
".",
"action",
"if",
"attr",
"is",
"not",
"None",
":",
"return",
"attr",
"return",
"WSA",
".",
"FAULT"
] | Find wsa:Action attribute, and return value or WSA.FAULT
for the default. | [
"Find",
"wsa",
":",
"Action",
"attribute",
"and",
"return",
"value",
"or",
"WSA",
".",
"FAULT",
"for",
"the",
"default",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1382-L1389 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | GetWSAActionInput | def GetWSAActionInput(operation):
"""Find wsa:Action attribute, and return value or the default."""
attr = operation.input.action
if attr is not None:
return attr
portType = operation.getPortType()
targetNamespace = portType.getTargetNamespace()
ptName = portType.name
msgName = opera... | python | def GetWSAActionInput(operation):
"""Find wsa:Action attribute, and return value or the default."""
attr = operation.input.action
if attr is not None:
return attr
portType = operation.getPortType()
targetNamespace = portType.getTargetNamespace()
ptName = portType.name
msgName = opera... | [
"def",
"GetWSAActionInput",
"(",
"operation",
")",
":",
"attr",
"=",
"operation",
".",
"input",
".",
"action",
"if",
"attr",
"is",
"not",
"None",
":",
"return",
"attr",
"portType",
"=",
"operation",
".",
"getPortType",
"(",
")",
"targetNamespace",
"=",
"po... | Find wsa:Action attribute, and return value or the default. | [
"Find",
"wsa",
":",
"Action",
"attribute",
"and",
"return",
"value",
"or",
"the",
"default",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1391-L1404 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | GetWSAActionOutput | def GetWSAActionOutput(operation):
"""Find wsa:Action attribute, and return value or the default."""
attr = operation.output.action
if attr is not None:
return attr
targetNamespace = operation.getPortType().getTargetNamespace()
ptName = operation.getPortType().name
msgName = operation.ou... | python | def GetWSAActionOutput(operation):
"""Find wsa:Action attribute, and return value or the default."""
attr = operation.output.action
if attr is not None:
return attr
targetNamespace = operation.getPortType().getTargetNamespace()
ptName = operation.getPortType().name
msgName = operation.ou... | [
"def",
"GetWSAActionOutput",
"(",
"operation",
")",
":",
"attr",
"=",
"operation",
".",
"output",
".",
"action",
"if",
"attr",
"is",
"not",
"None",
":",
"return",
"attr",
"targetNamespace",
"=",
"operation",
".",
"getPortType",
"(",
")",
".",
"getTargetNames... | Find wsa:Action attribute, and return value or the default. | [
"Find",
"wsa",
":",
"Action",
"attribute",
"and",
"return",
"value",
"or",
"the",
"default",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1406-L1418 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | callInfoFromWSDL | def callInfoFromWSDL(port, name):
"""Return a SOAPCallInfo given a WSDL port and operation name."""
wsdl = port.getService().getWSDL()
binding = port.getBinding()
portType = binding.getPortType()
operation = portType.operations[name]
opbinding = binding.operations[name]
messages = wsdl.messa... | python | def callInfoFromWSDL(port, name):
"""Return a SOAPCallInfo given a WSDL port and operation name."""
wsdl = port.getService().getWSDL()
binding = port.getBinding()
portType = binding.getPortType()
operation = portType.operations[name]
opbinding = binding.operations[name]
messages = wsdl.messa... | [
"def",
"callInfoFromWSDL",
"(",
"port",
",",
"name",
")",
":",
"wsdl",
"=",
"port",
".",
"getService",
"(",
")",
".",
"getWSDL",
"(",
")",
"binding",
"=",
"port",
".",
"getBinding",
"(",
")",
"portType",
"=",
"binding",
".",
"getPortType",
"(",
")",
... | Return a SOAPCallInfo given a WSDL port and operation name. | [
"Return",
"a",
"SOAPCallInfo",
"given",
"a",
"WSDL",
"port",
"and",
"operation",
"name",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1548-L1668 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | WSDLReader.loadFromStream | def loadFromStream(self, stream, name=None):
"""Return a WSDL instance loaded from a stream object."""
document = DOM.loadDocument(stream)
wsdl = WSDL()
if name:
wsdl.location = name
elif hasattr(stream, 'name'):
wsdl.location = stream.name
wsdl.lo... | python | def loadFromStream(self, stream, name=None):
"""Return a WSDL instance loaded from a stream object."""
document = DOM.loadDocument(stream)
wsdl = WSDL()
if name:
wsdl.location = name
elif hasattr(stream, 'name'):
wsdl.location = stream.name
wsdl.lo... | [
"def",
"loadFromStream",
"(",
"self",
",",
"stream",
",",
"name",
"=",
"None",
")",
":",
"document",
"=",
"DOM",
".",
"loadDocument",
"(",
"stream",
")",
"wsdl",
"=",
"WSDL",
"(",
")",
"if",
"name",
":",
"wsdl",
".",
"location",
"=",
"name",
"elif",
... | Return a WSDL instance loaded from a stream object. | [
"Return",
"a",
"WSDL",
"instance",
"loaded",
"from",
"a",
"stream",
"object",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L26-L35 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | WSDLReader.loadFromURL | def loadFromURL(self, url):
"""Return a WSDL instance loaded from the given url."""
document = DOM.loadFromURL(url)
wsdl = WSDL()
wsdl.location = url
wsdl.load(document)
return wsdl | python | def loadFromURL(self, url):
"""Return a WSDL instance loaded from the given url."""
document = DOM.loadFromURL(url)
wsdl = WSDL()
wsdl.location = url
wsdl.load(document)
return wsdl | [
"def",
"loadFromURL",
"(",
"self",
",",
"url",
")",
":",
"document",
"=",
"DOM",
".",
"loadFromURL",
"(",
"url",
")",
"wsdl",
"=",
"WSDL",
"(",
")",
"wsdl",
".",
"location",
"=",
"url",
"wsdl",
".",
"load",
"(",
"document",
")",
"return",
"wsdl"
] | Return a WSDL instance loaded from the given url. | [
"Return",
"a",
"WSDL",
"instance",
"loaded",
"from",
"the",
"given",
"url",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L37-L43 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | WSDLReader.loadFromFile | def loadFromFile(self, filename):
"""Return a WSDL instance loaded from the given file."""
file = open(filename, 'rb')
try:
wsdl = self.loadFromStream(file)
finally:
file.close()
return wsdl | python | def loadFromFile(self, filename):
"""Return a WSDL instance loaded from the given file."""
file = open(filename, 'rb')
try:
wsdl = self.loadFromStream(file)
finally:
file.close()
return wsdl | [
"def",
"loadFromFile",
"(",
"self",
",",
"filename",
")",
":",
"file",
"=",
"open",
"(",
"filename",
",",
"'rb'",
")",
"try",
":",
"wsdl",
"=",
"self",
".",
"loadFromStream",
"(",
"file",
")",
"finally",
":",
"file",
".",
"close",
"(",
")",
"return",... | Return a WSDL instance loaded from the given file. | [
"Return",
"a",
"WSDL",
"instance",
"loaded",
"from",
"the",
"given",
"file",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L49-L56 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | WSDL.toDom | def toDom(self):
""" Generate a DOM representation of the WSDL instance.
Not dealing with generating XML Schema, thus the targetNamespace
of all XML Schema elements or types used by WSDL message parts
needs to be specified via import information items.
"""
namespaceURI =... | python | def toDom(self):
""" Generate a DOM representation of the WSDL instance.
Not dealing with generating XML Schema, thus the targetNamespace
of all XML Schema elements or types used by WSDL message parts
needs to be specified via import information items.
"""
namespaceURI =... | [
"def",
"toDom",
"(",
"self",
")",
":",
"namespaceURI",
"=",
"DOM",
".",
"GetWSDLUri",
"(",
"self",
".",
"version",
")",
"self",
".",
"document",
"=",
"DOM",
".",
"createDocument",
"(",
"namespaceURI",
",",
"'wsdl:definitions'",
")",
"# Set up a couple prefixes... | Generate a DOM representation of the WSDL instance.
Not dealing with generating XML Schema, thus the targetNamespace
of all XML Schema elements or types used by WSDL message parts
needs to be specified via import information items. | [
"Generate",
"a",
"DOM",
"representation",
"of",
"the",
"WSDL",
"instance",
".",
"Not",
"dealing",
"with",
"generating",
"XML",
"Schema",
"thus",
"the",
"targetNamespace",
"of",
"all",
"XML",
"Schema",
"elements",
"or",
"types",
"used",
"by",
"WSDL",
"message",... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L133-L167 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | WSDL._import | def _import(self, document, element, base_location=None):
'''Algo take <import> element's children, clone them,
and add them to the main document. Support for relative
locations is a bit complicated. The orig document context
is lost, so we need to store base location in DOM elements
... | python | def _import(self, document, element, base_location=None):
'''Algo take <import> element's children, clone them,
and add them to the main document. Support for relative
locations is a bit complicated. The orig document context
is lost, so we need to store base location in DOM elements
... | [
"def",
"_import",
"(",
"self",
",",
"document",
",",
"element",
",",
"base_location",
"=",
"None",
")",
":",
"namespace",
"=",
"DOM",
".",
"getAttr",
"(",
"element",
",",
"'namespace'",
",",
"default",
"=",
"None",
")",
"location",
"=",
"DOM",
".",
"ge... | Algo take <import> element's children, clone them,
and add them to the main document. Support for relative
locations is a bit complicated. The orig document context
is lost, so we need to store base location in DOM elements
representing <types>, by creating a special temporary
... | [
"Algo",
"take",
"<import",
">",
"element",
"s",
"children",
"clone",
"them",
"and",
"add",
"them",
"to",
"the",
"main",
"document",
".",
"Support",
"for",
"relative",
"locations",
"is",
"a",
"bit",
"complicated",
".",
"The",
"orig",
"document",
"context",
... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L297-L370 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | Element.getWSDL | def getWSDL(self):
"""Return the WSDL object that contains this information item."""
parent = self
while 1:
# skip any collections
if isinstance(parent, WSDL):
return parent
try: parent = parent.parent()
except: break
... | python | def getWSDL(self):
"""Return the WSDL object that contains this information item."""
parent = self
while 1:
# skip any collections
if isinstance(parent, WSDL):
return parent
try: parent = parent.parent()
except: break
... | [
"def",
"getWSDL",
"(",
"self",
")",
":",
"parent",
"=",
"self",
"while",
"1",
":",
"# skip any collections",
"if",
"isinstance",
"(",
"parent",
",",
"WSDL",
")",
":",
"return",
"parent",
"try",
":",
"parent",
"=",
"parent",
".",
"parent",
"(",
")",
"ex... | Return the WSDL object that contains this information item. | [
"Return",
"the",
"WSDL",
"object",
"that",
"contains",
"this",
"information",
"item",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L383-L393 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | MessagePart.toDom | def toDom(self, node):
"""node -- node representing message"""
wsdl = self.getWSDL()
ep = ElementProxy(None, node)
epc = ep.createAppendElement(DOM.GetWSDLUri(wsdl.version), 'part')
epc.setAttributeNS(None, 'name', self.name)
if self.element is not None:
ns,n... | python | def toDom(self, node):
"""node -- node representing message"""
wsdl = self.getWSDL()
ep = ElementProxy(None, node)
epc = ep.createAppendElement(DOM.GetWSDLUri(wsdl.version), 'part')
epc.setAttributeNS(None, 'name', self.name)
if self.element is not None:
ns,n... | [
"def",
"toDom",
"(",
"self",
",",
"node",
")",
":",
"wsdl",
"=",
"self",
".",
"getWSDL",
"(",
")",
"ep",
"=",
"ElementProxy",
"(",
"None",
",",
"node",
")",
"epc",
"=",
"ep",
".",
"createAppendElement",
"(",
"DOM",
".",
"GetWSDLUri",
"(",
"wsdl",
"... | node -- node representing message | [
"node",
"--",
"node",
"representing",
"message"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L523-L537 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | Port.getBinding | def getBinding(self):
"""Return the Binding object that is referenced by this port."""
wsdl = self.getService().getWSDL()
return wsdl.bindings[self.binding] | python | def getBinding(self):
"""Return the Binding object that is referenced by this port."""
wsdl = self.getService().getWSDL()
return wsdl.bindings[self.binding] | [
"def",
"getBinding",
"(",
"self",
")",
":",
"wsdl",
"=",
"self",
".",
"getService",
"(",
")",
".",
"getWSDL",
"(",
")",
"return",
"wsdl",
".",
"bindings",
"[",
"self",
".",
"binding",
"]"
] | Return the Binding object that is referenced by this port. | [
"Return",
"the",
"Binding",
"object",
"that",
"is",
"referenced",
"by",
"this",
"port",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1097-L1100 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | Port.getPortType | def getPortType(self):
"""Return the PortType object that is referenced by this port."""
wsdl = self.getService().getWSDL()
binding = wsdl.bindings[self.binding]
return wsdl.portTypes[binding.type] | python | def getPortType(self):
"""Return the PortType object that is referenced by this port."""
wsdl = self.getService().getWSDL()
binding = wsdl.bindings[self.binding]
return wsdl.portTypes[binding.type] | [
"def",
"getPortType",
"(",
"self",
")",
":",
"wsdl",
"=",
"self",
".",
"getService",
"(",
")",
".",
"getWSDL",
"(",
")",
"binding",
"=",
"wsdl",
".",
"bindings",
"[",
"self",
".",
"binding",
"]",
"return",
"wsdl",
".",
"portTypes",
"[",
"binding",
".... | Return the PortType object that is referenced by this port. | [
"Return",
"the",
"PortType",
"object",
"that",
"is",
"referenced",
"by",
"this",
"port",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1102-L1106 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | Port.getAddressBinding | def getAddressBinding(self):
"""A convenience method to obtain the extension element used
as the address binding for the port."""
for item in self.extensions:
if isinstance(item, SoapAddressBinding) or \
isinstance(item, HttpAddressBinding):
return i... | python | def getAddressBinding(self):
"""A convenience method to obtain the extension element used
as the address binding for the port."""
for item in self.extensions:
if isinstance(item, SoapAddressBinding) or \
isinstance(item, HttpAddressBinding):
return i... | [
"def",
"getAddressBinding",
"(",
"self",
")",
":",
"for",
"item",
"in",
"self",
".",
"extensions",
":",
"if",
"isinstance",
"(",
"item",
",",
"SoapAddressBinding",
")",
"or",
"isinstance",
"(",
"item",
",",
"HttpAddressBinding",
")",
":",
"return",
"item",
... | A convenience method to obtain the extension element used
as the address binding for the port. | [
"A",
"convenience",
"method",
"to",
"obtain",
"the",
"extension",
"element",
"used",
"as",
"the",
"address",
"binding",
"for",
"the",
"port",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1108-L1117 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | SOAPCallInfo.addInParameter | def addInParameter(self, name, type, namespace=None, element_type=0):
"""Add an input parameter description to the call info."""
parameter = ParameterInfo(name, type, namespace, element_type)
self.inparams.append(parameter)
return parameter | python | def addInParameter(self, name, type, namespace=None, element_type=0):
"""Add an input parameter description to the call info."""
parameter = ParameterInfo(name, type, namespace, element_type)
self.inparams.append(parameter)
return parameter | [
"def",
"addInParameter",
"(",
"self",
",",
"name",
",",
"type",
",",
"namespace",
"=",
"None",
",",
"element_type",
"=",
"0",
")",
":",
"parameter",
"=",
"ParameterInfo",
"(",
"name",
",",
"type",
",",
"namespace",
",",
"element_type",
")",
"self",
".",
... | Add an input parameter description to the call info. | [
"Add",
"an",
"input",
"parameter",
"description",
"to",
"the",
"call",
"info",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1467-L1471 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | SOAPCallInfo.addOutParameter | def addOutParameter(self, name, type, namespace=None, element_type=0):
"""Add an output parameter description to the call info."""
parameter = ParameterInfo(name, type, namespace, element_type)
self.outparams.append(parameter)
return parameter | python | def addOutParameter(self, name, type, namespace=None, element_type=0):
"""Add an output parameter description to the call info."""
parameter = ParameterInfo(name, type, namespace, element_type)
self.outparams.append(parameter)
return parameter | [
"def",
"addOutParameter",
"(",
"self",
",",
"name",
",",
"type",
",",
"namespace",
"=",
"None",
",",
"element_type",
"=",
"0",
")",
":",
"parameter",
"=",
"ParameterInfo",
"(",
"name",
",",
"type",
",",
"namespace",
",",
"element_type",
")",
"self",
".",... | Add an output parameter description to the call info. | [
"Add",
"an",
"output",
"parameter",
"description",
"to",
"the",
"call",
"info",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1473-L1477 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | SOAPCallInfo.setReturnParameter | def setReturnParameter(self, name, type, namespace=None, element_type=0):
"""Set the return parameter description for the call info."""
parameter = ParameterInfo(name, type, namespace, element_type)
self.retval = parameter
return parameter | python | def setReturnParameter(self, name, type, namespace=None, element_type=0):
"""Set the return parameter description for the call info."""
parameter = ParameterInfo(name, type, namespace, element_type)
self.retval = parameter
return parameter | [
"def",
"setReturnParameter",
"(",
"self",
",",
"name",
",",
"type",
",",
"namespace",
"=",
"None",
",",
"element_type",
"=",
"0",
")",
":",
"parameter",
"=",
"ParameterInfo",
"(",
"name",
",",
"type",
",",
"namespace",
",",
"element_type",
")",
"self",
"... | Set the return parameter description for the call info. | [
"Set",
"the",
"return",
"parameter",
"description",
"for",
"the",
"call",
"info",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1479-L1483 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | SOAPCallInfo.addInHeaderInfo | def addInHeaderInfo(self, name, type, namespace, element_type=0,
mustUnderstand=0):
"""Add an input SOAP header description to the call info."""
headerinfo = HeaderInfo(name, type, namespace, element_type)
if mustUnderstand:
headerinfo.mustUnderstand = 1
... | python | def addInHeaderInfo(self, name, type, namespace, element_type=0,
mustUnderstand=0):
"""Add an input SOAP header description to the call info."""
headerinfo = HeaderInfo(name, type, namespace, element_type)
if mustUnderstand:
headerinfo.mustUnderstand = 1
... | [
"def",
"addInHeaderInfo",
"(",
"self",
",",
"name",
",",
"type",
",",
"namespace",
",",
"element_type",
"=",
"0",
",",
"mustUnderstand",
"=",
"0",
")",
":",
"headerinfo",
"=",
"HeaderInfo",
"(",
"name",
",",
"type",
",",
"namespace",
",",
"element_type",
... | Add an input SOAP header description to the call info. | [
"Add",
"an",
"input",
"SOAP",
"header",
"description",
"to",
"the",
"call",
"info",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1485-L1492 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/wstools/WSDLTools.py | SOAPCallInfo.addOutHeaderInfo | def addOutHeaderInfo(self, name, type, namespace, element_type=0,
mustUnderstand=0):
"""Add an output SOAP header description to the call info."""
headerinfo = HeaderInfo(name, type, namespace, element_type)
if mustUnderstand:
headerinfo.mustUnderstand = 1
... | python | def addOutHeaderInfo(self, name, type, namespace, element_type=0,
mustUnderstand=0):
"""Add an output SOAP header description to the call info."""
headerinfo = HeaderInfo(name, type, namespace, element_type)
if mustUnderstand:
headerinfo.mustUnderstand = 1
... | [
"def",
"addOutHeaderInfo",
"(",
"self",
",",
"name",
",",
"type",
",",
"namespace",
",",
"element_type",
"=",
"0",
",",
"mustUnderstand",
"=",
"0",
")",
":",
"headerinfo",
"=",
"HeaderInfo",
"(",
"name",
",",
"type",
",",
"namespace",
",",
"element_type",
... | Add an output SOAP header description to the call info. | [
"Add",
"an",
"output",
"SOAP",
"header",
"description",
"to",
"the",
"call",
"info",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/wstools/WSDLTools.py#L1494-L1501 |
padfoot27/merlin | venv/lib/python2.7/site-packages/setuptools/dist.py | assert_bool | def assert_bool(dist, attr, value):
"""Verify that value is True, False, 0, or 1"""
if bool(value) != value:
raise DistutilsSetupError(
"%r must be a boolean value (got %r)" % (attr,value)
) | python | def assert_bool(dist, attr, value):
"""Verify that value is True, False, 0, or 1"""
if bool(value) != value:
raise DistutilsSetupError(
"%r must be a boolean value (got %r)" % (attr,value)
) | [
"def",
"assert_bool",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"if",
"bool",
"(",
"value",
")",
"!=",
"value",
":",
"raise",
"DistutilsSetupError",
"(",
"\"%r must be a boolean value (got %r)\"",
"%",
"(",
"attr",
",",
"value",
")",
")"
] | Verify that value is True, False, 0, or 1 | [
"Verify",
"that",
"value",
"is",
"True",
"False",
"0",
"or",
"1"
] | train | https://github.com/padfoot27/merlin/blob/c317505c5eca0e774fcf8b8c7f08801479a5099a/venv/lib/python2.7/site-packages/setuptools/dist.py#L115-L120 |
padfoot27/merlin | venv/lib/python2.7/site-packages/setuptools/dist.py | check_requirements | def check_requirements(dist, attr, value):
"""Verify that install_requires is a valid requirements list"""
try:
list(pkg_resources.parse_requirements(value))
except (TypeError,ValueError):
raise DistutilsSetupError(
"%r must be a string or list of strings "
"containin... | python | def check_requirements(dist, attr, value):
"""Verify that install_requires is a valid requirements list"""
try:
list(pkg_resources.parse_requirements(value))
except (TypeError,ValueError):
raise DistutilsSetupError(
"%r must be a string or list of strings "
"containin... | [
"def",
"check_requirements",
"(",
"dist",
",",
"attr",
",",
"value",
")",
":",
"try",
":",
"list",
"(",
"pkg_resources",
".",
"parse_requirements",
"(",
"value",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"raise",
"DistutilsSetupError... | Verify that install_requires is a valid requirements list | [
"Verify",
"that",
"install_requires",
"is",
"a",
"valid",
"requirements",
"list"
] | train | https://github.com/padfoot27/merlin/blob/c317505c5eca0e774fcf8b8c7f08801479a5099a/venv/lib/python2.7/site-packages/setuptools/dist.py#L121-L129 |
pudo-attic/loadkit | loadkit/types/table.py | Table.store | def store(self):
""" Create a context manager to store records in the cleaned
table. """
output = tempfile.NamedTemporaryFile(suffix='.json')
try:
def write(o):
line = json.dumps(o, default=json_default)
return output.write(line + '\n')
... | python | def store(self):
""" Create a context manager to store records in the cleaned
table. """
output = tempfile.NamedTemporaryFile(suffix='.json')
try:
def write(o):
line = json.dumps(o, default=json_default)
return output.write(line + '\n')
... | [
"def",
"store",
"(",
"self",
")",
":",
"output",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"suffix",
"=",
"'.json'",
")",
"try",
":",
"def",
"write",
"(",
"o",
")",
":",
"line",
"=",
"json",
".",
"dumps",
"(",
"o",
",",
"default",
"=",
"json... | Create a context manager to store records in the cleaned
table. | [
"Create",
"a",
"context",
"manager",
"to",
"store",
"records",
"in",
"the",
"cleaned",
"table",
"."
] | train | https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/types/table.py#L21-L40 |
pudo-attic/loadkit | loadkit/types/table.py | Table.records | def records(self):
""" Get each record that has been stored in the table. """
output = tempfile.NamedTemporaryFile(suffix='.json')
try:
log.info("Loading table from (%s)...", self._obj)
shutil.copyfileobj(self.fh(), output)
output.seek(0)
for line... | python | def records(self):
""" Get each record that has been stored in the table. """
output = tempfile.NamedTemporaryFile(suffix='.json')
try:
log.info("Loading table from (%s)...", self._obj)
shutil.copyfileobj(self.fh(), output)
output.seek(0)
for line... | [
"def",
"records",
"(",
"self",
")",
":",
"output",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"suffix",
"=",
"'.json'",
")",
"try",
":",
"log",
".",
"info",
"(",
"\"Loading table from (%s)...\"",
",",
"self",
".",
"_obj",
")",
"shutil",
".",
"copyfil... | Get each record that has been stored in the table. | [
"Get",
"each",
"record",
"that",
"has",
"been",
"stored",
"in",
"the",
"table",
"."
] | train | https://github.com/pudo-attic/loadkit/blob/1fb17e69e2ffaf3dac4f40b574c3b7afb2198b7c/loadkit/types/table.py#L42-L57 |
radjkarl/fancyTools | fancytools/pystructure/GetCallablesInPackage.py | GetCallablesInPackage._cleanRecursive | def _cleanRecursive(self, subSelf):
"""
Delete all NestedOrderedDict that haven't any entries.
"""
for key, item in list(subSelf.items()):
if self.isNestedDict(item):
if not item:
subSelf.pop(key)
else:
s... | python | def _cleanRecursive(self, subSelf):
"""
Delete all NestedOrderedDict that haven't any entries.
"""
for key, item in list(subSelf.items()):
if self.isNestedDict(item):
if not item:
subSelf.pop(key)
else:
s... | [
"def",
"_cleanRecursive",
"(",
"self",
",",
"subSelf",
")",
":",
"for",
"key",
",",
"item",
"in",
"list",
"(",
"subSelf",
".",
"items",
"(",
")",
")",
":",
"if",
"self",
".",
"isNestedDict",
"(",
"item",
")",
":",
"if",
"not",
"item",
":",
"subSelf... | Delete all NestedOrderedDict that haven't any entries. | [
"Delete",
"all",
"NestedOrderedDict",
"that",
"haven",
"t",
"any",
"entries",
"."
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/GetCallablesInPackage.py#L67-L76 |
radjkarl/fancyTools | fancytools/pystructure/GetCallablesInPackage.py | GetCallablesInPackage.belongsToModule | def belongsToModule(obj, module):
"""Returns True is an object belongs to a module."""
return obj.__module__ == module.__name__ or obj.__module__.startswith(
module.__name__) | python | def belongsToModule(obj, module):
"""Returns True is an object belongs to a module."""
return obj.__module__ == module.__name__ or obj.__module__.startswith(
module.__name__) | [
"def",
"belongsToModule",
"(",
"obj",
",",
"module",
")",
":",
"return",
"obj",
".",
"__module__",
"==",
"module",
".",
"__name__",
"or",
"obj",
".",
"__module__",
".",
"startswith",
"(",
"module",
".",
"__name__",
")"
] | Returns True is an object belongs to a module. | [
"Returns",
"True",
"is",
"an",
"object",
"belongs",
"to",
"a",
"module",
"."
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/GetCallablesInPackage.py#L125-L128 |
radjkarl/fancyTools | fancytools/pystructure/GetCallablesInPackage.py | GetCallablesInPackage.buildHirarchy | def buildHirarchy(self, horizontal_operation=None,
vertical_operation=None):
"""Walk through the nested dict structure and executes
horizontal_operation(name, callable) resp.
vertical_operation(name, callable) if defined.
"""
def buildRecursive(pkey, pval):
... | python | def buildHirarchy(self, horizontal_operation=None,
vertical_operation=None):
"""Walk through the nested dict structure and executes
horizontal_operation(name, callable) resp.
vertical_operation(name, callable) if defined.
"""
def buildRecursive(pkey, pval):
... | [
"def",
"buildHirarchy",
"(",
"self",
",",
"horizontal_operation",
"=",
"None",
",",
"vertical_operation",
"=",
"None",
")",
":",
"def",
"buildRecursive",
"(",
"pkey",
",",
"pval",
")",
":",
"if",
"self",
".",
"isNestedDict",
"(",
"pval",
")",
":",
"if",
... | Walk through the nested dict structure and executes
horizontal_operation(name, callable) resp.
vertical_operation(name, callable) if defined. | [
"Walk",
"through",
"the",
"nested",
"dict",
"structure",
"and",
"executes",
"horizontal_operation",
"(",
"name",
"callable",
")",
"resp",
".",
"vertical_operation",
"(",
"name",
"callable",
")",
"if",
"defined",
"."
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/GetCallablesInPackage.py#L130-L146 |
sassoo/goldman | goldman/middleware/deserializer/__init__.py | Middleware.process_resource | def process_resource(self, req, resp, resource):
""" Process the request after routing.
Deserializer selection needs a resource to determine which
deserializers are allowed. If a deserializer is required then
it will be initialized & added to the request object for
further proce... | python | def process_resource(self, req, resp, resource):
""" Process the request after routing.
Deserializer selection needs a resource to determine which
deserializers are allowed. If a deserializer is required then
it will be initialized & added to the request object for
further proce... | [
"def",
"process_resource",
"(",
"self",
",",
"req",
",",
"resp",
",",
"resource",
")",
":",
"if",
"req",
".",
"content_required",
"and",
"resource",
":",
"allowed",
"=",
"resource",
".",
"deserializer_mimetypes",
"if",
"req",
".",
"content_length",
"in",
"("... | Process the request after routing.
Deserializer selection needs a resource to determine which
deserializers are allowed. If a deserializer is required then
it will be initialized & added to the request object for
further processing. | [
"Process",
"the",
"request",
"after",
"routing",
"."
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/middleware/deserializer/__init__.py#L44-L62 |
erwan-lemonnier/dynamodb-object-store | dynadbobjectstore.py | ObjectStore.create_table | def create_table(self):
"""Create the DynamoDB table used by this ObjectStore, only if it does
not already exists.
"""
all_tables = self.aws_conn.list_tables()['TableNames']
if self.table_name in all_tables:
log.info("Table %s already exists" % self.table_name)
... | python | def create_table(self):
"""Create the DynamoDB table used by this ObjectStore, only if it does
not already exists.
"""
all_tables = self.aws_conn.list_tables()['TableNames']
if self.table_name in all_tables:
log.info("Table %s already exists" % self.table_name)
... | [
"def",
"create_table",
"(",
"self",
")",
":",
"all_tables",
"=",
"self",
".",
"aws_conn",
".",
"list_tables",
"(",
")",
"[",
"'TableNames'",
"]",
"if",
"self",
".",
"table_name",
"in",
"all_tables",
":",
"log",
".",
"info",
"(",
"\"Table %s already exists\""... | Create the DynamoDB table used by this ObjectStore, only if it does
not already exists. | [
"Create",
"the",
"DynamoDB",
"table",
"used",
"by",
"this",
"ObjectStore",
"only",
"if",
"it",
"does",
"not",
"already",
"exists",
"."
] | train | https://github.com/erwan-lemonnier/dynamodb-object-store/blob/fd0eee1912bc9c2139541a41928ee08efb4270f8/dynadbobjectstore.py#L28-L50 |
erwan-lemonnier/dynamodb-object-store | dynadbobjectstore.py | ObjectStore.put | def put(self, key, value, overwrite=True):
"""Marshall the python object given as 'value' into a string, using the
to_string marshalling method passed in the constructor, and store it in
the DynamoDB table under key 'key'.
"""
self._get_table()
s = self.to_string(value)
... | python | def put(self, key, value, overwrite=True):
"""Marshall the python object given as 'value' into a string, using the
to_string marshalling method passed in the constructor, and store it in
the DynamoDB table under key 'key'.
"""
self._get_table()
s = self.to_string(value)
... | [
"def",
"put",
"(",
"self",
",",
"key",
",",
"value",
",",
"overwrite",
"=",
"True",
")",
":",
"self",
".",
"_get_table",
"(",
")",
"s",
"=",
"self",
".",
"to_string",
"(",
"value",
")",
"log",
".",
"debug",
"(",
"\"Storing in key '%s' the object: '%s'\""... | Marshall the python object given as 'value' into a string, using the
to_string marshalling method passed in the constructor, and store it in
the DynamoDB table under key 'key'. | [
"Marshall",
"the",
"python",
"object",
"given",
"as",
"value",
"into",
"a",
"string",
"using",
"the",
"to_string",
"marshalling",
"method",
"passed",
"in",
"the",
"constructor",
"and",
"store",
"it",
"in",
"the",
"DynamoDB",
"table",
"under",
"key",
"key",
"... | train | https://github.com/erwan-lemonnier/dynamodb-object-store/blob/fd0eee1912bc9c2139541a41928ee08efb4270f8/dynadbobjectstore.py#L56-L70 |
erwan-lemonnier/dynamodb-object-store | dynadbobjectstore.py | ObjectStore.get | def get(self, key):
"""Get the string representation of the object stored in DynamoDB under this key,
convert it back to an object using the 'from_string' unmarshalling method passed
in the constructor and return the object. Return None if no object found.
"""
self._get_table()
... | python | def get(self, key):
"""Get the string representation of the object stored in DynamoDB under this key,
convert it back to an object using the 'from_string' unmarshalling method passed
in the constructor and return the object. Return None if no object found.
"""
self._get_table()
... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_get_table",
"(",
")",
"s",
"=",
"self",
".",
"table",
".",
"get_item",
"(",
"key",
"=",
"key",
")",
"log",
".",
"debug",
"(",
"\"Retrieved from key '%s' the object: '%s'\"",
"%",
"(",
"key... | Get the string representation of the object stored in DynamoDB under this key,
convert it back to an object using the 'from_string' unmarshalling method passed
in the constructor and return the object. Return None if no object found. | [
"Get",
"the",
"string",
"representation",
"of",
"the",
"object",
"stored",
"in",
"DynamoDB",
"under",
"this",
"key",
"convert",
"it",
"back",
"to",
"an",
"object",
"using",
"the",
"from_string",
"unmarshalling",
"method",
"passed",
"in",
"the",
"constructor",
... | train | https://github.com/erwan-lemonnier/dynamodb-object-store/blob/fd0eee1912bc9c2139541a41928ee08efb4270f8/dynadbobjectstore.py#L72-L80 |
erwan-lemonnier/dynamodb-object-store | dynadbobjectstore.py | ObjectStore.delete | def delete(self, key):
"""If this key exists, delete it"""
self._get_table()
self.table.delete_item(key=key)
log.debug("Deleted item at key '%s'" % (key)) | python | def delete(self, key):
"""If this key exists, delete it"""
self._get_table()
self.table.delete_item(key=key)
log.debug("Deleted item at key '%s'" % (key)) | [
"def",
"delete",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_get_table",
"(",
")",
"self",
".",
"table",
".",
"delete_item",
"(",
"key",
"=",
"key",
")",
"log",
".",
"debug",
"(",
"\"Deleted item at key '%s'\"",
"%",
"(",
"key",
")",
")"
] | If this key exists, delete it | [
"If",
"this",
"key",
"exists",
"delete",
"it"
] | train | https://github.com/erwan-lemonnier/dynamodb-object-store/blob/fd0eee1912bc9c2139541a41928ee08efb4270f8/dynadbobjectstore.py#L82-L86 |
yunojuno/python-env-utils | env_utils/utils.py | _get_env | def _get_env(key, default=None, coerce=lambda x: x, required=False):
"""
Return env var coerced into a type other than string.
This function extends the standard os.getenv function to enable
the coercion of values into data types other than string (all env
vars are strings by default).
Args:
... | python | def _get_env(key, default=None, coerce=lambda x: x, required=False):
"""
Return env var coerced into a type other than string.
This function extends the standard os.getenv function to enable
the coercion of values into data types other than string (all env
vars are strings by default).
Args:
... | [
"def",
"_get_env",
"(",
"key",
",",
"default",
"=",
"None",
",",
"coerce",
"=",
"lambda",
"x",
":",
"x",
",",
"required",
"=",
"False",
")",
":",
"try",
":",
"value",
"=",
"os",
".",
"environ",
"[",
"key",
"]",
"except",
"KeyError",
":",
"if",
"r... | Return env var coerced into a type other than string.
This function extends the standard os.getenv function to enable
the coercion of values into data types other than string (all env
vars are strings by default).
Args:
key: string, the name of the env var to look up
Kwargs:
defau... | [
"Return",
"env",
"var",
"coerced",
"into",
"a",
"type",
"other",
"than",
"string",
"."
] | train | https://github.com/yunojuno/python-env-utils/blob/7f3b5635f93322759856644901221955908e7e99/env_utils/utils.py#L27-L60 |
yunojuno/python-env-utils | env_utils/utils.py | get_env | def get_env(key, *default, **kwargs):
"""
Return env var.
This is the parent function of all other get_foo functions,
and is responsible for unpacking args/kwargs into the values
that _get_env expects (it is the root function that actually
interacts with environ).
Args:
key: string... | python | def get_env(key, *default, **kwargs):
"""
Return env var.
This is the parent function of all other get_foo functions,
and is responsible for unpacking args/kwargs into the values
that _get_env expects (it is the root function that actually
interacts with environ).
Args:
key: string... | [
"def",
"get_env",
"(",
"key",
",",
"*",
"default",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"len",
"(",
"default",
")",
"in",
"(",
"0",
",",
"1",
")",
",",
"\"Too many args supplied.\"",
"func",
"=",
"kwargs",
".",
"get",
"(",
"'coerce'",
",",
... | Return env var.
This is the parent function of all other get_foo functions,
and is responsible for unpacking args/kwargs into the values
that _get_env expects (it is the root function that actually
interacts with environ).
Args:
key: string, the env var name to look up.
default: (o... | [
"Return",
"env",
"var",
"."
] | train | https://github.com/yunojuno/python-env-utils/blob/7f3b5635f93322759856644901221955908e7e99/env_utils/utils.py#L94-L123 |
yunojuno/python-env-utils | env_utils/utils.py | get_list | def get_list(key, *default, **kwargs):
"""Return env var as a list."""
separator = kwargs.get('separator', ' ')
return get_env(key, *default, coerce=lambda x: x.split(separator)) | python | def get_list(key, *default, **kwargs):
"""Return env var as a list."""
separator = kwargs.get('separator', ' ')
return get_env(key, *default, coerce=lambda x: x.split(separator)) | [
"def",
"get_list",
"(",
"key",
",",
"*",
"default",
",",
"*",
"*",
"kwargs",
")",
":",
"separator",
"=",
"kwargs",
".",
"get",
"(",
"'separator'",
",",
"' '",
")",
"return",
"get_env",
"(",
"key",
",",
"*",
"default",
",",
"coerce",
"=",
"lambda",
... | Return env var as a list. | [
"Return",
"env",
"var",
"as",
"a",
"list",
"."
] | train | https://github.com/yunojuno/python-env-utils/blob/7f3b5635f93322759856644901221955908e7e99/env_utils/utils.py#L146-L149 |
dossier/dossier.models | dossier/models/etl/ads.py | row_to_content_obj | def row_to_content_obj(key_row):
'''Returns ``FeatureCollection`` given an HBase artifact row.
Note that the FC returned has a Unicode feature ``artifact_id``
set to the row's key.
'''
key, row = key_row
cid = mk_content_id(key.encode('utf-8'))
response = row.get('response', {})
other_... | python | def row_to_content_obj(key_row):
'''Returns ``FeatureCollection`` given an HBase artifact row.
Note that the FC returned has a Unicode feature ``artifact_id``
set to the row's key.
'''
key, row = key_row
cid = mk_content_id(key.encode('utf-8'))
response = row.get('response', {})
other_... | [
"def",
"row_to_content_obj",
"(",
"key_row",
")",
":",
"key",
",",
"row",
"=",
"key_row",
"cid",
"=",
"mk_content_id",
"(",
"key",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"response",
"=",
"row",
".",
"get",
"(",
"'response'",
",",
"{",
"}",
")",
"ot... | Returns ``FeatureCollection`` given an HBase artifact row.
Note that the FC returned has a Unicode feature ``artifact_id``
set to the row's key. | [
"Returns",
"FeatureCollection",
"given",
"an",
"HBase",
"artifact",
"row",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/etl/ads.py#L58-L83 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCtimes.py | _dict_to_tuple | def _dict_to_tuple(d):
'''Convert a dictionary to a time tuple. Depends on key values in the
regexp pattern!
'''
# TODO: Adding a ms field to struct_time tuples is problematic
# since they don't have this field. Should use datetime
# which has a microseconds field, else no ms.. When mapp... | python | def _dict_to_tuple(d):
'''Convert a dictionary to a time tuple. Depends on key values in the
regexp pattern!
'''
# TODO: Adding a ms field to struct_time tuples is problematic
# since they don't have this field. Should use datetime
# which has a microseconds field, else no ms.. When mapp... | [
"def",
"_dict_to_tuple",
"(",
"d",
")",
":",
"# TODO: Adding a ms field to struct_time tuples is problematic ",
"# since they don't have this field. Should use datetime",
"# which has a microseconds field, else no ms.. When mapping struct_time ",
"# to gDateTime the last 3 fields are irrelevant,... | Convert a dictionary to a time tuple. Depends on key values in the
regexp pattern! | [
"Convert",
"a",
"dictionary",
"to",
"a",
"time",
"tuple",
".",
"Depends",
"on",
"key",
"values",
"in",
"the",
"regexp",
"pattern!"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCtimes.py#L79-L135 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCtimes.py | _localtimezone.dst | def dst(self, dt):
"""datetime -> DST offset in minutes east of UTC."""
tt = _localtime(_mktime((dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
if tt.tm_isdst > 0: return _dstdiff
return _zero | python | def dst(self, dt):
"""datetime -> DST offset in minutes east of UTC."""
tt = _localtime(_mktime((dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
if tt.tm_isdst > 0: return _dstdiff
return _zero | [
"def",
"dst",
"(",
"self",
",",
"dt",
")",
":",
"tt",
"=",
"_localtime",
"(",
"_mktime",
"(",
"(",
"dt",
".",
"year",
",",
"dt",
".",
"month",
",",
"dt",
".",
"day",
",",
"dt",
".",
"hour",
",",
"dt",
".",
"minute",
",",
"dt",
".",
"second",
... | datetime -> DST offset in minutes east of UTC. | [
"datetime",
"-",
">",
"DST",
"offset",
"in",
"minutes",
"east",
"of",
"UTC",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCtimes.py#L30-L35 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCtimes.py | _localtimezone.tzname | def tzname(self, dt):
"""datetime -> string name of time zone."""
tt = _localtime(_mktime((dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
return _time.tzname[tt.tm_isdst > 0] | python | def tzname(self, dt):
"""datetime -> string name of time zone."""
tt = _localtime(_mktime((dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
return _time.tzname[tt.tm_isdst > 0] | [
"def",
"tzname",
"(",
"self",
",",
"dt",
")",
":",
"tt",
"=",
"_localtime",
"(",
"_mktime",
"(",
"(",
"dt",
".",
"year",
",",
"dt",
".",
"month",
",",
"dt",
".",
"day",
",",
"dt",
".",
"hour",
",",
"dt",
".",
"minute",
",",
"dt",
".",
"second... | datetime -> string name of time zone. | [
"datetime",
"-",
">",
"string",
"name",
"of",
"time",
"zone",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCtimes.py#L40-L44 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCtimes.py | _localtimezone.utcoffset | def utcoffset(self, dt):
"""datetime -> minutes east of UTC (negative for west of UTC)."""
tt = _localtime(_mktime((dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
if tt.tm_isdst > 0: return _dstoffset
return _stdoffset | python | def utcoffset(self, dt):
"""datetime -> minutes east of UTC (negative for west of UTC)."""
tt = _localtime(_mktime((dt.year, dt.month, dt.day,
dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)))
if tt.tm_isdst > 0: return _dstoffset
return _stdoffset | [
"def",
"utcoffset",
"(",
"self",
",",
"dt",
")",
":",
"tt",
"=",
"_localtime",
"(",
"_mktime",
"(",
"(",
"dt",
".",
"year",
",",
"dt",
".",
"month",
",",
"dt",
".",
"day",
",",
"dt",
".",
"hour",
",",
"dt",
".",
"minute",
",",
"dt",
".",
"sec... | datetime -> minutes east of UTC (negative for west of UTC). | [
"datetime",
"-",
">",
"minutes",
"east",
"of",
"UTC",
"(",
"negative",
"for",
"west",
"of",
"UTC",
")",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCtimes.py#L46-L51 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCtimes.py | Duration.text_to_data | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data.
'''
if text is None:
return None
m = Duration.lex_pattern.match(text)
if m is None:
raise EvaluateException('Illegal duration', ps.Backtrace(elt))
d = m.groupdict()... | python | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data.
'''
if text is None:
return None
m = Duration.lex_pattern.match(text)
if m is None:
raise EvaluateException('Illegal duration', ps.Backtrace(elt))
d = m.groupdict()... | [
"def",
"text_to_data",
"(",
"self",
",",
"text",
",",
"elt",
",",
"ps",
")",
":",
"if",
"text",
"is",
"None",
":",
"return",
"None",
"m",
"=",
"Duration",
".",
"lex_pattern",
".",
"match",
"(",
"text",
")",
"if",
"m",
"is",
"None",
":",
"raise",
... | convert text into typecode specific data. | [
"convert",
"text",
"into",
"typecode",
"specific",
"data",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCtimes.py#L149-L167 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/TCtimes.py | Gregorian.text_to_data | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data.
'''
if text is None:
return None
m = self.lex_pattern.match(text)
if not m:
raise EvaluateException('Bad Gregorian: %s' %text, ps.Backtrace(elt))
try:
... | python | def text_to_data(self, text, elt, ps):
'''convert text into typecode specific data.
'''
if text is None:
return None
m = self.lex_pattern.match(text)
if not m:
raise EvaluateException('Bad Gregorian: %s' %text, ps.Backtrace(elt))
try:
... | [
"def",
"text_to_data",
"(",
"self",
",",
"text",
",",
"elt",
",",
"ps",
")",
":",
"if",
"text",
"is",
"None",
":",
"return",
"None",
"m",
"=",
"self",
".",
"lex_pattern",
".",
"match",
"(",
"text",
")",
"if",
"not",
"m",
":",
"raise",
"EvaluateExce... | convert text into typecode specific data. | [
"convert",
"text",
"into",
"typecode",
"specific",
"data",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/TCtimes.py#L192-L209 |
glue-viz/echo | echo/core.py | add_callback | def add_callback(instance, prop, callback, echo_old=False, priority=0):
"""
Attach a callback function to a property in an instance
Parameters
----------
instance
The instance to add the callback to
prop : str
Name of callback property in `instance`
callback : func
T... | python | def add_callback(instance, prop, callback, echo_old=False, priority=0):
"""
Attach a callback function to a property in an instance
Parameters
----------
instance
The instance to add the callback to
prop : str
Name of callback property in `instance`
callback : func
T... | [
"def",
"add_callback",
"(",
"instance",
",",
"prop",
",",
"callback",
",",
"echo_old",
"=",
"False",
",",
"priority",
"=",
"0",
")",
":",
"p",
"=",
"getattr",
"(",
"type",
"(",
"instance",
")",
",",
"prop",
")",
"if",
"not",
"isinstance",
"(",
"p",
... | Attach a callback function to a property in an instance
Parameters
----------
instance
The instance to add the callback to
prop : str
Name of callback property in `instance`
callback : func
The callback function to add
echo_old : bool, optional
If `True`, the cal... | [
"Attach",
"a",
"callback",
"function",
"to",
"a",
"property",
"in",
"an",
"instance"
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L334-L372 |
glue-viz/echo | echo/core.py | remove_callback | def remove_callback(instance, prop, callback):
"""
Remove a callback function from a property in an instance
Parameters
----------
instance
The instance to detach the callback from
prop : str
Name of callback property in `instance`
callback : func
The callback functi... | python | def remove_callback(instance, prop, callback):
"""
Remove a callback function from a property in an instance
Parameters
----------
instance
The instance to detach the callback from
prop : str
Name of callback property in `instance`
callback : func
The callback functi... | [
"def",
"remove_callback",
"(",
"instance",
",",
"prop",
",",
"callback",
")",
":",
"p",
"=",
"getattr",
"(",
"type",
"(",
"instance",
")",
",",
"prop",
")",
"if",
"not",
"isinstance",
"(",
"p",
",",
"CallbackProperty",
")",
":",
"raise",
"TypeError",
"... | Remove a callback function from a property in an instance
Parameters
----------
instance
The instance to detach the callback from
prop : str
Name of callback property in `instance`
callback : func
The callback function to remove | [
"Remove",
"a",
"callback",
"function",
"from",
"a",
"property",
"in",
"an",
"instance"
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L375-L391 |
glue-viz/echo | echo/core.py | callback_property | def callback_property(getter):
"""
A decorator to build a CallbackProperty.
This is used by wrapping a getter method, similar to the use of @property::
class Foo(object):
@callback_property
def x(self):
return self._x
@x.setter
def ... | python | def callback_property(getter):
"""
A decorator to build a CallbackProperty.
This is used by wrapping a getter method, similar to the use of @property::
class Foo(object):
@callback_property
def x(self):
return self._x
@x.setter
def ... | [
"def",
"callback_property",
"(",
"getter",
")",
":",
"cb",
"=",
"CallbackProperty",
"(",
"getter",
"=",
"getter",
")",
"cb",
".",
"__doc__",
"=",
"getter",
".",
"__doc__",
"return",
"cb"
] | A decorator to build a CallbackProperty.
This is used by wrapping a getter method, similar to the use of @property::
class Foo(object):
@callback_property
def x(self):
return self._x
@x.setter
def x(self, value):
self._x = v... | [
"A",
"decorator",
"to",
"build",
"a",
"CallbackProperty",
"."
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L394-L418 |
glue-viz/echo | echo/core.py | ignore_callback | def ignore_callback(instance, *props):
"""
Temporarily ignore any callbacks from one or more callback properties
This is a context manager. Within the context block, no callbacks will be
issued. In contrast with :func:`~echo.delay_callback`, no callbakcs will be
called on exiting the context manage... | python | def ignore_callback(instance, *props):
"""
Temporarily ignore any callbacks from one or more callback properties
This is a context manager. Within the context block, no callbacks will be
issued. In contrast with :func:`~echo.delay_callback`, no callbakcs will be
called on exiting the context manage... | [
"def",
"ignore_callback",
"(",
"instance",
",",
"*",
"props",
")",
":",
"for",
"prop",
"in",
"props",
":",
"p",
"=",
"getattr",
"(",
"type",
"(",
"instance",
")",
",",
"prop",
")",
"if",
"not",
"isinstance",
"(",
"p",
",",
"CallbackProperty",
")",
":... | Temporarily ignore any callbacks from one or more callback properties
This is a context manager. Within the context block, no callbacks will be
issued. In contrast with :func:`~echo.delay_callback`, no callbakcs will be
called on exiting the context manager
Parameters
----------
instance
... | [
"Temporarily",
"ignore",
"any",
"callbacks",
"from",
"one",
"or",
"more",
"callback",
"properties"
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L511-L555 |
glue-viz/echo | echo/core.py | CallbackProperty.notify | def notify(self, instance, old, new):
"""
Call all callback functions with the current value
Each callback will either be called using
callback(new) or callback(old, new) depending
on whether ``echo_old`` was set to `True` when calling
:func:`~echo.add_callback`
... | python | def notify(self, instance, old, new):
"""
Call all callback functions with the current value
Each callback will either be called using
callback(new) or callback(old, new) depending
on whether ``echo_old`` was set to `True` when calling
:func:`~echo.add_callback`
... | [
"def",
"notify",
"(",
"self",
",",
"instance",
",",
"old",
",",
"new",
")",
":",
"if",
"self",
".",
"_disabled",
".",
"get",
"(",
"instance",
",",
"False",
")",
":",
"return",
"for",
"cback",
"in",
"self",
".",
"_callbacks",
".",
"get",
"(",
"insta... | Call all callback functions with the current value
Each callback will either be called using
callback(new) or callback(old, new) depending
on whether ``echo_old`` was set to `True` when calling
:func:`~echo.add_callback`
Parameters
----------
instance
... | [
"Call",
"all",
"callback",
"functions",
"with",
"the",
"current",
"value"
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L97-L120 |
glue-viz/echo | echo/core.py | CallbackProperty.add_callback | def add_callback(self, instance, func, echo_old=False, priority=0):
"""
Add a callback to a specific instance that manages this property
Parameters
----------
instance
The instance to add the callback to
func : func
The callback function to add
... | python | def add_callback(self, instance, func, echo_old=False, priority=0):
"""
Add a callback to a specific instance that manages this property
Parameters
----------
instance
The instance to add the callback to
func : func
The callback function to add
... | [
"def",
"add_callback",
"(",
"self",
",",
"instance",
",",
"func",
",",
"echo_old",
"=",
"False",
",",
"priority",
"=",
"0",
")",
":",
"if",
"echo_old",
":",
"self",
".",
"_2arg_callbacks",
".",
"setdefault",
"(",
"instance",
",",
"CallbackContainer",
"(",
... | Add a callback to a specific instance that manages this property
Parameters
----------
instance
The instance to add the callback to
func : func
The callback function to add
echo_old : bool, optional
If `True`, the callback function will be inv... | [
"Add",
"a",
"callback",
"to",
"a",
"specific",
"instance",
"that",
"manages",
"this",
"property"
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L134-L156 |
glue-viz/echo | echo/core.py | CallbackProperty.remove_callback | def remove_callback(self, instance, func):
"""
Remove a previously-added callback
Parameters
----------
instance
The instance to detach the callback from
func : func
The callback function to remove
"""
for cb in [self._callbacks, s... | python | def remove_callback(self, instance, func):
"""
Remove a previously-added callback
Parameters
----------
instance
The instance to detach the callback from
func : func
The callback function to remove
"""
for cb in [self._callbacks, s... | [
"def",
"remove_callback",
"(",
"self",
",",
"instance",
",",
"func",
")",
":",
"for",
"cb",
"in",
"[",
"self",
".",
"_callbacks",
",",
"self",
".",
"_2arg_callbacks",
"]",
":",
"if",
"instance",
"not",
"in",
"cb",
":",
"continue",
"if",
"func",
"in",
... | Remove a previously-added callback
Parameters
----------
instance
The instance to detach the callback from
func : func
The callback function to remove | [
"Remove",
"a",
"previously",
"-",
"added",
"callback"
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L158-L176 |
glue-viz/echo | echo/core.py | HasCallbackProperties.add_callback | def add_callback(self, name, callback, echo_old=False, priority=0):
"""
Add a callback that gets triggered when a callback property of the
class changes.
Parameters
----------
name : str
The instance to add the callback to.
callback : func
... | python | def add_callback(self, name, callback, echo_old=False, priority=0):
"""
Add a callback that gets triggered when a callback property of the
class changes.
Parameters
----------
name : str
The instance to add the callback to.
callback : func
... | [
"def",
"add_callback",
"(",
"self",
",",
"name",
",",
"callback",
",",
"echo_old",
"=",
"False",
",",
"priority",
"=",
"0",
")",
":",
"if",
"self",
".",
"is_callback_property",
"(",
"name",
")",
":",
"prop",
"=",
"getattr",
"(",
"type",
"(",
"self",
... | Add a callback that gets triggered when a callback property of the
class changes.
Parameters
----------
name : str
The instance to add the callback to.
callback : func
The callback function to add
echo_old : bool, optional
If `True`, t... | [
"Add",
"a",
"callback",
"that",
"gets",
"triggered",
"when",
"a",
"callback",
"property",
"of",
"the",
"class",
"changes",
"."
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L245-L268 |
glue-viz/echo | echo/core.py | HasCallbackProperties.remove_callback | def remove_callback(self, name, callback):
"""
Remove a previously-added callback
Parameters
----------
name : str
The instance to remove the callback from.
func : func
The callback function to remove
"""
if self.is_callback_prope... | python | def remove_callback(self, name, callback):
"""
Remove a previously-added callback
Parameters
----------
name : str
The instance to remove the callback from.
func : func
The callback function to remove
"""
if self.is_callback_prope... | [
"def",
"remove_callback",
"(",
"self",
",",
"name",
",",
"callback",
")",
":",
"if",
"self",
".",
"is_callback_property",
"(",
"name",
")",
":",
"prop",
"=",
"getattr",
"(",
"type",
"(",
"self",
")",
",",
"name",
")",
"try",
":",
"prop",
".",
"remove... | Remove a previously-added callback
Parameters
----------
name : str
The instance to remove the callback from.
func : func
The callback function to remove | [
"Remove",
"a",
"previously",
"-",
"added",
"callback"
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L270-L289 |
glue-viz/echo | echo/core.py | HasCallbackProperties.iter_callback_properties | def iter_callback_properties(self):
"""
Iterator to loop over all callback properties.
"""
for name in dir(self):
if self.is_callback_property(name):
yield name, getattr(type(self), name) | python | def iter_callback_properties(self):
"""
Iterator to loop over all callback properties.
"""
for name in dir(self):
if self.is_callback_property(name):
yield name, getattr(type(self), name) | [
"def",
"iter_callback_properties",
"(",
"self",
")",
":",
"for",
"name",
"in",
"dir",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_callback_property",
"(",
"name",
")",
":",
"yield",
"name",
",",
"getattr",
"(",
"type",
"(",
"self",
")",
",",
"name",
... | Iterator to loop over all callback properties. | [
"Iterator",
"to",
"loop",
"over",
"all",
"callback",
"properties",
"."
] | train | https://github.com/glue-viz/echo/blob/6ad54cc5e869de27c34e8716f2619ddc640f08fe/echo/core.py#L325-L331 |
cmutel/constructive_geometries | constructive_geometries/cg.py | has_gis | def has_gis(wrapped, instance, args, kwargs):
"""Skip function execution if there are no presamples"""
if gis:
return wrapped(*args, **kwargs)
else:
warn(MISSING_GIS) | python | def has_gis(wrapped, instance, args, kwargs):
"""Skip function execution if there are no presamples"""
if gis:
return wrapped(*args, **kwargs)
else:
warn(MISSING_GIS) | [
"def",
"has_gis",
"(",
"wrapped",
",",
"instance",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"gis",
":",
"return",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"else",
":",
"warn",
"(",
"MISSING_GIS",
")"
] | Skip function execution if there are no presamples | [
"Skip",
"function",
"execution",
"if",
"there",
"are",
"no",
"presamples"
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L22-L27 |
cmutel/constructive_geometries | constructive_geometries/cg.py | sha256 | def sha256(filepath, blocksize=65536):
"""Generate SHA 256 hash for file at `filepath`"""
hasher = hashlib.sha256()
fo = open(filepath, 'rb')
buf = fo.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = fo.read(blocksize)
return hasher.hexdigest() | python | def sha256(filepath, blocksize=65536):
"""Generate SHA 256 hash for file at `filepath`"""
hasher = hashlib.sha256()
fo = open(filepath, 'rb')
buf = fo.read(blocksize)
while len(buf) > 0:
hasher.update(buf)
buf = fo.read(blocksize)
return hasher.hexdigest() | [
"def",
"sha256",
"(",
"filepath",
",",
"blocksize",
"=",
"65536",
")",
":",
"hasher",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"fo",
"=",
"open",
"(",
"filepath",
",",
"'rb'",
")",
"buf",
"=",
"fo",
".",
"read",
"(",
"blocksize",
")",
"while",
"len... | Generate SHA 256 hash for file at `filepath` | [
"Generate",
"SHA",
"256",
"hash",
"for",
"file",
"at",
"filepath"
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L33-L41 |
cmutel/constructive_geometries | constructive_geometries/cg.py | ConstructiveGeometries.check_data | def check_data(self):
"""Check that definitions file is present, and that faces file is readable."""
assert os.path.exists(self.data_fp)
if gis:
with fiona.drivers():
with fiona.open(self.faces_fp) as src:
assert src.meta
gpkg_hash = json.... | python | def check_data(self):
"""Check that definitions file is present, and that faces file is readable."""
assert os.path.exists(self.data_fp)
if gis:
with fiona.drivers():
with fiona.open(self.faces_fp) as src:
assert src.meta
gpkg_hash = json.... | [
"def",
"check_data",
"(",
"self",
")",
":",
"assert",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"data_fp",
")",
"if",
"gis",
":",
"with",
"fiona",
".",
"drivers",
"(",
")",
":",
"with",
"fiona",
".",
"open",
"(",
"self",
".",
"faces_fp",
... | Check that definitions file is present, and that faces file is readable. | [
"Check",
"that",
"definitions",
"file",
"is",
"present",
"and",
"that",
"faces",
"file",
"is",
"readable",
"."
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L73-L82 |
cmutel/constructive_geometries | constructive_geometries/cg.py | ConstructiveGeometries.load_definitions | def load_definitions(self):
"""Load mapping of country names to face ids"""
self.data = dict(json.load(open(self.data_fp))['data'])
self.all_faces = set(self.data.pop("__all__"))
self.locations = set(self.data.keys()) | python | def load_definitions(self):
"""Load mapping of country names to face ids"""
self.data = dict(json.load(open(self.data_fp))['data'])
self.all_faces = set(self.data.pop("__all__"))
self.locations = set(self.data.keys()) | [
"def",
"load_definitions",
"(",
"self",
")",
":",
"self",
".",
"data",
"=",
"dict",
"(",
"json",
".",
"load",
"(",
"open",
"(",
"self",
".",
"data_fp",
")",
")",
"[",
"'data'",
"]",
")",
"self",
".",
"all_faces",
"=",
"set",
"(",
"self",
".",
"da... | Load mapping of country names to face ids | [
"Load",
"mapping",
"of",
"country",
"names",
"to",
"face",
"ids"
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L84-L88 |
cmutel/constructive_geometries | constructive_geometries/cg.py | ConstructiveGeometries.construct_rest_of_world | def construct_rest_of_world(self, excluded, name=None, fp=None, geom=True):
"""Construct rest-of-world geometry and optionally write to filepath ``fp``.
Excludes faces in location list ``excluded``. ``excluded`` must be an iterable of location strings (not face ids)."""
for location in excluded... | python | def construct_rest_of_world(self, excluded, name=None, fp=None, geom=True):
"""Construct rest-of-world geometry and optionally write to filepath ``fp``.
Excludes faces in location list ``excluded``. ``excluded`` must be an iterable of location strings (not face ids)."""
for location in excluded... | [
"def",
"construct_rest_of_world",
"(",
"self",
",",
"excluded",
",",
"name",
"=",
"None",
",",
"fp",
"=",
"None",
",",
"geom",
"=",
"True",
")",
":",
"for",
"location",
"in",
"excluded",
":",
"assert",
"location",
"in",
"self",
".",
"locations",
",",
"... | Construct rest-of-world geometry and optionally write to filepath ``fp``.
Excludes faces in location list ``excluded``. ``excluded`` must be an iterable of location strings (not face ids). | [
"Construct",
"rest",
"-",
"of",
"-",
"world",
"geometry",
"and",
"optionally",
"write",
"to",
"filepath",
"fp",
"."
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L90-L111 |
cmutel/constructive_geometries | constructive_geometries/cg.py | ConstructiveGeometries.construct_rest_of_worlds | def construct_rest_of_worlds(self, excluded, fp=None, use_mp=True, simplify=True):
"""Construct many rest-of-world geometries and optionally write to filepath ``fp``.
``excluded`` must be a **dictionary** of {"rest-of-world label": ["names", "of", "excluded", "locations"]}``."""
geoms = {}
... | python | def construct_rest_of_worlds(self, excluded, fp=None, use_mp=True, simplify=True):
"""Construct many rest-of-world geometries and optionally write to filepath ``fp``.
``excluded`` must be a **dictionary** of {"rest-of-world label": ["names", "of", "excluded", "locations"]}``."""
geoms = {}
... | [
"def",
"construct_rest_of_worlds",
"(",
"self",
",",
"excluded",
",",
"fp",
"=",
"None",
",",
"use_mp",
"=",
"True",
",",
"simplify",
"=",
"True",
")",
":",
"geoms",
"=",
"{",
"}",
"raw_data",
"=",
"[",
"]",
"for",
"key",
"in",
"sorted",
"(",
"exclud... | Construct many rest-of-world geometries and optionally write to filepath ``fp``.
``excluded`` must be a **dictionary** of {"rest-of-world label": ["names", "of", "excluded", "locations"]}``. | [
"Construct",
"many",
"rest",
"-",
"of",
"-",
"world",
"geometries",
"and",
"optionally",
"write",
"to",
"filepath",
"fp",
"."
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L114-L141 |
cmutel/constructive_geometries | constructive_geometries/cg.py | ConstructiveGeometries.construct_rest_of_worlds_mapping | def construct_rest_of_worlds_mapping(self, excluded, fp=None):
"""Construct topo mapping file for ``excluded``.
``excluded`` must be a **dictionary** of {"rest-of-world label": ["names", "of", "excluded", "locations"]}``.
Topo mapping has the data format:
.. code-block:: python
... | python | def construct_rest_of_worlds_mapping(self, excluded, fp=None):
"""Construct topo mapping file for ``excluded``.
``excluded`` must be a **dictionary** of {"rest-of-world label": ["names", "of", "excluded", "locations"]}``.
Topo mapping has the data format:
.. code-block:: python
... | [
"def",
"construct_rest_of_worlds_mapping",
"(",
"self",
",",
"excluded",
",",
"fp",
"=",
"None",
")",
":",
"metadata",
"=",
"{",
"'filename'",
":",
"'faces.gpkg'",
",",
"'field'",
":",
"'id'",
",",
"'sha256'",
":",
"sha256",
"(",
"self",
".",
"faces_fp",
"... | Construct topo mapping file for ``excluded``.
``excluded`` must be a **dictionary** of {"rest-of-world label": ["names", "of", "excluded", "locations"]}``.
Topo mapping has the data format:
.. code-block:: python
{
'data': [
['location label', ... | [
"Construct",
"topo",
"mapping",
"file",
"for",
"excluded",
"."
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L143-L182 |
cmutel/constructive_geometries | constructive_geometries/cg.py | ConstructiveGeometries.construct_difference | def construct_difference(self, parent, excluded, name=None, fp=None):
"""Construct geometry from ``parent`` without the regions in ``excluded`` and optionally write to filepath ``fp``.
``excluded`` must be an iterable of location strings (not face ids)."""
assert parent in self.locations, "Can'... | python | def construct_difference(self, parent, excluded, name=None, fp=None):
"""Construct geometry from ``parent`` without the regions in ``excluded`` and optionally write to filepath ``fp``.
``excluded`` must be an iterable of location strings (not face ids)."""
assert parent in self.locations, "Can'... | [
"def",
"construct_difference",
"(",
"self",
",",
"parent",
",",
"excluded",
",",
"name",
"=",
"None",
",",
"fp",
"=",
"None",
")",
":",
"assert",
"parent",
"in",
"self",
".",
"locations",
",",
"\"Can't find location {}\"",
".",
"format",
"(",
"parent",
")"... | Construct geometry from ``parent`` without the regions in ``excluded`` and optionally write to filepath ``fp``.
``excluded`` must be an iterable of location strings (not face ids). | [
"Construct",
"geometry",
"from",
"parent",
"without",
"the",
"regions",
"in",
"excluded",
"and",
"optionally",
"write",
"to",
"filepath",
"fp",
"."
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L185-L200 |
cmutel/constructive_geometries | constructive_geometries/cg.py | ConstructiveGeometries.write_geoms_to_file | def write_geoms_to_file(self, fp, geoms, names=None):
"""Write unioned geometries ``geoms`` to filepath ``fp``. Optionally use ``names`` in name field."""
if fp[-5:] != '.gpkg':
fp = fp + '.gpkg'
if names is not None:
assert len(geoms) == len(names), "Inconsistent length ... | python | def write_geoms_to_file(self, fp, geoms, names=None):
"""Write unioned geometries ``geoms`` to filepath ``fp``. Optionally use ``names`` in name field."""
if fp[-5:] != '.gpkg':
fp = fp + '.gpkg'
if names is not None:
assert len(geoms) == len(names), "Inconsistent length ... | [
"def",
"write_geoms_to_file",
"(",
"self",
",",
"fp",
",",
"geoms",
",",
"names",
"=",
"None",
")",
":",
"if",
"fp",
"[",
"-",
"5",
":",
"]",
"!=",
"'.gpkg'",
":",
"fp",
"=",
"fp",
"+",
"'.gpkg'",
"if",
"names",
"is",
"not",
"None",
":",
"assert"... | Write unioned geometries ``geoms`` to filepath ``fp``. Optionally use ``names`` in name field. | [
"Write",
"unioned",
"geometries",
"geoms",
"to",
"filepath",
"fp",
".",
"Optionally",
"use",
"names",
"in",
"name",
"field",
"."
] | train | https://github.com/cmutel/constructive_geometries/blob/d38d7e8d5bf943a6499f3000004f1953af5970de/constructive_geometries/cg.py#L203-L223 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.