id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
250,100 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.async_change_device | async def async_change_device(
self, device_id: int, group_number: int, unit_number: int,
enable_status: ESFlags, switches: SwitchFlags) -> None:
"""
Change settings for a device on the base unit.
:param device_id: unique identifier for the device to be changed
:... | python | async def async_change_device(
self, device_id: int, group_number: int, unit_number: int,
enable_status: ESFlags, switches: SwitchFlags) -> None:
"""
Change settings for a device on the base unit.
:param device_id: unique identifier for the device to be changed
:... | [
"async",
"def",
"async_change_device",
"(",
"self",
",",
"device_id",
":",
"int",
",",
"group_number",
":",
"int",
",",
"unit_number",
":",
"int",
",",
"enable_status",
":",
"ESFlags",
",",
"switches",
":",
"SwitchFlags",
")",
"->",
"None",
":",
"# Lookup de... | Change settings for a device on the base unit.
:param device_id: unique identifier for the device to be changed
:param group_number: group number the device is to be assigned to
:param unit_number: unit number the device is to be assigned to
:param enable_status: flags indicating settin... | [
"Change",
"settings",
"for",
"a",
"device",
"on",
"the",
"base",
"unit",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L335-L371 |
250,101 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.async_change_special_device | async def async_change_special_device(
self, device_id: int, group_number: int, unit_number: int,
enable_status: ESFlags, switches: SwitchFlags,
special_status: SSFlags, high_limit: Optional[Union[int, float]],
low_limit: Optional[Union[int, float]],
control_h... | python | async def async_change_special_device(
self, device_id: int, group_number: int, unit_number: int,
enable_status: ESFlags, switches: SwitchFlags,
special_status: SSFlags, high_limit: Optional[Union[int, float]],
low_limit: Optional[Union[int, float]],
control_h... | [
"async",
"def",
"async_change_special_device",
"(",
"self",
",",
"device_id",
":",
"int",
",",
"group_number",
":",
"int",
",",
"unit_number",
":",
"int",
",",
"enable_status",
":",
"ESFlags",
",",
"switches",
":",
"SwitchFlags",
",",
"special_status",
":",
"S... | Change settings for a 'Special' device on the base unit.
:param device_id: unique identifier for the device to be changed
:param group_number: group number the device is to be assigned to
:param unit_number: unit number the device is to be assigned to
:param enable_status: flags indicat... | [
"Change",
"settings",
"for",
"a",
"Special",
"device",
"on",
"the",
"base",
"unit",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L373-L423 |
250,102 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.async_delete_device | async def async_delete_device(self, device_id: int) -> None:
"""
Delete an enrolled device.
:param device_id: unique identifier for the device to be deleted
"""
# Lookup device using zone to obtain an accurate index, which is
# needed to perform the delete command
... | python | async def async_delete_device(self, device_id: int) -> None:
"""
Delete an enrolled device.
:param device_id: unique identifier for the device to be deleted
"""
# Lookup device using zone to obtain an accurate index, which is
# needed to perform the delete command
... | [
"async",
"def",
"async_delete_device",
"(",
"self",
",",
"device_id",
":",
"int",
")",
"->",
"None",
":",
"# Lookup device using zone to obtain an accurate index, which is",
"# needed to perform the delete command",
"device",
"=",
"self",
".",
"_devices",
"[",
"device_id",
... | Delete an enrolled device.
:param device_id: unique identifier for the device to be deleted | [
"Delete",
"an",
"enrolled",
"device",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L425-L450 |
250,103 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.async_get_event_log | async def async_get_event_log(self, index: int) -> Optional[EventLogResponse]:
"""
Get an entry from the event log.
:param index: Index for the event log entry to be obtained.
:return: Response containing the event log entry, or None if not found.
"""
response = await s... | python | async def async_get_event_log(self, index: int) -> Optional[EventLogResponse]:
"""
Get an entry from the event log.
:param index: Index for the event log entry to be obtained.
:return: Response containing the event log entry, or None if not found.
"""
response = await s... | [
"async",
"def",
"async_get_event_log",
"(",
"self",
",",
"index",
":",
"int",
")",
"->",
"Optional",
"[",
"EventLogResponse",
"]",
":",
"response",
"=",
"await",
"self",
".",
"_protocol",
".",
"async_execute",
"(",
"GetEventLogCommand",
"(",
"index",
")",
")... | Get an entry from the event log.
:param index: Index for the event log entry to be obtained.
:return: Response containing the event log entry, or None if not found. | [
"Get",
"an",
"entry",
"from",
"the",
"event",
"log",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L465-L477 |
250,104 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.async_get_sensor_log | async def async_get_sensor_log(self, index: int) -> Optional[SensorLogResponse]:
"""
Get an entry from the Special sensor log.
:param index: Index for the sensor log entry to be obtained.
:return: Response containing the sensor log entry, or None if not found.
"""
respo... | python | async def async_get_sensor_log(self, index: int) -> Optional[SensorLogResponse]:
"""
Get an entry from the Special sensor log.
:param index: Index for the sensor log entry to be obtained.
:return: Response containing the sensor log entry, or None if not found.
"""
respo... | [
"async",
"def",
"async_get_sensor_log",
"(",
"self",
",",
"index",
":",
"int",
")",
"->",
"Optional",
"[",
"SensorLogResponse",
"]",
":",
"response",
"=",
"await",
"self",
".",
"_protocol",
".",
"async_execute",
"(",
"GetSensorLogCommand",
"(",
"index",
")",
... | Get an entry from the Special sensor log.
:param index: Index for the sensor log entry to be obtained.
:return: Response containing the sensor log entry, or None if not found. | [
"Get",
"an",
"entry",
"from",
"the",
"Special",
"sensor",
"log",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L479-L491 |
250,105 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.async_set_operation_mode | async def async_set_operation_mode(
self, operation_mode: OperationMode, password: str = '') -> None:
"""
Set the operation mode on the base unit.
:param operation_mode: the operation mode to change to
:param password: if specified, will be used instead of the password
... | python | async def async_set_operation_mode(
self, operation_mode: OperationMode, password: str = '') -> None:
"""
Set the operation mode on the base unit.
:param operation_mode: the operation mode to change to
:param password: if specified, will be used instead of the password
... | [
"async",
"def",
"async_set_operation_mode",
"(",
"self",
",",
"operation_mode",
":",
"OperationMode",
",",
"password",
":",
"str",
"=",
"''",
")",
"->",
"None",
":",
"await",
"self",
".",
"_protocol",
".",
"async_execute",
"(",
"SetOpModeCommand",
"(",
"operat... | Set the operation mode on the base unit.
:param operation_mode: the operation mode to change to
:param password: if specified, will be used instead of the password
property when issuing the command | [
"Set",
"the",
"operation",
"mode",
"on",
"the",
"base",
"unit",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L504-L516 |
250,106 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.async_set_switch_state | async def async_set_switch_state(
self, switch_number: SwitchNumber, state: bool) -> None:
"""
Turn a switch on or off.
:param switch_number: the switch to be set.
:param state: True to turn on, False to turn off.
"""
await self._protocol.async_execute(
... | python | async def async_set_switch_state(
self, switch_number: SwitchNumber, state: bool) -> None:
"""
Turn a switch on or off.
:param switch_number: the switch to be set.
:param state: True to turn on, False to turn off.
"""
await self._protocol.async_execute(
... | [
"async",
"def",
"async_set_switch_state",
"(",
"self",
",",
"switch_number",
":",
"SwitchNumber",
",",
"state",
":",
"bool",
")",
"->",
"None",
":",
"await",
"self",
".",
"_protocol",
".",
"async_execute",
"(",
"SetSwitchCommand",
"(",
"switch_number",
",",
"S... | Turn a switch on or off.
:param switch_number: the switch to be set.
:param state: True to turn on, False to turn off. | [
"Turn",
"a",
"switch",
"on",
"or",
"off",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L518-L530 |
250,107 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.as_dict | def as_dict(self) -> Dict[str, Any]:
"""Converts to a dict of attributes for easier serialization."""
def _on_filter(obj: Any, name: str) -> bool:
# Filter out any callbacks
if isinstance(obj, BaseUnit):
if name.startswith('on_'):
return False
... | python | def as_dict(self) -> Dict[str, Any]:
"""Converts to a dict of attributes for easier serialization."""
def _on_filter(obj: Any, name: str) -> bool:
# Filter out any callbacks
if isinstance(obj, BaseUnit):
if name.startswith('on_'):
return False
... | [
"def",
"as_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"def",
"_on_filter",
"(",
"obj",
":",
"Any",
",",
"name",
":",
"str",
")",
"->",
"bool",
":",
"# Filter out any callbacks",
"if",
"isinstance",
"(",
"obj",
",",
"Base... | Converts to a dict of attributes for easier serialization. | [
"Converts",
"to",
"a",
"dict",
"of",
"attributes",
"for",
"easier",
"serialization",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L539-L548 |
250,108 | pschmitt/zhue | zhue/model/basemodel.py | HueBaseObject.update | def update(self):
'''
Update our object's data
'''
self._json = self._request(
method='GET',
url=self.API
)._json | python | def update(self):
'''
Update our object's data
'''
self._json = self._request(
method='GET',
url=self.API
)._json | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"_json",
"=",
"self",
".",
"_request",
"(",
"method",
"=",
"'GET'",
",",
"url",
"=",
"self",
".",
"API",
")",
".",
"_json"
] | Update our object's data | [
"Update",
"our",
"object",
"s",
"data"
] | 4a3f4ddf12ceeedcb2157f92d93ff1c6438a7d59 | https://github.com/pschmitt/zhue/blob/4a3f4ddf12ceeedcb2157f92d93ff1c6438a7d59/zhue/model/basemodel.py#L38-L45 |
250,109 | pschmitt/zhue | zhue/model/basemodel.py | HueObject.address | def address(self):
'''
Return the address of this "object", minus the scheme, hostname
and port of the bridge
'''
return self.API.replace(
'http://{}:{}'.format(
self._bridge.hostname,
self._bridge.port
), ''
) | python | def address(self):
'''
Return the address of this "object", minus the scheme, hostname
and port of the bridge
'''
return self.API.replace(
'http://{}:{}'.format(
self._bridge.hostname,
self._bridge.port
), ''
) | [
"def",
"address",
"(",
"self",
")",
":",
"return",
"self",
".",
"API",
".",
"replace",
"(",
"'http://{}:{}'",
".",
"format",
"(",
"self",
".",
"_bridge",
".",
"hostname",
",",
"self",
".",
"_bridge",
".",
"port",
")",
",",
"''",
")"
] | Return the address of this "object", minus the scheme, hostname
and port of the bridge | [
"Return",
"the",
"address",
"of",
"this",
"object",
"minus",
"the",
"scheme",
"hostname",
"and",
"port",
"of",
"the",
"bridge"
] | 4a3f4ddf12ceeedcb2157f92d93ff1c6438a7d59 | https://github.com/pschmitt/zhue/blob/4a3f4ddf12ceeedcb2157f92d93ff1c6438a7d59/zhue/model/basemodel.py#L65-L75 |
250,110 | Clarify/clarify_brightcove_sync | clarify_brightcove_sync/clarify_brightcove_bridge.py | ClarifyBrightcoveBridge._load_bundle_map | def _load_bundle_map(self):
'''
Return a map of all bundles in the Clarify app that have an external_id set for them.
The bundles with external_ids set are assumed to be the ones we have inserted from Brightcove.
The external_id contains the Brightcove video id.
'''
bundl... | python | def _load_bundle_map(self):
'''
Return a map of all bundles in the Clarify app that have an external_id set for them.
The bundles with external_ids set are assumed to be the ones we have inserted from Brightcove.
The external_id contains the Brightcove video id.
'''
bundl... | [
"def",
"_load_bundle_map",
"(",
"self",
")",
":",
"bundle_map",
"=",
"{",
"}",
"next_href",
"=",
"None",
"has_next",
"=",
"True",
"while",
"has_next",
":",
"bundles",
"=",
"self",
".",
"clarify_client",
".",
"get_bundle_list",
"(",
"href",
"=",
"next_href",
... | Return a map of all bundles in the Clarify app that have an external_id set for them.
The bundles with external_ids set are assumed to be the ones we have inserted from Brightcove.
The external_id contains the Brightcove video id. | [
"Return",
"a",
"map",
"of",
"all",
"bundles",
"in",
"the",
"Clarify",
"app",
"that",
"have",
"an",
"external_id",
"set",
"for",
"them",
".",
"The",
"bundles",
"with",
"external_ids",
"set",
"are",
"assumed",
"to",
"be",
"the",
"ones",
"we",
"have",
"inse... | cda4443a40e72f1fb02af3d671d8f3f5f9644d24 | https://github.com/Clarify/clarify_brightcove_sync/blob/cda4443a40e72f1fb02af3d671d8f3f5f9644d24/clarify_brightcove_sync/clarify_brightcove_bridge.py#L29-L49 |
250,111 | Clarify/clarify_brightcove_sync | clarify_brightcove_sync/clarify_brightcove_bridge.py | ClarifyBrightcoveBridge._metadata_from_video | def _metadata_from_video(self, video):
'''Generate the searchable metadata that we'll store in the bundle for the video'''
long_desc = video['long_description']
if long_desc is not None:
long_desc = long_desc[:MAX_METADATA_STRING_LEN]
tags = video.get('tags')
metada... | python | def _metadata_from_video(self, video):
'''Generate the searchable metadata that we'll store in the bundle for the video'''
long_desc = video['long_description']
if long_desc is not None:
long_desc = long_desc[:MAX_METADATA_STRING_LEN]
tags = video.get('tags')
metada... | [
"def",
"_metadata_from_video",
"(",
"self",
",",
"video",
")",
":",
"long_desc",
"=",
"video",
"[",
"'long_description'",
"]",
"if",
"long_desc",
"is",
"not",
"None",
":",
"long_desc",
"=",
"long_desc",
"[",
":",
"MAX_METADATA_STRING_LEN",
"]",
"tags",
"=",
... | Generate the searchable metadata that we'll store in the bundle for the video | [
"Generate",
"the",
"searchable",
"metadata",
"that",
"we",
"ll",
"store",
"in",
"the",
"bundle",
"for",
"the",
"video"
] | cda4443a40e72f1fb02af3d671d8f3f5f9644d24 | https://github.com/Clarify/clarify_brightcove_sync/blob/cda4443a40e72f1fb02af3d671d8f3f5f9644d24/clarify_brightcove_sync/clarify_brightcove_bridge.py#L51-L68 |
250,112 | Clarify/clarify_brightcove_sync | clarify_brightcove_sync/clarify_brightcove_bridge.py | ClarifyBrightcoveBridge._src_media_url_for_video | def _src_media_url_for_video(self, video):
'''Get the url for the video media that we can send to Clarify'''
src_url = None
best_height = 0
best_source = None
# TODO: This assumes we have ingested videos. For remote videos, check if the remote flag is True
# and if so, u... | python | def _src_media_url_for_video(self, video):
'''Get the url for the video media that we can send to Clarify'''
src_url = None
best_height = 0
best_source = None
# TODO: This assumes we have ingested videos. For remote videos, check if the remote flag is True
# and if so, u... | [
"def",
"_src_media_url_for_video",
"(",
"self",
",",
"video",
")",
":",
"src_url",
"=",
"None",
"best_height",
"=",
"0",
"best_source",
"=",
"None",
"# TODO: This assumes we have ingested videos. For remote videos, check if the remote flag is True",
"# and if so, use the src url ... | Get the url for the video media that we can send to Clarify | [
"Get",
"the",
"url",
"for",
"the",
"video",
"media",
"that",
"we",
"can",
"send",
"to",
"Clarify"
] | cda4443a40e72f1fb02af3d671d8f3f5f9644d24 | https://github.com/Clarify/clarify_brightcove_sync/blob/cda4443a40e72f1fb02af3d671d8f3f5f9644d24/clarify_brightcove_sync/clarify_brightcove_bridge.py#L70-L88 |
250,113 | Clarify/clarify_brightcove_sync | clarify_brightcove_sync/clarify_brightcove_bridge.py | ClarifyBrightcoveBridge._update_metadata_for_video | def _update_metadata_for_video(self, metadata_href, video):
'''
Update the metadata for the video if video has been updated in Brightcove since the bundle
metadata was last updated.
'''
current_metadata = self.clarify_client.get_metadata(metadata_href)
cur_data = current_... | python | def _update_metadata_for_video(self, metadata_href, video):
'''
Update the metadata for the video if video has been updated in Brightcove since the bundle
metadata was last updated.
'''
current_metadata = self.clarify_client.get_metadata(metadata_href)
cur_data = current_... | [
"def",
"_update_metadata_for_video",
"(",
"self",
",",
"metadata_href",
",",
"video",
")",
":",
"current_metadata",
"=",
"self",
".",
"clarify_client",
".",
"get_metadata",
"(",
"metadata_href",
")",
"cur_data",
"=",
"current_metadata",
".",
"get",
"(",
"'data'",
... | Update the metadata for the video if video has been updated in Brightcove since the bundle
metadata was last updated. | [
"Update",
"the",
"metadata",
"for",
"the",
"video",
"if",
"video",
"has",
"been",
"updated",
"in",
"Brightcove",
"since",
"the",
"bundle",
"metadata",
"was",
"last",
"updated",
"."
] | cda4443a40e72f1fb02af3d671d8f3f5f9644d24 | https://github.com/Clarify/clarify_brightcove_sync/blob/cda4443a40e72f1fb02af3d671d8f3f5f9644d24/clarify_brightcove_sync/clarify_brightcove_bridge.py#L107-L120 |
250,114 | storborg/replaylib | replaylib/noseplugin.py | ReplayLibPlugin.options | def options(self, parser, env=os.environ):
"Add options to nosetests."
parser.add_option("--%s-record" % self.name,
action="store",
metavar="FILE",
dest="record_filename",
help="Record actions to this... | python | def options(self, parser, env=os.environ):
"Add options to nosetests."
parser.add_option("--%s-record" % self.name,
action="store",
metavar="FILE",
dest="record_filename",
help="Record actions to this... | [
"def",
"options",
"(",
"self",
",",
"parser",
",",
"env",
"=",
"os",
".",
"environ",
")",
":",
"parser",
".",
"add_option",
"(",
"\"--%s-record\"",
"%",
"self",
".",
"name",
",",
"action",
"=",
"\"store\"",
",",
"metavar",
"=",
"\"FILE\"",
",",
"dest",... | Add options to nosetests. | [
"Add",
"options",
"to",
"nosetests",
"."
] | 16bc3752bb992e3fb364fce9bd7c3f95e887a42d | https://github.com/storborg/replaylib/blob/16bc3752bb992e3fb364fce9bd7c3f95e887a42d/replaylib/noseplugin.py#L14-L25 |
250,115 | westerncapelabs/django-messaging-subscription | subscription/tasks.py | ensure_one_subscription | def ensure_one_subscription():
"""
Fixes issues caused by upstream failures
that lead to users having multiple active subscriptions
Runs daily
"""
cursor = connection.cursor()
cursor.execute("UPDATE subscription_subscription SET active = False \
WHERE id NOT IN \
... | python | def ensure_one_subscription():
"""
Fixes issues caused by upstream failures
that lead to users having multiple active subscriptions
Runs daily
"""
cursor = connection.cursor()
cursor.execute("UPDATE subscription_subscription SET active = False \
WHERE id NOT IN \
... | [
"def",
"ensure_one_subscription",
"(",
")",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"cursor",
".",
"execute",
"(",
"\"UPDATE subscription_subscription SET active = False \\\n WHERE id NOT IN \\\n (SELECT MAX(id) as id FROM \\\n ... | Fixes issues caused by upstream failures
that lead to users having multiple active subscriptions
Runs daily | [
"Fixes",
"issues",
"caused",
"by",
"upstream",
"failures",
"that",
"lead",
"to",
"users",
"having",
"multiple",
"active",
"subscriptions",
"Runs",
"daily"
] | 7af7021cdd6c02b0dfd4b617b9274401972dbaf8 | https://github.com/westerncapelabs/django-messaging-subscription/blob/7af7021cdd6c02b0dfd4b617b9274401972dbaf8/subscription/tasks.py#L43-L57 |
250,116 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/zonerpress_api.py | _get_encoding | def _get_encoding(dom, default="utf-8"):
"""
Try to look for meta tag in given `dom`.
Args:
dom (obj): pyDHTMLParser dom of HTML elements.
default (default "utr-8"): What to use if encoding is not found in
`dom`.
Returns:
str/default: Given en... | python | def _get_encoding(dom, default="utf-8"):
"""
Try to look for meta tag in given `dom`.
Args:
dom (obj): pyDHTMLParser dom of HTML elements.
default (default "utr-8"): What to use if encoding is not found in
`dom`.
Returns:
str/default: Given en... | [
"def",
"_get_encoding",
"(",
"dom",
",",
"default",
"=",
"\"utf-8\"",
")",
":",
"encoding",
"=",
"dom",
".",
"find",
"(",
"\"meta\"",
",",
"{",
"\"http-equiv\"",
":",
"\"Content-Type\"",
"}",
")",
"if",
"not",
"encoding",
":",
"return",
"default",
"encodin... | Try to look for meta tag in given `dom`.
Args:
dom (obj): pyDHTMLParser dom of HTML elements.
default (default "utr-8"): What to use if encoding is not found in
`dom`.
Returns:
str/default: Given encoding or `default` parameter if not found. | [
"Try",
"to",
"look",
"for",
"meta",
"tag",
"in",
"given",
"dom",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/zonerpress_api.py#L41-L63 |
250,117 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/zonerpress_api.py | handle_encodnig | def handle_encodnig(html):
"""
Look for encoding in given `html`. Try to convert `html` to utf-8.
Args:
html (str): HTML code as string.
Returns:
str: HTML code encoded in UTF.
"""
encoding = _get_encoding(
dhtmlparser.parseString(
html.split("</head>")[0]
... | python | def handle_encodnig(html):
"""
Look for encoding in given `html`. Try to convert `html` to utf-8.
Args:
html (str): HTML code as string.
Returns:
str: HTML code encoded in UTF.
"""
encoding = _get_encoding(
dhtmlparser.parseString(
html.split("</head>")[0]
... | [
"def",
"handle_encodnig",
"(",
"html",
")",
":",
"encoding",
"=",
"_get_encoding",
"(",
"dhtmlparser",
".",
"parseString",
"(",
"html",
".",
"split",
"(",
"\"</head>\"",
")",
"[",
"0",
"]",
")",
")",
"if",
"encoding",
"==",
"\"utf-8\"",
":",
"return",
"h... | Look for encoding in given `html`. Try to convert `html` to utf-8.
Args:
html (str): HTML code as string.
Returns:
str: HTML code encoded in UTF. | [
"Look",
"for",
"encoding",
"in",
"given",
"html",
".",
"Try",
"to",
"convert",
"html",
"to",
"utf",
"-",
"8",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/zonerpress_api.py#L66-L85 |
250,118 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/zonerpress_api.py | is_equal_tag | def is_equal_tag(element, tag_name, params, content):
"""
Check is `element` object match rest of the parameters.
All checks are performed only if proper attribute is set in the HTMLElement.
Args:
element (obj): HTMLElement instance.
tag_name (str): Tag name.
params (dict): Par... | python | def is_equal_tag(element, tag_name, params, content):
"""
Check is `element` object match rest of the parameters.
All checks are performed only if proper attribute is set in the HTMLElement.
Args:
element (obj): HTMLElement instance.
tag_name (str): Tag name.
params (dict): Par... | [
"def",
"is_equal_tag",
"(",
"element",
",",
"tag_name",
",",
"params",
",",
"content",
")",
":",
"if",
"tag_name",
"and",
"tag_name",
"!=",
"element",
".",
"getTagName",
"(",
")",
":",
"return",
"False",
"if",
"params",
"and",
"not",
"element",
".",
"con... | Check is `element` object match rest of the parameters.
All checks are performed only if proper attribute is set in the HTMLElement.
Args:
element (obj): HTMLElement instance.
tag_name (str): Tag name.
params (dict): Parameters of the tag.
content (str): Content of the tag.
... | [
"Check",
"is",
"element",
"object",
"match",
"rest",
"of",
"the",
"parameters",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/zonerpress_api.py#L88-L112 |
250,119 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/zonerpress_cz/zonerpress_api.py | has_neigh | def has_neigh(tag_name, params=None, content=None, left=True):
"""
This function generates functions, which matches all tags with neighbours
defined by parameters.
Args:
tag_name (str): Tag has to have neighbour with this tagname.
params (dict): Tag has to have neighbour with this param... | python | def has_neigh(tag_name, params=None, content=None, left=True):
"""
This function generates functions, which matches all tags with neighbours
defined by parameters.
Args:
tag_name (str): Tag has to have neighbour with this tagname.
params (dict): Tag has to have neighbour with this param... | [
"def",
"has_neigh",
"(",
"tag_name",
",",
"params",
"=",
"None",
",",
"content",
"=",
"None",
",",
"left",
"=",
"True",
")",
":",
"def",
"has_neigh_closure",
"(",
"element",
")",
":",
"if",
"not",
"element",
".",
"parent",
"or",
"not",
"(",
"element",
... | This function generates functions, which matches all tags with neighbours
defined by parameters.
Args:
tag_name (str): Tag has to have neighbour with this tagname.
params (dict): Tag has to have neighbour with this parameters.
params (str): Tag has to have neighbour with this content.
... | [
"This",
"function",
"generates",
"functions",
"which",
"matches",
"all",
"tags",
"with",
"neighbours",
"defined",
"by",
"parameters",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/zonerpress_cz/zonerpress_api.py#L115-L158 |
250,120 | mitakas/wallpaper | wallpaper/wallpaper.py | Wallpaper.paint | def paint(self):
"""
Saves the wallpaper as the specified filename.
"""
# nice blue color
self.image = Image.new(mode='RGB', size=(self.width, self.height),
color=(47, 98, 135))
self.paint_pattern()
self.image.save(fp=self.filename) | python | def paint(self):
"""
Saves the wallpaper as the specified filename.
"""
# nice blue color
self.image = Image.new(mode='RGB', size=(self.width, self.height),
color=(47, 98, 135))
self.paint_pattern()
self.image.save(fp=self.filename) | [
"def",
"paint",
"(",
"self",
")",
":",
"# nice blue color",
"self",
".",
"image",
"=",
"Image",
".",
"new",
"(",
"mode",
"=",
"'RGB'",
",",
"size",
"=",
"(",
"self",
".",
"width",
",",
"self",
".",
"height",
")",
",",
"color",
"=",
"(",
"47",
","... | Saves the wallpaper as the specified filename. | [
"Saves",
"the",
"wallpaper",
"as",
"the",
"specified",
"filename",
"."
] | 83d90f56cf888d39c98aeb84e0e64d1289e4d0c0 | https://github.com/mitakas/wallpaper/blob/83d90f56cf888d39c98aeb84e0e64d1289e4d0c0/wallpaper/wallpaper.py#L37-L46 |
250,121 | seryl/Python-Cotendo | cotendo/__init__.py | Cotendo.cdn_get_conf | def cdn_get_conf(self, cname, environment):
"""
Returns the existing origin configuration and token from the CDN
"""
response = self.client.service.cdn_get_conf(cname, environment)
cdn_config = CotendoCDN(response)
return cdn_config | python | def cdn_get_conf(self, cname, environment):
"""
Returns the existing origin configuration and token from the CDN
"""
response = self.client.service.cdn_get_conf(cname, environment)
cdn_config = CotendoCDN(response)
return cdn_config | [
"def",
"cdn_get_conf",
"(",
"self",
",",
"cname",
",",
"environment",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"service",
".",
"cdn_get_conf",
"(",
"cname",
",",
"environment",
")",
"cdn_config",
"=",
"CotendoCDN",
"(",
"response",
")",
"retu... | Returns the existing origin configuration and token from the CDN | [
"Returns",
"the",
"existing",
"origin",
"configuration",
"and",
"token",
"from",
"the",
"CDN"
] | a55e034f0845332319859f6276adc6ba35f5a121 | https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/__init__.py#L67-L73 |
250,122 | seryl/Python-Cotendo | cotendo/__init__.py | Cotendo.dns_get_conf | def dns_get_conf(self, domainName, environment):
"""
Returns the existing domain configuration and token from the ADNS
"""
response = self.client.service.dns_get_conf(domainName, environment)
dns_config = CotendoDNS(response)
return dns_config | python | def dns_get_conf(self, domainName, environment):
"""
Returns the existing domain configuration and token from the ADNS
"""
response = self.client.service.dns_get_conf(domainName, environment)
dns_config = CotendoDNS(response)
return dns_config | [
"def",
"dns_get_conf",
"(",
"self",
",",
"domainName",
",",
"environment",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"service",
".",
"dns_get_conf",
"(",
"domainName",
",",
"environment",
")",
"dns_config",
"=",
"CotendoDNS",
"(",
"response",
")... | Returns the existing domain configuration and token from the ADNS | [
"Returns",
"the",
"existing",
"domain",
"configuration",
"and",
"token",
"from",
"the",
"ADNS"
] | a55e034f0845332319859f6276adc6ba35f5a121 | https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/__init__.py#L95-L101 |
250,123 | seryl/Python-Cotendo | cotendo/__init__.py | Cotendo.doFlush | def doFlush(self, cname, flushExpression, flushType):
"""
doFlush method enables specific content to be "flushed" from the
cache servers.
* Note: The flush API is limited to 1,000 flush invocations per hour
(each flush invocation may include several objects). *
"""
... | python | def doFlush(self, cname, flushExpression, flushType):
"""
doFlush method enables specific content to be "flushed" from the
cache servers.
* Note: The flush API is limited to 1,000 flush invocations per hour
(each flush invocation may include several objects). *
"""
... | [
"def",
"doFlush",
"(",
"self",
",",
"cname",
",",
"flushExpression",
",",
"flushType",
")",
":",
"return",
"self",
".",
"client",
".",
"service",
".",
"doFlush",
"(",
"cname",
",",
"flushExpression",
",",
"flushType",
")"
] | doFlush method enables specific content to be "flushed" from the
cache servers.
* Note: The flush API is limited to 1,000 flush invocations per hour
(each flush invocation may include several objects). * | [
"doFlush",
"method",
"enables",
"specific",
"content",
"to",
"be",
"flushed",
"from",
"the",
"cache",
"servers",
"."
] | a55e034f0845332319859f6276adc6ba35f5a121 | https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/__init__.py#L129-L138 |
250,124 | seryl/Python-Cotendo | cotendo/__init__.py | CotendoHelper.UpdateDNS | def UpdateDNS(self, domain, environment):
"""Pushes DNS updates"""
self.dns_set_conf(domain, self.dns.config,
environment, self.dns.token) | python | def UpdateDNS(self, domain, environment):
"""Pushes DNS updates"""
self.dns_set_conf(domain, self.dns.config,
environment, self.dns.token) | [
"def",
"UpdateDNS",
"(",
"self",
",",
"domain",
",",
"environment",
")",
":",
"self",
".",
"dns_set_conf",
"(",
"domain",
",",
"self",
".",
"dns",
".",
"config",
",",
"environment",
",",
"self",
".",
"dns",
".",
"token",
")"
] | Pushes DNS updates | [
"Pushes",
"DNS",
"updates"
] | a55e034f0845332319859f6276adc6ba35f5a121 | https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/__init__.py#L193-L196 |
250,125 | seryl/Python-Cotendo | cotendo/__init__.py | CotendoHelper.ImportDNS | def ImportDNS(self, config, token=None):
"""
Import a dns configuration file into the helper
Note: This requires that you have the latest token.
To get the latest token, run the GrabDNS command first.
"""
if not token:
raise Exception("You must have the dns t... | python | def ImportDNS(self, config, token=None):
"""
Import a dns configuration file into the helper
Note: This requires that you have the latest token.
To get the latest token, run the GrabDNS command first.
"""
if not token:
raise Exception("You must have the dns t... | [
"def",
"ImportDNS",
"(",
"self",
",",
"config",
",",
"token",
"=",
"None",
")",
":",
"if",
"not",
"token",
":",
"raise",
"Exception",
"(",
"\"You must have the dns token set first.\"",
")",
"self",
".",
"dns",
"=",
"CotendoDNS",
"(",
"[",
"token",
",",
"co... | Import a dns configuration file into the helper
Note: This requires that you have the latest token.
To get the latest token, run the GrabDNS command first. | [
"Import",
"a",
"dns",
"configuration",
"file",
"into",
"the",
"helper"
] | a55e034f0845332319859f6276adc6ba35f5a121 | https://github.com/seryl/Python-Cotendo/blob/a55e034f0845332319859f6276adc6ba35f5a121/cotendo/__init__.py#L198-L208 |
250,126 | henrysher/kotocore | kotocore/cache.py | ServiceCache.get_connection | def get_connection(self, service_name):
"""
Retrieves a connection class from the cache, if available.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:returns: A <kotocore.connect... | python | def get_connection(self, service_name):
"""
Retrieves a connection class from the cache, if available.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:returns: A <kotocore.connect... | [
"def",
"get_connection",
"(",
"self",
",",
"service_name",
")",
":",
"service",
"=",
"self",
".",
"services",
".",
"get",
"(",
"service_name",
",",
"{",
"}",
")",
"connection_class",
"=",
"service",
".",
"get",
"(",
"'connection'",
",",
"None",
")",
"if"... | Retrieves a connection class from the cache, if available.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:returns: A <kotocore.connection.Connection> subclass | [
"Retrieves",
"a",
"connection",
"class",
"from",
"the",
"cache",
"if",
"available",
"."
] | c52d2f3878b924ceabca07f61c91abcb1b230ecc | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L47-L66 |
250,127 | henrysher/kotocore | kotocore/cache.py | ServiceCache.set_connection | def set_connection(self, service_name, to_cache):
"""
Sets a connection class within the cache.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param to_cache: The class to be cac... | python | def set_connection(self, service_name, to_cache):
"""
Sets a connection class within the cache.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param to_cache: The class to be cac... | [
"def",
"set_connection",
"(",
"self",
",",
"service_name",
",",
"to_cache",
")",
":",
"self",
".",
"services",
".",
"setdefault",
"(",
"service_name",
",",
"{",
"}",
")",
"self",
".",
"services",
"[",
"service_name",
"]",
"[",
"'connection'",
"]",
"=",
"... | Sets a connection class within the cache.
:param service_name: The service a given ``Connection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param to_cache: The class to be cached for the service.
:type to_cache: class | [
"Sets",
"a",
"connection",
"class",
"within",
"the",
"cache",
"."
] | c52d2f3878b924ceabca07f61c91abcb1b230ecc | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L68-L80 |
250,128 | henrysher/kotocore | kotocore/cache.py | ServiceCache.get_resource | def get_resource(self, service_name, resource_name, base_class=None):
"""
Retrieves a resource class from the cache, if available.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:pa... | python | def get_resource(self, service_name, resource_name, base_class=None):
"""
Retrieves a resource class from the cache, if available.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:pa... | [
"def",
"get_resource",
"(",
"self",
",",
"service_name",
",",
"resource_name",
",",
"base_class",
"=",
"None",
")",
":",
"classpath",
"=",
"self",
".",
"build_classpath",
"(",
"base_class",
")",
"service",
"=",
"self",
".",
"services",
".",
"get",
"(",
"se... | Retrieves a resource class from the cache, if available.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The name of the ``Resource``. Ex.
``Queue``, ``Notification... | [
"Retrieves",
"a",
"resource",
"class",
"from",
"the",
"cache",
"if",
"available",
"."
] | c52d2f3878b924ceabca07f61c91abcb1b230ecc | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L110-L142 |
250,129 | henrysher/kotocore | kotocore/cache.py | ServiceCache.set_resource | def set_resource(self, service_name, resource_name, to_cache):
"""
Sets the resource class within the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The... | python | def set_resource(self, service_name, resource_name, to_cache):
"""
Sets the resource class within the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The... | [
"def",
"set_resource",
"(",
"self",
",",
"service_name",
",",
"resource_name",
",",
"to_cache",
")",
":",
"self",
".",
"services",
".",
"setdefault",
"(",
"service_name",
",",
"{",
"}",
")",
"self",
".",
"services",
"[",
"service_name",
"]",
".",
"setdefau... | Sets the resource class within the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param resource_name: The name of the ``Resource``. Ex.
``Queue``, ``Notification``, ``Table``, ... | [
"Sets",
"the",
"resource",
"class",
"within",
"the",
"cache",
"."
] | c52d2f3878b924ceabca07f61c91abcb1b230ecc | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L144-L168 |
250,130 | henrysher/kotocore | kotocore/cache.py | ServiceCache.del_resource | def del_resource(self, service_name, resource_name, base_class=None):
"""
Deletes a resource class for a given service.
Fails silently if no connection is found in the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``,... | python | def del_resource(self, service_name, resource_name, base_class=None):
"""
Deletes a resource class for a given service.
Fails silently if no connection is found in the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``,... | [
"def",
"del_resource",
"(",
"self",
",",
"service_name",
",",
"resource_name",
",",
"base_class",
"=",
"None",
")",
":",
"# Unlike ``get_resource``, this should be fire & forget.",
"# We don't really care, as long as it's not in the cache any longer.",
"try",
":",
"classpath",
... | Deletes a resource class for a given service.
Fails silently if no connection is found in the cache.
:param service_name: The service a given ``Resource`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param base_class: (Optional) The base c... | [
"Deletes",
"a",
"resource",
"class",
"for",
"a",
"given",
"service",
"."
] | c52d2f3878b924ceabca07f61c91abcb1b230ecc | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L170-L192 |
250,131 | henrysher/kotocore | kotocore/cache.py | ServiceCache.get_collection | def get_collection(self, service_name, collection_name, base_class=None):
"""
Retrieves a collection class from the cache, if available.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
... | python | def get_collection(self, service_name, collection_name, base_class=None):
"""
Retrieves a collection class from the cache, if available.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
... | [
"def",
"get_collection",
"(",
"self",
",",
"service_name",
",",
"collection_name",
",",
"base_class",
"=",
"None",
")",
":",
"classpath",
"=",
"self",
".",
"build_classpath",
"(",
"base_class",
")",
"service",
"=",
"self",
".",
"services",
".",
"get",
"(",
... | Retrieves a collection class from the cache, if available.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_name: The name of the ``Collection``. Ex.
``QueueCollection... | [
"Retrieves",
"a",
"collection",
"class",
"from",
"the",
"cache",
"if",
"available",
"."
] | c52d2f3878b924ceabca07f61c91abcb1b230ecc | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L194-L227 |
250,132 | henrysher/kotocore | kotocore/cache.py | ServiceCache.set_collection | def set_collection(self, service_name, collection_name, to_cache):
"""
Sets a collection class within the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_n... | python | def set_collection(self, service_name, collection_name, to_cache):
"""
Sets a collection class within the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_n... | [
"def",
"set_collection",
"(",
"self",
",",
"service_name",
",",
"collection_name",
",",
"to_cache",
")",
":",
"self",
".",
"services",
".",
"setdefault",
"(",
"service_name",
",",
"{",
"}",
")",
"self",
".",
"services",
"[",
"service_name",
"]",
".",
"setd... | Sets a collection class within the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_name: The name of the ``Collection``. Ex.
``QueueCollection``, ``Notificatio... | [
"Sets",
"a",
"collection",
"class",
"within",
"the",
"cache",
"."
] | c52d2f3878b924ceabca07f61c91abcb1b230ecc | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L229-L254 |
250,133 | henrysher/kotocore | kotocore/cache.py | ServiceCache.del_collection | def del_collection(self, service_name, collection_name, base_class=None):
"""
Deletes a collection for a given service.
Fails silently if no collection is found in the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb`... | python | def del_collection(self, service_name, collection_name, base_class=None):
"""
Deletes a collection for a given service.
Fails silently if no collection is found in the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb`... | [
"def",
"del_collection",
"(",
"self",
",",
"service_name",
",",
"collection_name",
",",
"base_class",
"=",
"None",
")",
":",
"# Unlike ``get_collection``, this should be fire & forget.",
"# We don't really care, as long as it's not in the cache any longer.",
"try",
":",
"classpat... | Deletes a collection for a given service.
Fails silently if no collection is found in the cache.
:param service_name: The service a given ``Collection`` talks to. Ex.
``sqs``, ``sns``, ``dynamodb``, etc.
:type service_name: string
:param collection_name: The name of the ``... | [
"Deletes",
"a",
"collection",
"for",
"a",
"given",
"service",
"."
] | c52d2f3878b924ceabca07f61c91abcb1b230ecc | https://github.com/henrysher/kotocore/blob/c52d2f3878b924ceabca07f61c91abcb1b230ecc/kotocore/cache.py#L256-L283 |
250,134 | amadev/doan | doan/util.py | chunk | def chunk(seq, n):
# http://stackoverflow.com/a/312464/190597 (Ned Batchelder)
""" Yield successive n-sized chunks from seq."""
for i in range(0, len(seq), n):
yield seq[i:i + n] | python | def chunk(seq, n):
# http://stackoverflow.com/a/312464/190597 (Ned Batchelder)
""" Yield successive n-sized chunks from seq."""
for i in range(0, len(seq), n):
yield seq[i:i + n] | [
"def",
"chunk",
"(",
"seq",
",",
"n",
")",
":",
"# http://stackoverflow.com/a/312464/190597 (Ned Batchelder)",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"seq",
")",
",",
"n",
")",
":",
"yield",
"seq",
"[",
"i",
":",
"i",
"+",
"n",
"]"
] | Yield successive n-sized chunks from seq. | [
"Yield",
"successive",
"n",
"-",
"sized",
"chunks",
"from",
"seq",
"."
] | 5adfa983ac547007a688fe7517291a432919aa3e | https://github.com/amadev/doan/blob/5adfa983ac547007a688fe7517291a432919aa3e/doan/util.py#L15-L19 |
250,135 | RayCrafter/clusterlogger | src/clusterlogger/logfilter.py | HazelHenFilter.filter | def filter(self, record):
"""Add contextual information to the log record
:param record: the log record
:type record: :class:`logging.LogRecord`
:returns: True, if log should get sent
:rtype: :class:`bool`
:raises: None
"""
record.sitename = self.sitename... | python | def filter(self, record):
"""Add contextual information to the log record
:param record: the log record
:type record: :class:`logging.LogRecord`
:returns: True, if log should get sent
:rtype: :class:`bool`
:raises: None
"""
record.sitename = self.sitename... | [
"def",
"filter",
"(",
"self",
",",
"record",
")",
":",
"record",
".",
"sitename",
"=",
"self",
".",
"sitename",
"record",
".",
"platform",
"=",
"self",
".",
"platform",
"record",
".",
"jobid",
"=",
"self",
".",
"jobid",
"record",
".",
"submitter",
"=",... | Add contextual information to the log record
:param record: the log record
:type record: :class:`logging.LogRecord`
:returns: True, if log should get sent
:rtype: :class:`bool`
:raises: None | [
"Add",
"contextual",
"information",
"to",
"the",
"log",
"record"
] | c67a833a0b9d0c007d4054358702462706933df3 | https://github.com/RayCrafter/clusterlogger/blob/c67a833a0b9d0c007d4054358702462706933df3/src/clusterlogger/logfilter.py#L39-L55 |
250,136 | mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAuthMixin.auth_user_get_url | def auth_user_get_url(self):
'Build authorization URL for User Agent.'
if not self.client_id: raise AuthenticationError('No client_id specified')
return '{}?{}'.format(self.auth_url_user, urllib.urlencode(dict(
client_id=self.client_id, state=self.auth_state_check,
response_type='code', redirect_uri=self.au... | python | def auth_user_get_url(self):
'Build authorization URL for User Agent.'
if not self.client_id: raise AuthenticationError('No client_id specified')
return '{}?{}'.format(self.auth_url_user, urllib.urlencode(dict(
client_id=self.client_id, state=self.auth_state_check,
response_type='code', redirect_uri=self.au... | [
"def",
"auth_user_get_url",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"client_id",
":",
"raise",
"AuthenticationError",
"(",
"'No client_id specified'",
")",
"return",
"'{}?{}'",
".",
"format",
"(",
"self",
".",
"auth_url_user",
",",
"urllib",
".",
"url... | Build authorization URL for User Agent. | [
"Build",
"authorization",
"URL",
"for",
"User",
"Agent",
"."
] | 4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48 | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L102-L107 |
250,137 | mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAPIWrapper.listdir | def listdir(self, folder_id='0', offset=None, limit=None, fields=None):
'Get Box object, representing list of objects in a folder.'
if fields is not None\
and not isinstance(fields, types.StringTypes): fields = ','.join(fields)
return self(
join('folders', folder_id, 'items'),
dict(offset=offset, limit=l... | python | def listdir(self, folder_id='0', offset=None, limit=None, fields=None):
'Get Box object, representing list of objects in a folder.'
if fields is not None\
and not isinstance(fields, types.StringTypes): fields = ','.join(fields)
return self(
join('folders', folder_id, 'items'),
dict(offset=offset, limit=l... | [
"def",
"listdir",
"(",
"self",
",",
"folder_id",
"=",
"'0'",
",",
"offset",
"=",
"None",
",",
"limit",
"=",
"None",
",",
"fields",
"=",
"None",
")",
":",
"if",
"fields",
"is",
"not",
"None",
"and",
"not",
"isinstance",
"(",
"fields",
",",
"types",
... | Get Box object, representing list of objects in a folder. | [
"Get",
"Box",
"object",
"representing",
"list",
"of",
"objects",
"in",
"a",
"folder",
"."
] | 4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48 | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L213-L219 |
250,138 | mk-fg/txboxdotnet | txboxdotnet/api_v2.py | BoxAPIWrapper.mkdir | def mkdir(self, name=None, folder_id='0'):
'''Create a folder with a specified "name" attribute.
folder_id allows to specify a parent folder.'''
return self( 'folders', method='post', encode='json',
data=dict(name=name, parent=dict(id=folder_id)) ) | python | def mkdir(self, name=None, folder_id='0'):
'''Create a folder with a specified "name" attribute.
folder_id allows to specify a parent folder.'''
return self( 'folders', method='post', encode='json',
data=dict(name=name, parent=dict(id=folder_id)) ) | [
"def",
"mkdir",
"(",
"self",
",",
"name",
"=",
"None",
",",
"folder_id",
"=",
"'0'",
")",
":",
"return",
"self",
"(",
"'folders'",
",",
"method",
"=",
"'post'",
",",
"encode",
"=",
"'json'",
",",
"data",
"=",
"dict",
"(",
"name",
"=",
"name",
",",
... | Create a folder with a specified "name" attribute.
folder_id allows to specify a parent folder. | [
"Create",
"a",
"folder",
"with",
"a",
"specified",
"name",
"attribute",
".",
"folder_id",
"allows",
"to",
"specify",
"a",
"parent",
"folder",
"."
] | 4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48 | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L269-L273 |
250,139 | mk-fg/txboxdotnet | txboxdotnet/api_v2.py | txBoxAPI.auth_get_token | def auth_get_token(self, check_state=True):
'Refresh or acquire access_token.'
res = self.auth_access_data_raw = yield self._auth_token_request()
defer.returnValue(self._auth_token_process(res, check_state=check_state)) | python | def auth_get_token(self, check_state=True):
'Refresh or acquire access_token.'
res = self.auth_access_data_raw = yield self._auth_token_request()
defer.returnValue(self._auth_token_process(res, check_state=check_state)) | [
"def",
"auth_get_token",
"(",
"self",
",",
"check_state",
"=",
"True",
")",
":",
"res",
"=",
"self",
".",
"auth_access_data_raw",
"=",
"yield",
"self",
".",
"_auth_token_request",
"(",
")",
"defer",
".",
"returnValue",
"(",
"self",
".",
"_auth_token_process",
... | Refresh or acquire access_token. | [
"Refresh",
"or",
"acquire",
"access_token",
"."
] | 4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48 | https://github.com/mk-fg/txboxdotnet/blob/4a3e48fbe1388c5e2a17e808aaaf6b2460e61f48/txboxdotnet/api_v2.py#L704-L707 |
250,140 | coghost/izen | izen/dec.py | retry | def retry(tries, delay=0, back_off=1, raise_msg=''):
"""Retries a function or method until it got True.
- ``delay`` sets the initial delay in seconds
- ``back_off`` sets the factor by which
- ``raise_msg`` if not '', it'll raise an Exception
"""
if back_off < 1:
raise ValueError('back_... | python | def retry(tries, delay=0, back_off=1, raise_msg=''):
"""Retries a function or method until it got True.
- ``delay`` sets the initial delay in seconds
- ``back_off`` sets the factor by which
- ``raise_msg`` if not '', it'll raise an Exception
"""
if back_off < 1:
raise ValueError('back_... | [
"def",
"retry",
"(",
"tries",
",",
"delay",
"=",
"0",
",",
"back_off",
"=",
"1",
",",
"raise_msg",
"=",
"''",
")",
":",
"if",
"back_off",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'back_off must be 1 or greater'",
")",
"tries",
"=",
"math",
".",
"flo... | Retries a function or method until it got True.
- ``delay`` sets the initial delay in seconds
- ``back_off`` sets the factor by which
- ``raise_msg`` if not '', it'll raise an Exception | [
"Retries",
"a",
"function",
"or",
"method",
"until",
"it",
"got",
"True",
"."
] | 432db017f99dd2ba809e1ba1792145ab6510263d | https://github.com/coghost/izen/blob/432db017f99dd2ba809e1ba1792145ab6510263d/izen/dec.py#L80-L117 |
250,141 | drowse314-dev-ymat/xmlpumpkin | xmlpumpkin/__init__.py | parse_to_tree | def parse_to_tree(text):
"""Parse text using CaboCha, then return Tree instance."""
xml_text = cabocha.as_xml(text)
tree = Tree(xml_text)
return tree | python | def parse_to_tree(text):
"""Parse text using CaboCha, then return Tree instance."""
xml_text = cabocha.as_xml(text)
tree = Tree(xml_text)
return tree | [
"def",
"parse_to_tree",
"(",
"text",
")",
":",
"xml_text",
"=",
"cabocha",
".",
"as_xml",
"(",
"text",
")",
"tree",
"=",
"Tree",
"(",
"xml_text",
")",
"return",
"tree"
] | Parse text using CaboCha, then return Tree instance. | [
"Parse",
"text",
"using",
"CaboCha",
"then",
"return",
"Tree",
"instance",
"."
] | 6ccf5c5408a741e5b4a29f0e47849435cb3a6556 | https://github.com/drowse314-dev-ymat/xmlpumpkin/blob/6ccf5c5408a741e5b4a29f0e47849435cb3a6556/xmlpumpkin/__init__.py#L11-L15 |
250,142 | kervi/kervi-core | kervi/displays/__init__.py | Display.add_page | def add_page(self, page, default = True):
r"""
Add a display page to the display.
:param page: Page to be added
:type display_id: ``DisplayPage``
:param default: True if this page should be shown upon initialization.
:type name: ``bool``
"""
... | python | def add_page(self, page, default = True):
r"""
Add a display page to the display.
:param page: Page to be added
:type display_id: ``DisplayPage``
:param default: True if this page should be shown upon initialization.
:type name: ``bool``
"""
... | [
"def",
"add_page",
"(",
"self",
",",
"page",
",",
"default",
"=",
"True",
")",
":",
"self",
".",
"_pages",
"[",
"page",
".",
"page_id",
"]",
"=",
"page",
"page",
".",
"_add_display",
"(",
"self",
")",
"if",
"default",
"or",
"not",
"self",
".",
"_ac... | r"""
Add a display page to the display.
:param page: Page to be added
:type display_id: ``DisplayPage``
:param default: True if this page should be shown upon initialization.
:type name: ``bool`` | [
"r",
"Add",
"a",
"display",
"page",
"to",
"the",
"display",
"."
] | 3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23 | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/displays/__init__.py#L69-L83 |
250,143 | kervi/kervi-core | kervi/displays/__init__.py | Display.activate_page | def activate_page(self, page_id):
r"""
Activates a display page. Content of the active page is shown in the display.
:param page_id: Id of page to activate
:type page_id: ``str``
"""
if page_id == "next":
page_keys = list(self._pages.keys())
key... | python | def activate_page(self, page_id):
r"""
Activates a display page. Content of the active page is shown in the display.
:param page_id: Id of page to activate
:type page_id: ``str``
"""
if page_id == "next":
page_keys = list(self._pages.keys())
key... | [
"def",
"activate_page",
"(",
"self",
",",
"page_id",
")",
":",
"if",
"page_id",
"==",
"\"next\"",
":",
"page_keys",
"=",
"list",
"(",
"self",
".",
"_pages",
".",
"keys",
"(",
")",
")",
"key_count",
"=",
"len",
"(",
"page_keys",
")",
"if",
"key_count",
... | r"""
Activates a display page. Content of the active page is shown in the display.
:param page_id: Id of page to activate
:type page_id: ``str`` | [
"r",
"Activates",
"a",
"display",
"page",
".",
"Content",
"of",
"the",
"active",
"page",
"is",
"shown",
"in",
"the",
"display",
"."
] | 3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23 | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/displays/__init__.py#L108-L133 |
250,144 | kervi/kervi-core | kervi/displays/__init__.py | Display._get_font | def _get_font(self, size=8, name="PressStart2P.ttf"):
"""
Returns a font that can be used by pil image functions.
This default font is "SourceSansVariable-Roman" that is available on all platforms.
"""
import kervi.vision as vision
from PIL import ImageFont
vision... | python | def _get_font(self, size=8, name="PressStart2P.ttf"):
"""
Returns a font that can be used by pil image functions.
This default font is "SourceSansVariable-Roman" that is available on all platforms.
"""
import kervi.vision as vision
from PIL import ImageFont
vision... | [
"def",
"_get_font",
"(",
"self",
",",
"size",
"=",
"8",
",",
"name",
"=",
"\"PressStart2P.ttf\"",
")",
":",
"import",
"kervi",
".",
"vision",
"as",
"vision",
"from",
"PIL",
"import",
"ImageFont",
"vision_path",
"=",
"os",
".",
"path",
".",
"dirname",
"("... | Returns a font that can be used by pil image functions.
This default font is "SourceSansVariable-Roman" that is available on all platforms. | [
"Returns",
"a",
"font",
"that",
"can",
"be",
"used",
"by",
"pil",
"image",
"functions",
".",
"This",
"default",
"font",
"is",
"SourceSansVariable",
"-",
"Roman",
"that",
"is",
"available",
"on",
"all",
"platforms",
"."
] | 3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23 | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/displays/__init__.py#L188-L198 |
250,145 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_publisher | def _parse_publisher(details):
"""
Parse publisher of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Publisher's name as string or None if not found.
"""
publisher = _get_td_or_none(
details,
"ctl00_Conte... | python | def _parse_publisher(details):
"""
Parse publisher of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Publisher's name as string or None if not found.
"""
publisher = _get_td_or_none(
details,
"ctl00_Conte... | [
"def",
"_parse_publisher",
"(",
"details",
")",
":",
"publisher",
"=",
"_get_td_or_none",
"(",
"details",
",",
"\"ctl00_ContentPlaceHolder1_tblRowNakladatel\"",
")",
"# publisher is not specified",
"if",
"not",
"publisher",
":",
"return",
"None",
"publisher",
"=",
"dhtm... | Parse publisher of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
str/None: Publisher's name as string or None if not found. | [
"Parse",
"publisher",
"of",
"the",
"book",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L143-L168 |
250,146 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_pages_binding | def _parse_pages_binding(details):
"""
Parse number of pages and binding of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(pages, binding): Tuple with two string or two None.
"""
pages = _get_td_or_none(
details,
... | python | def _parse_pages_binding(details):
"""
Parse number of pages and binding of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(pages, binding): Tuple with two string or two None.
"""
pages = _get_td_or_none(
details,
... | [
"def",
"_parse_pages_binding",
"(",
"details",
")",
":",
"pages",
"=",
"_get_td_or_none",
"(",
"details",
",",
"\"ctl00_ContentPlaceHolder1_tblRowRozsahVazba\"",
")",
"if",
"not",
"pages",
":",
"return",
"None",
",",
"None",
"binding",
"=",
"None",
"# binding info a... | Parse number of pages and binding of the book.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(pages, binding): Tuple with two string or two None. | [
"Parse",
"number",
"of",
"pages",
"and",
"binding",
"of",
"the",
"book",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L189-L215 |
250,147 | edeposit/edeposit.amqp.harvester | src/edeposit/amqp/harvester/scrappers/ben_cz.py | _parse_ISBN_EAN | def _parse_ISBN_EAN(details):
"""
Parse ISBN and EAN.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(ISBN, EAN): Tuple with two string or two None.
"""
isbn_ean = _get_td_or_none(
details,
"ctl00_ContentPlaceHolder1_tblRowI... | python | def _parse_ISBN_EAN(details):
"""
Parse ISBN and EAN.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(ISBN, EAN): Tuple with two string or two None.
"""
isbn_ean = _get_td_or_none(
details,
"ctl00_ContentPlaceHolder1_tblRowI... | [
"def",
"_parse_ISBN_EAN",
"(",
"details",
")",
":",
"isbn_ean",
"=",
"_get_td_or_none",
"(",
"details",
",",
"\"ctl00_ContentPlaceHolder1_tblRowIsbnEan\"",
")",
"if",
"not",
"isbn_ean",
":",
"return",
"None",
",",
"None",
"ean",
"=",
"None",
"isbn",
"=",
"None",... | Parse ISBN and EAN.
Args:
details (obj): HTMLElement containing slice of the page with details.
Returns:
(ISBN, EAN): Tuple with two string or two None. | [
"Parse",
"ISBN",
"and",
"EAN",
"."
] | 38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e | https://github.com/edeposit/edeposit.amqp.harvester/blob/38cb87ccdf6bf2f550a98460d0a329c4b9dc8e2e/src/edeposit/amqp/harvester/scrappers/ben_cz.py#L218-L248 |
250,148 | kervi/kervi-core | kervi/core/utility/settings.py | Settings.store_value | def store_value(self, name, value):
"""Store a value to DB"""
self.spine.send_command("storeSetting", self.group, name, value) | python | def store_value(self, name, value):
"""Store a value to DB"""
self.spine.send_command("storeSetting", self.group, name, value) | [
"def",
"store_value",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"spine",
".",
"send_command",
"(",
"\"storeSetting\"",
",",
"self",
".",
"group",
",",
"name",
",",
"value",
")"
] | Store a value to DB | [
"Store",
"a",
"value",
"to",
"DB"
] | 3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23 | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/core/utility/settings.py#L22-L24 |
250,149 | kervi/kervi-core | kervi/core/utility/settings.py | Settings.retrieve_value | def retrieve_value(self, name, default_value=None):
"""Retrieve a value from DB"""
value = self.spine.send_query("retrieveSetting", self.group, name, processes=["kervi-main"])
if value is None:
return default_value
elif isinstance(value, list) and len(value) == 0:
... | python | def retrieve_value(self, name, default_value=None):
"""Retrieve a value from DB"""
value = self.spine.send_query("retrieveSetting", self.group, name, processes=["kervi-main"])
if value is None:
return default_value
elif isinstance(value, list) and len(value) == 0:
... | [
"def",
"retrieve_value",
"(",
"self",
",",
"name",
",",
"default_value",
"=",
"None",
")",
":",
"value",
"=",
"self",
".",
"spine",
".",
"send_query",
"(",
"\"retrieveSetting\"",
",",
"self",
".",
"group",
",",
"name",
",",
"processes",
"=",
"[",
"\"kerv... | Retrieve a value from DB | [
"Retrieve",
"a",
"value",
"from",
"DB"
] | 3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23 | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/core/utility/settings.py#L27-L39 |
250,150 | cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | teb_retry | def teb_retry(exc=RequestException,
when=dict(response__status_code=429),
delay='response__headers__Retry-After',
max_collisions=MAX_COLLISIONS,
default_retry=DEFAULT_RETRY):
"""Decorator catching rate limits exceed events during a crawl task.
It retries t... | python | def teb_retry(exc=RequestException,
when=dict(response__status_code=429),
delay='response__headers__Retry-After',
max_collisions=MAX_COLLISIONS,
default_retry=DEFAULT_RETRY):
"""Decorator catching rate limits exceed events during a crawl task.
It retries t... | [
"def",
"teb_retry",
"(",
"exc",
"=",
"RequestException",
",",
"when",
"=",
"dict",
"(",
"response__status_code",
"=",
"429",
")",
",",
"delay",
"=",
"'response__headers__Retry-After'",
",",
"max_collisions",
"=",
"MAX_COLLISIONS",
",",
"default_retry",
"=",
"DEFAU... | Decorator catching rate limits exceed events during a crawl task.
It retries the task later on, following a truncated exponential backoff. | [
"Decorator",
"catching",
"rate",
"limits",
"exceed",
"events",
"during",
"a",
"crawl",
"task",
".",
"It",
"retries",
"the",
"task",
"later",
"on",
"following",
"a",
"truncated",
"exponential",
"backoff",
"."
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L39-L71 |
250,151 | cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | RateLimiter.get_configs | def get_configs(cls):
"""Get rate limiters configuration
specified at application level
:rtype: dict of configurations
"""
import docido_sdk.config
http_config = docido_sdk.config.get('http') or {}
session_config = http_config.get('session') or {}
rate_li... | python | def get_configs(cls):
"""Get rate limiters configuration
specified at application level
:rtype: dict of configurations
"""
import docido_sdk.config
http_config = docido_sdk.config.get('http') or {}
session_config = http_config.get('session') or {}
rate_li... | [
"def",
"get_configs",
"(",
"cls",
")",
":",
"import",
"docido_sdk",
".",
"config",
"http_config",
"=",
"docido_sdk",
".",
"config",
".",
"get",
"(",
"'http'",
")",
"or",
"{",
"}",
"session_config",
"=",
"http_config",
".",
"get",
"(",
"'session'",
")",
"... | Get rate limiters configuration
specified at application level
:rtype: dict of configurations | [
"Get",
"rate",
"limiters",
"configuration",
"specified",
"at",
"application",
"level"
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L247-L257 |
250,152 | cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | RateLimiter.get_config | def get_config(cls, service, config=None):
"""Get get configuration of the specified rate limiter
:param str service:
rate limiter name
:param config:
optional global rate limiters configuration.
If not specified, then use rate limiters configuration
spe... | python | def get_config(cls, service, config=None):
"""Get get configuration of the specified rate limiter
:param str service:
rate limiter name
:param config:
optional global rate limiters configuration.
If not specified, then use rate limiters configuration
spe... | [
"def",
"get_config",
"(",
"cls",
",",
"service",
",",
"config",
"=",
"None",
")",
":",
"config",
"=",
"config",
"or",
"cls",
".",
"get_configs",
"(",
")",
"return",
"config",
"[",
"service",
"]"
] | Get get configuration of the specified rate limiter
:param str service:
rate limiter name
:param config:
optional global rate limiters configuration.
If not specified, then use rate limiters configuration
specified at application level | [
"Get",
"get",
"configuration",
"of",
"the",
"specified",
"rate",
"limiter"
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L260-L272 |
250,153 | cogniteev/docido-python-sdk | docido_sdk/toolbox/rate_limits.py | RateLimiter.get | def get(cls, service, config=None, persistence_kwargs=None, **context):
"""Load a rate-limiter from configuration
:param str service:
rate limiter name to retrieve
:param dict config:
alternate configuration object to use. If `None`, then use the global
application... | python | def get(cls, service, config=None, persistence_kwargs=None, **context):
"""Load a rate-limiter from configuration
:param str service:
rate limiter name to retrieve
:param dict config:
alternate configuration object to use. If `None`, then use the global
application... | [
"def",
"get",
"(",
"cls",
",",
"service",
",",
"config",
"=",
"None",
",",
"persistence_kwargs",
"=",
"None",
",",
"*",
"*",
"context",
")",
":",
"rl_config",
"=",
"cls",
".",
"get_config",
"(",
"service",
",",
"config",
")",
"context",
".",
"update",
... | Load a rate-limiter from configuration
:param str service:
rate limiter name to retrieve
:param dict config:
alternate configuration object to use. If `None`, then use the global
application configuration
:context:
Uniquely describe the consumed resource.... | [
"Load",
"a",
"rate",
"-",
"limiter",
"from",
"configuration"
] | 58ecb6c6f5757fd40c0601657ab18368da7ddf33 | https://github.com/cogniteev/docido-python-sdk/blob/58ecb6c6f5757fd40c0601657ab18368da7ddf33/docido_sdk/toolbox/rate_limits.py#L275-L302 |
250,154 | uw-it-aca/uw-restclients-gradepage | uw_gradepage/grading_status.py | get_grading_status | def get_grading_status(section_id, act_as=None):
"""
Return a restclients.models.gradepage.GradePageStatus object
on the given course
"""
url = "{}/{}".format(url_prefix, quote(section_id))
headers = {}
if act_as is not None:
headers["X-UW-Act-as"] = act_as
response = get_resou... | python | def get_grading_status(section_id, act_as=None):
"""
Return a restclients.models.gradepage.GradePageStatus object
on the given course
"""
url = "{}/{}".format(url_prefix, quote(section_id))
headers = {}
if act_as is not None:
headers["X-UW-Act-as"] = act_as
response = get_resou... | [
"def",
"get_grading_status",
"(",
"section_id",
",",
"act_as",
"=",
"None",
")",
":",
"url",
"=",
"\"{}/{}\"",
".",
"format",
"(",
"url_prefix",
",",
"quote",
"(",
"section_id",
")",
")",
"headers",
"=",
"{",
"}",
"if",
"act_as",
"is",
"not",
"None",
"... | Return a restclients.models.gradepage.GradePageStatus object
on the given course | [
"Return",
"a",
"restclients",
".",
"models",
".",
"gradepage",
".",
"GradePageStatus",
"object",
"on",
"the",
"given",
"course"
] | 207ae8aa5e58f979b77aeb2c5a1772b56bd57e90 | https://github.com/uw-it-aca/uw-restclients-gradepage/blob/207ae8aa5e58f979b77aeb2c5a1772b56bd57e90/uw_gradepage/grading_status.py#L19-L31 |
250,155 | PushAMP/strictdict3 | strictdict/strictbase/strictdict.py | StrictDict.to_dict | def to_dict(self):
"""
For backwards compatibility
"""
plain_dict = dict()
for k, v in self.items():
if self.__fields__[k].is_list:
if isinstance(self.__fields__[k], ViewModelField):
plain_dict[k] = tuple(vt.to_dict() for vt in v)
... | python | def to_dict(self):
"""
For backwards compatibility
"""
plain_dict = dict()
for k, v in self.items():
if self.__fields__[k].is_list:
if isinstance(self.__fields__[k], ViewModelField):
plain_dict[k] = tuple(vt.to_dict() for vt in v)
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"plain_dict",
"=",
"dict",
"(",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"__fields__",
"[",
"k",
"]",
".",
"is_list",
":",
"if",
"isinstance",
"(",
"self",
... | For backwards compatibility | [
"For",
"backwards",
"compatibility"
] | 8b7b91c097ecc57232871137db6135c71fc33a9e | https://github.com/PushAMP/strictdict3/blob/8b7b91c097ecc57232871137db6135c71fc33a9e/strictdict/strictbase/strictdict.py#L174-L194 |
250,156 | PushAMP/strictdict3 | strictdict/strictbase/strictdict.py | StrictDict.restore | def restore(cls, data_dict):
"""
Restore from previously simplified data. Data is supposed to be valid,
no checks are performed!
"""
obj = cls.__new__(cls) # Avoid calling constructor
object.__setattr__(obj, '_simplified', data_dict)
object.__setattr__(obj, '_sto... | python | def restore(cls, data_dict):
"""
Restore from previously simplified data. Data is supposed to be valid,
no checks are performed!
"""
obj = cls.__new__(cls) # Avoid calling constructor
object.__setattr__(obj, '_simplified', data_dict)
object.__setattr__(obj, '_sto... | [
"def",
"restore",
"(",
"cls",
",",
"data_dict",
")",
":",
"obj",
"=",
"cls",
".",
"__new__",
"(",
"cls",
")",
"# Avoid calling constructor",
"object",
".",
"__setattr__",
"(",
"obj",
",",
"'_simplified'",
",",
"data_dict",
")",
"object",
".",
"__setattr__",
... | Restore from previously simplified data. Data is supposed to be valid,
no checks are performed! | [
"Restore",
"from",
"previously",
"simplified",
"data",
".",
"Data",
"is",
"supposed",
"to",
"be",
"valid",
"no",
"checks",
"are",
"performed!"
] | 8b7b91c097ecc57232871137db6135c71fc33a9e | https://github.com/PushAMP/strictdict3/blob/8b7b91c097ecc57232871137db6135c71fc33a9e/strictdict/strictbase/strictdict.py#L197-L205 |
250,157 | daknuett/py_register_machine2 | engine_tools/output/gpu_alike/http.py | HTTPOutputServer.interrupt | def interrupt(self):
"""
Invoked by the renderering.Renderer, if the image has changed.
"""
self.image = io.BytesIO()
self.renderer.screen.save(self.image, "png") | python | def interrupt(self):
"""
Invoked by the renderering.Renderer, if the image has changed.
"""
self.image = io.BytesIO()
self.renderer.screen.save(self.image, "png") | [
"def",
"interrupt",
"(",
"self",
")",
":",
"self",
".",
"image",
"=",
"io",
".",
"BytesIO",
"(",
")",
"self",
".",
"renderer",
".",
"screen",
".",
"save",
"(",
"self",
".",
"image",
",",
"\"png\"",
")"
] | Invoked by the renderering.Renderer, if the image has changed. | [
"Invoked",
"by",
"the",
"renderering",
".",
"Renderer",
"if",
"the",
"image",
"has",
"changed",
"."
] | 599c53cd7576297d0d7a53344ed5d9aa98acc751 | https://github.com/daknuett/py_register_machine2/blob/599c53cd7576297d0d7a53344ed5d9aa98acc751/engine_tools/output/gpu_alike/http.py#L49-L54 |
250,158 | jut-io/jut-python-tools | jut/config.py | show | def show():
"""
print the available configurations directly to stdout
"""
if not is_configured():
raise JutException('No configurations available, please run: `jut config add`')
info('Available jut configurations:')
index = 0
for configuration in _CONFIG.sections():
usernam... | python | def show():
"""
print the available configurations directly to stdout
"""
if not is_configured():
raise JutException('No configurations available, please run: `jut config add`')
info('Available jut configurations:')
index = 0
for configuration in _CONFIG.sections():
usernam... | [
"def",
"show",
"(",
")",
":",
"if",
"not",
"is_configured",
"(",
")",
":",
"raise",
"JutException",
"(",
"'No configurations available, please run: `jut config add`'",
")",
"info",
"(",
"'Available jut configurations:'",
")",
"index",
"=",
"0",
"for",
"configuration",... | print the available configurations directly to stdout | [
"print",
"the",
"available",
"configurations",
"directly",
"to",
"stdout"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L41-L67 |
250,159 | jut-io/jut-python-tools | jut/config.py | set_default | def set_default(name=None, index=None):
"""
set the default configuration by name
"""
default_was_set = False
count = 1
for configuration in _CONFIG.sections():
if index != None:
if count == index:
_CONFIG.set(configuration, 'default', True)
... | python | def set_default(name=None, index=None):
"""
set the default configuration by name
"""
default_was_set = False
count = 1
for configuration in _CONFIG.sections():
if index != None:
if count == index:
_CONFIG.set(configuration, 'default', True)
... | [
"def",
"set_default",
"(",
"name",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"default_was_set",
"=",
"False",
"count",
"=",
"1",
"for",
"configuration",
"in",
"_CONFIG",
".",
"sections",
"(",
")",
":",
"if",
"index",
"!=",
"None",
":",
"if",
... | set the default configuration by name | [
"set",
"the",
"default",
"configuration",
"by",
"name"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L78-L109 |
250,160 | jut-io/jut-python-tools | jut/config.py | add | def add(name, **kwargs):
"""
add a new configuration with the name specified and all of the keywords
as attributes of that configuration.
"""
_CONFIG.add_section(name)
for (key, value) in kwargs.items():
_CONFIG.set(name, key, value)
with open(_CONFIG_FILEPATH, 'w') as configfile:... | python | def add(name, **kwargs):
"""
add a new configuration with the name specified and all of the keywords
as attributes of that configuration.
"""
_CONFIG.add_section(name)
for (key, value) in kwargs.items():
_CONFIG.set(name, key, value)
with open(_CONFIG_FILEPATH, 'w') as configfile:... | [
"def",
"add",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"_CONFIG",
".",
"add_section",
"(",
"name",
")",
"for",
"(",
"key",
",",
"value",
")",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"_CONFIG",
".",
"set",
"(",
"name",
",",
"key",
",... | add a new configuration with the name specified and all of the keywords
as attributes of that configuration. | [
"add",
"a",
"new",
"configuration",
"with",
"the",
"name",
"specified",
"and",
"all",
"of",
"the",
"keywords",
"as",
"attributes",
"of",
"that",
"configuration",
"."
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L116-L130 |
250,161 | jut-io/jut-python-tools | jut/config.py | get_default | def get_default():
"""
return the attributes associated with the default configuration
"""
if not is_configured():
raise JutException('No configurations available, please run `jut config add`')
for configuration in _CONFIG.sections():
if _CONFIG.has_option(configuration, 'default'... | python | def get_default():
"""
return the attributes associated with the default configuration
"""
if not is_configured():
raise JutException('No configurations available, please run `jut config add`')
for configuration in _CONFIG.sections():
if _CONFIG.has_option(configuration, 'default'... | [
"def",
"get_default",
"(",
")",
":",
"if",
"not",
"is_configured",
"(",
")",
":",
"raise",
"JutException",
"(",
"'No configurations available, please run `jut config add`'",
")",
"for",
"configuration",
"in",
"_CONFIG",
".",
"sections",
"(",
")",
":",
"if",
"_CONF... | return the attributes associated with the default configuration | [
"return",
"the",
"attributes",
"associated",
"with",
"the",
"default",
"configuration"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L133-L144 |
250,162 | jut-io/jut-python-tools | jut/config.py | remove | def remove(name=None, index=None):
"""
remove the specified configuration
"""
removed = False
count = 1
for configuration in _CONFIG.sections():
if index != None:
if count == index:
_CONFIG.remove_section(configuration)
removed = True
... | python | def remove(name=None, index=None):
"""
remove the specified configuration
"""
removed = False
count = 1
for configuration in _CONFIG.sections():
if index != None:
if count == index:
_CONFIG.remove_section(configuration)
removed = True
... | [
"def",
"remove",
"(",
"name",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"removed",
"=",
"False",
"count",
"=",
"1",
"for",
"configuration",
"in",
"_CONFIG",
".",
"sections",
"(",
")",
":",
"if",
"index",
"!=",
"None",
":",
"if",
"count",
"=... | remove the specified configuration | [
"remove",
"the",
"specified",
"configuration"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L147-L174 |
250,163 | jut-io/jut-python-tools | jut/config.py | is_default | def is_default(name=None, index=None):
"""
returns True if the specified configuration is the default one
"""
if not is_configured():
raise JutException('No configurations available, please run `jut config add`')
count = 1
for configuration in _CONFIG.sections():
if index != ... | python | def is_default(name=None, index=None):
"""
returns True if the specified configuration is the default one
"""
if not is_configured():
raise JutException('No configurations available, please run `jut config add`')
count = 1
for configuration in _CONFIG.sections():
if index != ... | [
"def",
"is_default",
"(",
"name",
"=",
"None",
",",
"index",
"=",
"None",
")",
":",
"if",
"not",
"is_configured",
"(",
")",
":",
"raise",
"JutException",
"(",
"'No configurations available, please run `jut config add`'",
")",
"count",
"=",
"1",
"for",
"configura... | returns True if the specified configuration is the default one | [
"returns",
"True",
"if",
"the",
"specified",
"configuration",
"is",
"the",
"default",
"one"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/config.py#L177-L199 |
250,164 | eeue56/PyChat.js | pychatjs/server/room.py | Room.disconnect | def disconnect(self, user):
""" Disconnect a user and send a message to the
connected clients """
self.remove_user(user)
self.send_message(create_message('RoomServer', 'Please all say goodbye to {name}!'.format(name=user.id.name)))
self.send_message(create_disconnect(user.id... | python | def disconnect(self, user):
""" Disconnect a user and send a message to the
connected clients """
self.remove_user(user)
self.send_message(create_message('RoomServer', 'Please all say goodbye to {name}!'.format(name=user.id.name)))
self.send_message(create_disconnect(user.id... | [
"def",
"disconnect",
"(",
"self",
",",
"user",
")",
":",
"self",
".",
"remove_user",
"(",
"user",
")",
"self",
".",
"send_message",
"(",
"create_message",
"(",
"'RoomServer'",
",",
"'Please all say goodbye to {name}!'",
".",
"format",
"(",
"name",
"=",
"user",... | Disconnect a user and send a message to the
connected clients | [
"Disconnect",
"a",
"user",
"and",
"send",
"a",
"message",
"to",
"the",
"connected",
"clients"
] | 45056de6f988350c90a6dbe674459a4affde8abc | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/room.py#L21-L26 |
250,165 | eeue56/PyChat.js | pychatjs/server/room.py | Room.get_user | def get_user(self, username):
""" gets a user with given username if connected """
for user in self.users:
if user.id.name == username:
return user
return None | python | def get_user(self, username):
""" gets a user with given username if connected """
for user in self.users:
if user.id.name == username:
return user
return None | [
"def",
"get_user",
"(",
"self",
",",
"username",
")",
":",
"for",
"user",
"in",
"self",
".",
"users",
":",
"if",
"user",
".",
"id",
".",
"name",
"==",
"username",
":",
"return",
"user",
"return",
"None"
] | gets a user with given username if connected | [
"gets",
"a",
"user",
"with",
"given",
"username",
"if",
"connected"
] | 45056de6f988350c90a6dbe674459a4affde8abc | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/room.py#L28-L33 |
250,166 | eeue56/PyChat.js | pychatjs/server/room.py | Room.send_message | def send_message(self, message):
""" send a message to each of the users """
for handler in self.users:
logging.info('Handler: ' + str(handler))
handler.write_message(message) | python | def send_message(self, message):
""" send a message to each of the users """
for handler in self.users:
logging.info('Handler: ' + str(handler))
handler.write_message(message) | [
"def",
"send_message",
"(",
"self",
",",
"message",
")",
":",
"for",
"handler",
"in",
"self",
".",
"users",
":",
"logging",
".",
"info",
"(",
"'Handler: '",
"+",
"str",
"(",
"handler",
")",
")",
"handler",
".",
"write_message",
"(",
"message",
")"
] | send a message to each of the users | [
"send",
"a",
"message",
"to",
"each",
"of",
"the",
"users"
] | 45056de6f988350c90a6dbe674459a4affde8abc | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/room.py#L50-L54 |
250,167 | eeue56/PyChat.js | pychatjs/server/room.py | Room.welcome | def welcome(self, user):
""" welcomes a user to the roomserver """
self.send_message(create_message('RoomServer', 'Please welcome {name} to the server!\nThere are currently {i} users online -\n {r}\n'.format(name=user.id,
i=self.amount_of_users_connected,
... | python | def welcome(self, user):
""" welcomes a user to the roomserver """
self.send_message(create_message('RoomServer', 'Please welcome {name} to the server!\nThere are currently {i} users online -\n {r}\n'.format(name=user.id,
i=self.amount_of_users_connected,
... | [
"def",
"welcome",
"(",
"self",
",",
"user",
")",
":",
"self",
".",
"send_message",
"(",
"create_message",
"(",
"'RoomServer'",
",",
"'Please welcome {name} to the server!\\nThere are currently {i} users online -\\n {r}\\n'",
".",
"format",
"(",
"name",
"=",
"user",
".",... | welcomes a user to the roomserver | [
"welcomes",
"a",
"user",
"to",
"the",
"roomserver"
] | 45056de6f988350c90a6dbe674459a4affde8abc | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/room.py#L56-L61 |
250,168 | tomokinakamaru/mapletree | mapletree/defaults/request/validators.py | float_range | def float_range(string, minimum, maximum, inf, sup):
""" Requires values to be a number and range in a certain range.
:param string: Value to validate
:param minimum: Minimum value to accept
:param maximum: Maximum value to accept
:param inf: Infimum value to accept
:param sup: Supremum value t... | python | def float_range(string, minimum, maximum, inf, sup):
""" Requires values to be a number and range in a certain range.
:param string: Value to validate
:param minimum: Minimum value to accept
:param maximum: Maximum value to accept
:param inf: Infimum value to accept
:param sup: Supremum value t... | [
"def",
"float_range",
"(",
"string",
",",
"minimum",
",",
"maximum",
",",
"inf",
",",
"sup",
")",
":",
"return",
"_inrange",
"(",
"float",
"(",
"string",
")",
",",
"minimum",
",",
"maximum",
",",
"inf",
",",
"sup",
")"
] | Requires values to be a number and range in a certain range.
:param string: Value to validate
:param minimum: Minimum value to accept
:param maximum: Maximum value to accept
:param inf: Infimum value to accept
:param sup: Supremum value to accept
:type string: str
:type minimum: float
:... | [
"Requires",
"values",
"to",
"be",
"a",
"number",
"and",
"range",
"in",
"a",
"certain",
"range",
"."
] | 19ec68769ef2c1cd2e4164ed8623e0c4280279bb | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/validators.py#L56-L70 |
250,169 | tomokinakamaru/mapletree | mapletree/defaults/request/validators.py | length_range | def length_range(string, minimum, maximum):
""" Requires values' length to be in a certain range.
:param string: Value to validate
:param minimum: Minimum length to accept
:param maximum: Maximum length to accept
:type string: str
:type minimum: int
:type maximum: int
"""
int_range(... | python | def length_range(string, minimum, maximum):
""" Requires values' length to be in a certain range.
:param string: Value to validate
:param minimum: Minimum length to accept
:param maximum: Maximum length to accept
:type string: str
:type minimum: int
:type maximum: int
"""
int_range(... | [
"def",
"length_range",
"(",
"string",
",",
"minimum",
",",
"maximum",
")",
":",
"int_range",
"(",
"len",
"(",
"string",
")",
",",
"minimum",
",",
"maximum",
")",
"return",
"string"
] | Requires values' length to be in a certain range.
:param string: Value to validate
:param minimum: Minimum length to accept
:param maximum: Maximum length to accept
:type string: str
:type minimum: int
:type maximum: int | [
"Requires",
"values",
"length",
"to",
"be",
"in",
"a",
"certain",
"range",
"."
] | 19ec68769ef2c1cd2e4164ed8623e0c4280279bb | https://github.com/tomokinakamaru/mapletree/blob/19ec68769ef2c1cd2e4164ed8623e0c4280279bb/mapletree/defaults/request/validators.py#L127-L138 |
250,170 | kcolford/txt2boil | txt2boil/core/gen.py | _Gen.collectTriggers | def collectTriggers(self, rgx, code):
"""Return a dictionary of triggers and their corresponding matches
from the code.
"""
return {m.group(0): m for m in re.finditer(rgx, code)} | python | def collectTriggers(self, rgx, code):
"""Return a dictionary of triggers and their corresponding matches
from the code.
"""
return {m.group(0): m for m in re.finditer(rgx, code)} | [
"def",
"collectTriggers",
"(",
"self",
",",
"rgx",
",",
"code",
")",
":",
"return",
"{",
"m",
".",
"group",
"(",
"0",
")",
":",
"m",
"for",
"m",
"in",
"re",
".",
"finditer",
"(",
"rgx",
",",
"code",
")",
"}"
] | Return a dictionary of triggers and their corresponding matches
from the code. | [
"Return",
"a",
"dictionary",
"of",
"triggers",
"and",
"their",
"corresponding",
"matches",
"from",
"the",
"code",
"."
] | 853a47bb8db27c0224531f24dfd02839c983d027 | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/gen.py#L30-L36 |
250,171 | kcolford/txt2boil | txt2boil/core/gen.py | _Gen.genOutputs | def genOutputs(self, code, match):
"""Return a list out template outputs based on the triggers found in
the code and the template they create.
"""
out = sorted((k, match.output(m)) for (k, m) in
self.collectTriggers(match.match, code).items())
out = list(ma... | python | def genOutputs(self, code, match):
"""Return a list out template outputs based on the triggers found in
the code and the template they create.
"""
out = sorted((k, match.output(m)) for (k, m) in
self.collectTriggers(match.match, code).items())
out = list(ma... | [
"def",
"genOutputs",
"(",
"self",
",",
"code",
",",
"match",
")",
":",
"out",
"=",
"sorted",
"(",
"(",
"k",
",",
"match",
".",
"output",
"(",
"m",
")",
")",
"for",
"(",
"k",
",",
"m",
")",
"in",
"self",
".",
"collectTriggers",
"(",
"match",
"."... | Return a list out template outputs based on the triggers found in
the code and the template they create. | [
"Return",
"a",
"list",
"out",
"template",
"outputs",
"based",
"on",
"the",
"triggers",
"found",
"in",
"the",
"code",
"and",
"the",
"template",
"they",
"create",
"."
] | 853a47bb8db27c0224531f24dfd02839c983d027 | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/gen.py#L38-L47 |
250,172 | kcolford/txt2boil | txt2boil/core/gen.py | _Gen.gen | def gen(self, text, start=0):
"""Return the source code in text, filled with autogenerated code
starting at start.
"""
for cc in self.chunkComment(text, start):
c = self.extractChunkContent(cc)
cc = ''.join(cc)
m = self.matchComment(c)
id... | python | def gen(self, text, start=0):
"""Return the source code in text, filled with autogenerated code
starting at start.
"""
for cc in self.chunkComment(text, start):
c = self.extractChunkContent(cc)
cc = ''.join(cc)
m = self.matchComment(c)
id... | [
"def",
"gen",
"(",
"self",
",",
"text",
",",
"start",
"=",
"0",
")",
":",
"for",
"cc",
"in",
"self",
".",
"chunkComment",
"(",
"text",
",",
"start",
")",
":",
"c",
"=",
"self",
".",
"extractChunkContent",
"(",
"cc",
")",
"cc",
"=",
"''",
".",
"... | Return the source code in text, filled with autogenerated code
starting at start. | [
"Return",
"the",
"source",
"code",
"in",
"text",
"filled",
"with",
"autogenerated",
"code",
"starting",
"at",
"start",
"."
] | 853a47bb8db27c0224531f24dfd02839c983d027 | https://github.com/kcolford/txt2boil/blob/853a47bb8db27c0224531f24dfd02839c983d027/txt2boil/core/gen.py#L49-L74 |
250,173 | pjuren/pyokit | src/pyokit/statistics/beta.py | beta_pdf | def beta_pdf(x, a, b):
"""Beta distirbution probability density function."""
bc = 1 / beta(a, b)
fc = x ** (a - 1)
sc = (1 - x) ** (b - 1)
return bc * fc * sc | python | def beta_pdf(x, a, b):
"""Beta distirbution probability density function."""
bc = 1 / beta(a, b)
fc = x ** (a - 1)
sc = (1 - x) ** (b - 1)
return bc * fc * sc | [
"def",
"beta_pdf",
"(",
"x",
",",
"a",
",",
"b",
")",
":",
"bc",
"=",
"1",
"/",
"beta",
"(",
"a",
",",
"b",
")",
"fc",
"=",
"x",
"**",
"(",
"a",
"-",
"1",
")",
"sc",
"=",
"(",
"1",
"-",
"x",
")",
"**",
"(",
"b",
"-",
"1",
")",
"retu... | Beta distirbution probability density function. | [
"Beta",
"distirbution",
"probability",
"density",
"function",
"."
] | fddae123b5d817daa39496183f19c000d9c3791f | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/statistics/beta.py#L110-L115 |
250,174 | limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin.has_field | def has_field(cls, field_name):
"""
Check if the current class has a field with the name "field_name"
Add management of dynamic fields, to return True if the name matches an
existing dynamic field without existing copy for this name.
"""
if super(ModelWithDynamicFieldMixi... | python | def has_field(cls, field_name):
"""
Check if the current class has a field with the name "field_name"
Add management of dynamic fields, to return True if the name matches an
existing dynamic field without existing copy for this name.
"""
if super(ModelWithDynamicFieldMixi... | [
"def",
"has_field",
"(",
"cls",
",",
"field_name",
")",
":",
"if",
"super",
"(",
"ModelWithDynamicFieldMixin",
",",
"cls",
")",
".",
"has_field",
"(",
"field_name",
")",
":",
"return",
"True",
"try",
":",
"cls",
".",
"_get_dynamic_field_for",
"(",
"field_nam... | Check if the current class has a field with the name "field_name"
Add management of dynamic fields, to return True if the name matches an
existing dynamic field without existing copy for this name. | [
"Check",
"if",
"the",
"current",
"class",
"has",
"a",
"field",
"with",
"the",
"name",
"field_name",
"Add",
"management",
"of",
"dynamic",
"fields",
"to",
"return",
"True",
"if",
"the",
"name",
"matches",
"an",
"existing",
"dynamic",
"field",
"without",
"exis... | 13f34e39efd2f802761457da30ab2a4213b63934 | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L49-L63 |
250,175 | limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin._add_dynamic_field_to_model | def _add_dynamic_field_to_model(cls, field, field_name):
"""
Add a copy of the DynamicField "field" to the current class and its
subclasses using the "field_name" name
"""
# create the new field
new_field = field._create_dynamic_version()
new_field.name = field_na... | python | def _add_dynamic_field_to_model(cls, field, field_name):
"""
Add a copy of the DynamicField "field" to the current class and its
subclasses using the "field_name" name
"""
# create the new field
new_field = field._create_dynamic_version()
new_field.name = field_na... | [
"def",
"_add_dynamic_field_to_model",
"(",
"cls",
",",
"field",
",",
"field_name",
")",
":",
"# create the new field",
"new_field",
"=",
"field",
".",
"_create_dynamic_version",
"(",
")",
"new_field",
".",
"name",
"=",
"field_name",
"new_field",
".",
"_attach_to_mod... | Add a copy of the DynamicField "field" to the current class and its
subclasses using the "field_name" name | [
"Add",
"a",
"copy",
"of",
"the",
"DynamicField",
"field",
"to",
"the",
"current",
"class",
"and",
"its",
"subclasses",
"using",
"the",
"field_name",
"name"
] | 13f34e39efd2f802761457da30ab2a4213b63934 | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L102-L127 |
250,176 | limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin._add_dynamic_field_to_instance | def _add_dynamic_field_to_instance(self, field, field_name):
"""
Add a copy of the DynamicField "field" to the current instance using the
"field_name" name
"""
# create the new field
new_field = field._create_dynamic_version()
new_field.name = field_name
n... | python | def _add_dynamic_field_to_instance(self, field, field_name):
"""
Add a copy of the DynamicField "field" to the current instance using the
"field_name" name
"""
# create the new field
new_field = field._create_dynamic_version()
new_field.name = field_name
n... | [
"def",
"_add_dynamic_field_to_instance",
"(",
"self",
",",
"field",
",",
"field_name",
")",
":",
"# create the new field",
"new_field",
"=",
"field",
".",
"_create_dynamic_version",
"(",
")",
"new_field",
".",
"name",
"=",
"field_name",
"new_field",
".",
"_attach_to... | Add a copy of the DynamicField "field" to the current instance using the
"field_name" name | [
"Add",
"a",
"copy",
"of",
"the",
"DynamicField",
"field",
"to",
"the",
"current",
"instance",
"using",
"the",
"field_name",
"name"
] | 13f34e39efd2f802761457da30ab2a4213b63934 | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L129-L157 |
250,177 | limpyd/redis-limpyd-extensions | limpyd_extensions/dynamic/model.py | ModelWithDynamicFieldMixin.get_field_name_for | def get_field_name_for(cls, field_name, dynamic_part):
"""
Given the name of a dynamic field, and a dynamic part, return the
name of the final dynamic field to use. It will then be used with
get_field.
"""
field = cls.get_field(field_name)
return field.get_name_fo... | python | def get_field_name_for(cls, field_name, dynamic_part):
"""
Given the name of a dynamic field, and a dynamic part, return the
name of the final dynamic field to use. It will then be used with
get_field.
"""
field = cls.get_field(field_name)
return field.get_name_fo... | [
"def",
"get_field_name_for",
"(",
"cls",
",",
"field_name",
",",
"dynamic_part",
")",
":",
"field",
"=",
"cls",
".",
"get_field",
"(",
"field_name",
")",
"return",
"field",
".",
"get_name_for",
"(",
"dynamic_part",
")"
] | Given the name of a dynamic field, and a dynamic part, return the
name of the final dynamic field to use. It will then be used with
get_field. | [
"Given",
"the",
"name",
"of",
"a",
"dynamic",
"field",
"and",
"a",
"dynamic",
"part",
"return",
"the",
"name",
"of",
"the",
"final",
"dynamic",
"field",
"to",
"use",
".",
"It",
"will",
"then",
"be",
"used",
"with",
"get_field",
"."
] | 13f34e39efd2f802761457da30ab2a4213b63934 | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/dynamic/model.py#L160-L167 |
250,178 | heikomuller/sco-datastore | scodata/image.py | get_image_files | def get_image_files(directory, files):
"""Recursively iterate through directory tree and list all files that have a
valid image file suffix
Parameters
----------
directory : directory
Path to directory on disk
files : List(string)
List of file names
Returns
-------
... | python | def get_image_files(directory, files):
"""Recursively iterate through directory tree and list all files that have a
valid image file suffix
Parameters
----------
directory : directory
Path to directory on disk
files : List(string)
List of file names
Returns
-------
... | [
"def",
"get_image_files",
"(",
"directory",
",",
"files",
")",
":",
"# For each file in the directory test if it is a valid image file or a",
"# sub-directory.",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
":",
"abs_file",
"=",
"os",
".",
"path",
... | Recursively iterate through directory tree and list all files that have a
valid image file suffix
Parameters
----------
directory : directory
Path to directory on disk
files : List(string)
List of file names
Returns
-------
List(string)
List of files that have a... | [
"Recursively",
"iterate",
"through",
"directory",
"tree",
"and",
"list",
"all",
"files",
"that",
"have",
"a",
"valid",
"image",
"file",
"suffix"
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L879-L906 |
250,179 | heikomuller/sco-datastore | scodata/image.py | DefaultImageManager.create_object | def create_object(self, filename, img_properties=None):
"""Create an image object on local disk from the given file. The file
is copied to a new local directory that is created for the image object.
The optional list of image properties will be associated with the new
object together wit... | python | def create_object(self, filename, img_properties=None):
"""Create an image object on local disk from the given file. The file
is copied to a new local directory that is created for the image object.
The optional list of image properties will be associated with the new
object together wit... | [
"def",
"create_object",
"(",
"self",
",",
"filename",
",",
"img_properties",
"=",
"None",
")",
":",
"# Get the file name, i.e., last component of the given absolute path",
"prop_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"os",
".",
"path",
".",
"normpath",... | Create an image object on local disk from the given file. The file
is copied to a new local directory that is created for the image object.
The optional list of image properties will be associated with the new
object together with the set of default properties for images.
Parameters
... | [
"Create",
"an",
"image",
"object",
"on",
"local",
"disk",
"from",
"the",
"given",
"file",
".",
"The",
"file",
"is",
"copied",
"to",
"a",
"new",
"local",
"directory",
"that",
"is",
"created",
"for",
"the",
"image",
"object",
".",
"The",
"optional",
"list"... | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L327-L384 |
250,180 | heikomuller/sco-datastore | scodata/image.py | DefaultImageManager.from_dict | def from_dict(self, document):
"""Create image object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageHandle
Handle for image object
"""
# Ge... | python | def from_dict(self, document):
"""Create image object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageHandle
Handle for image object
"""
# Ge... | [
"def",
"from_dict",
"(",
"self",
",",
"document",
")",
":",
"# Get object properties from Json document",
"identifier",
"=",
"str",
"(",
"document",
"[",
"'_id'",
"]",
")",
"active",
"=",
"document",
"[",
"'active'",
"]",
"timestamp",
"=",
"datetime",
".",
"da... | Create image object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageHandle
Handle for image object | [
"Create",
"image",
"object",
"from",
"JSON",
"document",
"retrieved",
"from",
"database",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L386-L408 |
250,181 | heikomuller/sco-datastore | scodata/image.py | DefaultImageManager.get_directory | def get_directory(self, identifier):
"""Implements the policy for naming directories for image objects. Image
object directories are name by their identifier. In addition, these
directories are grouped in parent directories named by the first two
characters of the identifier. The aim is ... | python | def get_directory(self, identifier):
"""Implements the policy for naming directories for image objects. Image
object directories are name by their identifier. In addition, these
directories are grouped in parent directories named by the first two
characters of the identifier. The aim is ... | [
"def",
"get_directory",
"(",
"self",
",",
"identifier",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"directory",
",",
"identifier",
"[",
":",
"2",
"]",
")",
",",
"identifier",
")"
] | Implements the policy for naming directories for image objects. Image
object directories are name by their identifier. In addition, these
directories are grouped in parent directories named by the first two
characters of the identifier. The aim is to avoid having too many
sub-folders in ... | [
"Implements",
"the",
"policy",
"for",
"naming",
"directories",
"for",
"image",
"objects",
".",
"Image",
"object",
"directories",
"are",
"name",
"by",
"their",
"identifier",
".",
"In",
"addition",
"these",
"directories",
"are",
"grouped",
"in",
"parent",
"directo... | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L410-L430 |
250,182 | heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.create_object | def create_object(self, name, images, filename, options=None, object_identifier=None, read_only=False):
"""Create an image group object with the given list of images. The
file name specifies the location on local disk where the tar-file
containing the image group files is located. The file will ... | python | def create_object(self, name, images, filename, options=None, object_identifier=None, read_only=False):
"""Create an image group object with the given list of images. The
file name specifies the location on local disk where the tar-file
containing the image group files is located. The file will ... | [
"def",
"create_object",
"(",
"self",
",",
"name",
",",
"images",
",",
"filename",
",",
"options",
"=",
"None",
",",
"object_identifier",
"=",
"None",
",",
"read_only",
"=",
"False",
")",
":",
"# Raise an exception if given image group is not valied.",
"self",
".",... | Create an image group object with the given list of images. The
file name specifies the location on local disk where the tar-file
containing the image group files is located. The file will be copied
to the image groups data directory.
Parameters
----------
name : string
... | [
"Create",
"an",
"image",
"group",
"object",
"with",
"the",
"given",
"list",
"of",
"images",
".",
"The",
"file",
"name",
"specifies",
"the",
"location",
"on",
"local",
"disk",
"where",
"the",
"tar",
"-",
"file",
"containing",
"the",
"image",
"group",
"files... | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L545-L610 |
250,183 | heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.from_dict | def from_dict(self, document):
"""Create image group object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageGroupHandle
Handle for image group object
... | python | def from_dict(self, document):
"""Create image group object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageGroupHandle
Handle for image group object
... | [
"def",
"from_dict",
"(",
"self",
",",
"document",
")",
":",
"# Get object attributes from Json document",
"identifier",
"=",
"str",
"(",
"document",
"[",
"'_id'",
"]",
")",
"# Create list of group images from Json",
"images",
"=",
"list",
"(",
")",
"for",
"grp_image... | Create image group object from JSON document retrieved from database.
Parameters
----------
document : JSON
Json document in database
Returns
-------
ImageGroupHandle
Handle for image group object | [
"Create",
"image",
"group",
"object",
"from",
"JSON",
"document",
"retrieved",
"from",
"database",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L612-L656 |
250,184 | heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.get_collections_for_image | def get_collections_for_image(self, image_id):
"""Get identifier of all collections that contain a given image.
Parameters
----------
image_id : string
Unique identifierof image object
Returns
-------
List(string)
List of image collection... | python | def get_collections_for_image(self, image_id):
"""Get identifier of all collections that contain a given image.
Parameters
----------
image_id : string
Unique identifierof image object
Returns
-------
List(string)
List of image collection... | [
"def",
"get_collections_for_image",
"(",
"self",
",",
"image_id",
")",
":",
"result",
"=",
"[",
"]",
"# Get all active collections that contain the image identifier",
"for",
"document",
"in",
"self",
".",
"collection",
".",
"find",
"(",
"{",
"'active'",
":",
"True",... | Get identifier of all collections that contain a given image.
Parameters
----------
image_id : string
Unique identifierof image object
Returns
-------
List(string)
List of image collection identifier | [
"Get",
"identifier",
"of",
"all",
"collections",
"that",
"contain",
"a",
"given",
"image",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L658-L675 |
250,185 | heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.to_dict | def to_dict(self, img_coll):
"""Create a Json-like dictionary for image group. Extends the basic
object with an array of image identifiers.
Parameters
----------
img_coll : ImageGroupHandle
Returns
-------
(JSON)
Json-like object, i.e., dicti... | python | def to_dict(self, img_coll):
"""Create a Json-like dictionary for image group. Extends the basic
object with an array of image identifiers.
Parameters
----------
img_coll : ImageGroupHandle
Returns
-------
(JSON)
Json-like object, i.e., dicti... | [
"def",
"to_dict",
"(",
"self",
",",
"img_coll",
")",
":",
"# Get the basic Json object from the super class",
"json_obj",
"=",
"super",
"(",
"DefaultImageGroupManager",
",",
"self",
")",
".",
"to_dict",
"(",
"img_coll",
")",
"# Add list of images as Json array",
"images... | Create a Json-like dictionary for image group. Extends the basic
object with an array of image identifiers.
Parameters
----------
img_coll : ImageGroupHandle
Returns
-------
(JSON)
Json-like object, i.e., dictionary. | [
"Create",
"a",
"Json",
"-",
"like",
"dictionary",
"for",
"image",
"group",
".",
"Extends",
"the",
"basic",
"object",
"with",
"an",
"array",
"of",
"image",
"identifiers",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L711-L738 |
250,186 | heikomuller/sco-datastore | scodata/image.py | DefaultImageGroupManager.validate_group | def validate_group(images):
"""Validates that the combination of folder and name for all images in
a group is unique. Raises a ValueError exception if uniqueness
constraint is violated.
Parameters
----------
images : List(GroupImage)
List of images in group
... | python | def validate_group(images):
"""Validates that the combination of folder and name for all images in
a group is unique. Raises a ValueError exception if uniqueness
constraint is violated.
Parameters
----------
images : List(GroupImage)
List of images in group
... | [
"def",
"validate_group",
"(",
"images",
")",
":",
"image_ids",
"=",
"set",
"(",
")",
"for",
"image",
"in",
"images",
":",
"key",
"=",
"image",
".",
"folder",
"+",
"image",
".",
"name",
"if",
"key",
"in",
"image_ids",
":",
"raise",
"ValueError",
"(",
... | Validates that the combination of folder and name for all images in
a group is unique. Raises a ValueError exception if uniqueness
constraint is violated.
Parameters
----------
images : List(GroupImage)
List of images in group | [
"Validates",
"that",
"the",
"combination",
"of",
"folder",
"and",
"name",
"for",
"all",
"images",
"in",
"a",
"group",
"is",
"unique",
".",
"Raises",
"a",
"ValueError",
"exception",
"if",
"uniqueness",
"constraint",
"is",
"violated",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L771-L787 |
250,187 | heikomuller/sco-datastore | scodata/image.py | DefaultPredictionImageSetManager.create_object | def create_object(self, name, image_sets):
"""Create a prediction image set list.
Parameters
----------
name : string
User-provided name for the image group.
image_sets : list(PredictionImageSet)
List of prediction image sets
Returns
----... | python | def create_object(self, name, image_sets):
"""Create a prediction image set list.
Parameters
----------
name : string
User-provided name for the image group.
image_sets : list(PredictionImageSet)
List of prediction image sets
Returns
----... | [
"def",
"create_object",
"(",
"self",
",",
"name",
",",
"image_sets",
")",
":",
"# Create a new object identifier",
"identifier",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
".",
"replace",
"(",
"'-'",
",",
"''",
")",
"properties",
"=",
"{",
"da... | Create a prediction image set list.
Parameters
----------
name : string
User-provided name for the image group.
image_sets : list(PredictionImageSet)
List of prediction image sets
Returns
-------
PredictionImageSetHandle
Objec... | [
"Create",
"a",
"prediction",
"image",
"set",
"list",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L806-L828 |
250,188 | heikomuller/sco-datastore | scodata/image.py | DefaultPredictionImageSetManager.from_dict | def from_dict(self, document):
"""Create a prediction image set resource from a dictionary
serialization.
Parameters
----------
document : dict
Dictionary serialization of the resource
Returns
-------
PredictionImageSetHandle
Hand... | python | def from_dict(self, document):
"""Create a prediction image set resource from a dictionary
serialization.
Parameters
----------
document : dict
Dictionary serialization of the resource
Returns
-------
PredictionImageSetHandle
Hand... | [
"def",
"from_dict",
"(",
"self",
",",
"document",
")",
":",
"return",
"PredictionImageSetHandle",
"(",
"str",
"(",
"document",
"[",
"'_id'",
"]",
")",
",",
"document",
"[",
"'properties'",
"]",
",",
"[",
"PredictionImageSet",
".",
"from_dict",
"(",
"img",
... | Create a prediction image set resource from a dictionary
serialization.
Parameters
----------
document : dict
Dictionary serialization of the resource
Returns
-------
PredictionImageSetHandle
Handle for prediction image sets | [
"Create",
"a",
"prediction",
"image",
"set",
"resource",
"from",
"a",
"dictionary",
"serialization",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L830-L853 |
250,189 | heikomuller/sco-datastore | scodata/image.py | DefaultPredictionImageSetManager.to_dict | def to_dict(self, img_sets):
"""Create a dictionary serialization for a prediction image set handle.
Parameters
----------
img_sets : PredictionImageSetHandle
Returns
-------
dict
Dictionary serialization of the resource
"""
# Get the... | python | def to_dict(self, img_sets):
"""Create a dictionary serialization for a prediction image set handle.
Parameters
----------
img_sets : PredictionImageSetHandle
Returns
-------
dict
Dictionary serialization of the resource
"""
# Get the... | [
"def",
"to_dict",
"(",
"self",
",",
"img_sets",
")",
":",
"# Get the basic Json object from the super class",
"json_obj",
"=",
"super",
"(",
"DefaultPredictionImageSetManager",
",",
"self",
")",
".",
"to_dict",
"(",
"img_sets",
")",
"# Add list of image sets as Json array... | Create a dictionary serialization for a prediction image set handle.
Parameters
----------
img_sets : PredictionImageSetHandle
Returns
-------
dict
Dictionary serialization of the resource | [
"Create",
"a",
"dictionary",
"serialization",
"for",
"a",
"prediction",
"image",
"set",
"handle",
"."
] | 7180a6b51150667e47629da566aedaa742e39342 | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/image.py#L855-L871 |
250,190 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/play.py | Play._load_tasks | def _load_tasks(self, tasks, vars={}, additional_conditions=[]):
''' handle task and handler include statements '''
results = []
if tasks is None:
# support empty handler files, and the like.
tasks = []
for x in tasks:
task_vars = self.vars.copy()
... | python | def _load_tasks(self, tasks, vars={}, additional_conditions=[]):
''' handle task and handler include statements '''
results = []
if tasks is None:
# support empty handler files, and the like.
tasks = []
for x in tasks:
task_vars = self.vars.copy()
... | [
"def",
"_load_tasks",
"(",
"self",
",",
"tasks",
",",
"vars",
"=",
"{",
"}",
",",
"additional_conditions",
"=",
"[",
"]",
")",
":",
"results",
"=",
"[",
"]",
"if",
"tasks",
"is",
"None",
":",
"# support empty handler files, and the like.",
"tasks",
"=",
"[... | handle task and handler include statements | [
"handle",
"task",
"and",
"handler",
"include",
"statements"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/play.py#L100-L152 |
250,191 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/play.py | Play._get_vars | def _get_vars(self):
''' load the vars section from a play, accounting for all sorts of variable features
including loading from yaml files, prompting, and conditional includes of the first
file found in a list. '''
if self.vars is None:
self.vars = {}
if type(self.... | python | def _get_vars(self):
''' load the vars section from a play, accounting for all sorts of variable features
including loading from yaml files, prompting, and conditional includes of the first
file found in a list. '''
if self.vars is None:
self.vars = {}
if type(self.... | [
"def",
"_get_vars",
"(",
"self",
")",
":",
"if",
"self",
".",
"vars",
"is",
"None",
":",
"self",
".",
"vars",
"=",
"{",
"}",
"if",
"type",
"(",
"self",
".",
"vars",
")",
"not",
"in",
"[",
"dict",
",",
"list",
"]",
":",
"raise",
"errors",
".",
... | load the vars section from a play, accounting for all sorts of variable features
including loading from yaml files, prompting, and conditional includes of the first
file found in a list. | [
"load",
"the",
"vars",
"section",
"from",
"a",
"play",
"accounting",
"for",
"all",
"sorts",
"of",
"variable",
"features",
"including",
"loading",
"from",
"yaml",
"files",
"prompting",
"and",
"conditional",
"includes",
"of",
"the",
"first",
"file",
"found",
"in... | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/play.py#L166-L225 |
250,192 | FreshXOpenSource/wallaby-frontend-qt | wallaby/FXUI.py | key_event_to_name | def key_event_to_name(event):
""" Converts a keystroke event into a corresponding key name.
"""
key_code = event.key()
modifiers = event.modifiers()
if modifiers & QtCore.Qt.KeypadModifier:
key = keypad_map.get(key_code)
else:
key = None
if key is None:
key = key_map.... | python | def key_event_to_name(event):
""" Converts a keystroke event into a corresponding key name.
"""
key_code = event.key()
modifiers = event.modifiers()
if modifiers & QtCore.Qt.KeypadModifier:
key = keypad_map.get(key_code)
else:
key = None
if key is None:
key = key_map.... | [
"def",
"key_event_to_name",
"(",
"event",
")",
":",
"key_code",
"=",
"event",
".",
"key",
"(",
")",
"modifiers",
"=",
"event",
".",
"modifiers",
"(",
")",
"if",
"modifiers",
"&",
"QtCore",
".",
"Qt",
".",
"KeypadModifier",
":",
"key",
"=",
"keypad_map",
... | Converts a keystroke event into a corresponding key name. | [
"Converts",
"a",
"keystroke",
"event",
"into",
"a",
"corresponding",
"key",
"name",
"."
] | eee70d0ec4ce34827f62a1654e28dbff8a8afb1a | https://github.com/FreshXOpenSource/wallaby-frontend-qt/blob/eee70d0ec4ce34827f62a1654e28dbff8a8afb1a/wallaby/FXUI.py#L253-L282 |
250,193 | KelSolaar/Oncilla | oncilla/libraries/python/pyclbr.py | readmodule | def readmodule(module, path=None):
'''Backwards compatible interface.
Call readmodule_ex() and then only keep Class objects from the
resulting dictionary.'''
res = {}
for key, value in _readmodule(module, path or []).items():
if isinstance(value, Class):
res[key] = value
re... | python | def readmodule(module, path=None):
'''Backwards compatible interface.
Call readmodule_ex() and then only keep Class objects from the
resulting dictionary.'''
res = {}
for key, value in _readmodule(module, path or []).items():
if isinstance(value, Class):
res[key] = value
re... | [
"def",
"readmodule",
"(",
"module",
",",
"path",
"=",
"None",
")",
":",
"res",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"_readmodule",
"(",
"module",
",",
"path",
"or",
"[",
"]",
")",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
... | Backwards compatible interface.
Call readmodule_ex() and then only keep Class objects from the
resulting dictionary. | [
"Backwards",
"compatible",
"interface",
"."
] | 2b4db3704cf2c22a09a207681cb041fff555a994 | https://github.com/KelSolaar/Oncilla/blob/2b4db3704cf2c22a09a207681cb041fff555a994/oncilla/libraries/python/pyclbr.py#L97-L107 |
250,194 | ojake/django-tracked-model | tracked_model/serializer.py | _basic_field_data | def _basic_field_data(field, obj):
"""Returns ``obj.field`` data as a dict"""
value = field.value_from_object(obj)
return {Field.TYPE: FieldType.VAL, Field.VALUE: value} | python | def _basic_field_data(field, obj):
"""Returns ``obj.field`` data as a dict"""
value = field.value_from_object(obj)
return {Field.TYPE: FieldType.VAL, Field.VALUE: value} | [
"def",
"_basic_field_data",
"(",
"field",
",",
"obj",
")",
":",
"value",
"=",
"field",
".",
"value_from_object",
"(",
"obj",
")",
"return",
"{",
"Field",
".",
"TYPE",
":",
"FieldType",
".",
"VAL",
",",
"Field",
".",
"VALUE",
":",
"value",
"}"
] | Returns ``obj.field`` data as a dict | [
"Returns",
"obj",
".",
"field",
"data",
"as",
"a",
"dict"
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L9-L12 |
250,195 | ojake/django-tracked-model | tracked_model/serializer.py | _related_field_data | def _related_field_data(field, obj):
"""Returns relation ``field`` as a dict.
Dict contains related pk info and some meta information
for reconstructing objects.
"""
data = _basic_field_data(field, obj)
relation_info = {
Field.REL_DB_TABLE: field.rel.to._meta.db_table,
Field.REL... | python | def _related_field_data(field, obj):
"""Returns relation ``field`` as a dict.
Dict contains related pk info and some meta information
for reconstructing objects.
"""
data = _basic_field_data(field, obj)
relation_info = {
Field.REL_DB_TABLE: field.rel.to._meta.db_table,
Field.REL... | [
"def",
"_related_field_data",
"(",
"field",
",",
"obj",
")",
":",
"data",
"=",
"_basic_field_data",
"(",
"field",
",",
"obj",
")",
"relation_info",
"=",
"{",
"Field",
".",
"REL_DB_TABLE",
":",
"field",
".",
"rel",
".",
"to",
".",
"_meta",
".",
"db_table"... | Returns relation ``field`` as a dict.
Dict contains related pk info and some meta information
for reconstructing objects. | [
"Returns",
"relation",
"field",
"as",
"a",
"dict",
"."
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L15-L29 |
250,196 | ojake/django-tracked-model | tracked_model/serializer.py | _m2m_field_data | def _m2m_field_data(field, obj):
"""Returns m2m ``field`` as a dict.
Value is an array of related primary keys and some meta information
for reconstructing objects.
"""
data = _basic_field_data(field, obj)
data[Field.TYPE] = FieldType.M2M
related = field.rel.to
relation_info = {
... | python | def _m2m_field_data(field, obj):
"""Returns m2m ``field`` as a dict.
Value is an array of related primary keys and some meta information
for reconstructing objects.
"""
data = _basic_field_data(field, obj)
data[Field.TYPE] = FieldType.M2M
related = field.rel.to
relation_info = {
... | [
"def",
"_m2m_field_data",
"(",
"field",
",",
"obj",
")",
":",
"data",
"=",
"_basic_field_data",
"(",
"field",
",",
"obj",
")",
"data",
"[",
"Field",
".",
"TYPE",
"]",
"=",
"FieldType",
".",
"M2M",
"related",
"=",
"field",
".",
"rel",
".",
"to",
"rela... | Returns m2m ``field`` as a dict.
Value is an array of related primary keys and some meta information
for reconstructing objects. | [
"Returns",
"m2m",
"field",
"as",
"a",
"dict",
"."
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L32-L50 |
250,197 | ojake/django-tracked-model | tracked_model/serializer.py | dump_model | def dump_model(obj):
"""Returns ``obj`` as a dict.
Returnded dic has a form of:
{
'field_name': {
'type': `FieldType`,
'value': field value,
# if field is a relation, it also has:
'rel': {
'db_table': model db table,
'a... | python | def dump_model(obj):
"""Returns ``obj`` as a dict.
Returnded dic has a form of:
{
'field_name': {
'type': `FieldType`,
'value': field value,
# if field is a relation, it also has:
'rel': {
'db_table': model db table,
'a... | [
"def",
"dump_model",
"(",
"obj",
")",
":",
"data",
"=",
"{",
"}",
"for",
"field",
"in",
"obj",
".",
"_meta",
".",
"fields",
":",
"if",
"isinstance",
"(",
"field",
",",
"RELATED_FIELDS",
")",
":",
"field_data",
"=",
"_related_field_data",
"(",
"field",
... | Returns ``obj`` as a dict.
Returnded dic has a form of:
{
'field_name': {
'type': `FieldType`,
'value': field value,
# if field is a relation, it also has:
'rel': {
'db_table': model db table,
'app_label': model app label,
... | [
"Returns",
"obj",
"as",
"a",
"dict",
"."
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L53-L83 |
250,198 | ojake/django-tracked-model | tracked_model/serializer.py | restore_model | def restore_model(cls, data):
"""Returns instance of ``cls`` with attributed loaded
from ``data`` dict.
"""
obj = cls()
for field in data:
setattr(obj, field, data[field][Field.VALUE])
return obj | python | def restore_model(cls, data):
"""Returns instance of ``cls`` with attributed loaded
from ``data`` dict.
"""
obj = cls()
for field in data:
setattr(obj, field, data[field][Field.VALUE])
return obj | [
"def",
"restore_model",
"(",
"cls",
",",
"data",
")",
":",
"obj",
"=",
"cls",
"(",
")",
"for",
"field",
"in",
"data",
":",
"setattr",
"(",
"obj",
",",
"field",
",",
"data",
"[",
"field",
"]",
"[",
"Field",
".",
"VALUE",
"]",
")",
"return",
"obj"
... | Returns instance of ``cls`` with attributed loaded
from ``data`` dict. | [
"Returns",
"instance",
"of",
"cls",
"with",
"attributed",
"loaded",
"from",
"data",
"dict",
"."
] | 19bc48874dd2e5fb5defedc6b8c5c3915cce1424 | https://github.com/ojake/django-tracked-model/blob/19bc48874dd2e5fb5defedc6b8c5c3915cce1424/tracked_model/serializer.py#L86-L94 |
250,199 | refinery29/chassis | chassis/services/cache.py | retrieve_object | def retrieve_object(cache, template, indexes):
"""Retrieve an object from Redis using a pipeline.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string interpolation format.... | python | def retrieve_object(cache, template, indexes):
"""Retrieve an object from Redis using a pipeline.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string interpolation format.... | [
"def",
"retrieve_object",
"(",
"cache",
",",
"template",
",",
"indexes",
")",
":",
"keys",
"=",
"[",
"]",
"with",
"cache",
"as",
"redis_connection",
":",
"pipe",
"=",
"redis_connection",
".",
"pipeline",
"(",
")",
"for",
"(",
"result_key",
",",
"redis_key_... | Retrieve an object from Redis using a pipeline.
Arguments:
template: a dictionary containg the keys for the object and
template strings for the corresponding redis keys. The template
string uses named string interpolation format. Example:
{
'username': '... | [
"Retrieve",
"an",
"object",
"from",
"Redis",
"using",
"a",
"pipeline",
"."
] | 1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192 | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/services/cache.py#L43-L82 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.