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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
51,900 | wharris/dougrain | dougrain/link.py | Link.url | def url(self, **kwargs):
"""Returns a URL for the link with optional template expansion.
If the link is marked as templated, the href will be expanded according
to RFC6570, using template variables provided in the keyword arguments.
If the href is a valid URI Template, but the link is n... | python | def url(self, **kwargs):
"""Returns a URL for the link with optional template expansion.
If the link is marked as templated, the href will be expanded according
to RFC6570, using template variables provided in the keyword arguments.
If the href is a valid URI Template, but the link is n... | [
"def",
"url",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"is_templated",
":",
"return",
"uritemplate",
".",
"expand",
"(",
"self",
".",
"template",
",",
"kwargs",
")",
"else",
":",
"return",
"self",
".",
"template"
] | Returns a URL for the link with optional template expansion.
If the link is marked as templated, the href will be expanded according
to RFC6570, using template variables provided in the keyword arguments.
If the href is a valid URI Template, but the link is not marked as
templated, the ... | [
"Returns",
"a",
"URL",
"for",
"the",
"link",
"with",
"optional",
"template",
"expansion",
"."
] | 45062a1562fc34793e40c6253a93aa91eb4cf855 | https://github.com/wharris/dougrain/blob/45062a1562fc34793e40c6253a93aa91eb4cf855/dougrain/link.py#L91-L104 |
51,901 | wharris/dougrain | dougrain/link.py | Link.from_object | def from_object(cls, o, base_uri):
"""Returns a new ``Link`` based on a JSON object or array.
Arguments:
- ``o``: a dictionary holding the deserializated JSON for the new
``Link``, or a ``list`` of such documents.
- ``base_uri``: optional URL used as the basis when exp... | python | def from_object(cls, o, base_uri):
"""Returns a new ``Link`` based on a JSON object or array.
Arguments:
- ``o``: a dictionary holding the deserializated JSON for the new
``Link``, or a ``list`` of such documents.
- ``base_uri``: optional URL used as the basis when exp... | [
"def",
"from_object",
"(",
"cls",
",",
"o",
",",
"base_uri",
")",
":",
"if",
"isinstance",
"(",
"o",
",",
"list",
")",
":",
"if",
"len",
"(",
"o",
")",
"==",
"1",
":",
"return",
"cls",
".",
"from_object",
"(",
"o",
"[",
"0",
"]",
",",
"base_uri... | Returns a new ``Link`` based on a JSON object or array.
Arguments:
- ``o``: a dictionary holding the deserializated JSON for the new
``Link``, or a ``list`` of such documents.
- ``base_uri``: optional URL used as the basis when expanding
relative... | [
"Returns",
"a",
"new",
"Link",
"based",
"on",
"a",
"JSON",
"object",
"or",
"array",
"."
] | 45062a1562fc34793e40c6253a93aa91eb4cf855 | https://github.com/wharris/dougrain/blob/45062a1562fc34793e40c6253a93aa91eb4cf855/dougrain/link.py#L119-L136 |
51,902 | dgomes/pymediaroom | pymediaroom/notify.py | install_mediaroom_protocol | async def install_mediaroom_protocol(responses_callback, box_ip=None):
"""Install an asyncio protocol to process NOTIFY messages."""
from . import version
_LOGGER.debug(version)
loop = asyncio.get_event_loop()
mediaroom_protocol = MediaroomProtocol(responses_callback, box_ip)
sock = create_so... | python | async def install_mediaroom_protocol(responses_callback, box_ip=None):
"""Install an asyncio protocol to process NOTIFY messages."""
from . import version
_LOGGER.debug(version)
loop = asyncio.get_event_loop()
mediaroom_protocol = MediaroomProtocol(responses_callback, box_ip)
sock = create_so... | [
"async",
"def",
"install_mediaroom_protocol",
"(",
"responses_callback",
",",
"box_ip",
"=",
"None",
")",
":",
"from",
".",
"import",
"version",
"_LOGGER",
".",
"debug",
"(",
"version",
")",
"loop",
"=",
"asyncio",
".",
"get_event_loop",
"(",
")",
"mediaroom_p... | Install an asyncio protocol to process NOTIFY messages. | [
"Install",
"an",
"asyncio",
"protocol",
"to",
"process",
"NOTIFY",
"messages",
"."
] | f4f2686c8d5622dd5ae1bcdd76900ba35e148529 | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L170-L183 |
51,903 | dgomes/pymediaroom | pymediaroom/notify.py | MediaroomNotify.tune | def tune(self):
"""XML node representing tune."""
if self._node.get('activities'):
tune = self._node['activities'].get('tune')
if type(tune) is collections.OrderedDict:
return tune
elif type(tune) is list:
return tune[0]
ret... | python | def tune(self):
"""XML node representing tune."""
if self._node.get('activities'):
tune = self._node['activities'].get('tune')
if type(tune) is collections.OrderedDict:
return tune
elif type(tune) is list:
return tune[0]
ret... | [
"def",
"tune",
"(",
"self",
")",
":",
"if",
"self",
".",
"_node",
".",
"get",
"(",
"'activities'",
")",
":",
"tune",
"=",
"self",
".",
"_node",
"[",
"'activities'",
"]",
".",
"get",
"(",
"'tune'",
")",
"if",
"type",
"(",
"tune",
")",
"is",
"colle... | XML node representing tune. | [
"XML",
"node",
"representing",
"tune",
"."
] | f4f2686c8d5622dd5ae1bcdd76900ba35e148529 | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L60-L69 |
51,904 | dgomes/pymediaroom | pymediaroom/notify.py | MediaroomNotify.stopped | def stopped(self):
"""Return if the stream is stopped."""
if self.tune and self.tune.get('@stopped'):
return True if self.tune.get('@stopped') == 'true' else False
else:
raise PyMediaroomError("No information in <node> about @stopped") | python | def stopped(self):
"""Return if the stream is stopped."""
if self.tune and self.tune.get('@stopped'):
return True if self.tune.get('@stopped') == 'true' else False
else:
raise PyMediaroomError("No information in <node> about @stopped") | [
"def",
"stopped",
"(",
"self",
")",
":",
"if",
"self",
".",
"tune",
"and",
"self",
".",
"tune",
".",
"get",
"(",
"'@stopped'",
")",
":",
"return",
"True",
"if",
"self",
".",
"tune",
".",
"get",
"(",
"'@stopped'",
")",
"==",
"'true'",
"else",
"False... | Return if the stream is stopped. | [
"Return",
"if",
"the",
"stream",
"is",
"stopped",
"."
] | f4f2686c8d5622dd5ae1bcdd76900ba35e148529 | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L72-L77 |
51,905 | dgomes/pymediaroom | pymediaroom/notify.py | MediaroomNotify.timeshift | def timeshift(self):
"""Return if the stream is a timeshift."""
if self.tune and self.tune.get('@src'):
return True if self.tune.get('@src').startswith('timeshift') else False
else:
raise PyMediaroomError("No information in <node> about @src") | python | def timeshift(self):
"""Return if the stream is a timeshift."""
if self.tune and self.tune.get('@src'):
return True if self.tune.get('@src').startswith('timeshift') else False
else:
raise PyMediaroomError("No information in <node> about @src") | [
"def",
"timeshift",
"(",
"self",
")",
":",
"if",
"self",
".",
"tune",
"and",
"self",
".",
"tune",
".",
"get",
"(",
"'@src'",
")",
":",
"return",
"True",
"if",
"self",
".",
"tune",
".",
"get",
"(",
"'@src'",
")",
".",
"startswith",
"(",
"'timeshift'... | Return if the stream is a timeshift. | [
"Return",
"if",
"the",
"stream",
"is",
"a",
"timeshift",
"."
] | f4f2686c8d5622dd5ae1bcdd76900ba35e148529 | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L80-L85 |
51,906 | dgomes/pymediaroom | pymediaroom/notify.py | MediaroomNotify.recorded | def recorded(self):
"""Return if the stream is a recording."""
if self.tune and self.tune.get('@src'):
return True if self.tune.get('@src').startswith('mbr') else False
else:
raise PyMediaroomError("No information in <node> about @src") | python | def recorded(self):
"""Return if the stream is a recording."""
if self.tune and self.tune.get('@src'):
return True if self.tune.get('@src').startswith('mbr') else False
else:
raise PyMediaroomError("No information in <node> about @src") | [
"def",
"recorded",
"(",
"self",
")",
":",
"if",
"self",
".",
"tune",
"and",
"self",
".",
"tune",
".",
"get",
"(",
"'@src'",
")",
":",
"return",
"True",
"if",
"self",
".",
"tune",
".",
"get",
"(",
"'@src'",
")",
".",
"startswith",
"(",
"'mbr'",
")... | Return if the stream is a recording. | [
"Return",
"if",
"the",
"stream",
"is",
"a",
"recording",
"."
] | f4f2686c8d5622dd5ae1bcdd76900ba35e148529 | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L88-L93 |
51,907 | dgomes/pymediaroom | pymediaroom/notify.py | MediaroomNotify.device_uuid | def device_uuid(self):
"""Return device UUID."""
if self._device:
return self._device
return GEN_ID_FORMAT.format(self.src_ip) | python | def device_uuid(self):
"""Return device UUID."""
if self._device:
return self._device
return GEN_ID_FORMAT.format(self.src_ip) | [
"def",
"device_uuid",
"(",
"self",
")",
":",
"if",
"self",
".",
"_device",
":",
"return",
"self",
".",
"_device",
"return",
"GEN_ID_FORMAT",
".",
"format",
"(",
"self",
".",
"src_ip",
")"
] | Return device UUID. | [
"Return",
"device",
"UUID",
"."
] | f4f2686c8d5622dd5ae1bcdd76900ba35e148529 | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L101-L105 |
51,908 | dgomes/pymediaroom | pymediaroom/notify.py | MediaroomProtocol.datagram_received | def datagram_received(self, data, addr):
"""Datagram received callback."""
#_LOGGER.debug(data)
if not self.box_ip or self.box_ip == addr[0]:
self.responses(MediaroomNotify(addr, data)) | python | def datagram_received(self, data, addr):
"""Datagram received callback."""
#_LOGGER.debug(data)
if not self.box_ip or self.box_ip == addr[0]:
self.responses(MediaroomNotify(addr, data)) | [
"def",
"datagram_received",
"(",
"self",
",",
"data",
",",
"addr",
")",
":",
"#_LOGGER.debug(data)",
"if",
"not",
"self",
".",
"box_ip",
"or",
"self",
".",
"box_ip",
"==",
"addr",
"[",
"0",
"]",
":",
"self",
".",
"responses",
"(",
"MediaroomNotify",
"(",... | Datagram received callback. | [
"Datagram",
"received",
"callback",
"."
] | f4f2686c8d5622dd5ae1bcdd76900ba35e148529 | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L150-L154 |
51,909 | dgomes/pymediaroom | pymediaroom/notify.py | MediaroomProtocol.error_received | def error_received(self, exception):
"""Datagram error callback."""
if exception is None:
pass
else:
import pprint
pprint.pprint(exception)
_LOGGER.error('Error received: %s', exception) | python | def error_received(self, exception):
"""Datagram error callback."""
if exception is None:
pass
else:
import pprint
pprint.pprint(exception)
_LOGGER.error('Error received: %s', exception) | [
"def",
"error_received",
"(",
"self",
",",
"exception",
")",
":",
"if",
"exception",
"is",
"None",
":",
"pass",
"else",
":",
"import",
"pprint",
"pprint",
".",
"pprint",
"(",
"exception",
")",
"_LOGGER",
".",
"error",
"(",
"'Error received: %s'",
",",
"exc... | Datagram error callback. | [
"Datagram",
"error",
"callback",
"."
] | f4f2686c8d5622dd5ae1bcdd76900ba35e148529 | https://github.com/dgomes/pymediaroom/blob/f4f2686c8d5622dd5ae1bcdd76900ba35e148529/pymediaroom/notify.py#L156-L163 |
51,910 | bububa/pyTOP | pyTOP/user.py | User.refresh_session | def refresh_session(self, sessionkey, refresh_token=None):
'''
Refresh Session Token
'''
if not refresh_token:
refresh_token = sessionkey
params = {
'appkey' : self.API_KEY,
'sessionkey' : sessionkey,
'refresh_token': refresh_token... | python | def refresh_session(self, sessionkey, refresh_token=None):
'''
Refresh Session Token
'''
if not refresh_token:
refresh_token = sessionkey
params = {
'appkey' : self.API_KEY,
'sessionkey' : sessionkey,
'refresh_token': refresh_token... | [
"def",
"refresh_session",
"(",
"self",
",",
"sessionkey",
",",
"refresh_token",
"=",
"None",
")",
":",
"if",
"not",
"refresh_token",
":",
"refresh_token",
"=",
"sessionkey",
"params",
"=",
"{",
"'appkey'",
":",
"self",
".",
"API_KEY",
",",
"'sessionkey'",
":... | Refresh Session Token | [
"Refresh",
"Session",
"Token"
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/user.py#L115-L138 |
51,911 | dschreij/python-mediadecoder | mediadecoder/timer.py | Timer.pause | def pause(self):
""" Pauses the clock to continue running later.
Saves the duration of the current interval in the previous_intervals
list."""
if self.status == RUNNING:
self.status = PAUSED
self.previous_intervals.append(time.time() - self.interval_start)
self.current_interval_duration = 0.0
elif s... | python | def pause(self):
""" Pauses the clock to continue running later.
Saves the duration of the current interval in the previous_intervals
list."""
if self.status == RUNNING:
self.status = PAUSED
self.previous_intervals.append(time.time() - self.interval_start)
self.current_interval_duration = 0.0
elif s... | [
"def",
"pause",
"(",
"self",
")",
":",
"if",
"self",
".",
"status",
"==",
"RUNNING",
":",
"self",
".",
"status",
"=",
"PAUSED",
"self",
".",
"previous_intervals",
".",
"append",
"(",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"interval_start",
... | Pauses the clock to continue running later.
Saves the duration of the current interval in the previous_intervals
list. | [
"Pauses",
"the",
"clock",
"to",
"continue",
"running",
"later",
".",
"Saves",
"the",
"duration",
"of",
"the",
"current",
"interval",
"in",
"the",
"previous_intervals",
"list",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/mediadecoder/timer.py#L47-L57 |
51,912 | dschreij/python-mediadecoder | mediadecoder/timer.py | Timer.start | def start(self):
""" Starts the clock from 0.
Uses a separate thread to handle the timing functionalities. """
if not hasattr(self,"thread") or not self.thread.isAlive():
self.thread = threading.Thread(target=self.__run)
self.status = RUNNING
self.reset()
self.thread.start()
else:
print("Clock a... | python | def start(self):
""" Starts the clock from 0.
Uses a separate thread to handle the timing functionalities. """
if not hasattr(self,"thread") or not self.thread.isAlive():
self.thread = threading.Thread(target=self.__run)
self.status = RUNNING
self.reset()
self.thread.start()
else:
print("Clock a... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"thread\"",
")",
"or",
"not",
"self",
".",
"thread",
".",
"isAlive",
"(",
")",
":",
"self",
".",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self... | Starts the clock from 0.
Uses a separate thread to handle the timing functionalities. | [
"Starts",
"the",
"clock",
"from",
"0",
".",
"Uses",
"a",
"separate",
"thread",
"to",
"handle",
"the",
"timing",
"functionalities",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/mediadecoder/timer.py#L59-L68 |
51,913 | dschreij/python-mediadecoder | mediadecoder/timer.py | Timer.__run | def __run(self):
""" Internal function that is run in a separate thread. Do not call
directly. """
self.interval_start = time.time()
while self.status != STOPPED:
if self.status == RUNNING:
self.current_interval_duration = time.time() - self.interval_start
# If max_duration is set, stop the clock if... | python | def __run(self):
""" Internal function that is run in a separate thread. Do not call
directly. """
self.interval_start = time.time()
while self.status != STOPPED:
if self.status == RUNNING:
self.current_interval_duration = time.time() - self.interval_start
# If max_duration is set, stop the clock if... | [
"def",
"__run",
"(",
"self",
")",
":",
"self",
".",
"interval_start",
"=",
"time",
".",
"time",
"(",
")",
"while",
"self",
".",
"status",
"!=",
"STOPPED",
":",
"if",
"self",
".",
"status",
"==",
"RUNNING",
":",
"self",
".",
"current_interval_duration",
... | Internal function that is run in a separate thread. Do not call
directly. | [
"Internal",
"function",
"that",
"is",
"run",
"in",
"a",
"separate",
"thread",
".",
"Do",
"not",
"call",
"directly",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/mediadecoder/timer.py#L70-L83 |
51,914 | dschreij/python-mediadecoder | mediadecoder/timer.py | Timer.current_frame | def current_frame(self):
""" The current frame number that should be displayed."""
if not self.__fps:
raise RuntimeError("fps not set so current frame number cannot be"
" calculated")
else:
return int(self.__fps * self.time) | python | def current_frame(self):
""" The current frame number that should be displayed."""
if not self.__fps:
raise RuntimeError("fps not set so current frame number cannot be"
" calculated")
else:
return int(self.__fps * self.time) | [
"def",
"current_frame",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__fps",
":",
"raise",
"RuntimeError",
"(",
"\"fps not set so current frame number cannot be\"",
"\" calculated\"",
")",
"else",
":",
"return",
"int",
"(",
"self",
".",
"__fps",
"*",
"self"... | The current frame number that should be displayed. | [
"The",
"current",
"frame",
"number",
"that",
"should",
"be",
"displayed",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/mediadecoder/timer.py#L116-L122 |
51,915 | dschreij/python-mediadecoder | mediadecoder/timer.py | Timer.fps | def fps(self,value):
""" Sets the frames per second of the current movie the clock is used for.
Parameters
----------
value : float
The fps value.
"""
if not value is None:
if not type(value) == float:
raise ValueError("fps needs to be specified as a float")
if value<1.0:
raise ValueError(... | python | def fps(self,value):
""" Sets the frames per second of the current movie the clock is used for.
Parameters
----------
value : float
The fps value.
"""
if not value is None:
if not type(value) == float:
raise ValueError("fps needs to be specified as a float")
if value<1.0:
raise ValueError(... | [
"def",
"fps",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
"is",
"None",
":",
"if",
"not",
"type",
"(",
"value",
")",
"==",
"float",
":",
"raise",
"ValueError",
"(",
"\"fps needs to be specified as a float\"",
")",
"if",
"value",
"<",
"1.0"... | Sets the frames per second of the current movie the clock is used for.
Parameters
----------
value : float
The fps value. | [
"Sets",
"the",
"frames",
"per",
"second",
"of",
"the",
"current",
"movie",
"the",
"clock",
"is",
"used",
"for",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/mediadecoder/timer.py#L139-L152 |
51,916 | dschreij/python-mediadecoder | mediadecoder/timer.py | Timer.max_duration | def max_duration(self,value):
""" Sets the value of max duration
Parameters
----------
value : float
The value for max_duration
Raises
------
TypeError
If max_duration is not a number.
ValueError
If max_duration is smaller than 0.
"""
if not value is None:
if not type(value) in [float,... | python | def max_duration(self,value):
""" Sets the value of max duration
Parameters
----------
value : float
The value for max_duration
Raises
------
TypeError
If max_duration is not a number.
ValueError
If max_duration is smaller than 0.
"""
if not value is None:
if not type(value) in [float,... | [
"def",
"max_duration",
"(",
"self",
",",
"value",
")",
":",
"if",
"not",
"value",
"is",
"None",
":",
"if",
"not",
"type",
"(",
"value",
")",
"in",
"[",
"float",
",",
"int",
"]",
":",
"raise",
"TypeError",
"(",
"\"max_duration needs to be specified as a num... | Sets the value of max duration
Parameters
----------
value : float
The value for max_duration
Raises
------
TypeError
If max_duration is not a number.
ValueError
If max_duration is smaller than 0. | [
"Sets",
"the",
"value",
"of",
"max",
"duration"
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/mediadecoder/timer.py#L161-L182 |
51,917 | danilobellini/dose | dose/shared.py | get_shared | def get_shared(fname, encoding="utf-8"):
"""
Loads the string data from a text file that was packaged as a
data file in the distribution.
Uses the setuptools ``pkg_resources.resource_string`` function as
a fallback, as installing Dose with it directly instead of using
wheel/pip would store the ... | python | def get_shared(fname, encoding="utf-8"):
"""
Loads the string data from a text file that was packaged as a
data file in the distribution.
Uses the setuptools ``pkg_resources.resource_string`` function as
a fallback, as installing Dose with it directly instead of using
wheel/pip would store the ... | [
"def",
"get_shared",
"(",
"fname",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"relative_path",
"=",
"\"share/dose/v{0}/{1}\"",
".",
"format",
"(",
"__version__",
",",
"fname",
")",
"prefixed_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sys",
".",
"p... | Loads the string data from a text file that was packaged as a
data file in the distribution.
Uses the setuptools ``pkg_resources.resource_string`` function as
a fallback, as installing Dose with it directly instead of using
wheel/pip would store the setup.py ``data_files`` otherwhere. For
more info... | [
"Loads",
"the",
"string",
"data",
"from",
"a",
"text",
"file",
"that",
"was",
"packaged",
"as",
"a",
"data",
"file",
"in",
"the",
"distribution",
"."
] | 141f48322f7812b7d32e3d5f065d4473a11102a4 | https://github.com/danilobellini/dose/blob/141f48322f7812b7d32e3d5f065d4473a11102a4/dose/shared.py#L8-L45 |
51,918 | kentwait/nxsim | nxsim/agents.py | BaseAgent.get_agents | def get_agents(self, state_id=None, limit_neighbors=False):
"""Returns list of agents based on their state and connectedness
Parameters
----------
state_id : int, str, or array-like, optional
Used to select agents that have the same specified "state". If state = None, return... | python | def get_agents(self, state_id=None, limit_neighbors=False):
"""Returns list of agents based on their state and connectedness
Parameters
----------
state_id : int, str, or array-like, optional
Used to select agents that have the same specified "state". If state = None, return... | [
"def",
"get_agents",
"(",
"self",
",",
"state_id",
"=",
"None",
",",
"limit_neighbors",
"=",
"False",
")",
":",
"if",
"limit_neighbors",
":",
"agents",
"=",
"self",
".",
"global_topology",
".",
"neighbors",
"(",
"self",
".",
"id",
")",
"else",
":",
"agen... | Returns list of agents based on their state and connectedness
Parameters
----------
state_id : int, str, or array-like, optional
Used to select agents that have the same specified "state". If state = None, returns all agents regardless
of its current state
limit_... | [
"Returns",
"list",
"of",
"agents",
"based",
"on",
"their",
"state",
"and",
"connectedness"
] | 88090d8099e574bc6fd1d24734cfa205ecce4c1d | https://github.com/kentwait/nxsim/blob/88090d8099e574bc6fd1d24734cfa205ecce4c1d/nxsim/agents.py#L57-L78 |
51,919 | kentwait/nxsim | nxsim/agents.py | BaseEnvironmentAgent.add_node | def add_node(self, agent_type=None, state=None, name='network_process', **state_params):
"""Add a new node to the current network
Parameters
----------
agent_type : NetworkAgent subclass
Agent in the new node will be instantiated using this agent class
state : object... | python | def add_node(self, agent_type=None, state=None, name='network_process', **state_params):
"""Add a new node to the current network
Parameters
----------
agent_type : NetworkAgent subclass
Agent in the new node will be instantiated using this agent class
state : object... | [
"def",
"add_node",
"(",
"self",
",",
"agent_type",
"=",
"None",
",",
"state",
"=",
"None",
",",
"name",
"=",
"'network_process'",
",",
"*",
"*",
"state_params",
")",
":",
"agent_id",
"=",
"int",
"(",
"len",
"(",
"self",
".",
"global_topology",
".",
"no... | Add a new node to the current network
Parameters
----------
agent_type : NetworkAgent subclass
Agent in the new node will be instantiated using this agent class
state : object
State of the Agent, this may be an integer or string or any other
name : str, o... | [
"Add",
"a",
"new",
"node",
"to",
"the",
"current",
"network"
] | 88090d8099e574bc6fd1d24734cfa205ecce4c1d | https://github.com/kentwait/nxsim/blob/88090d8099e574bc6fd1d24734cfa205ecce4c1d/nxsim/agents.py#L139-L161 |
51,920 | kentwait/nxsim | nxsim/agents.py | BaseEnvironmentAgent.add_edge | def add_edge(self, agent_id1, agent_id2, edge_attr_dict=None, *edge_attrs):
"""
Add an edge between agent_id1 and agent_id2. agent_id1 and agent_id2 correspond to Networkx node IDs.
This is a wrapper for the Networkx.Graph method `.add_edge`.
Agents agent_id1 and agent_id2 will be auto... | python | def add_edge(self, agent_id1, agent_id2, edge_attr_dict=None, *edge_attrs):
"""
Add an edge between agent_id1 and agent_id2. agent_id1 and agent_id2 correspond to Networkx node IDs.
This is a wrapper for the Networkx.Graph method `.add_edge`.
Agents agent_id1 and agent_id2 will be auto... | [
"def",
"add_edge",
"(",
"self",
",",
"agent_id1",
",",
"agent_id2",
",",
"edge_attr_dict",
"=",
"None",
",",
"*",
"edge_attrs",
")",
":",
"if",
"agent_id1",
"in",
"self",
".",
"global_topology",
".",
"nodes",
"(",
"data",
"=",
"False",
")",
":",
"if",
... | Add an edge between agent_id1 and agent_id2. agent_id1 and agent_id2 correspond to Networkx node IDs.
This is a wrapper for the Networkx.Graph method `.add_edge`.
Agents agent_id1 and agent_id2 will be automatically added if they are not already present in the graph.
Edge attributes can be spe... | [
"Add",
"an",
"edge",
"between",
"agent_id1",
"and",
"agent_id2",
".",
"agent_id1",
"and",
"agent_id2",
"correspond",
"to",
"Networkx",
"node",
"IDs",
"."
] | 88090d8099e574bc6fd1d24734cfa205ecce4c1d | https://github.com/kentwait/nxsim/blob/88090d8099e574bc6fd1d24734cfa205ecce4c1d/nxsim/agents.py#L164-L189 |
51,921 | bububa/pyTOP | pyTOP/packages/requests/packages/urllib3/connectionpool.py | HTTPConnectionPool._make_request | def _make_request(self, conn, method, url, timeout=_Default,
**httplib_request_kw):
"""
Perform a request on a given httplib connection object taken from our
pool.
"""
self.num_requests += 1
if timeout is _Default:
timeout = self.timeout... | python | def _make_request(self, conn, method, url, timeout=_Default,
**httplib_request_kw):
"""
Perform a request on a given httplib connection object taken from our
pool.
"""
self.num_requests += 1
if timeout is _Default:
timeout = self.timeout... | [
"def",
"_make_request",
"(",
"self",
",",
"conn",
",",
"method",
",",
"url",
",",
"timeout",
"=",
"_Default",
",",
"*",
"*",
"httplib_request_kw",
")",
":",
"self",
".",
"num_requests",
"+=",
"1",
"if",
"timeout",
"is",
"_Default",
":",
"timeout",
"=",
... | Perform a request on a given httplib connection object taken from our
pool. | [
"Perform",
"a",
"request",
"on",
"a",
"given",
"httplib",
"connection",
"object",
"taken",
"from",
"our",
"pool",
"."
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/packages/urllib3/connectionpool.py#L202-L222 |
51,922 | bububa/pyTOP | pyTOP/packages/requests/packages/urllib3/connectionpool.py | HTTPConnectionPool.is_same_host | def is_same_host(self, url):
"""
Check if the given ``url`` is a member of the same host as this
conncetion pool.
"""
# TODO: Add optional support for socket.gethostbyname checking.
return (url.startswith('/') or
get_host(url) == (self.scheme, self.host, s... | python | def is_same_host(self, url):
"""
Check if the given ``url`` is a member of the same host as this
conncetion pool.
"""
# TODO: Add optional support for socket.gethostbyname checking.
return (url.startswith('/') or
get_host(url) == (self.scheme, self.host, s... | [
"def",
"is_same_host",
"(",
"self",
",",
"url",
")",
":",
"# TODO: Add optional support for socket.gethostbyname checking.",
"return",
"(",
"url",
".",
"startswith",
"(",
"'/'",
")",
"or",
"get_host",
"(",
"url",
")",
"==",
"(",
"self",
".",
"scheme",
",",
"se... | Check if the given ``url`` is a member of the same host as this
conncetion pool. | [
"Check",
"if",
"the",
"given",
"url",
"is",
"a",
"member",
"of",
"the",
"same",
"host",
"as",
"this",
"conncetion",
"pool",
"."
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/packages/urllib3/connectionpool.py#L225-L232 |
51,923 | aio-libs/sphinxcontrib-asyncio | sphinxcontrib/asyncio.py | CoFunctionDocumenter.can_document_member | def can_document_member(cls, member, membername, isattr, parent):
"""Called to see if a member can be documented by this documenter."""
if not super().can_document_member(member, membername, isattr, parent):
return False
return iscoroutinefunction(member) | python | def can_document_member(cls, member, membername, isattr, parent):
"""Called to see if a member can be documented by this documenter."""
if not super().can_document_member(member, membername, isattr, parent):
return False
return iscoroutinefunction(member) | [
"def",
"can_document_member",
"(",
"cls",
",",
"member",
",",
"membername",
",",
"isattr",
",",
"parent",
")",
":",
"if",
"not",
"super",
"(",
")",
".",
"can_document_member",
"(",
"member",
",",
"membername",
",",
"isattr",
",",
"parent",
")",
":",
"ret... | Called to see if a member can be documented by this documenter. | [
"Called",
"to",
"see",
"if",
"a",
"member",
"can",
"be",
"documented",
"by",
"this",
"documenter",
"."
] | 1e0e9139b6dda8036f223fd0ddd358a76de4be7a | https://github.com/aio-libs/sphinxcontrib-asyncio/blob/1e0e9139b6dda8036f223fd0ddd358a76de4be7a/sphinxcontrib/asyncio.py#L83-L87 |
51,924 | senaite/senaite.jsonapi | src/senaite/jsonapi/v1/routes/registry.py | get | def get(context, request, key=None):
"""Return all registry items if key is None, otherwise try to fetch the registry key
"""
registry_records = api.get_registry_records_by_keyword(key)
# Prepare batch
size = req.get_batch_size()
start = req.get_batch_start()
batch = api.make_batch(registry... | python | def get(context, request, key=None):
"""Return all registry items if key is None, otherwise try to fetch the registry key
"""
registry_records = api.get_registry_records_by_keyword(key)
# Prepare batch
size = req.get_batch_size()
start = req.get_batch_start()
batch = api.make_batch(registry... | [
"def",
"get",
"(",
"context",
",",
"request",
",",
"key",
"=",
"None",
")",
":",
"registry_records",
"=",
"api",
".",
"get_registry_records_by_keyword",
"(",
"key",
")",
"# Prepare batch",
"size",
"=",
"req",
".",
"get_batch_size",
"(",
")",
"start",
"=",
... | Return all registry items if key is None, otherwise try to fetch the registry key | [
"Return",
"all",
"registry",
"items",
"if",
"key",
"is",
"None",
"otherwise",
"try",
"to",
"fetch",
"the",
"registry",
"key"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/v1/routes/registry.py#L10-L29 |
51,925 | bububa/pyTOP | pyTOP/packages/requests/sessions.py | merge_kwargs | def merge_kwargs(local_kwarg, default_kwarg):
"""Merges kwarg dictionaries.
If a local key in the dictionary is set to None, it will be removed.
"""
if default_kwarg is None:
return local_kwarg
if isinstance(local_kwarg, basestring):
return local_kwarg
if local_kwarg is None:... | python | def merge_kwargs(local_kwarg, default_kwarg):
"""Merges kwarg dictionaries.
If a local key in the dictionary is set to None, it will be removed.
"""
if default_kwarg is None:
return local_kwarg
if isinstance(local_kwarg, basestring):
return local_kwarg
if local_kwarg is None:... | [
"def",
"merge_kwargs",
"(",
"local_kwarg",
",",
"default_kwarg",
")",
":",
"if",
"default_kwarg",
"is",
"None",
":",
"return",
"local_kwarg",
"if",
"isinstance",
"(",
"local_kwarg",
",",
"basestring",
")",
":",
"return",
"local_kwarg",
"if",
"local_kwarg",
"is",... | Merges kwarg dictionaries.
If a local key in the dictionary is set to None, it will be removed. | [
"Merges",
"kwarg",
"dictionaries",
"."
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/sessions.py#L19-L47 |
51,926 | kentwait/nxsim | nxsim/simulation.py | NetworkSimulation.run_simulation | def run_simulation(self):
"""Runs the complete simulation"""
print('Starting simulations...')
for i in range(self.num_trials):
print('---Trial {}---'.format(i))
self.run_trial(i)
print('Simulation completed.') | python | def run_simulation(self):
"""Runs the complete simulation"""
print('Starting simulations...')
for i in range(self.num_trials):
print('---Trial {}---'.format(i))
self.run_trial(i)
print('Simulation completed.') | [
"def",
"run_simulation",
"(",
"self",
")",
":",
"print",
"(",
"'Starting simulations...'",
")",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_trials",
")",
":",
"print",
"(",
"'---Trial {}---'",
".",
"format",
"(",
"i",
")",
")",
"self",
".",
"run_tr... | Runs the complete simulation | [
"Runs",
"the",
"complete",
"simulation"
] | 88090d8099e574bc6fd1d24734cfa205ecce4c1d | https://github.com/kentwait/nxsim/blob/88090d8099e574bc6fd1d24734cfa205ecce4c1d/nxsim/simulation.py#L49-L55 |
51,927 | kentwait/nxsim | nxsim/simulation.py | NetworkSimulation.setup_network_agents | def setup_network_agents(self):
"""Initializes agents on nodes of graph and registers them to the SimPy environment"""
for i in self.env.G.nodes():
self.env.G.node[i]['agent'] = self.agent_type(environment=self.env, agent_id=i,
state=... | python | def setup_network_agents(self):
"""Initializes agents on nodes of graph and registers them to the SimPy environment"""
for i in self.env.G.nodes():
self.env.G.node[i]['agent'] = self.agent_type(environment=self.env, agent_id=i,
state=... | [
"def",
"setup_network_agents",
"(",
"self",
")",
":",
"for",
"i",
"in",
"self",
".",
"env",
".",
"G",
".",
"nodes",
"(",
")",
":",
"self",
".",
"env",
".",
"G",
".",
"node",
"[",
"i",
"]",
"[",
"'agent'",
"]",
"=",
"self",
".",
"agent_type",
"(... | Initializes agents on nodes of graph and registers them to the SimPy environment | [
"Initializes",
"agents",
"on",
"nodes",
"of",
"graph",
"and",
"registers",
"them",
"to",
"the",
"SimPy",
"environment"
] | 88090d8099e574bc6fd1d24734cfa205ecce4c1d | https://github.com/kentwait/nxsim/blob/88090d8099e574bc6fd1d24734cfa205ecce4c1d/nxsim/simulation.py#L87-L91 |
51,928 | cvxopt/chompack | src/python/maxchord.py | maxchord | def maxchord(A, ve = None):
"""
Maximal chordal subgraph of sparsity graph.
Returns a lower triangular sparse matrix which is the projection
of :math:`A` on a maximal chordal subgraph and a perfect
elimination order :math:`p`. Only the
lower triangular part of :math:`A` is accessed. The
opt... | python | def maxchord(A, ve = None):
"""
Maximal chordal subgraph of sparsity graph.
Returns a lower triangular sparse matrix which is the projection
of :math:`A` on a maximal chordal subgraph and a perfect
elimination order :math:`p`. Only the
lower triangular part of :math:`A` is accessed. The
opt... | [
"def",
"maxchord",
"(",
"A",
",",
"ve",
"=",
"None",
")",
":",
"n",
"=",
"A",
".",
"size",
"[",
"0",
"]",
"assert",
"A",
".",
"size",
"[",
"1",
"]",
"==",
"n",
",",
"\"A must be a square matrix\"",
"assert",
"type",
"(",
"A",
")",
"is",
"spmatrix... | Maximal chordal subgraph of sparsity graph.
Returns a lower triangular sparse matrix which is the projection
of :math:`A` on a maximal chordal subgraph and a perfect
elimination order :math:`p`. Only the
lower triangular part of :math:`A` is accessed. The
optional argument `ve` is the index of the ... | [
"Maximal",
"chordal",
"subgraph",
"of",
"sparsity",
"graph",
"."
] | e07106b58b8055c34f6201e8c954482f86987833 | https://github.com/cvxopt/chompack/blob/e07106b58b8055c34f6201e8c954482f86987833/src/python/maxchord.py#L5-L83 |
51,929 | Vauxoo/cfdilib | cfdilib/cfdicli.py | cli | def cli(config, in_file, out_file, verbose):
"""Main Interface to generate xml documents
from custom dictionaries using legal xsd files
complying with legal documents in all countires
around the world.
"""
config.out_file = out_file
config.verbose = verbose
config.in_file = in_file
c... | python | def cli(config, in_file, out_file, verbose):
"""Main Interface to generate xml documents
from custom dictionaries using legal xsd files
complying with legal documents in all countires
around the world.
"""
config.out_file = out_file
config.verbose = verbose
config.in_file = in_file
c... | [
"def",
"cli",
"(",
"config",
",",
"in_file",
",",
"out_file",
",",
"verbose",
")",
":",
"config",
".",
"out_file",
"=",
"out_file",
"config",
".",
"verbose",
"=",
"verbose",
"config",
".",
"in_file",
"=",
"in_file",
"config",
".",
"out_file",
"=",
"out_f... | Main Interface to generate xml documents
from custom dictionaries using legal xsd files
complying with legal documents in all countires
around the world. | [
"Main",
"Interface",
"to",
"generate",
"xml",
"documents",
"from",
"custom",
"dictionaries",
"using",
"legal",
"xsd",
"files",
"complying",
"with",
"legal",
"documents",
"in",
"all",
"countires",
"around",
"the",
"world",
"."
] | acd73d159f62119f3100d963a061820bbe3f93ea | https://github.com/Vauxoo/cfdilib/blob/acd73d159f62119f3100d963a061820bbe3f93ea/cfdilib/cfdicli.py#L26-L35 |
51,930 | Vauxoo/cfdilib | cfdilib/cfdicli.py | cfdv32mx | def cfdv32mx(config):
"""Format cfdi v3.2 for Mexico.
\b
File where the files will be written document.xml.
cfdicli --in_file /path/to/yout/json/documnt.json cfdv32mx
\b
File where the files will be written from document.json.
cfdicli --out_file ./document.xml cfdv32mx
"""
... | python | def cfdv32mx(config):
"""Format cfdi v3.2 for Mexico.
\b
File where the files will be written document.xml.
cfdicli --in_file /path/to/yout/json/documnt.json cfdv32mx
\b
File where the files will be written from document.json.
cfdicli --out_file ./document.xml cfdv32mx
"""
... | [
"def",
"cfdv32mx",
"(",
"config",
")",
":",
"# TODO: look for a secure option for eval.",
"# Or simply the CLI only should manage json?",
"# TODO: Implement json option also.",
"dict_input",
"=",
"eval",
"(",
"config",
".",
"in_file",
".",
"read",
"(",
")",
")",
"invo... | Format cfdi v3.2 for Mexico.
\b
File where the files will be written document.xml.
cfdicli --in_file /path/to/yout/json/documnt.json cfdv32mx
\b
File where the files will be written from document.json.
cfdicli --out_file ./document.xml cfdv32mx | [
"Format",
"cfdi",
"v3",
".",
"2",
"for",
"Mexico",
"."
] | acd73d159f62119f3100d963a061820bbe3f93ea | https://github.com/Vauxoo/cfdilib/blob/acd73d159f62119f3100d963a061820bbe3f93ea/cfdilib/cfdicli.py#L40-L61 |
51,931 | OpenSystemsLab/flask-widgets | flask_widgets.py | _make_cache_key | def _make_cache_key(key_prefix):
"""Make cache key from prefix
Borrowed from Flask-Cache extension
"""
if callable(key_prefix):
cache_key = key_prefix()
elif '%s' in key_prefix:
cache_key = key_prefix % request.path
else:
cache_key = key_prefix
cache_key = cache_key.... | python | def _make_cache_key(key_prefix):
"""Make cache key from prefix
Borrowed from Flask-Cache extension
"""
if callable(key_prefix):
cache_key = key_prefix()
elif '%s' in key_prefix:
cache_key = key_prefix % request.path
else:
cache_key = key_prefix
cache_key = cache_key.... | [
"def",
"_make_cache_key",
"(",
"key_prefix",
")",
":",
"if",
"callable",
"(",
"key_prefix",
")",
":",
"cache_key",
"=",
"key_prefix",
"(",
")",
"elif",
"'%s'",
"in",
"key_prefix",
":",
"cache_key",
"=",
"key_prefix",
"%",
"request",
".",
"path",
"else",
":... | Make cache key from prefix
Borrowed from Flask-Cache extension | [
"Make",
"cache",
"key",
"from",
"prefix",
"Borrowed",
"from",
"Flask",
"-",
"Cache",
"extension"
] | 6a9fb4c972dff97da5dd6ba713b39158ae4e8cdb | https://github.com/OpenSystemsLab/flask-widgets/blob/6a9fb4c972dff97da5dd6ba713b39158ae4e8cdb/flask_widgets.py#L7-L20 |
51,932 | dschreij/python-mediadecoder | mediadecoder/soundrenderers/pyaudiorenderer.py | SoundrendererPyAudio.get_frame | def get_frame(self, in_data, frame_count, time_info, status):
""" Callback function for the pyaudio stream. Don't use directly. """
while self.keep_listening:
try:
frame = self.queue.get(False, timeout=queue_timeout)
return (frame, pyaudio.paContinue)
except Empty:
pass
return (None, pyaudio.paC... | python | def get_frame(self, in_data, frame_count, time_info, status):
""" Callback function for the pyaudio stream. Don't use directly. """
while self.keep_listening:
try:
frame = self.queue.get(False, timeout=queue_timeout)
return (frame, pyaudio.paContinue)
except Empty:
pass
return (None, pyaudio.paC... | [
"def",
"get_frame",
"(",
"self",
",",
"in_data",
",",
"frame_count",
",",
"time_info",
",",
"status",
")",
":",
"while",
"self",
".",
"keep_listening",
":",
"try",
":",
"frame",
"=",
"self",
".",
"queue",
".",
"get",
"(",
"False",
",",
"timeout",
"=",
... | Callback function for the pyaudio stream. Don't use directly. | [
"Callback",
"function",
"for",
"the",
"pyaudio",
"stream",
".",
"Don",
"t",
"use",
"directly",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/mediadecoder/soundrenderers/pyaudiorenderer.py#L44-L52 |
51,933 | bububa/pyTOP | pyTOP/utils.py | sort_dict | def sort_dict(self, data, key):
'''Sort a list of dictionaries by dictionary key'''
return sorted(data, key=itemgetter(key)) if data else [] | python | def sort_dict(self, data, key):
'''Sort a list of dictionaries by dictionary key'''
return sorted(data, key=itemgetter(key)) if data else [] | [
"def",
"sort_dict",
"(",
"self",
",",
"data",
",",
"key",
")",
":",
"return",
"sorted",
"(",
"data",
",",
"key",
"=",
"itemgetter",
"(",
"key",
")",
")",
"if",
"data",
"else",
"[",
"]"
] | Sort a list of dictionaries by dictionary key | [
"Sort",
"a",
"list",
"of",
"dictionaries",
"by",
"dictionary",
"key"
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/utils.py#L28-L30 |
51,934 | bububa/pyTOP | pyTOP/packages/requests/packages/urllib3/_collections.py | RecentlyUsedContainer._push_entry | def _push_entry(self, key):
"Push entry onto our access log, invalidate the old entry if exists."
self._invalidate_entry(key)
new_entry = AccessEntry(key)
self.access_lookup[key] = new_entry
self.access_log_lock.acquire()
self.access_log.appendleft(new_entry)
se... | python | def _push_entry(self, key):
"Push entry onto our access log, invalidate the old entry if exists."
self._invalidate_entry(key)
new_entry = AccessEntry(key)
self.access_lookup[key] = new_entry
self.access_log_lock.acquire()
self.access_log.appendleft(new_entry)
se... | [
"def",
"_push_entry",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_invalidate_entry",
"(",
"key",
")",
"new_entry",
"=",
"AccessEntry",
"(",
"key",
")",
"self",
".",
"access_lookup",
"[",
"key",
"]",
"=",
"new_entry",
"self",
".",
"access_log_lock",
... | Push entry onto our access log, invalidate the old entry if exists. | [
"Push",
"entry",
"onto",
"our",
"access",
"log",
"invalidate",
"the",
"old",
"entry",
"if",
"exists",
"."
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/packages/urllib3/_collections.py#L58-L67 |
51,935 | bububa/pyTOP | pyTOP/packages/requests/packages/urllib3/_collections.py | RecentlyUsedContainer._prune_entries | def _prune_entries(self, num):
"Pop entries from our access log until we popped ``num`` valid ones."
while num > 0:
self.access_log_lock.acquire()
p = self.access_log.pop()
self.access_log_lock.release()
if not p.is_valid:
continue # Inval... | python | def _prune_entries(self, num):
"Pop entries from our access log until we popped ``num`` valid ones."
while num > 0:
self.access_log_lock.acquire()
p = self.access_log.pop()
self.access_log_lock.release()
if not p.is_valid:
continue # Inval... | [
"def",
"_prune_entries",
"(",
"self",
",",
"num",
")",
":",
"while",
"num",
">",
"0",
":",
"self",
".",
"access_log_lock",
".",
"acquire",
"(",
")",
"p",
"=",
"self",
".",
"access_log",
".",
"pop",
"(",
")",
"self",
".",
"access_log_lock",
".",
"rele... | Pop entries from our access log until we popped ``num`` valid ones. | [
"Pop",
"entries",
"from",
"our",
"access",
"log",
"until",
"we",
"popped",
"num",
"valid",
"ones",
"."
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/packages/urllib3/_collections.py#L69-L81 |
51,936 | bububa/pyTOP | pyTOP/packages/requests/packages/urllib3/_collections.py | RecentlyUsedContainer._prune_invalidated_entries | def _prune_invalidated_entries(self):
"Rebuild our access_log without the invalidated entries."
self.access_log_lock.acquire()
self.access_log = deque(e for e in self.access_log if e.is_valid)
self.access_log_lock.release() | python | def _prune_invalidated_entries(self):
"Rebuild our access_log without the invalidated entries."
self.access_log_lock.acquire()
self.access_log = deque(e for e in self.access_log if e.is_valid)
self.access_log_lock.release() | [
"def",
"_prune_invalidated_entries",
"(",
"self",
")",
":",
"self",
".",
"access_log_lock",
".",
"acquire",
"(",
")",
"self",
".",
"access_log",
"=",
"deque",
"(",
"e",
"for",
"e",
"in",
"self",
".",
"access_log",
"if",
"e",
".",
"is_valid",
")",
"self",... | Rebuild our access_log without the invalidated entries. | [
"Rebuild",
"our",
"access_log",
"without",
"the",
"invalidated",
"entries",
"."
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/packages/urllib3/_collections.py#L83-L87 |
51,937 | bububa/pyTOP | pyTOP/packages/requests/packages/urllib3/_collections.py | RecentlyUsedContainer._get_ordered_access_keys | def _get_ordered_access_keys(self):
"Return ordered access keys for inspection. Used for testing."
self.access_log_lock.acquire()
r = [e.key for e in self.access_log if e.is_valid]
self.access_log_lock.release()
return r | python | def _get_ordered_access_keys(self):
"Return ordered access keys for inspection. Used for testing."
self.access_log_lock.acquire()
r = [e.key for e in self.access_log if e.is_valid]
self.access_log_lock.release()
return r | [
"def",
"_get_ordered_access_keys",
"(",
"self",
")",
":",
"self",
".",
"access_log_lock",
".",
"acquire",
"(",
")",
"r",
"=",
"[",
"e",
".",
"key",
"for",
"e",
"in",
"self",
".",
"access_log",
"if",
"e",
".",
"is_valid",
"]",
"self",
".",
"access_log_l... | Return ordered access keys for inspection. Used for testing. | [
"Return",
"ordered",
"access",
"keys",
"for",
"inspection",
".",
"Used",
"for",
"testing",
"."
] | 1e48009bcfe886be392628244b370e6374e1f2b2 | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/packages/requests/packages/urllib3/_collections.py#L89-L95 |
51,938 | dschreij/python-mediadecoder | play.py | VideoPlayer.calc_scaled_res | def calc_scaled_res(self, screen_res, image_res):
"""Calculate appropriate texture size.
Calculate size or required texture so that it will fill the window,
but retains the movies original aspect ratio.
Parameters
----------
screen_res : tuple
Display window size/Resolution
image_res : tuple
... | python | def calc_scaled_res(self, screen_res, image_res):
"""Calculate appropriate texture size.
Calculate size or required texture so that it will fill the window,
but retains the movies original aspect ratio.
Parameters
----------
screen_res : tuple
Display window size/Resolution
image_res : tuple
... | [
"def",
"calc_scaled_res",
"(",
"self",
",",
"screen_res",
",",
"image_res",
")",
":",
"rs",
"=",
"screen_res",
"[",
"0",
"]",
"/",
"float",
"(",
"screen_res",
"[",
"1",
"]",
")",
"ri",
"=",
"image_res",
"[",
"0",
"]",
"/",
"float",
"(",
"image_res",
... | Calculate appropriate texture size.
Calculate size or required texture so that it will fill the window,
but retains the movies original aspect ratio.
Parameters
----------
screen_res : tuple
Display window size/Resolution
image_res : tuple
Image width and height
Returns
-------
tuple
... | [
"Calculate",
"appropriate",
"texture",
"size",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/play.py#L82-L106 |
51,939 | dschreij/python-mediadecoder | play.py | VideoPlayer.load_media | def load_media(self, vidSource):
""" Loads a video.
Parameters
----------
vidSource : str
The path to the video file
"""
if not os.path.exists(vidSource):
print("File not found: " + vidSource)
pygame.display.quit()
pygame.quit()
sys.exit(1)
self.decoder.load_media(vidSource)
self.decode... | python | def load_media(self, vidSource):
""" Loads a video.
Parameters
----------
vidSource : str
The path to the video file
"""
if not os.path.exists(vidSource):
print("File not found: " + vidSource)
pygame.display.quit()
pygame.quit()
sys.exit(1)
self.decoder.load_media(vidSource)
self.decode... | [
"def",
"load_media",
"(",
"self",
",",
"vidSource",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"vidSource",
")",
":",
"print",
"(",
"\"File not found: \"",
"+",
"vidSource",
")",
"pygame",
".",
"display",
".",
"quit",
"(",
")",
"pyga... | Loads a video.
Parameters
----------
vidSource : str
The path to the video file | [
"Loads",
"a",
"video",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/play.py#L108-L142 |
51,940 | dschreij/python-mediadecoder | play.py | VideoPlayer.__texUpdate | def __texUpdate(self, frame):
""" Update the texture with the newly supplied frame. """
# Retrieve buffer from videosink
if self.texture_locked:
return
self.buffer = frame
self.texUpdated = True | python | def __texUpdate(self, frame):
""" Update the texture with the newly supplied frame. """
# Retrieve buffer from videosink
if self.texture_locked:
return
self.buffer = frame
self.texUpdated = True | [
"def",
"__texUpdate",
"(",
"self",
",",
"frame",
")",
":",
"# Retrieve buffer from videosink",
"if",
"self",
".",
"texture_locked",
":",
"return",
"self",
".",
"buffer",
"=",
"frame",
"self",
".",
"texUpdated",
"=",
"True"
] | Update the texture with the newly supplied frame. | [
"Update",
"the",
"texture",
"with",
"the",
"newly",
"supplied",
"frame",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/play.py#L182-L188 |
51,941 | dschreij/python-mediadecoder | play.py | VideoPlayer.play | def play(self):
""" Starts playback. """
# Signal player to start video playback
self.paused = False
# Start listening for incoming audio frames
if self.decoder.audioformat:
self.audio.start()
self.decoder.play()
# While video is playing, render frames
while self.decoder.status in [mediadecoder.PL... | python | def play(self):
""" Starts playback. """
# Signal player to start video playback
self.paused = False
# Start listening for incoming audio frames
if self.decoder.audioformat:
self.audio.start()
self.decoder.play()
# While video is playing, render frames
while self.decoder.status in [mediadecoder.PL... | [
"def",
"play",
"(",
"self",
")",
":",
"# Signal player to start video playback",
"self",
".",
"paused",
"=",
"False",
"# Start listening for incoming audio frames",
"if",
"self",
".",
"decoder",
".",
"audioformat",
":",
"self",
".",
"audio",
".",
"start",
"(",
")"... | Starts playback. | [
"Starts",
"playback",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/play.py#L196-L268 |
51,942 | dschreij/python-mediadecoder | play.py | VideoPlayer.pause | def pause(self):
""" Pauses playback. """
if self.decoder.status == mediadecoder.PAUSED:
self.decoder.pause()
self.paused = False
elif self.decoder.status == mediadecoder.PLAYING:
self.decoder.pause()
self.paused = True
else:
print("Player not in pausable state") | python | def pause(self):
""" Pauses playback. """
if self.decoder.status == mediadecoder.PAUSED:
self.decoder.pause()
self.paused = False
elif self.decoder.status == mediadecoder.PLAYING:
self.decoder.pause()
self.paused = True
else:
print("Player not in pausable state") | [
"def",
"pause",
"(",
"self",
")",
":",
"if",
"self",
".",
"decoder",
".",
"status",
"==",
"mediadecoder",
".",
"PAUSED",
":",
"self",
".",
"decoder",
".",
"pause",
"(",
")",
"self",
".",
"paused",
"=",
"False",
"elif",
"self",
".",
"decoder",
".",
... | Pauses playback. | [
"Pauses",
"playback",
"."
] | f01b02d790f2abc52d9792e43076cf4cb7d3ce51 | https://github.com/dschreij/python-mediadecoder/blob/f01b02d790f2abc52d9792e43076cf4cb7d3ce51/play.py#L274-L283 |
51,943 | danilobellini/dose | dose/terminal.py | fg | def fg(color):
"""
Foreground color formatter function factory.
Each function casts from a unicode string to a colored bytestring
with the respective foreground color and foreground reset ANSI
escape codes. You can also use the ``fg.color`` or ``fg[color]``
directly as attributes/items.
Th... | python | def fg(color):
"""
Foreground color formatter function factory.
Each function casts from a unicode string to a colored bytestring
with the respective foreground color and foreground reset ANSI
escape codes. You can also use the ``fg.color`` or ``fg[color]``
directly as attributes/items.
Th... | [
"def",
"fg",
"(",
"color",
")",
":",
"ansi_code",
"=",
"[",
"getattr",
"(",
"colorama",
".",
"Fore",
",",
"color",
".",
"upper",
"(",
")",
")",
",",
"colorama",
".",
"Fore",
".",
"RESET",
"]",
"return",
"lambda",
"msg",
":",
"msg",
".",
"join",
"... | Foreground color formatter function factory.
Each function casts from a unicode string to a colored bytestring
with the respective foreground color and foreground reset ANSI
escape codes. You can also use the ``fg.color`` or ``fg[color]``
directly as attributes/items.
The colors are the names of t... | [
"Foreground",
"color",
"formatter",
"function",
"factory",
"."
] | 141f48322f7812b7d32e3d5f065d4473a11102a4 | https://github.com/danilobellini/dose/blob/141f48322f7812b7d32e3d5f065d4473a11102a4/dose/terminal.py#L147-L164 |
51,944 | danilobellini/dose | dose/terminal.py | clog | def clog(color):
"""Same to ``log``, but this one centralizes the message first."""
logger = log(color)
return lambda msg: logger(centralize(msg).rstrip()) | python | def clog(color):
"""Same to ``log``, but this one centralizes the message first."""
logger = log(color)
return lambda msg: logger(centralize(msg).rstrip()) | [
"def",
"clog",
"(",
"color",
")",
":",
"logger",
"=",
"log",
"(",
"color",
")",
"return",
"lambda",
"msg",
":",
"logger",
"(",
"centralize",
"(",
"msg",
")",
".",
"rstrip",
"(",
")",
")"
] | Same to ``log``, but this one centralizes the message first. | [
"Same",
"to",
"log",
"but",
"this",
"one",
"centralizes",
"the",
"message",
"first",
"."
] | 141f48322f7812b7d32e3d5f065d4473a11102a4 | https://github.com/danilobellini/dose/blob/141f48322f7812b7d32e3d5f065d4473a11102a4/dose/terminal.py#L204-L207 |
51,945 | danilobellini/dose | dose/terminal.py | TerminalSize.retrieve_width | def retrieve_width(self, signum=None, frame=None):
"""
Stores the terminal width into ``self.width``, if possible.
This function is also the SIGWINCH event handler.
"""
for method_name, args in self.strategies:
method = getattr(self, "from_" + method_name)
... | python | def retrieve_width(self, signum=None, frame=None):
"""
Stores the terminal width into ``self.width``, if possible.
This function is also the SIGWINCH event handler.
"""
for method_name, args in self.strategies:
method = getattr(self, "from_" + method_name)
... | [
"def",
"retrieve_width",
"(",
"self",
",",
"signum",
"=",
"None",
",",
"frame",
"=",
"None",
")",
":",
"for",
"method_name",
",",
"args",
"in",
"self",
".",
"strategies",
":",
"method",
"=",
"getattr",
"(",
"self",
",",
"\"from_\"",
"+",
"method_name",
... | Stores the terminal width into ``self.width``, if possible.
This function is also the SIGWINCH event handler. | [
"Stores",
"the",
"terminal",
"width",
"into",
"self",
".",
"width",
"if",
"possible",
".",
"This",
"function",
"is",
"also",
"the",
"SIGWINCH",
"event",
"handler",
"."
] | 141f48322f7812b7d32e3d5f065d4473a11102a4 | https://github.com/danilobellini/dose/blob/141f48322f7812b7d32e3d5f065d4473a11102a4/dose/terminal.py#L67-L78 |
51,946 | adamchainz/dynamodb_utils | dynamodb_utils/dumper.py | dump_part | def dump_part(part, total_segments=None):
"""
'part' may be the hash_key if we are dumping just a few hash_keys - else
it will be the segment number
"""
try:
connection = Connection(host=config['host'], region=config['region'])
filename = ".".join([config['table_name'], str(part), "... | python | def dump_part(part, total_segments=None):
"""
'part' may be the hash_key if we are dumping just a few hash_keys - else
it will be the segment number
"""
try:
connection = Connection(host=config['host'], region=config['region'])
filename = ".".join([config['table_name'], str(part), "... | [
"def",
"dump_part",
"(",
"part",
",",
"total_segments",
"=",
"None",
")",
":",
"try",
":",
"connection",
"=",
"Connection",
"(",
"host",
"=",
"config",
"[",
"'host'",
"]",
",",
"region",
"=",
"config",
"[",
"'region'",
"]",
")",
"filename",
"=",
"\".\"... | 'part' may be the hash_key if we are dumping just a few hash_keys - else
it will be the segment number | [
"part",
"may",
"be",
"the",
"hash_key",
"if",
"we",
"are",
"dumping",
"just",
"a",
"few",
"hash_keys",
"-",
"else",
"it",
"will",
"be",
"the",
"segment",
"number"
] | aabf1a56c88b06ac7e5fced75b08370cca1ab1e2 | https://github.com/adamchainz/dynamodb_utils/blob/aabf1a56c88b06ac7e5fced75b08370cca1ab1e2/dynamodb_utils/dumper.py#L93-L121 |
51,947 | cvxopt/chompack | src/python/pybase/hessian.py | hessian | def hessian(L, Y, U, adj = False, inv = False, factored_updates = False):
"""
Supernodal multifrontal Hessian mapping.
The mapping
.. math::
\mathcal H_X(U) = P(X^{-1}UX^{-1})
is the Hessian of the log-det barrier at a positive definite chordal
matrix :math:`X`, applied to a symmetri... | python | def hessian(L, Y, U, adj = False, inv = False, factored_updates = False):
"""
Supernodal multifrontal Hessian mapping.
The mapping
.. math::
\mathcal H_X(U) = P(X^{-1}UX^{-1})
is the Hessian of the log-det barrier at a positive definite chordal
matrix :math:`X`, applied to a symmetri... | [
"def",
"hessian",
"(",
"L",
",",
"Y",
",",
"U",
",",
"adj",
"=",
"False",
",",
"inv",
"=",
"False",
",",
"factored_updates",
"=",
"False",
")",
":",
"assert",
"L",
".",
"symb",
"==",
"Y",
".",
"symb",
",",
"\"Symbolic factorization mismatch\"",
"assert... | Supernodal multifrontal Hessian mapping.
The mapping
.. math::
\mathcal H_X(U) = P(X^{-1}UX^{-1})
is the Hessian of the log-det barrier at a positive definite chordal
matrix :math:`X`, applied to a symmetric chordal matrix :math:`U`. The Hessian operator
can be factored as
.. math::... | [
"Supernodal",
"multifrontal",
"Hessian",
"mapping",
"."
] | e07106b58b8055c34f6201e8c954482f86987833 | https://github.com/cvxopt/chompack/blob/e07106b58b8055c34f6201e8c954482f86987833/src/python/pybase/hessian.py#L237-L332 |
51,948 | chukysoria/pyspotify-connect | spotifyconnect/audio.py | AudioFormat.frame_size | def frame_size(self):
"""The byte size of a single frame of this format."""
if self.sample_type == SampleType.S16NativeEndian:
# Sample size is 2 bytes
return self.sample_size * self.channels
else:
raise ValueError('Unknown sample type: %d', self.sample_type) | python | def frame_size(self):
"""The byte size of a single frame of this format."""
if self.sample_type == SampleType.S16NativeEndian:
# Sample size is 2 bytes
return self.sample_size * self.channels
else:
raise ValueError('Unknown sample type: %d', self.sample_type) | [
"def",
"frame_size",
"(",
"self",
")",
":",
"if",
"self",
".",
"sample_type",
"==",
"SampleType",
".",
"S16NativeEndian",
":",
"# Sample size is 2 bytes",
"return",
"self",
".",
"sample_size",
"*",
"self",
".",
"channels",
"else",
":",
"raise",
"ValueError",
"... | The byte size of a single frame of this format. | [
"The",
"byte",
"size",
"of",
"a",
"single",
"frame",
"of",
"this",
"format",
"."
] | bd157fa4fb2b51b3641f198a35384678c1a4fa11 | https://github.com/chukysoria/pyspotify-connect/blob/bd157fa4fb2b51b3641f198a35384678c1a4fa11/spotifyconnect/audio.py#L62-L68 |
51,949 | idmillington/layout | layout/managers/root.py | add_fields | def add_fields(store_name, field_names):
"""
A class-decorator that creates layout managers with a set of named
fields.
"""
def decorate(cls):
def _add(index, name):
def _set_dir(self, value): getattr(self, store_name)[index] = value
def _get_dir(self): return getattr... | python | def add_fields(store_name, field_names):
"""
A class-decorator that creates layout managers with a set of named
fields.
"""
def decorate(cls):
def _add(index, name):
def _set_dir(self, value): getattr(self, store_name)[index] = value
def _get_dir(self): return getattr... | [
"def",
"add_fields",
"(",
"store_name",
",",
"field_names",
")",
":",
"def",
"decorate",
"(",
"cls",
")",
":",
"def",
"_add",
"(",
"index",
",",
"name",
")",
":",
"def",
"_set_dir",
"(",
"self",
",",
"value",
")",
":",
"getattr",
"(",
"self",
",",
... | A class-decorator that creates layout managers with a set of named
fields. | [
"A",
"class",
"-",
"decorator",
"that",
"creates",
"layout",
"managers",
"with",
"a",
"set",
"of",
"named",
"fields",
"."
] | c452d1d7a74c9a74f7639c1b49e2a41c4e354bb5 | https://github.com/idmillington/layout/blob/c452d1d7a74c9a74f7639c1b49e2a41c4e354bb5/layout/managers/root.py#L26-L42 |
51,950 | idmillington/layout | layout/managers/root.py | GroupLayoutManager._get_smallest_dimensions | def _get_smallest_dimensions(self, data):
"""A utility method to return the minimum size needed to fit
all the elements in."""
min_width = 0
min_height = 0
for element in self.elements:
if not element: continue
size = element.get_minimum_size(data)
... | python | def _get_smallest_dimensions(self, data):
"""A utility method to return the minimum size needed to fit
all the elements in."""
min_width = 0
min_height = 0
for element in self.elements:
if not element: continue
size = element.get_minimum_size(data)
... | [
"def",
"_get_smallest_dimensions",
"(",
"self",
",",
"data",
")",
":",
"min_width",
"=",
"0",
"min_height",
"=",
"0",
"for",
"element",
"in",
"self",
".",
"elements",
":",
"if",
"not",
"element",
":",
"continue",
"size",
"=",
"element",
".",
"get_minimum_s... | A utility method to return the minimum size needed to fit
all the elements in. | [
"A",
"utility",
"method",
"to",
"return",
"the",
"minimum",
"size",
"needed",
"to",
"fit",
"all",
"the",
"elements",
"in",
"."
] | c452d1d7a74c9a74f7639c1b49e2a41c4e354bb5 | https://github.com/idmillington/layout/blob/c452d1d7a74c9a74f7639c1b49e2a41c4e354bb5/layout/managers/root.py#L55-L65 |
51,951 | senaite/senaite.jsonapi | src/senaite/jsonapi/fieldmanagers.py | DateTimeFieldManager.set | def set(self, instance, value, **kw):
"""Converts the value into a DateTime object before setting.
"""
if value:
try:
value = DateTime(value)
except SyntaxError:
logger.warn("Value '{}' is not a valid DateTime string"
... | python | def set(self, instance, value, **kw):
"""Converts the value into a DateTime object before setting.
"""
if value:
try:
value = DateTime(value)
except SyntaxError:
logger.warn("Value '{}' is not a valid DateTime string"
... | [
"def",
"set",
"(",
"self",
",",
"instance",
",",
"value",
",",
"*",
"*",
"kw",
")",
":",
"if",
"value",
":",
"try",
":",
"value",
"=",
"DateTime",
"(",
"value",
")",
"except",
"SyntaxError",
":",
"logger",
".",
"warn",
"(",
"\"Value '{}' is not a valid... | Converts the value into a DateTime object before setting. | [
"Converts",
"the",
"value",
"into",
"a",
"DateTime",
"object",
"before",
"setting",
"."
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/fieldmanagers.py#L326-L337 |
51,952 | senaite/senaite.jsonapi | src/senaite/jsonapi/fieldmanagers.py | FileFieldManager.get_filename | def get_filename(self, instance):
"""Get the filename
"""
filename = self.field.getFilename(instance)
if filename:
return filename
fieldname = self.get_field_name()
content_type = self.get_content_type(instance)
extension = mimetypes.guess_extension(c... | python | def get_filename(self, instance):
"""Get the filename
"""
filename = self.field.getFilename(instance)
if filename:
return filename
fieldname = self.get_field_name()
content_type = self.get_content_type(instance)
extension = mimetypes.guess_extension(c... | [
"def",
"get_filename",
"(",
"self",
",",
"instance",
")",
":",
"filename",
"=",
"self",
".",
"field",
".",
"getFilename",
"(",
"instance",
")",
"if",
"filename",
":",
"return",
"filename",
"fieldname",
"=",
"self",
".",
"get_field_name",
"(",
")",
"content... | Get the filename | [
"Get",
"the",
"filename"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/fieldmanagers.py#L362-L373 |
51,953 | senaite/senaite.jsonapi | src/senaite/jsonapi/fieldmanagers.py | FileFieldManager.set | def set(self, instance, value, **kw):
"""Decodes base64 value and set the file object
"""
value = str(value).decode("base64")
# handle the filename
if "filename" not in kw:
logger.debug("FielFieldManager::set: No Filename detected "
"-> using... | python | def set(self, instance, value, **kw):
"""Decodes base64 value and set the file object
"""
value = str(value).decode("base64")
# handle the filename
if "filename" not in kw:
logger.debug("FielFieldManager::set: No Filename detected "
"-> using... | [
"def",
"set",
"(",
"self",
",",
"instance",
",",
"value",
",",
"*",
"*",
"kw",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
".",
"decode",
"(",
"\"base64\"",
")",
"# handle the filename",
"if",
"\"filename\"",
"not",
"in",
"kw",
":",
"logger",
"... | Decodes base64 value and set the file object | [
"Decodes",
"base64",
"value",
"and",
"set",
"the",
"file",
"object"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/fieldmanagers.py#L389-L400 |
51,954 | senaite/senaite.jsonapi | src/senaite/jsonapi/fieldmanagers.py | ReferenceFieldManager.set | def set(self, instance, value, **kw): # noqa
"""Set the value of the refernce field
"""
ref = []
# The value is an UID
if api.is_uid(value):
ref.append(api.get_object_by_uid(value))
# The value is already an object
if api.is_at_content(value):
... | python | def set(self, instance, value, **kw): # noqa
"""Set the value of the refernce field
"""
ref = []
# The value is an UID
if api.is_uid(value):
ref.append(api.get_object_by_uid(value))
# The value is already an object
if api.is_at_content(value):
... | [
"def",
"set",
"(",
"self",
",",
"instance",
",",
"value",
",",
"*",
"*",
"kw",
")",
":",
"# noqa",
"ref",
"=",
"[",
"]",
"# The value is an UID",
"if",
"api",
".",
"is_uid",
"(",
"value",
")",
":",
"ref",
".",
"append",
"(",
"api",
".",
"get_object... | Set the value of the refernce field | [
"Set",
"the",
"value",
"of",
"the",
"refernce",
"field"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/fieldmanagers.py#L421-L490 |
51,955 | senaite/senaite.jsonapi | src/senaite/jsonapi/fieldmanagers.py | ProxyFieldManager.get_proxy_field | def get_proxy_field(self, instance):
"""Get the proxied field of this field
"""
proxy_object = self.get_proxy_object(instance)
if not proxy_object:
return None
return proxy_object.getField(self.name) | python | def get_proxy_field(self, instance):
"""Get the proxied field of this field
"""
proxy_object = self.get_proxy_object(instance)
if not proxy_object:
return None
return proxy_object.getField(self.name) | [
"def",
"get_proxy_field",
"(",
"self",
",",
"instance",
")",
":",
"proxy_object",
"=",
"self",
".",
"get_proxy_object",
"(",
"instance",
")",
"if",
"not",
"proxy_object",
":",
"return",
"None",
"return",
"proxy_object",
".",
"getField",
"(",
"self",
".",
"na... | Get the proxied field of this field | [
"Get",
"the",
"proxied",
"field",
"of",
"this",
"field"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/fieldmanagers.py#L518-L524 |
51,956 | senaite/senaite.jsonapi | src/senaite/jsonapi/fieldmanagers.py | ARAnalysesFieldManager.set | def set(self, instance, value, **kw):
"""
Set Analyses to an AR
:param instance: Analysis Request
:param value: Single AS UID or a list of dictionaries containing AS UIDs
:param kw: Additional keyword parameters passed to the field
"""
if not isinstance(value, (... | python | def set(self, instance, value, **kw):
"""
Set Analyses to an AR
:param instance: Analysis Request
:param value: Single AS UID or a list of dictionaries containing AS UIDs
:param kw: Additional keyword parameters passed to the field
"""
if not isinstance(value, (... | [
"def",
"set",
"(",
"self",
",",
"instance",
",",
"value",
",",
"*",
"*",
"kw",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"value",
"=",
"[",
"value",
"]",
"uids",
"=",
"[",
"]",
"for",
"i... | Set Analyses to an AR
:param instance: Analysis Request
:param value: Single AS UID or a list of dictionaries containing AS UIDs
:param kw: Additional keyword parameters passed to the field | [
"Set",
"Analyses",
"to",
"an",
"AR"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/fieldmanagers.py#L549-L574 |
51,957 | senaite/senaite.jsonapi | src/senaite/jsonapi/fieldmanagers.py | UIDReferenceFieldManager.set | def set(self, instance, value, **kw): # noqa
"""Set the value of the uid reference field
"""
ref = []
# The value is an UID
if api.is_uid(value):
ref.append(value)
# The value is a dictionary, get the UIDs.
if u.is_dict(value):
ref = ref.... | python | def set(self, instance, value, **kw): # noqa
"""Set the value of the uid reference field
"""
ref = []
# The value is an UID
if api.is_uid(value):
ref.append(value)
# The value is a dictionary, get the UIDs.
if u.is_dict(value):
ref = ref.... | [
"def",
"set",
"(",
"self",
",",
"instance",
",",
"value",
",",
"*",
"*",
"kw",
")",
":",
"# noqa",
"ref",
"=",
"[",
"]",
"# The value is an UID",
"if",
"api",
".",
"is_uid",
"(",
"value",
")",
":",
"ref",
".",
"append",
"(",
"value",
")",
"# The va... | Set the value of the uid reference field | [
"Set",
"the",
"value",
"of",
"the",
"uid",
"reference",
"field"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/fieldmanagers.py#L598-L635 |
51,958 | senaite/senaite.jsonapi | src/senaite/jsonapi/dataproviders.py | Base.to_dict | def to_dict(self):
""" extract the data of the content and return it as a dictionary
"""
# 1. extract the schema fields
data = self.extract_fields()
# 2. include custom key-value pairs listed in the mapping dictionary
for key, attr in self.attributes.iteritems():
... | python | def to_dict(self):
""" extract the data of the content and return it as a dictionary
"""
# 1. extract the schema fields
data = self.extract_fields()
# 2. include custom key-value pairs listed in the mapping dictionary
for key, attr in self.attributes.iteritems():
... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"# 1. extract the schema fields",
"data",
"=",
"self",
".",
"extract_fields",
"(",
")",
"# 2. include custom key-value pairs listed in the mapping dictionary",
"for",
"key",
",",
"attr",
"in",
"self",
".",
"attributes",
".",
"i... | extract the data of the content and return it as a dictionary | [
"extract",
"the",
"data",
"of",
"the",
"content",
"and",
"return",
"it",
"as",
"a",
"dictionary"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/dataproviders.py#L61-L81 |
51,959 | senaite/senaite.jsonapi | src/senaite/jsonapi/dataproviders.py | Base.extract_fields | def extract_fields(self):
"""Extract the given fieldnames from the object
:returns: Schema name/value mapping
:rtype: dict
"""
# get the proper data manager for the object
dm = IDataManager(self.context)
# filter out ignored fields
fieldnames = filter(l... | python | def extract_fields(self):
"""Extract the given fieldnames from the object
:returns: Schema name/value mapping
:rtype: dict
"""
# get the proper data manager for the object
dm = IDataManager(self.context)
# filter out ignored fields
fieldnames = filter(l... | [
"def",
"extract_fields",
"(",
"self",
")",
":",
"# get the proper data manager for the object",
"dm",
"=",
"IDataManager",
"(",
"self",
".",
"context",
")",
"# filter out ignored fields",
"fieldnames",
"=",
"filter",
"(",
"lambda",
"name",
":",
"name",
"not",
"in",
... | Extract the given fieldnames from the object
:returns: Schema name/value mapping
:rtype: dict | [
"Extract",
"the",
"given",
"fieldnames",
"from",
"the",
"object"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/dataproviders.py#L83-L114 |
51,960 | senaite/senaite.jsonapi | src/senaite/jsonapi/dataproviders.py | ZCDataProvider._x_get_physical_path | def _x_get_physical_path(self):
"""Generate the physical path
"""
path = self.context.getPath()
portal_path = api.get_path(api.get_portal())
if portal_path not in path:
return "{}/{}".format(portal_path, path)
return path | python | def _x_get_physical_path(self):
"""Generate the physical path
"""
path = self.context.getPath()
portal_path = api.get_path(api.get_portal())
if portal_path not in path:
return "{}/{}".format(portal_path, path)
return path | [
"def",
"_x_get_physical_path",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"context",
".",
"getPath",
"(",
")",
"portal_path",
"=",
"api",
".",
"get_path",
"(",
"api",
".",
"get_portal",
"(",
")",
")",
"if",
"portal_path",
"not",
"in",
"path",
":"... | Generate the physical path | [
"Generate",
"the",
"physical",
"path"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/dataproviders.py#L160-L167 |
51,961 | danilobellini/dose | dose/misc.py | snake2ucamel | def snake2ucamel(value):
"""Casts a snake_case string to an UpperCamelCase string."""
UNDER, LETTER, OTHER = object(), object(), object()
def group_key_function(char):
if char == "_":
return UNDER
if char in string.ascii_letters:
return LETTER
return OTHER
... | python | def snake2ucamel(value):
"""Casts a snake_case string to an UpperCamelCase string."""
UNDER, LETTER, OTHER = object(), object(), object()
def group_key_function(char):
if char == "_":
return UNDER
if char in string.ascii_letters:
return LETTER
return OTHER
... | [
"def",
"snake2ucamel",
"(",
"value",
")",
":",
"UNDER",
",",
"LETTER",
",",
"OTHER",
"=",
"object",
"(",
")",
",",
"object",
"(",
")",
",",
"object",
"(",
")",
"def",
"group_key_function",
"(",
"char",
")",
":",
"if",
"char",
"==",
"\"_\"",
":",
"r... | Casts a snake_case string to an UpperCamelCase string. | [
"Casts",
"a",
"snake_case",
"string",
"to",
"an",
"UpperCamelCase",
"string",
"."
] | 141f48322f7812b7d32e3d5f065d4473a11102a4 | https://github.com/danilobellini/dose/blob/141f48322f7812b7d32e3d5f065d4473a11102a4/dose/misc.py#L22-L44 |
51,962 | danilobellini/dose | dose/misc.py | ucamel_method | def ucamel_method(func):
"""
Decorator to ensure the given snake_case method is also written in
UpperCamelCase in the given namespace. That was mainly written to
avoid confusion when using wxPython and its UpperCamelCaseMethods.
"""
frame_locals = inspect.currentframe().f_back.f_locals
frame... | python | def ucamel_method(func):
"""
Decorator to ensure the given snake_case method is also written in
UpperCamelCase in the given namespace. That was mainly written to
avoid confusion when using wxPython and its UpperCamelCaseMethods.
"""
frame_locals = inspect.currentframe().f_back.f_locals
frame... | [
"def",
"ucamel_method",
"(",
"func",
")",
":",
"frame_locals",
"=",
"inspect",
".",
"currentframe",
"(",
")",
".",
"f_back",
".",
"f_locals",
"frame_locals",
"[",
"snake2ucamel",
"(",
"func",
".",
"__name__",
")",
"]",
"=",
"func",
"return",
"func"
] | Decorator to ensure the given snake_case method is also written in
UpperCamelCase in the given namespace. That was mainly written to
avoid confusion when using wxPython and its UpperCamelCaseMethods. | [
"Decorator",
"to",
"ensure",
"the",
"given",
"snake_case",
"method",
"is",
"also",
"written",
"in",
"UpperCamelCase",
"in",
"the",
"given",
"namespace",
".",
"That",
"was",
"mainly",
"written",
"to",
"avoid",
"confusion",
"when",
"using",
"wxPython",
"and",
"i... | 141f48322f7812b7d32e3d5f065d4473a11102a4 | https://github.com/danilobellini/dose/blob/141f48322f7812b7d32e3d5f065d4473a11102a4/dose/misc.py#L67-L75 |
51,963 | danilobellini/dose | dose/misc.py | read_plain_text | def read_plain_text(fname, encoding="utf-8"):
"""Reads a file as a list of strings."""
with io.open(fname, encoding=encoding) as f:
result = list(f)
if result:
if result[-1][-1:] == "\n":
result.append("\n")
else:
result[-1] += "\n"
return [line[:-1] f... | python | def read_plain_text(fname, encoding="utf-8"):
"""Reads a file as a list of strings."""
with io.open(fname, encoding=encoding) as f:
result = list(f)
if result:
if result[-1][-1:] == "\n":
result.append("\n")
else:
result[-1] += "\n"
return [line[:-1] f... | [
"def",
"read_plain_text",
"(",
"fname",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"with",
"io",
".",
"open",
"(",
"fname",
",",
"encoding",
"=",
"encoding",
")",
"as",
"f",
":",
"result",
"=",
"list",
"(",
"f",
")",
"if",
"result",
":",
"if",
"r... | Reads a file as a list of strings. | [
"Reads",
"a",
"file",
"as",
"a",
"list",
"of",
"strings",
"."
] | 141f48322f7812b7d32e3d5f065d4473a11102a4 | https://github.com/danilobellini/dose/blob/141f48322f7812b7d32e3d5f065d4473a11102a4/dose/misc.py#L114-L124 |
51,964 | cvxopt/chompack | src/python/mcs.py | maxcardsearch | def maxcardsearch(A, ve = None):
"""
Maximum cardinality search ordering of a sparse chordal matrix.
Returns the maximum cardinality search ordering of a symmetric
chordal matrix :math:`A`. Only the lower triangular part of
:math:`A` is accessed. The maximum cardinality search ordering
is a per... | python | def maxcardsearch(A, ve = None):
"""
Maximum cardinality search ordering of a sparse chordal matrix.
Returns the maximum cardinality search ordering of a symmetric
chordal matrix :math:`A`. Only the lower triangular part of
:math:`A` is accessed. The maximum cardinality search ordering
is a per... | [
"def",
"maxcardsearch",
"(",
"A",
",",
"ve",
"=",
"None",
")",
":",
"n",
"=",
"A",
".",
"size",
"[",
"0",
"]",
"assert",
"A",
".",
"size",
"[",
"1",
"]",
"==",
"n",
",",
"\"A must be a square matrix\"",
"assert",
"type",
"(",
"A",
")",
"is",
"spm... | Maximum cardinality search ordering of a sparse chordal matrix.
Returns the maximum cardinality search ordering of a symmetric
chordal matrix :math:`A`. Only the lower triangular part of
:math:`A` is accessed. The maximum cardinality search ordering
is a perfect elimination ordering in the factorizatio... | [
"Maximum",
"cardinality",
"search",
"ordering",
"of",
"a",
"sparse",
"chordal",
"matrix",
"."
] | e07106b58b8055c34f6201e8c954482f86987833 | https://github.com/cvxopt/chompack/blob/e07106b58b8055c34f6201e8c954482f86987833/src/python/mcs.py#L4-L57 |
51,965 | chukysoria/pyspotify-connect | spotifyconnect/__init__.py | _setup_logging | def _setup_logging():
"""Setup logging to log to nowhere by default.
For details, see:
http://docs.python.org/3/howto/logging.html#library-config
Internal function.
"""
import logging
logger = logging.getLogger('spotify-connect')
handler = logging.NullHandler()
logger.addHandler(h... | python | def _setup_logging():
"""Setup logging to log to nowhere by default.
For details, see:
http://docs.python.org/3/howto/logging.html#library-config
Internal function.
"""
import logging
logger = logging.getLogger('spotify-connect')
handler = logging.NullHandler()
logger.addHandler(h... | [
"def",
"_setup_logging",
"(",
")",
":",
"import",
"logging",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'spotify-connect'",
")",
"handler",
"=",
"logging",
".",
"NullHandler",
"(",
")",
"logger",
".",
"addHandler",
"(",
"handler",
")"
] | Setup logging to log to nowhere by default.
For details, see:
http://docs.python.org/3/howto/logging.html#library-config
Internal function. | [
"Setup",
"logging",
"to",
"log",
"to",
"nowhere",
"by",
"default",
"."
] | bd157fa4fb2b51b3641f198a35384678c1a4fa11 | https://github.com/chukysoria/pyspotify-connect/blob/bd157fa4fb2b51b3641f198a35384678c1a4fa11/spotifyconnect/__init__.py#L19-L31 |
51,966 | chukysoria/pyspotify-connect | spotifyconnect/__init__.py | serialized | def serialized(f):
"""Decorator that serializes access to all decorated functions.
The decorator acquires pyspotify's single global lock while calling any
wrapped function. It is used to serialize access to:
- All calls to functions on :attr:`spotify.lib`.
- All code blocks working on pointers re... | python | def serialized(f):
"""Decorator that serializes access to all decorated functions.
The decorator acquires pyspotify's single global lock while calling any
wrapped function. It is used to serialize access to:
- All calls to functions on :attr:`spotify.lib`.
- All code blocks working on pointers re... | [
"def",
"serialized",
"(",
"f",
")",
":",
"import",
"functools",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"_lock",
":",
"return",
"f",
"(",
"*",
"args",
",",
"*",... | Decorator that serializes access to all decorated functions.
The decorator acquires pyspotify's single global lock while calling any
wrapped function. It is used to serialize access to:
- All calls to functions on :attr:`spotify.lib`.
- All code blocks working on pointers returned from functions on
... | [
"Decorator",
"that",
"serializes",
"access",
"to",
"all",
"decorated",
"functions",
"."
] | bd157fa4fb2b51b3641f198a35384678c1a4fa11 | https://github.com/chukysoria/pyspotify-connect/blob/bd157fa4fb2b51b3641f198a35384678c1a4fa11/spotifyconnect/__init__.py#L34-L61 |
51,967 | idmillington/layout | layout/pages/imposition.py | get_pocketmod_pages | def get_pocketmod_pages(elements,
page_edge_bottom=True,
first_page_vertical=True):
"""
Creates one or more managers that wraps the given elements into
one or more Pocket Mod-style page sets. Each manager in the list
that is returned corresponds to one pag... | python | def get_pocketmod_pages(elements,
page_edge_bottom=True,
first_page_vertical=True):
"""
Creates one or more managers that wraps the given elements into
one or more Pocket Mod-style page sets. Each manager in the list
that is returned corresponds to one pag... | [
"def",
"get_pocketmod_pages",
"(",
"elements",
",",
"page_edge_bottom",
"=",
"True",
",",
"first_page_vertical",
"=",
"True",
")",
":",
"pages",
"=",
"{",
"(",
"False",
",",
"False",
")",
":",
"[",
"2",
",",
"3",
",",
"4",
",",
"5",
",",
"1",
",",
... | Creates one or more managers that wraps the given elements into
one or more Pocket Mod-style page sets. Each manager in the list
that is returned corresponds to one page. This imposer is designed
to work with portrait oriented content pages, laid out onto a
landscape oriented page.
Arguments:
... | [
"Creates",
"one",
"or",
"more",
"managers",
"that",
"wraps",
"the",
"given",
"elements",
"into",
"one",
"or",
"more",
"Pocket",
"Mod",
"-",
"style",
"page",
"sets",
".",
"Each",
"manager",
"in",
"the",
"list",
"that",
"is",
"returned",
"corresponds",
"to",... | c452d1d7a74c9a74f7639c1b49e2a41c4e354bb5 | https://github.com/idmillington/layout/blob/c452d1d7a74c9a74f7639c1b49e2a41c4e354bb5/layout/pages/imposition.py#L252-L310 |
51,968 | zyga/python-glibc | pyglibc/select.py | epoll.close | def close(self):
"""
Close the internal epoll file descriptor if it isn't closed
:raises OSError:
If the underlying ``close(2)`` fails. The error message matches
those found in the manual page.
"""
with self._close_lock:
epfd = self._epfd
... | python | def close(self):
"""
Close the internal epoll file descriptor if it isn't closed
:raises OSError:
If the underlying ``close(2)`` fails. The error message matches
those found in the manual page.
"""
with self._close_lock:
epfd = self._epfd
... | [
"def",
"close",
"(",
"self",
")",
":",
"with",
"self",
".",
"_close_lock",
":",
"epfd",
"=",
"self",
".",
"_epfd",
"if",
"epfd",
">=",
"0",
":",
"self",
".",
"_epfd",
"=",
"-",
"1",
"close",
"(",
"epfd",
")"
] | Close the internal epoll file descriptor if it isn't closed
:raises OSError:
If the underlying ``close(2)`` fails. The error message matches
those found in the manual page. | [
"Close",
"the",
"internal",
"epoll",
"file",
"descriptor",
"if",
"it",
"isn",
"t",
"closed"
] | d6fdb306b123a995471584a5201155c60a34448a | https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/pyglibc/select.py#L125-L137 |
51,969 | zyga/python-glibc | pyglibc/select.py | epoll.fromfd | def fromfd(cls, fd):
"""
Create a new epoll object from a given file descriptor
:param fd:
A pre-made file descriptor obtained from ``epoll_create(2)`` or
``epoll_create1(2)``
:raises ValueError:
If fd is not a valid file descriptor
:returns:
... | python | def fromfd(cls, fd):
"""
Create a new epoll object from a given file descriptor
:param fd:
A pre-made file descriptor obtained from ``epoll_create(2)`` or
``epoll_create1(2)``
:raises ValueError:
If fd is not a valid file descriptor
:returns:
... | [
"def",
"fromfd",
"(",
"cls",
",",
"fd",
")",
":",
"if",
"fd",
"<",
"0",
":",
"_err_closed",
"(",
")",
"self",
"=",
"cls",
".",
"__new__",
"(",
")",
"object",
".",
"__init__",
"(",
"self",
")",
"self",
".",
"_epfd",
"=",
"fd",
"return",
"self"
] | Create a new epoll object from a given file descriptor
:param fd:
A pre-made file descriptor obtained from ``epoll_create(2)`` or
``epoll_create1(2)``
:raises ValueError:
If fd is not a valid file descriptor
:returns:
A new epoll object
.... | [
"Create",
"a",
"new",
"epoll",
"object",
"from",
"a",
"given",
"file",
"descriptor"
] | d6fdb306b123a995471584a5201155c60a34448a | https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/pyglibc/select.py#L160-L181 |
51,970 | zyga/python-glibc | pyglibc/select.py | epoll.register | def register(self, fd, eventmask=None):
"""
Register a new descriptor
:param fd:
The descriptor to register.
:param eventmask:
Bit-mask of events that will be monitored. By default EPOLLIN,
EPOLLOUT and EPOLLPRI are used. Note that EPOLLHUP is implici... | python | def register(self, fd, eventmask=None):
"""
Register a new descriptor
:param fd:
The descriptor to register.
:param eventmask:
Bit-mask of events that will be monitored. By default EPOLLIN,
EPOLLOUT and EPOLLPRI are used. Note that EPOLLHUP is implici... | [
"def",
"register",
"(",
"self",
",",
"fd",
",",
"eventmask",
"=",
"None",
")",
":",
"if",
"self",
".",
"_epfd",
"<",
"0",
":",
"_err_closed",
"(",
")",
"if",
"eventmask",
"is",
"None",
":",
"eventmask",
"=",
"EPOLLIN",
"|",
"EPOLLOUT",
"|",
"EPOLLPRI... | Register a new descriptor
:param fd:
The descriptor to register.
:param eventmask:
Bit-mask of events that will be monitored. By default EPOLLIN,
EPOLLOUT and EPOLLPRI are used. Note that EPOLLHUP is implicit and
doesn't need to be provided.
:rais... | [
"Register",
"a",
"new",
"descriptor"
] | d6fdb306b123a995471584a5201155c60a34448a | https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/pyglibc/select.py#L183-L206 |
51,971 | zyga/python-glibc | pyglibc/select.py | epoll.unregister | def unregister(self, fd):
"""
Unregister a previously registered descriptor
:param fd:
The descriptor to unregister
:raises ValueError:
If :meth:`closed()` is True
:raises OSError:
If the underlying ``epoll_ctl(2)`` fails. The error message ma... | python | def unregister(self, fd):
"""
Unregister a previously registered descriptor
:param fd:
The descriptor to unregister
:raises ValueError:
If :meth:`closed()` is True
:raises OSError:
If the underlying ``epoll_ctl(2)`` fails. The error message ma... | [
"def",
"unregister",
"(",
"self",
",",
"fd",
")",
":",
"if",
"self",
".",
"_epfd",
"<",
"0",
":",
"_err_closed",
"(",
")",
"ev",
"=",
"epoll_event",
"(",
")",
"try",
":",
"epoll_ctl",
"(",
"self",
".",
"_epfd",
",",
"EPOLL_CTL_DEL",
",",
"fd",
",",... | Unregister a previously registered descriptor
:param fd:
The descriptor to unregister
:raises ValueError:
If :meth:`closed()` is True
:raises OSError:
If the underlying ``epoll_ctl(2)`` fails. The error message matches
those found in the manual pa... | [
"Unregister",
"a",
"previously",
"registered",
"descriptor"
] | d6fdb306b123a995471584a5201155c60a34448a | https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/pyglibc/select.py#L208-L232 |
51,972 | zyga/python-glibc | pyglibc/select.py | epoll.modify | def modify(self, fd, eventmask):
"""
Change the bit-mask of events associated with a previously-registered
descriptor.
:param fd:
The descriptor to modify.
:param eventmask:
New bit-mask of events that will be monitored.
:raises ValueError:
... | python | def modify(self, fd, eventmask):
"""
Change the bit-mask of events associated with a previously-registered
descriptor.
:param fd:
The descriptor to modify.
:param eventmask:
New bit-mask of events that will be monitored.
:raises ValueError:
... | [
"def",
"modify",
"(",
"self",
",",
"fd",
",",
"eventmask",
")",
":",
"if",
"self",
".",
"_epfd",
"<",
"0",
":",
"_err_closed",
"(",
")",
"ev",
"=",
"epoll_event",
"(",
")",
"ev",
".",
"events",
"=",
"eventmask",
"ev",
".",
"data",
".",
"fd",
"=",... | Change the bit-mask of events associated with a previously-registered
descriptor.
:param fd:
The descriptor to modify.
:param eventmask:
New bit-mask of events that will be monitored.
:raises ValueError:
If :meth:`closed()` is True
:raises OSE... | [
"Change",
"the",
"bit",
"-",
"mask",
"of",
"events",
"associated",
"with",
"a",
"previously",
"-",
"registered",
"descriptor",
"."
] | d6fdb306b123a995471584a5201155c60a34448a | https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/pyglibc/select.py#L234-L254 |
51,973 | zyga/python-glibc | pyglibc/select.py | epoll.poll | def poll(self, timeout=-1, maxevents=-1):
"""
Poll for events
:param timeout:
The amount of seconds to wait for events before giving up. The
default value, -1, represents infinity. Note that unlike the
underlying ``epoll_wait()`` timeout is a fractional numbe... | python | def poll(self, timeout=-1, maxevents=-1):
"""
Poll for events
:param timeout:
The amount of seconds to wait for events before giving up. The
default value, -1, represents infinity. Note that unlike the
underlying ``epoll_wait()`` timeout is a fractional numbe... | [
"def",
"poll",
"(",
"self",
",",
"timeout",
"=",
"-",
"1",
",",
"maxevents",
"=",
"-",
"1",
")",
":",
"if",
"self",
".",
"_epfd",
"<",
"0",
":",
"_err_closed",
"(",
")",
"if",
"timeout",
"!=",
"-",
"1",
":",
"# 1000 because epoll_wait(2) uses milliseco... | Poll for events
:param timeout:
The amount of seconds to wait for events before giving up. The
default value, -1, represents infinity. Note that unlike the
underlying ``epoll_wait()`` timeout is a fractional number
representing **seconds**.
:param maxeven... | [
"Poll",
"for",
"events"
] | d6fdb306b123a995471584a5201155c60a34448a | https://github.com/zyga/python-glibc/blob/d6fdb306b123a995471584a5201155c60a34448a/pyglibc/select.py#L256-L290 |
51,974 | Vauxoo/cfdilib | cfdilib/cfdilib.py | BaseDocument.validate | def validate(self, schema_str, xml_valid):
"""Compare the valid information on an xml from given schema.
:param str schema_str: content string from schema file.
:param str xml_valid: content string from xml file.
:returns: If it is Valid or Not.
:rtype: bool
"""
... | python | def validate(self, schema_str, xml_valid):
"""Compare the valid information on an xml from given schema.
:param str schema_str: content string from schema file.
:param str xml_valid: content string from xml file.
:returns: If it is Valid or Not.
:rtype: bool
"""
... | [
"def",
"validate",
"(",
"self",
",",
"schema_str",
",",
"xml_valid",
")",
":",
"# TODO: be able to get doc for error given an xsd.",
"# Changed path to allow have xsd that are imported by others xsd in the",
"# same library, and not call to SAT page each time that is generated",
"# a new X... | Compare the valid information on an xml from given schema.
:param str schema_str: content string from schema file.
:param str xml_valid: content string from xml file.
:returns: If it is Valid or Not.
:rtype: bool | [
"Compare",
"the",
"valid",
"information",
"on",
"an",
"xml",
"from",
"given",
"schema",
"."
] | acd73d159f62119f3100d963a061820bbe3f93ea | https://github.com/Vauxoo/cfdilib/blob/acd73d159f62119f3100d963a061820bbe3f93ea/cfdilib/cfdilib.py#L158-L186 |
51,975 | Vauxoo/cfdilib | cfdilib/cfdilib.py | BaseDocument.set_xml | def set_xml(self):
"""Set document xml just rendered already
validated against xsd to be signed.
:params boolean debug_mode: Either if you want
the rendered template to be saved either it
is valid or not with the given schema.
:returns boolean: Either was valid or no... | python | def set_xml(self):
"""Set document xml just rendered already
validated against xsd to be signed.
:params boolean debug_mode: Either if you want
the rendered template to be saved either it
is valid or not with the given schema.
:returns boolean: Either was valid or no... | [
"def",
"set_xml",
"(",
"self",
")",
":",
"cached",
"=",
"StringIO",
"(",
")",
"document",
"=",
"u''",
"try",
":",
"document",
"=",
"self",
".",
"template",
".",
"render",
"(",
"inv",
"=",
"self",
")",
"except",
"UndefinedError",
"as",
"ups",
":",
"se... | Set document xml just rendered already
validated against xsd to be signed.
:params boolean debug_mode: Either if you want
the rendered template to be saved either it
is valid or not with the given schema.
:returns boolean: Either was valid or not the generated document. | [
"Set",
"document",
"xml",
"just",
"rendered",
"already",
"validated",
"against",
"xsd",
"to",
"be",
"signed",
"."
] | acd73d159f62119f3100d963a061820bbe3f93ea | https://github.com/Vauxoo/cfdilib/blob/acd73d159f62119f3100d963a061820bbe3f93ea/cfdilib/cfdilib.py#L188-L217 |
51,976 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_record | def get_record(uid=None):
"""Get a single record
"""
obj = None
if uid is not None:
obj = get_object_by_uid(uid)
else:
obj = get_object_by_request()
if obj is None:
fail(404, "No object found")
complete = req.get_complete(default=_marker)
if complete is _marker:
... | python | def get_record(uid=None):
"""Get a single record
"""
obj = None
if uid is not None:
obj = get_object_by_uid(uid)
else:
obj = get_object_by_request()
if obj is None:
fail(404, "No object found")
complete = req.get_complete(default=_marker)
if complete is _marker:
... | [
"def",
"get_record",
"(",
"uid",
"=",
"None",
")",
":",
"obj",
"=",
"None",
"if",
"uid",
"is",
"not",
"None",
":",
"obj",
"=",
"get_object_by_uid",
"(",
"uid",
")",
"else",
":",
"obj",
"=",
"get_object_by_request",
"(",
")",
"if",
"obj",
"is",
"None"... | Get a single record | [
"Get",
"a",
"single",
"record"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L70-L84 |
51,977 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_batched | def get_batched(portal_type=None, uid=None, endpoint=None, **kw):
"""Get batched results
"""
# fetch the catalog results
results = get_search_results(portal_type=portal_type, uid=uid, **kw)
# fetch the batch params from the request
size = req.get_batch_size()
start = req.get_batch_start()
... | python | def get_batched(portal_type=None, uid=None, endpoint=None, **kw):
"""Get batched results
"""
# fetch the catalog results
results = get_search_results(portal_type=portal_type, uid=uid, **kw)
# fetch the batch params from the request
size = req.get_batch_size()
start = req.get_batch_start()
... | [
"def",
"get_batched",
"(",
"portal_type",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"endpoint",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"# fetch the catalog results",
"results",
"=",
"get_search_results",
"(",
"portal_type",
"=",
"portal_type",
",",
"ui... | Get batched results | [
"Get",
"batched",
"results"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L88-L107 |
51,978 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_info | def get_info(brain_or_object, endpoint=None, complete=False):
"""Extract the data from the catalog brain or object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root... | python | def get_info(brain_or_object, endpoint=None, complete=False):
"""Extract the data from the catalog brain or object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root... | [
"def",
"get_info",
"(",
"brain_or_object",
",",
"endpoint",
"=",
"None",
",",
"complete",
"=",
"False",
")",
":",
"# also extract the brain data for objects",
"if",
"not",
"is_brain",
"(",
"brain_or_object",
")",
":",
"brain_or_object",
"=",
"get_brain",
"(",
"bra... | Extract the data from the catalog brain or object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root of the items
:type endpoint: str/unicode
:param complete: Fl... | [
"Extract",
"the",
"data",
"from",
"the",
"catalog",
"brain",
"or",
"object"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L279-L338 |
51,979 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_parent_info | def get_parent_info(brain_or_object, endpoint=None):
"""Generate url information for the parent object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root of the item... | python | def get_parent_info(brain_or_object, endpoint=None):
"""Generate url information for the parent object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root of the item... | [
"def",
"get_parent_info",
"(",
"brain_or_object",
",",
"endpoint",
"=",
"None",
")",
":",
"# special case for the portal object",
"if",
"is_root",
"(",
"brain_or_object",
")",
":",
"return",
"{",
"}",
"# get the parent object",
"parent",
"=",
"get_parent",
"(",
"bra... | Generate url information for the parent object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root of the items
:type endpoint: str/unicode
:returns: URL informat... | [
"Generate",
"url",
"information",
"for",
"the",
"parent",
"object"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L367-L395 |
51,980 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_children_info | def get_children_info(brain_or_object, complete=False):
"""Generate data items of the contained contents
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param complete: Flag to wake up the object and fetch all data... | python | def get_children_info(brain_or_object, complete=False):
"""Generate data items of the contained contents
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param complete: Flag to wake up the object and fetch all data... | [
"def",
"get_children_info",
"(",
"brain_or_object",
",",
"complete",
"=",
"False",
")",
":",
"# fetch the contents (if folderish)",
"children",
"=",
"get_contents",
"(",
"brain_or_object",
")",
"def",
"extract_data",
"(",
"brain_or_object",
")",
":",
"return",
"get_in... | Generate data items of the contained contents
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param complete: Flag to wake up the object and fetch all data
:type complete: bool
:returns: info mapping of contain... | [
"Generate",
"data",
"items",
"of",
"the",
"contained",
"contents"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L398-L419 |
51,981 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_file_info | def get_file_info(obj, fieldname, default=None):
"""Extract file data from a file field
:param obj: Content object
:type obj: ATContentType/DexterityContentType
:param fieldname: Schema name of the field
:type fieldname: str/unicode
:returns: File data mapping
:rtype: dict
"""
# ex... | python | def get_file_info(obj, fieldname, default=None):
"""Extract file data from a file field
:param obj: Content object
:type obj: ATContentType/DexterityContentType
:param fieldname: Schema name of the field
:type fieldname: str/unicode
:returns: File data mapping
:rtype: dict
"""
# ex... | [
"def",
"get_file_info",
"(",
"obj",
",",
"fieldname",
",",
"default",
"=",
"None",
")",
":",
"# extract the file field from the object if omitted",
"field",
"=",
"get_field",
"(",
"obj",
",",
"fieldname",
")",
"# get the value with the fieldmanager",
"fm",
"=",
"IFiel... | Extract file data from a file field
:param obj: Content object
:type obj: ATContentType/DexterityContentType
:param fieldname: Schema name of the field
:type fieldname: str/unicode
:returns: File data mapping
:rtype: dict | [
"Extract",
"file",
"data",
"from",
"a",
"file",
"field"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L422-L454 |
51,982 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_workflow_info | def get_workflow_info(brain_or_object, endpoint=None):
"""Generate workflow information of the assigned workflows
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root ... | python | def get_workflow_info(brain_or_object, endpoint=None):
"""Generate workflow information of the assigned workflows
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root ... | [
"def",
"get_workflow_info",
"(",
"brain_or_object",
",",
"endpoint",
"=",
"None",
")",
":",
"# ensure we have a full content object",
"obj",
"=",
"get_object",
"(",
"brain_or_object",
")",
"# get the portal workflow tool",
"wf_tool",
"=",
"get_tool",
"(",
"\"portal_workfl... | Generate workflow information of the assigned workflows
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:param endpoint: The named URL endpoint for the root of the items
:type endpoint: str/unicode
:returns: Wor... | [
"Generate",
"workflow",
"information",
"of",
"the",
"assigned",
"workflows"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L457-L545 |
51,983 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | search | def search(**kw):
"""Search the catalog adapter
:returns: Catalog search results
:rtype: iterable
"""
portal = get_portal()
catalog = ICatalog(portal)
catalog_query = ICatalogQuery(catalog)
query = catalog_query.make_query(**kw)
return catalog(query) | python | def search(**kw):
"""Search the catalog adapter
:returns: Catalog search results
:rtype: iterable
"""
portal = get_portal()
catalog = ICatalog(portal)
catalog_query = ICatalogQuery(catalog)
query = catalog_query.make_query(**kw)
return catalog(query) | [
"def",
"search",
"(",
"*",
"*",
"kw",
")",
":",
"portal",
"=",
"get_portal",
"(",
")",
"catalog",
"=",
"ICatalog",
"(",
"portal",
")",
"catalog_query",
"=",
"ICatalogQuery",
"(",
"catalog",
")",
"query",
"=",
"catalog_query",
".",
"make_query",
"(",
"*",... | Search the catalog adapter
:returns: Catalog search results
:rtype: iterable | [
"Search",
"the",
"catalog",
"adapter"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L560-L570 |
51,984 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_search_results | def get_search_results(portal_type=None, uid=None, **kw):
"""Search the catalog and return the results
:returns: Catalog search results
:rtype: iterable
"""
# If we have an UID, return the object immediately
if uid is not None:
logger.info("UID '%s' found, returning the object immediat... | python | def get_search_results(portal_type=None, uid=None, **kw):
"""Search the catalog and return the results
:returns: Catalog search results
:rtype: iterable
"""
# If we have an UID, return the object immediately
if uid is not None:
logger.info("UID '%s' found, returning the object immediat... | [
"def",
"get_search_results",
"(",
"portal_type",
"=",
"None",
",",
"uid",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"# If we have an UID, return the object immediately",
"if",
"uid",
"is",
"not",
"None",
":",
"logger",
".",
"info",
"(",
"\"UID '%s' found, retu... | Search the catalog and return the results
:returns: Catalog search results
:rtype: iterable | [
"Search",
"the",
"catalog",
"and",
"return",
"the",
"results"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L573-L601 |
51,985 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_brain | def get_brain(brain_or_object):
"""Return a ZCatalog brain for the object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: True if the object is a catalog brain
:rtype: bool
"""
if is_brain(brai... | python | def get_brain(brain_or_object):
"""Return a ZCatalog brain for the object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: True if the object is a catalog brain
:rtype: bool
"""
if is_brain(brai... | [
"def",
"get_brain",
"(",
"brain_or_object",
")",
":",
"if",
"is_brain",
"(",
"brain_or_object",
")",
":",
"return",
"brain_or_object",
"if",
"is_root",
"(",
"brain_or_object",
")",
":",
"return",
"brain_or_object",
"# fetch the brain by UID",
"uid",
"=",
"get_uid",
... | Return a ZCatalog brain for the object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: True if the object is a catalog brain
:rtype: bool | [
"Return",
"a",
"ZCatalog",
"brain",
"for",
"the",
"object"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L622-L643 |
51,986 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_field | def get_field(brain_or_object, name, default=None):
"""Return the named field
"""
fields = get_fields(brain_or_object)
return fields.get(name, default) | python | def get_field(brain_or_object, name, default=None):
"""Return the named field
"""
fields = get_fields(brain_or_object)
return fields.get(name, default) | [
"def",
"get_field",
"(",
"brain_or_object",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"fields",
"=",
"get_fields",
"(",
"brain_or_object",
")",
"return",
"fields",
".",
"get",
"(",
"name",
",",
"default",
")"
] | Return the named field | [
"Return",
"the",
"named",
"field"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L706-L710 |
51,987 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_behaviors | def get_behaviors(brain_or_object):
"""Iterate over all behaviors that are assigned to the object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Behaviors
:rtype: list
"""
obj = get_object(bra... | python | def get_behaviors(brain_or_object):
"""Iterate over all behaviors that are assigned to the object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Behaviors
:rtype: list
"""
obj = get_object(bra... | [
"def",
"get_behaviors",
"(",
"brain_or_object",
")",
":",
"obj",
"=",
"get_object",
"(",
"brain_or_object",
")",
"if",
"not",
"is_dexterity_content",
"(",
"obj",
")",
":",
"fail",
"(",
"400",
",",
"\"Only Dexterity contents can have assigned behaviors\"",
")",
"assi... | Iterate over all behaviors that are assigned to the object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Behaviors
:rtype: list | [
"Iterate",
"over",
"all",
"behaviors",
"that",
"are",
"assigned",
"to",
"the",
"object"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L713-L731 |
51,988 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | is_path | def is_path(path):
"""Checks if the passed in path is a valid Path within the portal
:param path: The path to check
:type uid: string
:return: True if the path is a valid path within the portal
:rtype: bool
"""
if not isinstance(path, basestring):
return False
portal_path = get_... | python | def is_path(path):
"""Checks if the passed in path is a valid Path within the portal
:param path: The path to check
:type uid: string
:return: True if the path is a valid path within the portal
:rtype: bool
"""
if not isinstance(path, basestring):
return False
portal_path = get_... | [
"def",
"is_path",
"(",
"path",
")",
":",
"if",
"not",
"isinstance",
"(",
"path",
",",
"basestring",
")",
":",
"return",
"False",
"portal_path",
"=",
"get_path",
"(",
"get_portal",
"(",
")",
")",
"if",
"not",
"path",
".",
"startswith",
"(",
"portal_path",... | Checks if the passed in path is a valid Path within the portal
:param path: The path to check
:type uid: string
:return: True if the path is a valid path within the portal
:rtype: bool | [
"Checks",
"if",
"the",
"passed",
"in",
"path",
"is",
"a",
"valid",
"Path",
"within",
"the",
"portal"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L761-L777 |
51,989 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | to_json_value | def to_json_value(obj, fieldname, value=_marker, default=None):
"""JSON save value encoding
:param obj: Content object
:type obj: ATContentType/DexterityContentType
:param fieldname: Schema name of the field
:type fieldname: str/unicode
:param value: The field value
:type value: depends on ... | python | def to_json_value(obj, fieldname, value=_marker, default=None):
"""JSON save value encoding
:param obj: Content object
:type obj: ATContentType/DexterityContentType
:param fieldname: Schema name of the field
:type fieldname: str/unicode
:param value: The field value
:type value: depends on ... | [
"def",
"to_json_value",
"(",
"obj",
",",
"fieldname",
",",
"value",
"=",
"_marker",
",",
"default",
"=",
"None",
")",
":",
"# This function bridges the value of the field to a probably more complex",
"# JSON structure to return to the client.",
"# extract the value from the objec... | JSON save value encoding
:param obj: Content object
:type obj: ATContentType/DexterityContentType
:param fieldname: Schema name of the field
:type fieldname: str/unicode
:param value: The field value
:type value: depends on the field type
:returns: JSON encoded field value
:rtype: field... | [
"JSON",
"save",
"value",
"encoding"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L812-L849 |
51,990 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | is_date | def is_date(thing):
"""Checks if the given thing represents a date
:param thing: The object to check if it is a date
:type thing: arbitrary object
:returns: True if we have a date object
:rtype: bool
"""
# known date types
date_types = (datetime.datetime,
datetime.date... | python | def is_date(thing):
"""Checks if the given thing represents a date
:param thing: The object to check if it is a date
:type thing: arbitrary object
:returns: True if we have a date object
:rtype: bool
"""
# known date types
date_types = (datetime.datetime,
datetime.date... | [
"def",
"is_date",
"(",
"thing",
")",
":",
"# known date types",
"date_types",
"=",
"(",
"datetime",
".",
"datetime",
",",
"datetime",
".",
"date",
",",
"DateTime",
")",
"return",
"isinstance",
"(",
"thing",
",",
"date_types",
")"
] | Checks if the given thing represents a date
:param thing: The object to check if it is a date
:type thing: arbitrary object
:returns: True if we have a date object
:rtype: bool | [
"Checks",
"if",
"the",
"given",
"thing",
"represents",
"a",
"date"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L852-L864 |
51,991 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | to_iso_date | def to_iso_date(date, default=None):
"""ISO representation for the date object
:param date: A date object
:type field: datetime/DateTime
:returns: The ISO format of the date
:rtype: str
"""
# not a date
if not is_date(date):
return default
# handle Zope DateTime objects
... | python | def to_iso_date(date, default=None):
"""ISO representation for the date object
:param date: A date object
:type field: datetime/DateTime
:returns: The ISO format of the date
:rtype: str
"""
# not a date
if not is_date(date):
return default
# handle Zope DateTime objects
... | [
"def",
"to_iso_date",
"(",
"date",
",",
"default",
"=",
"None",
")",
":",
"# not a date",
"if",
"not",
"is_date",
"(",
"date",
")",
":",
"return",
"default",
"# handle Zope DateTime objects",
"if",
"isinstance",
"(",
"date",
",",
"(",
"DateTime",
")",
")",
... | ISO representation for the date object
:param date: A date object
:type field: datetime/DateTime
:returns: The ISO format of the date
:rtype: str | [
"ISO",
"representation",
"for",
"the",
"date",
"object"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L878-L896 |
51,992 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_contents | def get_contents(brain_or_object):
"""Lookup folder contents for this object.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: List of contained contents
:rtype: list/Products.ZCatalog.Lazy.LazyMap
... | python | def get_contents(brain_or_object):
"""Lookup folder contents for this object.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: List of contained contents
:rtype: list/Products.ZCatalog.Lazy.LazyMap
... | [
"def",
"get_contents",
"(",
"brain_or_object",
")",
":",
"# Nothing to do if the object is contentish",
"if",
"not",
"is_folderish",
"(",
"brain_or_object",
")",
":",
"return",
"[",
"]",
"# Returning objects (not brains) to make sure we do not miss any child.",
"# It may happen w... | Lookup folder contents for this object.
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: List of contained contents
:rtype: list/Products.ZCatalog.Lazy.LazyMap | [
"Lookup",
"folder",
"contents",
"for",
"this",
"object",
"."
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L899-L917 |
51,993 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_resource_mapping | def get_resource_mapping():
"""Map resources used in the routes to portal types
:returns: Mapping of resource->portal_type
:rtype: dict
"""
portal_types = get_portal_types()
resources = map(portal_type_to_resource, portal_types)
return dict(zip(resources, portal_types)) | python | def get_resource_mapping():
"""Map resources used in the routes to portal types
:returns: Mapping of resource->portal_type
:rtype: dict
"""
portal_types = get_portal_types()
resources = map(portal_type_to_resource, portal_types)
return dict(zip(resources, portal_types)) | [
"def",
"get_resource_mapping",
"(",
")",
":",
"portal_types",
"=",
"get_portal_types",
"(",
")",
"resources",
"=",
"map",
"(",
"portal_type_to_resource",
",",
"portal_types",
")",
"return",
"dict",
"(",
"zip",
"(",
"resources",
",",
"portal_types",
")",
")"
] | Map resources used in the routes to portal types
:returns: Mapping of resource->portal_type
:rtype: dict | [
"Map",
"resources",
"used",
"in",
"the",
"routes",
"to",
"portal",
"types"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L997-L1005 |
51,994 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | resource_to_portal_type | def resource_to_portal_type(resource):
"""Converts a resource to a portal type
:param resource: Resource name as it is used in the content route
:type name: string
:returns: Portal type name
:rtype: string
"""
if resource is None:
return None
resource_mapping = get_resource_map... | python | def resource_to_portal_type(resource):
"""Converts a resource to a portal type
:param resource: Resource name as it is used in the content route
:type name: string
:returns: Portal type name
:rtype: string
"""
if resource is None:
return None
resource_mapping = get_resource_map... | [
"def",
"resource_to_portal_type",
"(",
"resource",
")",
":",
"if",
"resource",
"is",
"None",
":",
"return",
"None",
"resource_mapping",
"=",
"get_resource_mapping",
"(",
")",
"portal_type",
"=",
"resource_mapping",
".",
"get",
"(",
"resource",
".",
"lower",
"(",... | Converts a resource to a portal type
:param resource: Resource name as it is used in the content route
:type name: string
:returns: Portal type name
:rtype: string | [
"Converts",
"a",
"resource",
"to",
"a",
"portal",
"type"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L1021-L1039 |
51,995 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_container_for | def get_container_for(portal_type):
"""Returns the single holding container object of this content type
:param portal_type: The portal type requested
:type portal_type: string
:returns: Folderish container where the portal type can be created
:rtype: AT content object
"""
container_paths = ... | python | def get_container_for(portal_type):
"""Returns the single holding container object of this content type
:param portal_type: The portal type requested
:type portal_type: string
:returns: Folderish container where the portal type can be created
:rtype: AT content object
"""
container_paths = ... | [
"def",
"get_container_for",
"(",
"portal_type",
")",
":",
"container_paths",
"=",
"config",
".",
"CONTAINER_PATHS_FOR_PORTAL_TYPES",
"container_path",
"=",
"container_paths",
".",
"get",
"(",
"portal_type",
")",
"if",
"container_path",
"is",
"None",
":",
"return",
"... | Returns the single holding container object of this content type
:param portal_type: The portal type requested
:type portal_type: string
:returns: Folderish container where the portal type can be created
:rtype: AT content object | [
"Returns",
"the",
"single",
"holding",
"container",
"object",
"of",
"this",
"content",
"type"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L1042-L1057 |
51,996 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_endpoint | def get_endpoint(brain_or_object, default=DEFAULT_ENDPOINT):
"""Calculate the endpoint for this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Endpoint for this object
:rtype: string
"""
... | python | def get_endpoint(brain_or_object, default=DEFAULT_ENDPOINT):
"""Calculate the endpoint for this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Endpoint for this object
:rtype: string
"""
... | [
"def",
"get_endpoint",
"(",
"brain_or_object",
",",
"default",
"=",
"DEFAULT_ENDPOINT",
")",
":",
"portal_type",
"=",
"get_portal_type",
"(",
"brain_or_object",
")",
"resource",
"=",
"portal_type_to_resource",
"(",
"portal_type",
")",
"# Try to get the right namespaced en... | Calculate the endpoint for this object
:param brain_or_object: A single catalog brain or content object
:type brain_or_object: ATContentType/DexterityContentType/CatalogBrain
:returns: Endpoint for this object
:rtype: string | [
"Calculate",
"the",
"endpoint",
"for",
"this",
"object"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L1090-L1110 |
51,997 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_object_by_record | def get_object_by_record(record):
"""Find an object by a given record
Inspects request the record to locate an object
:param record: A dictionary representation of an object
:type record: dict
:returns: Found Object or None
:rtype: object
"""
# nothing to do here
if not record:
... | python | def get_object_by_record(record):
"""Find an object by a given record
Inspects request the record to locate an object
:param record: A dictionary representation of an object
:type record: dict
:returns: Found Object or None
:rtype: object
"""
# nothing to do here
if not record:
... | [
"def",
"get_object_by_record",
"(",
"record",
")",
":",
"# nothing to do here",
"if",
"not",
"record",
":",
"return",
"None",
"if",
"record",
".",
"get",
"(",
"\"uid\"",
")",
":",
"return",
"get_object_by_uid",
"(",
"record",
"[",
"\"uid\"",
"]",
")",
"if",
... | Find an object by a given record
Inspects request the record to locate an object
:param record: A dictionary representation of an object
:type record: dict
:returns: Found Object or None
:rtype: object | [
"Find",
"an",
"object",
"by",
"a",
"given",
"record"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L1135-L1159 |
51,998 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_object_by_path | def get_object_by_path(path):
"""Find an object by a given physical path
:param path: The physical path of the object to find
:type path: string
:returns: Found Object or None
:rtype: object
"""
# nothing to do here
if not isinstance(path, basestring):
return None
# path m... | python | def get_object_by_path(path):
"""Find an object by a given physical path
:param path: The physical path of the object to find
:type path: string
:returns: Found Object or None
:rtype: object
"""
# nothing to do here
if not isinstance(path, basestring):
return None
# path m... | [
"def",
"get_object_by_path",
"(",
"path",
")",
":",
"# nothing to do here",
"if",
"not",
"isinstance",
"(",
"path",
",",
"basestring",
")",
":",
"return",
"None",
"# path must be a string",
"path",
"=",
"str",
"(",
"path",
")",
"portal",
"=",
"get_portal",
"("... | Find an object by a given physical path
:param path: The physical path of the object to find
:type path: string
:returns: Found Object or None
:rtype: object | [
"Find",
"an",
"object",
"by",
"a",
"given",
"physical",
"path"
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L1162-L1191 |
51,999 | senaite/senaite.jsonapi | src/senaite/jsonapi/api.py | get_member_ids | def get_member_ids():
"""Return all member ids of the portal.
"""
pm = get_tool("portal_membership")
member_ids = pm.listMemberIds()
# How can it be possible to get member ids with None?
return filter(lambda x: x, member_ids) | python | def get_member_ids():
"""Return all member ids of the portal.
"""
pm = get_tool("portal_membership")
member_ids = pm.listMemberIds()
# How can it be possible to get member ids with None?
return filter(lambda x: x, member_ids) | [
"def",
"get_member_ids",
"(",
")",
":",
"pm",
"=",
"get_tool",
"(",
"\"portal_membership\"",
")",
"member_ids",
"=",
"pm",
".",
"listMemberIds",
"(",
")",
"# How can it be possible to get member ids with None?",
"return",
"filter",
"(",
"lambda",
"x",
":",
"x",
",... | Return all member ids of the portal. | [
"Return",
"all",
"member",
"ids",
"of",
"the",
"portal",
"."
] | 871959f4b1c9edbb477e9456325527ca78e13ec6 | https://github.com/senaite/senaite.jsonapi/blob/871959f4b1c9edbb477e9456325527ca78e13ec6/src/senaite/jsonapi/api.py#L1212-L1218 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.