repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
rfverbruggen/rachiopy | rachiopy/__init__.py | Rachio._request | def _request(self, path, method, body=None):
"""Make a request from the API."""
url = '/'.join([_SERVER, path])
(resp, content) = _HTTP.request(url, method,
headers=self._headers, body=body)
content_type = resp.get('content-type')
if conte... | python | def _request(self, path, method, body=None):
"""Make a request from the API."""
url = '/'.join([_SERVER, path])
(resp, content) = _HTTP.request(url, method,
headers=self._headers, body=body)
content_type = resp.get('content-type')
if conte... | [
"def",
"_request",
"(",
"self",
",",
"path",
",",
"method",
",",
"body",
"=",
"None",
")",
":",
"url",
"=",
"'/'",
".",
"join",
"(",
"[",
"_SERVER",
",",
"path",
"]",
")",
"(",
"resp",
",",
"content",
")",
"=",
"_HTTP",
".",
"request",
"(",
"ur... | Make a request from the API. | [
"Make",
"a",
"request",
"from",
"the",
"API",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/__init__.py#L32-L42 | train | Make a request from the API. |
rfverbruggen/rachiopy | rachiopy/__init__.py | Rachio.put | def put(self, path, payload):
"""Make a PUT request from the API."""
body = json.dumps(payload)
return self._request(path, 'PUT', body) | python | def put(self, path, payload):
"""Make a PUT request from the API."""
body = json.dumps(payload)
return self._request(path, 'PUT', body) | [
"def",
"put",
"(",
"self",
",",
"path",
",",
"payload",
")",
":",
"body",
"=",
"json",
".",
"dumps",
"(",
"payload",
")",
"return",
"self",
".",
"_request",
"(",
"path",
",",
"'PUT'",
",",
"body",
")"
] | Make a PUT request from the API. | [
"Make",
"a",
"PUT",
"request",
"from",
"the",
"API",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/__init__.py#L52-L55 | train | Make a PUT request from the API. |
rfverbruggen/rachiopy | rachiopy/__init__.py | Rachio.post | def post(self, path, payload):
"""Make a POST request from the API."""
body = json.dumps(payload)
return self._request(path, 'POST', body) | python | def post(self, path, payload):
"""Make a POST request from the API."""
body = json.dumps(payload)
return self._request(path, 'POST', body) | [
"def",
"post",
"(",
"self",
",",
"path",
",",
"payload",
")",
":",
"body",
"=",
"json",
".",
"dumps",
"(",
"payload",
")",
"return",
"self",
".",
"_request",
"(",
"path",
",",
"'POST'",
",",
"body",
")"
] | Make a POST request from the API. | [
"Make",
"a",
"POST",
"request",
"from",
"the",
"API",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/__init__.py#L57-L60 | train | Make a POST request from the API. |
dstanek/snake-guice | snakeguice/injector.py | Injector.create_child | def create_child(self, modules):
"""Create a new injector that inherits the state from this injector.
All bindings are inherited. In the future this may become closer to
child injectors on google-guice.
"""
binder = self._binder.create_child()
return Injector(modules, bi... | python | def create_child(self, modules):
"""Create a new injector that inherits the state from this injector.
All bindings are inherited. In the future this may become closer to
child injectors on google-guice.
"""
binder = self._binder.create_child()
return Injector(modules, bi... | [
"def",
"create_child",
"(",
"self",
",",
"modules",
")",
":",
"binder",
"=",
"self",
".",
"_binder",
".",
"create_child",
"(",
")",
"return",
"Injector",
"(",
"modules",
",",
"binder",
"=",
"binder",
",",
"stage",
"=",
"self",
".",
"_stage",
")"
] | Create a new injector that inherits the state from this injector.
All bindings are inherited. In the future this may become closer to
child injectors on google-guice. | [
"Create",
"a",
"new",
"injector",
"that",
"inherits",
"the",
"state",
"from",
"this",
"injector",
"."
] | d20b62de3ee31e84119c801756398c35ed803fb3 | https://github.com/dstanek/snake-guice/blob/d20b62de3ee31e84119c801756398c35ed803fb3/snakeguice/injector.py#L92-L99 | train | Create a new injector that inherits the state from this injector. |
fabaff/python-luftdaten | luftdaten/__init__.py | Luftdaten.get_data | async def get_data(self):
"""Retrieve the data."""
try:
with async_timeout.timeout(5, loop=self._loop):
response = await self._session.get(
'{}/{}/'.format(self.url, self.sensor_id))
_LOGGER.debug(
"Response from luftdaten.info... | python | async def get_data(self):
"""Retrieve the data."""
try:
with async_timeout.timeout(5, loop=self._loop):
response = await self._session.get(
'{}/{}/'.format(self.url, self.sensor_id))
_LOGGER.debug(
"Response from luftdaten.info... | [
"async",
"def",
"get_data",
"(",
"self",
")",
":",
"try",
":",
"with",
"async_timeout",
".",
"timeout",
"(",
"5",
",",
"loop",
"=",
"self",
".",
"_loop",
")",
":",
"response",
"=",
"await",
"self",
".",
"_session",
".",
"get",
"(",
"'{}/{}/'",
".",
... | Retrieve the data. | [
"Retrieve",
"the",
"data",
"."
] | 30be973257fccb19baa8dbd55206da00f62dc81c | https://github.com/fabaff/python-luftdaten/blob/30be973257fccb19baa8dbd55206da00f62dc81c/luftdaten/__init__.py#L30-L65 | train | Retrieve the data from the Luftdaten. |
spotify/gordon-gcp | src/gordon_gcp/schema/validate.py | MessageValidator.validate | def validate(self, message, schema_name):
"""Validate a message given a schema.
Args:
message (dict): Loaded JSON of pulled message from Google
PubSub.
schema_name (str): Name of schema to validate ``message``
against. ``schema_name`` will be used... | python | def validate(self, message, schema_name):
"""Validate a message given a schema.
Args:
message (dict): Loaded JSON of pulled message from Google
PubSub.
schema_name (str): Name of schema to validate ``message``
against. ``schema_name`` will be used... | [
"def",
"validate",
"(",
"self",
",",
"message",
",",
"schema_name",
")",
":",
"err",
"=",
"None",
"try",
":",
"jsonschema",
".",
"validate",
"(",
"message",
",",
"self",
".",
"schemas",
"[",
"schema_name",
"]",
")",
"except",
"KeyError",
":",
"msg",
"=... | Validate a message given a schema.
Args:
message (dict): Loaded JSON of pulled message from Google
PubSub.
schema_name (str): Name of schema to validate ``message``
against. ``schema_name`` will be used to look up
schema from :py:attr:`.Me... | [
"Validate",
"a",
"message",
"given",
"a",
"schema",
"."
] | 5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da | https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/schema/validate.py#L111-L141 | train | Validate a message given a schema. |
fabianvf/schema-transformer | schema_transformer/helpers.py | compose | def compose(*functions):
''' evaluates functions from right to left.
>>> add = lambda x, y: x + y
>>> add3 = lambda x: x + 3
>>> divide2 = lambda x: x/2
>>> subtract4 = lambda x: x - 4
>>> subtract1 = compose(add3, subtract4)
>>> subtract1(1)
0
>>> co... | python | def compose(*functions):
''' evaluates functions from right to left.
>>> add = lambda x, y: x + y
>>> add3 = lambda x: x + 3
>>> divide2 = lambda x: x/2
>>> subtract4 = lambda x: x - 4
>>> subtract1 = compose(add3, subtract4)
>>> subtract1(1)
0
>>> co... | [
"def",
"compose",
"(",
"*",
"functions",
")",
":",
"def",
"inner",
"(",
"func1",
",",
"func2",
")",
":",
"return",
"lambda",
"*",
"x",
",",
"*",
"*",
"y",
":",
"func1",
"(",
"func2",
"(",
"*",
"x",
",",
"*",
"*",
"y",
")",
")",
"return",
"fun... | evaluates functions from right to left.
>>> add = lambda x, y: x + y
>>> add3 = lambda x: x + 3
>>> divide2 = lambda x: x/2
>>> subtract4 = lambda x: x - 4
>>> subtract1 = compose(add3, subtract4)
>>> subtract1(1)
0
>>> compose(subtract1, add3)(4)
... | [
"evaluates",
"functions",
"from",
"right",
"to",
"left",
"."
] | 1ddce4f7615de71593a1adabee4dbfc4ae086433 | https://github.com/fabianvf/schema-transformer/blob/1ddce4f7615de71593a1adabee4dbfc4ae086433/schema_transformer/helpers.py#L19-L40 | train | evaluates functions from right to left. |
fabianvf/schema-transformer | schema_transformer/helpers.py | updated_schema | def updated_schema(old, new):
''' Creates a dictionary resulting from adding all keys/values of the second to the first
The second dictionary will overwrite the first.
>>> old, new = {'name': 'ric', 'job': None}, {'name': 'Rick'}
>>> updated = updated_schema(old, new)
>>> len(update... | python | def updated_schema(old, new):
''' Creates a dictionary resulting from adding all keys/values of the second to the first
The second dictionary will overwrite the first.
>>> old, new = {'name': 'ric', 'job': None}, {'name': 'Rick'}
>>> updated = updated_schema(old, new)
>>> len(update... | [
"def",
"updated_schema",
"(",
"old",
",",
"new",
")",
":",
"d",
"=",
"deepcopy",
"(",
"old",
")",
"for",
"key",
",",
"value",
"in",
"new",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
"and",
"old",
".",
"get",
... | Creates a dictionary resulting from adding all keys/values of the second to the first
The second dictionary will overwrite the first.
>>> old, new = {'name': 'ric', 'job': None}, {'name': 'Rick'}
>>> updated = updated_schema(old, new)
>>> len(updated.keys())
2
>>> print(... | [
"Creates",
"a",
"dictionary",
"resulting",
"from",
"adding",
"all",
"keys",
"/",
"values",
"of",
"the",
"second",
"to",
"the",
"first",
"The",
"second",
"dictionary",
"will",
"overwrite",
"the",
"first",
"."
] | 1ddce4f7615de71593a1adabee4dbfc4ae086433 | https://github.com/fabianvf/schema-transformer/blob/1ddce4f7615de71593a1adabee4dbfc4ae086433/schema_transformer/helpers.py#L43-L63 | train | Returns a dictionary resulting from adding all keys and values of the second to the first
CTYPE |
openvax/mhcnames | mhcnames/mouse.py | parse_mouse_allele_name | def parse_mouse_allele_name(name):
"""Parses mouse MHc alleles such as H2-Kd, H-2-Db, H2-IAb.
Returns pair of (gene, allele_code).
"""
original = name
if name.upper().startswith("H2"):
name = name[2:]
elif name.upper().startswith("H-2"):
name = name[3:]
_, name = parse_separa... | python | def parse_mouse_allele_name(name):
"""Parses mouse MHc alleles such as H2-Kd, H-2-Db, H2-IAb.
Returns pair of (gene, allele_code).
"""
original = name
if name.upper().startswith("H2"):
name = name[2:]
elif name.upper().startswith("H-2"):
name = name[3:]
_, name = parse_separa... | [
"def",
"parse_mouse_allele_name",
"(",
"name",
")",
":",
"original",
"=",
"name",
"if",
"name",
".",
"upper",
"(",
")",
".",
"startswith",
"(",
"\"H2\"",
")",
":",
"name",
"=",
"name",
"[",
"2",
":",
"]",
"elif",
"name",
".",
"upper",
"(",
")",
"."... | Parses mouse MHc alleles such as H2-Kd, H-2-Db, H2-IAb.
Returns pair of (gene, allele_code). | [
"Parses",
"mouse",
"MHc",
"alleles",
"such",
"as",
"H2",
"-",
"Kd",
"H",
"-",
"2",
"-",
"Db",
"H2",
"-",
"IAb",
".",
"Returns",
"pair",
"of",
"(",
"gene",
"allele_code",
")",
"."
] | 71694b9d620db68ceee44da1b8422ff436f15bd3 | https://github.com/openvax/mhcnames/blob/71694b9d620db68ceee44da1b8422ff436f15bd3/mhcnames/mouse.py#L21-L52 | train | Parses a mouse MHC allele name into a gene and allele code pair. |
indietyp/django-automated-logging | automated_logging/signals/__init__.py | validate_instance | def validate_instance(instance):
"""Validating if the instance should be logged, or is excluded"""
excludes = settings.AUTOMATED_LOGGING['exclude']['model']
for excluded in excludes:
if (excluded in [instance._meta.app_label.lower(),
instance.__class__.__name__.lower()] or
... | python | def validate_instance(instance):
"""Validating if the instance should be logged, or is excluded"""
excludes = settings.AUTOMATED_LOGGING['exclude']['model']
for excluded in excludes:
if (excluded in [instance._meta.app_label.lower(),
instance.__class__.__name__.lower()] or
... | [
"def",
"validate_instance",
"(",
"instance",
")",
":",
"excludes",
"=",
"settings",
".",
"AUTOMATED_LOGGING",
"[",
"'exclude'",
"]",
"[",
"'model'",
"]",
"for",
"excluded",
"in",
"excludes",
":",
"if",
"(",
"excluded",
"in",
"[",
"instance",
".",
"_meta",
... | Validating if the instance should be logged, or is excluded | [
"Validating",
"if",
"the",
"instance",
"should",
"be",
"logged",
"or",
"is",
"excluded"
] | 095dfc6df62dca45f7db4516bc35e52085d0a01c | https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/__init__.py#L23-L33 | train | Validating if the instance should be logged or is excluded |
indietyp/django-automated-logging | automated_logging/signals/__init__.py | get_current_user | def get_current_user():
"""Get current user object from middleware"""
thread_local = AutomatedLoggingMiddleware.thread_local
if hasattr(thread_local, 'current_user'):
user = thread_local.current_user
if isinstance(user, AnonymousUser):
user = None
else:
user = None
... | python | def get_current_user():
"""Get current user object from middleware"""
thread_local = AutomatedLoggingMiddleware.thread_local
if hasattr(thread_local, 'current_user'):
user = thread_local.current_user
if isinstance(user, AnonymousUser):
user = None
else:
user = None
... | [
"def",
"get_current_user",
"(",
")",
":",
"thread_local",
"=",
"AutomatedLoggingMiddleware",
".",
"thread_local",
"if",
"hasattr",
"(",
"thread_local",
",",
"'current_user'",
")",
":",
"user",
"=",
"thread_local",
".",
"current_user",
"if",
"isinstance",
"(",
"use... | Get current user object from middleware | [
"Get",
"current",
"user",
"object",
"from",
"middleware"
] | 095dfc6df62dca45f7db4516bc35e52085d0a01c | https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/__init__.py#L36-L46 | train | Get current user object from middleware |
indietyp/django-automated-logging | automated_logging/signals/__init__.py | get_current_environ | def get_current_environ():
"""Get current application and path object from middleware"""
thread_local = AutomatedLoggingMiddleware.thread_local
if hasattr(thread_local, 'request_uri'):
request_uri = thread_local.request_uri
else:
request_uri = None
if hasattr(thread_local, 'applicat... | python | def get_current_environ():
"""Get current application and path object from middleware"""
thread_local = AutomatedLoggingMiddleware.thread_local
if hasattr(thread_local, 'request_uri'):
request_uri = thread_local.request_uri
else:
request_uri = None
if hasattr(thread_local, 'applicat... | [
"def",
"get_current_environ",
"(",
")",
":",
"thread_local",
"=",
"AutomatedLoggingMiddleware",
".",
"thread_local",
"if",
"hasattr",
"(",
"thread_local",
",",
"'request_uri'",
")",
":",
"request_uri",
"=",
"thread_local",
".",
"request_uri",
"else",
":",
"request_u... | Get current application and path object from middleware | [
"Get",
"current",
"application",
"and",
"path",
"object",
"from",
"middleware"
] | 095dfc6df62dca45f7db4516bc35e52085d0a01c | https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/__init__.py#L49-L73 | train | Get current application and path object from middleware |
indietyp/django-automated-logging | automated_logging/signals/__init__.py | processor | def processor(status, sender, instance, updated=None, addition=''):
"""
This is the standard logging processor.
This is used to send the log to the handler and to other systems.
"""
logger = logging.getLogger(__name__)
if validate_instance(instance):
user = get_current_user()
ap... | python | def processor(status, sender, instance, updated=None, addition=''):
"""
This is the standard logging processor.
This is used to send the log to the handler and to other systems.
"""
logger = logging.getLogger(__name__)
if validate_instance(instance):
user = get_current_user()
ap... | [
"def",
"processor",
"(",
"status",
",",
"sender",
",",
"instance",
",",
"updated",
"=",
"None",
",",
"addition",
"=",
"''",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"if",
"validate_instance",
"(",
"instance",
")",
":",
... | This is the standard logging processor.
This is used to send the log to the handler and to other systems. | [
"This",
"is",
"the",
"standard",
"logging",
"processor",
"."
] | 095dfc6df62dca45f7db4516bc35e52085d0a01c | https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/__init__.py#L76-L106 | train | This is the standard logging processor. |
bunchesofdonald/django-hermes | hermes/models.py | Category.parents | def parents(self):
""" Returns a list of all the current category's parents."""
parents = []
if self.parent is None:
return []
category = self
while category.parent is not None:
parents.append(category.parent)
category = category.parent
... | python | def parents(self):
""" Returns a list of all the current category's parents."""
parents = []
if self.parent is None:
return []
category = self
while category.parent is not None:
parents.append(category.parent)
category = category.parent
... | [
"def",
"parents",
"(",
"self",
")",
":",
"parents",
"=",
"[",
"]",
"if",
"self",
".",
"parent",
"is",
"None",
":",
"return",
"[",
"]",
"category",
"=",
"self",
"while",
"category",
".",
"parent",
"is",
"not",
"None",
":",
"parents",
".",
"append",
... | Returns a list of all the current category's parents. | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"current",
"category",
"s",
"parents",
"."
] | ff5395a7b5debfd0756aab43db61f7a6cfa06aea | https://github.com/bunchesofdonald/django-hermes/blob/ff5395a7b5debfd0756aab43db61f7a6cfa06aea/hermes/models.py#L72-L84 | train | Returns a list of all the current category s parents. |
bunchesofdonald/django-hermes | hermes/models.py | Category.root_parent | def root_parent(self, category=None):
""" Returns the topmost parent of the current category. """
return next(filter(lambda c: c.is_root, self.hierarchy())) | python | def root_parent(self, category=None):
""" Returns the topmost parent of the current category. """
return next(filter(lambda c: c.is_root, self.hierarchy())) | [
"def",
"root_parent",
"(",
"self",
",",
"category",
"=",
"None",
")",
":",
"return",
"next",
"(",
"filter",
"(",
"lambda",
"c",
":",
"c",
".",
"is_root",
",",
"self",
".",
"hierarchy",
"(",
")",
")",
")"
] | Returns the topmost parent of the current category. | [
"Returns",
"the",
"topmost",
"parent",
"of",
"the",
"current",
"category",
"."
] | ff5395a7b5debfd0756aab43db61f7a6cfa06aea | https://github.com/bunchesofdonald/django-hermes/blob/ff5395a7b5debfd0756aab43db61f7a6cfa06aea/hermes/models.py#L89-L91 | train | Returns the root parent of the current category. |
rohankapoorcom/zm-py | zoneminder/run_state.py | RunState.active | def active(self) -> bool:
"""Indicate if this RunState is currently active."""
states = self._client.get_state(self._state_url)['states']
for state in states:
state = state['State']
if int(state['Id']) == self._state_id:
# yes, the ZM API uses the *string*... | python | def active(self) -> bool:
"""Indicate if this RunState is currently active."""
states = self._client.get_state(self._state_url)['states']
for state in states:
state = state['State']
if int(state['Id']) == self._state_id:
# yes, the ZM API uses the *string*... | [
"def",
"active",
"(",
"self",
")",
"->",
"bool",
":",
"states",
"=",
"self",
".",
"_client",
".",
"get_state",
"(",
"self",
".",
"_state_url",
")",
"[",
"'states'",
"]",
"for",
"state",
"in",
"states",
":",
"state",
"=",
"state",
"[",
"'State'",
"]",... | Indicate if this RunState is currently active. | [
"Indicate",
"if",
"this",
"RunState",
"is",
"currently",
"active",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/run_state.py#L26-L34 | train | Indicate if this RunState is currently active. |
mgk/urwid_timed_progress | urwid_timed_progress/__init__.py | to_reasonable_unit | def to_reasonable_unit(value, units, round_digits=2):
"""Convert a value to the most reasonable unit.
The most reasonable unit is roughly the one with the smallest exponent
absolute value when written in scientific notation. For example
`1.5` is more reasonable that `.0015` and `22` is more reasonable
... | python | def to_reasonable_unit(value, units, round_digits=2):
"""Convert a value to the most reasonable unit.
The most reasonable unit is roughly the one with the smallest exponent
absolute value when written in scientific notation. For example
`1.5` is more reasonable that `.0015` and `22` is more reasonable
... | [
"def",
"to_reasonable_unit",
"(",
"value",
",",
"units",
",",
"round_digits",
"=",
"2",
")",
":",
"def",
"to_unit",
"(",
"unit",
")",
":",
"return",
"float",
"(",
"value",
")",
"/",
"unit",
"[",
"1",
"]",
"exponents",
"=",
"[",
"abs",
"(",
"Decimal",... | Convert a value to the most reasonable unit.
The most reasonable unit is roughly the one with the smallest exponent
absolute value when written in scientific notation. For example
`1.5` is more reasonable that `.0015` and `22` is more reasonable
than `22000`. There is a bias towards numbers > 1, so `3.... | [
"Convert",
"a",
"value",
"to",
"the",
"most",
"reasonable",
"unit",
"."
] | b7292e78a58f35f285736988c48e815e71fa2060 | https://github.com/mgk/urwid_timed_progress/blob/b7292e78a58f35f285736988c48e815e71fa2060/urwid_timed_progress/__init__.py#L170-L185 | train | Convert a value to the most reasonable unit. |
mgk/urwid_timed_progress | urwid_timed_progress/__init__.py | FancyProgressBar.get_text | def get_text(self):
"""Return extended progress bar text"""
done_units = to_reasonable_unit(self.done, self.units)
current = round(self.current / done_units['multiplier'], 2)
percent = int(self.current * 100 / self.done)
return '{0:.2f} of {1:.2f} {2} ({3}%)'.format(current,
... | python | def get_text(self):
"""Return extended progress bar text"""
done_units = to_reasonable_unit(self.done, self.units)
current = round(self.current / done_units['multiplier'], 2)
percent = int(self.current * 100 / self.done)
return '{0:.2f} of {1:.2f} {2} ({3}%)'.format(current,
... | [
"def",
"get_text",
"(",
"self",
")",
":",
"done_units",
"=",
"to_reasonable_unit",
"(",
"self",
".",
"done",
",",
"self",
".",
"units",
")",
"current",
"=",
"round",
"(",
"self",
".",
"current",
"/",
"done_units",
"[",
"'multiplier'",
"]",
",",
"2",
")... | Return extended progress bar text | [
"Return",
"extended",
"progress",
"bar",
"text"
] | b7292e78a58f35f285736988c48e815e71fa2060 | https://github.com/mgk/urwid_timed_progress/blob/b7292e78a58f35f285736988c48e815e71fa2060/urwid_timed_progress/__init__.py#L19-L27 | train | Return extended progress bar text |
mgk/urwid_timed_progress | urwid_timed_progress/__init__.py | TimedProgressBar.add_progress | def add_progress(self, delta, done=None):
"""Add to the current progress amount
Add `delta` to the current progress amount. This also updates
:attr:`rate` and :attr:`remaining_time`.
The :attr:`current` progress is never less than 0 or greater
than :attr:`done`.
:param... | python | def add_progress(self, delta, done=None):
"""Add to the current progress amount
Add `delta` to the current progress amount. This also updates
:attr:`rate` and :attr:`remaining_time`.
The :attr:`current` progress is never less than 0 or greater
than :attr:`done`.
:param... | [
"def",
"add_progress",
"(",
"self",
",",
"delta",
",",
"done",
"=",
"None",
")",
":",
"if",
"done",
"is",
"not",
"None",
":",
"self",
".",
"done",
"=",
"done",
"self",
".",
"bar",
".",
"current",
"=",
"max",
"(",
"min",
"(",
"self",
".",
"done",
... | Add to the current progress amount
Add `delta` to the current progress amount. This also updates
:attr:`rate` and :attr:`remaining_time`.
The :attr:`current` progress is never less than 0 or greater
than :attr:`done`.
:param delta: amount to add, may be negative
:param... | [
"Add",
"to",
"the",
"current",
"progress",
"amount"
] | b7292e78a58f35f285736988c48e815e71fa2060 | https://github.com/mgk/urwid_timed_progress/blob/b7292e78a58f35f285736988c48e815e71fa2060/urwid_timed_progress/__init__.py#L90-L107 | train | Add delta to the current progress amount. |
mgk/urwid_timed_progress | urwid_timed_progress/__init__.py | TimedProgressBar.reset | def reset(self):
"""Set :attr:`current` and restart the progress bar timer."""
self.bar.current = 0
self.start_time = time.time()
self.add_progress(0) | python | def reset(self):
"""Set :attr:`current` and restart the progress bar timer."""
self.bar.current = 0
self.start_time = time.time()
self.add_progress(0) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"bar",
".",
"current",
"=",
"0",
"self",
".",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"add_progress",
"(",
"0",
")"
] | Set :attr:`current` and restart the progress bar timer. | [
"Set",
":",
"attr",
":",
"current",
"and",
"restart",
"the",
"progress",
"bar",
"timer",
"."
] | b7292e78a58f35f285736988c48e815e71fa2060 | https://github.com/mgk/urwid_timed_progress/blob/b7292e78a58f35f285736988c48e815e71fa2060/urwid_timed_progress/__init__.py#L109-L113 | train | Reset the current value and restart the progress bar timer. |
mgk/urwid_timed_progress | urwid_timed_progress/__init__.py | TimedProgressBar.remaining_time | def remaining_time(self):
"""remaining time (as a timedelta) until complete at current rate"""
if self.rate == 0:
return None
else:
remaining_progress = self.done - self.current
if self.rate == 0:
if self.done == 0:
return 0... | python | def remaining_time(self):
"""remaining time (as a timedelta) until complete at current rate"""
if self.rate == 0:
return None
else:
remaining_progress = self.done - self.current
if self.rate == 0:
if self.done == 0:
return 0... | [
"def",
"remaining_time",
"(",
"self",
")",
":",
"if",
"self",
".",
"rate",
"==",
"0",
":",
"return",
"None",
"else",
":",
"remaining_progress",
"=",
"self",
".",
"done",
"-",
"self",
".",
"current",
"if",
"self",
".",
"rate",
"==",
"0",
":",
"if",
... | remaining time (as a timedelta) until complete at current rate | [
"remaining",
"time",
"(",
"as",
"a",
"timedelta",
")",
"until",
"complete",
"at",
"current",
"rate"
] | b7292e78a58f35f285736988c48e815e71fa2060 | https://github.com/mgk/urwid_timed_progress/blob/b7292e78a58f35f285736988c48e815e71fa2060/urwid_timed_progress/__init__.py#L148-L160 | train | remaining time until complete at current rate |
F483/btctxstore | btctxstore/control.py | _recover_public_key | def _recover_public_key(G, order, r, s, i, e):
"""Recover a public key from a signature.
See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
Key Recovery Operation".
http://www.secg.org/sec1-v2.pdf
"""
c = G.curve()
# 1.1 Let x = r + jn
x = r + (i // 2) * order
# 1.3 po... | python | def _recover_public_key(G, order, r, s, i, e):
"""Recover a public key from a signature.
See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
Key Recovery Operation".
http://www.secg.org/sec1-v2.pdf
"""
c = G.curve()
# 1.1 Let x = r + jn
x = r + (i // 2) * order
# 1.3 po... | [
"def",
"_recover_public_key",
"(",
"G",
",",
"order",
",",
"r",
",",
"s",
",",
"i",
",",
"e",
")",
":",
"c",
"=",
"G",
".",
"curve",
"(",
")",
"# 1.1 Let x = r + jn",
"x",
"=",
"r",
"+",
"(",
"i",
"//",
"2",
")",
"*",
"order",
"# 1.3 point from x... | Recover a public key from a signature.
See SEC 1: Elliptic Curve Cryptography, section 4.1.6, "Public
Key Recovery Operation".
http://www.secg.org/sec1-v2.pdf | [
"Recover",
"a",
"public",
"key",
"from",
"a",
"signature",
".",
"See",
"SEC",
"1",
":",
"Elliptic",
"Curve",
"Cryptography",
"section",
"4",
".",
"1",
".",
"6",
"Public",
"Key",
"Recovery",
"Operation",
".",
"http",
":",
"//",
"www",
".",
"secg",
".",
... | 5790ace3a3d4c9bcc759e7c931fc4a57d40b6c25 | https://github.com/F483/btctxstore/blob/5790ace3a3d4c9bcc759e7c931fc4a57d40b6c25/btctxstore/control.py#L303-L328 | train | Recover a public key from a signature. |
spotify/gordon-gcp | src/gordon_gcp/clients/http.py | AIOConnection.valid_token_set | async def valid_token_set(self):
"""Check for validity of token, and refresh if none or expired."""
is_valid = False
if self._auth_client.token:
# Account for a token near expiration
now = datetime.datetime.utcnow()
skew = datetime.timedelta(seconds=60)
... | python | async def valid_token_set(self):
"""Check for validity of token, and refresh if none or expired."""
is_valid = False
if self._auth_client.token:
# Account for a token near expiration
now = datetime.datetime.utcnow()
skew = datetime.timedelta(seconds=60)
... | [
"async",
"def",
"valid_token_set",
"(",
"self",
")",
":",
"is_valid",
"=",
"False",
"if",
"self",
".",
"_auth_client",
".",
"token",
":",
"# Account for a token near expiration",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"skew",
"=",
... | Check for validity of token, and refresh if none or expired. | [
"Check",
"for",
"validity",
"of",
"token",
"and",
"refresh",
"if",
"none",
"or",
"expired",
"."
] | 5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da | https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/http.py#L72-L82 | train | Check if the token is valid and refresh if none or expired. |
spotify/gordon-gcp | src/gordon_gcp/clients/http.py | AIOConnection.request | async def request(self, method, url, params=None, headers=None,
data=None, json=None, token_refresh_attempts=2,
**kwargs):
"""Make an asynchronous HTTP request.
Args:
method (str): HTTP method to use for the request.
url (str): URL to ... | python | async def request(self, method, url, params=None, headers=None,
data=None, json=None, token_refresh_attempts=2,
**kwargs):
"""Make an asynchronous HTTP request.
Args:
method (str): HTTP method to use for the request.
url (str): URL to ... | [
"async",
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"token_refresh_attempts",
"=",
"2",
",",
"*",
"*",
"kwargs",
")",
"... | Make an asynchronous HTTP request.
Args:
method (str): HTTP method to use for the request.
url (str): URL to be requested.
params (dict): (optional) Query parameters for the request.
Defaults to ``None``.
headers (dict): (optional) HTTP headers to... | [
"Make",
"an",
"asynchronous",
"HTTP",
"request",
"."
] | 5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da | https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/http.py#L84-L189 | train | Makes an asynchronous HTTP request to the specified URL. |
spotify/gordon-gcp | src/gordon_gcp/clients/http.py | AIOConnection.get_json | async def get_json(self, url, json_callback=None, **kwargs):
"""Get a URL and return its JSON response.
Args:
url (str): URL to be requested.
json_callback (func): Custom JSON loader function. Defaults
to :meth:`json.loads`.
kwargs (dict): Additional ... | python | async def get_json(self, url, json_callback=None, **kwargs):
"""Get a URL and return its JSON response.
Args:
url (str): URL to be requested.
json_callback (func): Custom JSON loader function. Defaults
to :meth:`json.loads`.
kwargs (dict): Additional ... | [
"async",
"def",
"get_json",
"(",
"self",
",",
"url",
",",
"json_callback",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"json_callback",
":",
"json_callback",
"=",
"json",
".",
"loads",
"response",
"=",
"await",
"self",
".",
"request",
... | Get a URL and return its JSON response.
Args:
url (str): URL to be requested.
json_callback (func): Custom JSON loader function. Defaults
to :meth:`json.loads`.
kwargs (dict): Additional arguments to pass through to the
request.
Return... | [
"Get",
"a",
"URL",
"and",
"return",
"its",
"JSON",
"response",
"."
] | 5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da | https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/http.py#L191-L206 | train | Get a URL and return its JSON response. |
spotify/gordon-gcp | src/gordon_gcp/clients/http.py | AIOConnection.get_all | async def get_all(self, url, params=None):
"""Aggregate data from all pages of an API query.
Args:
url (str): Google API endpoint URL.
params (dict): (optional) URL query parameters.
Returns:
list: Parsed JSON query response results.
"""
if n... | python | async def get_all(self, url, params=None):
"""Aggregate data from all pages of an API query.
Args:
url (str): Google API endpoint URL.
params (dict): (optional) URL query parameters.
Returns:
list: Parsed JSON query response results.
"""
if n... | [
"async",
"def",
"get_all",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
")",
":",
"if",
"not",
"params",
":",
"params",
"=",
"{",
"}",
"items",
"=",
"[",
"]",
"next_page_token",
"=",
"None",
"while",
"True",
":",
"if",
"next_page_token",
":",... | Aggregate data from all pages of an API query.
Args:
url (str): Google API endpoint URL.
params (dict): (optional) URL query parameters.
Returns:
list: Parsed JSON query response results. | [
"Aggregate",
"data",
"from",
"all",
"pages",
"of",
"an",
"API",
"query",
"."
] | 5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da | https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/http.py#L208-L232 | train | Aggregate data from all pages of an API endpoint URL. |
gitenberg-dev/gitberg | gitenberg/config.py | check_config | def check_config():
""" Report if there is an existing config file
"""
configfile = ConfigFile()
global data
if data.keys() > 0:
# FIXME: run a better check of this file
print("gitberg config file exists")
print("\twould you like to edit your gitberg config file?")
else:
... | python | def check_config():
""" Report if there is an existing config file
"""
configfile = ConfigFile()
global data
if data.keys() > 0:
# FIXME: run a better check of this file
print("gitberg config file exists")
print("\twould you like to edit your gitberg config file?")
else:
... | [
"def",
"check_config",
"(",
")",
":",
"configfile",
"=",
"ConfigFile",
"(",
")",
"global",
"data",
"if",
"data",
".",
"keys",
"(",
")",
">",
"0",
":",
"# FIXME: run a better check of this file",
"print",
"(",
"\"gitberg config file exists\"",
")",
"print",
"(",
... | Report if there is an existing config file | [
"Report",
"if",
"there",
"is",
"an",
"existing",
"config",
"file"
] | 3f6db8b5a22ccdd2110d3199223c30db4e558b5c | https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/config.py#L94-L122 | train | Report if there is an existing config file |
fabaff/python-luftdaten | example.py | main | async def main():
"""Sample code to retrieve the data."""
async with aiohttp.ClientSession() as session:
data = Luftdaten(SENSOR_ID, loop, session)
await data.get_data()
if not await data.validate_sensor():
print("Station is not available:", data.sensor_id)
retur... | python | async def main():
"""Sample code to retrieve the data."""
async with aiohttp.ClientSession() as session:
data = Luftdaten(SENSOR_ID, loop, session)
await data.get_data()
if not await data.validate_sensor():
print("Station is not available:", data.sensor_id)
retur... | [
"async",
"def",
"main",
"(",
")",
":",
"async",
"with",
"aiohttp",
".",
"ClientSession",
"(",
")",
"as",
"session",
":",
"data",
"=",
"Luftdaten",
"(",
"SENSOR_ID",
",",
"loop",
",",
"session",
")",
"await",
"data",
".",
"get_data",
"(",
")",
"if",
"... | Sample code to retrieve the data. | [
"Sample",
"code",
"to",
"retrieve",
"the",
"data",
"."
] | 30be973257fccb19baa8dbd55206da00f62dc81c | https://github.com/fabaff/python-luftdaten/blob/30be973257fccb19baa8dbd55206da00f62dc81c/example.py#L11-L26 | train | Sample code to retrieve the data. |
xlzd/xtls | xtls/timeparser.py | _build_str_from_chinese | def _build_str_from_chinese(chinese_items):
"""
根据解析出的中文时间字符串的关键字返回对应的标准格式字符串
"""
year, month, day = chinese_items
year = reduce(lambda a, b: a*10+b, map(CHINESE_NUMS.find, year))
return '%04d-%02d-%02d 00:00:00' % (year, _parse_chinese_field(month), _parse_chinese_field(day)) | python | def _build_str_from_chinese(chinese_items):
"""
根据解析出的中文时间字符串的关键字返回对应的标准格式字符串
"""
year, month, day = chinese_items
year = reduce(lambda a, b: a*10+b, map(CHINESE_NUMS.find, year))
return '%04d-%02d-%02d 00:00:00' % (year, _parse_chinese_field(month), _parse_chinese_field(day)) | [
"def",
"_build_str_from_chinese",
"(",
"chinese_items",
")",
":",
"year",
",",
"month",
",",
"day",
"=",
"chinese_items",
"year",
"=",
"reduce",
"(",
"lambda",
"a",
",",
"b",
":",
"a",
"*",
"10",
"+",
"b",
",",
"map",
"(",
"CHINESE_NUMS",
".",
"find",
... | 根据解析出的中文时间字符串的关键字返回对应的标准格式字符串 | [
"根据解析出的中文时间字符串的关键字返回对应的标准格式字符串"
] | b3cc0ab24197ecaa39adcad7cd828cada9c04a4e | https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/timeparser.py#L48-L54 | train | Build a string from a list of chinese items. |
xlzd/xtls | xtls/timeparser.py | _build_str_from_expression | def _build_str_from_expression(exp_items):
"""
根据解析出的时间表达式的关键字计算对应的表达式值
:return: 表达式对应时间的标准时间格式字符串表示形式
"""
time_delta_base, unit, method = exp_items
if unit not in _KEY_TIME_MAPPING:
return None
delta = datetime.timedelta(seconds=int(time_delta_base) * _KEY_TIME_MAPPING[unit])
no... | python | def _build_str_from_expression(exp_items):
"""
根据解析出的时间表达式的关键字计算对应的表达式值
:return: 表达式对应时间的标准时间格式字符串表示形式
"""
time_delta_base, unit, method = exp_items
if unit not in _KEY_TIME_MAPPING:
return None
delta = datetime.timedelta(seconds=int(time_delta_base) * _KEY_TIME_MAPPING[unit])
no... | [
"def",
"_build_str_from_expression",
"(",
"exp_items",
")",
":",
"time_delta_base",
",",
"unit",
",",
"method",
"=",
"exp_items",
"if",
"unit",
"not",
"in",
"_KEY_TIME_MAPPING",
":",
"return",
"None",
"delta",
"=",
"datetime",
".",
"timedelta",
"(",
"seconds",
... | 根据解析出的时间表达式的关键字计算对应的表达式值
:return: 表达式对应时间的标准时间格式字符串表示形式 | [
"根据解析出的时间表达式的关键字计算对应的表达式值",
":",
"return",
":",
"表达式对应时间的标准时间格式字符串表示形式"
] | b3cc0ab24197ecaa39adcad7cd828cada9c04a4e | https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/timeparser.py#L57-L67 | train | Build a string from an expression. |
xlzd/xtls | xtls/timeparser.py | _build_str_from_time_items | def _build_str_from_time_items(items):
"""
根据解析出的时间字符串关键字计算标准时间表示格式的字符串
:return: 标准时间格式字符串表示形式
"""
if not items:
return None
items = [int(item) for item in items if item]
items = items + [0 for _ in xrange(6-len(items))]
return '%d-%02d-%02d %02d:%02d:%02d' % (items[0], items[1],... | python | def _build_str_from_time_items(items):
"""
根据解析出的时间字符串关键字计算标准时间表示格式的字符串
:return: 标准时间格式字符串表示形式
"""
if not items:
return None
items = [int(item) for item in items if item]
items = items + [0 for _ in xrange(6-len(items))]
return '%d-%02d-%02d %02d:%02d:%02d' % (items[0], items[1],... | [
"def",
"_build_str_from_time_items",
"(",
"items",
")",
":",
"if",
"not",
"items",
":",
"return",
"None",
"items",
"=",
"[",
"int",
"(",
"item",
")",
"for",
"item",
"in",
"items",
"if",
"item",
"]",
"items",
"=",
"items",
"+",
"[",
"0",
"for",
"_",
... | 根据解析出的时间字符串关键字计算标准时间表示格式的字符串
:return: 标准时间格式字符串表示形式 | [
"根据解析出的时间字符串关键字计算标准时间表示格式的字符串",
":",
"return",
":",
"标准时间格式字符串表示形式"
] | b3cc0ab24197ecaa39adcad7cd828cada9c04a4e | https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/timeparser.py#L70-L79 | train | Build a string from a list of time items. |
xlzd/xtls | xtls/timeparser.py | parse_time | def parse_time(time_str, iso_time_obj=False):
"""
解析出一个字符串中包含的(第一个)时间,并转换为时间对象或者字符串表现形式
:param time_str: 时间字符串 (eg. "2012年7月9日", "2012-03-01", "2016.05.1 12:11:11", "5小时以前","5天后")
:param iso_time_obj: True => 转换为对象 | False => 转换为字符串 | default value: False
:return: datetime object or time string
... | python | def parse_time(time_str, iso_time_obj=False):
"""
解析出一个字符串中包含的(第一个)时间,并转换为时间对象或者字符串表现形式
:param time_str: 时间字符串 (eg. "2012年7月9日", "2012-03-01", "2016.05.1 12:11:11", "5小时以前","5天后")
:param iso_time_obj: True => 转换为对象 | False => 转换为字符串 | default value: False
:return: datetime object or time string
... | [
"def",
"parse_time",
"(",
"time_str",
",",
"iso_time_obj",
"=",
"False",
")",
":",
"time_str",
"=",
"_parse_time",
"(",
"time_str",
")",
"if",
"not",
"time_str",
":",
"return",
"\"\"",
"if",
"iso_time_obj",
":",
"return",
"datetime",
".",
"datetime",
".",
... | 解析出一个字符串中包含的(第一个)时间,并转换为时间对象或者字符串表现形式
:param time_str: 时间字符串 (eg. "2012年7月9日", "2012-03-01", "2016.05.1 12:11:11", "5小时以前","5天后")
:param iso_time_obj: True => 转换为对象 | False => 转换为字符串 | default value: False
:return: datetime object or time string | [
"解析出一个字符串中包含的(第一个)时间,并转换为时间对象或者字符串表现形式",
":",
"param",
"time_str",
":",
"时间字符串",
"(eg",
".",
"2012年7月9日",
",",
"2012",
"-",
"03",
"-",
"01",
",",
"2016",
".",
"05",
".",
"1",
"12",
":",
"11",
":",
"11",
",",
"5小时以前",
",",
"5天后",
")",
":",
"param",
"i... | b3cc0ab24197ecaa39adcad7cd828cada9c04a4e | https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/timeparser.py#L127-L139 | train | Parse a time string into a datetime object or time string. |
xlzd/xtls | xtls/timeparser.py | now | def now(obj=True, utc=False, precise=False):
"""
得到此刻的时间
"""
t = (datetime.datetime.now(), datetime.datetime.utcnow())[utc]
return (t.strftime(STARDAND_FORMAT + ('', '.%f')[precise]), t)[obj] | python | def now(obj=True, utc=False, precise=False):
"""
得到此刻的时间
"""
t = (datetime.datetime.now(), datetime.datetime.utcnow())[utc]
return (t.strftime(STARDAND_FORMAT + ('', '.%f')[precise]), t)[obj] | [
"def",
"now",
"(",
"obj",
"=",
"True",
",",
"utc",
"=",
"False",
",",
"precise",
"=",
"False",
")",
":",
"t",
"=",
"(",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
",",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
")",
"[",
"utc... | 得到此刻的时间 | [
"得到此刻的时间"
] | b3cc0ab24197ecaa39adcad7cd828cada9c04a4e | https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/timeparser.py#L142-L147 | train | Get the current time. |
spotify/gordon-gcp | src/gordon_gcp/clients/gce.py | GCEClient.list_instances | async def list_instances(self,
project,
page_size=100,
instance_filter=None):
"""Fetch all instances in a GCE project.
You can find the endpoint documentation `here <https://cloud.
google.com/compute/docs/ref... | python | async def list_instances(self,
project,
page_size=100,
instance_filter=None):
"""Fetch all instances in a GCE project.
You can find the endpoint documentation `here <https://cloud.
google.com/compute/docs/ref... | [
"async",
"def",
"list_instances",
"(",
"self",
",",
"project",
",",
"page_size",
"=",
"100",
",",
"instance_filter",
"=",
"None",
")",
":",
"url",
"=",
"(",
"f'{self.BASE_URL}{self.api_version}/projects/{project}'",
"'/aggregated/instances'",
")",
"params",
"=",
"{"... | Fetch all instances in a GCE project.
You can find the endpoint documentation `here <https://cloud.
google.com/compute/docs/reference/latest/instances/
aggregatedList>`__.
Args:
project (str): unique, user-provided project ID.
page_size (int): hint for the clien... | [
"Fetch",
"all",
"instances",
"in",
"a",
"GCE",
"project",
"."
] | 5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da | https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/clients/gce.py#L89-L118 | train | Fetches all instances in a GCE project. |
openvax/mhcnames | mhcnames/class2.py | infer_alpha_chain | def infer_alpha_chain(beta):
"""
Given a parsed beta chain of a class II MHC, infer the most frequent
corresponding alpha chain.
"""
if beta.gene.startswith("DRB"):
return AlleleName(species="HLA", gene="DRA1", allele_family="01", allele_code="01")
elif beta.gene.startswith("DPB"):
... | python | def infer_alpha_chain(beta):
"""
Given a parsed beta chain of a class II MHC, infer the most frequent
corresponding alpha chain.
"""
if beta.gene.startswith("DRB"):
return AlleleName(species="HLA", gene="DRA1", allele_family="01", allele_code="01")
elif beta.gene.startswith("DPB"):
... | [
"def",
"infer_alpha_chain",
"(",
"beta",
")",
":",
"if",
"beta",
".",
"gene",
".",
"startswith",
"(",
"\"DRB\"",
")",
":",
"return",
"AlleleName",
"(",
"species",
"=",
"\"HLA\"",
",",
"gene",
"=",
"\"DRA1\"",
",",
"allele_family",
"=",
"\"01\"",
",",
"al... | Given a parsed beta chain of a class II MHC, infer the most frequent
corresponding alpha chain. | [
"Given",
"a",
"parsed",
"beta",
"chain",
"of",
"a",
"class",
"II",
"MHC",
"infer",
"the",
"most",
"frequent",
"corresponding",
"alpha",
"chain",
"."
] | 71694b9d620db68ceee44da1b8422ff436f15bd3 | https://github.com/openvax/mhcnames/blob/71694b9d620db68ceee44da1b8422ff436f15bd3/mhcnames/class2.py#L21-L39 | train | Infer the most frequent alpha chain for a given beta chain. |
openvax/mhcnames | mhcnames/class2.py | parse_classi_or_classii_allele_name | def parse_classi_or_classii_allele_name(name, infer_pair=True):
"""
Handle different forms of both single and alpha-beta allele names.
Alpha-beta alleles may look like:
DPA10105-DPB110001
HLA-DPA1*01:05-DPB1*100:01
hla-dpa1*0105-dpb1*10001
dpa1*0105-dpb1*10001
HLA-DPA1*01:05/DPB1*100:01... | python | def parse_classi_or_classii_allele_name(name, infer_pair=True):
"""
Handle different forms of both single and alpha-beta allele names.
Alpha-beta alleles may look like:
DPA10105-DPB110001
HLA-DPA1*01:05-DPB1*100:01
hla-dpa1*0105-dpb1*10001
dpa1*0105-dpb1*10001
HLA-DPA1*01:05/DPB1*100:01... | [
"def",
"parse_classi_or_classii_allele_name",
"(",
"name",
",",
"infer_pair",
"=",
"True",
")",
":",
"species",
",",
"name",
"=",
"split_species_prefix",
"(",
"name",
")",
"# Handle the case where alpha/beta pairs are separated with a /.",
"name",
"=",
"name",
".",
"rep... | Handle different forms of both single and alpha-beta allele names.
Alpha-beta alleles may look like:
DPA10105-DPB110001
HLA-DPA1*01:05-DPB1*100:01
hla-dpa1*0105-dpb1*10001
dpa1*0105-dpb1*10001
HLA-DPA1*01:05/DPB1*100:01
Other class II alleles may look like:
DRB1_0102
DRB101:02
... | [
"Handle",
"different",
"forms",
"of",
"both",
"single",
"and",
"alpha",
"-",
"beta",
"allele",
"names",
".",
"Alpha",
"-",
"beta",
"alleles",
"may",
"look",
"like",
":"
] | 71694b9d620db68ceee44da1b8422ff436f15bd3 | https://github.com/openvax/mhcnames/blob/71694b9d620db68ceee44da1b8422ff436f15bd3/mhcnames/class2.py#L42-L83 | train | Parse a single or alpha - beta allele name. |
xlzd/xtls | xtls/mqwrapper.py | consumer | def consumer(cfg_uri, queue, logger=None, fetchsize=1):
"""
分布式爬虫的爬虫端(具体爬虫部分)
被包装的函数必须满足如下要求:
1. 有且仅有一个参数
2. 对于每个任务,返回两个参数: code, message
:param cfg_uri: 读取任务的路径
:param queue: Queue的名字
:param logger: 日志记录工具
:param fetchsize: 每次取出消息数量
"""
from stompest.protocol import S... | python | def consumer(cfg_uri, queue, logger=None, fetchsize=1):
"""
分布式爬虫的爬虫端(具体爬虫部分)
被包装的函数必须满足如下要求:
1. 有且仅有一个参数
2. 对于每个任务,返回两个参数: code, message
:param cfg_uri: 读取任务的路径
:param queue: Queue的名字
:param logger: 日志记录工具
:param fetchsize: 每次取出消息数量
"""
from stompest.protocol import S... | [
"def",
"consumer",
"(",
"cfg_uri",
",",
"queue",
",",
"logger",
"=",
"None",
",",
"fetchsize",
"=",
"1",
")",
":",
"from",
"stompest",
".",
"protocol",
"import",
"StompSpec",
"_info",
",",
"_exception",
"=",
"_deal_logger",
"(",
"logger",
")",
"cfg_uri",
... | 分布式爬虫的爬虫端(具体爬虫部分)
被包装的函数必须满足如下要求:
1. 有且仅有一个参数
2. 对于每个任务,返回两个参数: code, message
:param cfg_uri: 读取任务的路径
:param queue: Queue的名字
:param logger: 日志记录工具
:param fetchsize: 每次取出消息数量 | [
"分布式爬虫的爬虫端(具体爬虫部分)",
"被包装的函数必须满足如下要求:",
"1",
".",
"有且仅有一个参数",
"2",
".",
"对于每个任务,返回两个参数:",
"code",
"message"
] | b3cc0ab24197ecaa39adcad7cd828cada9c04a4e | https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/mqwrapper.py#L45-L97 | train | A consumer function that returns a function that returns a list of messages from a queue. |
xlzd/xtls | xtls/mqwrapper.py | producer | def producer(cfg_uri, queue, logger=None):
"""
分布式爬虫的任务端(将任务加入Queue)
注意:
被包装的函数需要返回一个可迭代的对象
:param cfg_uri: 读取任务的路径
:param queue: Queue的名字
:param logger: 日志记录工具
"""
_info, _exception = _deal_logger(logger)
cfg_uri = _deal_uri(cfg_uri)
def decorator(function):
@... | python | def producer(cfg_uri, queue, logger=None):
"""
分布式爬虫的任务端(将任务加入Queue)
注意:
被包装的函数需要返回一个可迭代的对象
:param cfg_uri: 读取任务的路径
:param queue: Queue的名字
:param logger: 日志记录工具
"""
_info, _exception = _deal_logger(logger)
cfg_uri = _deal_uri(cfg_uri)
def decorator(function):
@... | [
"def",
"producer",
"(",
"cfg_uri",
",",
"queue",
",",
"logger",
"=",
"None",
")",
":",
"_info",
",",
"_exception",
"=",
"_deal_logger",
"(",
"logger",
")",
"cfg_uri",
"=",
"_deal_uri",
"(",
"cfg_uri",
")",
"def",
"decorator",
"(",
"function",
")",
":",
... | 分布式爬虫的任务端(将任务加入Queue)
注意:
被包装的函数需要返回一个可迭代的对象
:param cfg_uri: 读取任务的路径
:param queue: Queue的名字
:param logger: 日志记录工具 | [
"分布式爬虫的任务端(将任务加入Queue)"
] | b3cc0ab24197ecaa39adcad7cd828cada9c04a4e | https://github.com/xlzd/xtls/blob/b3cc0ab24197ecaa39adcad7cd828cada9c04a4e/xtls/mqwrapper.py#L100-L133 | train | Decorator for the producer function. |
ethan-nelson/osm_diff_tool | osmdt/process.py | process | def process(data_stream):
"""
Process a diff file stream into a class with objects separated.
Parameters
----------
data_stream : class
A file-like class containing a decompressed diff file data stream.
Returns
-------
data_object : osc_decoder class
A class containing ... | python | def process(data_stream):
"""
Process a diff file stream into a class with objects separated.
Parameters
----------
data_stream : class
A file-like class containing a decompressed diff file data stream.
Returns
-------
data_object : osc_decoder class
A class containing ... | [
"def",
"process",
"(",
"data_stream",
")",
":",
"import",
"xml",
".",
"etree",
".",
"cElementTree",
"as",
"ElementTree",
"def",
"parse_diff",
"(",
"source",
",",
"handle",
")",
":",
"for",
"event",
",",
"elem",
"in",
"ElementTree",
".",
"iterparse",
"(",
... | Process a diff file stream into a class with objects separated.
Parameters
----------
data_stream : class
A file-like class containing a decompressed diff file data stream.
Returns
-------
data_object : osc_decoder class
A class containing attribute dictionaries for each OpenSt... | [
"Process",
"a",
"diff",
"file",
"stream",
"into",
"a",
"class",
"with",
"objects",
"separated",
"."
] | d5b083100dedd9427ad23c4be5316f89a55ec8f0 | https://github.com/ethan-nelson/osm_diff_tool/blob/d5b083100dedd9427ad23c4be5316f89a55ec8f0/osmdt/process.py#L1-L87 | train | Process a diff file stream into a single object. |
ministryofjustice/django-zendesk-tickets | zendesk_tickets/client.py | create_ticket | def create_ticket(subject, tags, ticket_body, requester_email=None,
custom_fields=[]):
""" Create a new Zendesk ticket """
payload = {'ticket': {
'subject': subject,
'comment': {
'body': ticket_body
},
'group_id': settings.ZENDESK_GROUP_ID,
... | python | def create_ticket(subject, tags, ticket_body, requester_email=None,
custom_fields=[]):
""" Create a new Zendesk ticket """
payload = {'ticket': {
'subject': subject,
'comment': {
'body': ticket_body
},
'group_id': settings.ZENDESK_GROUP_ID,
... | [
"def",
"create_ticket",
"(",
"subject",
",",
"tags",
",",
"ticket_body",
",",
"requester_email",
"=",
"None",
",",
"custom_fields",
"=",
"[",
"]",
")",
":",
"payload",
"=",
"{",
"'ticket'",
":",
"{",
"'subject'",
":",
"subject",
",",
"'comment'",
":",
"{... | Create a new Zendesk ticket | [
"Create",
"a",
"new",
"Zendesk",
"ticket"
] | 8c1332b5536dc1cf967b612aad5d07e02439d280 | https://github.com/ministryofjustice/django-zendesk-tickets/blob/8c1332b5536dc1cf967b612aad5d07e02439d280/zendesk_tickets/client.py#L19-L45 | train | Create a Zendesk ticket |
ponty/psidialogs | psidialogs/__init__.py | message | def message(message, title=''):
"""
Display a message
:ref:`screenshots<message>`
:param message: message to be displayed.
:param title: window title
:rtype: None
"""
return backend_api.opendialog("message", dict(message=message, title=title)) | python | def message(message, title=''):
"""
Display a message
:ref:`screenshots<message>`
:param message: message to be displayed.
:param title: window title
:rtype: None
"""
return backend_api.opendialog("message", dict(message=message, title=title)) | [
"def",
"message",
"(",
"message",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"message\"",
",",
"dict",
"(",
"message",
"=",
"message",
",",
"title",
"=",
"title",
")",
")"
] | Display a message
:ref:`screenshots<message>`
:param message: message to be displayed.
:param title: window title
:rtype: None | [
"Display",
"a",
"message"
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L9-L19 | train | Display a message in the current window. |
ponty/psidialogs | psidialogs/__init__.py | text | def text(text, message='', title=''):
"""
This function is suitable for displaying general text, which can be longer
than in :func:`message`
:ref:`screenshots<text>`
:param text: (long) text to be displayed
:param message: (short) message to be displayed.
:param title: window title
:rt... | python | def text(text, message='', title=''):
"""
This function is suitable for displaying general text, which can be longer
than in :func:`message`
:ref:`screenshots<text>`
:param text: (long) text to be displayed
:param message: (short) message to be displayed.
:param title: window title
:rt... | [
"def",
"text",
"(",
"text",
",",
"message",
"=",
"''",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"text\"",
",",
"dict",
"(",
"text",
"=",
"text",
",",
"message",
"=",
"message",
",",
"title",
"=",
"title",
... | This function is suitable for displaying general text, which can be longer
than in :func:`message`
:ref:`screenshots<text>`
:param text: (long) text to be displayed
:param message: (short) message to be displayed.
:param title: window title
:rtype: None | [
"This",
"function",
"is",
"suitable",
"for",
"displaying",
"general",
"text",
"which",
"can",
"be",
"longer",
"than",
"in",
":",
"func",
":",
"message"
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L48-L60 | train | Display a text window. |
ponty/psidialogs | psidialogs/__init__.py | ask_string | def ask_string(message='Enter something.', default='', title=''):
"""
Show a box in which a user can enter some text.
You may optionally specify some default text, which will appear in the
entry-box when it is displayed.
Returns the text that the user entered, or None if he cancels the operation
... | python | def ask_string(message='Enter something.', default='', title=''):
"""
Show a box in which a user can enter some text.
You may optionally specify some default text, which will appear in the
entry-box when it is displayed.
Returns the text that the user entered, or None if he cancels the operation
... | [
"def",
"ask_string",
"(",
"message",
"=",
"'Enter something.'",
",",
"default",
"=",
"''",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"ask_string\"",
",",
"dict",
"(",
"message",
"=",
"message",
",",
"default",
"=... | Show a box in which a user can enter some text.
You may optionally specify some default text, which will appear in the
entry-box when it is displayed.
Returns the text that the user entered, or None if he cancels the operation
:ref:`screenshots<ask_string>`
:param message: message to be displaye... | [
"Show",
"a",
"box",
"in",
"which",
"a",
"user",
"can",
"enter",
"some",
"text",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L63-L79 | train | Display a dialog with some text. |
ponty/psidialogs | psidialogs/__init__.py | ask_file | def ask_file(message='Select file for open.', default='', title='', save=False):
"""
A dialog to get a file name.
The "default" argument specifies a file path.
save=False -> file for loading
save=True -> file for saving
Return the file path that the user entered, or None if he cancels the oper... | python | def ask_file(message='Select file for open.', default='', title='', save=False):
"""
A dialog to get a file name.
The "default" argument specifies a file path.
save=False -> file for loading
save=True -> file for saving
Return the file path that the user entered, or None if he cancels the oper... | [
"def",
"ask_file",
"(",
"message",
"=",
"'Select file for open.'",
",",
"default",
"=",
"''",
",",
"title",
"=",
"''",
",",
"save",
"=",
"False",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"ask_file\"",
",",
"dict",
"(",
"message",
"=",
... | A dialog to get a file name.
The "default" argument specifies a file path.
save=False -> file for loading
save=True -> file for saving
Return the file path that the user entered, or None if he cancels the operation.
:param message: message to be displayed.
:param save: bool 0 -> load , 1 -> s... | [
"A",
"dialog",
"to",
"get",
"a",
"file",
"name",
".",
"The",
"default",
"argument",
"specifies",
"a",
"file",
"path",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L82-L98 | train | A dialog to get a file name. |
ponty/psidialogs | psidialogs/__init__.py | ask_folder | def ask_folder(message='Select folder.', default='', title=''):
"""
A dialog to get a directory name.
Returns the name of a directory, or None if user chose to cancel.
If the "default" argument specifies a directory name, and that
directory exists, then the dialog box will start with that directory.... | python | def ask_folder(message='Select folder.', default='', title=''):
"""
A dialog to get a directory name.
Returns the name of a directory, or None if user chose to cancel.
If the "default" argument specifies a directory name, and that
directory exists, then the dialog box will start with that directory.... | [
"def",
"ask_folder",
"(",
"message",
"=",
"'Select folder.'",
",",
"default",
"=",
"''",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"ask_folder\"",
",",
"dict",
"(",
"message",
"=",
"message",
",",
"default",
"=",... | A dialog to get a directory name.
Returns the name of a directory, or None if user chose to cancel.
If the "default" argument specifies a directory name, and that
directory exists, then the dialog box will start with that directory.
:param message: message to be displayed.
:param title: window titl... | [
"A",
"dialog",
"to",
"get",
"a",
"directory",
"name",
".",
"Returns",
"the",
"name",
"of",
"a",
"directory",
"or",
"None",
"if",
"user",
"chose",
"to",
"cancel",
".",
"If",
"the",
"default",
"argument",
"specifies",
"a",
"directory",
"name",
"and",
"that... | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L101-L113 | train | A dialog to get a folder name. |
ponty/psidialogs | psidialogs/__init__.py | choice | def choice(choices=[], message='Pick something.', default=None, title=''):
"""
Present the user with a list of choices.
return the choice that he selects.
return None if he cancels the selection selection.
:ref:`screenshots<choice>`
:param choices: a list of the choices to be displayed
:pa... | python | def choice(choices=[], message='Pick something.', default=None, title=''):
"""
Present the user with a list of choices.
return the choice that he selects.
return None if he cancels the selection selection.
:ref:`screenshots<choice>`
:param choices: a list of the choices to be displayed
:pa... | [
"def",
"choice",
"(",
"choices",
"=",
"[",
"]",
",",
"message",
"=",
"'Pick something.'",
",",
"default",
"=",
"None",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"choice\"",
",",
"dict",
"(",
"choices",
"=",
"... | Present the user with a list of choices.
return the choice that he selects.
return None if he cancels the selection selection.
:ref:`screenshots<choice>`
:param choices: a list of the choices to be displayed
:param message: message to be displayed.
:param title: window title
:param default... | [
"Present",
"the",
"user",
"with",
"a",
"list",
"of",
"choices",
".",
"return",
"the",
"choice",
"that",
"he",
"selects",
".",
"return",
"None",
"if",
"he",
"cancels",
"the",
"selection",
"selection",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L116-L130 | train | Display a list of choices. |
ponty/psidialogs | psidialogs/__init__.py | multi_choice | def multi_choice(choices=[], message='Pick as many items as you like.', default=None, title=''):
"""
Present the user with a list of choices.
allow him to select multiple items and return them in a list.
if the user doesn't choose anything from the list, return the empty list.
return None if he canc... | python | def multi_choice(choices=[], message='Pick as many items as you like.', default=None, title=''):
"""
Present the user with a list of choices.
allow him to select multiple items and return them in a list.
if the user doesn't choose anything from the list, return the empty list.
return None if he canc... | [
"def",
"multi_choice",
"(",
"choices",
"=",
"[",
"]",
",",
"message",
"=",
"'Pick as many items as you like.'",
",",
"default",
"=",
"None",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"multi_choice\"",
",",
"dict",
... | Present the user with a list of choices.
allow him to select multiple items and return them in a list.
if the user doesn't choose anything from the list, return the empty list.
return None if he cancelled selection.
:ref:`screenshots<multi_choice>`
:param choices: a list of the choices to be displ... | [
"Present",
"the",
"user",
"with",
"a",
"list",
"of",
"choices",
".",
"allow",
"him",
"to",
"select",
"multiple",
"items",
"and",
"return",
"them",
"in",
"a",
"list",
".",
"if",
"the",
"user",
"doesn",
"t",
"choose",
"anything",
"from",
"the",
"list",
"... | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L133-L148 | train | Display a list of items in a window with a message. |
ponty/psidialogs | psidialogs/__init__.py | ask_ok_cancel | def ask_ok_cancel(message='', default=0, title=''):
"""
Display a message with choices of OK and Cancel.
returned value:
OK -> True
Cancel -> False
:ref:`screenshots<ask_ok_cancel>`
:param message: message to be displayed.
:param title: window title
:param default:... | python | def ask_ok_cancel(message='', default=0, title=''):
"""
Display a message with choices of OK and Cancel.
returned value:
OK -> True
Cancel -> False
:ref:`screenshots<ask_ok_cancel>`
:param message: message to be displayed.
:param title: window title
:param default:... | [
"def",
"ask_ok_cancel",
"(",
"message",
"=",
"''",
",",
"default",
"=",
"0",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"ask_ok_cancel\"",
",",
"dict",
"(",
"message",
"=",
"message",
",",
"default",
"=",
"defau... | Display a message with choices of OK and Cancel.
returned value:
OK -> True
Cancel -> False
:ref:`screenshots<ask_ok_cancel>`
:param message: message to be displayed.
:param title: window title
:param default: default button as boolean (OK=True, Cancel=False)
:rtype: b... | [
"Display",
"a",
"message",
"with",
"choices",
"of",
"OK",
"and",
"Cancel",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L151-L166 | train | Display a message with choices of OK and Cancel. |
ponty/psidialogs | psidialogs/__init__.py | ask_yes_no | def ask_yes_no(message='', default=0, title=''):
"""
Display a message with choices of Yes and No.
returned value:
Yes -> True
No -> False
:ref:`screenshots<ask_yes_no>`
:param message: message to be displayed.
:param title: window title
:param default: default button a... | python | def ask_yes_no(message='', default=0, title=''):
"""
Display a message with choices of Yes and No.
returned value:
Yes -> True
No -> False
:ref:`screenshots<ask_yes_no>`
:param message: message to be displayed.
:param title: window title
:param default: default button a... | [
"def",
"ask_yes_no",
"(",
"message",
"=",
"''",
",",
"default",
"=",
"0",
",",
"title",
"=",
"''",
")",
":",
"return",
"backend_api",
".",
"opendialog",
"(",
"\"ask_yes_no\"",
",",
"dict",
"(",
"message",
"=",
"message",
",",
"default",
"=",
"default",
... | Display a message with choices of Yes and No.
returned value:
Yes -> True
No -> False
:ref:`screenshots<ask_yes_no>`
:param message: message to be displayed.
:param title: window title
:param default: default button as boolean (YES=True, NO=False)
:rtype: bool | [
"Display",
"a",
"message",
"with",
"choices",
"of",
"Yes",
"and",
"No",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/__init__.py#L169-L184 | train | Display a message with choices of Yes and No. |
inveniosoftware/invenio-webhooks | invenio_webhooks/ext.py | _WebhooksState.register | def register(self, receiver_id, receiver):
"""Register a receiver."""
assert receiver_id not in self.receivers
self.receivers[receiver_id] = receiver(receiver_id) | python | def register(self, receiver_id, receiver):
"""Register a receiver."""
assert receiver_id not in self.receivers
self.receivers[receiver_id] = receiver(receiver_id) | [
"def",
"register",
"(",
"self",
",",
"receiver_id",
",",
"receiver",
")",
":",
"assert",
"receiver_id",
"not",
"in",
"self",
".",
"receivers",
"self",
".",
"receivers",
"[",
"receiver_id",
"]",
"=",
"receiver",
"(",
"receiver_id",
")"
] | Register a receiver. | [
"Register",
"a",
"receiver",
"."
] | f407cb2245464543ee474a81189fb9d3978bdde5 | https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/ext.py#L45-L48 | train | Register a receiver. |
inveniosoftware/invenio-webhooks | invenio_webhooks/ext.py | _WebhooksState.load_entry_point_group | def load_entry_point_group(self, entry_point_group):
"""Load actions from an entry point group."""
for ep in pkg_resources.iter_entry_points(group=entry_point_group):
self.register(ep.name, ep.load()) | python | def load_entry_point_group(self, entry_point_group):
"""Load actions from an entry point group."""
for ep in pkg_resources.iter_entry_points(group=entry_point_group):
self.register(ep.name, ep.load()) | [
"def",
"load_entry_point_group",
"(",
"self",
",",
"entry_point_group",
")",
":",
"for",
"ep",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"group",
"=",
"entry_point_group",
")",
":",
"self",
".",
"register",
"(",
"ep",
".",
"name",
",",
"ep",
".",... | Load actions from an entry point group. | [
"Load",
"actions",
"from",
"an",
"entry",
"point",
"group",
"."
] | f407cb2245464543ee474a81189fb9d3978bdde5 | https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/ext.py#L54-L57 | train | Load actions from an entry point group. |
inveniosoftware/invenio-webhooks | invenio_webhooks/ext.py | InvenioWebhooks.init_app | def init_app(self, app, entry_point_group='invenio_webhooks.receivers'):
"""Flask application initialization."""
self.init_config(app)
state = _WebhooksState(app, entry_point_group=entry_point_group)
self._state = app.extensions['invenio-webhooks'] = state | python | def init_app(self, app, entry_point_group='invenio_webhooks.receivers'):
"""Flask application initialization."""
self.init_config(app)
state = _WebhooksState(app, entry_point_group=entry_point_group)
self._state = app.extensions['invenio-webhooks'] = state | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"entry_point_group",
"=",
"'invenio_webhooks.receivers'",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"state",
"=",
"_WebhooksState",
"(",
"app",
",",
"entry_point_group",
"=",
"entry_point_group",
")",... | Flask application initialization. | [
"Flask",
"application",
"initialization",
"."
] | f407cb2245464543ee474a81189fb9d3978bdde5 | https://github.com/inveniosoftware/invenio-webhooks/blob/f407cb2245464543ee474a81189fb9d3978bdde5/invenio_webhooks/ext.py#L68-L72 | train | Initialize the Flask application. |
rfverbruggen/rachiopy | rachiopy/schedulerule.py | Schedulerule.skip | def skip(self, sched_rule_id):
"""Skip a schedule rule (watering time)."""
path = 'schedulerule/skip'
payload = {'id': sched_rule_id}
return self.rachio.put(path, payload) | python | def skip(self, sched_rule_id):
"""Skip a schedule rule (watering time)."""
path = 'schedulerule/skip'
payload = {'id': sched_rule_id}
return self.rachio.put(path, payload) | [
"def",
"skip",
"(",
"self",
",",
"sched_rule_id",
")",
":",
"path",
"=",
"'schedulerule/skip'",
"payload",
"=",
"{",
"'id'",
":",
"sched_rule_id",
"}",
"return",
"self",
".",
"rachio",
".",
"put",
"(",
"path",
",",
"payload",
")"
] | Skip a schedule rule (watering time). | [
"Skip",
"a",
"schedule",
"rule",
"(",
"watering",
"time",
")",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/schedulerule.py#L11-L15 | train | Skip a schedule rule. |
rfverbruggen/rachiopy | rachiopy/schedulerule.py | Schedulerule.start | def start(self, sched_rule_id):
"""Start a schedule rule (watering time)."""
path = 'schedulerule/start'
payload = {'id': sched_rule_id}
return self.rachio.put(path, payload) | python | def start(self, sched_rule_id):
"""Start a schedule rule (watering time)."""
path = 'schedulerule/start'
payload = {'id': sched_rule_id}
return self.rachio.put(path, payload) | [
"def",
"start",
"(",
"self",
",",
"sched_rule_id",
")",
":",
"path",
"=",
"'schedulerule/start'",
"payload",
"=",
"{",
"'id'",
":",
"sched_rule_id",
"}",
"return",
"self",
".",
"rachio",
".",
"put",
"(",
"path",
",",
"payload",
")"
] | Start a schedule rule (watering time). | [
"Start",
"a",
"schedule",
"rule",
"(",
"watering",
"time",
")",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/schedulerule.py#L17-L21 | train | Start a schedule rule. |
rfverbruggen/rachiopy | rachiopy/schedulerule.py | Schedulerule.seasonalAdjustment | def seasonalAdjustment(self, sched_rule_id, adjustment):
"""Seasonal adjustment for a schedule rule (watering time).
This adjustment amount will be applied to the overall run time of the
selected schedule while overriding any current adjustments.
"""
path = 'schedulerule/seasona... | python | def seasonalAdjustment(self, sched_rule_id, adjustment):
"""Seasonal adjustment for a schedule rule (watering time).
This adjustment amount will be applied to the overall run time of the
selected schedule while overriding any current adjustments.
"""
path = 'schedulerule/seasona... | [
"def",
"seasonalAdjustment",
"(",
"self",
",",
"sched_rule_id",
",",
"adjustment",
")",
":",
"path",
"=",
"'schedulerule/seasonal_adjustment'",
"payload",
"=",
"{",
"'id'",
":",
"sched_rule_id",
",",
"'adjustment'",
":",
"adjustment",
"}",
"return",
"self",
".",
... | Seasonal adjustment for a schedule rule (watering time).
This adjustment amount will be applied to the overall run time of the
selected schedule while overriding any current adjustments. | [
"Seasonal",
"adjustment",
"for",
"a",
"schedule",
"rule",
"(",
"watering",
"time",
")",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/schedulerule.py#L23-L31 | train | Seasonal adjustment for a schedule rule. |
rfverbruggen/rachiopy | rachiopy/schedulerule.py | Schedulerule.get | def get(self, sched_rule_id):
"""Retrieve the information for a scheduleRule entity."""
path = '/'.join(['schedulerule', sched_rule_id])
return self.rachio.get(path) | python | def get(self, sched_rule_id):
"""Retrieve the information for a scheduleRule entity."""
path = '/'.join(['schedulerule', sched_rule_id])
return self.rachio.get(path) | [
"def",
"get",
"(",
"self",
",",
"sched_rule_id",
")",
":",
"path",
"=",
"'/'",
".",
"join",
"(",
"[",
"'schedulerule'",
",",
"sched_rule_id",
"]",
")",
"return",
"self",
".",
"rachio",
".",
"get",
"(",
"path",
")"
] | Retrieve the information for a scheduleRule entity. | [
"Retrieve",
"the",
"information",
"for",
"a",
"scheduleRule",
"entity",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/schedulerule.py#L33-L36 | train | Retrieve the information for a scheduleRule entity. |
spotify/gordon-gcp | src/gordon_gcp/schema/parse.py | MessageParser.parse | def parse(self, message, schema):
"""Parse message according to schema.
`message` should already be validated against the given schema.
See :ref:`schemadef` for more information.
Args:
message (dict): message data to parse.
schema (str): valid message schema.
... | python | def parse(self, message, schema):
"""Parse message according to schema.
`message` should already be validated against the given schema.
See :ref:`schemadef` for more information.
Args:
message (dict): message data to parse.
schema (str): valid message schema.
... | [
"def",
"parse",
"(",
"self",
",",
"message",
",",
"schema",
")",
":",
"func",
"=",
"{",
"'audit-log'",
":",
"self",
".",
"_parse_audit_log_msg",
",",
"'event'",
":",
"self",
".",
"_parse_event_msg",
",",
"}",
"[",
"schema",
"]",
"return",
"func",
"(",
... | Parse message according to schema.
`message` should already be validated against the given schema.
See :ref:`schemadef` for more information.
Args:
message (dict): message data to parse.
schema (str): valid message schema.
Returns:
(dict): parsed mes... | [
"Parse",
"message",
"according",
"to",
"schema",
"."
] | 5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da | https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/schema/parse.py#L69-L85 | train | Parse the message according to schema. |
rfverbruggen/rachiopy | rachiopy/zone.py | Zone.start | def start(self, zone_id, duration):
"""Start a zone."""
path = 'zone/start'
payload = {'id': zone_id, 'duration': duration}
return self.rachio.put(path, payload) | python | def start(self, zone_id, duration):
"""Start a zone."""
path = 'zone/start'
payload = {'id': zone_id, 'duration': duration}
return self.rachio.put(path, payload) | [
"def",
"start",
"(",
"self",
",",
"zone_id",
",",
"duration",
")",
":",
"path",
"=",
"'zone/start'",
"payload",
"=",
"{",
"'id'",
":",
"zone_id",
",",
"'duration'",
":",
"duration",
"}",
"return",
"self",
".",
"rachio",
".",
"put",
"(",
"path",
",",
... | Start a zone. | [
"Start",
"a",
"zone",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/zone.py#L11-L15 | train | Start a zone. |
rfverbruggen/rachiopy | rachiopy/zone.py | Zone.startMultiple | def startMultiple(self, zones):
"""Start multiple zones."""
path = 'zone/start_multiple'
payload = {'zones': zones}
return self.rachio.put(path, payload) | python | def startMultiple(self, zones):
"""Start multiple zones."""
path = 'zone/start_multiple'
payload = {'zones': zones}
return self.rachio.put(path, payload) | [
"def",
"startMultiple",
"(",
"self",
",",
"zones",
")",
":",
"path",
"=",
"'zone/start_multiple'",
"payload",
"=",
"{",
"'zones'",
":",
"zones",
"}",
"return",
"self",
".",
"rachio",
".",
"put",
"(",
"path",
",",
"payload",
")"
] | Start multiple zones. | [
"Start",
"multiple",
"zones",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/zone.py#L17-L21 | train | Start multiple zones. |
rfverbruggen/rachiopy | rachiopy/zone.py | Zone.get | def get(self, zone_id):
"""Retrieve the information for a zone entity."""
path = '/'.join(['zone', zone_id])
return self.rachio.get(path) | python | def get(self, zone_id):
"""Retrieve the information for a zone entity."""
path = '/'.join(['zone', zone_id])
return self.rachio.get(path) | [
"def",
"get",
"(",
"self",
",",
"zone_id",
")",
":",
"path",
"=",
"'/'",
".",
"join",
"(",
"[",
"'zone'",
",",
"zone_id",
"]",
")",
"return",
"self",
".",
"rachio",
".",
"get",
"(",
"path",
")"
] | Retrieve the information for a zone entity. | [
"Retrieve",
"the",
"information",
"for",
"a",
"zone",
"entity",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/zone.py#L27-L30 | train | Retrieve the information for a zone entity. |
rfverbruggen/rachiopy | rachiopy/zone.py | ZoneSchedule.start | def start(self):
"""Start the schedule."""
zones = [{"id": data[0], "duration": data[1], "sortOrder": count}
for (count, data) in enumerate(self._zones, 1)]
self._api.startMultiple(zones) | python | def start(self):
"""Start the schedule."""
zones = [{"id": data[0], "duration": data[1], "sortOrder": count}
for (count, data) in enumerate(self._zones, 1)]
self._api.startMultiple(zones) | [
"def",
"start",
"(",
"self",
")",
":",
"zones",
"=",
"[",
"{",
"\"id\"",
":",
"data",
"[",
"0",
"]",
",",
"\"duration\"",
":",
"data",
"[",
"1",
"]",
",",
"\"sortOrder\"",
":",
"count",
"}",
"for",
"(",
"count",
",",
"data",
")",
"in",
"enumerate... | Start the schedule. | [
"Start",
"the",
"schedule",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/zone.py#L45-L49 | train | Start the schedule. |
angvp/django-klingon | klingon/admin.py | TranslationInlineForm.clean_translation | def clean_translation(self):
"""
Do not allow translations longer than the max_lenght of the field to
be translated.
"""
translation = self.cleaned_data['translation']
if self.instance and self.instance.content_object:
# do not allow string longer than transl... | python | def clean_translation(self):
"""
Do not allow translations longer than the max_lenght of the field to
be translated.
"""
translation = self.cleaned_data['translation']
if self.instance and self.instance.content_object:
# do not allow string longer than transl... | [
"def",
"clean_translation",
"(",
"self",
")",
":",
"translation",
"=",
"self",
".",
"cleaned_data",
"[",
"'translation'",
"]",
"if",
"self",
".",
"instance",
"and",
"self",
".",
"instance",
".",
"content_object",
":",
"# do not allow string longer than translatable ... | Do not allow translations longer than the max_lenght of the field to
be translated. | [
"Do",
"not",
"allow",
"translations",
"longer",
"than",
"the",
"max_lenght",
"of",
"the",
"field",
"to",
"be",
"translated",
"."
] | 6716fcb7e98d7d27d41c72c4036d3593f1cc04c2 | https://github.com/angvp/django-klingon/blob/6716fcb7e98d7d27d41c72c4036d3593f1cc04c2/klingon/admin.py#L54-L80 | train | Check if the translation is longer than the max_lenght of the field to
. If so raise forms. ValidationError. |
ministryofjustice/django-zendesk-tickets | zendesk_tickets/views.py | get_safe_return_to | def get_safe_return_to(request, return_to):
"""
Ensure the user-originating redirection url is safe, i.e. within same scheme://domain:port
"""
if return_to and is_safe_url(url=return_to, host=request.get_host()) and return_to != request.build_absolute_uri():
return return_to | python | def get_safe_return_to(request, return_to):
"""
Ensure the user-originating redirection url is safe, i.e. within same scheme://domain:port
"""
if return_to and is_safe_url(url=return_to, host=request.get_host()) and return_to != request.build_absolute_uri():
return return_to | [
"def",
"get_safe_return_to",
"(",
"request",
",",
"return_to",
")",
":",
"if",
"return_to",
"and",
"is_safe_url",
"(",
"url",
"=",
"return_to",
",",
"host",
"=",
"request",
".",
"get_host",
"(",
")",
")",
"and",
"return_to",
"!=",
"request",
".",
"build_ab... | Ensure the user-originating redirection url is safe, i.e. within same scheme://domain:port | [
"Ensure",
"the",
"user",
"-",
"originating",
"redirection",
"url",
"is",
"safe",
"i",
".",
"e",
".",
"within",
"same",
"scheme",
":",
"//",
"domain",
":",
"port"
] | 8c1332b5536dc1cf967b612aad5d07e02439d280 | https://github.com/ministryofjustice/django-zendesk-tickets/blob/8c1332b5536dc1cf967b612aad5d07e02439d280/zendesk_tickets/views.py#L15-L20 | train | Ensure the user - originating redirection url is safe. |
open-contracting/ocds-merge | ocdsmerge/merge.py | _get_merge_rules | def _get_merge_rules(properties, path=None):
"""
Yields merge rules as key-value pairs, in which the first element is a JSON path as a tuple, and the second element
is a list of merge properties whose values are `true`.
"""
if path is None:
path = ()
for key, value in properties.items()... | python | def _get_merge_rules(properties, path=None):
"""
Yields merge rules as key-value pairs, in which the first element is a JSON path as a tuple, and the second element
is a list of merge properties whose values are `true`.
"""
if path is None:
path = ()
for key, value in properties.items()... | [
"def",
"_get_merge_rules",
"(",
"properties",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"(",
")",
"for",
"key",
",",
"value",
"in",
"properties",
".",
"items",
"(",
")",
":",
"new_path",
"=",
"path",
"+",
"("... | Yields merge rules as key-value pairs, in which the first element is a JSON path as a tuple, and the second element
is a list of merge properties whose values are `true`. | [
"Yields",
"merge",
"rules",
"as",
"key",
"-",
"value",
"pairs",
"in",
"which",
"the",
"first",
"element",
"is",
"a",
"JSON",
"path",
"as",
"a",
"tuple",
"and",
"the",
"second",
"element",
"is",
"a",
"list",
"of",
"merge",
"properties",
"whose",
"values",... | 09ef170b24f3fd13bdb1e33043d22de5f0448a9d | https://github.com/open-contracting/ocds-merge/blob/09ef170b24f3fd13bdb1e33043d22de5f0448a9d/ocdsmerge/merge.py#L60-L92 | train | Yields merge rules as key - value pairs in which the first element is a JSON path as a tuple and the second element is a list of merge properties whose values are true. |
open-contracting/ocds-merge | ocdsmerge/merge.py | get_merge_rules | def get_merge_rules(schema=None):
"""
Returns merge rules as key-value pairs, in which the key is a JSON path as a tuple, and the value is a list of
merge properties whose values are `true`.
"""
schema = schema or get_release_schema_url(get_tags()[-1])
if isinstance(schema, dict):
deref_... | python | def get_merge_rules(schema=None):
"""
Returns merge rules as key-value pairs, in which the key is a JSON path as a tuple, and the value is a list of
merge properties whose values are `true`.
"""
schema = schema or get_release_schema_url(get_tags()[-1])
if isinstance(schema, dict):
deref_... | [
"def",
"get_merge_rules",
"(",
"schema",
"=",
"None",
")",
":",
"schema",
"=",
"schema",
"or",
"get_release_schema_url",
"(",
"get_tags",
"(",
")",
"[",
"-",
"1",
"]",
")",
"if",
"isinstance",
"(",
"schema",
",",
"dict",
")",
":",
"deref_schema",
"=",
... | Returns merge rules as key-value pairs, in which the key is a JSON path as a tuple, and the value is a list of
merge properties whose values are `true`. | [
"Returns",
"merge",
"rules",
"as",
"key",
"-",
"value",
"pairs",
"in",
"which",
"the",
"key",
"is",
"a",
"JSON",
"path",
"as",
"a",
"tuple",
"and",
"the",
"value",
"is",
"a",
"list",
"of",
"merge",
"properties",
"whose",
"values",
"are",
"true",
"."
] | 09ef170b24f3fd13bdb1e33043d22de5f0448a9d | https://github.com/open-contracting/ocds-merge/blob/09ef170b24f3fd13bdb1e33043d22de5f0448a9d/ocdsmerge/merge.py#L106-L116 | train | Returns merge rules as key - value pairs in which the key is a JSON path as a tuple and the value is a list of
merge properties whose values are true. |
open-contracting/ocds-merge | ocdsmerge/merge.py | flatten | def flatten(obj, merge_rules=None, path=None, flattened=None):
"""
Flattens a JSON object into key-value pairs, in which the key is the JSON path as a tuple. For example:
{
"a": "I am a",
"b": ["A", "list"],
"c": [
{"ca": "I am ca"},
{"cb": "I am cb"}
... | python | def flatten(obj, merge_rules=None, path=None, flattened=None):
"""
Flattens a JSON object into key-value pairs, in which the key is the JSON path as a tuple. For example:
{
"a": "I am a",
"b": ["A", "list"],
"c": [
{"ca": "I am ca"},
{"cb": "I am cb"}
... | [
"def",
"flatten",
"(",
"obj",
",",
"merge_rules",
"=",
"None",
",",
"path",
"=",
"None",
",",
"flattened",
"=",
"None",
")",
":",
"if",
"merge_rules",
"is",
"None",
":",
"merge_rules",
"=",
"{",
"}",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"(... | Flattens a JSON object into key-value pairs, in which the key is the JSON path as a tuple. For example:
{
"a": "I am a",
"b": ["A", "list"],
"c": [
{"ca": "I am ca"},
{"cb": "I am cb"}
]
}
flattens to:
{
('a',): 'I am a',
('b',):... | [
"Flattens",
"a",
"JSON",
"object",
"into",
"key",
"-",
"value",
"pairs",
"in",
"which",
"the",
"key",
"is",
"the",
"JSON",
"path",
"as",
"a",
"tuple",
".",
"For",
"example",
":"
] | 09ef170b24f3fd13bdb1e33043d22de5f0448a9d | https://github.com/open-contracting/ocds-merge/blob/09ef170b24f3fd13bdb1e33043d22de5f0448a9d/ocdsmerge/merge.py#L119-L177 | train | Flattens a JSON object into key - value pairs in which the key is the JSON path as a tuple. |
open-contracting/ocds-merge | ocdsmerge/merge.py | unflatten | def unflatten(processed, merge_rules):
"""
Unflattens a processed object into a JSON object.
"""
unflattened = OrderedDict()
for key in processed:
current_node = unflattened
for end, part in enumerate(key, 1):
# If this is a path to an item of an array.
# See... | python | def unflatten(processed, merge_rules):
"""
Unflattens a processed object into a JSON object.
"""
unflattened = OrderedDict()
for key in processed:
current_node = unflattened
for end, part in enumerate(key, 1):
# If this is a path to an item of an array.
# See... | [
"def",
"unflatten",
"(",
"processed",
",",
"merge_rules",
")",
":",
"unflattened",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
"in",
"processed",
":",
"current_node",
"=",
"unflattened",
"for",
"end",
",",
"part",
"in",
"enumerate",
"(",
"key",
",",
"1",
... | Unflattens a processed object into a JSON object. | [
"Unflattens",
"a",
"processed",
"object",
"into",
"a",
"JSON",
"object",
"."
] | 09ef170b24f3fd13bdb1e33043d22de5f0448a9d | https://github.com/open-contracting/ocds-merge/blob/09ef170b24f3fd13bdb1e33043d22de5f0448a9d/ocdsmerge/merge.py#L180-L234 | train | Unflattens a processed object into a JSON object. |
open-contracting/ocds-merge | ocdsmerge/merge.py | process_flattened | def process_flattened(flattened):
"""
Replace numbers in JSON paths (representing positions in arrays) with special objects. This ensures that objects
in arrays with different `id` values have different JSON paths – and makes it easy to identify such arrays.
"""
# Keep arrays in order.
processed... | python | def process_flattened(flattened):
"""
Replace numbers in JSON paths (representing positions in arrays) with special objects. This ensures that objects
in arrays with different `id` values have different JSON paths – and makes it easy to identify such arrays.
"""
# Keep arrays in order.
processed... | [
"def",
"process_flattened",
"(",
"flattened",
")",
":",
"# Keep arrays in order.",
"processed",
"=",
"OrderedDict",
"(",
")",
"# Cache identifiers, to avoid minting a new ID for each field of the same object.",
"identifiers",
"=",
"{",
"}",
"for",
"key",
"in",
"flattened",
... | Replace numbers in JSON paths (representing positions in arrays) with special objects. This ensures that objects
in arrays with different `id` values have different JSON paths – and makes it easy to identify such arrays. | [
"Replace",
"numbers",
"in",
"JSON",
"paths",
"(",
"representing",
"positions",
"in",
"arrays",
")",
"with",
"special",
"objects",
".",
"This",
"ensures",
"that",
"objects",
"in",
"arrays",
"with",
"different",
"id",
"values",
"have",
"different",
"JSON",
"path... | 09ef170b24f3fd13bdb1e33043d22de5f0448a9d | https://github.com/open-contracting/ocds-merge/blob/09ef170b24f3fd13bdb1e33043d22de5f0448a9d/ocdsmerge/merge.py#L237-L274 | train | Process a flattened object into a single object. |
open-contracting/ocds-merge | ocdsmerge/merge.py | merge | def merge(releases, schema=None, merge_rules=None):
"""
Merges a list of releases into a compiledRelease.
"""
if not merge_rules:
merge_rules = get_merge_rules(schema)
merged = OrderedDict({('tag',): ['compiled']})
for release in sorted(releases, key=lambda release: release['date']):
... | python | def merge(releases, schema=None, merge_rules=None):
"""
Merges a list of releases into a compiledRelease.
"""
if not merge_rules:
merge_rules = get_merge_rules(schema)
merged = OrderedDict({('tag',): ['compiled']})
for release in sorted(releases, key=lambda release: release['date']):
... | [
"def",
"merge",
"(",
"releases",
",",
"schema",
"=",
"None",
",",
"merge_rules",
"=",
"None",
")",
":",
"if",
"not",
"merge_rules",
":",
"merge_rules",
"=",
"get_merge_rules",
"(",
"schema",
")",
"merged",
"=",
"OrderedDict",
"(",
"{",
"(",
"'tag'",
",",... | Merges a list of releases into a compiledRelease. | [
"Merges",
"a",
"list",
"of",
"releases",
"into",
"a",
"compiledRelease",
"."
] | 09ef170b24f3fd13bdb1e33043d22de5f0448a9d | https://github.com/open-contracting/ocds-merge/blob/09ef170b24f3fd13bdb1e33043d22de5f0448a9d/ocdsmerge/merge.py#L277-L305 | train | Merges a list of releases into a compiledRelease. |
open-contracting/ocds-merge | ocdsmerge/merge.py | merge_versioned | def merge_versioned(releases, schema=None, merge_rules=None):
"""
Merges a list of releases into a versionedRelease.
"""
if not merge_rules:
merge_rules = get_merge_rules(schema)
merged = OrderedDict()
for release in sorted(releases, key=lambda release: release['date']):
release... | python | def merge_versioned(releases, schema=None, merge_rules=None):
"""
Merges a list of releases into a versionedRelease.
"""
if not merge_rules:
merge_rules = get_merge_rules(schema)
merged = OrderedDict()
for release in sorted(releases, key=lambda release: release['date']):
release... | [
"def",
"merge_versioned",
"(",
"releases",
",",
"schema",
"=",
"None",
",",
"merge_rules",
"=",
"None",
")",
":",
"if",
"not",
"merge_rules",
":",
"merge_rules",
"=",
"get_merge_rules",
"(",
"schema",
")",
"merged",
"=",
"OrderedDict",
"(",
")",
"for",
"re... | Merges a list of releases into a versionedRelease. | [
"Merges",
"a",
"list",
"of",
"releases",
"into",
"a",
"versionedRelease",
"."
] | 09ef170b24f3fd13bdb1e33043d22de5f0448a9d | https://github.com/open-contracting/ocds-merge/blob/09ef170b24f3fd13bdb1e33043d22de5f0448a9d/ocdsmerge/merge.py#L308-L346 | train | Merge a list of releases into a versionedRelease. |
ponty/psidialogs | psidialogs/api/easydialogs_api.py | AskFileForSave | def AskFileForSave(message=None, savedFileName=None, version=None, defaultLocation=None, dialogOptionFlags=None, location=None, clientName=None, windowTitle=None, actionButtonLabel=None, cancelButtonLabel=None, preferenceKey=None, popupExtension=None, eventProc=None, fileType=None, fileCreator=None, wanted=None, multip... | python | def AskFileForSave(message=None, savedFileName=None, version=None, defaultLocation=None, dialogOptionFlags=None, location=None, clientName=None, windowTitle=None, actionButtonLabel=None, cancelButtonLabel=None, preferenceKey=None, popupExtension=None, eventProc=None, fileType=None, fileCreator=None, wanted=None, multip... | [
"def",
"AskFileForSave",
"(",
"message",
"=",
"None",
",",
"savedFileName",
"=",
"None",
",",
"version",
"=",
"None",
",",
"defaultLocation",
"=",
"None",
",",
"dialogOptionFlags",
"=",
"None",
",",
"location",
"=",
"None",
",",
"clientName",
"=",
"None",
... | Original doc: Display a dialog asking the user for a filename to save to.
wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
the other arguments can be looked up in Apple's Navigation Services documentation | [
"Original",
"doc",
":",
"Display",
"a",
"dialog",
"asking",
"the",
"user",
"for",
"a",
"filename",
"to",
"save",
"to",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/api/easydialogs_api.py#L4-L9 | train | A dialog that asks the user for a filename to save to. |
ponty/psidialogs | psidialogs/api/easydialogs_api.py | AskFileForOpen | def AskFileForOpen(message=None, typeList=None, version=None, defaultLocation=None, dialogOptionFlags=None, location=None, clientName=None, windowTitle=None, actionButtonLabel=None, cancelButtonLabel=None, preferenceKey=None, popupExtension=None, eventProc=None, previewProc=None, filterProc=None, wanted=None, multiple=... | python | def AskFileForOpen(message=None, typeList=None, version=None, defaultLocation=None, dialogOptionFlags=None, location=None, clientName=None, windowTitle=None, actionButtonLabel=None, cancelButtonLabel=None, preferenceKey=None, popupExtension=None, eventProc=None, previewProc=None, filterProc=None, wanted=None, multiple=... | [
"def",
"AskFileForOpen",
"(",
"message",
"=",
"None",
",",
"typeList",
"=",
"None",
",",
"version",
"=",
"None",
",",
"defaultLocation",
"=",
"None",
",",
"dialogOptionFlags",
"=",
"None",
",",
"location",
"=",
"None",
",",
"clientName",
"=",
"None",
",",
... | Original doc: Display a dialog asking the user for a file to open.
wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
the other arguments can be looked up in Apple's Navigation Services documentation | [
"Original",
"doc",
":",
"Display",
"a",
"dialog",
"asking",
"the",
"user",
"for",
"a",
"file",
"to",
"open",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/api/easydialogs_api.py#L12-L17 | train | This function is used to display a dialog to ask the user for a file to open. |
ponty/psidialogs | psidialogs/api/easydialogs_api.py | ask_folder | def ask_folder(message=None, version=None, defaultLocation=None, dialogOptionFlags=None, location=None, clientName=None, windowTitle=None, actionButtonLabel=None, cancelButtonLabel=None, preferenceKey=None, popupExtension=None, eventProc=None, filterProc=None, wanted=None, multiple=None):
"""Original doc: Display a... | python | def ask_folder(message=None, version=None, defaultLocation=None, dialogOptionFlags=None, location=None, clientName=None, windowTitle=None, actionButtonLabel=None, cancelButtonLabel=None, preferenceKey=None, popupExtension=None, eventProc=None, filterProc=None, wanted=None, multiple=None):
"""Original doc: Display a... | [
"def",
"ask_folder",
"(",
"message",
"=",
"None",
",",
"version",
"=",
"None",
",",
"defaultLocation",
"=",
"None",
",",
"dialogOptionFlags",
"=",
"None",
",",
"location",
"=",
"None",
",",
"clientName",
"=",
"None",
",",
"windowTitle",
"=",
"None",
",",
... | Original doc: Display a dialog asking the user for select a folder.
wanted is the return type wanted: FSSpec, FSRef, unicode or string (default)
the other arguments can be looked up in Apple's Navigation Services documentation | [
"Original",
"doc",
":",
"Display",
"a",
"dialog",
"asking",
"the",
"user",
"for",
"select",
"a",
"folder",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/api/easydialogs_api.py#L36-L41 | train | Display a dialog asking the user for a folder. |
ponty/psidialogs | psidialogs/api/easydialogs_api.py | AskString | def AskString(prompt, default='', id=261, ok=None, cancel=None):
"""Original doc: Display a PROMPT string and a text entry field with a DEFAULT string.
Return the contents of the text entry field when the user clicks the
OK button or presses Return.
Return None when the user clicks the Cancel button.
... | python | def AskString(prompt, default='', id=261, ok=None, cancel=None):
"""Original doc: Display a PROMPT string and a text entry field with a DEFAULT string.
Return the contents of the text entry field when the user clicks the
OK button or presses Return.
Return None when the user clicks the Cancel button.
... | [
"def",
"AskString",
"(",
"prompt",
",",
"default",
"=",
"''",
",",
"id",
"=",
"261",
",",
"ok",
"=",
"None",
",",
"cancel",
"=",
"None",
")",
":",
"return",
"psidialogs",
".",
"ask_string",
"(",
"message",
"=",
"prompt",
",",
"default",
"=",
"default... | Original doc: Display a PROMPT string and a text entry field with a DEFAULT string.
Return the contents of the text entry field when the user clicks the
OK button or presses Return.
Return None when the user clicks the Cancel button.
If omitted, DEFAULT is empty.
The PROMPT and DEFAULT strings, a... | [
"Original",
"doc",
":",
"Display",
"a",
"PROMPT",
"string",
"and",
"a",
"text",
"entry",
"field",
"with",
"a",
"DEFAULT",
"string",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/api/easydialogs_api.py#L44-L56 | train | Original doc : Display a PROMPT string and a text entry field with a DEFAULT string. |
ponty/psidialogs | psidialogs/api/easydialogs_api.py | Message | def Message(msg, id=260, ok=None):
"""Original doc: Display a MESSAGE string.
Return when the user clicks the OK button or presses Return.
The MESSAGE string can be at most 255 characters long.
"""
return psidialogs.message(message=msg, ok=ok) | python | def Message(msg, id=260, ok=None):
"""Original doc: Display a MESSAGE string.
Return when the user clicks the OK button or presses Return.
The MESSAGE string can be at most 255 characters long.
"""
return psidialogs.message(message=msg, ok=ok) | [
"def",
"Message",
"(",
"msg",
",",
"id",
"=",
"260",
",",
"ok",
"=",
"None",
")",
":",
"return",
"psidialogs",
".",
"message",
"(",
"message",
"=",
"msg",
",",
"ok",
"=",
"ok",
")"
] | Original doc: Display a MESSAGE string.
Return when the user clicks the OK button or presses Return.
The MESSAGE string can be at most 255 characters long. | [
"Original",
"doc",
":",
"Display",
"a",
"MESSAGE",
"string",
"."
] | e385ab6b48cb43af52b810a1bf76a8135f4585b8 | https://github.com/ponty/psidialogs/blob/e385ab6b48cb43af52b810a1bf76a8135f4585b8/psidialogs/api/easydialogs_api.py#L59-L66 | train | Display a MESSAGE string. |
F483/btctxstore | btctxstore/common.py | chunks | def chunks(items, size):
""" Split list into chunks of the given size.
Original order is preserved.
Example:
> chunks([1,2,3,4,5,6,7,8], 3)
[[1, 2, 3], [4, 5, 6], [7, 8]]
"""
return [items[i:i+size] for i in range(0, len(items), size)] | python | def chunks(items, size):
""" Split list into chunks of the given size.
Original order is preserved.
Example:
> chunks([1,2,3,4,5,6,7,8], 3)
[[1, 2, 3], [4, 5, 6], [7, 8]]
"""
return [items[i:i+size] for i in range(0, len(items), size)] | [
"def",
"chunks",
"(",
"items",
",",
"size",
")",
":",
"return",
"[",
"items",
"[",
"i",
":",
"i",
"+",
"size",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"items",
")",
",",
"size",
")",
"]"
] | Split list into chunks of the given size.
Original order is preserved.
Example:
> chunks([1,2,3,4,5,6,7,8], 3)
[[1, 2, 3], [4, 5, 6], [7, 8]] | [
"Split",
"list",
"into",
"chunks",
"of",
"the",
"given",
"size",
".",
"Original",
"order",
"is",
"preserved",
"."
] | 5790ace3a3d4c9bcc759e7c931fc4a57d40b6c25 | https://github.com/F483/btctxstore/blob/5790ace3a3d4c9bcc759e7c931fc4a57d40b6c25/btctxstore/common.py#L22-L30 | train | Split list into chunks of the given size. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder.login | def login(self):
"""Login to the ZoneMinder API."""
_LOGGER.debug("Attempting to login to ZoneMinder")
login_post = {'view': 'console', 'action': 'login'}
if self._username:
login_post['username'] = self._username
if self._password:
login_post['password']... | python | def login(self):
"""Login to the ZoneMinder API."""
_LOGGER.debug("Attempting to login to ZoneMinder")
login_post = {'view': 'console', 'action': 'login'}
if self._username:
login_post['username'] = self._username
if self._password:
login_post['password']... | [
"def",
"login",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Attempting to login to ZoneMinder\"",
")",
"login_post",
"=",
"{",
"'view'",
":",
"'console'",
",",
"'action'",
":",
"'login'",
"}",
"if",
"self",
".",
"_username",
":",
"login_post",
"[... | Login to the ZoneMinder API. | [
"Login",
"to",
"the",
"ZoneMinder",
"API",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L35-L62 | train | Login to the ZoneMinder API. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder._zm_request | def _zm_request(self, method, api_url, data=None,
timeout=DEFAULT_TIMEOUT) -> dict:
"""Perform a request to the ZoneMinder API."""
try:
# Since the API uses sessions that expire, sometimes we need to
# re-auth if the call fails.
for _ in range(Zone... | python | def _zm_request(self, method, api_url, data=None,
timeout=DEFAULT_TIMEOUT) -> dict:
"""Perform a request to the ZoneMinder API."""
try:
# Since the API uses sessions that expire, sometimes we need to
# re-auth if the call fails.
for _ in range(Zone... | [
"def",
"_zm_request",
"(",
"self",
",",
"method",
",",
"api_url",
",",
"data",
"=",
"None",
",",
"timeout",
"=",
"DEFAULT_TIMEOUT",
")",
"->",
"dict",
":",
"try",
":",
"# Since the API uses sessions that expire, sometimes we need to",
"# re-auth if the call fails.",
"... | Perform a request to the ZoneMinder API. | [
"Perform",
"a",
"request",
"to",
"the",
"ZoneMinder",
"API",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L72-L100 | train | Perform a request to the ZoneMinder API. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder.get_monitors | def get_monitors(self) -> List[Monitor]:
"""Get a list of Monitors from the ZoneMinder API."""
raw_monitors = self._zm_request('get', ZoneMinder.MONITOR_URL)
if not raw_monitors:
_LOGGER.warning("Could not fetch monitors from ZoneMinder")
return []
monitors = []
... | python | def get_monitors(self) -> List[Monitor]:
"""Get a list of Monitors from the ZoneMinder API."""
raw_monitors = self._zm_request('get', ZoneMinder.MONITOR_URL)
if not raw_monitors:
_LOGGER.warning("Could not fetch monitors from ZoneMinder")
return []
monitors = []
... | [
"def",
"get_monitors",
"(",
"self",
")",
"->",
"List",
"[",
"Monitor",
"]",
":",
"raw_monitors",
"=",
"self",
".",
"_zm_request",
"(",
"'get'",
",",
"ZoneMinder",
".",
"MONITOR_URL",
")",
"if",
"not",
"raw_monitors",
":",
"_LOGGER",
".",
"warning",
"(",
... | Get a list of Monitors from the ZoneMinder API. | [
"Get",
"a",
"list",
"of",
"Monitors",
"from",
"the",
"ZoneMinder",
"API",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L102-L115 | train | Get a list of Monitors from the ZoneMinder API. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder.get_run_states | def get_run_states(self) -> List[RunState]:
"""Get a list of RunStates from the ZoneMinder API."""
raw_states = self.get_state('api/states.json')
if not raw_states:
_LOGGER.warning("Could not fetch runstates from ZoneMinder")
return []
run_states = []
for... | python | def get_run_states(self) -> List[RunState]:
"""Get a list of RunStates from the ZoneMinder API."""
raw_states = self.get_state('api/states.json')
if not raw_states:
_LOGGER.warning("Could not fetch runstates from ZoneMinder")
return []
run_states = []
for... | [
"def",
"get_run_states",
"(",
"self",
")",
"->",
"List",
"[",
"RunState",
"]",
":",
"raw_states",
"=",
"self",
".",
"get_state",
"(",
"'api/states.json'",
")",
"if",
"not",
"raw_states",
":",
"_LOGGER",
".",
"warning",
"(",
"\"Could not fetch runstates from Zone... | Get a list of RunStates from the ZoneMinder API. | [
"Get",
"a",
"list",
"of",
"RunStates",
"from",
"the",
"ZoneMinder",
"API",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L117-L130 | train | Get a list of RunStates from the ZoneMinder API. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder.get_active_state | def get_active_state(self) -> Optional[str]:
"""Get the name of the active run state from the ZoneMinder API."""
for state in self.get_run_states():
if state.active:
return state.name
return None | python | def get_active_state(self) -> Optional[str]:
"""Get the name of the active run state from the ZoneMinder API."""
for state in self.get_run_states():
if state.active:
return state.name
return None | [
"def",
"get_active_state",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"for",
"state",
"in",
"self",
".",
"get_run_states",
"(",
")",
":",
"if",
"state",
".",
"active",
":",
"return",
"state",
".",
"name",
"return",
"None"
] | Get the name of the active run state from the ZoneMinder API. | [
"Get",
"the",
"name",
"of",
"the",
"active",
"run",
"state",
"from",
"the",
"ZoneMinder",
"API",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L132-L137 | train | Get the name of the active run state from the ZoneMinder API. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder.set_active_state | def set_active_state(self, state_name):
"""
Set the ZoneMinder run state to the given state name, via ZM API.
Note that this is a long-running API call; ZoneMinder changes the state
of each camera in turn, and this GET does not receive a response until
all cameras have been upda... | python | def set_active_state(self, state_name):
"""
Set the ZoneMinder run state to the given state name, via ZM API.
Note that this is a long-running API call; ZoneMinder changes the state
of each camera in turn, and this GET does not receive a response until
all cameras have been upda... | [
"def",
"set_active_state",
"(",
"self",
",",
"state_name",
")",
":",
"_LOGGER",
".",
"info",
"(",
"'Setting ZoneMinder run state to state %s'",
",",
"state_name",
")",
"return",
"self",
".",
"_zm_request",
"(",
"'GET'",
",",
"'api/states/change/{}.json'",
".",
"form... | Set the ZoneMinder run state to the given state name, via ZM API.
Note that this is a long-running API call; ZoneMinder changes the state
of each camera in turn, and this GET does not receive a response until
all cameras have been updated. Even on a reasonably powerful machine,
this cal... | [
"Set",
"the",
"ZoneMinder",
"run",
"state",
"to",
"the",
"given",
"state",
"name",
"via",
"ZM",
"API",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L139-L152 | train | Set the active state of the ZoneMinder. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder.get_url_with_auth | def get_url_with_auth(self, url) -> str:
"""Add the auth credentials to a url (if needed)."""
if not self._username:
return url
url += '&user={:s}'.format(self._username)
if not self._password:
return url
return url + '&pass={:s}'.format(self._password) | python | def get_url_with_auth(self, url) -> str:
"""Add the auth credentials to a url (if needed)."""
if not self._username:
return url
url += '&user={:s}'.format(self._username)
if not self._password:
return url
return url + '&pass={:s}'.format(self._password) | [
"def",
"get_url_with_auth",
"(",
"self",
",",
"url",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"_username",
":",
"return",
"url",
"url",
"+=",
"'&user={:s}'",
".",
"format",
"(",
"self",
".",
"_username",
")",
"if",
"not",
"self",
".",
"_passwor... | Add the auth credentials to a url (if needed). | [
"Add",
"the",
"auth",
"credentials",
"to",
"a",
"url",
"(",
"if",
"needed",
")",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L158-L168 | train | Add the auth credentials to a url ( if needed. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder.is_available | def is_available(self) -> bool:
"""Indicate if this ZoneMinder service is currently available."""
status_response = self.get_state(
'api/host/daemonCheck.json'
)
if not status_response:
return False
return status_response.get('result') == 1 | python | def is_available(self) -> bool:
"""Indicate if this ZoneMinder service is currently available."""
status_response = self.get_state(
'api/host/daemonCheck.json'
)
if not status_response:
return False
return status_response.get('result') == 1 | [
"def",
"is_available",
"(",
"self",
")",
"->",
"bool",
":",
"status_response",
"=",
"self",
".",
"get_state",
"(",
"'api/host/daemonCheck.json'",
")",
"if",
"not",
"status_response",
":",
"return",
"False",
"return",
"status_response",
".",
"get",
"(",
"'result'... | Indicate if this ZoneMinder service is currently available. | [
"Indicate",
"if",
"this",
"ZoneMinder",
"service",
"is",
"currently",
"available",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L171-L180 | train | Indicate if this ZoneMinder service is currently available. |
rohankapoorcom/zm-py | zoneminder/zm.py | ZoneMinder._build_server_url | def _build_server_url(server_host, server_path) -> str:
"""Build the server url making sure it ends in a trailing slash."""
server_url = urljoin(server_host, server_path)
if server_url[-1] == '/':
return server_url
return '{}/'.format(server_url) | python | def _build_server_url(server_host, server_path) -> str:
"""Build the server url making sure it ends in a trailing slash."""
server_url = urljoin(server_host, server_path)
if server_url[-1] == '/':
return server_url
return '{}/'.format(server_url) | [
"def",
"_build_server_url",
"(",
"server_host",
",",
"server_path",
")",
"->",
"str",
":",
"server_url",
"=",
"urljoin",
"(",
"server_host",
",",
"server_path",
")",
"if",
"server_url",
"[",
"-",
"1",
"]",
"==",
"'/'",
":",
"return",
"server_url",
"return",
... | Build the server url making sure it ends in a trailing slash. | [
"Build",
"the",
"server",
"url",
"making",
"sure",
"it",
"ends",
"in",
"a",
"trailing",
"slash",
"."
] | bd3a9f6b2f7b84b37589e2939f628b479a5531bf | https://github.com/rohankapoorcom/zm-py/blob/bd3a9f6b2f7b84b37589e2939f628b479a5531bf/zoneminder/zm.py#L193-L198 | train | Build the server url making sure it ends in a trailing slash. |
rfverbruggen/rachiopy | rachiopy/flexschedulerule.py | FlexSchedulerule.get | def get(self, flex_sched_rule_id):
"""Retrieve the information for a flexscheduleRule entity."""
path = '/'.join(['flexschedulerule', flex_sched_rule_id])
return self.rachio.get(path) | python | def get(self, flex_sched_rule_id):
"""Retrieve the information for a flexscheduleRule entity."""
path = '/'.join(['flexschedulerule', flex_sched_rule_id])
return self.rachio.get(path) | [
"def",
"get",
"(",
"self",
",",
"flex_sched_rule_id",
")",
":",
"path",
"=",
"'/'",
".",
"join",
"(",
"[",
"'flexschedulerule'",
",",
"flex_sched_rule_id",
"]",
")",
"return",
"self",
".",
"rachio",
".",
"get",
"(",
"path",
")"
] | Retrieve the information for a flexscheduleRule entity. | [
"Retrieve",
"the",
"information",
"for",
"a",
"flexscheduleRule",
"entity",
"."
] | c91abc9984f0f453e60fa905285c1b640c3390ae | https://github.com/rfverbruggen/rachiopy/blob/c91abc9984f0f453e60fa905285c1b640c3390ae/rachiopy/flexschedulerule.py#L11-L14 | train | Retrieve the information for a flexscheduleRule entity. |
gitenberg-dev/gitberg | gitenberg/workflow.py | upload_all_books | def upload_all_books(book_id_start, book_id_end, rdf_library=None):
""" Uses the fetch, make, push subcommands to
mirror Project Gutenberg to a github3 api
"""
# TODO refactor appname into variable
logger.info(
"starting a gitberg mass upload: {0} -> {1}".format(
book_id_sta... | python | def upload_all_books(book_id_start, book_id_end, rdf_library=None):
""" Uses the fetch, make, push subcommands to
mirror Project Gutenberg to a github3 api
"""
# TODO refactor appname into variable
logger.info(
"starting a gitberg mass upload: {0} -> {1}".format(
book_id_sta... | [
"def",
"upload_all_books",
"(",
"book_id_start",
",",
"book_id_end",
",",
"rdf_library",
"=",
"None",
")",
":",
"# TODO refactor appname into variable",
"logger",
".",
"info",
"(",
"\"starting a gitberg mass upload: {0} -> {1}\"",
".",
"format",
"(",
"book_id_start",
",",... | Uses the fetch, make, push subcommands to
mirror Project Gutenberg to a github3 api | [
"Uses",
"the",
"fetch",
"make",
"push",
"subcommands",
"to",
"mirror",
"Project",
"Gutenberg",
"to",
"a",
"github3",
"api"
] | 3f6db8b5a22ccdd2110d3199223c30db4e558b5c | https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/workflow.py#L15-L41 | train | Uses the fetch make push subcommands to github3 api
|
gitenberg-dev/gitberg | gitenberg/workflow.py | upload_list | def upload_list(book_id_list, rdf_library=None):
""" Uses the fetch, make, push subcommands to add a list of pg books
"""
with open(book_id_list, 'r') as f:
cache = {}
for book_id in f:
book_id = book_id.strip()
try:
if int(book_id) in missing_pgid:
... | python | def upload_list(book_id_list, rdf_library=None):
""" Uses the fetch, make, push subcommands to add a list of pg books
"""
with open(book_id_list, 'r') as f:
cache = {}
for book_id in f:
book_id = book_id.strip()
try:
if int(book_id) in missing_pgid:
... | [
"def",
"upload_list",
"(",
"book_id_list",
",",
"rdf_library",
"=",
"None",
")",
":",
"with",
"open",
"(",
"book_id_list",
",",
"'r'",
")",
"as",
"f",
":",
"cache",
"=",
"{",
"}",
"for",
"book_id",
"in",
"f",
":",
"book_id",
"=",
"book_id",
".",
"str... | Uses the fetch, make, push subcommands to add a list of pg books | [
"Uses",
"the",
"fetch",
"make",
"push",
"subcommands",
"to",
"add",
"a",
"list",
"of",
"pg",
"books"
] | 3f6db8b5a22ccdd2110d3199223c30db4e558b5c | https://github.com/gitenberg-dev/gitberg/blob/3f6db8b5a22ccdd2110d3199223c30db4e558b5c/gitenberg/workflow.py#L43-L57 | train | Adds a list of pg books to the database. |
angvp/django-klingon | klingon/models.py | Translatable.translate | def translate(self):
"""
Create all translations objects for this Translatable instance.
@rtype: list of Translation objects
@return: Returns a list of translations objects
"""
translations = []
for lang in settings.LANGUAGES:
# do not create an trans... | python | def translate(self):
"""
Create all translations objects for this Translatable instance.
@rtype: list of Translation objects
@return: Returns a list of translations objects
"""
translations = []
for lang in settings.LANGUAGES:
# do not create an trans... | [
"def",
"translate",
"(",
"self",
")",
":",
"translations",
"=",
"[",
"]",
"for",
"lang",
"in",
"settings",
".",
"LANGUAGES",
":",
"# do not create an translations for default language.",
"# we will use the original model for this",
"if",
"lang",
"[",
"0",
"]",
"==",
... | Create all translations objects for this Translatable instance.
@rtype: list of Translation objects
@return: Returns a list of translations objects | [
"Create",
"all",
"translations",
"objects",
"for",
"this",
"Translatable",
"instance",
"."
] | 6716fcb7e98d7d27d41c72c4036d3593f1cc04c2 | https://github.com/angvp/django-klingon/blob/6716fcb7e98d7d27d41c72c4036d3593f1cc04c2/klingon/models.py#L57-L84 | train | Creates all translations objects for this Translatable instance. |
angvp/django-klingon | klingon/models.py | Translatable.translations_objects | def translations_objects(self, lang):
"""
Return the complete list of translation objects of a Translatable
instance
@type lang: string
@param lang: a string with the name of the language
@rtype: list of Translation
@return: Returns a list of translations object... | python | def translations_objects(self, lang):
"""
Return the complete list of translation objects of a Translatable
instance
@type lang: string
@param lang: a string with the name of the language
@rtype: list of Translation
@return: Returns a list of translations object... | [
"def",
"translations_objects",
"(",
"self",
",",
"lang",
")",
":",
"return",
"Translation",
".",
"objects",
".",
"filter",
"(",
"object_id",
"=",
"self",
".",
"id",
",",
"content_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"self",
... | Return the complete list of translation objects of a Translatable
instance
@type lang: string
@param lang: a string with the name of the language
@rtype: list of Translation
@return: Returns a list of translations objects | [
"Return",
"the",
"complete",
"list",
"of",
"translation",
"objects",
"of",
"a",
"Translatable",
"instance"
] | 6716fcb7e98d7d27d41c72c4036d3593f1cc04c2 | https://github.com/angvp/django-klingon/blob/6716fcb7e98d7d27d41c72c4036d3593f1cc04c2/klingon/models.py#L86-L101 | train | Returns the complete list of translation objects of a Translatable
instance |
angvp/django-klingon | klingon/models.py | Translatable.translations | def translations(self, lang):
"""
Return the list of translation strings of a Translatable
instance in a dictionary form
@type lang: string
@param lang: a string with the name of the language
@rtype: python Dictionary
@return: Returns a all fieldname / translati... | python | def translations(self, lang):
"""
Return the list of translation strings of a Translatable
instance in a dictionary form
@type lang: string
@param lang: a string with the name of the language
@rtype: python Dictionary
@return: Returns a all fieldname / translati... | [
"def",
"translations",
"(",
"self",
",",
"lang",
")",
":",
"key",
"=",
"self",
".",
"_get_translations_cache_key",
"(",
"lang",
")",
"trans_dict",
"=",
"cache",
".",
"get",
"(",
"key",
",",
"{",
"}",
")",
"if",
"self",
".",
"translatable_slug",
"is",
"... | Return the list of translation strings of a Translatable
instance in a dictionary form
@type lang: string
@param lang: a string with the name of the language
@rtype: python Dictionary
@return: Returns a all fieldname / translations (key / value) | [
"Return",
"the",
"list",
"of",
"translation",
"strings",
"of",
"a",
"Translatable",
"instance",
"in",
"a",
"dictionary",
"form"
] | 6716fcb7e98d7d27d41c72c4036d3593f1cc04c2 | https://github.com/angvp/django-klingon/blob/6716fcb7e98d7d27d41c72c4036d3593f1cc04c2/klingon/models.py#L103-L128 | train | Returns the list of translation strings of a Translatable
instance in a dictionary form
|
angvp/django-klingon | klingon/models.py | Translatable.get_translation_obj | def get_translation_obj(self, lang, field, create=False):
"""
Return the translation object of an specific field in a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the ... | python | def get_translation_obj(self, lang, field, create=False):
"""
Return the translation object of an specific field in a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the ... | [
"def",
"get_translation_obj",
"(",
"self",
",",
"lang",
",",
"field",
",",
"create",
"=",
"False",
")",
":",
"trans",
"=",
"None",
"try",
":",
"trans",
"=",
"Translation",
".",
"objects",
".",
"get",
"(",
"object_id",
"=",
"self",
".",
"id",
",",
"co... | Return the translation object of an specific field in a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the name that we try to get
@rtype: Translation
@return: Returns ... | [
"Return",
"the",
"translation",
"object",
"of",
"an",
"specific",
"field",
"in",
"a",
"Translatable",
"istance"
] | 6716fcb7e98d7d27d41c72c4036d3593f1cc04c2 | https://github.com/angvp/django-klingon/blob/6716fcb7e98d7d27d41c72c4036d3593f1cc04c2/klingon/models.py#L130-L160 | train | Returns the translation object of an specific field in a Translatable
istance
|
angvp/django-klingon | klingon/models.py | Translatable.get_translation | def get_translation(self, lang, field):
"""
Return the translation string of an specific field in a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the name that we try t... | python | def get_translation(self, lang, field):
"""
Return the translation string of an specific field in a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the name that we try t... | [
"def",
"get_translation",
"(",
"self",
",",
"lang",
",",
"field",
")",
":",
"# Read from cache",
"key",
"=",
"self",
".",
"_get_translation_cache_key",
"(",
"lang",
",",
"field",
")",
"trans",
"=",
"cache",
".",
"get",
"(",
"key",
",",
"''",
")",
"if",
... | Return the translation string of an specific field in a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the name that we try to get
@rtype: string
@return: Returns a tra... | [
"Return",
"the",
"translation",
"string",
"of",
"an",
"specific",
"field",
"in",
"a",
"Translatable",
"istance"
] | 6716fcb7e98d7d27d41c72c4036d3593f1cc04c2 | https://github.com/angvp/django-klingon/blob/6716fcb7e98d7d27d41c72c4036d3593f1cc04c2/klingon/models.py#L162-L188 | train | Get the translation string of an specific field in a Translatable
object |
angvp/django-klingon | klingon/models.py | Translatable.set_translation | def set_translation(self, lang, field, text):
"""
Store a translation string in the specified field for a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the name that we... | python | def set_translation(self, lang, field, text):
"""
Store a translation string in the specified field for a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the name that we... | [
"def",
"set_translation",
"(",
"self",
",",
"lang",
",",
"field",
",",
"text",
")",
":",
"# Do not allow user to set a translations in the default language",
"auto_slug_obj",
"=",
"None",
"if",
"lang",
"==",
"self",
".",
"_get_default_language",
"(",
")",
":",
"rais... | Store a translation string in the specified field for a Translatable
istance
@type lang: string
@param lang: a string with the name of the language
@type field: string
@param field: a string with the name that we try to get
@type text: string
@param text: a str... | [
"Store",
"a",
"translation",
"string",
"in",
"the",
"specified",
"field",
"for",
"a",
"Translatable",
"istance"
] | 6716fcb7e98d7d27d41c72c4036d3593f1cc04c2 | https://github.com/angvp/django-klingon/blob/6716fcb7e98d7d27d41c72c4036d3593f1cc04c2/klingon/models.py#L190-L237 | train | Set the translation string in the specified field for a specific language. |
angvp/django-klingon | klingon/models.py | Translatable.translations_link | def translations_link(self):
"""
Print on admin change list the link to see all translations for this object
@type text: string
@param text: a string with the html to link to the translations admin interface
"""
translation_type = ContentType.objects.get_for_model(Transl... | python | def translations_link(self):
"""
Print on admin change list the link to see all translations for this object
@type text: string
@param text: a string with the html to link to the translations admin interface
"""
translation_type = ContentType.objects.get_for_model(Transl... | [
"def",
"translations_link",
"(",
"self",
")",
":",
"translation_type",
"=",
"ContentType",
".",
"objects",
".",
"get_for_model",
"(",
"Translation",
")",
"link",
"=",
"urlresolvers",
".",
"reverse",
"(",
"'admin:%s_%s_changelist'",
"%",
"(",
"translation_type",
".... | Print on admin change list the link to see all translations for this object
@type text: string
@param text: a string with the html to link to the translations admin interface | [
"Print",
"on",
"admin",
"change",
"list",
"the",
"link",
"to",
"see",
"all",
"translations",
"for",
"this",
"object"
] | 6716fcb7e98d7d27d41c72c4036d3593f1cc04c2 | https://github.com/angvp/django-klingon/blob/6716fcb7e98d7d27d41c72c4036d3593f1cc04c2/klingon/models.py#L239-L254 | train | Print on admin change list the link to see all translations for this object |
indietyp/django-automated-logging | automated_logging/signals/database.py | comparison_callback | def comparison_callback(sender, instance, **kwargs):
"""Comparing old and new object to determin which fields changed how"""
if validate_instance(instance) and settings.AUTOMATED_LOGGING['to_database']:
try:
old = sender.objects.get(pk=instance.pk)
except Exception:
retur... | python | def comparison_callback(sender, instance, **kwargs):
"""Comparing old and new object to determin which fields changed how"""
if validate_instance(instance) and settings.AUTOMATED_LOGGING['to_database']:
try:
old = sender.objects.get(pk=instance.pk)
except Exception:
retur... | [
"def",
"comparison_callback",
"(",
"sender",
",",
"instance",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"validate_instance",
"(",
"instance",
")",
"and",
"settings",
".",
"AUTOMATED_LOGGING",
"[",
"'to_database'",
"]",
":",
"try",
":",
"old",
"=",
"sender",
... | Comparing old and new object to determin which fields changed how | [
"Comparing",
"old",
"and",
"new",
"object",
"to",
"determin",
"which",
"fields",
"changed",
"how"
] | 095dfc6df62dca45f7db4516bc35e52085d0a01c | https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/database.py#L18-L92 | train | Compare old and new object to determine which fields changed how |
indietyp/django-automated-logging | automated_logging/signals/database.py | save_callback | def save_callback(sender, instance, created, update_fields, **kwargs):
"""Save object & link logging entry"""
if validate_instance(instance):
status = 'add' if created is True else 'change'
change = ''
if status == 'change' and 'al_chl' in instance.__dict__.keys():
changelog... | python | def save_callback(sender, instance, created, update_fields, **kwargs):
"""Save object & link logging entry"""
if validate_instance(instance):
status = 'add' if created is True else 'change'
change = ''
if status == 'change' and 'al_chl' in instance.__dict__.keys():
changelog... | [
"def",
"save_callback",
"(",
"sender",
",",
"instance",
",",
"created",
",",
"update_fields",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"validate_instance",
"(",
"instance",
")",
":",
"status",
"=",
"'add'",
"if",
"created",
"is",
"True",
"else",
"'change'"... | Save object & link logging entry | [
"Save",
"object",
"&",
"link",
"logging",
"entry"
] | 095dfc6df62dca45f7db4516bc35e52085d0a01c | https://github.com/indietyp/django-automated-logging/blob/095dfc6df62dca45f7db4516bc35e52085d0a01c/automated_logging/signals/database.py#L97-L107 | train | Save object & link logging entry |
Xaroth/libzfs-python | libzfs/handle.py | LibZFSHandle.requires_refcount | def requires_refcount(cls, func):
"""
The ``requires_refcount`` decorator adds a check prior to call ``func`` to verify
that there is an active handle. if there is no such handle, a ``NoHandleException`` exception is thrown.
"""
@functools.wraps(func)
def requires_active_... | python | def requires_refcount(cls, func):
"""
The ``requires_refcount`` decorator adds a check prior to call ``func`` to verify
that there is an active handle. if there is no such handle, a ``NoHandleException`` exception is thrown.
"""
@functools.wraps(func)
def requires_active_... | [
"def",
"requires_refcount",
"(",
"cls",
",",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"requires_active_handle",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"cls",
".",
"refcount",
"(",
")",
"==",
"0",
... | The ``requires_refcount`` decorator adds a check prior to call ``func`` to verify
that there is an active handle. if there is no such handle, a ``NoHandleException`` exception is thrown. | [
"The",
"requires_refcount",
"decorator",
"adds",
"a",
"check",
"prior",
"to",
"call",
"func",
"to",
"verify",
"that",
"there",
"is",
"an",
"active",
"handle",
".",
"if",
"there",
"is",
"no",
"such",
"handle",
"a",
"NoHandleException",
"exception",
"is",
"thr... | 146e5f28de5971bb6eb64fd82b098c5f302f0b33 | https://github.com/Xaroth/libzfs-python/blob/146e5f28de5971bb6eb64fd82b098c5f302f0b33/libzfs/handle.py#L49-L59 | train | Decorator to make sure that a function is called with no active handle. |
Xaroth/libzfs-python | libzfs/handle.py | LibZFSHandle.auto | def auto(cls, func):
"""
The ``auto`` decorator wraps ``func`` in a context manager so that a handle is obtained.
.. note::
Please note, that most functions require the handle to continue being alive for future calls to data
retrieved from the function. In such cases, it's... | python | def auto(cls, func):
"""
The ``auto`` decorator wraps ``func`` in a context manager so that a handle is obtained.
.. note::
Please note, that most functions require the handle to continue being alive for future calls to data
retrieved from the function. In such cases, it's... | [
"def",
"auto",
"(",
"cls",
",",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"auto_claim_handle",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"cls",
"(",
")",
":",
"return",
"func",
"(",
"*",
"args",... | The ``auto`` decorator wraps ``func`` in a context manager so that a handle is obtained.
.. note::
Please note, that most functions require the handle to continue being alive for future calls to data
retrieved from the function. In such cases, it's advisable to use the `requires_refcount`... | [
"The",
"auto",
"decorator",
"wraps",
"func",
"in",
"a",
"context",
"manager",
"so",
"that",
"a",
"handle",
"is",
"obtained",
"."
] | 146e5f28de5971bb6eb64fd82b098c5f302f0b33 | https://github.com/Xaroth/libzfs-python/blob/146e5f28de5971bb6eb64fd82b098c5f302f0b33/libzfs/handle.py#L62-L75 | train | A decorator that creates a context manager that automatically claims a handle for the given class. |
spotify/gordon-gcp | src/gordon_gcp/plugins/janitor/__init__.py | get_gpubsub_publisher | def get_gpubsub_publisher(config, metrics, changes_channel, **kw):
"""Get a GPubsubPublisher client.
A factory function that validates configuration, creates an auth
and pubsub API client, and returns a Google Pub/Sub Publisher
provider.
Args:
config (dict): Google Cloud Pub/Sub-related co... | python | def get_gpubsub_publisher(config, metrics, changes_channel, **kw):
"""Get a GPubsubPublisher client.
A factory function that validates configuration, creates an auth
and pubsub API client, and returns a Google Pub/Sub Publisher
provider.
Args:
config (dict): Google Cloud Pub/Sub-related co... | [
"def",
"get_gpubsub_publisher",
"(",
"config",
",",
"metrics",
",",
"changes_channel",
",",
"*",
"*",
"kw",
")",
":",
"builder",
"=",
"gpubsub_publisher",
".",
"GPubsubPublisherBuilder",
"(",
"config",
",",
"metrics",
",",
"changes_channel",
",",
"*",
"*",
"kw... | Get a GPubsubPublisher client.
A factory function that validates configuration, creates an auth
and pubsub API client, and returns a Google Pub/Sub Publisher
provider.
Args:
config (dict): Google Cloud Pub/Sub-related configuration.
metrics (obj): :interface:`IMetricRelay` implementati... | [
"Get",
"a",
"GPubsubPublisher",
"client",
"."
] | 5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da | https://github.com/spotify/gordon-gcp/blob/5ab19e3c2fe6ace72ee91e2ef1a1326f90b805da/src/gordon_gcp/plugins/janitor/__init__.py#L34-L53 | train | Returns a GPubsubPublisher client. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.