id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
239,300 | flipagram/smarterling | smarterling/__init__.py | sha1 | def sha1(s):
""" Returns a sha1 of the given string
"""
h = hashlib.new('sha1')
h.update(s)
return h.hexdigest() | python | def sha1(s):
""" Returns a sha1 of the given string
"""
h = hashlib.new('sha1')
h.update(s)
return h.hexdigest() | [
"def",
"sha1",
"(",
"s",
")",
":",
"h",
"=",
"hashlib",
".",
"new",
"(",
"'sha1'",
")",
"h",
".",
"update",
"(",
"s",
")",
"return",
"h",
".",
"hexdigest",
"(",
")"
] | Returns a sha1 of the given string | [
"Returns",
"a",
"sha1",
"of",
"the",
"given",
"string"
] | 2ea0957edad0657ba4c54280796869ffc1031b11 | https://github.com/flipagram/smarterling/blob/2ea0957edad0657ba4c54280796869ffc1031b11/smarterling/__init__.py#L35-L40 |
239,301 | flipagram/smarterling | smarterling/__init__.py | get_translated_items | def get_translated_items(fapi, file_uri, use_cache, cache_dir=None):
""" Returns the last modified from smarterling
"""
items = None
cache_file = os.path.join(cache_dir, sha1(file_uri)) if use_cache else None
if use_cache and os.path.exists(cache_file):
print("Using cache file %s for transla... | python | def get_translated_items(fapi, file_uri, use_cache, cache_dir=None):
""" Returns the last modified from smarterling
"""
items = None
cache_file = os.path.join(cache_dir, sha1(file_uri)) if use_cache else None
if use_cache and os.path.exists(cache_file):
print("Using cache file %s for transla... | [
"def",
"get_translated_items",
"(",
"fapi",
",",
"file_uri",
",",
"use_cache",
",",
"cache_dir",
"=",
"None",
")",
":",
"items",
"=",
"None",
"cache_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cache_dir",
",",
"sha1",
"(",
"file_uri",
")",
")",
"... | Returns the last modified from smarterling | [
"Returns",
"the",
"last",
"modified",
"from",
"smarterling"
] | 2ea0957edad0657ba4c54280796869ffc1031b11 | https://github.com/flipagram/smarterling/blob/2ea0957edad0657ba4c54280796869ffc1031b11/smarterling/__init__.py#L59-L74 |
239,302 | flipagram/smarterling | smarterling/__init__.py | get_translated_file | def get_translated_file(fapi, file_uri, locale, retrieval_type, include_original_strings, use_cache, cache_dir=None):
""" Returns a translated file from smartling
"""
file_data = None
cache_name = str(file_uri)+"."+str(locale)+"."+str(retrieval_type)+"."+str(include_original_strings)
cache_file = os... | python | def get_translated_file(fapi, file_uri, locale, retrieval_type, include_original_strings, use_cache, cache_dir=None):
""" Returns a translated file from smartling
"""
file_data = None
cache_name = str(file_uri)+"."+str(locale)+"."+str(retrieval_type)+"."+str(include_original_strings)
cache_file = os... | [
"def",
"get_translated_file",
"(",
"fapi",
",",
"file_uri",
",",
"locale",
",",
"retrieval_type",
",",
"include_original_strings",
",",
"use_cache",
",",
"cache_dir",
"=",
"None",
")",
":",
"file_data",
"=",
"None",
"cache_name",
"=",
"str",
"(",
"file_uri",
"... | Returns a translated file from smartling | [
"Returns",
"a",
"translated",
"file",
"from",
"smartling"
] | 2ea0957edad0657ba4c54280796869ffc1031b11 | https://github.com/flipagram/smarterling/blob/2ea0957edad0657ba4c54280796869ffc1031b11/smarterling/__init__.py#L76-L97 |
239,303 | flipagram/smarterling | smarterling/__init__.py | upload_file | def upload_file(fapi, file_name, conf):
""" Uploads a file to smartling
"""
if not conf.has_key('file-type'):
raise SmarterlingError("%s doesn't have a file-type" % file_name)
print("Uploading %s to smartling" % file_name)
data = UploadData(
os.path.dirname(file_name)+os.sep,
... | python | def upload_file(fapi, file_name, conf):
""" Uploads a file to smartling
"""
if not conf.has_key('file-type'):
raise SmarterlingError("%s doesn't have a file-type" % file_name)
print("Uploading %s to smartling" % file_name)
data = UploadData(
os.path.dirname(file_name)+os.sep,
... | [
"def",
"upload_file",
"(",
"fapi",
",",
"file_name",
",",
"conf",
")",
":",
"if",
"not",
"conf",
".",
"has_key",
"(",
"'file-type'",
")",
":",
"raise",
"SmarterlingError",
"(",
"\"%s doesn't have a file-type\"",
"%",
"file_name",
")",
"print",
"(",
"\"Uploadin... | Uploads a file to smartling | [
"Uploads",
"a",
"file",
"to",
"smartling"
] | 2ea0957edad0657ba4c54280796869ffc1031b11 | https://github.com/flipagram/smarterling/blob/2ea0957edad0657ba4c54280796869ffc1031b11/smarterling/__init__.py#L189-L211 |
239,304 | flipagram/smarterling | smarterling/__init__.py | create_file_api | def create_file_api(conf):
""" Creates a SmartlingFileApi from the given config
"""
api_key = conf.config.get('api-key', os.environ.get('SMARTLING_API_KEY'))
project_id = conf.config.get('project-id', os.environ.get('SMARTLING_PROJECT_ID'))
if not project_id or not api_key:
raise Smarterlin... | python | def create_file_api(conf):
""" Creates a SmartlingFileApi from the given config
"""
api_key = conf.config.get('api-key', os.environ.get('SMARTLING_API_KEY'))
project_id = conf.config.get('project-id', os.environ.get('SMARTLING_PROJECT_ID'))
if not project_id or not api_key:
raise Smarterlin... | [
"def",
"create_file_api",
"(",
"conf",
")",
":",
"api_key",
"=",
"conf",
".",
"config",
".",
"get",
"(",
"'api-key'",
",",
"os",
".",
"environ",
".",
"get",
"(",
"'SMARTLING_API_KEY'",
")",
")",
"project_id",
"=",
"conf",
".",
"config",
".",
"get",
"("... | Creates a SmartlingFileApi from the given config | [
"Creates",
"a",
"SmartlingFileApi",
"from",
"the",
"given",
"config"
] | 2ea0957edad0657ba4c54280796869ffc1031b11 | https://github.com/flipagram/smarterling/blob/2ea0957edad0657ba4c54280796869ffc1031b11/smarterling/__init__.py#L213-L232 |
239,305 | flipagram/smarterling | smarterling/__init__.py | parse_config | def parse_config(file_name='smarterling.config'):
""" Parses a smarterling configuration file
"""
if not os.path.exists(file_name) or not os.path.isfile(file_name):
raise SmarterlingError('Config file not found: %s' % file_name)
try:
contents = read_from_file(file_name)
contents_... | python | def parse_config(file_name='smarterling.config'):
""" Parses a smarterling configuration file
"""
if not os.path.exists(file_name) or not os.path.isfile(file_name):
raise SmarterlingError('Config file not found: %s' % file_name)
try:
contents = read_from_file(file_name)
contents_... | [
"def",
"parse_config",
"(",
"file_name",
"=",
"'smarterling.config'",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"file_name",
")",
"or",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"file_name",
")",
":",
"raise",
"SmarterlingError",
... | Parses a smarterling configuration file | [
"Parses",
"a",
"smarterling",
"configuration",
"file"
] | 2ea0957edad0657ba4c54280796869ffc1031b11 | https://github.com/flipagram/smarterling/blob/2ea0957edad0657ba4c54280796869ffc1031b11/smarterling/__init__.py#L234-L244 |
239,306 | flipagram/smarterling | smarterling/__init__.py | AttributeDict.get | def get(self, key, default_val=None, require_value=False):
""" Returns a dictionary value
"""
val = dict.get(self, key, default_val)
if val is None and require_value:
raise KeyError('key "%s" not found' % key)
if isinstance(val, dict):
return AttributeDict... | python | def get(self, key, default_val=None, require_value=False):
""" Returns a dictionary value
"""
val = dict.get(self, key, default_val)
if val is None and require_value:
raise KeyError('key "%s" not found' % key)
if isinstance(val, dict):
return AttributeDict... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default_val",
"=",
"None",
",",
"require_value",
"=",
"False",
")",
":",
"val",
"=",
"dict",
".",
"get",
"(",
"self",
",",
"key",
",",
"default_val",
")",
"if",
"val",
"is",
"None",
"and",
"require_value",... | Returns a dictionary value | [
"Returns",
"a",
"dictionary",
"value"
] | 2ea0957edad0657ba4c54280796869ffc1031b11 | https://github.com/flipagram/smarterling/blob/2ea0957edad0657ba4c54280796869ffc1031b11/smarterling/__init__.py#L25-L33 |
239,307 | roboogle/gtkmvc3 | gtkmvco/gtkmvc3/adapters/basic.py | Adapter.connect_widget | def connect_widget(self, wid,
getter=None, setter=None,
signal=None, arg=None, update=True,
flavour=None):
"""
Finish set-up by connecting the widget. The model was already
specified in the constructor.
*wid* is a wid... | python | def connect_widget(self, wid,
getter=None, setter=None,
signal=None, arg=None, update=True,
flavour=None):
"""
Finish set-up by connecting the widget. The model was already
specified in the constructor.
*wid* is a wid... | [
"def",
"connect_widget",
"(",
"self",
",",
"wid",
",",
"getter",
"=",
"None",
",",
"setter",
"=",
"None",
",",
"signal",
"=",
"None",
",",
"arg",
"=",
"None",
",",
"update",
"=",
"True",
",",
"flavour",
"=",
"None",
")",
":",
"if",
"wid",
"in",
"... | Finish set-up by connecting the widget. The model was already
specified in the constructor.
*wid* is a widget instance.
*getter* is a callable. It is passed *wid* and must return its
current value.
*setter* is a callable. It is passed *wid* and the current value of
the... | [
"Finish",
"set",
"-",
"up",
"by",
"connecting",
"the",
"widget",
".",
"The",
"model",
"was",
"already",
"specified",
"in",
"the",
"constructor",
"."
] | 63405fd8d2056be26af49103b13a8d5e57fe4dff | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/adapters/basic.py#L160-L229 |
239,308 | roboogle/gtkmvc3 | gtkmvco/gtkmvc3/adapters/basic.py | Adapter._connect_model | def _connect_model(self, model):
"""
Used internally to connect the property into the model, and
register self as a value observer for that property"""
parts = self._prop_name.split(".")
if len(parts) > 1:
# identifies the model
models = parts[:-1]
... | python | def _connect_model(self, model):
"""
Used internally to connect the property into the model, and
register self as a value observer for that property"""
parts = self._prop_name.split(".")
if len(parts) > 1:
# identifies the model
models = parts[:-1]
... | [
"def",
"_connect_model",
"(",
"self",
",",
"model",
")",
":",
"parts",
"=",
"self",
".",
"_prop_name",
".",
"split",
"(",
"\".\"",
")",
"if",
"len",
"(",
"parts",
")",
">",
"1",
":",
"# identifies the model",
"models",
"=",
"parts",
"[",
":",
"-",
"1... | Used internally to connect the property into the model, and
register self as a value observer for that property | [
"Used",
"internally",
"to",
"connect",
"the",
"property",
"into",
"the",
"model",
"and",
"register",
"self",
"as",
"a",
"value",
"observer",
"for",
"that",
"property"
] | 63405fd8d2056be26af49103b13a8d5e57fe4dff | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/adapters/basic.py#L257-L292 |
239,309 | roboogle/gtkmvc3 | gtkmvco/gtkmvc3/adapters/basic.py | Adapter._get_observer_fun | def _get_observer_fun(self, prop_name):
"""This is the code for an value change observer"""
def _observer_fun(self, model, old, new):
if self._itsme:
return
self._on_prop_changed()
# doesn't affect stack traces
_observer_fun.__name__ = "property_%... | python | def _get_observer_fun(self, prop_name):
"""This is the code for an value change observer"""
def _observer_fun(self, model, old, new):
if self._itsme:
return
self._on_prop_changed()
# doesn't affect stack traces
_observer_fun.__name__ = "property_%... | [
"def",
"_get_observer_fun",
"(",
"self",
",",
"prop_name",
")",
":",
"def",
"_observer_fun",
"(",
"self",
",",
"model",
",",
"old",
",",
"new",
")",
":",
"if",
"self",
".",
"_itsme",
":",
"return",
"self",
".",
"_on_prop_changed",
"(",
")",
"# doesn't af... | This is the code for an value change observer | [
"This",
"is",
"the",
"code",
"for",
"an",
"value",
"change",
"observer"
] | 63405fd8d2056be26af49103b13a8d5e57fe4dff | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/adapters/basic.py#L294-L303 |
239,310 | roboogle/gtkmvc3 | gtkmvco/gtkmvc3/adapters/basic.py | Adapter._write_property | def _write_property(self, val, *args):
"""Sets the value of property. Given val is transformed
accodingly to prop_write function when specified at
construction-time. A try to cast the value to the property
type is given."""
val_wid = val
# 'finally' would be better here, ... | python | def _write_property(self, val, *args):
"""Sets the value of property. Given val is transformed
accodingly to prop_write function when specified at
construction-time. A try to cast the value to the property
type is given."""
val_wid = val
# 'finally' would be better here, ... | [
"def",
"_write_property",
"(",
"self",
",",
"val",
",",
"*",
"args",
")",
":",
"val_wid",
"=",
"val",
"# 'finally' would be better here, but not supported in 2.4 :(",
"try",
":",
"totype",
"=",
"type",
"(",
"self",
".",
"_get_property",
"(",
"*",
"args",
")",
... | Sets the value of property. Given val is transformed
accodingly to prop_write function when specified at
construction-time. A try to cast the value to the property
type is given. | [
"Sets",
"the",
"value",
"of",
"property",
".",
"Given",
"val",
"is",
"transformed",
"accodingly",
"to",
"prop_write",
"function",
"when",
"specified",
"at",
"construction",
"-",
"time",
".",
"A",
"try",
"to",
"cast",
"the",
"value",
"to",
"the",
"property",
... | 63405fd8d2056be26af49103b13a8d5e57fe4dff | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/adapters/basic.py#L326-L356 |
239,311 | roboogle/gtkmvc3 | gtkmvco/gtkmvc3/adapters/basic.py | Adapter._read_widget | def _read_widget(self):
"""Returns the value currently stored into the widget, after
transforming it accordingly to possibly specified function.
This is implemented by calling the getter provided by the
user. This method can raise InvalidValue (raised by the
getter) when the val... | python | def _read_widget(self):
"""Returns the value currently stored into the widget, after
transforming it accordingly to possibly specified function.
This is implemented by calling the getter provided by the
user. This method can raise InvalidValue (raised by the
getter) when the val... | [
"def",
"_read_widget",
"(",
"self",
")",
":",
"getter",
"=",
"self",
".",
"_wid_info",
"[",
"self",
".",
"_wid",
"]",
"[",
"0",
"]",
"return",
"getter",
"(",
"self",
".",
"_wid",
")"
] | Returns the value currently stored into the widget, after
transforming it accordingly to possibly specified function.
This is implemented by calling the getter provided by the
user. This method can raise InvalidValue (raised by the
getter) when the value in the widget must not be consid... | [
"Returns",
"the",
"value",
"currently",
"stored",
"into",
"the",
"widget",
"after",
"transforming",
"it",
"accordingly",
"to",
"possibly",
"specified",
"function",
"."
] | 63405fd8d2056be26af49103b13a8d5e57fe4dff | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/adapters/basic.py#L358-L367 |
239,312 | roboogle/gtkmvc3 | gtkmvco/gtkmvc3/adapters/basic.py | Adapter._write_widget | def _write_widget(self, val):
"""Writes value into the widget. If specified, user setter
is invoked."""
self._itsme = True
try:
setter = self._wid_info[self._wid][1]
wtype = self._wid_info[self._wid][2]
if setter:
if wtype is not None:
... | python | def _write_widget(self, val):
"""Writes value into the widget. If specified, user setter
is invoked."""
self._itsme = True
try:
setter = self._wid_info[self._wid][1]
wtype = self._wid_info[self._wid][2]
if setter:
if wtype is not None:
... | [
"def",
"_write_widget",
"(",
"self",
",",
"val",
")",
":",
"self",
".",
"_itsme",
"=",
"True",
"try",
":",
"setter",
"=",
"self",
".",
"_wid_info",
"[",
"self",
".",
"_wid",
"]",
"[",
"1",
"]",
"wtype",
"=",
"self",
".",
"_wid_info",
"[",
"self",
... | Writes value into the widget. If specified, user setter
is invoked. | [
"Writes",
"value",
"into",
"the",
"widget",
".",
"If",
"specified",
"user",
"setter",
"is",
"invoked",
"."
] | 63405fd8d2056be26af49103b13a8d5e57fe4dff | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/adapters/basic.py#L369-L382 |
239,313 | roboogle/gtkmvc3 | gtkmvco/gtkmvc3/adapters/basic.py | UserClassAdapter._on_prop_changed | def _on_prop_changed(self, instance, meth_name, res, args, kwargs):
"""Called by the observation code, when a modifying method
is called"""
Adapter._on_prop_changed(self) | python | def _on_prop_changed(self, instance, meth_name, res, args, kwargs):
"""Called by the observation code, when a modifying method
is called"""
Adapter._on_prop_changed(self) | [
"def",
"_on_prop_changed",
"(",
"self",
",",
"instance",
",",
"meth_name",
",",
"res",
",",
"args",
",",
"kwargs",
")",
":",
"Adapter",
".",
"_on_prop_changed",
"(",
"self",
")"
] | Called by the observation code, when a modifying method
is called | [
"Called",
"by",
"the",
"observation",
"code",
"when",
"a",
"modifying",
"method",
"is",
"called"
] | 63405fd8d2056be26af49103b13a8d5e57fe4dff | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/adapters/basic.py#L459-L462 |
239,314 | roboogle/gtkmvc3 | gtkmvco/gtkmvc3/adapters/basic.py | UserClassAdapter._get_property | def _get_property(self, *args):
"""Private method that returns the value currently stored
into the property"""
val = self._getter(Adapter._get_property(self), *args)
if self._prop_read:
return self._prop_read(val, *args)
return val | python | def _get_property(self, *args):
"""Private method that returns the value currently stored
into the property"""
val = self._getter(Adapter._get_property(self), *args)
if self._prop_read:
return self._prop_read(val, *args)
return val | [
"def",
"_get_property",
"(",
"self",
",",
"*",
"args",
")",
":",
"val",
"=",
"self",
".",
"_getter",
"(",
"Adapter",
".",
"_get_property",
"(",
"self",
")",
",",
"*",
"args",
")",
"if",
"self",
".",
"_prop_read",
":",
"return",
"self",
".",
"_prop_re... | Private method that returns the value currently stored
into the property | [
"Private",
"method",
"that",
"returns",
"the",
"value",
"currently",
"stored",
"into",
"the",
"property"
] | 63405fd8d2056be26af49103b13a8d5e57fe4dff | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/adapters/basic.py#L464-L470 |
239,315 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/random/RandomString.py | RandomString.distort | def distort(value):
"""
Distorts a string by randomly replacing characters in it.
:param value: a string to distort.
:return: a distored string.
"""
value = value.lower()
if (RandomBoolean.chance(1, 5)):
value = value[0:1].upper() + value[1:]
... | python | def distort(value):
"""
Distorts a string by randomly replacing characters in it.
:param value: a string to distort.
:return: a distored string.
"""
value = value.lower()
if (RandomBoolean.chance(1, 5)):
value = value[0:1].upper() + value[1:]
... | [
"def",
"distort",
"(",
"value",
")",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
"if",
"(",
"RandomBoolean",
".",
"chance",
"(",
"1",
",",
"5",
")",
")",
":",
"value",
"=",
"value",
"[",
"0",
":",
"1",
"]",
".",
"upper",
"(",
")",
"+"... | Distorts a string by randomly replacing characters in it.
:param value: a string to distort.
:return: a distored string. | [
"Distorts",
"a",
"string",
"by",
"randomly",
"replacing",
"characters",
"in",
"it",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/random/RandomString.py#L47-L63 |
239,316 | kervi/kervi-devices | kervi/devices/pwm/PCA9685.py | PCA9685DeviceDriver.pwm_start | def pwm_start(self, channel, duty_cycle=None, frequency=None):
"""
Starts the pwm signal on a channel. The channel should be defined as pwm prior to this call.
If no duty_cycle or frequency is passed in this call previous values from call to
define_as_pwm or pwm_start is used.
:... | python | def pwm_start(self, channel, duty_cycle=None, frequency=None):
"""
Starts the pwm signal on a channel. The channel should be defined as pwm prior to this call.
If no duty_cycle or frequency is passed in this call previous values from call to
define_as_pwm or pwm_start is used.
:... | [
"def",
"pwm_start",
"(",
"self",
",",
"channel",
",",
"duty_cycle",
"=",
"None",
",",
"frequency",
"=",
"None",
")",
":",
"if",
"frequency",
":",
"self",
".",
"set_pwm_freq",
"(",
"frequency",
")",
"self",
".",
"set_pwm",
"(",
"channel",
",",
"0",
",",... | Starts the pwm signal on a channel. The channel should be defined as pwm prior to this call.
If no duty_cycle or frequency is passed in this call previous values from call to
define_as_pwm or pwm_start is used.
:param channel:
The channel to start the pwm signal on.
:type c... | [
"Starts",
"the",
"pwm",
"signal",
"on",
"a",
"channel",
".",
"The",
"channel",
"should",
"be",
"defined",
"as",
"pwm",
"prior",
"to",
"this",
"call",
".",
"If",
"no",
"duty_cycle",
"or",
"frequency",
"is",
"passed",
"in",
"this",
"call",
"previous",
"val... | c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56 | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/pwm/PCA9685.py#L119-L143 |
239,317 | kervi/kervi-devices | kervi/devices/pwm/PCA9685.py | PCA9685DeviceDriver.set_pwm_freq | def set_pwm_freq(self, freq_hz):
"""Set the PWM frequency to the provided value in hertz."""
prescaleval = 25000000.0 # 25MHz
prescaleval /= 4096.0 # 12-bit
prescaleval /= float(freq_hz)
prescaleval -= 1.0
logger.debug('Setting PWM frequency to {0} Hz'.format(fre... | python | def set_pwm_freq(self, freq_hz):
"""Set the PWM frequency to the provided value in hertz."""
prescaleval = 25000000.0 # 25MHz
prescaleval /= 4096.0 # 12-bit
prescaleval /= float(freq_hz)
prescaleval -= 1.0
logger.debug('Setting PWM frequency to {0} Hz'.format(fre... | [
"def",
"set_pwm_freq",
"(",
"self",
",",
"freq_hz",
")",
":",
"prescaleval",
"=",
"25000000.0",
"# 25MHz",
"prescaleval",
"/=",
"4096.0",
"# 12-bit",
"prescaleval",
"/=",
"float",
"(",
"freq_hz",
")",
"prescaleval",
"-=",
"1.0",
"logger",
".",
"debug",
"(",
... | Set the PWM frequency to the provided value in hertz. | [
"Set",
"the",
"PWM",
"frequency",
"to",
"the",
"provided",
"value",
"in",
"hertz",
"."
] | c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56 | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/pwm/PCA9685.py#L151-L167 |
239,318 | kervi/kervi-devices | kervi/devices/pwm/PCA9685.py | PCA9685DeviceDriver.set_pwm | def set_pwm(self, channel, on, off):
"""Sets a single PWM channel."""
self.i2c.write8(LED0_ON_L+4*channel, on & 0xFF)
self.i2c.write8(LED0_ON_H+4*channel, on >> 8)
self.i2c.write8(LED0_OFF_L+4*channel, off & 0xFF)
self.i2c.write8(LED0_OFF_H+4*channel, off >> 8) | python | def set_pwm(self, channel, on, off):
"""Sets a single PWM channel."""
self.i2c.write8(LED0_ON_L+4*channel, on & 0xFF)
self.i2c.write8(LED0_ON_H+4*channel, on >> 8)
self.i2c.write8(LED0_OFF_L+4*channel, off & 0xFF)
self.i2c.write8(LED0_OFF_H+4*channel, off >> 8) | [
"def",
"set_pwm",
"(",
"self",
",",
"channel",
",",
"on",
",",
"off",
")",
":",
"self",
".",
"i2c",
".",
"write8",
"(",
"LED0_ON_L",
"+",
"4",
"*",
"channel",
",",
"on",
"&",
"0xFF",
")",
"self",
".",
"i2c",
".",
"write8",
"(",
"LED0_ON_H",
"+",
... | Sets a single PWM channel. | [
"Sets",
"a",
"single",
"PWM",
"channel",
"."
] | c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56 | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/pwm/PCA9685.py#L169-L174 |
239,319 | kervi/kervi-devices | kervi/devices/pwm/PCA9685.py | PCA9685DeviceDriver.set_all_pwm | def set_all_pwm(self, on, off):
"""Sets all PWM channels."""
self.i2c.write8(ALL_LED_ON_L, on & 0xFF)
self.i2c.write8(ALL_LED_ON_H, on >> 8)
self.i2c.write8(ALL_LED_OFF_L, off & 0xFF)
self.i2c.write8(ALL_LED_OFF_H, off >> 8) | python | def set_all_pwm(self, on, off):
"""Sets all PWM channels."""
self.i2c.write8(ALL_LED_ON_L, on & 0xFF)
self.i2c.write8(ALL_LED_ON_H, on >> 8)
self.i2c.write8(ALL_LED_OFF_L, off & 0xFF)
self.i2c.write8(ALL_LED_OFF_H, off >> 8) | [
"def",
"set_all_pwm",
"(",
"self",
",",
"on",
",",
"off",
")",
":",
"self",
".",
"i2c",
".",
"write8",
"(",
"ALL_LED_ON_L",
",",
"on",
"&",
"0xFF",
")",
"self",
".",
"i2c",
".",
"write8",
"(",
"ALL_LED_ON_H",
",",
"on",
">>",
"8",
")",
"self",
".... | Sets all PWM channels. | [
"Sets",
"all",
"PWM",
"channels",
"."
] | c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56 | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/pwm/PCA9685.py#L176-L181 |
239,320 | host-anshu/simpleInterceptor | example/call_graph/generate.py | collect_ansible_classes | def collect_ansible_classes():
"""Run playbook and collect classes of ansible that are run."""
def trace_calls(frame, event, arg): # pylint: disable=W0613
"""Trace function calls to collect ansible classes.
Trace functions and check if they have self as an arg. If so, get their class if the
... | python | def collect_ansible_classes():
"""Run playbook and collect classes of ansible that are run."""
def trace_calls(frame, event, arg): # pylint: disable=W0613
"""Trace function calls to collect ansible classes.
Trace functions and check if they have self as an arg. If so, get their class if the
... | [
"def",
"collect_ansible_classes",
"(",
")",
":",
"def",
"trace_calls",
"(",
"frame",
",",
"event",
",",
"arg",
")",
":",
"# pylint: disable=W0613",
"\"\"\"Trace function calls to collect ansible classes.\n\n Trace functions and check if they have self as an arg. If so, get the... | Run playbook and collect classes of ansible that are run. | [
"Run",
"playbook",
"and",
"collect",
"classes",
"of",
"ansible",
"that",
"are",
"run",
"."
] | 71238fed57c62b5f77ce32d0c9b98acad73ab6a8 | https://github.com/host-anshu/simpleInterceptor/blob/71238fed57c62b5f77ce32d0c9b98acad73ab6a8/example/call_graph/generate.py#L30-L54 |
239,321 | host-anshu/simpleInterceptor | example/call_graph/generate.py | _parse_args | def _parse_args():
"""Parse args and separate generator and playbook args."""
class HelpOnErrorArgParser(argparse.ArgumentParser):
"""Print help message as well when an error is raised."""
def error(self, message):
sys.stderr.write("Error: %s\n" % message)
self.print_help... | python | def _parse_args():
"""Parse args and separate generator and playbook args."""
class HelpOnErrorArgParser(argparse.ArgumentParser):
"""Print help message as well when an error is raised."""
def error(self, message):
sys.stderr.write("Error: %s\n" % message)
self.print_help... | [
"def",
"_parse_args",
"(",
")",
":",
"class",
"HelpOnErrorArgParser",
"(",
"argparse",
".",
"ArgumentParser",
")",
":",
"\"\"\"Print help message as well when an error is raised.\"\"\"",
"def",
"error",
"(",
"self",
",",
"message",
")",
":",
"sys",
".",
"stderr",
".... | Parse args and separate generator and playbook args. | [
"Parse",
"args",
"and",
"separate",
"generator",
"and",
"playbook",
"args",
"."
] | 71238fed57c62b5f77ce32d0c9b98acad73ab6a8 | https://github.com/host-anshu/simpleInterceptor/blob/71238fed57c62b5f77ce32d0c9b98acad73ab6a8/example/call_graph/generate.py#L68-L144 |
239,322 | wickman/compactor | compactor/httpd.py | WireProtocolMessageHandler.detect_process | def detect_process(cls, headers):
"""Returns tuple of process, legacy or None, None if not process originating."""
try:
if 'Libprocess-From' in headers:
return PID.from_string(headers['Libprocess-From']), False
elif 'User-Agent' in headers and headers['User-Agent'].startswith('libprocess/')... | python | def detect_process(cls, headers):
"""Returns tuple of process, legacy or None, None if not process originating."""
try:
if 'Libprocess-From' in headers:
return PID.from_string(headers['Libprocess-From']), False
elif 'User-Agent' in headers and headers['User-Agent'].startswith('libprocess/')... | [
"def",
"detect_process",
"(",
"cls",
",",
"headers",
")",
":",
"try",
":",
"if",
"'Libprocess-From'",
"in",
"headers",
":",
"return",
"PID",
".",
"from_string",
"(",
"headers",
"[",
"'Libprocess-From'",
"]",
")",
",",
"False",
"elif",
"'User-Agent'",
"in",
... | Returns tuple of process, legacy or None, None if not process originating. | [
"Returns",
"tuple",
"of",
"process",
"legacy",
"or",
"None",
"None",
"if",
"not",
"process",
"originating",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/httpd.py#L27-L39 |
239,323 | wickman/compactor | compactor/httpd.py | HTTPD.mount_process | def mount_process(self, process):
"""
Mount a Process onto the http server to receive message callbacks.
"""
for route_path in process.route_paths:
route = '/%s%s' % (process.pid.id, route_path)
log.info('Mounting route %s' % route)
self.app.add_handlers('.*$', [(
re.escape(... | python | def mount_process(self, process):
"""
Mount a Process onto the http server to receive message callbacks.
"""
for route_path in process.route_paths:
route = '/%s%s' % (process.pid.id, route_path)
log.info('Mounting route %s' % route)
self.app.add_handlers('.*$', [(
re.escape(... | [
"def",
"mount_process",
"(",
"self",
",",
"process",
")",
":",
"for",
"route_path",
"in",
"process",
".",
"route_paths",
":",
"route",
"=",
"'/%s%s'",
"%",
"(",
"process",
".",
"pid",
".",
"id",
",",
"route_path",
")",
"log",
".",
"info",
"(",
"'Mounti... | Mount a Process onto the http server to receive message callbacks. | [
"Mount",
"a",
"Process",
"onto",
"the",
"http",
"server",
"to",
"receive",
"message",
"callbacks",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/httpd.py#L118-L139 |
239,324 | wickman/compactor | compactor/httpd.py | HTTPD.unmount_process | def unmount_process(self, process):
"""
Unmount a process from the http server to stop receiving message
callbacks.
"""
# There is no remove_handlers, but .handlers is public so why not. server.handlers is a list of
# 2-tuples of the form (host_pattern, [list of RequestHandler]) objects. We f... | python | def unmount_process(self, process):
"""
Unmount a process from the http server to stop receiving message
callbacks.
"""
# There is no remove_handlers, but .handlers is public so why not. server.handlers is a list of
# 2-tuples of the form (host_pattern, [list of RequestHandler]) objects. We f... | [
"def",
"unmount_process",
"(",
"self",
",",
"process",
")",
":",
"# There is no remove_handlers, but .handlers is public so why not. server.handlers is a list of",
"# 2-tuples of the form (host_pattern, [list of RequestHandler]) objects. We filter out all",
"# handlers matching our process fro... | Unmount a process from the http server to stop receiving message
callbacks. | [
"Unmount",
"a",
"process",
"from",
"the",
"http",
"server",
"to",
"stop",
"receiving",
"message",
"callbacks",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/httpd.py#L141-L157 |
239,325 | staffanm/layeredconfig | layeredconfig/configsource.py | ConfigSource.typevalue | def typevalue(self, key, value):
"""Given a parameter identified by ``key`` and an untyped string,
convert that string to the type that our version of key has.
"""
def listconvert(value):
# this function might be called with both string
# represenations of entir... | python | def typevalue(self, key, value):
"""Given a parameter identified by ``key`` and an untyped string,
convert that string to the type that our version of key has.
"""
def listconvert(value):
# this function might be called with both string
# represenations of entir... | [
"def",
"typevalue",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"def",
"listconvert",
"(",
"value",
")",
":",
"# this function might be called with both string",
"# represenations of entire lists and simple (unquoted)",
"# strings. String representations come in two flavours... | Given a parameter identified by ``key`` and an untyped string,
convert that string to the type that our version of key has. | [
"Given",
"a",
"parameter",
"identified",
"by",
"key",
"and",
"an",
"untyped",
"string",
"convert",
"that",
"string",
"to",
"the",
"type",
"that",
"our",
"version",
"of",
"key",
"has",
"."
] | f3dad66729854f5c34910c7533f88d39b223a977 | https://github.com/staffanm/layeredconfig/blob/f3dad66729854f5c34910c7533f88d39b223a977/layeredconfig/configsource.py#L175-L218 |
239,326 | toumorokoshi/jenks | jenks/utils.py | generate_valid_keys | def generate_valid_keys():
""" create a list of valid keys """
valid_keys = []
for minimum, maximum in RANGES:
for i in range(ord(minimum), ord(maximum) + 1):
valid_keys.append(chr(i))
return valid_keys | python | def generate_valid_keys():
""" create a list of valid keys """
valid_keys = []
for minimum, maximum in RANGES:
for i in range(ord(minimum), ord(maximum) + 1):
valid_keys.append(chr(i))
return valid_keys | [
"def",
"generate_valid_keys",
"(",
")",
":",
"valid_keys",
"=",
"[",
"]",
"for",
"minimum",
",",
"maximum",
"in",
"RANGES",
":",
"for",
"i",
"in",
"range",
"(",
"ord",
"(",
"minimum",
")",
",",
"ord",
"(",
"maximum",
")",
"+",
"1",
")",
":",
"valid... | create a list of valid keys | [
"create",
"a",
"list",
"of",
"valid",
"keys"
] | d3333a7b86ba290b7185aa5b8da75e76a28124f5 | https://github.com/toumorokoshi/jenks/blob/d3333a7b86ba290b7185aa5b8da75e76a28124f5/jenks/utils.py#L27-L33 |
239,327 | toumorokoshi/jenks | jenks/utils.py | get_configuration_file | def get_configuration_file():
""" return jenks configuration file """
path = os.path.abspath(os.curdir)
while path != os.sep:
config_path = os.path.join(path, CONFIG_FILE_NAME)
if os.path.exists(config_path):
return config_path
path = os.path.dirname(path)
return None | python | def get_configuration_file():
""" return jenks configuration file """
path = os.path.abspath(os.curdir)
while path != os.sep:
config_path = os.path.join(path, CONFIG_FILE_NAME)
if os.path.exists(config_path):
return config_path
path = os.path.dirname(path)
return None | [
"def",
"get_configuration_file",
"(",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"curdir",
")",
"while",
"path",
"!=",
"os",
".",
"sep",
":",
"config_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"CONF... | return jenks configuration file | [
"return",
"jenks",
"configuration",
"file"
] | d3333a7b86ba290b7185aa5b8da75e76a28124f5 | https://github.com/toumorokoshi/jenks/blob/d3333a7b86ba290b7185aa5b8da75e76a28124f5/jenks/utils.py#L36-L44 |
239,328 | toumorokoshi/jenks | jenks/utils.py | generate_write_yaml_to_file | def generate_write_yaml_to_file(file_name):
""" generate a method to write the configuration in yaml to the method desired """
def write_yaml(config):
with open(file_name, 'w+') as fh:
fh.write(yaml.dump(config))
return write_yaml | python | def generate_write_yaml_to_file(file_name):
""" generate a method to write the configuration in yaml to the method desired """
def write_yaml(config):
with open(file_name, 'w+') as fh:
fh.write(yaml.dump(config))
return write_yaml | [
"def",
"generate_write_yaml_to_file",
"(",
"file_name",
")",
":",
"def",
"write_yaml",
"(",
"config",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'w+'",
")",
"as",
"fh",
":",
"fh",
".",
"write",
"(",
"yaml",
".",
"dump",
"(",
"config",
")",
")",
... | generate a method to write the configuration in yaml to the method desired | [
"generate",
"a",
"method",
"to",
"write",
"the",
"configuration",
"in",
"yaml",
"to",
"the",
"method",
"desired"
] | d3333a7b86ba290b7185aa5b8da75e76a28124f5 | https://github.com/toumorokoshi/jenks/blob/d3333a7b86ba290b7185aa5b8da75e76a28124f5/jenks/utils.py#L47-L52 |
239,329 | emilydolson/avida-spatial-tools | avidaspatial/parse_files.py | load_grid_data | def load_grid_data(file_list, data_type="binary", sort=True, delim=" "):
"""
Loads data from one or multiple grid_task files.
Arguments:
file_list - either a string or a list of strings indicating files to
load data from. Files are assumed to be in grid_task.dat
... | python | def load_grid_data(file_list, data_type="binary", sort=True, delim=" "):
"""
Loads data from one or multiple grid_task files.
Arguments:
file_list - either a string or a list of strings indicating files to
load data from. Files are assumed to be in grid_task.dat
... | [
"def",
"load_grid_data",
"(",
"file_list",
",",
"data_type",
"=",
"\"binary\"",
",",
"sort",
"=",
"True",
",",
"delim",
"=",
"\" \"",
")",
":",
"# If there's only one file, we pretend it's a list",
"if",
"not",
"type",
"(",
"file_list",
")",
"is",
"list",
":",
... | Loads data from one or multiple grid_task files.
Arguments:
file_list - either a string or a list of strings indicating files to
load data from. Files are assumed to be in grid_task.dat
format (space delimited values, one per cell).
data_type - a string repr... | [
"Loads",
"data",
"from",
"one",
"or",
"multiple",
"grid_task",
"files",
"."
] | 7beb0166ccefad5fa722215b030ac2a53d62b59e | https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/parse_files.py#L11-L70 |
239,330 | emilydolson/avida-spatial-tools | avidaspatial/parse_files.py | make_niche_grid | def make_niche_grid(res_dict, world_size=(60, 60)):
"""
Converts dictionary specifying where resources are to nested lists
specifying what sets of resources are where.
res_dict - a dictionary in which keys are resources in the environment
and values are list of tuples representing the cells they're... | python | def make_niche_grid(res_dict, world_size=(60, 60)):
"""
Converts dictionary specifying where resources are to nested lists
specifying what sets of resources are where.
res_dict - a dictionary in which keys are resources in the environment
and values are list of tuples representing the cells they're... | [
"def",
"make_niche_grid",
"(",
"res_dict",
",",
"world_size",
"=",
"(",
"60",
",",
"60",
")",
")",
":",
"# Initialize array to represent world",
"world",
"=",
"initialize_grid",
"(",
"world_size",
",",
"set",
"(",
")",
")",
"# Fill in data on niches present in each ... | Converts dictionary specifying where resources are to nested lists
specifying what sets of resources are where.
res_dict - a dictionary in which keys are resources in the environment
and values are list of tuples representing the cells they're in.
world_size - a tuple indicating the dimensions of the ... | [
"Converts",
"dictionary",
"specifying",
"where",
"resources",
"are",
"to",
"nested",
"lists",
"specifying",
"what",
"sets",
"of",
"resources",
"are",
"where",
"."
] | 7beb0166ccefad5fa722215b030ac2a53d62b59e | https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/parse_files.py#L73-L96 |
239,331 | emilydolson/avida-spatial-tools | avidaspatial/parse_files.py | parse_environment_file_list | def parse_environment_file_list(names, world_size=(60, 60)):
"""
Extract information about spatial resources from all environment files in
a list.
Arguments:
names - a list of strings representing the paths to the environment files.
world_size - a tuple representing the x and y coordinates of t... | python | def parse_environment_file_list(names, world_size=(60, 60)):
"""
Extract information about spatial resources from all environment files in
a list.
Arguments:
names - a list of strings representing the paths to the environment files.
world_size - a tuple representing the x and y coordinates of t... | [
"def",
"parse_environment_file_list",
"(",
"names",
",",
"world_size",
"=",
"(",
"60",
",",
"60",
")",
")",
":",
"# Convert single file to list if necessary",
"try",
":",
"names",
"[",
"0",
"]",
"=",
"names",
"[",
"0",
"]",
"except",
":",
"names",
"=",
"["... | Extract information about spatial resources from all environment files in
a list.
Arguments:
names - a list of strings representing the paths to the environment files.
world_size - a tuple representing the x and y coordinates of the world.
(default: 60x60)
Returns a dictionary in ... | [
"Extract",
"information",
"about",
"spatial",
"resources",
"from",
"all",
"environment",
"files",
"in",
"a",
"list",
"."
] | 7beb0166ccefad5fa722215b030ac2a53d62b59e | https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/parse_files.py#L99-L124 |
239,332 | emilydolson/avida-spatial-tools | avidaspatial/parse_files.py | parse_environment_file | def parse_environment_file(filename, world_size=(60, 60)):
"""
Extract information about spatial resources from an environment file.
Arguments:
filename - a string representing the path to the environment file.
world_size - a tuple representing the x and y coordinates of the world.
... | python | def parse_environment_file(filename, world_size=(60, 60)):
"""
Extract information about spatial resources from an environment file.
Arguments:
filename - a string representing the path to the environment file.
world_size - a tuple representing the x and y coordinates of the world.
... | [
"def",
"parse_environment_file",
"(",
"filename",
",",
"world_size",
"=",
"(",
"60",
",",
"60",
")",
")",
":",
"infile",
"=",
"open",
"(",
"filename",
")",
"lines",
"=",
"infile",
".",
"readlines",
"(",
")",
"infile",
".",
"close",
"(",
")",
"tasks",
... | Extract information about spatial resources from an environment file.
Arguments:
filename - a string representing the path to the environment file.
world_size - a tuple representing the x and y coordinates of the world.
(default: 60x60)
Returns a list of lists of sets indicating the s... | [
"Extract",
"information",
"about",
"spatial",
"resources",
"from",
"an",
"environment",
"file",
"."
] | 7beb0166ccefad5fa722215b030ac2a53d62b59e | https://github.com/emilydolson/avida-spatial-tools/blob/7beb0166ccefad5fa722215b030ac2a53d62b59e/avidaspatial/parse_files.py#L143-L184 |
239,333 | CenterForOpenScience/sharepa | sharepa/experimental_analysis_functions.py | add_category_labels | def add_category_labels(level_name, cat_name, dataframe_needing_cat):
'''A function that adds a category name column to a pandas dataframe
:param level_name: an aggregation from elasticsearch results with nesting
:type level_name: elasticsearch response.aggregation object
:param cat_name: a... | python | def add_category_labels(level_name, cat_name, dataframe_needing_cat):
'''A function that adds a category name column to a pandas dataframe
:param level_name: an aggregation from elasticsearch results with nesting
:type level_name: elasticsearch response.aggregation object
:param cat_name: a... | [
"def",
"add_category_labels",
"(",
"level_name",
",",
"cat_name",
",",
"dataframe_needing_cat",
")",
":",
"cat_name_dataframe",
"=",
"pd",
".",
"DataFrame",
"(",
"[",
"level_name",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"dataframe_needing_cat",
".",
"shape",
... | A function that adds a category name column to a pandas dataframe
:param level_name: an aggregation from elasticsearch results with nesting
:type level_name: elasticsearch response.aggregation object
:param cat_name: an aggregation from elasticsearch results with nesting
:type cat_name:... | [
"A",
"function",
"that",
"adds",
"a",
"category",
"name",
"column",
"to",
"a",
"pandas",
"dataframe"
] | 5ea69b160080f0b9c655012f17fabaa1bcc02ae0 | https://github.com/CenterForOpenScience/sharepa/blob/5ea69b160080f0b9c655012f17fabaa1bcc02ae0/sharepa/experimental_analysis_functions.py#L81-L95 |
239,334 | siemens/django-dingos | dingos/core/datastructures.py | ExtendedSortedDict.chained_set | def chained_set(self, value, command='set', *keys):
"""
chained_set takes the value to
enter into the dictionary, a command of what
to do with the value, and a sequence of keys.
Examples:
d = {}
d.chained_set(1,'append','level 1','level 2')
-> d['level... | python | def chained_set(self, value, command='set', *keys):
"""
chained_set takes the value to
enter into the dictionary, a command of what
to do with the value, and a sequence of keys.
Examples:
d = {}
d.chained_set(1,'append','level 1','level 2')
-> d['level... | [
"def",
"chained_set",
"(",
"self",
",",
"value",
",",
"command",
"=",
"'set'",
",",
"*",
"keys",
")",
":",
"new_object",
"=",
"self",
".",
"__class__",
"(",
")",
"existing",
"=",
"self",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"keys",... | chained_set takes the value to
enter into the dictionary, a command of what
to do with the value, and a sequence of keys.
Examples:
d = {}
d.chained_set(1,'append','level 1','level 2')
-> d['level 1']['level 2'] = [1]
d.chained_set(2,'append','level 1','level... | [
"chained_set",
"takes",
"the",
"value",
"to",
"enter",
"into",
"the",
"dictionary",
"a",
"command",
"of",
"what",
"to",
"do",
"with",
"the",
"value",
"and",
"a",
"sequence",
"of",
"keys",
"."
] | 7154f75b06d2538568e2f2455a76f3d0db0b7d70 | https://github.com/siemens/django-dingos/blob/7154f75b06d2538568e2f2455a76f3d0db0b7d70/dingos/core/datastructures.py#L129-L177 |
239,335 | usc-isi-i2/dig-extractor | digExtractor/extractor.py | Extractor.set_renamed_input_fields | def set_renamed_input_fields(self, renamed_input_fields):
"""This method expects a scalar string or a list of input_fields
to """
if not (isinstance(renamed_input_fields, basestring) or
isinstance(renamed_input_fields, ListType)):
raise ValueError("renamed_input_field... | python | def set_renamed_input_fields(self, renamed_input_fields):
"""This method expects a scalar string or a list of input_fields
to """
if not (isinstance(renamed_input_fields, basestring) or
isinstance(renamed_input_fields, ListType)):
raise ValueError("renamed_input_field... | [
"def",
"set_renamed_input_fields",
"(",
"self",
",",
"renamed_input_fields",
")",
":",
"if",
"not",
"(",
"isinstance",
"(",
"renamed_input_fields",
",",
"basestring",
")",
"or",
"isinstance",
"(",
"renamed_input_fields",
",",
"ListType",
")",
")",
":",
"raise",
... | This method expects a scalar string or a list of input_fields
to | [
"This",
"method",
"expects",
"a",
"scalar",
"string",
"or",
"a",
"list",
"of",
"input_fields",
"to"
] | 87c138e0300d77e35ebeb5f5e9488c3d71e60eb3 | https://github.com/usc-isi-i2/dig-extractor/blob/87c138e0300d77e35ebeb5f5e9488c3d71e60eb3/digExtractor/extractor.py#L36-L43 |
239,336 | wooga/play-deliver | playdeliver/file_util.py | list_dir_abspath | def list_dir_abspath(path):
"""
Return a list absolute file paths.
see mkdir_p os.listdir.
"""
return map(lambda f: os.path.join(path, f), os.listdir(path)) | python | def list_dir_abspath(path):
"""
Return a list absolute file paths.
see mkdir_p os.listdir.
"""
return map(lambda f: os.path.join(path, f), os.listdir(path)) | [
"def",
"list_dir_abspath",
"(",
"path",
")",
":",
"return",
"map",
"(",
"lambda",
"f",
":",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"f",
")",
",",
"os",
".",
"listdir",
"(",
"path",
")",
")"
] | Return a list absolute file paths.
see mkdir_p os.listdir. | [
"Return",
"a",
"list",
"absolute",
"file",
"paths",
"."
] | 9de0f35376f5342720b3a90bd3ca296b1f3a3f4c | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/file_util.py#L7-L13 |
239,337 | tarvitz/django-unity-asset-server-http-client | duashttp/models.py | AssetVersion.get_digest | def get_digest(self):
""" return int uuid number for digest
:rtype: int
:return: digest
"""
a, b = struct.unpack('>QQ', self.digest)
return (a << 64) | b | python | def get_digest(self):
""" return int uuid number for digest
:rtype: int
:return: digest
"""
a, b = struct.unpack('>QQ', self.digest)
return (a << 64) | b | [
"def",
"get_digest",
"(",
"self",
")",
":",
"a",
",",
"b",
"=",
"struct",
".",
"unpack",
"(",
"'>QQ'",
",",
"self",
".",
"digest",
")",
"return",
"(",
"a",
"<<",
"64",
")",
"|",
"b"
] | return int uuid number for digest
:rtype: int
:return: digest | [
"return",
"int",
"uuid",
"number",
"for",
"digest"
] | 2b7e3b1116b5e98b31c2e267bdd66a77e0579ad1 | https://github.com/tarvitz/django-unity-asset-server-http-client/blob/2b7e3b1116b5e98b31c2e267bdd66a77e0579ad1/duashttp/models.py#L102-L109 |
239,338 | tarvitz/django-unity-asset-server-http-client | duashttp/models.py | AssetVersion.get_blob_hash | def get_blob_hash(self, h=hashlib.md5):
"""
get hash instance of blob content
:param h: callable hash generator
:type h: builtin_function_or_method
:rtype: _hashlib.HASH
:return: hash instance
"""
assert callable(h)
return h(self.get_blob_data()) | python | def get_blob_hash(self, h=hashlib.md5):
"""
get hash instance of blob content
:param h: callable hash generator
:type h: builtin_function_or_method
:rtype: _hashlib.HASH
:return: hash instance
"""
assert callable(h)
return h(self.get_blob_data()) | [
"def",
"get_blob_hash",
"(",
"self",
",",
"h",
"=",
"hashlib",
".",
"md5",
")",
":",
"assert",
"callable",
"(",
"h",
")",
"return",
"h",
"(",
"self",
".",
"get_blob_data",
"(",
")",
")"
] | get hash instance of blob content
:param h: callable hash generator
:type h: builtin_function_or_method
:rtype: _hashlib.HASH
:return: hash instance | [
"get",
"hash",
"instance",
"of",
"blob",
"content"
] | 2b7e3b1116b5e98b31c2e267bdd66a77e0579ad1 | https://github.com/tarvitz/django-unity-asset-server-http-client/blob/2b7e3b1116b5e98b31c2e267bdd66a77e0579ad1/duashttp/models.py#L111-L121 |
239,339 | tarvitz/django-unity-asset-server-http-client | duashttp/models.py | AssetVersion.get_blob_data | def get_blob_data(self, tag_target='asset', force=False):
"""
get asset version content using pg large object streams
:param bool force: False by default, forces get content from database
instead of using cached value
:rtype: str
:return: content in raw format
... | python | def get_blob_data(self, tag_target='asset', force=False):
"""
get asset version content using pg large object streams
:param bool force: False by default, forces get content from database
instead of using cached value
:rtype: str
:return: content in raw format
... | [
"def",
"get_blob_data",
"(",
"self",
",",
"tag_target",
"=",
"'asset'",
",",
"force",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_blob_data'",
")",
"and",
"not",
"force",
":",
"return",
"self",
".",
"_blob_data",
"if",
"six",
".",
"PY... | get asset version content using pg large object streams
:param bool force: False by default, forces get content from database
instead of using cached value
:rtype: str
:return: content in raw format | [
"get",
"asset",
"version",
"content",
"using",
"pg",
"large",
"object",
"streams"
] | 2b7e3b1116b5e98b31c2e267bdd66a77e0579ad1 | https://github.com/tarvitz/django-unity-asset-server-http-client/blob/2b7e3b1116b5e98b31c2e267bdd66a77e0579ad1/duashttp/models.py#L123-L144 |
239,340 | JukeboxPipeline/jukebox-core | src/jukeboxcore/action.py | ActionUnit.run | def run(self, obj):
"""Execute the actions on the given object.
:param obj: The object that the action should process
:type obj: :class:`object`
:returns: None
:rtype: None
:raises: None
"""
for d in self.depsuccess:
if d.status.value != Actio... | python | def run(self, obj):
"""Execute the actions on the given object.
:param obj: The object that the action should process
:type obj: :class:`object`
:returns: None
:rtype: None
:raises: None
"""
for d in self.depsuccess:
if d.status.value != Actio... | [
"def",
"run",
"(",
"self",
",",
"obj",
")",
":",
"for",
"d",
"in",
"self",
".",
"depsuccess",
":",
"if",
"d",
".",
"status",
".",
"value",
"!=",
"ActionStatus",
".",
"SUCCESS",
":",
"self",
".",
"status",
"=",
"ActionStatus",
"(",
"ActionStatus",
"."... | Execute the actions on the given object.
:param obj: The object that the action should process
:type obj: :class:`object`
:returns: None
:rtype: None
:raises: None | [
"Execute",
"the",
"actions",
"on",
"the",
"given",
"object",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/action.py#L109-L131 |
239,341 | JukeboxPipeline/jukebox-core | src/jukeboxcore/action.py | ActionCollection.status | def status(self, ):
"""The global status that summerizes all actions
The status will be calculated in the following order:
If any error occured, the status will be :data:`ActionStatus.ERROR`.
If any failure occured, the status will be :data:`ActionStatus.FAILURE`.
If all ... | python | def status(self, ):
"""The global status that summerizes all actions
The status will be calculated in the following order:
If any error occured, the status will be :data:`ActionStatus.ERROR`.
If any failure occured, the status will be :data:`ActionStatus.FAILURE`.
If all ... | [
"def",
"status",
"(",
"self",
",",
")",
":",
"status",
"=",
"ActionStatus",
"(",
"ActionStatus",
".",
"SUCCESS",
",",
"\"All actions succeeded.\"",
")",
"for",
"a",
"in",
"self",
".",
"actions",
":",
"if",
"a",
".",
"status",
".",
"value",
"==",
"ActionS... | The global status that summerizes all actions
The status will be calculated in the following order:
If any error occured, the status will be :data:`ActionStatus.ERROR`.
If any failure occured, the status will be :data:`ActionStatus.FAILURE`.
If all actions were successful or skip... | [
"The",
"global",
"status",
"that",
"summerizes",
"all",
"actions"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/action.py#L169-L189 |
239,342 | vmalloc/dessert | dessert/util.py | format_explanation | def format_explanation(explanation, original_msg=None):
"""This formats an explanation
Normally all embedded newlines are escaped, however there are
three exceptions: \n{, \n} and \n~. The first two are intended
cover nested explanations, see function and attribute explanations
for examples (.visi... | python | def format_explanation(explanation, original_msg=None):
"""This formats an explanation
Normally all embedded newlines are escaped, however there are
three exceptions: \n{, \n} and \n~. The first two are intended
cover nested explanations, see function and attribute explanations
for examples (.visi... | [
"def",
"format_explanation",
"(",
"explanation",
",",
"original_msg",
"=",
"None",
")",
":",
"if",
"not",
"conf",
".",
"is_message_introspection_enabled",
"(",
")",
"and",
"original_msg",
":",
"return",
"original_msg",
"explanation",
"=",
"ecu",
"(",
"explanation"... | This formats an explanation
Normally all embedded newlines are escaped, however there are
three exceptions: \n{, \n} and \n~. The first two are intended
cover nested explanations, see function and attribute explanations
for examples (.visit_Call(), visit_Attribute()). The last one is
for when one... | [
"This",
"formats",
"an",
"explanation"
] | fa86b39da4853f2c35f0686942db777c7cc57728 | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/util.py#L33-L48 |
239,343 | vmalloc/dessert | dessert/util.py | _split_explanation | def _split_explanation(explanation):
"""Return a list of individual lines in the explanation
This will return a list of lines split on '\n{', '\n}' and '\n~'.
Any other newlines will be escaped and appear in the line as the
literal '\n' characters.
"""
raw_lines = (explanation or u('')).split('... | python | def _split_explanation(explanation):
"""Return a list of individual lines in the explanation
This will return a list of lines split on '\n{', '\n}' and '\n~'.
Any other newlines will be escaped and appear in the line as the
literal '\n' characters.
"""
raw_lines = (explanation or u('')).split('... | [
"def",
"_split_explanation",
"(",
"explanation",
")",
":",
"raw_lines",
"=",
"(",
"explanation",
"or",
"u",
"(",
"''",
")",
")",
".",
"split",
"(",
"'\\n'",
")",
"lines",
"=",
"[",
"raw_lines",
"[",
"0",
"]",
"]",
"for",
"l",
"in",
"raw_lines",
"[",
... | Return a list of individual lines in the explanation
This will return a list of lines split on '\n{', '\n}' and '\n~'.
Any other newlines will be escaped and appear in the line as the
literal '\n' characters. | [
"Return",
"a",
"list",
"of",
"individual",
"lines",
"in",
"the",
"explanation"
] | fa86b39da4853f2c35f0686942db777c7cc57728 | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/util.py#L51-L65 |
239,344 | vmalloc/dessert | dessert/util.py | _format_lines | def _format_lines(lines):
"""Format the individual lines
This will replace the '{', '}' and '~' characters of our mini
formatting language with the proper 'where ...', 'and ...' and ' +
...' text, taking care of indentation along the way.
Return a list of formatted lines.
"""
result = line... | python | def _format_lines(lines):
"""Format the individual lines
This will replace the '{', '}' and '~' characters of our mini
formatting language with the proper 'where ...', 'and ...' and ' +
...' text, taking care of indentation along the way.
Return a list of formatted lines.
"""
result = line... | [
"def",
"_format_lines",
"(",
"lines",
")",
":",
"result",
"=",
"lines",
"[",
":",
"1",
"]",
"stack",
"=",
"[",
"0",
"]",
"stackcnt",
"=",
"[",
"0",
"]",
"for",
"line",
"in",
"lines",
"[",
"1",
":",
"]",
":",
"if",
"line",
".",
"startswith",
"("... | Format the individual lines
This will replace the '{', '}' and '~' characters of our mini
formatting language with the proper 'where ...', 'and ...' and ' +
...' text, taking care of indentation along the way.
Return a list of formatted lines. | [
"Format",
"the",
"individual",
"lines"
] | fa86b39da4853f2c35f0686942db777c7cc57728 | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/util.py#L68-L100 |
239,345 | vmalloc/dessert | dessert/util.py | _diff_text | def _diff_text(left, right, verbose=False):
"""Return the explanation for the diff between text or bytes
Unless --verbose is used this will skip leading and trailing
characters which are identical to keep the diff minimal.
If the input are bytes they will be safely converted to text.
"""
from ... | python | def _diff_text(left, right, verbose=False):
"""Return the explanation for the diff between text or bytes
Unless --verbose is used this will skip leading and trailing
characters which are identical to keep the diff minimal.
If the input are bytes they will be safely converted to text.
"""
from ... | [
"def",
"_diff_text",
"(",
"left",
",",
"right",
",",
"verbose",
"=",
"False",
")",
":",
"from",
"difflib",
"import",
"ndiff",
"explanation",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"left",
",",
"py",
".",
"builtin",
".",
"bytes",
")",
":",
"left",
"=... | Return the explanation for the diff between text or bytes
Unless --verbose is used this will skip leading and trailing
characters which are identical to keep the diff minimal.
If the input are bytes they will be safely converted to text. | [
"Return",
"the",
"explanation",
"for",
"the",
"diff",
"between",
"text",
"or",
"bytes"
] | fa86b39da4853f2c35f0686942db777c7cc57728 | https://github.com/vmalloc/dessert/blob/fa86b39da4853f2c35f0686942db777c7cc57728/dessert/util.py#L163-L202 |
239,346 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/validate/Schema.py | Schema.with_rule | def with_rule(self, rule):
"""
Adds validation rule to this schema.
This method returns reference to this exception to implement Builder pattern
to chain additional calls.
:param rule: a validation rule to be added.
:return: this validation schema.
"""
... | python | def with_rule(self, rule):
"""
Adds validation rule to this schema.
This method returns reference to this exception to implement Builder pattern
to chain additional calls.
:param rule: a validation rule to be added.
:return: this validation schema.
"""
... | [
"def",
"with_rule",
"(",
"self",
",",
"rule",
")",
":",
"self",
".",
"rules",
"=",
"self",
".",
"rules",
"if",
"self",
".",
"rules",
"!=",
"None",
"else",
"[",
"]",
"self",
".",
"rules",
".",
"append",
"(",
"rule",
")",
"return",
"self"
] | Adds validation rule to this schema.
This method returns reference to this exception to implement Builder pattern
to chain additional calls.
:param rule: a validation rule to be added.
:return: this validation schema. | [
"Adds",
"validation",
"rule",
"to",
"this",
"schema",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/validate/Schema.py#L66-L79 |
239,347 | wickman/compactor | compactor/context.py | Context._make_socket | def _make_socket(cls, ip, port):
"""Bind to a new socket.
If LIBPROCESS_PORT or LIBPROCESS_IP are configured in the environment,
these will be used for socket connectivity.
"""
bound_socket = bind_sockets(port, address=ip)[0]
ip, port = bound_socket.getsockname()
if not ip or ip == '0.0.0.... | python | def _make_socket(cls, ip, port):
"""Bind to a new socket.
If LIBPROCESS_PORT or LIBPROCESS_IP are configured in the environment,
these will be used for socket connectivity.
"""
bound_socket = bind_sockets(port, address=ip)[0]
ip, port = bound_socket.getsockname()
if not ip or ip == '0.0.0.... | [
"def",
"_make_socket",
"(",
"cls",
",",
"ip",
",",
"port",
")",
":",
"bound_socket",
"=",
"bind_sockets",
"(",
"port",
",",
"address",
"=",
"ip",
")",
"[",
"0",
"]",
"ip",
",",
"port",
"=",
"bound_socket",
".",
"getsockname",
"(",
")",
"if",
"not",
... | Bind to a new socket.
If LIBPROCESS_PORT or LIBPROCESS_IP are configured in the environment,
these will be used for socket connectivity. | [
"Bind",
"to",
"a",
"new",
"socket",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L45-L57 |
239,348 | wickman/compactor | compactor/context.py | Context.stop | def stop(self):
"""Stops the context. This terminates all PIDs and closes all connections."""
log.info('Stopping %s' % self)
pids = list(self._processes)
# Clean up the context
for pid in pids:
self.terminate(pid)
while self._connections:
pid = next(iter(self._connections))
... | python | def stop(self):
"""Stops the context. This terminates all PIDs and closes all connections."""
log.info('Stopping %s' % self)
pids = list(self._processes)
# Clean up the context
for pid in pids:
self.terminate(pid)
while self._connections:
pid = next(iter(self._connections))
... | [
"def",
"stop",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Stopping %s'",
"%",
"self",
")",
"pids",
"=",
"list",
"(",
"self",
".",
"_processes",
")",
"# Clean up the context",
"for",
"pid",
"in",
"pids",
":",
"self",
".",
"terminate",
"(",
"pid",... | Stops the context. This terminates all PIDs and closes all connections. | [
"Stops",
"the",
"context",
".",
"This",
"terminates",
"all",
"PIDs",
"and",
"closes",
"all",
"connections",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L151-L168 |
239,349 | wickman/compactor | compactor/context.py | Context.spawn | def spawn(self, process):
"""Spawn a process.
Spawning a process binds it to this context and assigns the process a
pid which is returned. The process' ``initialize`` method is called.
Note: A process cannot send messages until it is bound to a context.
:param process: The process to bind to thi... | python | def spawn(self, process):
"""Spawn a process.
Spawning a process binds it to this context and assigns the process a
pid which is returned. The process' ``initialize`` method is called.
Note: A process cannot send messages until it is bound to a context.
:param process: The process to bind to thi... | [
"def",
"spawn",
"(",
"self",
",",
"process",
")",
":",
"self",
".",
"_assert_started",
"(",
")",
"process",
".",
"bind",
"(",
"self",
")",
"self",
".",
"http",
".",
"mount_process",
"(",
"process",
")",
"self",
".",
"_processes",
"[",
"process",
".",
... | Spawn a process.
Spawning a process binds it to this context and assigns the process a
pid which is returned. The process' ``initialize`` method is called.
Note: A process cannot send messages until it is bound to a context.
:param process: The process to bind to this context.
:type process: :cl... | [
"Spawn",
"a",
"process",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L170-L188 |
239,350 | wickman/compactor | compactor/context.py | Context.dispatch | def dispatch(self, pid, method, *args):
"""Call a method on another process by its pid.
The method on the other process does not need to be installed with
``Process.install``. The call is serialized with all other calls on the
context's event loop. The pid must be bound to this context.
This fun... | python | def dispatch(self, pid, method, *args):
"""Call a method on another process by its pid.
The method on the other process does not need to be installed with
``Process.install``. The call is serialized with all other calls on the
context's event loop. The pid must be bound to this context.
This fun... | [
"def",
"dispatch",
"(",
"self",
",",
"pid",
",",
"method",
",",
"*",
"args",
")",
":",
"self",
".",
"_assert_started",
"(",
")",
"self",
".",
"_assert_local_pid",
"(",
"pid",
")",
"function",
"=",
"self",
".",
"_get_dispatch_method",
"(",
"pid",
",",
"... | Call a method on another process by its pid.
The method on the other process does not need to be installed with
``Process.install``. The call is serialized with all other calls on the
context's event loop. The pid must be bound to this context.
This function returns immediately.
:param pid: The... | [
"Call",
"a",
"method",
"on",
"another",
"process",
"by",
"its",
"pid",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L198-L216 |
239,351 | wickman/compactor | compactor/context.py | Context.delay | def delay(self, amount, pid, method, *args):
"""Call a method on another process after a specified delay.
This is equivalent to ``dispatch`` except with an additional amount of
time to wait prior to invoking the call.
This function returns immediately.
:param amount: The amount of time to wait in... | python | def delay(self, amount, pid, method, *args):
"""Call a method on another process after a specified delay.
This is equivalent to ``dispatch`` except with an additional amount of
time to wait prior to invoking the call.
This function returns immediately.
:param amount: The amount of time to wait in... | [
"def",
"delay",
"(",
"self",
",",
"amount",
",",
"pid",
",",
"method",
",",
"*",
"args",
")",
":",
"self",
".",
"_assert_started",
"(",
")",
"self",
".",
"_assert_local_pid",
"(",
"pid",
")",
"function",
"=",
"self",
".",
"_get_dispatch_method",
"(",
"... | Call a method on another process after a specified delay.
This is equivalent to ``dispatch`` except with an additional amount of
time to wait prior to invoking the call.
This function returns immediately.
:param amount: The amount of time to wait in seconds before making the call.
:type amount: `... | [
"Call",
"a",
"method",
"on",
"another",
"process",
"after",
"a",
"specified",
"delay",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L218-L237 |
239,352 | wickman/compactor | compactor/context.py | Context._maybe_connect | def _maybe_connect(self, to_pid, callback=None):
"""Asynchronously establish a connection to the remote pid."""
callback = stack_context.wrap(callback or (lambda stream: None))
def streaming_callback(data):
# we are not guaranteed to get an acknowledgment, but log and discard bytes if we do.
l... | python | def _maybe_connect(self, to_pid, callback=None):
"""Asynchronously establish a connection to the remote pid."""
callback = stack_context.wrap(callback or (lambda stream: None))
def streaming_callback(data):
# we are not guaranteed to get an acknowledgment, but log and discard bytes if we do.
l... | [
"def",
"_maybe_connect",
"(",
"self",
",",
"to_pid",
",",
"callback",
"=",
"None",
")",
":",
"callback",
"=",
"stack_context",
".",
"wrap",
"(",
"callback",
"or",
"(",
"lambda",
"stream",
":",
"None",
")",
")",
"def",
"streaming_callback",
"(",
"data",
"... | Asynchronously establish a connection to the remote pid. | [
"Asynchronously",
"establish",
"a",
"connection",
"to",
"the",
"remote",
"pid",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L247-L302 |
239,353 | wickman/compactor | compactor/context.py | Context.send | def send(self, from_pid, to_pid, method, body=None):
"""Send a message method from one pid to another with an optional body.
Note: It is more idiomatic to send directly from a bound process rather than
calling send on the context.
If the destination pid is on the same context, the Context may skip the... | python | def send(self, from_pid, to_pid, method, body=None):
"""Send a message method from one pid to another with an optional body.
Note: It is more idiomatic to send directly from a bound process rather than
calling send on the context.
If the destination pid is on the same context, the Context may skip the... | [
"def",
"send",
"(",
"self",
",",
"from_pid",
",",
"to_pid",
",",
"method",
",",
"body",
"=",
"None",
")",
":",
"self",
".",
"_assert_started",
"(",
")",
"self",
".",
"_assert_local_pid",
"(",
"from_pid",
")",
"if",
"self",
".",
"_is_local",
"(",
"to_pi... | Send a message method from one pid to another with an optional body.
Note: It is more idiomatic to send directly from a bound process rather than
calling send on the context.
If the destination pid is on the same context, the Context may skip the
wire and route directly to process itself. ``from_pid`... | [
"Send",
"a",
"message",
"method",
"from",
"one",
"pid",
"to",
"another",
"with",
"an",
"optional",
"body",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L309-L356 |
239,354 | wickman/compactor | compactor/context.py | Context.link | def link(self, pid, to):
"""Link a local process to a possibly remote process.
Note: It is more idiomatic to call ``link`` directly on the bound Process
object instead.
When ``pid`` is linked to ``to``, the termination of the ``to`` process
(or the severing of its connection from the Process ``pid... | python | def link(self, pid, to):
"""Link a local process to a possibly remote process.
Note: It is more idiomatic to call ``link`` directly on the bound Process
object instead.
When ``pid`` is linked to ``to``, the termination of the ``to`` process
(or the severing of its connection from the Process ``pid... | [
"def",
"link",
"(",
"self",
",",
"pid",
",",
"to",
")",
":",
"self",
".",
"_assert_started",
"(",
")",
"def",
"really_link",
"(",
")",
":",
"self",
".",
"_links",
"[",
"pid",
"]",
".",
"add",
"(",
"to",
")",
"log",
".",
"info",
"(",
"'Added link ... | Link a local process to a possibly remote process.
Note: It is more idiomatic to call ``link`` directly on the bound Process
object instead.
When ``pid`` is linked to ``to``, the termination of the ``to`` process
(or the severing of its connection from the Process ``pid``) will result
in the local... | [
"Link",
"a",
"local",
"process",
"to",
"a",
"possibly",
"remote",
"process",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L374-L405 |
239,355 | wickman/compactor | compactor/context.py | Context.terminate | def terminate(self, pid):
"""Terminate a process bound to this context.
When a process is terminated, all the processes to which it is linked
will be have their ``exited`` methods called. Messages to this process
will no longer be delivered.
This method returns immediately.
:param pid: The p... | python | def terminate(self, pid):
"""Terminate a process bound to this context.
When a process is terminated, all the processes to which it is linked
will be have their ``exited`` methods called. Messages to this process
will no longer be delivered.
This method returns immediately.
:param pid: The p... | [
"def",
"terminate",
"(",
"self",
",",
"pid",
")",
":",
"self",
".",
"_assert_started",
"(",
")",
"log",
".",
"info",
"(",
"'Terminating %s'",
"%",
"pid",
")",
"process",
"=",
"self",
".",
"_processes",
".",
"pop",
"(",
"pid",
",",
"None",
")",
"if",
... | Terminate a process bound to this context.
When a process is terminated, all the processes to which it is linked
will be have their ``exited`` methods called. Messages to this process
will no longer be delivered.
This method returns immediately.
:param pid: The pid of the process to terminate.
... | [
"Terminate",
"a",
"process",
"bound",
"to",
"this",
"context",
"."
] | 52714be3d84aa595a212feccb4d92ec250cede2a | https://github.com/wickman/compactor/blob/52714be3d84aa595a212feccb4d92ec250cede2a/compactor/context.py#L407-L427 |
239,356 | DolphDev/ezurl | ezurl/__init__.py | Url._page_gen | def _page_gen(self):
"""
Generates The String for pages
"""
track = ""
for page in self.__pages__:
track += "/{page}".format(page=page)
return track | python | def _page_gen(self):
"""
Generates The String for pages
"""
track = ""
for page in self.__pages__:
track += "/{page}".format(page=page)
return track | [
"def",
"_page_gen",
"(",
"self",
")",
":",
"track",
"=",
"\"\"",
"for",
"page",
"in",
"self",
".",
"__pages__",
":",
"track",
"+=",
"\"/{page}\"",
".",
"format",
"(",
"page",
"=",
"page",
")",
"return",
"track"
] | Generates The String for pages | [
"Generates",
"The",
"String",
"for",
"pages"
] | deaa755db2c0532c237f9eb4192aa51c7e928a07 | https://github.com/DolphDev/ezurl/blob/deaa755db2c0532c237f9eb4192aa51c7e928a07/ezurl/__init__.py#L102-L109 |
239,357 | DolphDev/ezurl | ezurl/__init__.py | Url._query_gen | def _query_gen(self):
"""Generates The String for queries"""
return urlencode(self.__query__, safe=self.safe, querydelimiter=self.__querydelimiter__) | python | def _query_gen(self):
"""Generates The String for queries"""
return urlencode(self.__query__, safe=self.safe, querydelimiter=self.__querydelimiter__) | [
"def",
"_query_gen",
"(",
"self",
")",
":",
"return",
"urlencode",
"(",
"self",
".",
"__query__",
",",
"safe",
"=",
"self",
".",
"safe",
",",
"querydelimiter",
"=",
"self",
".",
"__querydelimiter__",
")"
] | Generates The String for queries | [
"Generates",
"The",
"String",
"for",
"queries"
] | deaa755db2c0532c237f9eb4192aa51c7e928a07 | https://github.com/DolphDev/ezurl/blob/deaa755db2c0532c237f9eb4192aa51c7e928a07/ezurl/__init__.py#L111-L113 |
239,358 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/convert/StringConverter.py | StringConverter.to_nullable_string | def to_nullable_string(value):
"""
Converts value into string or returns None when value is None.
:param value: the value to convert.
:return: string value or None when value is None.
"""
if value == None:
return None
if type(value) == datetime.date:... | python | def to_nullable_string(value):
"""
Converts value into string or returns None when value is None.
:param value: the value to convert.
:return: string value or None when value is None.
"""
if value == None:
return None
if type(value) == datetime.date:... | [
"def",
"to_nullable_string",
"(",
"value",
")",
":",
"if",
"value",
"==",
"None",
":",
"return",
"None",
"if",
"type",
"(",
"value",
")",
"==",
"datetime",
".",
"date",
":",
"return",
"value",
".",
"isoformat",
"(",
")",
"if",
"type",
"(",
"value",
"... | Converts value into string or returns None when value is None.
:param value: the value to convert.
:return: string value or None when value is None. | [
"Converts",
"value",
"into",
"string",
"or",
"returns",
"None",
"when",
"value",
"is",
"None",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/convert/StringConverter.py#L30-L55 |
239,359 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/convert/StringConverter.py | StringConverter.to_string_with_default | def to_string_with_default(value, default_value):
"""
Converts value into string or returns default when value is None.
:param value: the value to convert.
:param default_value: the default value.
:return: string value or default when value is null.
"""
result ... | python | def to_string_with_default(value, default_value):
"""
Converts value into string or returns default when value is None.
:param value: the value to convert.
:param default_value: the default value.
:return: string value or default when value is null.
"""
result ... | [
"def",
"to_string_with_default",
"(",
"value",
",",
"default_value",
")",
":",
"result",
"=",
"StringConverter",
".",
"to_nullable_string",
"(",
"value",
")",
"return",
"result",
"if",
"result",
"!=",
"None",
"else",
"default_value"
] | Converts value into string or returns default when value is None.
:param value: the value to convert.
:param default_value: the default value.
:return: string value or default when value is null. | [
"Converts",
"value",
"into",
"string",
"or",
"returns",
"default",
"when",
"value",
"is",
"None",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/convert/StringConverter.py#L69-L80 |
239,360 | rvswift/EB | EB/builder/postanalysis/postanalysis.py | run | def run(itf):
"""
Run postanalyze functions.
"""
if not itf:
return 1
# access user input
options = SplitInput(itf)
# check input args
error_check(options)
# read input files
try:
molecules, ensemble_lookup = ReadFiles(options)
except:
return 1
if o... | python | def run(itf):
"""
Run postanalyze functions.
"""
if not itf:
return 1
# access user input
options = SplitInput(itf)
# check input args
error_check(options)
# read input files
try:
molecules, ensemble_lookup = ReadFiles(options)
except:
return 1
if o... | [
"def",
"run",
"(",
"itf",
")",
":",
"if",
"not",
"itf",
":",
"return",
"1",
"# access user input",
"options",
"=",
"SplitInput",
"(",
"itf",
")",
"# check input args",
"error_check",
"(",
"options",
")",
"# read input files",
"try",
":",
"molecules",
",",
"e... | Run postanalyze functions. | [
"Run",
"postanalyze",
"functions",
"."
] | 341880b79faf8147dc9fa6e90438531cd09fabcc | https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/postanalysis/postanalysis.py#L11-L34 |
239,361 | rvswift/EB | EB/builder/postanalysis/postanalysis.py | evaluate_list | def evaluate_list(molecules, ensemble_lookup, options):
"""
Evaluate a list of ensembles and return statistics and ROC plots if appropriate
"""
# create stats dictionaries to store results from each ensemble
stats = {} # {file name : metric_List}
# print progress messages
if options.write... | python | def evaluate_list(molecules, ensemble_lookup, options):
"""
Evaluate a list of ensembles and return statistics and ROC plots if appropriate
"""
# create stats dictionaries to store results from each ensemble
stats = {} # {file name : metric_List}
# print progress messages
if options.write... | [
"def",
"evaluate_list",
"(",
"molecules",
",",
"ensemble_lookup",
",",
"options",
")",
":",
"# create stats dictionaries to store results from each ensemble",
"stats",
"=",
"{",
"}",
"# {file name : metric_List}",
"# print progress messages",
"if",
"options",
".",
"write_roc"... | Evaluate a list of ensembles and return statistics and ROC plots if appropriate | [
"Evaluate",
"a",
"list",
"of",
"ensembles",
"and",
"return",
"statistics",
"and",
"ROC",
"plots",
"if",
"appropriate"
] | 341880b79faf8147dc9fa6e90438531cd09fabcc | https://github.com/rvswift/EB/blob/341880b79faf8147dc9fa6e90438531cd09fabcc/EB/builder/postanalysis/postanalysis.py#L106-L133 |
239,362 | humilis/humilis-lambdautils | lambdautils/monitor.py | _sentry_context_dict | def _sentry_context_dict(context):
"""Create a dict with context information for Sentry."""
d = {
"function_name": context.function_name,
"function_version": context.function_version,
"invoked_function_arn": context.invoked_function_arn,
"memory_limit_in_mb": context.memory_limit... | python | def _sentry_context_dict(context):
"""Create a dict with context information for Sentry."""
d = {
"function_name": context.function_name,
"function_version": context.function_version,
"invoked_function_arn": context.invoked_function_arn,
"memory_limit_in_mb": context.memory_limit... | [
"def",
"_sentry_context_dict",
"(",
"context",
")",
":",
"d",
"=",
"{",
"\"function_name\"",
":",
"context",
".",
"function_name",
",",
"\"function_version\"",
":",
"context",
".",
"function_version",
",",
"\"invoked_function_arn\"",
":",
"context",
".",
"invoked_fu... | Create a dict with context information for Sentry. | [
"Create",
"a",
"dict",
"with",
"context",
"information",
"for",
"Sentry",
"."
] | 58f75eb5ace23523c283708d56a9193181ea7e8e | https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/monitor.py#L27-L44 |
239,363 | humilis/humilis-lambdautils | lambdautils/monitor.py | sentry_monitor | def sentry_monitor(error_stream=None, **kwargs):
"""Sentry monitoring for AWS Lambda handler."""
def decorator(func):
"""A decorator that adds Sentry monitoring to a Lambda handler."""
def wrapper(event, context):
"""Wrap the target function."""
client = _setup_sentry_cli... | python | def sentry_monitor(error_stream=None, **kwargs):
"""Sentry monitoring for AWS Lambda handler."""
def decorator(func):
"""A decorator that adds Sentry monitoring to a Lambda handler."""
def wrapper(event, context):
"""Wrap the target function."""
client = _setup_sentry_cli... | [
"def",
"sentry_monitor",
"(",
"error_stream",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"\"\"\"A decorator that adds Sentry monitoring to a Lambda handler.\"\"\"",
"def",
"wrapper",
"(",
"event",
",",
"context",
")",
... | Sentry monitoring for AWS Lambda handler. | [
"Sentry",
"monitoring",
"for",
"AWS",
"Lambda",
"handler",
"."
] | 58f75eb5ace23523c283708d56a9193181ea7e8e | https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/monitor.py#L47-L66 |
239,364 | humilis/humilis-lambdautils | lambdautils/monitor.py | _setup_sentry_client | def _setup_sentry_client(context):
"""Produce and configure the sentry client."""
# get_secret will be deprecated soon
dsn = os.environ.get("SENTRY_DSN")
try:
client = raven.Client(dsn, sample_rate=SENTRY_SAMPLE_RATE)
client.user_context(_sentry_context_dict(context))
return cli... | python | def _setup_sentry_client(context):
"""Produce and configure the sentry client."""
# get_secret will be deprecated soon
dsn = os.environ.get("SENTRY_DSN")
try:
client = raven.Client(dsn, sample_rate=SENTRY_SAMPLE_RATE)
client.user_context(_sentry_context_dict(context))
return cli... | [
"def",
"_setup_sentry_client",
"(",
"context",
")",
":",
"# get_secret will be deprecated soon",
"dsn",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"SENTRY_DSN\"",
")",
"try",
":",
"client",
"=",
"raven",
".",
"Client",
"(",
"dsn",
",",
"sample_rate",
"=",
... | Produce and configure the sentry client. | [
"Produce",
"and",
"configure",
"the",
"sentry",
"client",
"."
] | 58f75eb5ace23523c283708d56a9193181ea7e8e | https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/monitor.py#L69-L80 |
239,365 | humilis/humilis-lambdautils | lambdautils/monitor.py | _handle_processing_error | def _handle_processing_error(err, errstream, client):
"""Handle ProcessingError exceptions."""
errors = sorted(err.events, key=operator.attrgetter("index"))
failed = [e.event for e in errors]
silent = all(isinstance(e.error, OutOfOrderError) for e in errors)
if errstream:
_deliver_errored_e... | python | def _handle_processing_error(err, errstream, client):
"""Handle ProcessingError exceptions."""
errors = sorted(err.events, key=operator.attrgetter("index"))
failed = [e.event for e in errors]
silent = all(isinstance(e.error, OutOfOrderError) for e in errors)
if errstream:
_deliver_errored_e... | [
"def",
"_handle_processing_error",
"(",
"err",
",",
"errstream",
",",
"client",
")",
":",
"errors",
"=",
"sorted",
"(",
"err",
".",
"events",
",",
"key",
"=",
"operator",
".",
"attrgetter",
"(",
"\"index\"",
")",
")",
"failed",
"=",
"[",
"e",
".",
"eve... | Handle ProcessingError exceptions. | [
"Handle",
"ProcessingError",
"exceptions",
"."
] | 58f75eb5ace23523c283708d56a9193181ea7e8e | https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/monitor.py#L83-L107 |
239,366 | humilis/humilis-lambdautils | lambdautils/monitor.py | _deliver_errored_events | def _deliver_errored_events(errstream, recs):
"""Deliver errors to error stream."""
rlogger.info("Going to handle %s failed events", len(recs))
rlogger.info(
"First failed event: %s", json.dumps(recs[0], indent=4))
kinesis_stream = errstream.get("kinesis_stream")
randomkey = str(uuid.uuid4(... | python | def _deliver_errored_events(errstream, recs):
"""Deliver errors to error stream."""
rlogger.info("Going to handle %s failed events", len(recs))
rlogger.info(
"First failed event: %s", json.dumps(recs[0], indent=4))
kinesis_stream = errstream.get("kinesis_stream")
randomkey = str(uuid.uuid4(... | [
"def",
"_deliver_errored_events",
"(",
"errstream",
",",
"recs",
")",
":",
"rlogger",
".",
"info",
"(",
"\"Going to handle %s failed events\"",
",",
"len",
"(",
"recs",
")",
")",
"rlogger",
".",
"info",
"(",
"\"First failed event: %s\"",
",",
"json",
".",
"dumps... | Deliver errors to error stream. | [
"Deliver",
"errors",
"to",
"error",
"stream",
"."
] | 58f75eb5ace23523c283708d56a9193181ea7e8e | https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/monitor.py#L110-L129 |
239,367 | humilis/humilis-lambdautils | lambdautils/monitor.py | _get_records | def _get_records(event):
"""Get records from an AWS Lambda trigger event."""
try:
recs, _ = unpack_kinesis_event(event, deserializer=None)
except KeyError:
# If not a Kinesis event, just unpack the records
recs = event["Records"]
return recs | python | def _get_records(event):
"""Get records from an AWS Lambda trigger event."""
try:
recs, _ = unpack_kinesis_event(event, deserializer=None)
except KeyError:
# If not a Kinesis event, just unpack the records
recs = event["Records"]
return recs | [
"def",
"_get_records",
"(",
"event",
")",
":",
"try",
":",
"recs",
",",
"_",
"=",
"unpack_kinesis_event",
"(",
"event",
",",
"deserializer",
"=",
"None",
")",
"except",
"KeyError",
":",
"# If not a Kinesis event, just unpack the records",
"recs",
"=",
"event",
"... | Get records from an AWS Lambda trigger event. | [
"Get",
"records",
"from",
"an",
"AWS",
"Lambda",
"trigger",
"event",
"."
] | 58f75eb5ace23523c283708d56a9193181ea7e8e | https://github.com/humilis/humilis-lambdautils/blob/58f75eb5ace23523c283708d56a9193181ea7e8e/lambdautils/monitor.py#L132-L139 |
239,368 | macbre/elasticsearch-query | elasticsearch_query.py | ElasticsearchQuery._search | def _search(self, query, fields=None, limit=50000, sampling=None):
"""
Perform the search and return raw rows
:type query object
:type fields list[str] or None
:type limit int
:type sampling int or None
:arg sampling: Percentage of results to be returned (0,100)... | python | def _search(self, query, fields=None, limit=50000, sampling=None):
"""
Perform the search and return raw rows
:type query object
:type fields list[str] or None
:type limit int
:type sampling int or None
:arg sampling: Percentage of results to be returned (0,100)... | [
"def",
"_search",
"(",
"self",
",",
"query",
",",
"fields",
"=",
"None",
",",
"limit",
"=",
"50000",
",",
"sampling",
"=",
"None",
")",
":",
"body",
"=",
"{",
"\"query\"",
":",
"{",
"\"bool\"",
":",
"{",
"\"must\"",
":",
"[",
"query",
"]",
"}",
"... | Perform the search and return raw rows
:type query object
:type fields list[str] or None
:type limit int
:type sampling int or None
:arg sampling: Percentage of results to be returned (0,100)
:rtype: list | [
"Perform",
"the",
"search",
"and",
"return",
"raw",
"rows"
] | d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf | https://github.com/macbre/elasticsearch-query/blob/d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf/elasticsearch_query.py#L121-L190 |
239,369 | macbre/elasticsearch-query | elasticsearch_query.py | ElasticsearchQuery.get_rows | def get_rows(self, match, fields=None, limit=10, sampling=None):
"""
Returns raw rows that matches given query
:arg match: query to be run against Kibana log messages (ex. {"@message": "Foo Bar DB queries"})
:type fields list[str] or None
:arg limit: the number of results (defau... | python | def get_rows(self, match, fields=None, limit=10, sampling=None):
"""
Returns raw rows that matches given query
:arg match: query to be run against Kibana log messages (ex. {"@message": "Foo Bar DB queries"})
:type fields list[str] or None
:arg limit: the number of results (defau... | [
"def",
"get_rows",
"(",
"self",
",",
"match",
",",
"fields",
"=",
"None",
",",
"limit",
"=",
"10",
",",
"sampling",
"=",
"None",
")",
":",
"query",
"=",
"{",
"\"match\"",
":",
"match",
",",
"}",
"return",
"self",
".",
"_search",
"(",
"query",
",",
... | Returns raw rows that matches given query
:arg match: query to be run against Kibana log messages (ex. {"@message": "Foo Bar DB queries"})
:type fields list[str] or None
:arg limit: the number of results (defaults to 10)
:type sampling int or None
:arg sampling: Percentage of re... | [
"Returns",
"raw",
"rows",
"that",
"matches",
"given",
"query"
] | d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf | https://github.com/macbre/elasticsearch-query/blob/d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf/elasticsearch_query.py#L192-L206 |
239,370 | macbre/elasticsearch-query | elasticsearch_query.py | ElasticsearchQuery.query_by_string | def query_by_string(self, query, fields=None, limit=10, sampling=None):
"""
Returns raw rows that matches the given query string
:arg query: query string to be run against Kibana log messages (ex. @message:"^PHP Fatal").
:type fields list[str] or None
:arg limit: the number of r... | python | def query_by_string(self, query, fields=None, limit=10, sampling=None):
"""
Returns raw rows that matches the given query string
:arg query: query string to be run against Kibana log messages (ex. @message:"^PHP Fatal").
:type fields list[str] or None
:arg limit: the number of r... | [
"def",
"query_by_string",
"(",
"self",
",",
"query",
",",
"fields",
"=",
"None",
",",
"limit",
"=",
"10",
",",
"sampling",
"=",
"None",
")",
":",
"query",
"=",
"{",
"\"query_string\"",
":",
"{",
"\"query\"",
":",
"query",
",",
"}",
"}",
"return",
"se... | Returns raw rows that matches the given query string
:arg query: query string to be run against Kibana log messages (ex. @message:"^PHP Fatal").
:type fields list[str] or None
:arg limit: the number of results (defaults to 10)
:type sampling int or None
:arg sampling: Percentage... | [
"Returns",
"raw",
"rows",
"that",
"matches",
"the",
"given",
"query",
"string"
] | d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf | https://github.com/macbre/elasticsearch-query/blob/d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf/elasticsearch_query.py#L208-L224 |
239,371 | macbre/elasticsearch-query | elasticsearch_query.py | ElasticsearchQuery.count | def count(self, query):
"""
Returns number of matching entries
:type query str
:rtype: int
"""
body = {
"query": {
"bool": {
"must": [{
"query_string": {
"query": query,
... | python | def count(self, query):
"""
Returns number of matching entries
:type query str
:rtype: int
"""
body = {
"query": {
"bool": {
"must": [{
"query_string": {
"query": query,
... | [
"def",
"count",
"(",
"self",
",",
"query",
")",
":",
"body",
"=",
"{",
"\"query\"",
":",
"{",
"\"bool\"",
":",
"{",
"\"must\"",
":",
"[",
"{",
"\"query_string\"",
":",
"{",
"\"query\"",
":",
"query",
",",
"}",
"}",
"]",
"}",
"}",
"}",
"body",
"["... | Returns number of matching entries
:type query str
:rtype: int | [
"Returns",
"number",
"of",
"matching",
"entries"
] | d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf | https://github.com/macbre/elasticsearch-query/blob/d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf/elasticsearch_query.py#L226-L247 |
239,372 | macbre/elasticsearch-query | elasticsearch_query.py | ElasticsearchQuery.query_by_sql | def query_by_sql(self, sql):
"""
Returns entries matching given SQL query
:type sql str
:rtype: list[dict]
"""
# https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest.html
# https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-sy... | python | def query_by_sql(self, sql):
"""
Returns entries matching given SQL query
:type sql str
:rtype: list[dict]
"""
# https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest.html
# https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-sy... | [
"def",
"query_by_sql",
"(",
"self",
",",
"sql",
")",
":",
"# https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-rest.html",
"# https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-syntax-select.html",
"body",
"=",
"{",
"'query'",
":",
"sql",
"}",
"re... | Returns entries matching given SQL query
:type sql str
:rtype: list[dict] | [
"Returns",
"entries",
"matching",
"given",
"SQL",
"query"
] | d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf | https://github.com/macbre/elasticsearch-query/blob/d5e0fa43fde20b7f38f9d99c3fc24f681d6e5baf/elasticsearch_query.py#L249-L265 |
239,373 | koriakin/binflakes | binflakes/types/int.py | BinInt.extract | def extract(self, pos, width):
"""Extracts a subword with a given width, starting from a given
bit position.
"""
pos = operator.index(pos)
width = operator.index(width)
if width < 0:
raise ValueError('width must not be negative')
if pos < 0:
... | python | def extract(self, pos, width):
"""Extracts a subword with a given width, starting from a given
bit position.
"""
pos = operator.index(pos)
width = operator.index(width)
if width < 0:
raise ValueError('width must not be negative')
if pos < 0:
... | [
"def",
"extract",
"(",
"self",
",",
"pos",
",",
"width",
")",
":",
"pos",
"=",
"operator",
".",
"index",
"(",
"pos",
")",
"width",
"=",
"operator",
".",
"index",
"(",
"width",
")",
"if",
"width",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'width m... | Extracts a subword with a given width, starting from a given
bit position. | [
"Extracts",
"a",
"subword",
"with",
"a",
"given",
"width",
"starting",
"from",
"a",
"given",
"bit",
"position",
"."
] | f059cecadf1c605802a713c62375b5bd5606d53f | https://github.com/koriakin/binflakes/blob/f059cecadf1c605802a713c62375b5bd5606d53f/binflakes/types/int.py#L72-L82 |
239,374 | Brazelton-Lab/bio_utils | bio_utils/blast_tools/blast_to_cigar.py | blast_to_cigar | def blast_to_cigar(query_seq, match_seq, subject_seq, cigar_age='new'):
"""converts BLAST alignment into a old or new CIGAR line
Args:
query_seq (str): Aligned portion of query sequence
match_seq (str): Alignment sequence
subject_seq (str): Aligned portion of subject/reference sequenc... | python | def blast_to_cigar(query_seq, match_seq, subject_seq, cigar_age='new'):
"""converts BLAST alignment into a old or new CIGAR line
Args:
query_seq (str): Aligned portion of query sequence
match_seq (str): Alignment sequence
subject_seq (str): Aligned portion of subject/reference sequenc... | [
"def",
"blast_to_cigar",
"(",
"query_seq",
",",
"match_seq",
",",
"subject_seq",
",",
"cigar_age",
"=",
"'new'",
")",
":",
"if",
"not",
"len",
"(",
"query_seq",
")",
"==",
"len",
"(",
"match_seq",
")",
"or",
"not",
"len",
"(",
"query_seq",
")",
"==",
"... | converts BLAST alignment into a old or new CIGAR line
Args:
query_seq (str): Aligned portion of query sequence
match_seq (str): Alignment sequence
subject_seq (str): Aligned portion of subject/reference sequence
cigar_age (str): ['old', 'new'] CIGAR format to use, new is highly
... | [
"converts",
"BLAST",
"alignment",
"into",
"a",
"old",
"or",
"new",
"CIGAR",
"line"
] | 5a7ddf13ee0bf4baaaeb6b2b99e01bf74aa132b7 | https://github.com/Brazelton-Lab/bio_utils/blob/5a7ddf13ee0bf4baaaeb6b2b99e01bf74aa132b7/bio_utils/blast_tools/blast_to_cigar.py#L32-L113 |
239,375 | edeposit/isbn_validator | src/isbn_validator/isbn_validator.py | _clean_isbn | def _clean_isbn(isbn):
"""
Remove all non-digit and non "x" characters from given string.
Args:
isbn (str): isbn string, which will be cleaned.
Returns:
list: array of numbers (if "x" is found, it is converted to 10).
"""
if isinstance(isbn, basestring):
isbn = list(isb... | python | def _clean_isbn(isbn):
"""
Remove all non-digit and non "x" characters from given string.
Args:
isbn (str): isbn string, which will be cleaned.
Returns:
list: array of numbers (if "x" is found, it is converted to 10).
"""
if isinstance(isbn, basestring):
isbn = list(isb... | [
"def",
"_clean_isbn",
"(",
"isbn",
")",
":",
"if",
"isinstance",
"(",
"isbn",
",",
"basestring",
")",
":",
"isbn",
"=",
"list",
"(",
"isbn",
".",
"lower",
"(",
")",
")",
"# filter digits and \"x\"",
"isbn",
"=",
"filter",
"(",
"lambda",
"x",
":",
"x",
... | Remove all non-digit and non "x" characters from given string.
Args:
isbn (str): isbn string, which will be cleaned.
Returns:
list: array of numbers (if "x" is found, it is converted to 10). | [
"Remove",
"all",
"non",
"-",
"digit",
"and",
"non",
"x",
"characters",
"from",
"given",
"string",
"."
] | d285846940a8f71bac5a4694f640c026510d9063 | https://github.com/edeposit/isbn_validator/blob/d285846940a8f71bac5a4694f640c026510d9063/src/isbn_validator/isbn_validator.py#L18-L35 |
239,376 | edeposit/isbn_validator | src/isbn_validator/isbn_validator.py | _isbn_cleaner | def _isbn_cleaner(fn):
"""
Decorator for calling other functions from this module.
Purpose of this decorator is to clean the ISBN string from garbage and
return list of digits.
Args:
fn (function): function in which will be :func:`_clean_isbn(isbn)` call
wrapped.
... | python | def _isbn_cleaner(fn):
"""
Decorator for calling other functions from this module.
Purpose of this decorator is to clean the ISBN string from garbage and
return list of digits.
Args:
fn (function): function in which will be :func:`_clean_isbn(isbn)` call
wrapped.
... | [
"def",
"_isbn_cleaner",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper",
"(",
"isbn",
")",
":",
"return",
"fn",
"(",
"_clean_isbn",
"(",
"isbn",
")",
")",
"return",
"wrapper"
] | Decorator for calling other functions from this module.
Purpose of this decorator is to clean the ISBN string from garbage and
return list of digits.
Args:
fn (function): function in which will be :func:`_clean_isbn(isbn)` call
wrapped. | [
"Decorator",
"for",
"calling",
"other",
"functions",
"from",
"this",
"module",
"."
] | d285846940a8f71bac5a4694f640c026510d9063 | https://github.com/edeposit/isbn_validator/blob/d285846940a8f71bac5a4694f640c026510d9063/src/isbn_validator/isbn_validator.py#L38-L53 |
239,377 | jespino/anillo | anillo/app.py | application | def application(handler, adapter_cls=WerkzeugAdapter):
"""Converts an anillo function based handler in a
wsgi compiliant application function.
:param adapter_cls: the wsgi adapter implementation (default: wekrzeug)
:returns: wsgi function
:rtype: callable
"""
adapter = adapter_cls()
de... | python | def application(handler, adapter_cls=WerkzeugAdapter):
"""Converts an anillo function based handler in a
wsgi compiliant application function.
:param adapter_cls: the wsgi adapter implementation (default: wekrzeug)
:returns: wsgi function
:rtype: callable
"""
adapter = adapter_cls()
de... | [
"def",
"application",
"(",
"handler",
",",
"adapter_cls",
"=",
"WerkzeugAdapter",
")",
":",
"adapter",
"=",
"adapter_cls",
"(",
")",
"def",
"wrapper",
"(",
"environ",
",",
"start_response",
")",
":",
"request",
"=",
"adapter",
".",
"to_request",
"(",
"enviro... | Converts an anillo function based handler in a
wsgi compiliant application function.
:param adapter_cls: the wsgi adapter implementation (default: wekrzeug)
:returns: wsgi function
:rtype: callable | [
"Converts",
"an",
"anillo",
"function",
"based",
"handler",
"in",
"a",
"wsgi",
"compiliant",
"application",
"function",
"."
] | 901a84fd2b4fa909bc06e8bd76090457990576a7 | https://github.com/jespino/anillo/blob/901a84fd2b4fa909bc06e8bd76090457990576a7/anillo/app.py#L4-L20 |
239,378 | iceb0y/aiowrap | aiowrap/wrap.py | wrap_async | def wrap_async(func):
"""Wraps an asynchronous function into a synchronous function."""
@functools.wraps(func)
def wrapped(*args, **kwargs):
fut = asyncio.ensure_future(func(*args, **kwargs))
cur = greenlet.getcurrent()
def callback(fut):
try:
cur.switch(f... | python | def wrap_async(func):
"""Wraps an asynchronous function into a synchronous function."""
@functools.wraps(func)
def wrapped(*args, **kwargs):
fut = asyncio.ensure_future(func(*args, **kwargs))
cur = greenlet.getcurrent()
def callback(fut):
try:
cur.switch(f... | [
"def",
"wrap_async",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"fut",
"=",
"asyncio",
".",
"ensure_future",
"(",
"func",
"(",
"*",
"args",
",",
... | Wraps an asynchronous function into a synchronous function. | [
"Wraps",
"an",
"asynchronous",
"function",
"into",
"a",
"synchronous",
"function",
"."
] | 7a155e68c0faee0eea7a3f43c1e96a36ccc2fd84 | https://github.com/iceb0y/aiowrap/blob/7a155e68c0faee0eea7a3f43c1e96a36ccc2fd84/aiowrap/wrap.py#L5-L18 |
239,379 | iceb0y/aiowrap | aiowrap/wrap.py | wrap_sync | def wrap_sync(func):
"""Wraps a synchronous function into an asynchronous function."""
@functools.wraps(func)
def wrapped(*args, **kwargs):
fut = asyncio.Future()
def green():
try:
fut.set_result(func(*args, **kwargs))
except BaseException as e:
... | python | def wrap_sync(func):
"""Wraps a synchronous function into an asynchronous function."""
@functools.wraps(func)
def wrapped(*args, **kwargs):
fut = asyncio.Future()
def green():
try:
fut.set_result(func(*args, **kwargs))
except BaseException as e:
... | [
"def",
"wrap_sync",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"fut",
"=",
"asyncio",
".",
"Future",
"(",
")",
"def",
"green",
"(",
")",
":",
"... | Wraps a synchronous function into an asynchronous function. | [
"Wraps",
"a",
"synchronous",
"function",
"into",
"an",
"asynchronous",
"function",
"."
] | 7a155e68c0faee0eea7a3f43c1e96a36ccc2fd84 | https://github.com/iceb0y/aiowrap/blob/7a155e68c0faee0eea7a3f43c1e96a36ccc2fd84/aiowrap/wrap.py#L20-L32 |
239,380 | dwwkelly/note | note/server.py | Note_Server.Run | def Run(self):
"""
Wait for clients to connect and service them
:returns: None
"""
while True:
try:
events = self.poller.poll()
except KeyboardInterrupt:
self.context.destroy()
sys.exit()
self... | python | def Run(self):
"""
Wait for clients to connect and service them
:returns: None
"""
while True:
try:
events = self.poller.poll()
except KeyboardInterrupt:
self.context.destroy()
sys.exit()
self... | [
"def",
"Run",
"(",
"self",
")",
":",
"while",
"True",
":",
"try",
":",
"events",
"=",
"self",
".",
"poller",
".",
"poll",
"(",
")",
"except",
"KeyboardInterrupt",
":",
"self",
".",
"context",
".",
"destroy",
"(",
")",
"sys",
".",
"exit",
"(",
")",
... | Wait for clients to connect and service them
:returns: None | [
"Wait",
"for",
"clients",
"to",
"connect",
"and",
"service",
"them"
] | b41d5fe1e4a3b67b50285168dd58f903bf219e6c | https://github.com/dwwkelly/note/blob/b41d5fe1e4a3b67b50285168dd58f903bf219e6c/note/server.py#L31-L46 |
239,381 | dwwkelly/note | note/server.py | Note_Server.Handle_Receive | def Handle_Receive(self, msg):
"""
Handle a received message.
:param msg: the received message
:type msg: str
:returns: The message to reply with
:rtype: str
"""
msg = self.Check_Message(msg)
msg_type = msg['type']
f_name = "Handle_{0}".... | python | def Handle_Receive(self, msg):
"""
Handle a received message.
:param msg: the received message
:type msg: str
:returns: The message to reply with
:rtype: str
"""
msg = self.Check_Message(msg)
msg_type = msg['type']
f_name = "Handle_{0}".... | [
"def",
"Handle_Receive",
"(",
"self",
",",
"msg",
")",
":",
"msg",
"=",
"self",
".",
"Check_Message",
"(",
"msg",
")",
"msg_type",
"=",
"msg",
"[",
"'type'",
"]",
"f_name",
"=",
"\"Handle_{0}\"",
".",
"format",
"(",
"msg_type",
")",
"try",
":",
"f",
... | Handle a received message.
:param msg: the received message
:type msg: str
:returns: The message to reply with
:rtype: str | [
"Handle",
"a",
"received",
"message",
"."
] | b41d5fe1e4a3b67b50285168dd58f903bf219e6c | https://github.com/dwwkelly/note/blob/b41d5fe1e4a3b67b50285168dd58f903bf219e6c/note/server.py#L73-L93 |
239,382 | dwwkelly/note | note/server.py | Note_Server.Handle_Search | def Handle_Search(self, msg):
"""
Handle a search.
:param msg: the received search
:type msg: dict
:returns: The message to reply with
:rtype: str
"""
search_term = msg['object']['searchTerm']
results = self.db.searchForItem(search_term)
... | python | def Handle_Search(self, msg):
"""
Handle a search.
:param msg: the received search
:type msg: dict
:returns: The message to reply with
:rtype: str
"""
search_term = msg['object']['searchTerm']
results = self.db.searchForItem(search_term)
... | [
"def",
"Handle_Search",
"(",
"self",
",",
"msg",
")",
":",
"search_term",
"=",
"msg",
"[",
"'object'",
"]",
"[",
"'searchTerm'",
"]",
"results",
"=",
"self",
".",
"db",
".",
"searchForItem",
"(",
"search_term",
")",
"reply",
"=",
"{",
"\"status\"",
":",
... | Handle a search.
:param msg: the received search
:type msg: dict
:returns: The message to reply with
:rtype: str | [
"Handle",
"a",
"search",
"."
] | b41d5fe1e4a3b67b50285168dd58f903bf219e6c | https://github.com/dwwkelly/note/blob/b41d5fe1e4a3b67b50285168dd58f903bf219e6c/note/server.py#L103-L123 |
239,383 | dwwkelly/note | note/server.py | Note_Server.Handle_Note | def Handle_Note(self, msg):
""" Handle a new note.
:param msg: the received note
:type msg: dict
:returns: The message to reply with
:rtype: str
"""
note_text = msg['object']['note']
note_tags = msg['object']['tags']
if 'ID' in msg['object']:
... | python | def Handle_Note(self, msg):
""" Handle a new note.
:param msg: the received note
:type msg: dict
:returns: The message to reply with
:rtype: str
"""
note_text = msg['object']['note']
note_tags = msg['object']['tags']
if 'ID' in msg['object']:
... | [
"def",
"Handle_Note",
"(",
"self",
",",
"msg",
")",
":",
"note_text",
"=",
"msg",
"[",
"'object'",
"]",
"[",
"'note'",
"]",
"note_tags",
"=",
"msg",
"[",
"'object'",
"]",
"[",
"'tags'",
"]",
"if",
"'ID'",
"in",
"msg",
"[",
"'object'",
"]",
":",
"no... | Handle a new note.
:param msg: the received note
:type msg: dict
:returns: The message to reply with
:rtype: str | [
"Handle",
"a",
"new",
"note",
"."
] | b41d5fe1e4a3b67b50285168dd58f903bf219e6c | https://github.com/dwwkelly/note/blob/b41d5fe1e4a3b67b50285168dd58f903bf219e6c/note/server.py#L125-L154 |
239,384 | ericflo/hurricane | hurricane/utils.py | RingBuffer.after_match | def after_match(self, func, full_fallback=False):
"""Returns an iterator for all the elements after the first
match. If `full_fallback` is `True`, it will return all the
messages if the function never matched.
"""
iterator = iter(self)
for item in iterator:
i... | python | def after_match(self, func, full_fallback=False):
"""Returns an iterator for all the elements after the first
match. If `full_fallback` is `True`, it will return all the
messages if the function never matched.
"""
iterator = iter(self)
for item in iterator:
i... | [
"def",
"after_match",
"(",
"self",
",",
"func",
",",
"full_fallback",
"=",
"False",
")",
":",
"iterator",
"=",
"iter",
"(",
"self",
")",
"for",
"item",
"in",
"iterator",
":",
"if",
"func",
"(",
"item",
")",
":",
"return",
"iterator",
"if",
"full_fallba... | Returns an iterator for all the elements after the first
match. If `full_fallback` is `True`, it will return all the
messages if the function never matched. | [
"Returns",
"an",
"iterator",
"for",
"all",
"the",
"elements",
"after",
"the",
"first",
"match",
".",
"If",
"full_fallback",
"is",
"True",
"it",
"will",
"return",
"all",
"the",
"messages",
"if",
"the",
"function",
"never",
"matched",
"."
] | c192b711b2b1c06a386d1a1a47f538b13a659cde | https://github.com/ericflo/hurricane/blob/c192b711b2b1c06a386d1a1a47f538b13a659cde/hurricane/utils.py#L112-L123 |
239,385 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/run/Cleaner.py | Cleaner.clear | def clear(correlation_id, components):
"""
Clears state of multiple components.
To be cleaned state components must implement [[ICleanable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution throu... | python | def clear(correlation_id, components):
"""
Clears state of multiple components.
To be cleaned state components must implement [[ICleanable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution throu... | [
"def",
"clear",
"(",
"correlation_id",
",",
"components",
")",
":",
"if",
"components",
"==",
"None",
":",
"return",
"for",
"component",
"in",
"components",
":",
"Cleaner",
".",
"clear_one",
"(",
"correlation_id",
",",
"component",
")"
] | Clears state of multiple components.
To be cleaned state components must implement [[ICleanable]] interface.
If they don't the call to this method has no effect.
:param correlation_id: (optional) transaction id to trace execution through call chain.
:param components: the list of comp... | [
"Clears",
"state",
"of",
"multiple",
"components",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/run/Cleaner.py#L36-L51 |
239,386 | lcgong/redbean | redbean/iso8601.py | parse_datetime | def parse_datetime(value):
"""Parses a string and return a datetime.datetime.
This function supports time zone offsets. When the input contains one,
the output uses a timezone with a fixed offset from UTC.
Raises ValueError if the input is well formatted but not a valid datetime.
Returns None if t... | python | def parse_datetime(value):
"""Parses a string and return a datetime.datetime.
This function supports time zone offsets. When the input contains one,
the output uses a timezone with a fixed offset from UTC.
Raises ValueError if the input is well formatted but not a valid datetime.
Returns None if t... | [
"def",
"parse_datetime",
"(",
"value",
")",
":",
"match",
"=",
"datetime_re",
".",
"match",
"(",
"value",
")",
"if",
"match",
":",
"kw",
"=",
"match",
".",
"groupdict",
"(",
")",
"if",
"kw",
"[",
"'microsecond'",
"]",
":",
"kw",
"[",
"'microsecond'",
... | Parses a string and return a datetime.datetime.
This function supports time zone offsets. When the input contains one,
the output uses a timezone with a fixed offset from UTC.
Raises ValueError if the input is well formatted but not a valid datetime.
Returns None if the input isn't well formatted. | [
"Parses",
"a",
"string",
"and",
"return",
"a",
"datetime",
".",
"datetime",
"."
] | 45df9ff1e807e742771c752808d7fdac4007c919 | https://github.com/lcgong/redbean/blob/45df9ff1e807e742771c752808d7fdac4007c919/redbean/iso8601.py#L73-L98 |
239,387 | sysr-q/mattdaemon | mattdaemon/daemon.py | daemon.status | def status(self):
"""
Check if the daemon is currently running.
Requires procfs, so it will only work on POSIX compliant OS'.
"""
# Get the pid from the pidfile
try:
pf = file(self.pidfile,'r')
pid = int(pf.read().strip())
pf.close()
except IOError:
pid = None
if not pid:
return False
... | python | def status(self):
"""
Check if the daemon is currently running.
Requires procfs, so it will only work on POSIX compliant OS'.
"""
# Get the pid from the pidfile
try:
pf = file(self.pidfile,'r')
pid = int(pf.read().strip())
pf.close()
except IOError:
pid = None
if not pid:
return False
... | [
"def",
"status",
"(",
"self",
")",
":",
"# Get the pid from the pidfile",
"try",
":",
"pf",
"=",
"file",
"(",
"self",
".",
"pidfile",
",",
"'r'",
")",
"pid",
"=",
"int",
"(",
"pf",
".",
"read",
"(",
")",
".",
"strip",
"(",
")",
")",
"pf",
".",
"c... | Check if the daemon is currently running.
Requires procfs, so it will only work on POSIX compliant OS'. | [
"Check",
"if",
"the",
"daemon",
"is",
"currently",
"running",
".",
"Requires",
"procfs",
"so",
"it",
"will",
"only",
"work",
"on",
"POSIX",
"compliant",
"OS",
"."
] | bc32a372f46650e0ca69b84da320fa7fee3d192d | https://github.com/sysr-q/mattdaemon/blob/bc32a372f46650e0ca69b84da320fa7fee3d192d/mattdaemon/daemon.py#L174-L193 |
239,388 | LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.func | def func(self, name: str):
"""return the first func defined named name"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)
and f._name == name):
return f | python | def func(self, name: str):
"""return the first func defined named name"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)
and f._name == name):
return f | [
"def",
"func",
"(",
"self",
",",
"name",
":",
"str",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"isinstance",
"(",
"f",
".",
"_ctype",
",",
"FuncType",
")",
"and",
"f",
"."... | return the first func defined named name | [
"return",
"the",
"first",
"func",
"defined",
"named",
"name"
] | b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15 | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L369-L375 |
239,389 | LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.type | def type(self, name: str):
"""return the first complete definition of type 'name'"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF
and f._name == name):
return f | python | def type(self, name: str):
"""return the first complete definition of type 'name'"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF
and f._name == name):
return f | [
"def",
"type",
"(",
"self",
",",
"name",
":",
"str",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"f",
".",
"_ctype",
".",
"_storage",
"==",
"Storages",
".",
"TYPEDEF",
"and",
... | return the first complete definition of type 'name | [
"return",
"the",
"first",
"complete",
"definition",
"of",
"type",
"name"
] | b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15 | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L385-L391 |
239,390 | LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.declallfuncs | def declallfuncs(self):
"""generator on all declaration of function"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)):
yield f | python | def declallfuncs(self):
"""generator on all declaration of function"""
for f in self.body:
if (hasattr(f, '_ctype')
and isinstance(f._ctype, FuncType)):
yield f | [
"def",
"declallfuncs",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"isinstance",
"(",
"f",
".",
"_ctype",
",",
"FuncType",
")",
")",
":",
"yield",
"f"
] | generator on all declaration of function | [
"generator",
"on",
"all",
"declaration",
"of",
"function"
] | b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15 | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L417-L422 |
239,391 | LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.declallvars | def declallvars(self):
"""generator on all declaration of variable"""
for f in self.body:
if (hasattr(f, '_ctype')
and not isinstance(f._ctype, FuncType)):
yield f | python | def declallvars(self):
"""generator on all declaration of variable"""
for f in self.body:
if (hasattr(f, '_ctype')
and not isinstance(f._ctype, FuncType)):
yield f | [
"def",
"declallvars",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"not",
"isinstance",
"(",
"f",
".",
"_ctype",
",",
"FuncType",
")",
")",
":",
"yield",
"f"
] | generator on all declaration of variable | [
"generator",
"on",
"all",
"declaration",
"of",
"variable"
] | b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15 | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L424-L429 |
239,392 | LionelAuroux/cnorm | cnorm/nodes.py | BlockStmt.declalltypes | def declalltypes(self):
"""generator on all declaration of type"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF):
yield f | python | def declalltypes(self):
"""generator on all declaration of type"""
for f in self.body:
if (hasattr(f, '_ctype')
and f._ctype._storage == Storages.TYPEDEF):
yield f | [
"def",
"declalltypes",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"body",
":",
"if",
"(",
"hasattr",
"(",
"f",
",",
"'_ctype'",
")",
"and",
"f",
".",
"_ctype",
".",
"_storage",
"==",
"Storages",
".",
"TYPEDEF",
")",
":",
"yield",
"f"
] | generator on all declaration of type | [
"generator",
"on",
"all",
"declaration",
"of",
"type"
] | b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15 | https://github.com/LionelAuroux/cnorm/blob/b7bb09a70c62fb02c1e41e6280a2a5c0cf2c0f15/cnorm/nodes.py#L431-L436 |
239,393 | JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/widgets/actionreportdialog.py | TextPopupButton.show_popup | def show_popup(self, *args, **kwargs):
"""Show a popup with a textedit
:returns: None
:rtype: None
:raises: None
"""
self.mw = JB_MainWindow(parent=self, flags=QtCore.Qt.Dialog)
self.mw.setWindowTitle(self.popuptitle)
self.mw.setWindowModality(QtCore.Qt.A... | python | def show_popup(self, *args, **kwargs):
"""Show a popup with a textedit
:returns: None
:rtype: None
:raises: None
"""
self.mw = JB_MainWindow(parent=self, flags=QtCore.Qt.Dialog)
self.mw.setWindowTitle(self.popuptitle)
self.mw.setWindowModality(QtCore.Qt.A... | [
"def",
"show_popup",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"mw",
"=",
"JB_MainWindow",
"(",
"parent",
"=",
"self",
",",
"flags",
"=",
"QtCore",
".",
"Qt",
".",
"Dialog",
")",
"self",
".",
"mw",
".",
"setWi... | Show a popup with a textedit
:returns: None
:rtype: None
:raises: None | [
"Show",
"a",
"popup",
"with",
"a",
"textedit"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/widgets/actionreportdialog.py#L36-L55 |
239,394 | ravenac95/overlay4u | overlay4u/__init__.py | mount | def mount(directory, lower_dir, upper_dir, mount_table=None):
"""Creates a mount"""
return OverlayFS.mount(directory, lower_dir, upper_dir,
mount_table=mount_table) | python | def mount(directory, lower_dir, upper_dir, mount_table=None):
"""Creates a mount"""
return OverlayFS.mount(directory, lower_dir, upper_dir,
mount_table=mount_table) | [
"def",
"mount",
"(",
"directory",
",",
"lower_dir",
",",
"upper_dir",
",",
"mount_table",
"=",
"None",
")",
":",
"return",
"OverlayFS",
".",
"mount",
"(",
"directory",
",",
"lower_dir",
",",
"upper_dir",
",",
"mount_table",
"=",
"mount_table",
")"
] | Creates a mount | [
"Creates",
"a",
"mount"
] | 621eecc0d4d40951aa8afcb533b5eec5d91c73cc | https://github.com/ravenac95/overlay4u/blob/621eecc0d4d40951aa8afcb533b5eec5d91c73cc/overlay4u/__init__.py#L4-L7 |
239,395 | TrainerDex/TrainerDex.py | trainerdex/leaderboard.py | DiscordLeaderboard.filter_teams | def filter_teams(self, teams):
"""Expects an iterable of team IDs"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['faction']['id'] in teams] | python | def filter_teams(self, teams):
"""Expects an iterable of team IDs"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['faction']['id'] in teams] | [
"def",
"filter_teams",
"(",
"self",
",",
"teams",
")",
":",
"return",
"[",
"LeaderboardInstance",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"_leaderboard",
"if",
"x",
"[",
"'faction'",
"]",
"[",
"'id'",
"]",
"in",
"teams",
"]"
] | Expects an iterable of team IDs | [
"Expects",
"an",
"iterable",
"of",
"team",
"IDs"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/leaderboard.py#L123-L125 |
239,396 | TrainerDex/TrainerDex.py | trainerdex/leaderboard.py | DiscordLeaderboard.filter_users | def filter_users(self, users):
"""Expects an interable of User IDs ints"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['user_id'] in users] | python | def filter_users(self, users):
"""Expects an interable of User IDs ints"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['user_id'] in users] | [
"def",
"filter_users",
"(",
"self",
",",
"users",
")",
":",
"return",
"[",
"LeaderboardInstance",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"_leaderboard",
"if",
"x",
"[",
"'user_id'",
"]",
"in",
"users",
"]"
] | Expects an interable of User IDs ints | [
"Expects",
"an",
"interable",
"of",
"User",
"IDs",
"ints"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/leaderboard.py#L127-L129 |
239,397 | TrainerDex/TrainerDex.py | trainerdex/leaderboard.py | DiscordLeaderboard.filter_trainers | def filter_trainers(self, trainers):
"""Expects an interable of Trainer IDs ints"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['id'] in trainers] | python | def filter_trainers(self, trainers):
"""Expects an interable of Trainer IDs ints"""
return [LeaderboardInstance(x) for x in self._leaderboard if x['id'] in trainers] | [
"def",
"filter_trainers",
"(",
"self",
",",
"trainers",
")",
":",
"return",
"[",
"LeaderboardInstance",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"_leaderboard",
"if",
"x",
"[",
"'id'",
"]",
"in",
"trainers",
"]"
] | Expects an interable of Trainer IDs ints | [
"Expects",
"an",
"interable",
"of",
"Trainer",
"IDs",
"ints"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/leaderboard.py#L131-L133 |
239,398 | willkg/phil | phil/util.py | normalize_path | def normalize_path(path, filetype=FILE):
"""Takes a path and a filetype, verifies existence and type, and
returns absolute path.
"""
if not path:
raise ValueError('"{0}" is not a valid path.'.format(path))
if not os.path.exists(path):
raise ValueError('"{0}" does not exist.'.format(... | python | def normalize_path(path, filetype=FILE):
"""Takes a path and a filetype, verifies existence and type, and
returns absolute path.
"""
if not path:
raise ValueError('"{0}" is not a valid path.'.format(path))
if not os.path.exists(path):
raise ValueError('"{0}" does not exist.'.format(... | [
"def",
"normalize_path",
"(",
"path",
",",
"filetype",
"=",
"FILE",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"'\"{0}\" is not a valid path.'",
".",
"format",
"(",
"path",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"("... | Takes a path and a filetype, verifies existence and type, and
returns absolute path. | [
"Takes",
"a",
"path",
"and",
"a",
"filetype",
"verifies",
"existence",
"and",
"type",
"and",
"returns",
"absolute",
"path",
"."
] | cb7ed0199cca2c405af9d6d209ddbf739a437e9c | https://github.com/willkg/phil/blob/cb7ed0199cca2c405af9d6d209ddbf739a437e9c/phil/util.py#L49-L63 |
239,399 | willkg/phil | phil/util.py | err | def err(*output, **kwargs):
"""Writes output to stderr.
:arg wrap: If you set ``wrap=False``, then ``err`` won't textwrap
the output.
"""
output = 'Error: ' + ' '.join([str(o) for o in output])
if kwargs.get('wrap') is not False:
output = '\n'.join(wrap(output, kwargs.get('indent',... | python | def err(*output, **kwargs):
"""Writes output to stderr.
:arg wrap: If you set ``wrap=False``, then ``err`` won't textwrap
the output.
"""
output = 'Error: ' + ' '.join([str(o) for o in output])
if kwargs.get('wrap') is not False:
output = '\n'.join(wrap(output, kwargs.get('indent',... | [
"def",
"err",
"(",
"*",
"output",
",",
"*",
"*",
"kwargs",
")",
":",
"output",
"=",
"'Error: '",
"+",
"' '",
".",
"join",
"(",
"[",
"str",
"(",
"o",
")",
"for",
"o",
"in",
"output",
"]",
")",
"if",
"kwargs",
".",
"get",
"(",
"'wrap'",
")",
"i... | Writes output to stderr.
:arg wrap: If you set ``wrap=False``, then ``err`` won't textwrap
the output. | [
"Writes",
"output",
"to",
"stderr",
"."
] | cb7ed0199cca2c405af9d6d209ddbf739a437e9c | https://github.com/willkg/phil/blob/cb7ed0199cca2c405af9d6d209ddbf739a437e9c/phil/util.py#L77-L90 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.