nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
stopstalk/stopstalk-deployment
10c3ab44c4ece33ae515f6888c15033db2004bb1
aws_lambda/spoj_aws_lambda_function/lambda_code/pip/_vendor/urllib3/connectionpool.py
python
HTTPConnectionPool._make_request
(self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw)
return httplib_response
Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout: Socket timeout in seconds for the request. This can be a float or integer, which will set the same timeout value for the socket connect and the socket read, or an instance of :class:`urllib3.util.Timeout`, which gives you more fine-grained control over your timeouts.
Perform a request on a given urllib connection object taken from our pool.
[ "Perform", "a", "request", "on", "a", "given", "urllib", "connection", "object", "taken", "from", "our", "pool", "." ]
def _make_request(self, conn, method, url, timeout=_Default, chunked=False, **httplib_request_kw): """ Perform a request on a given urllib connection object taken from our pool. :param conn: a connection from one of our connection pools :param timeout: Socket timeout in seconds for the request. This can be a float or integer, which will set the same timeout value for the socket connect and the socket read, or an instance of :class:`urllib3.util.Timeout`, which gives you more fine-grained control over your timeouts. """ self.num_requests += 1 timeout_obj = self._get_timeout(timeout) timeout_obj.start_connect() conn.timeout = timeout_obj.connect_timeout # Trigger any extra validation we need to do. try: self._validate_conn(conn) except (SocketTimeout, BaseSSLError) as e: # Py2 raises this as a BaseSSLError, Py3 raises it as socket timeout. self._raise_timeout(err=e, url=url, timeout_value=conn.timeout) raise # conn.request() calls httplib.*.request, not the method in # urllib3.request. It also calls makefile (recv) on the socket. if chunked: conn.request_chunked(method, url, **httplib_request_kw) else: conn.request(method, url, **httplib_request_kw) # Reset the timeout for the recv() on the socket read_timeout = timeout_obj.read_timeout # App Engine doesn't have a sock attr if getattr(conn, 'sock', None): # In Python 3 socket.py will catch EAGAIN and return None when you # try and read into the file pointer created by http.client, which # instead raises a BadStatusLine exception. Instead of catching # the exception and assuming all BadStatusLine exceptions are read # timeouts, check for a zero timeout before making the request. if read_timeout == 0: raise ReadTimeoutError( self, url, "Read timed out. (read timeout=%s)" % read_timeout) if read_timeout is Timeout.DEFAULT_TIMEOUT: conn.sock.settimeout(socket.getdefaulttimeout()) else: # None or a value conn.sock.settimeout(read_timeout) # Receive the response from the server try: try: # Python 2.7, use buffering of HTTP responses httplib_response = conn.getresponse(buffering=True) except TypeError: # Python 2.6 and older, Python 3 try: httplib_response = conn.getresponse() except Exception as e: # Remove the TypeError from the exception chain in Python 3; # otherwise it looks like a programming error was the cause. six.raise_from(e, None) except (SocketTimeout, BaseSSLError, SocketError) as e: self._raise_timeout(err=e, url=url, timeout_value=read_timeout) raise # AppEngine doesn't have a version attr. http_version = getattr(conn, '_http_vsn_str', 'HTTP/?') log.debug("%s://%s:%s \"%s %s %s\" %s %s", self.scheme, self.host, self.port, method, url, http_version, httplib_response.status, httplib_response.length) try: assert_header_parsing(httplib_response.msg) except (HeaderParsingError, TypeError) as hpe: # Platform-specific: Python 3 log.warning( 'Failed to parse headers (url=%s): %s', self._absolute_url(url), hpe, exc_info=True) return httplib_response
[ "def", "_make_request", "(", "self", ",", "conn", ",", "method", ",", "url", ",", "timeout", "=", "_Default", ",", "chunked", "=", "False", ",", "*", "*", "httplib_request_kw", ")", ":", "self", ".", "num_requests", "+=", "1", "timeout_obj", "=", "self",...
https://github.com/stopstalk/stopstalk-deployment/blob/10c3ab44c4ece33ae515f6888c15033db2004bb1/aws_lambda/spoj_aws_lambda_function/lambda_code/pip/_vendor/urllib3/connectionpool.py#L319-L402
learnables/cherry
80e78f8bb53c2e6bb8eece0ba74122e5d6d6216f
cherry/pg.py
python
generalized_advantage
(gamma, tau, rewards, dones, values, next_value)
return advantages
**Description** Computes the generalized advantage estimator. (GAE) **References** 1. Schulman et al. 2015. “High-Dimensional Continuous Control Using Generalized Advantage Estimation” 2. https://github.com/joschu/modular_rl/blob/master/modular_rl/core.py#L49 **Arguments** * **gamma** (float) - Discount factor. * **tau** (float) - Bias-variance trade-off. * **rewards** (tensor) - Tensor of rewards. * **dones** (tensor) - Tensor indicating episode termination. Entry is 1 if the transition led to a terminal (absorbing) state, 0 else. * **values** (tensor) - Values for the states producing the rewards. * **next_value** (tensor) - Value of the state obtained after the transition from the state used to compute the last value in `values`. **Returns** * tensor - Tensor of advantages. **Example** ~~~python mass, next_value = policy(replay[-1].next_state) advantages = generalized_advantage(0.99, 0.95, replay.reward(), replay.value(), replay.done(), next_value) ~~~
**Description**
[ "**", "Description", "**" ]
def generalized_advantage(gamma, tau, rewards, dones, values, next_value): """ **Description** Computes the generalized advantage estimator. (GAE) **References** 1. Schulman et al. 2015. “High-Dimensional Continuous Control Using Generalized Advantage Estimation” 2. https://github.com/joschu/modular_rl/blob/master/modular_rl/core.py#L49 **Arguments** * **gamma** (float) - Discount factor. * **tau** (float) - Bias-variance trade-off. * **rewards** (tensor) - Tensor of rewards. * **dones** (tensor) - Tensor indicating episode termination. Entry is 1 if the transition led to a terminal (absorbing) state, 0 else. * **values** (tensor) - Values for the states producing the rewards. * **next_value** (tensor) - Value of the state obtained after the transition from the state used to compute the last value in `values`. **Returns** * tensor - Tensor of advantages. **Example** ~~~python mass, next_value = policy(replay[-1].next_state) advantages = generalized_advantage(0.99, 0.95, replay.reward(), replay.value(), replay.done(), next_value) ~~~ """ rewards = _reshape_helper(rewards) dones = _reshape_helper(dones) values = _reshape_helper(values) next_value = _reshape_helper(next_value) msg = 'rewards, values, and dones must have equal length.' assert len(values) == len(rewards) == len(dones), msg next_values = th.cat((values[1:], next_value), dim=0) td_errors = ch.temporal_difference(gamma, rewards, dones, values, next_values) advantages = ch.discount(tau * gamma, td_errors, dones) return advantages
[ "def", "generalized_advantage", "(", "gamma", ",", "tau", ",", "rewards", ",", "dones", ",", "values", ",", "next_value", ")", ":", "rewards", "=", "_reshape_helper", "(", "rewards", ")", "dones", "=", "_reshape_helper", "(", "dones", ")", "values", "=", "...
https://github.com/learnables/cherry/blob/80e78f8bb53c2e6bb8eece0ba74122e5d6d6216f/cherry/pg.py#L15-L69
JulianEberius/SublimePythonIDE
d70e40abc0c9f347af3204c7b910e0d6bfd6e459
server/lib/python2/rope/refactor/suites.py
python
find_visible
(node, lines)
return find_visible_for_suite(root, lines)
Return the line which is visible from all `lines`
Return the line which is visible from all `lines`
[ "Return", "the", "line", "which", "is", "visible", "from", "all", "lines" ]
def find_visible(node, lines): """Return the line which is visible from all `lines`""" root = ast_suite_tree(node) return find_visible_for_suite(root, lines)
[ "def", "find_visible", "(", "node", ",", "lines", ")", ":", "root", "=", "ast_suite_tree", "(", "node", ")", "return", "find_visible_for_suite", "(", "root", ",", "lines", ")" ]
https://github.com/JulianEberius/SublimePythonIDE/blob/d70e40abc0c9f347af3204c7b910e0d6bfd6e459/server/lib/python2/rope/refactor/suites.py#L4-L7
Chaffelson/nipyapi
d3b186fd701ce308c2812746d98af9120955e810
nipyapi/nifi/models/process_group_name_dto.py
python
ProcessGroupNameDTO.__ne__
(self, other)
return not self == other
Returns true if both objects are not equal
Returns true if both objects are not equal
[ "Returns", "true", "if", "both", "objects", "are", "not", "equal" ]
def __ne__(self, other): """ Returns true if both objects are not equal """ return not self == other
[ "def", "__ne__", "(", "self", ",", "other", ")", ":", "return", "not", "self", "==", "other" ]
https://github.com/Chaffelson/nipyapi/blob/d3b186fd701ce308c2812746d98af9120955e810/nipyapi/nifi/models/process_group_name_dto.py#L149-L153
zhl2008/awd-platform
0416b31abea29743387b10b3914581fbe8e7da5e
web_flaskbb/Python-2.7.9/Demo/metaclasses/Trace.py
python
NotTracingWrapper.__call__
(self, *args, **kw)
return apply(self.func, (self.inst,) + args, kw)
[]
def __call__(self, *args, **kw): return apply(self.func, (self.inst,) + args, kw)
[ "def", "__call__", "(", "self", ",", "*", "args", ",", "*", "*", "kw", ")", ":", "return", "apply", "(", "self", ".", "func", ",", "(", "self", ".", "inst", ",", ")", "+", "args", ",", "kw", ")" ]
https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/Python-2.7.9/Demo/metaclasses/Trace.py#L87-L88
django-extensions/django-extensions
f67ff680cd6d7264cdce05309b537ac2e1ee4a70
django_extensions/management/commands/graph_models.py
python
Command.render_output_pydot
(self, dotdata, **kwargs)
Render model data as image using pydot.
Render model data as image using pydot.
[ "Render", "model", "data", "as", "image", "using", "pydot", "." ]
def render_output_pydot(self, dotdata, **kwargs): """Render model data as image using pydot.""" if not HAS_PYDOT: raise CommandError("You need to install pydot python module") graph = pydot.graph_from_dot_data(dotdata) if not graph: raise CommandError("pydot returned an error") if isinstance(graph, (list, tuple)): if len(graph) > 1: sys.stderr.write("Found more then one graph, rendering only the first one.\n") graph = graph[0] output_file = kwargs['outputfile'] formats = [ 'bmp', 'canon', 'cmap', 'cmapx', 'cmapx_np', 'dot', 'dia', 'emf', 'em', 'fplus', 'eps', 'fig', 'gd', 'gd2', 'gif', 'gv', 'imap', 'imap_np', 'ismap', 'jpe', 'jpeg', 'jpg', 'metafile', 'pdf', 'pic', 'plain', 'plain-ext', 'png', 'pov', 'ps', 'ps2', 'svg', 'svgz', 'tif', 'tiff', 'tk', 'vml', 'vmlz', 'vrml', 'wbmp', 'xdot', ] ext = output_file[output_file.rfind('.') + 1:] format_ = ext if ext in formats else 'raw' graph.write(output_file, format=format_)
[ "def", "render_output_pydot", "(", "self", ",", "dotdata", ",", "*", "*", "kwargs", ")", ":", "if", "not", "HAS_PYDOT", ":", "raise", "CommandError", "(", "\"You need to install pydot python module\"", ")", "graph", "=", "pydot", ".", "graph_from_dot_data", "(", ...
https://github.com/django-extensions/django-extensions/blob/f67ff680cd6d7264cdce05309b537ac2e1ee4a70/django_extensions/management/commands/graph_models.py#L310-L333
pycontribs/pyrax
a0c022981f76a4cba96a22ecc19bb52843ac4fbe
pyrax/image.py
python
ImageClient.add_image_tag
(self, img, tag)
return img.add_tag(tag)
Adds the tag to the specified image.
Adds the tag to the specified image.
[ "Adds", "the", "tag", "to", "the", "specified", "image", "." ]
def add_image_tag(self, img, tag): """ Adds the tag to the specified image. """ return img.add_tag(tag)
[ "def", "add_image_tag", "(", "self", ",", "img", ",", "tag", ")", ":", "return", "img", ".", "add_tag", "(", "tag", ")" ]
https://github.com/pycontribs/pyrax/blob/a0c022981f76a4cba96a22ecc19bb52843ac4fbe/pyrax/image.py#L641-L645
architv/chcli
e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7
challenges/writers.py
python
write_contest_header
(contest_type)
Prints the header for the type of contest
Prints the header for the type of contest
[ "Prints", "the", "header", "for", "the", "type", "of", "contest" ]
def write_contest_header(contest_type): """Prints the header for the type of contest""" if contest_type == challenge().ACTIVE: click.secho("%-3s %-50s %-20s %-11s %-15s" % ("NO.", "NAME", "ENDS IN", "DURATION", "PLATFORM")) elif contest_type == challenge().UPCOMING: click.secho("%-3s %-50s %-20s %-11s %-15s" % ("NO.", "NAME", "STARTS IN", "DURATION", "PLATFORM")) elif contest_type in [challenge().HIRING, challenge().SHORT, challenge().ALL]: click.secho("%-3s %-50s %-20s %-11s %-15s" % ("NO.", "NAME", "STARTS/ENDS IN", "DURATION", "PLATFORM"))
[ "def", "write_contest_header", "(", "contest_type", ")", ":", "if", "contest_type", "==", "challenge", "(", ")", ".", "ACTIVE", ":", "click", ".", "secho", "(", "\"%-3s %-50s %-20s %-11s %-15s\"", "%", "(", "\"NO.\"", ",", "\"NAME\"", ",", "\"ENDS IN\"",...
https://github.com/architv/chcli/blob/e9e387b9a85c6b64bc74b1a7c5b85baa4d4ea7d7/challenges/writers.py#L75-L85
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/pillar/etcd_pillar.py
python
__virtual__
()
return __virtualname__ if HAS_LIBS else False
Only return if python-etcd is installed
Only return if python-etcd is installed
[ "Only", "return", "if", "python", "-", "etcd", "is", "installed" ]
def __virtual__(): """ Only return if python-etcd is installed """ return __virtualname__ if HAS_LIBS else False
[ "def", "__virtual__", "(", ")", ":", "return", "__virtualname__", "if", "HAS_LIBS", "else", "False" ]
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/pillar/etcd_pillar.py#L76-L80
kuri65536/python-for-android
26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891
python-modules/twisted/twisted/lore/tree.py
python
getHeaders
(document)
return domhelpers.findElements( document, lambda n, m=re.compile('h[23]$').match: m(n.nodeName))
Return all H2 and H3 nodes in the given document. @type document: A DOM Node or Document @rtype: C{list}
Return all H2 and H3 nodes in the given document.
[ "Return", "all", "H2", "and", "H3", "nodes", "in", "the", "given", "document", "." ]
def getHeaders(document): """ Return all H2 and H3 nodes in the given document. @type document: A DOM Node or Document @rtype: C{list} """ return domhelpers.findElements( document, lambda n, m=re.compile('h[23]$').match: m(n.nodeName))
[ "def", "getHeaders", "(", "document", ")", ":", "return", "domhelpers", ".", "findElements", "(", "document", ",", "lambda", "n", ",", "m", "=", "re", ".", "compile", "(", "'h[23]$'", ")", ".", "match", ":", "m", "(", "n", ".", "nodeName", ")", ")" ]
https://github.com/kuri65536/python-for-android/blob/26402a08fc46b09ef94e8d7a6bbc3a54ff9d0891/python-modules/twisted/twisted/lore/tree.py#L308-L318
PyHDI/veriloggen
2382d200deabf59cfcfd741f5eba371010aaf2bb
veriloggen/types/fixed.py
python
_FixedVariable.assign
(self, value)
return vtypes._Variable.assign(self, v)
[]
def assign(self, value): v = self._adjust(value) return vtypes._Variable.assign(self, v)
[ "def", "assign", "(", "self", ",", "value", ")", ":", "v", "=", "self", ".", "_adjust", "(", "value", ")", "return", "vtypes", ".", "_Variable", ".", "assign", "(", "self", ",", "v", ")" ]
https://github.com/PyHDI/veriloggen/blob/2382d200deabf59cfcfd741f5eba371010aaf2bb/veriloggen/types/fixed.py#L395-L397
openstack/solum
93f8cc562d3c2ea0ab3af4061c07348e61f30806
solum/deployer/handlers/heat.py
python
Handler._parse_server_ip
(self, heat_output)
return None
Parse server ip from heat-stack-show output.
Parse server ip from heat-stack-show output.
[ "Parse", "server", "ip", "from", "heat", "-", "stack", "-", "show", "output", "." ]
def _parse_server_ip(self, heat_output): """Parse server ip from heat-stack-show output.""" if 'outputs' in heat_output._info: for outputs in heat_output._info['outputs']: if outputs['output_key'] == 'public_ip': return outputs['output_value'] return None
[ "def", "_parse_server_ip", "(", "self", ",", "heat_output", ")", ":", "if", "'outputs'", "in", "heat_output", ".", "_info", ":", "for", "outputs", "in", "heat_output", ".", "_info", "[", "'outputs'", "]", ":", "if", "outputs", "[", "'output_key'", "]", "==...
https://github.com/openstack/solum/blob/93f8cc562d3c2ea0ab3af4061c07348e61f30806/solum/deployer/handlers/heat.py#L767-L773
khanhnamle1994/natural-language-processing
01d450d5ac002b0156ef4cf93a07cb508c1bcdc5
assignment1/.env/lib/python2.7/site-packages/jinja2/lexer.py
python
describe_token
(token)
return _describe_token_type(token.type)
Returns a description of the token.
Returns a description of the token.
[ "Returns", "a", "description", "of", "the", "token", "." ]
def describe_token(token): """Returns a description of the token.""" if token.type == 'name': return token.value return _describe_token_type(token.type)
[ "def", "describe_token", "(", "token", ")", ":", "if", "token", ".", "type", "==", "'name'", ":", "return", "token", ".", "value", "return", "_describe_token_type", "(", "token", ".", "type", ")" ]
https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/jinja2/lexer.py#L164-L168
IronLanguages/ironpython3
7a7bb2a872eeab0d1009fc8a6e24dca43f65b693
Src/StdLib/Lib/imp.py
python
find_module
(name, path=None)
return file, file_path, (suffix, mode, type_)
**DEPRECATED** Search for a module. If path is omitted or None, search for a built-in, frozen or special module and continue search in sys.path. The module name cannot contain '.'; to search for a submodule of a package, pass the submodule name and the package's __path__.
**DEPRECATED**
[ "**", "DEPRECATED", "**" ]
def find_module(name, path=None): """**DEPRECATED** Search for a module. If path is omitted or None, search for a built-in, frozen or special module and continue search in sys.path. The module name cannot contain '.'; to search for a submodule of a package, pass the submodule name and the package's __path__. """ if not isinstance(name, str): raise TypeError("'name' must be a str, not {}".format(type(name))) elif not isinstance(path, (type(None), list)): # Backwards-compatibility raise RuntimeError("'list' must be None or a list, " "not {}".format(type(name))) if path is None: if is_builtin(name): return None, None, ('', '', C_BUILTIN) elif is_frozen(name): return None, None, ('', '', PY_FROZEN) else: path = sys.path for entry in path: package_directory = os.path.join(entry, name) for suffix in ['.py', machinery.BYTECODE_SUFFIXES[0]]: package_file_name = '__init__' + suffix file_path = os.path.join(package_directory, package_file_name) if os.path.isfile(file_path): return None, package_directory, ('', '', PKG_DIRECTORY) for suffix, mode, type_ in get_suffixes(): file_name = name + suffix file_path = os.path.join(entry, file_name) if os.path.isfile(file_path): break else: continue break # Break out of outer loop when breaking out of inner loop. else: raise ImportError(_ERR_MSG.format(name), name=name) encoding = None if 'b' not in mode: with open(file_path, 'rb') as file: encoding = tokenize.detect_encoding(file.readline)[0] file = open(file_path, mode, encoding=encoding) return file, file_path, (suffix, mode, type_)
[ "def", "find_module", "(", "name", ",", "path", "=", "None", ")", ":", "if", "not", "isinstance", "(", "name", ",", "str", ")", ":", "raise", "TypeError", "(", "\"'name' must be a str, not {}\"", ".", "format", "(", "type", "(", "name", ")", ")", ")", ...
https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/imp.py#L255-L304
bruderstein/PythonScript
df9f7071ddf3a079e3a301b9b53a6dc78cf1208f
PythonLib/full/xml/etree/ElementTree.py
python
ProcessingInstruction
(target, text=None)
return element
Processing Instruction element factory. This function creates a special element which the standard serializer serializes as an XML comment. *target* is a string containing the processing instruction, *text* is a string containing the processing instruction contents, if any.
Processing Instruction element factory.
[ "Processing", "Instruction", "element", "factory", "." ]
def ProcessingInstruction(target, text=None): """Processing Instruction element factory. This function creates a special element which the standard serializer serializes as an XML comment. *target* is a string containing the processing instruction, *text* is a string containing the processing instruction contents, if any. """ element = Element(ProcessingInstruction) element.text = target if text: element.text = element.text + " " + text return element
[ "def", "ProcessingInstruction", "(", "target", ",", "text", "=", "None", ")", ":", "element", "=", "Element", "(", "ProcessingInstruction", ")", "element", ".", "text", "=", "target", "if", "text", ":", "element", ".", "text", "=", "element", ".", "text", ...
https://github.com/bruderstein/PythonScript/blob/df9f7071ddf3a079e3a301b9b53a6dc78cf1208f/PythonLib/full/xml/etree/ElementTree.py#L458-L472
saltstack/salt
fae5bc757ad0f1716483ce7ae180b451545c2058
salt/cloud/clouds/virtualbox.py
python
start
(name, call=None)
return treat_machine_dict(machine)
Start a machine. @param name: Machine to start @type name: str @param call: Must be "action" @type call: str
Start a machine.
[ "Start", "a", "machine", "." ]
def start(name, call=None): """ Start a machine. @param name: Machine to start @type name: str @param call: Must be "action" @type call: str """ if call != "action": raise SaltCloudSystemExit( "The instance action must be called with -a or --action." ) log.info("Starting machine: %s", name) vb_start_vm(name) machine = vb_get_machine(name) del machine["name"] return treat_machine_dict(machine)
[ "def", "start", "(", "name", ",", "call", "=", "None", ")", ":", "if", "call", "!=", "\"action\"", ":", "raise", "SaltCloudSystemExit", "(", "\"The instance action must be called with -a or --action.\"", ")", "log", ".", "info", "(", "\"Starting machine: %s\"", ",",...
https://github.com/saltstack/salt/blob/fae5bc757ad0f1716483ce7ae180b451545c2058/salt/cloud/clouds/virtualbox.py#L393-L410
wecatch/app-turbo
d3b931db1b0f210d8af1da109edbf88756fa427d
turbo/util.py
python
camel_to_underscore
(name)
return ''.join(as_list)
convert CamelCase style to under_score_case
convert CamelCase style to under_score_case
[ "convert", "CamelCase", "style", "to", "under_score_case" ]
def camel_to_underscore(name): """ convert CamelCase style to under_score_case """ as_list = [] length = len(name) for index, i in enumerate(name): if index != 0 and index != length - 1 and i.isupper(): as_list.append('_%s' % i.lower()) else: as_list.append(i.lower()) return ''.join(as_list)
[ "def", "camel_to_underscore", "(", "name", ")", ":", "as_list", "=", "[", "]", "length", "=", "len", "(", "name", ")", "for", "index", ",", "i", "in", "enumerate", "(", "name", ")", ":", "if", "index", "!=", "0", "and", "index", "!=", "length", "-"...
https://github.com/wecatch/app-turbo/blob/d3b931db1b0f210d8af1da109edbf88756fa427d/turbo/util.py#L224-L236
krintoxi/NoobSec-Toolkit
38738541cbc03cedb9a3b3ed13b629f781ad64f6
NoobSecToolkit /tools/sqli/thirdparty/bottle/bottle.py
python
MultiDict.__contains__
(self, key)
return key in self.dict
[]
def __contains__(self, key): return key in self.dict
[ "def", "__contains__", "(", "self", ",", "key", ")", ":", "return", "key", "in", "self", ".", "dict" ]
https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /tools/sqli/thirdparty/bottle/bottle.py#L1702-L1702
thatmattlove/hyperglass
c52a6f609843177671d38bcad59b8bd658f46b64
hyperglass/external/msteams.py
python
MSTeams.__init__
(self, config)
Initialize external base class with Microsoft Teams connection details.
Initialize external base class with Microsoft Teams connection details.
[ "Initialize", "external", "base", "class", "with", "Microsoft", "Teams", "connection", "details", "." ]
def __init__(self, config): """Initialize external base class with Microsoft Teams connection details.""" super().__init__( base_url="https://outlook.office.com", config=config, parse=False )
[ "def", "__init__", "(", "self", ",", "config", ")", ":", "super", "(", ")", ".", "__init__", "(", "base_url", "=", "\"https://outlook.office.com\"", ",", "config", "=", "config", ",", "parse", "=", "False", ")" ]
https://github.com/thatmattlove/hyperglass/blob/c52a6f609843177671d38bcad59b8bd658f46b64/hyperglass/external/msteams.py#L12-L17
timonwong/OmniMarkupPreviewer
21921ac7a99d2b5924a2219b33679a5b53621392
OmniMarkupLib/Renderers/libs/markdown/odict.py
python
OrderedDict.index_for_location
(self, location)
return i
Return index or None for a given location.
Return index or None for a given location.
[ "Return", "index", "or", "None", "for", "a", "given", "location", "." ]
def index_for_location(self, location): """ Return index or None for a given location. """ if location == '_begin': i = 0 elif location == '_end': i = None elif location.startswith('<') or location.startswith('>'): i = self.index(location[1:]) if location.startswith('>'): if i >= len(self): # last item i = None else: i += 1 else: raise ValueError('Not a valid location: "%s". Location key ' 'must start with a ">" or "<".' % location) return i
[ "def", "index_for_location", "(", "self", ",", "location", ")", ":", "if", "location", "==", "'_begin'", ":", "i", "=", "0", "elif", "location", "==", "'_end'", ":", "i", "=", "None", "elif", "location", ".", "startswith", "(", "'<'", ")", "or", "locat...
https://github.com/timonwong/OmniMarkupPreviewer/blob/21921ac7a99d2b5924a2219b33679a5b53621392/OmniMarkupLib/Renderers/libs/markdown/odict.py#L149-L166
openedx/edx-platform
68dd185a0ab45862a2a61e0f803d7e03d2be71b5
common/lib/xmodule/xmodule/modulestore/xml.py
python
LibraryXMLModuleStore.patch_descriptor_kvs
(library_descriptor)
Metadata inheritance can be done purely through XBlocks, but in the import phase a root block with an InheritanceKeyValueStore is assumed to be at the top of the hierarchy. This should change in the future, but as XBlocks don't have this KVS, we have to patch it here manually.
Metadata inheritance can be done purely through XBlocks, but in the import phase a root block with an InheritanceKeyValueStore is assumed to be at the top of the hierarchy. This should change in the future, but as XBlocks don't have this KVS, we have to patch it here manually.
[ "Metadata", "inheritance", "can", "be", "done", "purely", "through", "XBlocks", "but", "in", "the", "import", "phase", "a", "root", "block", "with", "an", "InheritanceKeyValueStore", "is", "assumed", "to", "be", "at", "the", "top", "of", "the", "hierarchy", ...
def patch_descriptor_kvs(library_descriptor): """ Metadata inheritance can be done purely through XBlocks, but in the import phase a root block with an InheritanceKeyValueStore is assumed to be at the top of the hierarchy. This should change in the future, but as XBlocks don't have this KVS, we have to patch it here manually. """ init_dict = {key: getattr(library_descriptor, key) for key in library_descriptor.fields.keys()} # if set, invalidate '_unwrapped_field_data' so it will be reset # the next time it will be called lazy.invalidate(library_descriptor, '_unwrapped_field_data') # pylint: disable=protected-access library_descriptor._field_data = inheriting_field_data(InheritanceKeyValueStore(init_dict))
[ "def", "patch_descriptor_kvs", "(", "library_descriptor", ")", ":", "init_dict", "=", "{", "key", ":", "getattr", "(", "library_descriptor", ",", "key", ")", "for", "key", "in", "library_descriptor", ".", "fields", ".", "keys", "(", ")", "}", "# if set, invali...
https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/common/lib/xmodule/xmodule/modulestore/xml.py#L895-L907
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/combinat/words/morphism.py
python
WordMorphism.letter_growth_types
(self)
return mortal, polynomial, exponential
r""" Return the mortal, polynomial and exponential growing letters. The growth of `| s^n(a) |` as `n` goes to `\infty` is always of the form `\alpha^n n^\beta` (where `\alpha` is a Perron number and `\beta` an integer). Without doing any linear algebra three cases can be differentiated: mortal (ultimately empty or `\alpha=0`); polynomial (`\alpha=1`); exponential (`\alpha > 1`). This is what is done in this method. It requires this morphism to be an endomorphism. OUTPUT: The output is a 3-tuple of lists (mortal, polynomial, exponential) where: - ``mortal``: list of mortal letters - ``polynomial``: a list of lists where ``polynomial[i]`` is the list of letters with growth `n^i`. - ``exponential``: list of at least exponentionally growing letters EXAMPLES:: sage: s = WordMorphism('a->abc,b->bc,c->c') sage: mortal, poly, expo = s.letter_growth_types() sage: mortal [] sage: poly [['c'], ['b'], ['a']] sage: expo [] When three mortal letters (c, d, and e), and two letters (a, b) are not growing:: sage: s = WordMorphism('a->bc,b->cac,c->de,d->,e->') sage: s^20 WordMorphism: a->cacde, b->debcde, c->, d->, e-> sage: mortal, poly, expo = s.letter_growth_types() sage: mortal ['c', 'd', 'e'] sage: poly [['a', 'b']] sage: expo [] :: sage: s = WordMorphism('a->abcd,b->bc,c->c,d->a') sage: mortal, poly, expo = s.letter_growth_types() sage: mortal [] sage: poly [['c'], ['b']] sage: expo ['a', 'd'] TESTS:: sage: s = WordMorphism('a->a') sage: s.letter_growth_types() ([], [['a']], []) :: sage: s = WordMorphism('a->b,b->a') sage: s.letter_growth_types() ([], [['a', 'b']], []) :: sage: s = WordMorphism('a->abcd,b->cd,c->dd,d->') sage: s.letter_growth_types() (['b', 'c', 'd'], [['a']], []) :: sage: s = WordMorphism('a->', domain=Words('a'), codomain=Words('a')) sage: s.letter_growth_types() (['a'], [], [])
r""" Return the mortal, polynomial and exponential growing letters.
[ "r", "Return", "the", "mortal", "polynomial", "and", "exponential", "growing", "letters", "." ]
def letter_growth_types(self): r""" Return the mortal, polynomial and exponential growing letters. The growth of `| s^n(a) |` as `n` goes to `\infty` is always of the form `\alpha^n n^\beta` (where `\alpha` is a Perron number and `\beta` an integer). Without doing any linear algebra three cases can be differentiated: mortal (ultimately empty or `\alpha=0`); polynomial (`\alpha=1`); exponential (`\alpha > 1`). This is what is done in this method. It requires this morphism to be an endomorphism. OUTPUT: The output is a 3-tuple of lists (mortal, polynomial, exponential) where: - ``mortal``: list of mortal letters - ``polynomial``: a list of lists where ``polynomial[i]`` is the list of letters with growth `n^i`. - ``exponential``: list of at least exponentionally growing letters EXAMPLES:: sage: s = WordMorphism('a->abc,b->bc,c->c') sage: mortal, poly, expo = s.letter_growth_types() sage: mortal [] sage: poly [['c'], ['b'], ['a']] sage: expo [] When three mortal letters (c, d, and e), and two letters (a, b) are not growing:: sage: s = WordMorphism('a->bc,b->cac,c->de,d->,e->') sage: s^20 WordMorphism: a->cacde, b->debcde, c->, d->, e-> sage: mortal, poly, expo = s.letter_growth_types() sage: mortal ['c', 'd', 'e'] sage: poly [['a', 'b']] sage: expo [] :: sage: s = WordMorphism('a->abcd,b->bc,c->c,d->a') sage: mortal, poly, expo = s.letter_growth_types() sage: mortal [] sage: poly [['c'], ['b']] sage: expo ['a', 'd'] TESTS:: sage: s = WordMorphism('a->a') sage: s.letter_growth_types() ([], [['a']], []) :: sage: s = WordMorphism('a->b,b->a') sage: s.letter_growth_types() ([], [['a', 'b']], []) :: sage: s = WordMorphism('a->abcd,b->cd,c->dd,d->') sage: s.letter_growth_types() (['b', 'c', 'd'], [['a']], []) :: sage: s = WordMorphism('a->', domain=Words('a'), codomain=Words('a')) sage: s.letter_growth_types() (['a'], [], []) """ immortal = set(self.immortal_letters()) mortal = [a for a in self.domain().alphabet() if a not in immortal] # Starting with degree d=0, search for letters with polynomial # growth of degree d. polynomial = [] m = {a : [b for b in self.image(a) if b in immortal] for a in immortal} while True: # Construct the permutation of letters containing all letters whose # iterated images under morphism m is always of length 1. not_growing = {a : image_a[0] for (a,image_a) in m.items() if len(image_a) == 1} preimages = {} roots = [] for k, v in not_growing.items(): if v not in not_growing: roots.append(v) if v not in preimages: preimages[v] = [] preimages[v].append(k) while roots: v = roots.pop() for k in preimages.get(v): del not_growing[k] if k in preimages: roots.append(k) # The letters inside not_growing are the ones with polynomial # growth d. If there is none, then the remaining letters in m # have exponential growth. if not not_growing: break polynomial.append(list(not_growing)) # clean the morphism m for the next iteration by removing the # letters with polynomial growth degree d m = {a : [b for b in L if b not in not_growing] for a, L in m.items() if a not in not_growing} exponential = list(m) # sort the letters as in the input alphabet if possible A = self.domain().alphabet() try: rank = A.rank except AttributeError: pass else: mortal.sort(key=rank) for letters in polynomial: letters.sort(key=rank) exponential.sort(key=rank) return mortal, polynomial, exponential
[ "def", "letter_growth_types", "(", "self", ")", ":", "immortal", "=", "set", "(", "self", ".", "immortal_letters", "(", ")", ")", "mortal", "=", "[", "a", "for", "a", "in", "self", ".", "domain", "(", ")", ".", "alphabet", "(", ")", "if", "a", "not...
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/combinat/words/morphism.py#L3211-L3349
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_utils/library/docker_creds.py
python
check_dest_dir_exists
(module, dest)
Check if dest dir is present and is a directory
Check if dest dir is present and is a directory
[ "Check", "if", "dest", "dir", "is", "present", "and", "is", "a", "directory" ]
def check_dest_dir_exists(module, dest): '''Check if dest dir is present and is a directory''' dir_exists = os.path.exists(dest) if dir_exists: if not os.path.isdir(dest): msg = "{} exists but is not a directory".format(dest) result = {'failed': True, 'changed': False, 'msg': msg, 'state': 'unknown'} module.fail_json(**result) else: return 1 else: return 0
[ "def", "check_dest_dir_exists", "(", "module", ",", "dest", ")", ":", "dir_exists", "=", "os", ".", "path", ".", "exists", "(", "dest", ")", "if", "dir_exists", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "dest", ")", ":", "msg", "=", "...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_utils/library/docker_creds.py#L72-L86
HunterMcGushion/hyperparameter_hunter
28b1d48e01a993818510811b82a677e0a7a232b2
hyperparameter_hunter/space/dimensions.py
python
Dimension._check_distance
(self, a, b)
Check that two points fit within the dimension's bounds Raises ------ RuntimeError If either `a` or `b` fall outside the dimension's original (untransformed) bounds
Check that two points fit within the dimension's bounds
[ "Check", "that", "two", "points", "fit", "within", "the", "dimension", "s", "bounds" ]
def _check_distance(self, a, b): """Check that two points fit within the dimension's bounds Raises ------ RuntimeError If either `a` or `b` fall outside the dimension's original (untransformed) bounds""" if not (a in self and b in self): raise RuntimeError( f"Distance computation requires values within space. Received {a} and {b}" )
[ "def", "_check_distance", "(", "self", ",", "a", ",", "b", ")", ":", "if", "not", "(", "a", "in", "self", "and", "b", "in", "self", ")", ":", "raise", "RuntimeError", "(", "f\"Distance computation requires values within space. Received {a} and {b}\"", ")" ]
https://github.com/HunterMcGushion/hyperparameter_hunter/blob/28b1d48e01a993818510811b82a677e0a7a232b2/hyperparameter_hunter/space/dimensions.py#L286-L296
golismero/golismero
7d605b937e241f51c1ca4f47b20f755eeefb9d76
thirdparty_libs/texttable.py
python
Texttable._str
(self, i, x)
Handles string formatting of cell data i - index of the cell datatype in self._dtype x - cell data to format
Handles string formatting of cell data
[ "Handles", "string", "formatting", "of", "cell", "data" ]
def _str(self, i, x): """Handles string formatting of cell data i - index of the cell datatype in self._dtype x - cell data to format """ try: f = float(x) except: return str(x) n = self._precision dtype = self._dtype[i] if dtype == 'i': return str(int(round(f))) elif dtype == 'f': return '%.*f' % (n, f) elif dtype == 'e': return '%.*e' % (n, f) elif dtype == 't': return str(x) else: if f - round(f) == 0: if abs(f) > 1e8: return '%.*e' % (n, f) else: return str(int(round(f))) else: if abs(f) > 1e8: return '%.*e' % (n, f) else: return '%.*f' % (n, f)
[ "def", "_str", "(", "self", ",", "i", ",", "x", ")", ":", "try", ":", "f", "=", "float", "(", "x", ")", "except", ":", "return", "str", "(", "x", ")", "n", "=", "self", ".", "_precision", "dtype", "=", "self", ".", "_dtype", "[", "i", "]", ...
https://github.com/golismero/golismero/blob/7d605b937e241f51c1ca4f47b20f755eeefb9d76/thirdparty_libs/texttable.py#L369-L401
carnal0wnage/weirdAAL
c14e36d7bb82447f38a43da203f4bc29429f4cf4
libs/aws/brute.py
python
brute_cloudsearch_permissions
()
return generic_permission_bruteforcer('cloudsearch', tests)
http://boto3.readthedocs.io/en/latest/reference/services/cloudsearch.html
http://boto3.readthedocs.io/en/latest/reference/services/cloudsearch.html
[ "http", ":", "//", "boto3", ".", "readthedocs", ".", "io", "/", "en", "/", "latest", "/", "reference", "/", "services", "/", "cloudsearch", ".", "html" ]
def brute_cloudsearch_permissions(): ''' http://boto3.readthedocs.io/en/latest/reference/services/cloudsearch.html ''' print("### Enumerating CloudSearch Permissions ###") tests = [('DescribeDomains', 'describe_domains', (), {}, ), ('ListDomainNames', 'list_domain_names', (), {}, ), ] return generic_permission_bruteforcer('cloudsearch', tests)
[ "def", "brute_cloudsearch_permissions", "(", ")", ":", "print", "(", "\"### Enumerating CloudSearch Permissions ###\"", ")", "tests", "=", "[", "(", "'DescribeDomains'", ",", "'describe_domains'", ",", "(", ")", ",", "{", "}", ",", ")", ",", "(", "'ListDomainNames...
https://github.com/carnal0wnage/weirdAAL/blob/c14e36d7bb82447f38a43da203f4bc29429f4cf4/libs/aws/brute.py#L530-L537
biolab/orange2
db40a9449cb45b507d63dcd5739b223f9cffb8e6
Orange/OrangeCanvas/document/interactions.py
python
UserInteraction.isCanceled
(self)
return self.__canceled
Was the interaction canceled.
Was the interaction canceled.
[ "Was", "the", "interaction", "canceled", "." ]
def isCanceled(self): """ Was the interaction canceled. """ return self.__canceled
[ "def", "isCanceled", "(", "self", ")", ":", "return", "self", ".", "__canceled" ]
https://github.com/biolab/orange2/blob/db40a9449cb45b507d63dcd5739b223f9cffb8e6/Orange/OrangeCanvas/document/interactions.py#L143-L147
FSX/momoko
ad2f602c85b5df09e54dcb997c2f81ccc3d2b221
momoko/connection.py
python
Pool.register_hstore
(self, *args, **kwargs)
return self._operate(Connection.register_hstore, args, kwargs)
Register adapter and typecaster for ``dict-hstore`` conversions. See :py:meth:`momoko.Connection.register_hstore` for documentation about the parameters. This method has no ``globally`` parameter, because it already registers hstore to all the connections in the pool.
Register adapter and typecaster for ``dict-hstore`` conversions.
[ "Register", "adapter", "and", "typecaster", "for", "dict", "-", "hstore", "conversions", "." ]
def register_hstore(self, *args, **kwargs): """ Register adapter and typecaster for ``dict-hstore`` conversions. See :py:meth:`momoko.Connection.register_hstore` for documentation about the parameters. This method has no ``globally`` parameter, because it already registers hstore to all the connections in the pool. """ kwargs["globally"] = True return self._operate(Connection.register_hstore, args, kwargs)
[ "def", "register_hstore", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"globally\"", "]", "=", "True", "return", "self", ".", "_operate", "(", "Connection", ".", "register_hstore", ",", "args", ",", "kwargs", ")" ]
https://github.com/FSX/momoko/blob/ad2f602c85b5df09e54dcb997c2f81ccc3d2b221/momoko/connection.py#L428-L437
autorope/donkeycar
a3df79a3573127dff31fc9b2953588056875b214
donkeycar/parts/pins.py
python
pca9685
(busnum: int, address: int, frequency: int = 60)
return pca
pca9685 factory allocates driver for pca9685 at given bus number and i2c address. If we have already created one for that bus/addr pair then use that singleton. If frequency is not the same, then error. :param busnum: I2C bus number of PCA9685 :param address: address of PCA9685 on I2C bus :param frequency: frequency in hertz of duty cycle :except: PCA9685 has a single frequency for all channels, so attempts to allocate a controller at a given bus number and address with different frequencies will raise a ValueError
pca9685 factory allocates driver for pca9685 at given bus number and i2c address. If we have already created one for that bus/addr pair then use that singleton. If frequency is not the same, then error. :param busnum: I2C bus number of PCA9685 :param address: address of PCA9685 on I2C bus :param frequency: frequency in hertz of duty cycle :except: PCA9685 has a single frequency for all channels, so attempts to allocate a controller at a given bus number and address with different frequencies will raise a ValueError
[ "pca9685", "factory", "allocates", "driver", "for", "pca9685", "at", "given", "bus", "number", "and", "i2c", "address", ".", "If", "we", "have", "already", "created", "one", "for", "that", "bus", "/", "addr", "pair", "then", "use", "that", "singleton", "."...
def pca9685(busnum: int, address: int, frequency: int = 60): """ pca9685 factory allocates driver for pca9685 at given bus number and i2c address. If we have already created one for that bus/addr pair then use that singleton. If frequency is not the same, then error. :param busnum: I2C bus number of PCA9685 :param address: address of PCA9685 on I2C bus :param frequency: frequency in hertz of duty cycle :except: PCA9685 has a single frequency for all channels, so attempts to allocate a controller at a given bus number and address with different frequencies will raise a ValueError """ key = str(busnum) + ":" + hex(address) pca = _pca9685.get(key) if pca is None: pca = PCA9685(busnum, address, frequency) if pca.get_frequency() != frequency: raise ValueError( f"Frequency {frequency} conflicts with pca9685 at {key} " f"with frequency {pca.pwm.get_pwm_freq()}") return pca
[ "def", "pca9685", "(", "busnum", ":", "int", ",", "address", ":", "int", ",", "frequency", ":", "int", "=", "60", ")", ":", "key", "=", "str", "(", "busnum", ")", "+", "\":\"", "+", "hex", "(", "address", ")", "pca", "=", "_pca9685", ".", "get", ...
https://github.com/autorope/donkeycar/blob/a3df79a3573127dff31fc9b2953588056875b214/donkeycar/parts/pins.py#L598-L621
SickChill/SickChill
01020f3636d01535f60b83464d8127ea0efabfc7
sickchill/adba/aniDBresponses.py
python
NotificationStateResponse.__init__
(self, cmd, restag, rescode, resstr, datalines)
attributes: data: notifies - pending notifies msgs - pending msgs buddys - number of online buddys
attributes:
[ "attributes", ":" ]
def __init__(self, cmd, restag, rescode, resstr, datalines): """ attributes: data: notifies - pending notifies msgs - pending msgs buddys - number of online buddys """ super().__init__(cmd, restag, rescode, resstr, datalines) self.codestr = "NOTIFICATION" self.codehead = () self.coderep = () buddy = cmd.parameters["buddy"] buddy = int(buddy or "0") if buddy: self.codetail = ("notifies", "msgs", "buddys") else: self.codetail = ("notifies", "msgs")
[ "def", "__init__", "(", "self", ",", "cmd", ",", "restag", ",", "rescode", ",", "resstr", ",", "datalines", ")", ":", "super", "(", ")", ".", "__init__", "(", "cmd", ",", "restag", ",", "rescode", ",", "resstr", ",", "datalines", ")", "self", ".", ...
https://github.com/SickChill/SickChill/blob/01020f3636d01535f60b83464d8127ea0efabfc7/sickchill/adba/aniDBresponses.py#L974-L994
aws-cloudformation/cfn-lint
16df5d0ca0d8ebcf9330ebea701e83d883b47217
src/cfnlint/rules/functions/DynamicReferenceSecureString.py
python
DynamicReferenceSecureString.__init__
(self)
Init
Init
[ "Init" ]
def __init__(self): """Init """ super(DynamicReferenceSecureString, self).__init__() self.property_specs = [] self.resource_specs = [] self.exceptions = { 'AWS::DirectoryService::MicrosoftAD': 'Password', 'AWS::DirectoryService::SimpleAD': 'Password', 'AWS::ElastiCache::ReplicationGroup': 'AuthToken', 'AWS::IAM::User.LoginProfile': 'Password', 'AWS::KinesisFirehose::DeliveryStream.RedshiftDestinationConfiguration': 'Password', 'AWS::OpsWorks::App.Source': 'Password', 'AWS::OpsWorks::Stack.RdsDbInstance': 'DbPassword', 'AWS::OpsWorks::Stack.Source': 'Password', 'AWS::RDS::DBCluster': 'MasterUserPassword', 'AWS::RDS::DBInstance': 'MasterUserPassword', 'AWS::Redshift::Cluster': 'MasterUserPassword', }
[ "def", "__init__", "(", "self", ")", ":", "super", "(", "DynamicReferenceSecureString", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "property_specs", "=", "[", "]", "self", ".", "resource_specs", "=", "[", "]", "self", ".", "exceptions", "=...
https://github.com/aws-cloudformation/cfn-lint/blob/16df5d0ca0d8ebcf9330ebea701e83d883b47217/src/cfnlint/rules/functions/DynamicReferenceSecureString.py#L23-L40
andresriancho/w3af
cd22e5252243a87aaa6d0ddea47cf58dacfe00a9
w3af/plugins/attack/db/sqlmap/thirdparty/bottle/bottle.py
python
Bottle.add_route
(self, route)
Add a route object, but do not change the :data:`Route.app` attribute.
Add a route object, but do not change the :data:`Route.app` attribute.
[ "Add", "a", "route", "object", "but", "do", "not", "change", "the", ":", "data", ":", "Route", ".", "app", "attribute", "." ]
def add_route(self, route): """ Add a route object, but do not change the :data:`Route.app` attribute.""" self.routes.append(route) self.router.add(route.rule, route.method, route, name=route.name) if DEBUG: route.prepare()
[ "def", "add_route", "(", "self", ",", "route", ")", ":", "self", ".", "routes", ".", "append", "(", "route", ")", "self", ".", "router", ".", "add", "(", "route", ".", "rule", ",", "route", ".", "method", ",", "route", ",", "name", "=", "route", ...
https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/plugins/attack/db/sqlmap/thirdparty/bottle/bottle.py#L834-L839
StackStorm/st2
85ae05b73af422efd3097c9c05351f7f1cc8369e
st2exporter/dist_utils.py
python
apply_vagrant_workaround
()
Function which detects if the script is being executed inside vagrant and if it is, it deletes "os.link" attribute. Note: Without this workaround, setup.py sdist will fail when running inside a shared directory (nfs / virtualbox shared folders).
Function which detects if the script is being executed inside vagrant and if it is, it deletes "os.link" attribute. Note: Without this workaround, setup.py sdist will fail when running inside a shared directory (nfs / virtualbox shared folders).
[ "Function", "which", "detects", "if", "the", "script", "is", "being", "executed", "inside", "vagrant", "and", "if", "it", "is", "it", "deletes", "os", ".", "link", "attribute", ".", "Note", ":", "Without", "this", "workaround", "setup", ".", "py", "sdist",...
def apply_vagrant_workaround(): """ Function which detects if the script is being executed inside vagrant and if it is, it deletes "os.link" attribute. Note: Without this workaround, setup.py sdist will fail when running inside a shared directory (nfs / virtualbox shared folders). """ if os.environ.get("USER", None) == "vagrant": del os.link
[ "def", "apply_vagrant_workaround", "(", ")", ":", "if", "os", ".", "environ", ".", "get", "(", "\"USER\"", ",", "None", ")", "==", "\"vagrant\"", ":", "del", "os", ".", "link" ]
https://github.com/StackStorm/st2/blob/85ae05b73af422efd3097c9c05351f7f1cc8369e/st2exporter/dist_utils.py#L146-L154
fritzy/SleekXMPP
cc1d470397de768ffcc41d2ed5ac3118d19f09f5
examples/pubsub_events.py
python
PubsubEvents._purge
(self, msg)
Handle receiving a node purge event.
Handle receiving a node purge event.
[ "Handle", "receiving", "a", "node", "purge", "event", "." ]
def _purge(self, msg): """Handle receiving a node purge event.""" print('Purged all items from %s' % ( msg['pubsub_event']['purge']['node']))
[ "def", "_purge", "(", "self", ",", "msg", ")", ":", "print", "(", "'Purged all items from %s'", "%", "(", "msg", "[", "'pubsub_event'", "]", "[", "'purge'", "]", "[", "'node'", "]", ")", ")" ]
https://github.com/fritzy/SleekXMPP/blob/cc1d470397de768ffcc41d2ed5ac3118d19f09f5/examples/pubsub_events.py#L74-L77
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
ansible/roles/lib_oa_openshift/library/oc_adm_registry.py
python
Secret.add_secret
(self, key, value)
return True
add a secret
add a secret
[ "add", "a", "secret" ]
def add_secret(self, key, value): ''' add a secret ''' if self.secrets: self.secrets[key] = value else: self.put(Secret.secret_path, {key: value}) return True
[ "def", "add_secret", "(", "self", ",", "key", ",", "value", ")", ":", "if", "self", ".", "secrets", ":", "self", ".", "secrets", "[", "key", "]", "=", "value", "else", ":", "self", ".", "put", "(", "Secret", ".", "secret_path", ",", "{", "key", "...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/ansible/roles/lib_oa_openshift/library/oc_adm_registry.py#L2007-L2014
apache/libcloud
90971e17bfd7b6bb97b2489986472c531cc8e140
libcloud/compute/drivers/openstack.py
python
OpenStackSecurityGroup.__init__
( self, id, tenant_id, name, description, driver, rules=None, extra=None )
Constructor. :keyword id: Group id. :type id: ``str`` :keyword tenant_id: Owner of the security group. :type tenant_id: ``str`` :keyword name: Human-readable name for the security group. Might not be unique. :type name: ``str`` :keyword description: Human-readable description of a security group. :type description: ``str`` :keyword rules: Rules associated with this group. :type rules: ``list`` of :class:`OpenStackSecurityGroupRule` :keyword extra: Extra attributes associated with this group. :type extra: ``dict``
Constructor.
[ "Constructor", "." ]
def __init__( self, id, tenant_id, name, description, driver, rules=None, extra=None ): """ Constructor. :keyword id: Group id. :type id: ``str`` :keyword tenant_id: Owner of the security group. :type tenant_id: ``str`` :keyword name: Human-readable name for the security group. Might not be unique. :type name: ``str`` :keyword description: Human-readable description of a security group. :type description: ``str`` :keyword rules: Rules associated with this group. :type rules: ``list`` of :class:`OpenStackSecurityGroupRule` :keyword extra: Extra attributes associated with this group. :type extra: ``dict`` """ self.id = id self.tenant_id = tenant_id self.name = name self.description = description self.driver = driver self.rules = rules or [] self.extra = extra or {}
[ "def", "__init__", "(", "self", ",", "id", ",", "tenant_id", ",", "name", ",", "description", ",", "driver", ",", "rules", "=", "None", ",", "extra", "=", "None", ")", ":", "self", ".", "id", "=", "id", "self", ".", "tenant_id", "=", "tenant_id", "...
https://github.com/apache/libcloud/blob/90971e17bfd7b6bb97b2489986472c531cc8e140/libcloud/compute/drivers/openstack.py#L1255-L1288
Blizzard/heroprotocol
3d36eaf44fc4c8ff3331c2ae2f1dc08a94535f1c
heroprotocol/versions/protocol48583.py
python
decode_replay_game_events
(contents)
Decodes and yields each game event from the contents byte string.
Decodes and yields each game event from the contents byte string.
[ "Decodes", "and", "yields", "each", "game", "event", "from", "the", "contents", "byte", "string", "." ]
def decode_replay_game_events(contents): """Decodes and yields each game event from the contents byte string.""" decoder = BitPackedDecoder(contents, typeinfos) for event in _decode_event_stream(decoder, game_eventid_typeid, game_event_types, decode_user_id=True): yield event
[ "def", "decode_replay_game_events", "(", "contents", ")", ":", "decoder", "=", "BitPackedDecoder", "(", "contents", ",", "typeinfos", ")", "for", "event", "in", "_decode_event_stream", "(", "decoder", ",", "game_eventid_typeid", ",", "game_event_types", ",", "decode...
https://github.com/Blizzard/heroprotocol/blob/3d36eaf44fc4c8ff3331c2ae2f1dc08a94535f1c/heroprotocol/versions/protocol48583.py#L395-L402
bruceyang2012/Face-detection-with-mobilenet-ssd
58fafb6e93d28531797aac1e9a4436730c8cee7c
face_generator.py
python
BatchGenerator.__init__
(self, images_path, include_classes='all', box_output_format=['class_id', 'xmin', 'xmax', 'ymin', 'ymax'])
Arguments: images_path (str): The filepath to the image samples. include_classes (list, optional): Either 'all' or a list of integers containing the class IDs that are to be included in the dataset. Defaults to 'all', in which case all boxes will be included in the dataset. box_output_format (list, optional): A list of five strings representing the desired order of the five items class ID, xmin, xmax, ymin, ymax in the generated data. The expected strings are 'xmin', 'xmax', 'ymin', 'ymax', 'class_id'. If you want to train the model, this must be the order that the box encoding class requires as input. Defaults to `['class_id', 'xmin', 'xmax', 'ymin', 'ymax']`. Note that even though the parser methods are able to produce different output formats, the SSDBoxEncoder currently requires the format `['class_id', 'xmin', 'xmax', 'ymin', 'ymax']`. This list only specifies the five box parameters that are relevant as training targets, a list of filenames is generated separately.
Arguments: images_path (str): The filepath to the image samples. include_classes (list, optional): Either 'all' or a list of integers containing the class IDs that are to be included in the dataset. Defaults to 'all', in which case all boxes will be included in the dataset. box_output_format (list, optional): A list of five strings representing the desired order of the five items class ID, xmin, xmax, ymin, ymax in the generated data. The expected strings are 'xmin', 'xmax', 'ymin', 'ymax', 'class_id'. If you want to train the model, this must be the order that the box encoding class requires as input. Defaults to `['class_id', 'xmin', 'xmax', 'ymin', 'ymax']`. Note that even though the parser methods are able to produce different output formats, the SSDBoxEncoder currently requires the format `['class_id', 'xmin', 'xmax', 'ymin', 'ymax']`. This list only specifies the five box parameters that are relevant as training targets, a list of filenames is generated separately.
[ "Arguments", ":", "images_path", "(", "str", ")", ":", "The", "filepath", "to", "the", "image", "samples", ".", "include_classes", "(", "list", "optional", ")", ":", "Either", "all", "or", "a", "list", "of", "integers", "containing", "the", "class", "IDs",...
def __init__(self, images_path, include_classes='all', box_output_format=['class_id', 'xmin', 'xmax', 'ymin', 'ymax']): ''' Arguments: images_path (str): The filepath to the image samples. include_classes (list, optional): Either 'all' or a list of integers containing the class IDs that are to be included in the dataset. Defaults to 'all', in which case all boxes will be included in the dataset. box_output_format (list, optional): A list of five strings representing the desired order of the five items class ID, xmin, xmax, ymin, ymax in the generated data. The expected strings are 'xmin', 'xmax', 'ymin', 'ymax', 'class_id'. If you want to train the model, this must be the order that the box encoding class requires as input. Defaults to `['class_id', 'xmin', 'xmax', 'ymin', 'ymax']`. Note that even though the parser methods are able to produce different output formats, the SSDBoxEncoder currently requires the format `['class_id', 'xmin', 'xmax', 'ymin', 'ymax']`. This list only specifies the five box parameters that are relevant as training targets, a list of filenames is generated separately. ''' # These are the variables we always need self.images_path = images_path self.include_classes = include_classes self.box_output_format = box_output_format # These are the variables that we only need if we want to use parse_csv() self.labels_path = None self.input_format = None # These are the variables that we only need if we want to use parse_xml() self.annotations_path = None self.image_set_path = None self.image_set = None self.classes = None # The two variables below store the output from the parsers. This is the input for the generate() method # `self.filenames` is a list containing all file names of the image samples. Note that it does not contain the actual image files themselves. self.filenames = [] # All unique image filenames will go here # `self.labels` is a list containing one 2D Numpy array per image. For an image with `k` ground truth bounding boxes, # the respective 2D array has `k` rows, each row containing `(xmin, xmax, ymin, ymax, class_id)` for the respective bounding box. self.labels = []
[ "def", "__init__", "(", "self", ",", "images_path", ",", "include_classes", "=", "'all'", ",", "box_output_format", "=", "[", "'class_id'", ",", "'xmin'", ",", "'xmax'", ",", "'ymin'", ",", "'ymax'", "]", ")", ":", "# These are the variables we always need", "se...
https://github.com/bruceyang2012/Face-detection-with-mobilenet-ssd/blob/58fafb6e93d28531797aac1e9a4436730c8cee7c/face_generator.py#L229-L268
clinton-hall/nzbToMedia
27669389216902d1085660167e7bda0bd8527ecf
libs/common/validate.py
python
Validator.get_default_value
(self, check)
return self._check_value(value, fun_name, fun_args, fun_kwargs)
Given a check, return the default value for the check (converted to the right type). If the check doesn't specify a default value then a ``KeyError`` will be raised.
Given a check, return the default value for the check (converted to the right type). If the check doesn't specify a default value then a ``KeyError`` will be raised.
[ "Given", "a", "check", "return", "the", "default", "value", "for", "the", "check", "(", "converted", "to", "the", "right", "type", ")", ".", "If", "the", "check", "doesn", "t", "specify", "a", "default", "value", "then", "a", "KeyError", "will", "be", ...
def get_default_value(self, check): """ Given a check, return the default value for the check (converted to the right type). If the check doesn't specify a default value then a ``KeyError`` will be raised. """ fun_name, fun_args, fun_kwargs, default = self._parse_with_caching(check) if default is None: raise KeyError('Check "%s" has no default value.' % check) value = self._handle_none(default) if value is None: return value return self._check_value(value, fun_name, fun_args, fun_kwargs)
[ "def", "get_default_value", "(", "self", ",", "check", ")", ":", "fun_name", ",", "fun_args", ",", "fun_kwargs", ",", "default", "=", "self", ".", "_parse_with_caching", "(", "check", ")", "if", "default", "is", "None", ":", "raise", "KeyError", "(", "'Che...
https://github.com/clinton-hall/nzbToMedia/blob/27669389216902d1085660167e7bda0bd8527ecf/libs/common/validate.py#L729-L743
LumaPictures/pymel
fa88a3f4fa18e09bb8aa9bdf4dab53d984bada72
pymel/util/nameparse.py
python
MayaNodePath.isDagName
(self)
return len(self.nodes) > 1
True if this object is specified including one or more dag parents
True if this object is specified including one or more dag parents
[ "True", "if", "this", "object", "is", "specified", "including", "one", "or", "more", "dag", "parents" ]
def isDagName(self): """ True if this object is specified including one or more dag parents """ return len(self.nodes) > 1
[ "def", "isDagName", "(", "self", ")", ":", "return", "len", "(", "self", ".", "nodes", ")", ">", "1" ]
https://github.com/LumaPictures/pymel/blob/fa88a3f4fa18e09bb8aa9bdf4dab53d984bada72/pymel/util/nameparse.py#L1119-L1121
jjhelmus/nmrglue
f47397dcda84854d2136395a9998fe0b57356cbf
nmrglue/process/proc_base.py
python
neg_middle
(data)
return data
Negate middle half.
Negate middle half.
[ "Negate", "middle", "half", "." ]
def neg_middle(data): """ Negate middle half. """ data[..., int(data.shape[-1] * 1. / 4.):int(data.shape[-1] * 3. / 4.)] = \ -data[..., int(data.shape[-1] * 1. / 4.):int(data.shape[-1] * 3. / 4.)] return data
[ "def", "neg_middle", "(", "data", ")", ":", "data", "[", "...", ",", "int", "(", "data", ".", "shape", "[", "-", "1", "]", "*", "1.", "/", "4.", ")", ":", "int", "(", "data", ".", "shape", "[", "-", "1", "]", "*", "3.", "/", "4.", ")", "]...
https://github.com/jjhelmus/nmrglue/blob/f47397dcda84854d2136395a9998fe0b57356cbf/nmrglue/process/proc_base.py#L1715-L1721
guildai/guildai
1665985a3d4d788efc1a3180ca51cc417f71ca78
guild/external/pip/_vendor/pyparsing.py
python
pyparsing_common.stripHTMLTags
(s, l, tokens)
return pyparsing_common._html_stripper.transformString(tokens[0])
Parse action to remove HTML tags from web page HTML source Example:: # strip HTML links from normal text text = '<td>More info at the <a href="http://pyparsing.wikispaces.com">pyparsing</a> wiki page</td>' td,td_end = makeHTMLTags("TD") table_text = td + SkipTo(td_end).setParseAction(pyparsing_common.stripHTMLTags)("body") + td_end print(table_text.parseString(text).body) # -> 'More info at the pyparsing wiki page'
Parse action to remove HTML tags from web page HTML source
[ "Parse", "action", "to", "remove", "HTML", "tags", "from", "web", "page", "HTML", "source" ]
def stripHTMLTags(s, l, tokens): """ Parse action to remove HTML tags from web page HTML source Example:: # strip HTML links from normal text text = '<td>More info at the <a href="http://pyparsing.wikispaces.com">pyparsing</a> wiki page</td>' td,td_end = makeHTMLTags("TD") table_text = td + SkipTo(td_end).setParseAction(pyparsing_common.stripHTMLTags)("body") + td_end print(table_text.parseString(text).body) # -> 'More info at the pyparsing wiki page' """ return pyparsing_common._html_stripper.transformString(tokens[0])
[ "def", "stripHTMLTags", "(", "s", ",", "l", ",", "tokens", ")", ":", "return", "pyparsing_common", ".", "_html_stripper", ".", "transformString", "(", "tokens", "[", "0", "]", ")" ]
https://github.com/guildai/guildai/blob/1665985a3d4d788efc1a3180ca51cc417f71ca78/guild/external/pip/_vendor/pyparsing.py#L5625-L5637
linuxscout/mishkal
4f4ae0ebc2d6acbeb3de3f0303151ec7b54d2f76
support/spellcheck/spellcheck.py
python
SpellcheckClass.enableAjustVocalization
(self)
Enable the Ajust Vocalization option.
Enable the Ajust Vocalization option.
[ "Enable", "the", "Ajust", "Vocalization", "option", "." ]
def enableAjustVocalization(self): """ Enable the Ajust Vocalization option. """ self.enabledAjustVocalization=True;
[ "def", "enableAjustVocalization", "(", "self", ")", ":", "self", ".", "enabledAjustVocalization", "=", "True" ]
https://github.com/linuxscout/mishkal/blob/4f4ae0ebc2d6acbeb3de3f0303151ec7b54d2f76/support/spellcheck/spellcheck.py#L173-L177
microsoft/msticpy
2a401444ee529114004f496f4c0376ff25b5268a
msticpy/config/compound_ctrls.py
python
UserDefLoadComponent.value
(self, value: Union[str, Dict[str, Optional[str]]])
Set value of controls from dict.
Set value of controls from dict.
[ "Set", "value", "of", "controls", "from", "dict", "." ]
def value(self, value: Union[str, Dict[str, Optional[str]]]): """Set value of controls from dict.""" if isinstance(value, dict): self._set_ctrl_from_val(path="", value=value)
[ "def", "value", "(", "self", ",", "value", ":", "Union", "[", "str", ",", "Dict", "[", "str", ",", "Optional", "[", "str", "]", "]", "]", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "self", ".", "_set_ctrl_from_val", "(", "...
https://github.com/microsoft/msticpy/blob/2a401444ee529114004f496f4c0376ff25b5268a/msticpy/config/compound_ctrls.py#L476-L479
enthought/chaco
0907d1dedd07a499202efbaf2fe2a4e51b4c8e5f
chaco/plots/line_scatterplot_1d.py
python
LineScatterPlot1D._render
(self, gc, lines)
Render a sequence of line values, accounting for selections
Render a sequence of line values, accounting for selections
[ "Render", "a", "sequence", "of", "line", "values", "accounting", "for", "selections" ]
def _render(self, gc, lines): """ Render a sequence of line values, accounting for selections """ with gc: gc.clip_to_rect(self.x, self.y, self.width, self.height) if not self.index: return name = self.selection_metadata_name md = self.index.metadata if name in md and md[name] is not None and len(md[name]) > 0: selected_mask = md[name][0] selected_lines = lines[selected_mask] unselected_lines = lines[~selected_mask] color = list(self.color_) color[3] *= self.unselected_alpha if unselected_lines.size > 0: self._render_lines( gc, unselected_lines, self.color_, self.line_width, self.line_style_, ) if selected_lines.size > 0: self._render_lines( gc, selected_lines, self.selected_color_, self.selected_line_width, self.selected_line_style_, ) else: self._render_lines( gc, lines, self.color_, self.line_width, self.line_style_ )
[ "def", "_render", "(", "self", ",", "gc", ",", "lines", ")", ":", "with", "gc", ":", "gc", ".", "clip_to_rect", "(", "self", ".", "x", ",", "self", ".", "y", ",", "self", ".", "width", ",", "self", ".", "height", ")", "if", "not", "self", ".", ...
https://github.com/enthought/chaco/blob/0907d1dedd07a499202efbaf2fe2a4e51b4c8e5f/chaco/plots/line_scatterplot_1d.py#L87-L121
bytedance/fedlearner
89f5a2341d9b3c9100c799473fe5f436da7e87a2
fedlearner/common/metrics.py
python
Metrics.remove_handler
(self, hdlr)
Remove the specified handler from this logger.
Remove the specified handler from this logger.
[ "Remove", "the", "specified", "handler", "from", "this", "logger", "." ]
def remove_handler(self, hdlr): """ Remove the specified handler from this logger. """ with self._lock: if hdlr in self.handlers: self.handlers.remove(hdlr)
[ "def", "remove_handler", "(", "self", ",", "hdlr", ")", ":", "with", "self", ".", "_lock", ":", "if", "hdlr", "in", "self", ".", "handlers", ":", "self", ".", "handlers", ".", "remove", "(", "hdlr", ")" ]
https://github.com/bytedance/fedlearner/blob/89f5a2341d9b3c9100c799473fe5f436da7e87a2/fedlearner/common/metrics.py#L198-L204
Qiskit/qiskit-terra
b66030e3b9192efdd3eb95cf25c6545fe0a13da4
qiskit/opflow/state_fns/cvar_measurement.py
python
CVaRMeasurement.to_density_matrix
(self, massive: bool = False)
Not defined.
Not defined.
[ "Not", "defined", "." ]
def to_density_matrix(self, massive: bool = False): """Not defined.""" raise NotImplementedError
[ "def", "to_density_matrix", "(", "self", ",", "massive", ":", "bool", "=", "False", ")", ":", "raise", "NotImplementedError" ]
https://github.com/Qiskit/qiskit-terra/blob/b66030e3b9192efdd3eb95cf25c6545fe0a13da4/qiskit/opflow/state_fns/cvar_measurement.py#L129-L131
haiwen/seahub
e92fcd44e3e46260597d8faa9347cb8222b8b10d
seahub/share/models.py
python
FileShare.is_file_share_link
(self)
return True if self.s_type == 'f' else False
[]
def is_file_share_link(self): return True if self.s_type == 'f' else False
[ "def", "is_file_share_link", "(", "self", ")", ":", "return", "True", "if", "self", ".", "s_type", "==", "'f'", "else", "False" ]
https://github.com/haiwen/seahub/blob/e92fcd44e3e46260597d8faa9347cb8222b8b10d/seahub/share/models.py#L347-L348
yourlabs/django-autocomplete-light
3eb84a09c5828e4a9409f0aec14c2874bcbe17df
src/dal/views.py
python
BaseQuerySetView.get_search_fields
(self)
Get the fields to search over.
Get the fields to search over.
[ "Get", "the", "fields", "to", "search", "over", "." ]
def get_search_fields(self): """Get the fields to search over.""" if self.search_fields: return self.search_fields else: return [self.model_field_name]
[ "def", "get_search_fields", "(", "self", ")", ":", "if", "self", ".", "search_fields", ":", "return", "self", ".", "search_fields", "else", ":", "return", "[", "self", ".", "model_field_name", "]" ]
https://github.com/yourlabs/django-autocomplete-light/blob/3eb84a09c5828e4a9409f0aec14c2874bcbe17df/src/dal/views.py#L114-L119
ShiyuLiang/odin-pytorch
34e53f5a982811a0d74baba049538d34efc0732d
code/wideresnet.py
python
NetworkBlock.__init__
(self, nb_layers, in_planes, out_planes, block, stride, dropRate=0.0)
[]
def __init__(self, nb_layers, in_planes, out_planes, block, stride, dropRate=0.0): super(NetworkBlock, self).__init__() self.layer = self._make_layer(block, in_planes, out_planes, nb_layers, stride, dropRate)
[ "def", "__init__", "(", "self", ",", "nb_layers", ",", "in_planes", ",", "out_planes", ",", "block", ",", "stride", ",", "dropRate", "=", "0.0", ")", ":", "super", "(", "NetworkBlock", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "layer", ...
https://github.com/ShiyuLiang/odin-pytorch/blob/34e53f5a982811a0d74baba049538d34efc0732d/code/wideresnet.py#L34-L36
openedx/edx-platform
68dd185a0ab45862a2a61e0f803d7e03d2be71b5
openedx/features/enterprise_support/api.py
python
enterprise_customer_uuid_from_session
(request)
return _CACHE_MISS
Retrieve an enterprise customer UUID from the request's session, returning a ``__CACHE_MISS__`` if absent. Note that this may return ``None``, which indicates that we've previously looked for an associated customer for this request's user, and none was present.
Retrieve an enterprise customer UUID from the request's session, returning a ``__CACHE_MISS__`` if absent. Note that this may return ``None``, which indicates that we've previously looked for an associated customer for this request's user, and none was present.
[ "Retrieve", "an", "enterprise", "customer", "UUID", "from", "the", "request", "s", "session", "returning", "a", "__CACHE_MISS__", "if", "absent", ".", "Note", "that", "this", "may", "return", "None", "which", "indicates", "that", "we", "ve", "previously", "loo...
def enterprise_customer_uuid_from_session(request): """ Retrieve an enterprise customer UUID from the request's session, returning a ``__CACHE_MISS__`` if absent. Note that this may return ``None``, which indicates that we've previously looked for an associated customer for this request's user, and none was present. """ customer_data = enterprise_customer_from_session(request) if customer_data is not _CACHE_MISS: customer_data = customer_data or {} return customer_data.get('uuid') return _CACHE_MISS
[ "def", "enterprise_customer_uuid_from_session", "(", "request", ")", ":", "customer_data", "=", "enterprise_customer_from_session", "(", "request", ")", "if", "customer_data", "is", "not", "_CACHE_MISS", ":", "customer_data", "=", "customer_data", "or", "{", "}", "ret...
https://github.com/openedx/edx-platform/blob/68dd185a0ab45862a2a61e0f803d7e03d2be71b5/openedx/features/enterprise_support/api.py#L427-L439
mikedh/trimesh
6b1e05616b44e6dd708d9bc748b211656ebb27ec
trimesh/visual/texture.py
python
TextureVisuals.to_color
(self)
return vis
Convert textured visuals to a ColorVisuals with vertex color calculated from texture. Returns ----------- vis : trimesh.visuals.ColorVisuals Contains vertex color from texture
Convert textured visuals to a ColorVisuals with vertex color calculated from texture.
[ "Convert", "textured", "visuals", "to", "a", "ColorVisuals", "with", "vertex", "color", "calculated", "from", "texture", "." ]
def to_color(self): """ Convert textured visuals to a ColorVisuals with vertex color calculated from texture. Returns ----------- vis : trimesh.visuals.ColorVisuals Contains vertex color from texture """ # find the color at each UV coordinate colors = self.material.to_color(self.uv) # create ColorVisuals from result vis = color.ColorVisuals(vertex_colors=colors) return vis
[ "def", "to_color", "(", "self", ")", ":", "# find the color at each UV coordinate", "colors", "=", "self", ".", "material", ".", "to_color", "(", "self", ".", "uv", ")", "# create ColorVisuals from result", "vis", "=", "color", ".", "ColorVisuals", "(", "vertex_co...
https://github.com/mikedh/trimesh/blob/6b1e05616b44e6dd708d9bc748b211656ebb27ec/trimesh/visual/texture.py#L148-L162
s3rvac/weechat-notify-send
d99632574a11098c05bc2b6075e149aaea77be0d
notify_send.py
python
parse_tags
(tags)
return tags.split(',')
Parses the given "list" of tags (str) from WeeChat into a list.
Parses the given "list" of tags (str) from WeeChat into a list.
[ "Parses", "the", "given", "list", "of", "tags", "(", "str", ")", "from", "WeeChat", "into", "a", "list", "." ]
def parse_tags(tags): """Parses the given "list" of tags (str) from WeeChat into a list.""" return tags.split(',')
[ "def", "parse_tags", "(", "tags", ")", ":", "return", "tags", ".", "split", "(", "','", ")" ]
https://github.com/s3rvac/weechat-notify-send/blob/d99632574a11098c05bc2b6075e149aaea77be0d/notify_send.py#L244-L246
anatolikalysch/VMAttack
67dcce6087163d85bbe7780e3f6e6e9e72e2212a
lib/Instruction.py
python
Instruction.is_add_basepointer
(self)
return (('ADD' in self.Instruction.mnemonic) and (self.Instruction.instructionClass == 'ISC_INTEGER') and (self.Instruction.operands[0].name == 'EBP' or self.Instruction.operands[0].name == 'RBP'))
@brief Tests if the instruction adds something to the basepointer
[]
def is_add_basepointer(self): """ @brief Tests if the instruction adds something to the basepointer """ return (('ADD' in self.Instruction.mnemonic) and (self.Instruction.instructionClass == 'ISC_INTEGER') and (self.Instruction.operands[0].name == 'EBP' or self.Instruction.operands[0].name == 'RBP'))
[ "def", "is_add_basepointer", "(", "self", ")", ":", "return", "(", "(", "'ADD'", "in", "self", ".", "Instruction", ".", "mnemonic", ")", "and", "(", "self", ".", "Instruction", ".", "instructionClass", "==", "'ISC_INTEGER'", ")", "and", "(", "self", ".", ...
https://github.com/anatolikalysch/VMAttack/blob/67dcce6087163d85bbe7780e3f6e6e9e72e2212a/lib/Instruction.py#L446-L454
sympy/sympy
d822fcba181155b85ff2b29fe525adbafb22b448
sympy/vector/vector.py
python
dot
(vect1, vect2)
return Dot(vect1, vect2)
Returns dot product of two vectors. Examples ======== >>> from sympy.vector import CoordSys3D >>> from sympy.vector.vector import dot >>> R = CoordSys3D('R') >>> v1 = R.i + R.j + R.k >>> v2 = R.x * R.i + R.y * R.j + R.z * R.k >>> dot(v1, v2) R.x + R.y + R.z
Returns dot product of two vectors.
[ "Returns", "dot", "product", "of", "two", "vectors", "." ]
def dot(vect1, vect2): """ Returns dot product of two vectors. Examples ======== >>> from sympy.vector import CoordSys3D >>> from sympy.vector.vector import dot >>> R = CoordSys3D('R') >>> v1 = R.i + R.j + R.k >>> v2 = R.x * R.i + R.y * R.j + R.z * R.k >>> dot(v1, v2) R.x + R.y + R.z """ if isinstance(vect1, Add): return Add.fromiter(dot(i, vect2) for i in vect1.args) if isinstance(vect2, Add): return Add.fromiter(dot(vect1, i) for i in vect2.args) if isinstance(vect1, BaseVector) and isinstance(vect2, BaseVector): if vect1._sys == vect2._sys: return S.One if vect1 == vect2 else S.Zero from .functions import express try: v = express(vect2, vect1._sys) except ValueError: return Dot(vect1, vect2) else: return dot(vect1, v) if isinstance(vect1, VectorZero) or isinstance(vect2, VectorZero): return S.Zero if isinstance(vect1, VectorMul): v1, m1 = next(iter(vect1.components.items())) return m1*dot(v1, vect2) if isinstance(vect2, VectorMul): v2, m2 = next(iter(vect2.components.items())) return m2*dot(vect1, v2) return Dot(vect1, vect2)
[ "def", "dot", "(", "vect1", ",", "vect2", ")", ":", "if", "isinstance", "(", "vect1", ",", "Add", ")", ":", "return", "Add", ".", "fromiter", "(", "dot", "(", "i", ",", "vect2", ")", "for", "i", "in", "vect1", ".", "args", ")", "if", "isinstance"...
https://github.com/sympy/sympy/blob/d822fcba181155b85ff2b29fe525adbafb22b448/sympy/vector/vector.py#L578-L617
duo-labs/isthislegit
5d51fd2e0fe070cacd1ee169ca8a371a72e005ef
dashboard/lib/flanker/addresslib/lexer.py
python
t_comment_RPAREN
(t)
return t
r'\)
r'\)
[ "r", "\\", ")" ]
def t_comment_RPAREN(t): r'\)' t.lexer.begin('INITIAL') return t
[ "def", "t_comment_RPAREN", "(", "t", ")", ":", "t", ".", "lexer", ".", "begin", "(", "'INITIAL'", ")", "return", "t" ]
https://github.com/duo-labs/isthislegit/blob/5d51fd2e0fe070cacd1ee169ca8a371a72e005ef/dashboard/lib/flanker/addresslib/lexer.py#L183-L186
bikalims/bika.lims
35e4bbdb5a3912cae0b5eb13e51097c8b0486349
bika/lims/browser/fields/aranalysesfield.py
python
ARAnalysesField.Services
(self)
return self._v_services
Return analysis services
Return analysis services
[ "Return", "analysis", "services" ]
def Services(self): """ Return analysis services """ bsc = getToolByName(self.context, 'bika_setup_catalog') if not shasattr(self, '_v_services'): self._v_services = [service.getObject() for service in bsc(portal_type='AnalysisService')] return self._v_services
[ "def", "Services", "(", "self", ")", ":", "bsc", "=", "getToolByName", "(", "self", ".", "context", ",", "'bika_setup_catalog'", ")", "if", "not", "shasattr", "(", "self", ",", "'_v_services'", ")", ":", "self", ".", "_v_services", "=", "[", "service", "...
https://github.com/bikalims/bika.lims/blob/35e4bbdb5a3912cae0b5eb13e51097c8b0486349/bika/lims/browser/fields/aranalysesfield.py#L215-L222
google/active-qa
bd96fab78255b8ef4f1147f78bd571abf2b919b3
px/nmt/train.py
python
run_full_eval
(model_dir, infer_model, infer_sess, eval_model, eval_sess, hparams, summary_writer, sample_src_data, sample_ctx_data, sample_tgt_data, sample_annot_data, avg_ckpts=False)
return result_summary, global_step, metrics
Wrapper for running sample_decode, internal_eval and external_eval.
Wrapper for running sample_decode, internal_eval and external_eval.
[ "Wrapper", "for", "running", "sample_decode", "internal_eval", "and", "external_eval", "." ]
def run_full_eval(model_dir, infer_model, infer_sess, eval_model, eval_sess, hparams, summary_writer, sample_src_data, sample_ctx_data, sample_tgt_data, sample_annot_data, avg_ckpts=False): """Wrapper for running sample_decode, internal_eval and external_eval.""" run_sample_decode(infer_model, infer_sess, model_dir, hparams, summary_writer, sample_src_data, sample_ctx_data, sample_tgt_data, sample_annot_data) dev_ppl = None test_ppl = None # only evaluate perplexity when using supervised learning if not hparams.use_rl: dev_ppl, test_ppl = run_internal_eval(eval_model, eval_sess, model_dir, hparams, summary_writer) dev_scores, test_scores, global_step = run_external_eval( infer_model, infer_sess, model_dir, hparams, summary_writer) metrics = { "dev_ppl": dev_ppl, "test_ppl": test_ppl, "dev_scores": dev_scores, "test_scores": test_scores, } avg_dev_scores, avg_test_scores = None, None if avg_ckpts: avg_dev_scores, avg_test_scores = run_avg_external_eval( infer_model, infer_sess, model_dir, hparams, summary_writer, global_step) metrics["avg_dev_scores"] = avg_dev_scores metrics["avg_test_scores"] = avg_test_scores result_summary = _format_results("dev", dev_ppl, dev_scores, hparams.metrics) if avg_dev_scores: result_summary += ", " + _format_results("avg_dev", None, avg_dev_scores, hparams.metrics) if hparams.test_prefix: result_summary += ", " + _format_results("test", test_ppl, test_scores, hparams.metrics) if avg_test_scores: result_summary += ", " + _format_results("avg_test", None, avg_test_scores, hparams.metrics) return result_summary, global_step, metrics
[ "def", "run_full_eval", "(", "model_dir", ",", "infer_model", ",", "infer_sess", ",", "eval_model", ",", "eval_sess", ",", "hparams", ",", "summary_writer", ",", "sample_src_data", ",", "sample_ctx_data", ",", "sample_tgt_data", ",", "sample_annot_data", ",", "avg_c...
https://github.com/google/active-qa/blob/bd96fab78255b8ef4f1147f78bd571abf2b919b3/px/nmt/train.py#L223-L276
yt-project/yt
dc7b24f9b266703db4c843e329c6c8644d47b824
yt/geometry/grid_geometry_handler.py
python
GridIndex._chunk_all
(self, dobj, cache=True, fast_index=None)
[]
def _chunk_all(self, dobj, cache=True, fast_index=None): gobjs = getattr(dobj._current_chunk, "objs", dobj._chunk_info) fast_index = fast_index or getattr(dobj._current_chunk, "_fast_index", None) yield YTDataChunk(dobj, "all", gobjs, dobj.size, cache, fast_index=fast_index)
[ "def", "_chunk_all", "(", "self", ",", "dobj", ",", "cache", "=", "True", ",", "fast_index", "=", "None", ")", ":", "gobjs", "=", "getattr", "(", "dobj", ".", "_current_chunk", ",", "\"objs\"", ",", "dobj", ".", "_chunk_info", ")", "fast_index", "=", "...
https://github.com/yt-project/yt/blob/dc7b24f9b266703db4c843e329c6c8644d47b824/yt/geometry/grid_geometry_handler.py#L365-L368
pytorch/examples
151944ecaf9ba2c8288ee550143ae7ffdaa90a80
super_resolution/main.py
python
checkpoint
(epoch)
[]
def checkpoint(epoch): model_out_path = "model_epoch_{}.pth".format(epoch) torch.save(model, model_out_path) print("Checkpoint saved to {}".format(model_out_path))
[ "def", "checkpoint", "(", "epoch", ")", ":", "model_out_path", "=", "\"model_epoch_{}.pth\"", ".", "format", "(", "epoch", ")", "torch", ".", "save", "(", "model", ",", "model_out_path", ")", "print", "(", "\"Checkpoint saved to {}\"", ".", "format", "(", "mod...
https://github.com/pytorch/examples/blob/151944ecaf9ba2c8288ee550143ae7ffdaa90a80/super_resolution/main.py#L75-L78
khanhnamle1994/natural-language-processing
01d450d5ac002b0156ef4cf93a07cb508c1bcdc5
assignment1/.env/lib/python2.7/site-packages/IPython/config/loader.py
python
LazyConfigValue.prepend
(self, other)
like list.extend, but for the front
like list.extend, but for the front
[ "like", "list", ".", "extend", "but", "for", "the", "front" ]
def prepend(self, other): """like list.extend, but for the front""" self._prepend[:0] = other
[ "def", "prepend", "(", "self", ",", "other", ")", ":", "self", ".", "_prepend", "[", ":", "0", "]", "=", "other" ]
https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/IPython/config/loader.py#L103-L105
google/grr
8ad8a4d2c5a93c92729206b7771af19d92d4f915
grr/core/grr_response_core/lib/parsers/linux_service_parser.py
python
LinuxXinetdParser._GenService
(self, name, cfg)
return service
[]
def _GenService(self, name, cfg): # Merge the config values. service = rdf_client.LinuxServiceInformation(name=name) service.config = self._GenConfig(cfg) if service.config.disable == ["no"]: service.starts = True service.start_mode = "XINETD" service.start_after = ["xinetd"] return service
[ "def", "_GenService", "(", "self", ",", "name", ",", "cfg", ")", ":", "# Merge the config values.", "service", "=", "rdf_client", ".", "LinuxServiceInformation", "(", "name", "=", "name", ")", "service", ".", "config", "=", "self", ".", "_GenConfig", "(", "c...
https://github.com/google/grr/blob/8ad8a4d2c5a93c92729206b7771af19d92d4f915/grr/core/grr_response_core/lib/parsers/linux_service_parser.py#L263-L271
Stiivi/bubbles
b3c9332b8a9534655bd77821586e45a5086b1ddc
bubbles/stores.py
python
FileSystemStore.get_object
(self, name)
Returns a CSVSource object with filename constructed from store's path and extension
Returns a CSVSource object with filename constructed from store's path and extension
[ "Returns", "a", "CSVSource", "object", "with", "filename", "constructed", "from", "store", "s", "path", "and", "extension" ]
def get_object(self, name): """Returns a CSVSource object with filename constructed from store's path and extension""" path = os.path.join(self.path, name) ext = os.path.splitext(name)[1] ext = ext[1:] if ext else ext if ext == "csv": return data_object("csv_source", path) elif ext == "xls": return data_object("xls", path) else: raise ArgumentError("Unknown extension '%s'" % ext)
[ "def", "get_object", "(", "self", ",", "name", ")", ":", "path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "name", ")", "ext", "=", "os", ".", "path", ".", "splitext", "(", "name", ")", "[", "1", "]", "ext", "=", "ex...
https://github.com/Stiivi/bubbles/blob/b3c9332b8a9534655bd77821586e45a5086b1ddc/bubbles/stores.py#L140-L153
django/django
0a17666045de6739ae1c2ac695041823d5f827f7
django/db/migrations/questioner.py
python
InteractiveMigrationQuestioner.ask_auto_now_add_addition
(self, field_name, model_name)
return None
Adding an auto_now_add field to a model.
Adding an auto_now_add field to a model.
[ "Adding", "an", "auto_now_add", "field", "to", "a", "model", "." ]
def ask_auto_now_add_addition(self, field_name, model_name): """Adding an auto_now_add field to a model.""" if not self.dry_run: choice = self._choice_input( f"It is impossible to add the field '{field_name}' with " f"'auto_now_add=True' to {model_name} without providing a " f"default. This is because the database needs something to " f"populate existing rows.\n", [ 'Provide a one-off default now which will be set on all ' 'existing rows', 'Quit and manually define a default value in models.py.', ] ) if choice == 2: sys.exit(3) else: return self._ask_default(default='timezone.now') return None
[ "def", "ask_auto_now_add_addition", "(", "self", ",", "field_name", ",", "model_name", ")", ":", "if", "not", "self", ".", "dry_run", ":", "choice", "=", "self", ".", "_choice_input", "(", "f\"It is impossible to add the field '{field_name}' with \"", "f\"'auto_now_add=...
https://github.com/django/django/blob/0a17666045de6739ae1c2ac695041823d5f827f7/django/db/migrations/questioner.py#L227-L245
CvvT/dumpDex
92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1
python/idaapi.py
python
isSeg1
(*args)
return _idaapi.isSeg1(*args)
isSeg1(F) -> bool
isSeg1(F) -> bool
[ "isSeg1", "(", "F", ")", "-", ">", "bool" ]
def isSeg1(*args): """ isSeg1(F) -> bool """ return _idaapi.isSeg1(*args)
[ "def", "isSeg1", "(", "*", "args", ")", ":", "return", "_idaapi", ".", "isSeg1", "(", "*", "args", ")" ]
https://github.com/CvvT/dumpDex/blob/92ab3b7e996194a06bf1dd5538a4954e8a5ee9c1/python/idaapi.py#L22184-L22188
KhronosGroup/NNEF-Tools
c913758ca687dab8cb7b49e8f1556819a2d0ca25
nnef_tools/io/tf/lite/flatbuffers/QuantizationParameters.py
python
QuantizationParameters.QuantizedDimension
(self)
return 0
[]
def QuantizedDimension(self): o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16)) if o != 0: return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos) return 0
[ "def", "QuantizedDimension", "(", "self", ")", ":", "o", "=", "flatbuffers", ".", "number_types", ".", "UOffsetTFlags", ".", "py_type", "(", "self", ".", "_tab", ".", "Offset", "(", "16", ")", ")", "if", "o", "!=", "0", ":", "return", "self", ".", "_...
https://github.com/KhronosGroup/NNEF-Tools/blob/c913758ca687dab8cb7b49e8f1556819a2d0ca25/nnef_tools/io/tf/lite/flatbuffers/QuantizationParameters.py#L153-L157
drj11/pypng
1b5bc2d7e7a068a2f0b41bfce282349748bf133b
code/png.py
python
Reader._iter_straight_packed
(self, byte_blocks)
Iterator that undoes the effect of filtering; yields each row as a sequence of packed bytes. Assumes input is straightlaced. `byte_blocks` should be an iterable that yields the raw bytes in blocks of arbitrary size.
Iterator that undoes the effect of filtering; yields each row as a sequence of packed bytes. Assumes input is straightlaced. `byte_blocks` should be an iterable that yields the raw bytes in blocks of arbitrary size.
[ "Iterator", "that", "undoes", "the", "effect", "of", "filtering", ";", "yields", "each", "row", "as", "a", "sequence", "of", "packed", "bytes", ".", "Assumes", "input", "is", "straightlaced", ".", "byte_blocks", "should", "be", "an", "iterable", "that", "yie...
def _iter_straight_packed(self, byte_blocks): """Iterator that undoes the effect of filtering; yields each row as a sequence of packed bytes. Assumes input is straightlaced. `byte_blocks` should be an iterable that yields the raw bytes in blocks of arbitrary size. """ # length of row, in bytes rb = self.row_bytes a = bytearray() # The previous (reconstructed) scanline. # None indicates first line of image. recon = None for some_bytes in byte_blocks: a.extend(some_bytes) while len(a) >= rb + 1: filter_type = a[0] scanline = a[1: rb + 1] del a[: rb + 1] recon = self.undo_filter(filter_type, scanline, recon) yield recon if len(a) != 0: # :file:format We get here with a file format error: # when the available bytes (after decompressing) do not # pack into exact rows. raise FormatError('Wrong size for decompressed IDAT chunk.') assert len(a) == 0
[ "def", "_iter_straight_packed", "(", "self", ",", "byte_blocks", ")", ":", "# length of row, in bytes", "rb", "=", "self", ".", "row_bytes", "a", "=", "bytearray", "(", ")", "# The previous (reconstructed) scanline.", "# None indicates first line of image.", "recon", "=",...
https://github.com/drj11/pypng/blob/1b5bc2d7e7a068a2f0b41bfce282349748bf133b/code/png.py#L1557-L1584
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
Python-2.7.13/Lib/email/parser.py
python
Parser.parse
(self, fp, headersonly=False)
return feedparser.close()
Create a message structure from the data in a file. Reads all the data from the file and returns the root of the message structure. Optional headersonly is a flag specifying whether to stop parsing after reading the headers or not. The default is False, meaning it parses the entire contents of the file.
Create a message structure from the data in a file.
[ "Create", "a", "message", "structure", "from", "the", "data", "in", "a", "file", "." ]
def parse(self, fp, headersonly=False): """Create a message structure from the data in a file. Reads all the data from the file and returns the root of the message structure. Optional headersonly is a flag specifying whether to stop parsing after reading the headers or not. The default is False, meaning it parses the entire contents of the file. """ feedparser = FeedParser(self._class) if headersonly: feedparser._set_headersonly() while True: data = fp.read(8192) if not data: break feedparser.feed(data) return feedparser.close()
[ "def", "parse", "(", "self", ",", "fp", ",", "headersonly", "=", "False", ")", ":", "feedparser", "=", "FeedParser", "(", "self", ".", "_class", ")", "if", "headersonly", ":", "feedparser", ".", "_set_headersonly", "(", ")", "while", "True", ":", "data",...
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/email/parser.py#L56-L72
lordmauve/pgzero
46a889fb918ccd606d39ba63680386d7f8fcbc5a
pgzero/clock.py
python
Clock.schedule
(self, callback, delay)
Schedule callback to be called once, at `delay` seconds from now. :param callback: A parameterless callable to be called. :param delay: The delay before the call (in clock time / seconds).
Schedule callback to be called once, at `delay` seconds from now.
[ "Schedule", "callback", "to", "be", "called", "once", "at", "delay", "seconds", "from", "now", "." ]
def schedule(self, callback, delay): """Schedule callback to be called once, at `delay` seconds from now. :param callback: A parameterless callable to be called. :param delay: The delay before the call (in clock time / seconds). """ heapq.heappush(self.events, Event(self.t + delay, callback, None))
[ "def", "schedule", "(", "self", ",", "callback", ",", "delay", ")", ":", "heapq", ".", "heappush", "(", "self", ".", "events", ",", "Event", "(", "self", ".", "t", "+", "delay", ",", "callback", ",", "None", ")", ")" ]
https://github.com/lordmauve/pgzero/blob/46a889fb918ccd606d39ba63680386d7f8fcbc5a/pgzero/clock.py#L98-L105
pypa/pipenv
b21baade71a86ab3ee1429f71fbc14d4f95fb75d
pipenv/vendor/vistir/path.py
python
get_converted_relative_path
(path, relative_to=None)
return relpath_s
Convert `path` to be relative. Given a vague relative path, return the path relative to the given location. :param str path: The location of a target path :param str relative_to: The starting path to build against, optional :returns: A relative posix-style path with a leading `./` This performs additional conversion to ensure the result is of POSIX form, and starts with `./`, or is precisely `.`. >>> os.chdir('/home/user/code/myrepo/myfolder') >>> vistir.path.get_converted_relative_path('/home/user/code/file.zip') './../../file.zip' >>> vistir.path.get_converted_relative_path('/home/user/code/myrepo/myfolder/mysubfolder') './mysubfolder' >>> vistir.path.get_converted_relative_path('/home/user/code/myrepo/myfolder') '.'
Convert `path` to be relative.
[ "Convert", "path", "to", "be", "relative", "." ]
def get_converted_relative_path(path, relative_to=None): # type: (TPath, Optional[TPath]) -> str """Convert `path` to be relative. Given a vague relative path, return the path relative to the given location. :param str path: The location of a target path :param str relative_to: The starting path to build against, optional :returns: A relative posix-style path with a leading `./` This performs additional conversion to ensure the result is of POSIX form, and starts with `./`, or is precisely `.`. >>> os.chdir('/home/user/code/myrepo/myfolder') >>> vistir.path.get_converted_relative_path('/home/user/code/file.zip') './../../file.zip' >>> vistir.path.get_converted_relative_path('/home/user/code/myrepo/myfolder/mysubfolder') './mysubfolder' >>> vistir.path.get_converted_relative_path('/home/user/code/myrepo/myfolder') '.' """ from .misc import to_text, to_bytes # noqa if not relative_to: relative_to = os.getcwdu() if six.PY2 else os.getcwd() if six.PY2: path = to_bytes(path, encoding="utf-8") else: path = to_text(path, encoding="utf-8") relative_to = to_text(relative_to, encoding="utf-8") start_path = Path(relative_to) try: start = start_path.resolve() except OSError: start = start_path.absolute() # check if there is a drive letter or mount point # if it is a mountpoint use the original absolute path # instead of the unc path if check_for_unc_path(start): start = start_path.absolute() path = start.joinpath(path).relative_to(start) # check and see if the path that was passed into the function is a UNC path # and raise value error if it is not. if check_for_unc_path(path): raise ValueError("The path argument does not currently accept UNC paths") relpath_s = to_text(posixpath.normpath(path.as_posix())) if not (relpath_s == "." or relpath_s.startswith("./")): relpath_s = posixpath.join(".", relpath_s) return relpath_s
[ "def", "get_converted_relative_path", "(", "path", ",", "relative_to", "=", "None", ")", ":", "# type: (TPath, Optional[TPath]) -> str", "from", ".", "misc", "import", "to_text", ",", "to_bytes", "# noqa", "if", "not", "relative_to", ":", "relative_to", "=", "os", ...
https://github.com/pypa/pipenv/blob/b21baade71a86ab3ee1429f71fbc14d4f95fb75d/pipenv/vendor/vistir/path.py#L575-L628
twilio/twilio-python
6e1e811ea57a1edfadd5161ace87397c563f6915
twilio/rest/verify/v2/service/entity/__init__.py
python
EntityInstance.links
(self)
return self._properties['links']
:returns: Nested resource URLs. :rtype: unicode
:returns: Nested resource URLs. :rtype: unicode
[ ":", "returns", ":", "Nested", "resource", "URLs", ".", ":", "rtype", ":", "unicode" ]
def links(self): """ :returns: Nested resource URLs. :rtype: unicode """ return self._properties['links']
[ "def", "links", "(", "self", ")", ":", "return", "self", ".", "_properties", "[", "'links'", "]" ]
https://github.com/twilio/twilio-python/blob/6e1e811ea57a1edfadd5161ace87397c563f6915/twilio/rest/verify/v2/service/entity/__init__.py#L418-L423
plasticityai/magnitude
7ac0baeaf181263b661c3ae00643d21e3fd90216
pymagnitude/third_party/_apsw/tools/shell.py
python
Shell.command_backup
(self, cmd)
backup ?DB? FILE: Backup DB (default "main") to FILE Copies the contents of the current database to FILE overwriting whatever was in FILE. If you have attached databases then you can specify their name instead of the default of "main". The backup is done at the page level - SQLite copies the pages as is. There is no round trip through SQL code.
backup ?DB? FILE: Backup DB (default "main") to FILE
[ "backup", "?DB?", "FILE", ":", "Backup", "DB", "(", "default", "main", ")", "to", "FILE" ]
def command_backup(self, cmd): """backup ?DB? FILE: Backup DB (default "main") to FILE Copies the contents of the current database to FILE overwriting whatever was in FILE. If you have attached databases then you can specify their name instead of the default of "main". The backup is done at the page level - SQLite copies the pages as is. There is no round trip through SQL code. """ dbname="main" if len(cmd)==1: fname=cmd[0] elif len(cmd)==2: dbname=cmd[0] fname=cmd[1] else: raise self.Error("Backup takes one or two parameters") out=apsw.Connection(fname) b=out.backup("main", self.db, dbname) try: while not b.done: b.step() finally: b.finish() out.close()
[ "def", "command_backup", "(", "self", ",", "cmd", ")", ":", "dbname", "=", "\"main\"", "if", "len", "(", "cmd", ")", "==", "1", ":", "fname", "=", "cmd", "[", "0", "]", "elif", "len", "(", "cmd", ")", "==", "2", ":", "dbname", "=", "cmd", "[", ...
https://github.com/plasticityai/magnitude/blob/7ac0baeaf181263b661c3ae00643d21e3fd90216/pymagnitude/third_party/_apsw/tools/shell.py#L944-L969
zakird/pyad
d95ff67745065cafca4f2653aab1fbce2df91fb9
pyad/pyadutils.py
python
convert_datetime
(adsi_time_com_obj)
return datetime.datetime.fromtimestamp(date_value)
Converts 64-bit integer COM object representing time into a python datetime object.
Converts 64-bit integer COM object representing time into a python datetime object.
[ "Converts", "64", "-", "bit", "integer", "COM", "object", "representing", "time", "into", "a", "python", "datetime", "object", "." ]
def convert_datetime(adsi_time_com_obj): """Converts 64-bit integer COM object representing time into a python datetime object.""" # credit goes to John Nielsen who documented this at # http://docs.activestate.com/activepython/2.6/pywin32/html/com/help/active_directory.html. high_part = int(adsi_time_com_obj.highpart) << 32 low_part = int(adsi_time_com_obj.lowpart) date_value = ((high_part + low_part) - 116444736000000000) // 10000000 # # The "fromtimestamp" function in datetime cannot take a # negative value, so if the resulting date value is negative, # explicitly set it to 18000. This will result in the date # 1970-01-01 00:00:00 being returned from this function # if date_value < 0: date_value = 18000 return datetime.datetime.fromtimestamp(date_value)
[ "def", "convert_datetime", "(", "adsi_time_com_obj", ")", ":", "# credit goes to John Nielsen who documented this at", "# http://docs.activestate.com/activepython/2.6/pywin32/html/com/help/active_directory.html.", "high_part", "=", "int", "(", "adsi_time_com_obj", ".", "highpart", ")",...
https://github.com/zakird/pyad/blob/d95ff67745065cafca4f2653aab1fbce2df91fb9/pyad/pyadutils.py#L81-L97
QCoDeS/Qcodes
3cda2cef44812e2aa4672781f2423bf5f816f9f9
qcodes/dataset/measurements.py
python
DataSaver._validate_result_types
( results_dict: Mapping[ParamSpecBase, np.ndarray])
Validate the type of the results
Validate the type of the results
[ "Validate", "the", "type", "of", "the", "results" ]
def _validate_result_types( results_dict: Mapping[ParamSpecBase, np.ndarray]) -> None: """ Validate the type of the results """ allowed_kinds = {'numeric': 'iuf', 'text': 'SU', 'array': 'iufcSUmM', 'complex': 'c'} for ps, vals in results_dict.items(): if vals.dtype.kind not in allowed_kinds[ps.type]: raise ValueError(f'Parameter {ps.name} is of type ' f'"{ps.type}", but got a result of ' f'type {vals.dtype} ({vals}).')
[ "def", "_validate_result_types", "(", "results_dict", ":", "Mapping", "[", "ParamSpecBase", ",", "np", ".", "ndarray", "]", ")", "->", "None", ":", "allowed_kinds", "=", "{", "'numeric'", ":", "'iuf'", ",", "'text'", ":", "'SU'", ",", "'array'", ":", "'iuf...
https://github.com/QCoDeS/Qcodes/blob/3cda2cef44812e2aa4672781f2423bf5f816f9f9/qcodes/dataset/measurements.py#L434-L447
inasafe/inasafe
355eb2ce63f516b9c26af0c86a24f99e53f63f87
safe/gui/tools/minimum_needs/needs_manager_dialog.py
python
NeedsManagerDialog.page_changed
(self, index)
Slot for when tab changes in the stacked widget changes. :param index: Index of the now active tab. :type index: int
Slot for when tab changes in the stacked widget changes.
[ "Slot", "for", "when", "tab", "changes", "in", "the", "stacked", "widget", "changes", "." ]
def page_changed(self, index): """Slot for when tab changes in the stacked widget changes. :param index: Index of the now active tab. :type index: int """ if index == 0: # profile edit page for item in self.resource_editing_buttons: item.hide() for item in self.profile_editing_widgets: item.setEnabled(True) for item in self.profile_editing_buttons: item.show() else: # resource_edit_page for item in self.resource_editing_buttons: item.show() for item in self.profile_editing_widgets: item.setEnabled(False) for item in self.profile_editing_buttons: item.hide()
[ "def", "page_changed", "(", "self", ",", "index", ")", ":", "if", "index", "==", "0", ":", "# profile edit page", "for", "item", "in", "self", ".", "resource_editing_buttons", ":", "item", ".", "hide", "(", ")", "for", "item", "in", "self", ".", "profile...
https://github.com/inasafe/inasafe/blob/355eb2ce63f516b9c26af0c86a24f99e53f63f87/safe/gui/tools/minimum_needs/needs_manager_dialog.py#L765-L784
replit-archive/empythoned
977ec10ced29a3541a4973dc2b59910805695752
cpython/Lib/pydoc.py
python
HTMLDoc.page
(self, title, contents)
return ''' <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: %s</title> </head><body bgcolor="#f0f0f8"> %s </body></html>''' % (title, contents)
Format an HTML page.
Format an HTML page.
[ "Format", "an", "HTML", "page", "." ]
def page(self, title, contents): """Format an HTML page.""" return ''' <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: %s</title> </head><body bgcolor="#f0f0f8"> %s </body></html>''' % (title, contents)
[ "def", "page", "(", "self", ",", "title", ",", "contents", ")", ":", "return", "'''\n<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">\n<html><head><title>Python: %s</title>\n</head><body bgcolor=\"#f0f0f8\">\n%s\n</body></html>'''", "%", "(", "title", ",", "contents",...
https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/cpython/Lib/pydoc.py#L425-L432
tkarras/progressive_growing_of_gans
2504c3f3cb98ca58751610ad61fa1097313152bd
dataset_tool.py
python
create_celeba
(tfrecord_dir, celeba_dir, cx=89, cy=121)
[]
def create_celeba(tfrecord_dir, celeba_dir, cx=89, cy=121): print('Loading CelebA from "%s"' % celeba_dir) glob_pattern = os.path.join(celeba_dir, 'img_align_celeba_png', '*.png') image_filenames = sorted(glob.glob(glob_pattern)) expected_images = 202599 if len(image_filenames) != expected_images: error('Expected to find %d images' % expected_images) with TFRecordExporter(tfrecord_dir, len(image_filenames)) as tfr: order = tfr.choose_shuffled_order() for idx in range(order.size): img = np.asarray(PIL.Image.open(image_filenames[order[idx]])) assert img.shape == (218, 178, 3) img = img[cy - 64 : cy + 64, cx - 64 : cx + 64] img = img.transpose(2, 0, 1) # HWC => CHW tfr.add_image(img)
[ "def", "create_celeba", "(", "tfrecord_dir", ",", "celeba_dir", ",", "cx", "=", "89", ",", "cy", "=", "121", ")", ":", "print", "(", "'Loading CelebA from \"%s\"'", "%", "celeba_dir", ")", "glob_pattern", "=", "os", ".", "path", ".", "join", "(", "celeba_d...
https://github.com/tkarras/progressive_growing_of_gans/blob/2504c3f3cb98ca58751610ad61fa1097313152bd/dataset_tool.py#L435-L450
kamalgill/flask-appengine-template
11760f83faccbb0d0afe416fc58e67ecfb4643c2
src/lib/werkzeug/debug/tbtools.py
python
Line.classes
(self)
return rv
[]
def classes(self): rv = ['line'] if self.in_frame: rv.append('in-frame') if self.current: rv.append('current') return rv
[ "def", "classes", "(", "self", ")", ":", "rv", "=", "[", "'line'", "]", "if", "self", ".", "in_frame", ":", "rv", ".", "append", "(", "'in-frame'", ")", "if", "self", ".", "current", ":", "rv", ".", "append", "(", "'current'", ")", "return", "rv" ]
https://github.com/kamalgill/flask-appengine-template/blob/11760f83faccbb0d0afe416fc58e67ecfb4643c2/src/lib/werkzeug/debug/tbtools.py#L200-L206
ilayn/harold
2bfa00fca4549313d47386991a27c84c8fc91637
harold/_polynomial_ops.py
python
haroldpoly
(rootlist)
Takes a 1D array-like numerical elements as roots and forms the polynomial
Takes a 1D array-like numerical elements as roots and forms the polynomial
[ "Takes", "a", "1D", "array", "-", "like", "numerical", "elements", "as", "roots", "and", "forms", "the", "polynomial" ]
def haroldpoly(rootlist): """ Takes a 1D array-like numerical elements as roots and forms the polynomial """ if isinstance(rootlist, collections.abc.Iterable): r = np.array([x for x in rootlist], dtype=complex) else: raise TypeError('The argument must be something iterable,\nsuch as ' 'list, numpy array, tuple etc. I don\'t know\nwhat ' 'to do with a \"{0}\" object.' ''.format(type(rootlist).__name__)) n = r.size if n == 0: return np.ones(1) else: p = np.array([0.+0j for x in range(n+1)], dtype=complex) p[0] = 1 # Monic polynomial p[1] = -rootlist[0] for x in range(1, n): p[x+1] = -p[x]*r[x] for y in range(x, 0, -1): p[y] -= p[y-1] * r[x] return p
[ "def", "haroldpoly", "(", "rootlist", ")", ":", "if", "isinstance", "(", "rootlist", ",", "collections", ".", "abc", ".", "Iterable", ")", ":", "r", "=", "np", ".", "array", "(", "[", "x", "for", "x", "in", "rootlist", "]", ",", "dtype", "=", "comp...
https://github.com/ilayn/harold/blob/2bfa00fca4549313d47386991a27c84c8fc91637/harold/_polynomial_ops.py#L319-L342
huggingface/transformers
623b4f7c63f60cce917677ee704d6c93ee960b4b
src/transformers/models/fsmt/modeling_fsmt.py
python
_reorder_buffer
(attn_cache, new_order)
return attn_cache
[]
def _reorder_buffer(attn_cache, new_order): for k, input_buffer_k in attn_cache.items(): if input_buffer_k is not None: attn_cache[k] = input_buffer_k.index_select(0, new_order) return attn_cache
[ "def", "_reorder_buffer", "(", "attn_cache", ",", "new_order", ")", ":", "for", "k", ",", "input_buffer_k", "in", "attn_cache", ".", "items", "(", ")", ":", "if", "input_buffer_k", "is", "not", "None", ":", "attn_cache", "[", "k", "]", "=", "input_buffer_k...
https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/fsmt/modeling_fsmt.py#L799-L803
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/algebras/quantum_groups/ace_quantum_onsager.py
python
ACEQuantumOnsagerAlgebra._dagger_on_basis
(self, x)
return self.prod(A[tw(m)]**e for m,e in reversed(x._sorted_items()))
r""" Return the action of the `\dagger` antiautomorphism on the basis element indexed by ``x``. EXAMPLES:: sage: A = algebras.AlternatingCentralExtensionQuantumOnsager(QQ) sage: I = A._indices.monoid_generators() sage: A._dagger_on_basis(I[0,1] * I[1,-1] * I[2,1]) G[1]*W[-1]*Gt[1] sage: A._dagger_on_basis(I[1,-1] * I[1,1]) W[-1]*W[1] + (q/(q^2+1))*G[2] + (-q/(q^2+1))*Gt[2] sage: A._dagger_on_basis(I[0,1] * I[1,-1] * I[1,2] * I[2,1]) (q^4/(q^8+2*q^6-2*q^2-1))*G[1]^2*Gt[1]*Gt[2] + (-q^4/(q^8+2*q^6-2*q^2-1))*G[1]*G[2]*Gt[1]^2 + G[1]*W[-1]*W[2]*Gt[1] + (q/(q^2+1))*G[1]*G[3]*Gt[1] + (-q/(q^2+1))*G[1]*Gt[1]*Gt[3] sage: [(x, A.dagger(x)) for x in A.some_elements()] [(W[0], W[0]), (W[3], W[3]), (W[-1], W[-1]), (W[1], W[1]), (W[-2], W[-2]), (G[1], Gt[1]), (G[2], Gt[2]), (Gt[1], G[1]), (Gt[2], G[2])]
r""" Return the action of the `\dagger` antiautomorphism on the basis element indexed by ``x``.
[ "r", "Return", "the", "action", "of", "the", "\\", "dagger", "antiautomorphism", "on", "the", "basis", "element", "indexed", "by", "x", "." ]
def _dagger_on_basis(self, x): r""" Return the action of the `\dagger` antiautomorphism on the basis element indexed by ``x``. EXAMPLES:: sage: A = algebras.AlternatingCentralExtensionQuantumOnsager(QQ) sage: I = A._indices.monoid_generators() sage: A._dagger_on_basis(I[0,1] * I[1,-1] * I[2,1]) G[1]*W[-1]*Gt[1] sage: A._dagger_on_basis(I[1,-1] * I[1,1]) W[-1]*W[1] + (q/(q^2+1))*G[2] + (-q/(q^2+1))*Gt[2] sage: A._dagger_on_basis(I[0,1] * I[1,-1] * I[1,2] * I[2,1]) (q^4/(q^8+2*q^6-2*q^2-1))*G[1]^2*Gt[1]*Gt[2] + (-q^4/(q^8+2*q^6-2*q^2-1))*G[1]*G[2]*Gt[1]^2 + G[1]*W[-1]*W[2]*Gt[1] + (q/(q^2+1))*G[1]*G[3]*Gt[1] + (-q/(q^2+1))*G[1]*Gt[1]*Gt[3] sage: [(x, A.dagger(x)) for x in A.some_elements()] [(W[0], W[0]), (W[3], W[3]), (W[-1], W[-1]), (W[1], W[1]), (W[-2], W[-2]), (G[1], Gt[1]), (G[2], Gt[2]), (Gt[1], G[1]), (Gt[2], G[2])] """ def tw(m): if m[0] == 0: return (2, m[1]) if m[0] == 1: return (1, m[1]) if m[0] == 2: return (0, m[1]) A = self.algebra_generators() return self.prod(A[tw(m)]**e for m,e in reversed(x._sorted_items()))
[ "def", "_dagger_on_basis", "(", "self", ",", "x", ")", ":", "def", "tw", "(", "m", ")", ":", "if", "m", "[", "0", "]", "==", "0", ":", "return", "(", "2", ",", "m", "[", "1", "]", ")", "if", "m", "[", "0", "]", "==", "1", ":", "return", ...
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/algebras/quantum_groups/ace_quantum_onsager.py#L620-L651
aaronportnoy/toolbag
2d39457a7617b2f334d203d8c8cf88a5a25ef1fa
toolbag/agent/dbg/cobra/cluster.py
python
ClusterServer.failWork
(self, work)
This is called for a work unit that is in a failed state. This is most commonly that the work() method has raised an exception.
This is called for a work unit that is in a failed state. This is most commonly that the work() method has raised an exception.
[ "This", "is", "called", "for", "a", "work", "unit", "that", "is", "in", "a", "failed", "state", ".", "This", "is", "most", "commonly", "that", "the", "work", "()", "method", "has", "raised", "an", "exception", "." ]
def failWork(self, work): """ This is called for a work unit that is in a failed state. This is most commonly that the work() method has raised an exception. """ self.__cleanWork(work.id) if self.callback: self.callback.workFailed(self, work)
[ "def", "failWork", "(", "self", ",", "work", ")", ":", "self", ".", "__cleanWork", "(", "work", ".", "id", ")", "if", "self", ".", "callback", ":", "self", ".", "callback", ".", "workFailed", "(", "self", ",", "work", ")" ]
https://github.com/aaronportnoy/toolbag/blob/2d39457a7617b2f334d203d8c8cf88a5a25ef1fa/toolbag/agent/dbg/cobra/cluster.py#L310-L317
postlund/pyatv
4ed1f5539f37d86d80272663d1f2ea34a6c41ec4
pyatv/protocols/companion/protocol.py
python
CompanionProtocol.send_opack
(self, frame_type: FrameType, data: Dict[str, Any])
Send data encoded with OPACK.
Send data encoded with OPACK.
[ "Send", "data", "encoded", "with", "OPACK", "." ]
def send_opack(self, frame_type: FrameType, data: Dict[str, Any]) -> None: """Send data encoded with OPACK.""" # Add XID if not present if "_x" not in data: data["_x"] = self._xid self._xid += 1 _LOGGER.debug("Send OPACK: %s", data) self.connection.send(frame_type, opack.pack(data))
[ "def", "send_opack", "(", "self", ",", "frame_type", ":", "FrameType", ",", "data", ":", "Dict", "[", "str", ",", "Any", "]", ")", "->", "None", ":", "# Add XID if not present", "if", "\"_x\"", "not", "in", "data", ":", "data", "[", "\"_x\"", "]", "=",...
https://github.com/postlund/pyatv/blob/4ed1f5539f37d86d80272663d1f2ea34a6c41ec4/pyatv/protocols/companion/protocol.py#L182-L190
prompt-toolkit/ptpython
d8b5c90d20cc1e8d88837aa7163289950c231f74
ptpython/python_input.py
python
PythonInput.selected_option
(self)
Return the currently selected option.
Return the currently selected option.
[ "Return", "the", "currently", "selected", "option", "." ]
def selected_option(self) -> Option: "Return the currently selected option." i = 0 for category in self.options: for o in category.options: if i == self.selected_option_index: return o else: i += 1 raise ValueError("Nothing selected")
[ "def", "selected_option", "(", "self", ")", "->", "Option", ":", "i", "=", "0", "for", "category", "in", "self", ".", "options", ":", "for", "o", "in", "category", ".", "options", ":", "if", "i", "==", "self", ".", "selected_option_index", ":", "return...
https://github.com/prompt-toolkit/ptpython/blob/d8b5c90d20cc1e8d88837aa7163289950c231f74/ptpython/python_input.py#L411-L421
TengXiaoDai/DistributedCrawling
f5c2439e6ce68dd9b49bde084d76473ff9ed4963
Lib/shutil.py
python
copyfileobj
(fsrc, fdst, length=16*1024)
copy data from file-like object fsrc to file-like object fdst
copy data from file-like object fsrc to file-like object fdst
[ "copy", "data", "from", "file", "-", "like", "object", "fsrc", "to", "file", "-", "like", "object", "fdst" ]
def copyfileobj(fsrc, fdst, length=16*1024): """copy data from file-like object fsrc to file-like object fdst""" while 1: buf = fsrc.read(length) if not buf: break fdst.write(buf)
[ "def", "copyfileobj", "(", "fsrc", ",", "fdst", ",", "length", "=", "16", "*", "1024", ")", ":", "while", "1", ":", "buf", "=", "fsrc", ".", "read", "(", "length", ")", "if", "not", "buf", ":", "break", "fdst", ".", "write", "(", "buf", ")" ]
https://github.com/TengXiaoDai/DistributedCrawling/blob/f5c2439e6ce68dd9b49bde084d76473ff9ed4963/Lib/shutil.py#L76-L82
geometalab/Vector-Tiles-Reader-QGIS-Plugin
a31ae86959c8f3b7d6f332f84191cd7ca4683e1d
plugin/vt_reader.py
python
VtReader._load_tiles
(self)
[]
def _load_tiles(self): if not self._source or self.connection()["type"] == ConnectionTypes.MBTiles: # recreate source to assure the source belongs to the new thread, SQLite3 isn't happy about it otherwise self._source = self._create_source(self.connection()) try: self._feature_count = 0 self._all_tiles = [] bounds: Bounds = self._loading_options["bounds"] clip_tiles = self._loading_options["clip_tiles"] max_tiles = self._loading_options["max_tiles"] layer_filter = self._loading_options["layer_filter"] info("Tile limit enabled: {} ({})", max_tiles is not None and max_tiles > 0, max_tiles) self.cancel_requested = False self.feature_collections_by_layer_name_and_geotype = {} self._update_progress(show_dialog=True) self._clip_tiles_at_tile_bounds = clip_tiles zoom_level = self._get_clamped_zoom_level() all_tiles = get_all_tiles(bounds=bounds, is_cancel_requested_handler=lambda: self.cancel_requested) tiles_to_load = set() cached_tiles = [] tiles_to_ignore = set() source_name = self._source.name() scheme = self._source.scheme() for t in all_tiles: if self.cancel_requested or (max_tiles and len(cached_tiles) >= max_tiles): break decoded_data = get_cache_entry(cache_name=source_name, zoom_level=zoom_level, x=t[0], y=t[1]) if decoded_data: tile = VectorTile(scheme=scheme, zoom_level=zoom_level, x=t[0], y=t[1]) tile.decoded_data = decoded_data cached_tiles.append(tile) tiles_to_ignore.add((tile.column, tile.row)) else: tiles_to_load.add(t) remaining_nr_of_tiles = len(tiles_to_load) if max_tiles: if len(cached_tiles) + len(tiles_to_load) >= max_tiles: remaining_nr_of_tiles = clamp(max_tiles - len(cached_tiles), low=0) info("{} tiles in cache. Max. {} will be loaded additionally.", len(cached_tiles), remaining_nr_of_tiles) if len(cached_tiles) > 0: if not self.cancel_requested: self._process_tiles(cached_tiles, layer_filter) self._all_tiles.extend(cached_tiles) debug("Loading data for zoom level '{}' source '{}'", zoom_level, self._source.name()) if remaining_nr_of_tiles: tile_data_tuples = self._source.load_tiles( zoom_level=zoom_level, tiles_to_load=tiles_to_load, max_tiles=remaining_nr_of_tiles ) if len(tile_data_tuples) > 0 and not self.cancel_requested: tiles = self._decode_tiles(tile_data_tuples) self._process_tiles(tiles, layer_filter) for t in tiles: cache_tile( cache_name=source_name, zoom_level=zoom_level, x=t.column, y=t.row, decoded_data=t.decoded_data, ) self._all_tiles.extend(tiles) self._ready_for_next_loading_step.emit() except Exception as e: tb = "" if traceback: tb = traceback.format_exc() critical("An exception occured: {}, {}", e, tb) self.cancelled.emit()
[ "def", "_load_tiles", "(", "self", ")", ":", "if", "not", "self", ".", "_source", "or", "self", ".", "connection", "(", ")", "[", "\"type\"", "]", "==", "ConnectionTypes", ".", "MBTiles", ":", "# recreate source to assure the source belongs to the new thread, SQLite...
https://github.com/geometalab/Vector-Tiles-Reader-QGIS-Plugin/blob/a31ae86959c8f3b7d6f332f84191cd7ca4683e1d/plugin/vt_reader.py#L231-L306
gwpy/gwpy
82becd78d166a32985cb657a54d0d39f6a207739
gwpy/io/datafind.py
python
find_best_frametype
(channel, start, end, frametype_match=None, allow_tape=True, connection=None, host=None, port=None)
Intelligently select the best frametype from which to read this channel Parameters ---------- channel : `str`, `~gwpy.detector.Channel` the channel to be found start : `~gwpy.time.LIGOTimeGPS`, `float`, `str` GPS start time of period of interest, any input parseable by `~gwpy.time.to_gps` is fine end : `~gwpy.time.LIGOTimeGPS`, `float`, `str` GPS end time of period of interest, any input parseable by `~gwpy.time.to_gps` is fine host : `str`, optional name of datafind host to use port : `int`, optional port on datafind host to use frametype_match : `str`, optiona regular expression to use for frametype `str` matching allow_tape : `bool`, optional do not test types whose frame files are stored on tape (not on spinning disk) Returns ------- frametype : `str` the best matching frametype for the ``channel`` in the ``[start, end)`` interval Raises ------ ValueError if no valid frametypes are found Examples -------- >>> from gwpy.io.datafind import find_best_frametype >>> find_best_frametype('L1:GDS-CALIB_STRAIN', 1126259460, 1126259464) 'L1_HOFT_C00'
Intelligently select the best frametype from which to read this channel
[ "Intelligently", "select", "the", "best", "frametype", "from", "which", "to", "read", "this", "channel" ]
def find_best_frametype(channel, start, end, frametype_match=None, allow_tape=True, connection=None, host=None, port=None): """Intelligently select the best frametype from which to read this channel Parameters ---------- channel : `str`, `~gwpy.detector.Channel` the channel to be found start : `~gwpy.time.LIGOTimeGPS`, `float`, `str` GPS start time of period of interest, any input parseable by `~gwpy.time.to_gps` is fine end : `~gwpy.time.LIGOTimeGPS`, `float`, `str` GPS end time of period of interest, any input parseable by `~gwpy.time.to_gps` is fine host : `str`, optional name of datafind host to use port : `int`, optional port on datafind host to use frametype_match : `str`, optiona regular expression to use for frametype `str` matching allow_tape : `bool`, optional do not test types whose frame files are stored on tape (not on spinning disk) Returns ------- frametype : `str` the best matching frametype for the ``channel`` in the ``[start, end)`` interval Raises ------ ValueError if no valid frametypes are found Examples -------- >>> from gwpy.io.datafind import find_best_frametype >>> find_best_frametype('L1:GDS-CALIB_STRAIN', 1126259460, 1126259464) 'L1_HOFT_C00' """ try: return find_frametype(channel, gpstime=(start, end), frametype_match=frametype_match, allow_tape=allow_tape, on_gaps='error', connection=connection, host=host, port=port) except RuntimeError: # gaps (or something else went wrong) ftout = find_frametype(channel, gpstime=(start, end), frametype_match=frametype_match, return_all=True, allow_tape=allow_tape, on_gaps='ignore', connection=connection, host=host, port=port) try: if isinstance(ftout, dict): return {key: ftout[key][0] for key in ftout} return ftout[0] except IndexError: raise ValueError("Cannot find any valid frametypes for channel(s)")
[ "def", "find_best_frametype", "(", "channel", ",", "start", ",", "end", ",", "frametype_match", "=", "None", ",", "allow_tape", "=", "True", ",", "connection", "=", "None", ",", "host", "=", "None", ",", "port", "=", "None", ")", ":", "try", ":", "retu...
https://github.com/gwpy/gwpy/blob/82becd78d166a32985cb657a54d0d39f6a207739/gwpy/io/datafind.py#L614-L678
1040003585/WebScrapingWithPython
a770fa5b03894076c8c9539b1ffff34424ffc016
portia_examle/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py
python
find_eggs_in_zip
(importer, path_item, only=False)
Find eggs in zip files; possibly multiple nested eggs.
Find eggs in zip files; possibly multiple nested eggs.
[ "Find", "eggs", "in", "zip", "files", ";", "possibly", "multiple", "nested", "eggs", "." ]
def find_eggs_in_zip(importer, path_item, only=False): """ Find eggs in zip files; possibly multiple nested eggs. """ if importer.archive.endswith('.whl'): # wheels are not supported with this finder # they don't have PKG-INFO metadata, and won't ever contain eggs return metadata = EggMetadata(importer) if metadata.has_metadata('PKG-INFO'): yield Distribution.from_filename(path_item, metadata=metadata) if only: # don't yield nested distros return for subitem in metadata.resource_listdir('/'): if _is_unpacked_egg(subitem): subpath = os.path.join(path_item, subitem) for dist in find_eggs_in_zip(zipimport.zipimporter(subpath), subpath): yield dist
[ "def", "find_eggs_in_zip", "(", "importer", ",", "path_item", ",", "only", "=", "False", ")", ":", "if", "importer", ".", "archive", ".", "endswith", "(", "'.whl'", ")", ":", "# wheels are not supported with this finder", "# they don't have PKG-INFO metadata, and won't ...
https://github.com/1040003585/WebScrapingWithPython/blob/a770fa5b03894076c8c9539b1ffff34424ffc016/portia_examle/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py#L1940-L1958
openshift/openshift-tools
1188778e728a6e4781acf728123e5b356380fe6f
openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/src/lib/deploymentconfig.py
python
DeploymentConfig.exists_env_value
(self, key, value)
return False
return whether a key, value pair exists
return whether a key, value pair exists
[ "return", "whether", "a", "key", "value", "pair", "exists" ]
def exists_env_value(self, key, value): ''' return whether a key, value pair exists ''' results = self.get_env_vars() if not results: return False for result in results: if result['name'] == key: if 'value' not in result: if value == "" or value is None: return True elif result['value'] == value: return True return False
[ "def", "exists_env_value", "(", "self", ",", "key", ",", "value", ")", ":", "results", "=", "self", ".", "get_env_vars", "(", ")", "if", "not", "results", ":", "return", "False", "for", "result", "in", "results", ":", "if", "result", "[", "'name'", "]"...
https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.11.28-1/roles/lib_openshift/src/lib/deploymentconfig.py#L84-L98
wxWidgets/Phoenix
b2199e299a6ca6d866aa6f3d0888499136ead9d6
wx/lib/agw/customtreectrl.py
python
CustomTreeCtrl.ChildrenClosing
(self, item)
We are about to destroy the item children. :param `item`: an instance of :class:`GenericTreeItem`.
We are about to destroy the item children.
[ "We", "are", "about", "to", "destroy", "the", "item", "children", "." ]
def ChildrenClosing(self, item): """ We are about to destroy the item children. :param `item`: an instance of :class:`GenericTreeItem`. """ if self._editCtrl is not None and item != self._editCtrl.item() and self.IsDescendantOf(item, self._editCtrl.item()): self._editCtrl.StopEditing() if item != self._key_current and self.IsDescendantOf(item, self._key_current): self._key_current = None if self.IsDescendantOf(item, self._select_me): self._select_me = item if item != self._current and self.IsDescendantOf(item, self._current): self._current.SetHilight(False) self._current = None self._select_me = item
[ "def", "ChildrenClosing", "(", "self", ",", "item", ")", ":", "if", "self", ".", "_editCtrl", "is", "not", "None", "and", "item", "!=", "self", ".", "_editCtrl", ".", "item", "(", ")", "and", "self", ".", "IsDescendantOf", "(", "item", ",", "self", "...
https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/agw/customtreectrl.py#L5427-L5446
jason9693/MusicTransformer-tensorflow2.0
f7c06c0cb2e9cdddcbf6db779cb39cd650282778
custom/callback.py
python
CustomSchedule.__call__
(self, step)
return tf.math.rsqrt(self.d_model) * tf.math.minimum(arg1, arg2)
[]
def __call__(self, step): arg1 = tf.math.rsqrt(step) arg2 = step * (self.warmup_steps ** -1.5) return tf.math.rsqrt(self.d_model) * tf.math.minimum(arg1, arg2)
[ "def", "__call__", "(", "self", ",", "step", ")", ":", "arg1", "=", "tf", ".", "math", ".", "rsqrt", "(", "step", ")", "arg2", "=", "step", "*", "(", "self", ".", "warmup_steps", "**", "-", "1.5", ")", "return", "tf", ".", "math", ".", "rsqrt", ...
https://github.com/jason9693/MusicTransformer-tensorflow2.0/blob/f7c06c0cb2e9cdddcbf6db779cb39cd650282778/custom/callback.py#L66-L70
trigger/trigger
c089f761a150f537f7e3201422a3964ec52ff245
trigger/netdevices/__init__.py
python
NetDevice.can_ssh_async
(self)
return self._can_ssh('async')
Am I enabled to use SSH async?
Am I enabled to use SSH async?
[ "Am", "I", "enabled", "to", "use", "SSH", "async?" ]
def can_ssh_async(self): """Am I enabled to use SSH async?""" return self._can_ssh('async')
[ "def", "can_ssh_async", "(", "self", ")", ":", "return", "self", ".", "_can_ssh", "(", "'async'", ")" ]
https://github.com/trigger/trigger/blob/c089f761a150f537f7e3201422a3964ec52ff245/trigger/netdevices/__init__.py#L824-L826
deepfakes/faceswap
09c7d8aca3c608d1afad941ea78e9fd9b64d9219
lib/gui/display_analysis.py
python
StatsData._resize_frame
(self, event)
Resize the options frame to fit the canvas. Parameters ---------- event: `tkinter.Event` The tkinter resize event
Resize the options frame to fit the canvas.
[ "Resize", "the", "options", "frame", "to", "fit", "the", "canvas", "." ]
def _resize_frame(self, event): """ Resize the options frame to fit the canvas. Parameters ---------- event: `tkinter.Event` The tkinter resize event """ logger.debug("Resize Analysis Frame") canvas_width = event.width canvas_height = event.height self._canvas.itemconfig(self._tree_canvas, width=canvas_width, height=canvas_height) logger.debug("Resized Analysis Frame")
[ "def", "_resize_frame", "(", "self", ",", "event", ")", ":", "logger", ".", "debug", "(", "\"Resize Analysis Frame\"", ")", "canvas_width", "=", "event", ".", "width", "canvas_height", "=", "event", ".", "height", "self", ".", "_canvas", ".", "itemconfig", "...
https://github.com/deepfakes/faceswap/blob/09c7d8aca3c608d1afad941ea78e9fd9b64d9219/lib/gui/display_analysis.py#L416-L428
markovmodel/PyEMMA
e9d08d715dde17ceaa96480a9ab55d5e87d3a4b3
pyemma/coordinates/data/_base/datasource.py
python
DataSourceIterator._itraj
(self, value)
Reader-internal property that tracks the upcoming trajectory index. Should not be used within iterator loop. Parameters ---------- value : int The upcoming trajectory index.
Reader-internal property that tracks the upcoming trajectory index. Should not be used within iterator loop. Parameters ---------- value : int The upcoming trajectory index.
[ "Reader", "-", "internal", "property", "that", "tracks", "the", "upcoming", "trajectory", "index", ".", "Should", "not", "be", "used", "within", "iterator", "loop", ".", "Parameters", "----------", "value", ":", "int", "The", "upcoming", "trajectory", "index", ...
def _itraj(self, value): """ Reader-internal property that tracks the upcoming trajectory index. Should not be used within iterator loop. Parameters ---------- value : int The upcoming trajectory index. """ if value != self._selected_itraj: self.state.itraj = value # TODO: this side effect is unexpected. self.state.t = 0
[ "def", "_itraj", "(", "self", ",", "value", ")", ":", "if", "value", "!=", "self", ".", "_selected_itraj", ":", "self", ".", "state", ".", "itraj", "=", "value", "# TODO: this side effect is unexpected.", "self", ".", "state", ".", "t", "=", "0" ]
https://github.com/markovmodel/PyEMMA/blob/e9d08d715dde17ceaa96480a9ab55d5e87d3a4b3/pyemma/coordinates/data/_base/datasource.py#L865-L876
misterch0c/shadowbroker
e3a069bea47a2c1009697941ac214adc6f90aa8d
windows/Resources/Python/Core/Lib/email/base64mime.py
python
header_encode
(header, charset='iso-8859-1', keep_eols=False, maxlinelen=76, eol=NL)
return joiner.join(lines)
r"""Encode a single header line with Base64 encoding in a given charset. Defined in RFC 2045, this Base64 encoding is identical to normal Base64 encoding, except that each line must be intelligently wrapped (respecting the Base64 encoding), and subsequent lines must start with a space. charset names the character set to use to encode the header. It defaults to iso-8859-1. End-of-line characters (\r, \n, \r\n) will be automatically converted to the canonical email line separator \r\n unless the keep_eols parameter is True (the default is False). Each line of the header will be terminated in the value of eol, which defaults to "\n". Set this to "\r\n" if you are using the result of this function directly in email. The resulting string will be in the form: "=?charset?b?WW/5ciBtYXp66XLrIHf8eiBhIGhhbXBzdGHuciBBIFlv+XIgbWF6euly?=\n =?charset?b?6yB3/HogYSBoYW1wc3Rh7nIgQkMgWW/5ciBtYXp66XLrIHf8eiBhIGhh?=" with each line wrapped at, at most, maxlinelen characters (defaults to 76 characters).
r"""Encode a single header line with Base64 encoding in a given charset. Defined in RFC 2045, this Base64 encoding is identical to normal Base64 encoding, except that each line must be intelligently wrapped (respecting the Base64 encoding), and subsequent lines must start with a space. charset names the character set to use to encode the header. It defaults to iso-8859-1. End-of-line characters (\r, \n, \r\n) will be automatically converted to the canonical email line separator \r\n unless the keep_eols parameter is True (the default is False). Each line of the header will be terminated in the value of eol, which defaults to "\n". Set this to "\r\n" if you are using the result of this function directly in email. The resulting string will be in the form: "=?charset?b?WW/5ciBtYXp66XLrIHf8eiBhIGhhbXBzdGHuciBBIFlv+XIgbWF6euly?=\n =?charset?b?6yB3/HogYSBoYW1wc3Rh7nIgQkMgWW/5ciBtYXp66XLrIHf8eiBhIGhh?=" with each line wrapped at, at most, maxlinelen characters (defaults to 76 characters).
[ "r", "Encode", "a", "single", "header", "line", "with", "Base64", "encoding", "in", "a", "given", "charset", ".", "Defined", "in", "RFC", "2045", "this", "Base64", "encoding", "is", "identical", "to", "normal", "Base64", "encoding", "except", "that", "each",...
def header_encode(header, charset='iso-8859-1', keep_eols=False, maxlinelen=76, eol=NL): r"""Encode a single header line with Base64 encoding in a given charset. Defined in RFC 2045, this Base64 encoding is identical to normal Base64 encoding, except that each line must be intelligently wrapped (respecting the Base64 encoding), and subsequent lines must start with a space. charset names the character set to use to encode the header. It defaults to iso-8859-1. End-of-line characters (\r, \n, \r\n) will be automatically converted to the canonical email line separator \r\n unless the keep_eols parameter is True (the default is False). Each line of the header will be terminated in the value of eol, which defaults to "\n". Set this to "\r\n" if you are using the result of this function directly in email. The resulting string will be in the form: "=?charset?b?WW/5ciBtYXp66XLrIHf8eiBhIGhhbXBzdGHuciBBIFlv+XIgbWF6euly?=\n =?charset?b?6yB3/HogYSBoYW1wc3Rh7nIgQkMgWW/5ciBtYXp66XLrIHf8eiBhIGhh?=" with each line wrapped at, at most, maxlinelen characters (defaults to 76 characters). """ if not header: return header if not keep_eols: header = fix_eols(header) base64ed = [] max_encoded = maxlinelen - len(charset) - MISC_LEN max_unencoded = max_encoded * 3 // 4 for i in range(0, len(header), max_unencoded): base64ed.append(b2a_base64(header[i:i + max_unencoded])) lines = [] for line in base64ed: if line.endswith(NL): line = line[:-1] lines.append('=?%s?b?%s?=' % (charset, line)) joiner = eol + ' ' return joiner.join(lines)
[ "def", "header_encode", "(", "header", ",", "charset", "=", "'iso-8859-1'", ",", "keep_eols", "=", "False", ",", "maxlinelen", "=", "76", ",", "eol", "=", "NL", ")", ":", "if", "not", "header", ":", "return", "header", "if", "not", "keep_eols", ":", "h...
https://github.com/misterch0c/shadowbroker/blob/e3a069bea47a2c1009697941ac214adc6f90aa8d/windows/Resources/Python/Core/Lib/email/base64mime.py#L52-L95
openstack/manila
142990edc027e14839d5deaf4954dd6fc88de15e
manila/api/v1/share_snapshots.py
python
ShareSnapshotMixin.update
(self, req, id, body)
return self._view_builder.detail(req, snapshot)
Update a snapshot.
Update a snapshot.
[ "Update", "a", "snapshot", "." ]
def update(self, req, id, body): """Update a snapshot.""" context = req.environ['manila.context'] if not body or 'snapshot' not in body: raise exc.HTTPUnprocessableEntity() snapshot_data = body['snapshot'] valid_update_keys = ( 'display_name', 'display_description', ) update_dict = {key: snapshot_data[key] for key in valid_update_keys if key in snapshot_data} try: snapshot = self.share_api.get_snapshot(context, id) except exception.NotFound: raise exc.HTTPNotFound() snapshot = self.share_api.snapshot_update(context, snapshot, update_dict) snapshot.update(update_dict) return self._view_builder.detail(req, snapshot)
[ "def", "update", "(", "self", ",", "req", ",", "id", ",", "body", ")", ":", "context", "=", "req", ".", "environ", "[", "'manila.context'", "]", "if", "not", "body", "or", "'snapshot'", "not", "in", "body", ":", "raise", "exc", ".", "HTTPUnprocessableE...
https://github.com/openstack/manila/blob/142990edc027e14839d5deaf4954dd6fc88de15e/manila/api/v1/share_snapshots.py#L146-L171
ping/instagram_private_api
0fda0369ac02bc03d56f5f3f99bc9de2cc25ffaa
instagram_private_api/utils.py
python
chunk_generator
(chunk_count, chunk_size, file_data)
Generic chunk generator logic :param chunk_count: Number of chunks wanted :param chunk_size: Size of each chunk :param file_data: bytes to be split into chunk :return:
Generic chunk generator logic
[ "Generic", "chunk", "generator", "logic" ]
def chunk_generator(chunk_count, chunk_size, file_data): """ Generic chunk generator logic :param chunk_count: Number of chunks wanted :param chunk_size: Size of each chunk :param file_data: bytes to be split into chunk :return: """ try: total_len = len(file_data) is_fp = False except TypeError: total_len = get_file_size(file_data) is_fp = True for i in range(chunk_count): start_range = i * chunk_size end_range = (start_range + chunk_size) if i < (chunk_count - 1) else total_len chunk_info = Chunk(i, start_range, end_range, chunk_count) if is_fp: file_data.seek(chunk_info.start, os.SEEK_SET) yield chunk_info, file_data.read(chunk_info.length) else: yield chunk_info, file_data[chunk_info.start: chunk_info.end]
[ "def", "chunk_generator", "(", "chunk_count", ",", "chunk_size", ",", "file_data", ")", ":", "try", ":", "total_len", "=", "len", "(", "file_data", ")", "is_fp", "=", "False", "except", "TypeError", ":", "total_len", "=", "get_file_size", "(", "file_data", "...
https://github.com/ping/instagram_private_api/blob/0fda0369ac02bc03d56f5f3f99bc9de2cc25ffaa/instagram_private_api/utils.py#L81-L104
facelessuser/RegReplace
c127d48c9f81a610eb01dbd78f4cc40182ab6800
support.py
python
is_installed_by_package_control
()
return str(__pc_name__ in set(settings.get('installed_packages', [])))
Check if installed by package control.
Check if installed by package control.
[ "Check", "if", "installed", "by", "package", "control", "." ]
def is_installed_by_package_control(): """Check if installed by package control.""" settings = sublime.load_settings('Package Control.sublime-settings') return str(__pc_name__ in set(settings.get('installed_packages', [])))
[ "def", "is_installed_by_package_control", "(", ")", ":", "settings", "=", "sublime", ".", "load_settings", "(", "'Package Control.sublime-settings'", ")", "return", "str", "(", "__pc_name__", "in", "set", "(", "settings", ".", "get", "(", "'installed_packages'", ","...
https://github.com/facelessuser/RegReplace/blob/c127d48c9f81a610eb01dbd78f4cc40182ab6800/support.py#L70-L74
khanhnamle1994/natural-language-processing
01d450d5ac002b0156ef4cf93a07cb508c1bcdc5
assignment1/.env/lib/python2.7/site-packages/IPython/html/services/notebooks/filenbmanager.py
python
FileNotebookManager.is_hidden
(self, path)
return is_hidden(os_path, self.notebook_dir)
Does the API style path correspond to a hidden directory or file? Parameters ---------- path : string The path to check. This is an API path (`/` separated, relative to base notebook-dir). Returns ------- exists : bool Whether the path is hidden.
Does the API style path correspond to a hidden directory or file? Parameters ---------- path : string The path to check. This is an API path (`/` separated, relative to base notebook-dir). Returns ------- exists : bool Whether the path is hidden.
[ "Does", "the", "API", "style", "path", "correspond", "to", "a", "hidden", "directory", "or", "file?", "Parameters", "----------", "path", ":", "string", "The", "path", "to", "check", ".", "This", "is", "an", "API", "path", "(", "/", "separated", "relative"...
def is_hidden(self, path): """Does the API style path correspond to a hidden directory or file? Parameters ---------- path : string The path to check. This is an API path (`/` separated, relative to base notebook-dir). Returns ------- exists : bool Whether the path is hidden. """ path = path.strip('/') os_path = self._get_os_path(path=path) return is_hidden(os_path, self.notebook_dir)
[ "def", "is_hidden", "(", "self", ",", "path", ")", ":", "path", "=", "path", ".", "strip", "(", "'/'", ")", "os_path", "=", "self", ".", "_get_os_path", "(", "path", "=", "path", ")", "return", "is_hidden", "(", "os_path", ",", "self", ".", "notebook...
https://github.com/khanhnamle1994/natural-language-processing/blob/01d450d5ac002b0156ef4cf93a07cb508c1bcdc5/assignment1/.env/lib/python2.7/site-packages/IPython/html/services/notebooks/filenbmanager.py#L113-L130
buke/GreenOdoo
3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df
runtime/python/lib/python2.7/site-packages/gdata/apps/organization/client.py
python
OrganizationUnitProvisioningClient.update_org_unit
(self, customer_id, org_unit_path, org_unit_entry, **kwargs)
return self.update(org_unit_entry, uri=self.MakeOrganizationUnitOrgunitProvisioningUri( customer_id, org_unit_path=org_unit_path), **kwargs)
Update a Organization Unit. Args: customer_id: string The ID of the Google Apps customer. org_unit_path: string The organization's full path name. [Note: Each element of the path MUST be URL encoded (example: finance%2Forganization/suborganization)] org_unit_entry: gdata.apps.organization.data.OrgUnitEntry The updated organization unit entry. Returns: A gdata.apps.organization.data.OrgUnitEntry representing an organization unit.
Update a Organization Unit.
[ "Update", "a", "Organization", "Unit", "." ]
def update_org_unit(self, customer_id, org_unit_path, org_unit_entry, **kwargs): """Update a Organization Unit. Args: customer_id: string The ID of the Google Apps customer. org_unit_path: string The organization's full path name. [Note: Each element of the path MUST be URL encoded (example: finance%2Forganization/suborganization)] org_unit_entry: gdata.apps.organization.data.OrgUnitEntry The updated organization unit entry. Returns: A gdata.apps.organization.data.OrgUnitEntry representing an organization unit. """ if not org_unit_entry.GetParentOrgUnitPath(): org_unit_entry.SetParentOrgUnitPath('/') return self.update(org_unit_entry, uri=self.MakeOrganizationUnitOrgunitProvisioningUri( customer_id, org_unit_path=org_unit_path), **kwargs)
[ "def", "update_org_unit", "(", "self", ",", "customer_id", ",", "org_unit_path", ",", "org_unit_entry", ",", "*", "*", "kwargs", ")", ":", "if", "not", "org_unit_entry", ".", "GetParentOrgUnitPath", "(", ")", ":", "org_unit_entry", ".", "SetParentOrgUnitPath", "...
https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/python/lib/python2.7/site-packages/gdata/apps/organization/client.py#L216-L236