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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
pwnieexpress/pwn_plug_sources | 1a23324f5dc2c3de20f9c810269b6a29b2758cad | src/fimap/baseTools.py | python | baseTools.getRandomStr | (self) | return ret | [] | def getRandomStr(self):
chars = string.letters + string.digits
ret = ""
for i in range(8):
if (i==0):
ret = ret + random.choice(string.letters)
else:
ret = ret + random.choice(chars)
return ret | [
"def",
"getRandomStr",
"(",
"self",
")",
":",
"chars",
"=",
"string",
".",
"letters",
"+",
"string",
".",
"digits",
"ret",
"=",
"\"\"",
"for",
"i",
"in",
"range",
"(",
"8",
")",
":",
"if",
"(",
"i",
"==",
"0",
")",
":",
"ret",
"=",
"ret",
"+",
... | https://github.com/pwnieexpress/pwn_plug_sources/blob/1a23324f5dc2c3de20f9c810269b6a29b2758cad/src/fimap/baseTools.py#L34-L42 | |||
edgewall/trac | beb3e4eaf1e0a456d801a50a8614ecab06de29fc | trac/mimeview/api.py | python | IContentConverter.get_supported_conversions | () | Return an iterable of tuples in the form (key, name, extension,
in_mimetype, out_mimetype, quality) representing the MIME conversions
supported and
the quality ratio of the conversion in the range 0 to 9, where 0 means
no support and 9 means "perfect" support. eg. ('latex', 'LaTeX', 'tex',
'text/x-trac-wiki', 'text/plain', 8) | Return an iterable of tuples in the form (key, name, extension,
in_mimetype, out_mimetype, quality) representing the MIME conversions
supported and
the quality ratio of the conversion in the range 0 to 9, where 0 means
no support and 9 means "perfect" support. eg. ('latex', 'LaTeX', 'tex',
'text/x-trac-wiki', 'text/plain', 8) | [
"Return",
"an",
"iterable",
"of",
"tuples",
"in",
"the",
"form",
"(",
"key",
"name",
"extension",
"in_mimetype",
"out_mimetype",
"quality",
")",
"representing",
"the",
"MIME",
"conversions",
"supported",
"and",
"the",
"quality",
"ratio",
"of",
"the",
"conversion... | def get_supported_conversions():
"""Return an iterable of tuples in the form (key, name, extension,
in_mimetype, out_mimetype, quality) representing the MIME conversions
supported and
the quality ratio of the conversion in the range 0 to 9, where 0 means
no support and 9 means "perfect" support. eg. ('latex', 'LaTeX', 'tex',
'text/x-trac-wiki', 'text/plain', 8)""" | [
"def",
"get_supported_conversions",
"(",
")",
":"
] | https://github.com/edgewall/trac/blob/beb3e4eaf1e0a456d801a50a8614ecab06de29fc/trac/mimeview/api.py#L582-L588 | ||
CGATOxford/cgat | 326aad4694bdfae8ddc194171bb5d73911243947 | CGAT/CBioPortal.py | python | CBioPortal.getMutationData | (self, gene_list, genetic_profile_id, case_set_id=None,
study=None, study_name=None) | return mutation_data | For data of type EXTENDED_MUTATION, you can request the full set of
annotated extended mutation data.
This enables you to, for example, determine which sequencing
center sequenced the mutation, the amino acid change that
results from the mutation, or gather links to predicted
functional consequences of the mutation.
Query Format
case_set_id= [case set ID] (required)
genetic_profile_id= [a single genetic profile IDs] (required).
gene_list= [one or more genes, specified as HUGO Gene Symbols or
Entrez Gene IDs](required)
Response Format
A list of dictionaries with the following entires
entrez_gene_id: Entrez Gene ID.
gene_symbol: HUGO Gene Symbol.
case_id: Case ID.
sequencing_center: Sequencer Center responsible for identifying
this mutation.
For example: broad.mit.edu.
mutation_status: somatic or germline mutation status. all mutations
returned will be of type somatic.
mutation_type: mutation type, such as nonsense, missense, or frameshift_ins.
validation_status: validation status. Usually valid, invalid, or unknown.
amino_acid_change: amino acid change resulting from the mutation.
functional_impact_score: predicted functional impact score,
as predicted by: Mutation Assessor.
xvar_link: Link to the Mutation Assessor web site.
xvar_link_pdb: Link to the Protein Data Bank (PDB) View within
Mutation Assessor web site.
xvar_link_msa: Link the Multiple Sequence Alignment (MSA) view
within the Mutation Assessor web site.
chr: chromosome where mutation occurs.
start_position: start position of mutation.
end_position: end position of mutation.
If a default study is set then a check will be performed to
set if the supplied case id is from the specified study. The
study can be over written using the study and study_name
parameters | For data of type EXTENDED_MUTATION, you can request the full set of
annotated extended mutation data. | [
"For",
"data",
"of",
"type",
"EXTENDED_MUTATION",
"you",
"can",
"request",
"the",
"full",
"set",
"of",
"annotated",
"extended",
"mutation",
"data",
"."
] | def getMutationData(self, gene_list, genetic_profile_id, case_set_id=None,
study=None, study_name=None):
'''For data of type EXTENDED_MUTATION, you can request the full set of
annotated extended mutation data.
This enables you to, for example, determine which sequencing
center sequenced the mutation, the amino acid change that
results from the mutation, or gather links to predicted
functional consequences of the mutation.
Query Format
case_set_id= [case set ID] (required)
genetic_profile_id= [a single genetic profile IDs] (required).
gene_list= [one or more genes, specified as HUGO Gene Symbols or
Entrez Gene IDs](required)
Response Format
A list of dictionaries with the following entires
entrez_gene_id: Entrez Gene ID.
gene_symbol: HUGO Gene Symbol.
case_id: Case ID.
sequencing_center: Sequencer Center responsible for identifying
this mutation.
For example: broad.mit.edu.
mutation_status: somatic or germline mutation status. all mutations
returned will be of type somatic.
mutation_type: mutation type, such as nonsense, missense, or frameshift_ins.
validation_status: validation status. Usually valid, invalid, or unknown.
amino_acid_change: amino acid change resulting from the mutation.
functional_impact_score: predicted functional impact score,
as predicted by: Mutation Assessor.
xvar_link: Link to the Mutation Assessor web site.
xvar_link_pdb: Link to the Protein Data Bank (PDB) View within
Mutation Assessor web site.
xvar_link_msa: Link the Multiple Sequence Alignment (MSA) view
within the Mutation Assessor web site.
chr: chromosome where mutation occurs.
start_position: start position of mutation.
end_position: end position of mutation.
If a default study is set then a check will be performed to
set if the supplied case id is from the specified study. The
study can be over written using the study and study_name
parameters
'''
study_id = self._getStudyId(study, study_name)
case_set_id = self._getCaseListId(case_set_id, study_id)
if study_id:
if not study_id == self.study:
profiles = getGeneticProfiles(study_id)
else:
profiles = self.profiles
if genetic_profile_id not in proiles:
raise ValueError(
"%s not a valid genetic profile for study %s" %
(genetic_profile_id, gene_id))
genetic_profile_id = ",".join(genetic_profile_id)
gene_list = ",".join(gene_list)
mutation_data = self._executeQuery(
command="getMutationData",
args=dict({"case_set_id": case_set_id,
"genetic_profile_id": genetic_profile_id,
"gene_list": gene_list}))
return mutation_data | [
"def",
"getMutationData",
"(",
"self",
",",
"gene_list",
",",
"genetic_profile_id",
",",
"case_set_id",
"=",
"None",
",",
"study",
"=",
"None",
",",
"study_name",
"=",
"None",
")",
":",
"study_id",
"=",
"self",
".",
"_getStudyId",
"(",
"study",
",",
"study... | https://github.com/CGATOxford/cgat/blob/326aad4694bdfae8ddc194171bb5d73911243947/CGAT/CBioPortal.py#L362-L435 | |
GoogleCloudPlatform/PerfKitBenchmarker | 6e3412d7d5e414b8ca30ed5eaf970cef1d919a67 | perfkitbenchmarker/linux_packages/multichase.py | python | AptInstall | (vm) | Installs the multichase package on the VM. | Installs the multichase package on the VM. | [
"Installs",
"the",
"multichase",
"package",
"on",
"the",
"VM",
"."
] | def AptInstall(vm):
"""Installs the multichase package on the VM."""
_Install(vm) | [
"def",
"AptInstall",
"(",
"vm",
")",
":",
"_Install",
"(",
"vm",
")"
] | https://github.com/GoogleCloudPlatform/PerfKitBenchmarker/blob/6e3412d7d5e414b8ca30ed5eaf970cef1d919a67/perfkitbenchmarker/linux_packages/multichase.py#L40-L42 | ||
HaoZhang95/Python24 | b897224b8a0e6a5734f408df8c24846a98c553bf | 00Python/venv/Lib/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/urllib3/util/url.py | python | parse_url | (url) | return Url(scheme, auth, host, port, path, query, fragment) | Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is
performed to parse incomplete urls. Fields not provided will be None.
Partly backwards-compatible with :mod:`urlparse`.
Example::
>>> parse_url('http://google.com/mail/')
Url(scheme='http', host='google.com', port=None, path='/mail/', ...)
>>> parse_url('google.com:80')
Url(scheme=None, host='google.com', port=80, path=None, ...)
>>> parse_url('/foo?bar')
Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...) | Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is
performed to parse incomplete urls. Fields not provided will be None. | [
"Given",
"a",
"url",
"return",
"a",
"parsed",
":",
"class",
":",
".",
"Url",
"namedtuple",
".",
"Best",
"-",
"effort",
"is",
"performed",
"to",
"parse",
"incomplete",
"urls",
".",
"Fields",
"not",
"provided",
"will",
"be",
"None",
"."
] | def parse_url(url):
"""
Given a url, return a parsed :class:`.Url` namedtuple. Best-effort is
performed to parse incomplete urls. Fields not provided will be None.
Partly backwards-compatible with :mod:`urlparse`.
Example::
>>> parse_url('http://google.com/mail/')
Url(scheme='http', host='google.com', port=None, path='/mail/', ...)
>>> parse_url('google.com:80')
Url(scheme=None, host='google.com', port=80, path=None, ...)
>>> parse_url('/foo?bar')
Url(scheme=None, host=None, port=None, path='/foo', query='bar', ...)
"""
# While this code has overlap with stdlib's urlparse, it is much
# simplified for our needs and less annoying.
# Additionally, this implementations does silly things to be optimal
# on CPython.
if not url:
# Empty
return Url()
scheme = None
auth = None
host = None
port = None
path = None
fragment = None
query = None
# Scheme
if '://' in url:
scheme, url = url.split('://', 1)
# Find the earliest Authority Terminator
# (http://tools.ietf.org/html/rfc3986#section-3.2)
url, path_, delim = split_first(url, ['/', '?', '#'])
if delim:
# Reassemble the path
path = delim + path_
# Auth
if '@' in url:
# Last '@' denotes end of auth part
auth, url = url.rsplit('@', 1)
# IPv6
if url and url[0] == '[':
host, url = url.split(']', 1)
host += ']'
# Port
if ':' in url:
_host, port = url.split(':', 1)
if not host:
host = _host
if port:
# If given, ports must be integers. No whitespace, no plus or
# minus prefixes, no non-integer digits such as ^2 (superscript).
if not port.isdigit():
raise LocationParseError(url)
try:
port = int(port)
except ValueError:
raise LocationParseError(url)
else:
# Blank ports are cool, too. (rfc3986#section-3.2.3)
port = None
elif not host and url:
host = url
if not path:
return Url(scheme, auth, host, port, path, query, fragment)
# Fragment
if '#' in path:
path, fragment = path.split('#', 1)
# Query
if '?' in path:
path, query = path.split('?', 1)
return Url(scheme, auth, host, port, path, query, fragment) | [
"def",
"parse_url",
"(",
"url",
")",
":",
"# While this code has overlap with stdlib's urlparse, it is much",
"# simplified for our needs and less annoying.",
"# Additionally, this implementations does silly things to be optimal",
"# on CPython.",
"if",
"not",
"url",
":",
"# Empty",
"r... | https://github.com/HaoZhang95/Python24/blob/b897224b8a0e6a5734f408df8c24846a98c553bf/00Python/venv/Lib/site-packages/pip-10.0.1-py3.7.egg/pip/_vendor/urllib3/util/url.py#L132-L222 | |
fhamborg/news-please | 3c2562470601f060828e9d0ad05ebdbb5907641f | newsplease/pipeline/extractor/comparer/comparer_title.py | python | ComparerTitle.extract | (self, item, list_article_candidate) | Compares the extracted titles.
:param item: The corresponding NewscrawlerItem
:param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted
:return: A string, the most likely title | Compares the extracted titles. | [
"Compares",
"the",
"extracted",
"titles",
"."
] | def extract(self, item, list_article_candidate):
"""Compares the extracted titles.
:param item: The corresponding NewscrawlerItem
:param list_article_candidate: A list, the list of ArticleCandidate-Objects which have been extracted
:return: A string, the most likely title
"""
list_title = []
# Save every title from the candidates in list_title.
for article_candidate in list_article_candidate:
if article_candidate.title is not None:
list_title.append(article_candidate.title)
if not list_title:
return None
# Creates a list with matched titles
list_title_matches = self.find_matches(list_title)
# Extract title with the most matches
matched_title = self.extract_match(list_title_matches)
# Returns the matched title if there is one, else returns the shortest title
if matched_title:
return matched_title
else:
if list_title_matches:
return self.choose_shortest_title(set(list_title_matches))
else:
return self.choose_shortest_title(list_title) | [
"def",
"extract",
"(",
"self",
",",
"item",
",",
"list_article_candidate",
")",
":",
"list_title",
"=",
"[",
"]",
"# Save every title from the candidates in list_title.",
"for",
"article_candidate",
"in",
"list_article_candidate",
":",
"if",
"article_candidate",
".",
"t... | https://github.com/fhamborg/news-please/blob/3c2562470601f060828e9d0ad05ebdbb5907641f/newsplease/pipeline/extractor/comparer/comparer_title.py#L53-L82 | ||
calliope-project/calliope | 9d588fa98ec8eb11065ebb43bcc90d07657b0d43 | calliope/backend/pyomo/constraints/milp.py | python | unit_capacity_systemwide_milp_constraint_rule | (backend_model, tech) | Set constraints to limit the number of purchased units of a single technology
type across all locations in the model.
The first valid case is applied:
.. container:: scrolling-wrapper
.. math::
\\sum_{loc}\\boldsymbol{units}(loc::tech) + \\boldsymbol{purchased}(loc::tech)
\\begin{cases}
= units_{equals, systemwide}(tech),&
\\text{if } units_{equals, systemwide}(tech)\\\\
\\leq units_{max, systemwide}(tech),&
\\text{if } units_{max, systemwide}(tech)\\\\
\\text{unconstrained},& \\text{otherwise}
\\end{cases}
\\forall tech \\in techs | Set constraints to limit the number of purchased units of a single technology
type across all locations in the model. | [
"Set",
"constraints",
"to",
"limit",
"the",
"number",
"of",
"purchased",
"units",
"of",
"a",
"single",
"technology",
"type",
"across",
"all",
"locations",
"in",
"the",
"model",
"."
] | def unit_capacity_systemwide_milp_constraint_rule(backend_model, tech):
"""
Set constraints to limit the number of purchased units of a single technology
type across all locations in the model.
The first valid case is applied:
.. container:: scrolling-wrapper
.. math::
\\sum_{loc}\\boldsymbol{units}(loc::tech) + \\boldsymbol{purchased}(loc::tech)
\\begin{cases}
= units_{equals, systemwide}(tech),&
\\text{if } units_{equals, systemwide}(tech)\\\\
\\leq units_{max, systemwide}(tech),&
\\text{if } units_{max, systemwide}(tech)\\\\
\\text{unconstrained},& \\text{otherwise}
\\end{cases}
\\forall tech \\in techs
"""
max_systemwide = get_param(backend_model, "units_max_systemwide", tech)
equals_systemwide = get_param(backend_model, "units_equals_systemwide", tech)
def _sum(var_name):
if hasattr(backend_model, var_name):
return po.quicksum(
getattr(backend_model, var_name)[node, tech]
for node in backend_model.nodes
if [node, tech] in getattr(backend_model, var_name)._index
)
else:
return 0
sum_expr_units = _sum("units")
sum_expr_purchase = _sum("purchased")
if equals_systemwide:
return sum_expr_units + sum_expr_purchase == equals_systemwide
else:
return sum_expr_units + sum_expr_purchase <= max_systemwide | [
"def",
"unit_capacity_systemwide_milp_constraint_rule",
"(",
"backend_model",
",",
"tech",
")",
":",
"max_systemwide",
"=",
"get_param",
"(",
"backend_model",
",",
"\"units_max_systemwide\"",
",",
"tech",
")",
"equals_systemwide",
"=",
"get_param",
"(",
"backend_model",
... | https://github.com/calliope-project/calliope/blob/9d588fa98ec8eb11065ebb43bcc90d07657b0d43/calliope/backend/pyomo/constraints/milp.py#L362-L404 | ||
leancloud/satori | 701caccbd4fe45765001ca60435c0cb499477c03 | satori-rules/plugin/libs/gevent/subprocess.py | python | Popen.communicate | (self, input=None, timeout=None) | return (None if stdout is None else stdout_value or b'',
None if stderr is None else stderr_value or b'') | Interact with process: Send data to stdin. Read data from
stdout and stderr, until end-of-file is reached. Wait for
process to terminate. The optional input argument should be a
string to be sent to the child process, or None, if no data
should be sent to the child.
communicate() returns a tuple (stdout, stderr).
:keyword timeout: Under Python 2, this is a gevent extension; if
given and it expires, we will raise :class:`gevent.timeout.Timeout`.
Under Python 3, this raises the standard :exc:`TimeoutExpired` exception.
.. versionchanged:: 1.1a2
Under Python 2, if the *timeout* elapses, raise the :exc:`gevent.timeout.Timeout`
exception. Previously, we silently returned.
.. versionchanged:: 1.1b5
Honor a *timeout* even if there's no way to communicate with the child
(stdin, stdout, and stderr are not pipes). | Interact with process: Send data to stdin. Read data from
stdout and stderr, until end-of-file is reached. Wait for
process to terminate. The optional input argument should be a
string to be sent to the child process, or None, if no data
should be sent to the child. | [
"Interact",
"with",
"process",
":",
"Send",
"data",
"to",
"stdin",
".",
"Read",
"data",
"from",
"stdout",
"and",
"stderr",
"until",
"end",
"-",
"of",
"-",
"file",
"is",
"reached",
".",
"Wait",
"for",
"process",
"to",
"terminate",
".",
"The",
"optional",
... | def communicate(self, input=None, timeout=None):
"""Interact with process: Send data to stdin. Read data from
stdout and stderr, until end-of-file is reached. Wait for
process to terminate. The optional input argument should be a
string to be sent to the child process, or None, if no data
should be sent to the child.
communicate() returns a tuple (stdout, stderr).
:keyword timeout: Under Python 2, this is a gevent extension; if
given and it expires, we will raise :class:`gevent.timeout.Timeout`.
Under Python 3, this raises the standard :exc:`TimeoutExpired` exception.
.. versionchanged:: 1.1a2
Under Python 2, if the *timeout* elapses, raise the :exc:`gevent.timeout.Timeout`
exception. Previously, we silently returned.
.. versionchanged:: 1.1b5
Honor a *timeout* even if there's no way to communicate with the child
(stdin, stdout, and stderr are not pipes).
"""
greenlets = []
if self.stdin:
greenlets.append(spawn(write_and_close, self.stdin, input))
# If the timeout parameter is used, and the caller calls back after
# getting a TimeoutExpired exception, we can wind up with multiple
# greenlets trying to run and read from and close stdout/stderr.
# That's bad because it can lead to 'RuntimeError: reentrant call in io.BufferedReader'.
# We can't just kill the previous greenlets when a timeout happens,
# though, because we risk losing the output collected by that greenlet
# (and Python 3, where timeout is an official parameter, explicitly says
# that no output should be lost in the event of a timeout.) Instead, we're
# watching for the exception and ignoring it. It's not elegant,
# but it works
if self.stdout:
def _read_out():
try:
data = self.stdout.read()
except RuntimeError:
return
if self._stdout_buffer is not None:
self._stdout_buffer += data
else:
self._stdout_buffer = data
stdout = spawn(_read_out)
greenlets.append(stdout)
else:
stdout = None
if self.stderr:
def _read_err():
try:
data = self.stderr.read()
except RuntimeError:
return
if self._stderr_buffer is not None:
self._stderr_buffer += data
else:
self._stderr_buffer = data
stderr = spawn(_read_err)
greenlets.append(stderr)
else:
stderr = None
# If we were given stdin=stdout=stderr=None, we have no way to
# communicate with the child, and thus no greenlets to wait
# on. This is a nonsense case, but it comes up in the test
# case for Python 3.5 (test_subprocess.py
# RunFuncTestCase.test_timeout). Instead, we go directly to
# self.wait
if not greenlets and timeout is not None:
result = self.wait(timeout=timeout)
# Python 3 would have already raised, but Python 2 would not
# so we need to do that manually
if result is None:
from gevent.timeout import Timeout
raise Timeout(timeout)
done = joinall(greenlets, timeout=timeout)
if timeout is not None and len(done) != len(greenlets):
if PY3:
raise TimeoutExpired(self.args, timeout)
from gevent.timeout import Timeout
raise Timeout(timeout)
if self.stdout:
try:
self.stdout.close()
except RuntimeError:
pass
if self.stderr:
try:
self.stderr.close()
except RuntimeError:
pass
self.wait()
stdout_value = self._stdout_buffer
self._stdout_buffer = None
stderr_value = self._stderr_buffer
self._stderr_buffer = None
# XXX: Under python 3 in universal newlines mode we should be
# returning str, not bytes
return (None if stdout is None else stdout_value or b'',
None if stderr is None else stderr_value or b'') | [
"def",
"communicate",
"(",
"self",
",",
"input",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"greenlets",
"=",
"[",
"]",
"if",
"self",
".",
"stdin",
":",
"greenlets",
".",
"append",
"(",
"spawn",
"(",
"write_and_close",
",",
"self",
".",
"std... | https://github.com/leancloud/satori/blob/701caccbd4fe45765001ca60435c0cb499477c03/satori-rules/plugin/libs/gevent/subprocess.py#L559-L662 | |
arizvisa/ida-minsc | 8627a60f047b5e55d3efeecde332039cd1a16eea | custom/tags.py | python | export.__new__ | (cls, *tags, **location) | return cls.everything(*tags, **location) | Read the specified tags within the database using the cache. | Read the specified tags within the database using the cache. | [
"Read",
"the",
"specified",
"tags",
"within",
"the",
"database",
"using",
"the",
"cache",
"."
] | def __new__(cls, *tags, **location):
'''Read the specified tags within the database using the cache.'''
return cls.everything(*tags, **location) | [
"def",
"__new__",
"(",
"cls",
",",
"*",
"tags",
",",
"*",
"*",
"location",
")",
":",
"return",
"cls",
".",
"everything",
"(",
"*",
"tags",
",",
"*",
"*",
"location",
")"
] | https://github.com/arizvisa/ida-minsc/blob/8627a60f047b5e55d3efeecde332039cd1a16eea/custom/tags.py#L535-L537 | |
mechboxes/mech | 2f74584670715e5c67442dd057ca10709f7e6712 | mech/vmrun.py | python | VMrun.start | (self, gui=False, quiet=False) | return self.vmrun('start', self.vmx_file, 'gui' if gui else 'nogui', quiet=quiet) | Start a VM or Team | Start a VM or Team | [
"Start",
"a",
"VM",
"or",
"Team"
] | def start(self, gui=False, quiet=False):
'''Start a VM or Team'''
return self.vmrun('start', self.vmx_file, 'gui' if gui else 'nogui', quiet=quiet) | [
"def",
"start",
"(",
"self",
",",
"gui",
"=",
"False",
",",
"quiet",
"=",
"False",
")",
":",
"return",
"self",
".",
"vmrun",
"(",
"'start'",
",",
"self",
".",
"vmx_file",
",",
"'gui'",
"if",
"gui",
"else",
"'nogui'",
",",
"quiet",
"=",
"quiet",
")"... | https://github.com/mechboxes/mech/blob/2f74584670715e5c67442dd057ca10709f7e6712/mech/vmrun.py#L174-L176 | |
pymedusa/Medusa | 1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38 | ext/oauthlib/oauth2/rfc6749/request_validator.py | python | RequestValidator.validate_client_id | (self, client_id, request, *args, **kwargs) | Ensure client_id belong to a valid and active client.
Note, while not strictly necessary it can often be very convenient
to set request.client to the client object associated with the
given client_id.
:param client_id: Unicode client identifier.
:param request: OAuthlib request.
:type request: oauthlib.common.Request
:rtype: True or False
Method is used by:
- Authorization Code Grant
- Implicit Grant | Ensure client_id belong to a valid and active client. | [
"Ensure",
"client_id",
"belong",
"to",
"a",
"valid",
"and",
"active",
"client",
"."
] | def validate_client_id(self, client_id, request, *args, **kwargs):
"""Ensure client_id belong to a valid and active client.
Note, while not strictly necessary it can often be very convenient
to set request.client to the client object associated with the
given client_id.
:param client_id: Unicode client identifier.
:param request: OAuthlib request.
:type request: oauthlib.common.Request
:rtype: True or False
Method is used by:
- Authorization Code Grant
- Implicit Grant
"""
raise NotImplementedError('Subclasses must implement this method.') | [
"def",
"validate_client_id",
"(",
"self",
",",
"client_id",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError",
"(",
"'Subclasses must implement this method.'",
")"
] | https://github.com/pymedusa/Medusa/blob/1405fbb6eb8ef4d20fcca24c32ddca52b11f0f38/ext/oauthlib/oauth2/rfc6749/request_validator.py#L536-L552 | ||
InQuest/omnibus | 88dbf5d02f87eaa79a1cfc13d403cf854ee44c40 | lib/modules/dnsresolve.py | python | Plugin.run | (self) | [] | def run(self):
domain = self.artifact['name']
self.artifact['data']['dnsresolve'] = {
'A': 'Not Found',
'AAAA': 'Not Found',
'CNAME': 'Not Found',
'NS': 'Not Found',
'MX': 'Not Found',
'TXT': 'Not Found'
}
for key in self.artifact['data']['dnsresolve'].keys():
self.artifact['data']['dnsresolve'][key] = self.get_record(domain, key)
# self.artifact['data']['dnsresolve']['A'] = self.get_record(domain, 'A')
# self.artifact['data']['dnsresolve']['AAAA'] = self.get_record(domain, 'AAAA')
# self.artifact['data']['dnsresolve']['CNAME'] = self.get_record(domain, 'CNAME')
# self.artifact['data']['dnsresolve']['NS'] = self.get_record(domain, 'NS')
# self.artifact['data']['dnsresolve']['MX'] = self.get_record(domain, 'MX')
# self.artifact['data']['dnsresolve']['TXT'] = self.get_record(domain, 'TXT')
for host in self.artifact['data']['dnsresolve']:
if isinstance(host, str):
if detect_type(host) == 'host':
entry = {
'name': host,
'type': 'host',
'source': 'DNS resolution',
'subtype': None
}
self.artifact['children'].append(entry)
elif isinstance(host, list):
for h in host:
if detect_type(h) == 'host':
entry = {
'name': h,
'type': 'host',
'source': 'DNS resolution',
'subtype': None
}
self.artifact['children'].append(entry) | [
"def",
"run",
"(",
"self",
")",
":",
"domain",
"=",
"self",
".",
"artifact",
"[",
"'name'",
"]",
"self",
".",
"artifact",
"[",
"'data'",
"]",
"[",
"'dnsresolve'",
"]",
"=",
"{",
"'A'",
":",
"'Not Found'",
",",
"'AAAA'",
":",
"'Not Found'",
",",
"'CNA... | https://github.com/InQuest/omnibus/blob/88dbf5d02f87eaa79a1cfc13d403cf854ee44c40/lib/modules/dnsresolve.py#L36-L78 | ||||
grantjenks/python-diskcache | 1cb1425b1ba24f26fb1e37349c4c2658c2a46d8f | diskcache/core.py | python | Cache.pull | (
self,
prefix=None,
default=(None, None),
side='front',
expire_time=False,
tag=False,
retry=False,
) | Pull key and value item pair from `side` of queue in cache.
When prefix is None, integer keys are used. Otherwise, string keys are
used in the format "prefix-integer". Integer starts at 500 trillion.
If queue is empty, return default.
Defaults to pulling key and value item pairs from front of queue. Set
side to 'back' to pull from back of queue. Side must be one of 'front'
or 'back'.
Operation is atomic. Concurrent operations will be serialized.
Raises :exc:`Timeout` error when database timeout occurs and `retry` is
`False` (default).
See also `Cache.push` and `Cache.get`.
>>> cache = Cache()
>>> cache.pull()
(None, None)
>>> for letter in 'abc':
... print(cache.push(letter))
500000000000000
500000000000001
500000000000002
>>> key, value = cache.pull()
>>> print(key)
500000000000000
>>> value
'a'
>>> _, value = cache.pull(side='back')
>>> value
'c'
>>> cache.push(1234, 'userids')
'userids-500000000000000'
>>> _, value = cache.pull('userids')
>>> value
1234
:param str prefix: key prefix (default None, key is integer)
:param default: value to return if key is missing
(default (None, None))
:param str side: either 'front' or 'back' (default 'front')
:param bool expire_time: if True, return expire_time in tuple
(default False)
:param bool tag: if True, return tag in tuple (default False)
:param bool retry: retry if database timeout occurs (default False)
:return: key and value item pair or default if queue is empty
:raises Timeout: if database timeout occurs | Pull key and value item pair from `side` of queue in cache. | [
"Pull",
"key",
"and",
"value",
"item",
"pair",
"from",
"side",
"of",
"queue",
"in",
"cache",
"."
] | def pull(
self,
prefix=None,
default=(None, None),
side='front',
expire_time=False,
tag=False,
retry=False,
):
"""Pull key and value item pair from `side` of queue in cache.
When prefix is None, integer keys are used. Otherwise, string keys are
used in the format "prefix-integer". Integer starts at 500 trillion.
If queue is empty, return default.
Defaults to pulling key and value item pairs from front of queue. Set
side to 'back' to pull from back of queue. Side must be one of 'front'
or 'back'.
Operation is atomic. Concurrent operations will be serialized.
Raises :exc:`Timeout` error when database timeout occurs and `retry` is
`False` (default).
See also `Cache.push` and `Cache.get`.
>>> cache = Cache()
>>> cache.pull()
(None, None)
>>> for letter in 'abc':
... print(cache.push(letter))
500000000000000
500000000000001
500000000000002
>>> key, value = cache.pull()
>>> print(key)
500000000000000
>>> value
'a'
>>> _, value = cache.pull(side='back')
>>> value
'c'
>>> cache.push(1234, 'userids')
'userids-500000000000000'
>>> _, value = cache.pull('userids')
>>> value
1234
:param str prefix: key prefix (default None, key is integer)
:param default: value to return if key is missing
(default (None, None))
:param str side: either 'front' or 'back' (default 'front')
:param bool expire_time: if True, return expire_time in tuple
(default False)
:param bool tag: if True, return tag in tuple (default False)
:param bool retry: retry if database timeout occurs (default False)
:return: key and value item pair or default if queue is empty
:raises Timeout: if database timeout occurs
"""
# Caution: Nearly identical code exists in Cache.peek
if prefix is None:
min_key = 0
max_key = 999999999999999
else:
min_key = prefix + '-000000000000000'
max_key = prefix + '-999999999999999'
order = {'front': 'ASC', 'back': 'DESC'}
select = (
'SELECT rowid, key, expire_time, tag, mode, filename, value'
' FROM Cache WHERE ? < key AND key < ? AND raw = 1'
' ORDER BY key %s LIMIT 1'
) % order[side]
if expire_time and tag:
default = default, None, None
elif expire_time or tag:
default = default, None
while True:
while True:
with self._transact(retry) as (sql, cleanup):
rows = sql(select, (min_key, max_key)).fetchall()
if not rows:
return default
(
(rowid, key, db_expire, db_tag, mode, name, db_value),
) = rows
sql('DELETE FROM Cache WHERE rowid = ?', (rowid,))
if db_expire is not None and db_expire < time.time():
cleanup(name)
else:
break
try:
value = self._disk.fetch(mode, name, db_value, False)
except IOError:
# Key was deleted before we could retrieve result.
continue
finally:
if name is not None:
self._disk.remove(name)
break
if expire_time and tag:
return (key, value), db_expire, db_tag
elif expire_time:
return (key, value), db_expire
elif tag:
return (key, value), db_tag
else:
return key, value | [
"def",
"pull",
"(",
"self",
",",
"prefix",
"=",
"None",
",",
"default",
"=",
"(",
"None",
",",
"None",
")",
",",
"side",
"=",
"'front'",
",",
"expire_time",
"=",
"False",
",",
"tag",
"=",
"False",
",",
"retry",
"=",
"False",
",",
")",
":",
"# Cau... | https://github.com/grantjenks/python-diskcache/blob/1cb1425b1ba24f26fb1e37349c4c2658c2a46d8f/diskcache/core.py#L1486-L1603 | ||
AppScale/gts | 46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9 | AppServer/lib/webob-1.2.3/webob/request.py | python | BaseRequest._urlargs__get | (self) | Return any *positional* variables matched in the URL.
Takes values from ``environ['wsgiorg.routing_args']``.
Systems like ``routes`` set this value. | Return any *positional* variables matched in the URL. | [
"Return",
"any",
"*",
"positional",
"*",
"variables",
"matched",
"in",
"the",
"URL",
"."
] | def _urlargs__get(self):
"""
Return any *positional* variables matched in the URL.
Takes values from ``environ['wsgiorg.routing_args']``.
Systems like ``routes`` set this value.
"""
if 'wsgiorg.routing_args' in self.environ:
return self.environ['wsgiorg.routing_args'][0]
else:
# Since you can't update this value in-place, we don't need
# to set the key in the environment
return () | [
"def",
"_urlargs__get",
"(",
"self",
")",
":",
"if",
"'wsgiorg.routing_args'",
"in",
"self",
".",
"environ",
":",
"return",
"self",
".",
"environ",
"[",
"'wsgiorg.routing_args'",
"]",
"[",
"0",
"]",
"else",
":",
"# Since you can't update this value in-place, we don'... | https://github.com/AppScale/gts/blob/46f909cf5dc5ba81faf9d81dc9af598dcf8a82a9/AppServer/lib/webob-1.2.3/webob/request.py#L609-L621 | ||
oaubert/python-vlc | 908ffdbd0844dc1849728c456e147788798c99da | generated/2.2/vlc.py | python | Media.save_meta | (self) | return libvlc_media_save_meta(self) | Save the meta previously set.
@return: true if the write operation was successful. | Save the meta previously set. | [
"Save",
"the",
"meta",
"previously",
"set",
"."
] | def save_meta(self):
'''Save the meta previously set.
@return: true if the write operation was successful.
'''
return libvlc_media_save_meta(self) | [
"def",
"save_meta",
"(",
"self",
")",
":",
"return",
"libvlc_media_save_meta",
"(",
"self",
")"
] | https://github.com/oaubert/python-vlc/blob/908ffdbd0844dc1849728c456e147788798c99da/generated/2.2/vlc.py#L2184-L2188 | |
KalleHallden/AutoTimer | 2d954216700c4930baa154e28dbddc34609af7ce | env/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py | python | WorkingSet.add_entry | (self, entry) | Add a path item to ``.entries``, finding any distributions on it
``find_distributions(entry, True)`` is used to find distributions
corresponding to the path entry, and they are added. `entry` is
always appended to ``.entries``, even if it is already present.
(This is because ``sys.path`` can contain the same value more than
once, and the ``.entries`` of the ``sys.path`` WorkingSet should always
equal ``sys.path``.) | Add a path item to ``.entries``, finding any distributions on it | [
"Add",
"a",
"path",
"item",
"to",
".",
"entries",
"finding",
"any",
"distributions",
"on",
"it"
] | def add_entry(self, entry):
"""Add a path item to ``.entries``, finding any distributions on it
``find_distributions(entry, True)`` is used to find distributions
corresponding to the path entry, and they are added. `entry` is
always appended to ``.entries``, even if it is already present.
(This is because ``sys.path`` can contain the same value more than
once, and the ``.entries`` of the ``sys.path`` WorkingSet should always
equal ``sys.path``.)
"""
self.entry_keys.setdefault(entry, [])
self.entries.append(entry)
for dist in find_distributions(entry, True):
self.add(dist, entry, False) | [
"def",
"add_entry",
"(",
"self",
",",
"entry",
")",
":",
"self",
".",
"entry_keys",
".",
"setdefault",
"(",
"entry",
",",
"[",
"]",
")",
"self",
".",
"entries",
".",
"append",
"(",
"entry",
")",
"for",
"dist",
"in",
"find_distributions",
"(",
"entry",
... | https://github.com/KalleHallden/AutoTimer/blob/2d954216700c4930baa154e28dbddc34609af7ce/env/lib/python2.7/site-packages/pip/_vendor/pkg_resources/__init__.py#L611-L624 | ||
FSecureLABS/Jandroid | e31d0dab58a2bfd6ed8e0a387172b8bd7c893436 | libs/platform-tools/platform-tools_linux/systrace/catapult/devil/devil/android/device_blacklist.py | python | Blacklist.Reset | (self) | Erases the blacklist file if it exists. | Erases the blacklist file if it exists. | [
"Erases",
"the",
"blacklist",
"file",
"if",
"it",
"exists",
"."
] | def Reset(self):
"""Erases the blacklist file if it exists."""
logger.info('Resetting blacklist %s', self._path)
with self._blacklist_lock:
if os.path.exists(self._path):
os.remove(self._path) | [
"def",
"Reset",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Resetting blacklist %s'",
",",
"self",
".",
"_path",
")",
"with",
"self",
".",
"_blacklist_lock",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_path",
")",
":",
"... | https://github.com/FSecureLABS/Jandroid/blob/e31d0dab58a2bfd6ed8e0a387172b8bd7c893436/libs/platform-tools/platform-tools_linux/systrace/catapult/devil/devil/android/device_blacklist.py#L75-L80 | ||
daoluan/decode-Django | d46a858b45b56de48b0355f50dd9e45402d04cfd | Django-1.5.1/django/views/generic/dates.py | python | DayMixin.get_day_format | (self) | return self.day_format | Get a day format string in strptime syntax to be used to parse the day
from url variables. | Get a day format string in strptime syntax to be used to parse the day
from url variables. | [
"Get",
"a",
"day",
"format",
"string",
"in",
"strptime",
"syntax",
"to",
"be",
"used",
"to",
"parse",
"the",
"day",
"from",
"url",
"variables",
"."
] | def get_day_format(self):
"""
Get a day format string in strptime syntax to be used to parse the day
from url variables.
"""
return self.day_format | [
"def",
"get_day_format",
"(",
"self",
")",
":",
"return",
"self",
".",
"day_format"
] | https://github.com/daoluan/decode-Django/blob/d46a858b45b56de48b0355f50dd9e45402d04cfd/Django-1.5.1/django/views/generic/dates.py#L138-L143 | |
facebookresearch/pytext | 1a4e184b233856fcfb9997d74f167cbf5bbbfb8d | pytext/legacy/data/pipeline.py | python | Pipeline.identity | (x) | return x | Return a copy of the input.
This is here for serialization compatibility with pickle. | Return a copy of the input. | [
"Return",
"a",
"copy",
"of",
"the",
"input",
"."
] | def identity(x):
"""Return a copy of the input.
This is here for serialization compatibility with pickle.
"""
return x | [
"def",
"identity",
"(",
"x",
")",
":",
"return",
"x"
] | https://github.com/facebookresearch/pytext/blob/1a4e184b233856fcfb9997d74f167cbf5bbbfb8d/pytext/legacy/data/pipeline.py#L86-L91 | |
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit /tools/inject/thirdparty/clientform/clientform.py | python | HTMLForm.set_value_by_label | (
self, value,
name=None, type=None, kind=None, id=None, label=None, nr=None) | All arguments should be passed by name. | [] | def set_value_by_label(
self, value,
name=None, type=None, kind=None, id=None, label=None, nr=None):
"""
All arguments should be passed by name.
"""
c = self.find_control(name, type, kind, id, label=label, nr=nr)
c.set_value_by_label(value) | [
"def",
"set_value_by_label",
"(",
"self",
",",
"value",
",",
"name",
"=",
"None",
",",
"type",
"=",
"None",
",",
"kind",
"=",
"None",
",",
"id",
"=",
"None",
",",
"label",
"=",
"None",
",",
"nr",
"=",
"None",
")",
":",
"c",
"=",
"self",
".",
"f... | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /tools/inject/thirdparty/clientform/clientform.py#L2962-L2971 | |||
chen3feng/blade-build | 360b4c9ddb9087fb811af3aef2830301cf48805e | src/blade/cc_targets.py | python | ForeignCcLibrary._library_full_path | (self, type) | return self._target_file_path(os.path.join(self.attr['install_dir'], self.attr['lib_dir'],
'lib%s.%s' % (self.name, type))) | Return full path of the library file with specified type | Return full path of the library file with specified type | [
"Return",
"full",
"path",
"of",
"the",
"library",
"file",
"with",
"specified",
"type"
] | def _library_full_path(self, type):
"""Return full path of the library file with specified type"""
assert type in ('a', 'so')
return self._target_file_path(os.path.join(self.attr['install_dir'], self.attr['lib_dir'],
'lib%s.%s' % (self.name, type))) | [
"def",
"_library_full_path",
"(",
"self",
",",
"type",
")",
":",
"assert",
"type",
"in",
"(",
"'a'",
",",
"'so'",
")",
"return",
"self",
".",
"_target_file_path",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"attr",
"[",
"'install_dir'",
"]",... | https://github.com/chen3feng/blade-build/blob/360b4c9ddb9087fb811af3aef2830301cf48805e/src/blade/cc_targets.py#L1131-L1135 | |
nsacyber/WALKOFF | 52d3311abe99d64cd2a902eb998c5e398efe0e07 | api_gateway/serverdb/__init__.py | python | initialize_default_resources_workflow_developer | () | Initializes the default resources for a workflow developer | Initializes the default resources for a workflow developer | [
"Initializes",
"the",
"default",
"resources",
"for",
"a",
"workflow",
"developer"
] | def initialize_default_resources_workflow_developer():
"""Initializes the default resources for a workflow developer"""
workflow_developer = Role.query.filter(Role.id == 5).first()
if not workflow_developer:
workflow_developer = Role("workflow_developer", description="Placeholder description",
resources=default_resource_permissions_workflow_developer)
db.session.add(workflow_developer)
else:
workflow_developer.set_resources(default_resource_permissions_workflow_developer)
db.session.commit() | [
"def",
"initialize_default_resources_workflow_developer",
"(",
")",
":",
"workflow_developer",
"=",
"Role",
".",
"query",
".",
"filter",
"(",
"Role",
".",
"id",
"==",
"5",
")",
".",
"first",
"(",
")",
"if",
"not",
"workflow_developer",
":",
"workflow_developer",... | https://github.com/nsacyber/WALKOFF/blob/52d3311abe99d64cd2a902eb998c5e398efe0e07/api_gateway/serverdb/__init__.py#L146-L155 | ||
galaxyproject/galaxy | 4c03520f05062e0f4a1b3655dc0b7452fda69943 | lib/galaxy/job_metrics/instrumenters/env.py | python | EnvPlugin.job_properties | (self, job_id, job_directory) | return properties | Recover environment variables dumped out on compute server and filter
out specific variables if needed. | Recover environment variables dumped out on compute server and filter
out specific variables if needed. | [
"Recover",
"environment",
"variables",
"dumped",
"out",
"on",
"compute",
"server",
"and",
"filter",
"out",
"specific",
"variables",
"if",
"needed",
"."
] | def job_properties(self, job_id, job_directory):
""" Recover environment variables dumped out on compute server and filter
out specific variables if needed.
"""
variables = self.variables
properties = {}
env_string = ''.join(open(self.__env_file(job_directory)).readlines())
while env_string:
# Check if the next lines contain a shell function.
# We use '\n\}\n' as regex termination because shell
# functions can be nested.
# We use the non-greedy '.+?' because of re.DOTALL .
m = re.match(r'([^=]+)=(\(\) \{.+?\n\})\n', env_string, re.DOTALL)
if m is None:
m = re.match('([^=]+)=(.*)\n', env_string)
if m is None:
# Some problem recording or reading back env output.
message_template = "Problem parsing env metric output for job %s - properties will be incomplete"
message = message_template % job_id
log.debug(message)
break
(var, value) = m.groups()
if not variables or var in variables:
properties[var] = value
env_string = env_string[m.end():]
return properties | [
"def",
"job_properties",
"(",
"self",
",",
"job_id",
",",
"job_directory",
")",
":",
"variables",
"=",
"self",
".",
"variables",
"properties",
"=",
"{",
"}",
"env_string",
"=",
"''",
".",
"join",
"(",
"open",
"(",
"self",
".",
"__env_file",
"(",
"job_dir... | https://github.com/galaxyproject/galaxy/blob/4c03520f05062e0f4a1b3655dc0b7452fda69943/lib/galaxy/job_metrics/instrumenters/env.py#L38-L65 | |
erevus-cn/pocscan | 5fef32b1abe22a9f666ad3aacfd1f99d784cb72d | pocscan/plugins/pocsuite/packages/requests/sessions.py | python | Session.request | (self, method, url,
params=None,
data=None,
headers=None,
cookies=None,
files=None,
auth=None,
timeout=None,
allow_redirects=True,
proxies=None,
hooks=None,
stream=None,
verify=None,
cert=None) | return resp | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the query
string for the :class:`Request`.
:param data: (optional) Dictionary or bytes to send in the body of the
:class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the
:class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the
:class:`Request`.
:param files: (optional) Dictionary of 'filename': file-like-objects
for multipart encoding upload.
:param auth: (optional) Auth tuple or callable to enable
Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) Float describing the timeout of the
request in seconds.
:param allow_redirects: (optional) Boolean. Set to True by default.
:param proxies: (optional) Dictionary mapping protocol to the URL of
the proxy.
:param stream: (optional) whether to immediately download the response
content. Defaults to ``False``.
:param verify: (optional) if ``True``, the SSL cert will be verified.
A CA_BUNDLE path can also be provided.
:param cert: (optional) if String, path to ssl client cert file (.pem).
If Tuple, ('cert', 'key') pair. | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object. | [
"Constructs",
"a",
":",
"class",
":",
"Request",
"<Request",
">",
"prepares",
"it",
"and",
"sends",
"it",
".",
"Returns",
":",
"class",
":",
"Response",
"<Response",
">",
"object",
"."
] | def request(self, method, url,
params=None,
data=None,
headers=None,
cookies=None,
files=None,
auth=None,
timeout=None,
allow_redirects=True,
proxies=None,
hooks=None,
stream=None,
verify=None,
cert=None):
"""Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the query
string for the :class:`Request`.
:param data: (optional) Dictionary or bytes to send in the body of the
:class:`Request`.
:param headers: (optional) Dictionary of HTTP Headers to send with the
:class:`Request`.
:param cookies: (optional) Dict or CookieJar object to send with the
:class:`Request`.
:param files: (optional) Dictionary of 'filename': file-like-objects
for multipart encoding upload.
:param auth: (optional) Auth tuple or callable to enable
Basic/Digest/Custom HTTP Auth.
:param timeout: (optional) Float describing the timeout of the
request in seconds.
:param allow_redirects: (optional) Boolean. Set to True by default.
:param proxies: (optional) Dictionary mapping protocol to the URL of
the proxy.
:param stream: (optional) whether to immediately download the response
content. Defaults to ``False``.
:param verify: (optional) if ``True``, the SSL cert will be verified.
A CA_BUNDLE path can also be provided.
:param cert: (optional) if String, path to ssl client cert file (.pem).
If Tuple, ('cert', 'key') pair.
"""
method = builtin_str(method)
# Create the Request.
req = Request(
method = method.upper(),
url = url,
headers = headers,
files = files,
data = data or {},
params = params or {},
auth = auth,
cookies = cookies,
hooks = hooks,
)
prep = self.prepare_request(req)
proxies = proxies or {}
# Gather clues from the surrounding environment.
if self.trust_env:
# Set environment's proxies.
env_proxies = get_environ_proxies(url) or {}
for (k, v) in env_proxies.items():
proxies.setdefault(k, v)
# Look for configuration.
if not verify and verify is not False:
verify = os.environ.get('REQUESTS_CA_BUNDLE')
# Curl compatibility.
if not verify and verify is not False:
verify = os.environ.get('CURL_CA_BUNDLE')
# Merge all the kwargs.
proxies = merge_setting(proxies, self.proxies)
stream = merge_setting(stream, self.stream)
verify = merge_setting(verify, self.verify)
cert = merge_setting(cert, self.cert)
# Send the request.
send_kwargs = {
'stream': stream,
'timeout': timeout,
'verify': verify,
'cert': cert,
'proxies': proxies,
'allow_redirects': allow_redirects,
}
resp = self.send(prep, **send_kwargs)
return resp | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"cookies",
"=",
"None",
",",
"files",
"=",
"None",
",",
"auth",
"=",
"None",
",",
"timeout",
"=",
"N... | https://github.com/erevus-cn/pocscan/blob/5fef32b1abe22a9f666ad3aacfd1f99d784cb72d/pocscan/plugins/pocsuite/packages/requests/sessions.py#L364-L458 | |
Source-Python-Dev-Team/Source.Python | d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb | addons/source-python/packages/site-packages/mutagen/id3/_tags.py | python | ID3Tags.add | (self, frame) | return self.loaded_frame(frame) | Add a frame to the tag. | Add a frame to the tag. | [
"Add",
"a",
"frame",
"to",
"the",
"tag",
"."
] | def add(self, frame):
"""Add a frame to the tag."""
return self.loaded_frame(frame) | [
"def",
"add",
"(",
"self",
",",
"frame",
")",
":",
"return",
"self",
".",
"loaded_frame",
"(",
"frame",
")"
] | https://github.com/Source-Python-Dev-Team/Source.Python/blob/d0ffd8ccbd1e9923c9bc44936f20613c1c76b7fb/addons/source-python/packages/site-packages/mutagen/id3/_tags.py#L286-L288 | |
shiweibsw/Translation-Tools | 2fbbf902364e557fa7017f9a74a8797b7440c077 | venv/Lib/site-packages/pip-9.0.3-py3.6.egg/pip/_vendor/distlib/markers.py | python | Evaluator.get_fragment | (self, offset) | return s | Get the part of the source which is causing a problem. | Get the part of the source which is causing a problem. | [
"Get",
"the",
"part",
"of",
"the",
"source",
"which",
"is",
"causing",
"a",
"problem",
"."
] | def get_fragment(self, offset):
"""
Get the part of the source which is causing a problem.
"""
fragment_len = 10
s = '%r' % (self.source[offset:offset + fragment_len])
if offset + fragment_len < len(self.source):
s += '...'
return s | [
"def",
"get_fragment",
"(",
"self",
",",
"offset",
")",
":",
"fragment_len",
"=",
"10",
"s",
"=",
"'%r'",
"%",
"(",
"self",
".",
"source",
"[",
"offset",
":",
"offset",
"+",
"fragment_len",
"]",
")",
"if",
"offset",
"+",
"fragment_len",
"<",
"len",
"... | https://github.com/shiweibsw/Translation-Tools/blob/2fbbf902364e557fa7017f9a74a8797b7440c077/venv/Lib/site-packages/pip-9.0.3-py3.6.egg/pip/_vendor/distlib/markers.py#L60-L68 | |
blackye/lalascan | e35726e6648525eb47493e39ee63a2a906dbb4b2 | lalascan/data/http.py | python | HTTP_Response.raw_headers | (self) | return self.__raw_headers | :returns: HTTP method used for this request.
:rtype: str | None | :returns: HTTP method used for this request.
:rtype: str | None | [
":",
"returns",
":",
"HTTP",
"method",
"used",
"for",
"this",
"request",
".",
":",
"rtype",
":",
"str",
"|",
"None"
] | def raw_headers(self):
"""
:returns: HTTP method used for this request.
:rtype: str | None
"""
return self.__raw_headers | [
"def",
"raw_headers",
"(",
"self",
")",
":",
"return",
"self",
".",
"__raw_headers"
] | https://github.com/blackye/lalascan/blob/e35726e6648525eb47493e39ee63a2a906dbb4b2/lalascan/data/http.py#L912-L917 | |
openstack/ironic | b392dc19bcd29cef5a69ec00d2f18a7a19a679e5 | ironic/conductor/manager.py | python | handle_sync_power_state_max_retries_exceeded | (task, actual_power_state,
exception=None) | Handles power state sync exceeding the max retries.
When synchronizing the power state between a node and the DB has exceeded
the maximum number of retries, change the DB power state to be the actual
node power state and place the node in maintenance.
:param task: a TaskManager instance with an exclusive lock
:param actual_power_state: the actual power state of the node; a power
state from ironic.common.states
:param exception: the exception object that caused the sync power state
to fail, if present. | Handles power state sync exceeding the max retries. | [
"Handles",
"power",
"state",
"sync",
"exceeding",
"the",
"max",
"retries",
"."
] | def handle_sync_power_state_max_retries_exceeded(task, actual_power_state,
exception=None):
"""Handles power state sync exceeding the max retries.
When synchronizing the power state between a node and the DB has exceeded
the maximum number of retries, change the DB power state to be the actual
node power state and place the node in maintenance.
:param task: a TaskManager instance with an exclusive lock
:param actual_power_state: the actual power state of the node; a power
state from ironic.common.states
:param exception: the exception object that caused the sync power state
to fail, if present.
"""
node = task.node
msg = (_("During sync_power_state, max retries exceeded "
"for node %(node)s, node state %(actual)s "
"does not match expected state '%(state)s'. "
"Updating DB state to '%(actual)s' "
"Switching node to maintenance mode.") %
{'node': node.uuid, 'actual': actual_power_state,
'state': node.power_state})
if exception is not None:
msg += _(" Error: %s") % exception
old_power_state = node.power_state
node.power_state = actual_power_state
utils.node_history_record(task.node, event=msg,
event_type=states.MONITORING,
error=True)
node.maintenance = True
node.maintenance_reason = msg
node.fault = faults.POWER_FAILURE
node.save()
if old_power_state != actual_power_state:
if node.instance_uuid:
nova.power_update(
task.context, node.instance_uuid, node.power_state)
notify_utils.emit_power_state_corrected_notification(
task, old_power_state)
LOG.error(msg) | [
"def",
"handle_sync_power_state_max_retries_exceeded",
"(",
"task",
",",
"actual_power_state",
",",
"exception",
"=",
"None",
")",
":",
"node",
"=",
"task",
".",
"node",
"msg",
"=",
"(",
"_",
"(",
"\"During sync_power_state, max retries exceeded \"",
"\"for node %(node)... | https://github.com/openstack/ironic/blob/b392dc19bcd29cef5a69ec00d2f18a7a19a679e5/ironic/conductor/manager.py#L3562-L3603 | ||
rhinstaller/anaconda | 63edc8680f1b05cbfe11bef28703acba808c5174 | pyanaconda/modules/payloads/source/mount_tasks.py | python | SetUpMountTask._check_mount | (self) | Check if the source is unmounted. | Check if the source is unmounted. | [
"Check",
"if",
"the",
"source",
"is",
"unmounted",
"."
] | def _check_mount(self):
"""Check if the source is unmounted."""
if os.path.ismount(self._target_mount):
raise SourceSetupError("The mount point {} is already in use.".format(
self._target_mount
)) | [
"def",
"_check_mount",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"ismount",
"(",
"self",
".",
"_target_mount",
")",
":",
"raise",
"SourceSetupError",
"(",
"\"The mount point {} is already in use.\"",
".",
"format",
"(",
"self",
".",
"_target_mount",
... | https://github.com/rhinstaller/anaconda/blob/63edc8680f1b05cbfe11bef28703acba808c5174/pyanaconda/modules/payloads/source/mount_tasks.py#L77-L82 | ||
CLUEbenchmark/CLUE | 5bd39732734afecb490cf18a5212e692dbf2c007 | baselines/models/classifier_utils.py | python | iFLYTEKDataProcessor.get_test_examples | (self, data_dir) | return self._create_examples(
self._read_json(os.path.join(data_dir, "test.json")), "test") | See base class. | See base class. | [
"See",
"base",
"class",
"."
] | def get_test_examples(self, data_dir):
"""See base class."""
return self._create_examples(
self._read_json(os.path.join(data_dir, "test.json")), "test") | [
"def",
"get_test_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"return",
"self",
".",
"_create_examples",
"(",
"self",
".",
"_read_json",
"(",
"os",
".",
"path",
".",
"join",
"(",
"data_dir",
",",
"\"test.json\"",
")",
")",
",",
"\"test\"",
")"
] | https://github.com/CLUEbenchmark/CLUE/blob/5bd39732734afecb490cf18a5212e692dbf2c007/baselines/models/classifier_utils.py#L307-L310 | |
Kkevsterrr/backdoorme | f9755ca6cec600335e681752e7a1c5c617bb5a39 | backdoors/shell/__pupy/pupy/packages/windows/x86/psutil/_psbsd.py | python | swap_memory | () | return _common.sswap(total, used, free, percent, sin, sout) | System swap memory as (total, used, free, sin, sout) namedtuple. | System swap memory as (total, used, free, sin, sout) namedtuple. | [
"System",
"swap",
"memory",
"as",
"(",
"total",
"used",
"free",
"sin",
"sout",
")",
"namedtuple",
"."
] | def swap_memory():
"""System swap memory as (total, used, free, sin, sout) namedtuple."""
total, used, free, sin, sout = [x * PAGESIZE for x in cext.swap_mem()]
percent = usage_percent(used, total, _round=1)
return _common.sswap(total, used, free, percent, sin, sout) | [
"def",
"swap_memory",
"(",
")",
":",
"total",
",",
"used",
",",
"free",
",",
"sin",
",",
"sout",
"=",
"[",
"x",
"*",
"PAGESIZE",
"for",
"x",
"in",
"cext",
".",
"swap_mem",
"(",
")",
"]",
"percent",
"=",
"usage_percent",
"(",
"used",
",",
"total",
... | https://github.com/Kkevsterrr/backdoorme/blob/f9755ca6cec600335e681752e7a1c5c617bb5a39/backdoors/shell/__pupy/pupy/packages/windows/x86/psutil/_psbsd.py#L85-L89 | |
huggingface/transformers | 623b4f7c63f60cce917677ee704d6c93ee960b4b | src/transformers/models/ibert/quant_modules.py | python | IntLayerNorm.forward | (self, x, scaling_factor=None) | return x, scaling_factor | [] | def forward(self, x, scaling_factor=None):
if not self.quant_mode:
mean = x.mean(axis=2, keepdim=True)
y = x - mean
var = torch.mean(y ** 2, axis=2, keepdim=True)
x = y / torch.sqrt(self.eps + var)
x = x * self.weight + self.bias
return x, None
# compute sqrt of the feature dimension if it is the first run
if self.dim_sqrt is None:
n = torch.tensor(x.shape[2], dtype=torch.float)
self.dim_sqrt = torch.sqrt(n).to(x.device)
# Normalization: computes mean and variance(std)
x_int = x / scaling_factor
mean_int = round_ste.apply(x_int.mean(axis=2, keepdim=True))
y_int = x_int - mean_int
y_int_shifted = floor_ste.apply(y_int / 2 ** self.shift)
y_sq_int = y_int_shifted ** 2
var_int = torch.sum(y_sq_int, axis=2, keepdim=True)
# overflow handling in training time
if self.training:
# if overflow is detected
if var_int.max() >= 2 ** self.max_bit:
var_int = self.overflow_fallback(y_int)
assert var_int.max() < 2 ** self.max_bit + 0.1, (
"Error detected in overflow handling: "
"`var_int` exceeds `self.max_bit` (the maximum possible bit width)"
)
# To be replaced with integer-sqrt kernel that produces the same output
std_int = floor_ste.apply(torch.sqrt(var_int)) * 2 ** self.shift
factor = floor_ste.apply(2 ** 31 / std_int)
y_int = floor_ste.apply(y_int * factor / 2)
scaling_factor = self.dim_sqrt / 2 ** 30
# scaling and shifting
bias = self.bias.data.detach() / (self.weight.data.detach())
bias_int = floor_ste.apply(bias / scaling_factor)
y_int = y_int + bias_int
scaling_factor = scaling_factor * self.weight
x = y_int * scaling_factor
return x, scaling_factor | [
"def",
"forward",
"(",
"self",
",",
"x",
",",
"scaling_factor",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"quant_mode",
":",
"mean",
"=",
"x",
".",
"mean",
"(",
"axis",
"=",
"2",
",",
"keepdim",
"=",
"True",
")",
"y",
"=",
"x",
"-",
"mea... | https://github.com/huggingface/transformers/blob/623b4f7c63f60cce917677ee704d6c93ee960b4b/src/transformers/models/ibert/quant_modules.py#L481-L527 | |||
IronLanguages/ironpython3 | 7a7bb2a872eeab0d1009fc8a6e24dca43f65b693 | Src/StdLib/Lib/multiprocessing/managers.py | python | Token.__setstate__ | (self, state) | [] | def __setstate__(self, state):
(self.typeid, self.address, self.id) = state | [
"def",
"__setstate__",
"(",
"self",
",",
"state",
")",
":",
"(",
"self",
".",
"typeid",
",",
"self",
".",
"address",
",",
"self",
".",
"id",
")",
"=",
"state"
] | https://github.com/IronLanguages/ironpython3/blob/7a7bb2a872eeab0d1009fc8a6e24dca43f65b693/Src/StdLib/Lib/multiprocessing/managers.py#L64-L65 | ||||
OpenAgricultureFoundation/openag-device-software | a51d2de399c0a6781ae51d0dcfaae1583d75f346 | device/peripherals/modules/atlas_ec/driver.py | python | AtlasECDriver.calibrate_single | (self, value: float, retry: bool = True) | Takes a single point calibration reading. | Takes a single point calibration reading. | [
"Takes",
"a",
"single",
"point",
"calibration",
"reading",
"."
] | def calibrate_single(self, value: float, retry: bool = True) -> None:
"""Takes a single point calibration reading."""
self.logger.info("Taking single point calibration reading")
# Temporary solution
message = "Not implemented"
raise exceptions.TakeSinglePointCalibrationError(
message=message, logger=self.logger
) | [
"def",
"calibrate_single",
"(",
"self",
",",
"value",
":",
"float",
",",
"retry",
":",
"bool",
"=",
"True",
")",
"->",
"None",
":",
"self",
".",
"logger",
".",
"info",
"(",
"\"Taking single point calibration reading\"",
")",
"# Temporary solution",
"message",
... | https://github.com/OpenAgricultureFoundation/openag-device-software/blob/a51d2de399c0a6781ae51d0dcfaae1583d75f346/device/peripherals/modules/atlas_ec/driver.py#L187-L195 | ||
cloud-custodian/cloud-custodian | 1ce1deb2d0f0832d6eb8839ef74b4c9e397128de | c7n/policy.py | python | PolicyConditions.get_deprecations | (self) | return deprecations | Return any matching deprecations for the policy fields itself. | Return any matching deprecations for the policy fields itself. | [
"Return",
"any",
"matching",
"deprecations",
"for",
"the",
"policy",
"fields",
"itself",
"."
] | def get_deprecations(self):
"""Return any matching deprecations for the policy fields itself."""
deprecations = []
for f in self.filters:
deprecations.extend(f.get_deprecations())
return deprecations | [
"def",
"get_deprecations",
"(",
"self",
")",
":",
"deprecations",
"=",
"[",
"]",
"for",
"f",
"in",
"self",
".",
"filters",
":",
"deprecations",
".",
"extend",
"(",
"f",
".",
"get_deprecations",
"(",
")",
")",
"return",
"deprecations"
] | https://github.com/cloud-custodian/cloud-custodian/blob/1ce1deb2d0f0832d6eb8839ef74b4c9e397128de/c7n/policy.py#L993-L998 | |
securesystemslab/zippy | ff0e84ac99442c2c55fe1d285332cfd4e185e089 | zippy/benchmarks/src/benchmarks/sympy/sympy/benchmarks/bench_symbench.py | python | bench_R8 | () | right(x^2,0,5,10^4) | right(x^2,0,5,10^4) | [
"right",
"(",
"x^2",
"0",
"5",
"10^4",
")"
] | def bench_R8():
"right(x^2,0,5,10^4)"
def right(f, a, b, n):
a = sympify(a)
b = sympify(b)
n = sympify(n)
x = f.atoms(Symbol).pop()
Deltax = (b - a)/n
c = a
est = 0
for i in range(n):
c += Deltax
est += f.subs(x, c)
return est*Deltax
a = right(x**2, 0, 5, 10**4) | [
"def",
"bench_R8",
"(",
")",
":",
"def",
"right",
"(",
"f",
",",
"a",
",",
"b",
",",
"n",
")",
":",
"a",
"=",
"sympify",
"(",
"a",
")",
"b",
"=",
"sympify",
"(",
"b",
")",
"n",
"=",
"sympify",
"(",
"n",
")",
"x",
"=",
"f",
".",
"atoms",
... | https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/benchmarks/bench_symbench.py#L71-L86 | ||
buke/GreenOdoo | 3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df | runtime/common/lib/python2.7/site-packages/libxml2.py | python | catalogGetSystem | (sysID) | return ret | Try to lookup the catalog reference associated to a system
ID DEPRECATED, use xmlCatalogResolveSystem() | Try to lookup the catalog reference associated to a system
ID DEPRECATED, use xmlCatalogResolveSystem() | [
"Try",
"to",
"lookup",
"the",
"catalog",
"reference",
"associated",
"to",
"a",
"system",
"ID",
"DEPRECATED",
"use",
"xmlCatalogResolveSystem",
"()"
] | def catalogGetSystem(sysID):
"""Try to lookup the catalog reference associated to a system
ID DEPRECATED, use xmlCatalogResolveSystem() """
ret = libxml2mod.xmlCatalogGetSystem(sysID)
return ret | [
"def",
"catalogGetSystem",
"(",
"sysID",
")",
":",
"ret",
"=",
"libxml2mod",
".",
"xmlCatalogGetSystem",
"(",
"sysID",
")",
"return",
"ret"
] | https://github.com/buke/GreenOdoo/blob/3d8c55d426fb41fdb3f2f5a1533cfe05983ba1df/runtime/common/lib/python2.7/site-packages/libxml2.py#L877-L881 | |
zeropointdynamics/zelos | 0c5bd57b4bab56c23c27dc5301ba1a42ee054726 | src/zelos/ext/platforms/linux/syscalls/arg_strings.py | python | _parse_fdset | (z, addr) | return fds | Parse the individual fd's that are 'ready' from an fd_set. An fd
is 'ready' when its corresponding bit is set in the fd_set. The
fd_set is an array of bitmasks, where the ith bit of the
jth element corresponds to the fd value (j * 32) + i. | Parse the individual fd's that are 'ready' from an fd_set. An fd
is 'ready' when its corresponding bit is set in the fd_set. The
fd_set is an array of bitmasks, where the ith bit of the
jth element corresponds to the fd value (j * 32) + i. | [
"Parse",
"the",
"individual",
"fd",
"s",
"that",
"are",
"ready",
"from",
"an",
"fd_set",
".",
"An",
"fd",
"is",
"ready",
"when",
"its",
"corresponding",
"bit",
"is",
"set",
"in",
"the",
"fd_set",
".",
"The",
"fd_set",
"is",
"an",
"array",
"of",
"bitmas... | def _parse_fdset(z, addr):
"""
Parse the individual fd's that are 'ready' from an fd_set. An fd
is 'ready' when its corresponding bit is set in the fd_set. The
fd_set is an array of bitmasks, where the ith bit of the
jth element corresponds to the fd value (j * 32) + i.
"""
fds = []
for i in range(0, 1024 // 8, 32 // 8):
val = z.memory.read_uint32(addr + i)
for bit in range(32):
if val & 2 ** bit != 0:
fds.append((i // 4) * 32 + bit)
return fds | [
"def",
"_parse_fdset",
"(",
"z",
",",
"addr",
")",
":",
"fds",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"1024",
"//",
"8",
",",
"32",
"//",
"8",
")",
":",
"val",
"=",
"z",
".",
"memory",
".",
"read_uint32",
"(",
"addr",
"+",
... | https://github.com/zeropointdynamics/zelos/blob/0c5bd57b4bab56c23c27dc5301ba1a42ee054726/src/zelos/ext/platforms/linux/syscalls/arg_strings.py#L123-L136 | |
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/cpdp/v20190820/models.py | python | CheckAcctRequest.__init__ | (self) | r"""
:param MidasAppId: 聚鑫分配的支付主MidasAppId
:type MidasAppId: str
:param SubAppId: 聚鑫计费SubAppId,代表子商户
:type SubAppId: str
:param BindType: 1 – 小额转账验证
2 – 短信验证
每个结算账户每天只能使用一次小额转账验证
:type BindType: int
:param SettleAcctNo: 结算账户账号
<敏感信息>加密详见<a href="https://cloud.tencent.com/document/product/1122/48979" target="_blank">《商户端接口敏感信息加密说明》</a>
:type SettleAcctNo: str
:param MidasSecretId: 聚鑫分配的安全ID
:type MidasSecretId: str
:param MidasSignature: 按照聚鑫安全密钥计算的签名
:type MidasSignature: str
:param CheckCode: 短信验证码或指令号
BindType==2必填,平安渠道必填
:type CheckCode: str
:param CurrencyType: 币种 RMB
BindType==1必填
:type CurrencyType: str
:param CurrencyUnit: 单位
1:元,2:角,3:分
BindType==1必填
:type CurrencyUnit: int
:param CurrencyAmt: 金额
BindType==1必填
:type CurrencyAmt: str
:param EncryptType: 敏感信息加密类型:
RSA: rsa非对称加密,使用RSA-PKCS1-v1_5
AES: aes对称加密,使用AES256-CBC-PCKS7padding
缺省: RSA
:type EncryptType: str
:param MidasEnvironment: 环境名:
release: 现网环境
sandbox: 沙箱环境
development: 开发环境
缺省: release
:type MidasEnvironment: str | r"""
:param MidasAppId: 聚鑫分配的支付主MidasAppId
:type MidasAppId: str
:param SubAppId: 聚鑫计费SubAppId,代表子商户
:type SubAppId: str
:param BindType: 1 – 小额转账验证
2 – 短信验证
每个结算账户每天只能使用一次小额转账验证
:type BindType: int
:param SettleAcctNo: 结算账户账号
<敏感信息>加密详见<a href="https://cloud.tencent.com/document/product/1122/48979" target="_blank">《商户端接口敏感信息加密说明》</a>
:type SettleAcctNo: str
:param MidasSecretId: 聚鑫分配的安全ID
:type MidasSecretId: str
:param MidasSignature: 按照聚鑫安全密钥计算的签名
:type MidasSignature: str
:param CheckCode: 短信验证码或指令号
BindType==2必填,平安渠道必填
:type CheckCode: str
:param CurrencyType: 币种 RMB
BindType==1必填
:type CurrencyType: str
:param CurrencyUnit: 单位
1:元,2:角,3:分
BindType==1必填
:type CurrencyUnit: int
:param CurrencyAmt: 金额
BindType==1必填
:type CurrencyAmt: str
:param EncryptType: 敏感信息加密类型:
RSA: rsa非对称加密,使用RSA-PKCS1-v1_5
AES: aes对称加密,使用AES256-CBC-PCKS7padding
缺省: RSA
:type EncryptType: str
:param MidasEnvironment: 环境名:
release: 现网环境
sandbox: 沙箱环境
development: 开发环境
缺省: release
:type MidasEnvironment: str | [
"r",
":",
"param",
"MidasAppId",
":",
"聚鑫分配的支付主MidasAppId",
":",
"type",
"MidasAppId",
":",
"str",
":",
"param",
"SubAppId",
":",
"聚鑫计费SubAppId,代表子商户",
":",
"type",
"SubAppId",
":",
"str",
":",
"param",
"BindType",
":",
"1",
"–",
"小额转账验证",
"2",
"–",
"短信验证"... | def __init__(self):
r"""
:param MidasAppId: 聚鑫分配的支付主MidasAppId
:type MidasAppId: str
:param SubAppId: 聚鑫计费SubAppId,代表子商户
:type SubAppId: str
:param BindType: 1 – 小额转账验证
2 – 短信验证
每个结算账户每天只能使用一次小额转账验证
:type BindType: int
:param SettleAcctNo: 结算账户账号
<敏感信息>加密详见<a href="https://cloud.tencent.com/document/product/1122/48979" target="_blank">《商户端接口敏感信息加密说明》</a>
:type SettleAcctNo: str
:param MidasSecretId: 聚鑫分配的安全ID
:type MidasSecretId: str
:param MidasSignature: 按照聚鑫安全密钥计算的签名
:type MidasSignature: str
:param CheckCode: 短信验证码或指令号
BindType==2必填,平安渠道必填
:type CheckCode: str
:param CurrencyType: 币种 RMB
BindType==1必填
:type CurrencyType: str
:param CurrencyUnit: 单位
1:元,2:角,3:分
BindType==1必填
:type CurrencyUnit: int
:param CurrencyAmt: 金额
BindType==1必填
:type CurrencyAmt: str
:param EncryptType: 敏感信息加密类型:
RSA: rsa非对称加密,使用RSA-PKCS1-v1_5
AES: aes对称加密,使用AES256-CBC-PCKS7padding
缺省: RSA
:type EncryptType: str
:param MidasEnvironment: 环境名:
release: 现网环境
sandbox: 沙箱环境
development: 开发环境
缺省: release
:type MidasEnvironment: str
"""
self.MidasAppId = None
self.SubAppId = None
self.BindType = None
self.SettleAcctNo = None
self.MidasSecretId = None
self.MidasSignature = None
self.CheckCode = None
self.CurrencyType = None
self.CurrencyUnit = None
self.CurrencyAmt = None
self.EncryptType = None
self.MidasEnvironment = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"MidasAppId",
"=",
"None",
"self",
".",
"SubAppId",
"=",
"None",
"self",
".",
"BindType",
"=",
"None",
"self",
".",
"SettleAcctNo",
"=",
"None",
"self",
".",
"MidasSecretId",
"=",
"None",
"self",
"... | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/cpdp/v20190820/models.py#L2488-L2541 | ||
JiYou/openstack | 8607dd488bde0905044b303eb6e52bdea6806923 | packages/source/nova/nova/notifications.py | python | _send_instance_update_notification | (context, instance, old_vm_state=None,
old_task_state=None, new_vm_state=None, new_task_state=None,
service="compute", host=None) | Send 'compute.instance.update' notification to inform observers
about instance state changes | Send 'compute.instance.update' notification to inform observers
about instance state changes | [
"Send",
"compute",
".",
"instance",
".",
"update",
"notification",
"to",
"inform",
"observers",
"about",
"instance",
"state",
"changes"
] | def _send_instance_update_notification(context, instance, old_vm_state=None,
old_task_state=None, new_vm_state=None, new_task_state=None,
service="compute", host=None):
"""Send 'compute.instance.update' notification to inform observers
about instance state changes"""
payload = info_from_instance(context, instance, None, None)
if not new_vm_state:
new_vm_state = instance["vm_state"]
if not new_task_state:
new_task_state = instance["task_state"]
states_payload = {
"old_state": old_vm_state,
"state": new_vm_state,
"old_task_state": old_task_state,
"new_task_state": new_task_state,
}
payload.update(states_payload)
# add audit fields:
(audit_start, audit_end) = audit_period_bounds(current_period=True)
payload["audit_period_beginning"] = audit_start
payload["audit_period_ending"] = audit_end
# add bw usage info:
bw = bandwidth_usage(instance, audit_start)
payload["bandwidth"] = bw
publisher_id = notifier_api.publisher_id(service, host)
notifier_api.notify(context, publisher_id, 'compute.instance.update',
notifier_api.INFO, payload) | [
"def",
"_send_instance_update_notification",
"(",
"context",
",",
"instance",
",",
"old_vm_state",
"=",
"None",
",",
"old_task_state",
"=",
"None",
",",
"new_vm_state",
"=",
"None",
",",
"new_task_state",
"=",
"None",
",",
"service",
"=",
"\"compute\"",
",",
"ho... | https://github.com/JiYou/openstack/blob/8607dd488bde0905044b303eb6e52bdea6806923/packages/source/nova/nova/notifications.py#L156-L190 | ||
iGio90/Dwarf | bb3011cdffd209c7e3f5febe558053bf649ca69c | dwarf_debugger/ui/panels/panel_objc_inspector.py | python | ObjCInspector._on_class_contextmenu | (self, pos) | Class ContextMenu | Class ContextMenu | [
"Class",
"ContextMenu"
] | def _on_class_contextmenu(self, pos):
""" Class ContextMenu
"""
index = self._ObjC_classes.indexAt(pos).row()
glbl_pt = self._ObjC_classes.mapToGlobal(pos)
context_menu = QMenu(self)
if index != -1:
context_menu.addAction(
'Breakpoint constructor', lambda: self._breakpoint_class(
self._ObjCclass_model.item(index, 0).text()))
context_menu.addAction(
'Breakpoint all methods', lambda: self._breakpoint_class_functions(
self._ObjCclass_model.item(index, 0).text()))
context_menu.addSeparator()
if self._ObjC_classes.search_enabled:
context_menu.addSeparator()
context_menu.addAction(
'Search', self._ObjC_classes._on_cm_search)
context_menu.addAction('Refresh', self._cm_refresh_classes)
context_menu.exec_(glbl_pt) | [
"def",
"_on_class_contextmenu",
"(",
"self",
",",
"pos",
")",
":",
"index",
"=",
"self",
".",
"_ObjC_classes",
".",
"indexAt",
"(",
"pos",
")",
".",
"row",
"(",
")",
"glbl_pt",
"=",
"self",
".",
"_ObjC_classes",
".",
"mapToGlobal",
"(",
"pos",
")",
"co... | https://github.com/iGio90/Dwarf/blob/bb3011cdffd209c7e3f5febe558053bf649ca69c/dwarf_debugger/ui/panels/panel_objc_inspector.py#L184-L205 | ||
trakt/Plex-Trakt-Scrobbler | aeb0bfbe62fad4b06c164f1b95581da7f35dce0b | Trakttv.bundle/Contents/Libraries/Shared/trakt/objects/comment.py | python | Comment.id | (self) | return sid | Returns the comment identifier
:rtype: :class:`~python:int` | Returns the comment identifier | [
"Returns",
"the",
"comment",
"identifier"
] | def id(self):
"""Returns the comment identifier
:rtype: :class:`~python:int`
"""
if self.pk is None:
return None
_, sid = self.pk
return sid | [
"def",
"id",
"(",
"self",
")",
":",
"if",
"self",
".",
"pk",
"is",
"None",
":",
"return",
"None",
"_",
",",
"sid",
"=",
"self",
".",
"pk",
"return",
"sid"
] | https://github.com/trakt/Plex-Trakt-Scrobbler/blob/aeb0bfbe62fad4b06c164f1b95581da7f35dce0b/Trakttv.bundle/Contents/Libraries/Shared/trakt/objects/comment.py#L94-L105 | |
kundajelab/deeplift | 0201a218965a263b9dd353099feacbb6f6db0051 | deeplift/layers/core.py | python | Layer.get_inputs | (self) | return self.inputs | return an object representing the input Layers | return an object representing the input Layers | [
"return",
"an",
"object",
"representing",
"the",
"input",
"Layers"
] | def get_inputs(self):
"""
return an object representing the input Layers
"""
return self.inputs | [
"def",
"get_inputs",
"(",
"self",
")",
":",
"return",
"self",
".",
"inputs"
] | https://github.com/kundajelab/deeplift/blob/0201a218965a263b9dd353099feacbb6f6db0051/deeplift/layers/core.py#L95-L99 | |
pascalw/Airplayer | cb6f6a393710a31f934e3c09de4f689158d23b50 | airplayer/lib/jsonrpclib/jsonrpc.py | python | TransportMixIn.send_content | (self, connection, request_body) | [] | def send_content(self, connection, request_body):
connection.putheader("Content-Type", "application/json-rpc")
connection.putheader("Content-Length", str(len(request_body)))
connection.endheaders()
if request_body:
connection.send(request_body) | [
"def",
"send_content",
"(",
"self",
",",
"connection",
",",
"request_body",
")",
":",
"connection",
".",
"putheader",
"(",
"\"Content-Type\"",
",",
"\"application/json-rpc\"",
")",
"connection",
".",
"putheader",
"(",
"\"Content-Length\"",
",",
"str",
"(",
"len",
... | https://github.com/pascalw/Airplayer/blob/cb6f6a393710a31f934e3c09de4f689158d23b50/airplayer/lib/jsonrpclib/jsonrpc.py#L122-L127 | ||||
kanzure/nanoengineer | 874e4c9f8a9190f093625b267f9767e19f82e6c4 | cad/src/dna/commands/BreakStrands/BreakStrands_PropertyManager.py | python | BreakStrands_PropertyManager.connect_or_disconnect_signals | (self, isConnect) | Connect or disconnect widget signals sent to their slot methods.
This can be overridden in subclasses. By default it does nothing.
@param isConnect: If True the widget will send the signals to the slot
method.
@type isConnect: boolean | Connect or disconnect widget signals sent to their slot methods.
This can be overridden in subclasses. By default it does nothing. | [
"Connect",
"or",
"disconnect",
"widget",
"signals",
"sent",
"to",
"their",
"slot",
"methods",
".",
"This",
"can",
"be",
"overridden",
"in",
"subclasses",
".",
"By",
"default",
"it",
"does",
"nothing",
"."
] | def connect_or_disconnect_signals(self, isConnect):
"""
Connect or disconnect widget signals sent to their slot methods.
This can be overridden in subclasses. By default it does nothing.
@param isConnect: If True the widget will send the signals to the slot
method.
@type isConnect: boolean
"""
#TODO: This is a temporary fix for a bug. When you invoke a temporary mode
# entering such a temporary mode keeps the signals of
#PM from the previous mode connected (
#but while exiting that temporary mode and reentering the
#previous mode, it atucally reconnects the signal! This gives rise to
#lots of bugs. This needs more general fix in Temporary mode API.
# -- Ninad 2008-01-09 (similar comment exists in MovePropertyManager.py
if isConnect and self.isAlreadyConnected:
if debug_flags.atom_debug:
print_compact_stack("warning: attempt to connect widgets"\
"in this PM that are already connected." )
return
if not isConnect and self.isAlreadyDisconnected:
if debug_flags.atom_debug:
print_compact_stack("warning: attempt to disconnect widgets"\
"in this PM that are already disconnected.")
return
self.isAlreadyConnected = isConnect
self.isAlreadyDisconnected = not isConnect
if isConnect:
change_connect = self.win.connect
else:
change_connect = self.win.disconnect
_superclass.connect_or_disconnect_signals(self, isConnect = isConnect)
if DEBUG_BREAK_OPTIONS_FEATURE:
self._dnaStrandChooserGroupBox.connect_or_disconnect_signals(isConnect = isConnect)
change_connect(self.breakAllStrandsButton,
SIGNAL("clicked()"),
self.command.breakStrandBonds)
change_connect(self.basesBeforeNextBreakSpinBox,
SIGNAL("valueChanged(int)"),
self.valueChanged_basesBeforeNextBreak) | [
"def",
"connect_or_disconnect_signals",
"(",
"self",
",",
"isConnect",
")",
":",
"#TODO: This is a temporary fix for a bug. When you invoke a temporary mode",
"# entering such a temporary mode keeps the signals of",
"#PM from the previous mode connected (",
"#but while exiting that temporary m... | https://github.com/kanzure/nanoengineer/blob/874e4c9f8a9190f093625b267f9767e19f82e6c4/cad/src/dna/commands/BreakStrands/BreakStrands_PropertyManager.py#L96-L145 | ||
accel-brain/accel-brain-code | 86f489dc9be001a3bae6d053f48d6b57c0bedb95 | Algorithm-Wars/algowars/truesampler/volatility_conditional_true_sampler.py | python | VolatilityConditionalTrueSampler.get_conditional_axis | (self) | return self.__conditional_axis | getter | getter | [
"getter"
] | def get_conditional_axis(self):
''' getter '''
return self.__conditional_axis | [
"def",
"get_conditional_axis",
"(",
"self",
")",
":",
"return",
"self",
".",
"__conditional_axis"
] | https://github.com/accel-brain/accel-brain-code/blob/86f489dc9be001a3bae6d053f48d6b57c0bedb95/Algorithm-Wars/algowars/truesampler/volatility_conditional_true_sampler.py#L381-L383 | |
hctomkins/caffe-gui-tool | 4037259d37691a203385edebf8630a4d54ae947a | CGTNodes.py | python | LRNNode.free | (self) | [] | def free(self):
print("Removing node ", self, ", Goodbye!") | [
"def",
"free",
"(",
"self",
")",
":",
"print",
"(",
"\"Removing node \"",
",",
"self",
",",
"\", Goodbye!\"",
")"
] | https://github.com/hctomkins/caffe-gui-tool/blob/4037259d37691a203385edebf8630a4d54ae947a/CGTNodes.py#L1122-L1123 | ||||
olivierkes/manuskript | 2b992e70c617325013e347b470246af66f6d2690 | manuskript/importer/opmlImporter.py | python | opmlImporter.saveNewlines | (cls, inString) | return inString | Since XML parsers are notorious for stripping out significant newlines,
save them in a form we can restore after the parse. | Since XML parsers are notorious for stripping out significant newlines,
save them in a form we can restore after the parse. | [
"Since",
"XML",
"parsers",
"are",
"notorious",
"for",
"stripping",
"out",
"significant",
"newlines",
"save",
"them",
"in",
"a",
"form",
"we",
"can",
"restore",
"after",
"the",
"parse",
"."
] | def saveNewlines(cls, inString):
"""
Since XML parsers are notorious for stripping out significant newlines,
save them in a form we can restore after the parse.
"""
inString = inString.replace("\r\n", "\n")
inString = inString.replace("\n", "{{lf}}")
return inString | [
"def",
"saveNewlines",
"(",
"cls",
",",
"inString",
")",
":",
"inString",
"=",
"inString",
".",
"replace",
"(",
"\"\\r\\n\"",
",",
"\"\\n\"",
")",
"inString",
"=",
"inString",
".",
"replace",
"(",
"\"\\n\"",
",",
"\"{{lf}}\"",
")",
"return",
"inString"
] | https://github.com/olivierkes/manuskript/blob/2b992e70c617325013e347b470246af66f6d2690/manuskript/importer/opmlImporter.py#L100-L108 | |
kubernetes-client/python | 47b9da9de2d02b2b7a34fbe05afb44afd130d73a | kubernetes/client/models/v1_ingress.py | python | V1Ingress.kind | (self, kind) | Sets the kind of this V1Ingress.
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501
:param kind: The kind of this V1Ingress. # noqa: E501
:type: str | Sets the kind of this V1Ingress. | [
"Sets",
"the",
"kind",
"of",
"this",
"V1Ingress",
"."
] | def kind(self, kind):
"""Sets the kind of this V1Ingress.
Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds # noqa: E501
:param kind: The kind of this V1Ingress. # noqa: E501
:type: str
"""
self._kind = kind | [
"def",
"kind",
"(",
"self",
",",
"kind",
")",
":",
"self",
".",
"_kind",
"=",
"kind"
] | https://github.com/kubernetes-client/python/blob/47b9da9de2d02b2b7a34fbe05afb44afd130d73a/kubernetes/client/models/v1_ingress.py#L110-L119 | ||
cloudbase/cloudbase-init | 300dabb36e91502f4ae93640136ad7a804aebd88 | cloudbaseinit/metadata/services/opennebulaservice.py | python | OpenNebulaService._calculate_netmask | (address, gateway) | return ".".join(netmask_chunks) | Try to determine a default netmask.
It is a simple, frequent and dummy prediction
based on the provided IP and gateway addresses. | Try to determine a default netmask. | [
"Try",
"to",
"determine",
"a",
"default",
"netmask",
"."
] | def _calculate_netmask(address, gateway):
"""Try to determine a default netmask.
It is a simple, frequent and dummy prediction
based on the provided IP and gateway addresses.
"""
address_chunks = address.split(".")
gateway_chunks = gateway.split(".")
netmask_chunks = []
for achunk, gchunk in six.moves.zip(
address_chunks, gateway_chunks):
if achunk == gchunk:
nchunk = "255"
else:
nchunk = "0"
netmask_chunks.append(nchunk)
return ".".join(netmask_chunks) | [
"def",
"_calculate_netmask",
"(",
"address",
",",
"gateway",
")",
":",
"address_chunks",
"=",
"address",
".",
"split",
"(",
"\".\"",
")",
"gateway_chunks",
"=",
"gateway",
".",
"split",
"(",
"\".\"",
")",
"netmask_chunks",
"=",
"[",
"]",
"for",
"achunk",
"... | https://github.com/cloudbase/cloudbase-init/blob/300dabb36e91502f4ae93640136ad7a804aebd88/cloudbaseinit/metadata/services/opennebulaservice.py#L102-L118 | |
sfepy/sfepy | 02ec7bb2ab39ee1dfe1eb4cd509f0ffb7dcc8b25 | sfepy/base/conf.py | python | ProblemConf.add_missing | (self, conf) | Add missing values from another problem configuration.
Missing keys/values are added also to values that are dictionaries.
Parameters
----------
conf : ProblemConf instance
The other configuration. | Add missing values from another problem configuration. | [
"Add",
"missing",
"values",
"from",
"another",
"problem",
"configuration",
"."
] | def add_missing(self, conf):
"""
Add missing values from another problem configuration.
Missing keys/values are added also to values that are dictionaries.
Parameters
----------
conf : ProblemConf instance
The other configuration.
"""
for x in conf.__dict__:
his = conf.__dict__[x]
my = getattr(self, x, None)
if isinstance(my, dict) and isinstance(his, dict):
for key in his:
if key not in my:
my[key]=his[key]
elif my is None:
setattr(self, x, his) | [
"def",
"add_missing",
"(",
"self",
",",
"conf",
")",
":",
"for",
"x",
"in",
"conf",
".",
"__dict__",
":",
"his",
"=",
"conf",
".",
"__dict__",
"[",
"x",
"]",
"my",
"=",
"getattr",
"(",
"self",
",",
"x",
",",
"None",
")",
"if",
"isinstance",
"(",
... | https://github.com/sfepy/sfepy/blob/02ec7bb2ab39ee1dfe1eb4cd509f0ffb7dcc8b25/sfepy/base/conf.py#L600-L619 | ||
QuantFans/quantdigger | 8b6c436509e7dfe63798300c0e31ea04eace9779 | quantdigger/engine/series.py | python | SeriesBase.update | (self, v) | 更新最后一个值 | 更新最后一个值 | [
"更新最后一个值"
] | def update(self, v):
""" 更新最后一个值 """
if isinstance(v, SeriesBase):
self.data[self.curbar] = v[0]
else:
self.data[self.curbar] = v | [
"def",
"update",
"(",
"self",
",",
"v",
")",
":",
"if",
"isinstance",
"(",
"v",
",",
"SeriesBase",
")",
":",
"self",
".",
"data",
"[",
"self",
".",
"curbar",
"]",
"=",
"v",
"[",
"0",
"]",
"else",
":",
"self",
".",
"data",
"[",
"self",
".",
"c... | https://github.com/QuantFans/quantdigger/blob/8b6c436509e7dfe63798300c0e31ea04eace9779/quantdigger/engine/series.py#L41-L46 | ||
nodejs/node-gyp | a2f298870692022302fa27a1d42363c4a72df407 | gyp/pylib/gyp/generator/android.py | python | AndroidMkWriter.Write | (
self,
qualified_target,
relative_target,
base_path,
output_filename,
spec,
configs,
part_of_all,
write_alias_target,
sdk_version,
) | return self.android_module | The main entry point: writes a .mk file for a single target.
Arguments:
qualified_target: target we're generating
relative_target: qualified target name relative to the root
base_path: path relative to source root we're building in, used to resolve
target-relative paths
output_filename: output .mk file name to write
spec, configs: gyp info
part_of_all: flag indicating this target is part of 'all'
write_alias_target: flag indicating whether to create short aliases for
this target
sdk_version: what to emit for LOCAL_SDK_VERSION in output | The main entry point: writes a .mk file for a single target. | [
"The",
"main",
"entry",
"point",
":",
"writes",
"a",
".",
"mk",
"file",
"for",
"a",
"single",
"target",
"."
] | def Write(
self,
qualified_target,
relative_target,
base_path,
output_filename,
spec,
configs,
part_of_all,
write_alias_target,
sdk_version,
):
"""The main entry point: writes a .mk file for a single target.
Arguments:
qualified_target: target we're generating
relative_target: qualified target name relative to the root
base_path: path relative to source root we're building in, used to resolve
target-relative paths
output_filename: output .mk file name to write
spec, configs: gyp info
part_of_all: flag indicating this target is part of 'all'
write_alias_target: flag indicating whether to create short aliases for
this target
sdk_version: what to emit for LOCAL_SDK_VERSION in output
"""
gyp.common.EnsureDirExists(output_filename)
self.fp = open(output_filename, "w")
self.fp.write(header)
self.qualified_target = qualified_target
self.relative_target = relative_target
self.path = base_path
self.target = spec["target_name"]
self.type = spec["type"]
self.toolset = spec["toolset"]
deps, link_deps = self.ComputeDeps(spec)
# Some of the generation below can add extra output, sources, or
# link dependencies. All of the out params of the functions that
# follow use names like extra_foo.
extra_outputs = []
extra_sources = []
self.android_class = MODULE_CLASSES.get(self.type, "GYP")
self.android_module = self.ComputeAndroidModule(spec)
(self.android_stem, self.android_suffix) = self.ComputeOutputParts(spec)
self.output = self.output_binary = self.ComputeOutput(spec)
# Standard header.
self.WriteLn("include $(CLEAR_VARS)\n")
# Module class and name.
self.WriteLn("LOCAL_MODULE_CLASS := " + self.android_class)
self.WriteLn("LOCAL_MODULE := " + self.android_module)
# Only emit LOCAL_MODULE_STEM if it's different to LOCAL_MODULE.
# The library module classes fail if the stem is set. ComputeOutputParts
# makes sure that stem == modulename in these cases.
if self.android_stem != self.android_module:
self.WriteLn("LOCAL_MODULE_STEM := " + self.android_stem)
self.WriteLn("LOCAL_MODULE_SUFFIX := " + self.android_suffix)
if self.toolset == "host":
self.WriteLn("LOCAL_IS_HOST_MODULE := true")
self.WriteLn("LOCAL_MULTILIB := $(GYP_HOST_MULTILIB)")
elif sdk_version > 0:
self.WriteLn(
"LOCAL_MODULE_TARGET_ARCH := " "$(TARGET_$(GYP_VAR_PREFIX)ARCH)"
)
self.WriteLn("LOCAL_SDK_VERSION := %s" % sdk_version)
# Grab output directories; needed for Actions and Rules.
if self.toolset == "host":
self.WriteLn(
"gyp_intermediate_dir := "
"$(call local-intermediates-dir,,$(GYP_HOST_VAR_PREFIX))"
)
else:
self.WriteLn(
"gyp_intermediate_dir := "
"$(call local-intermediates-dir,,$(GYP_VAR_PREFIX))"
)
self.WriteLn(
"gyp_shared_intermediate_dir := "
"$(call intermediates-dir-for,GYP,shared,,,$(GYP_VAR_PREFIX))"
)
self.WriteLn()
# List files this target depends on so that actions/rules/copies/sources
# can depend on the list.
# TODO: doesn't pull in things through transitive link deps; needed?
target_dependencies = [x[1] for x in deps if x[0] == "path"]
self.WriteLn("# Make sure our deps are built first.")
self.WriteList(
target_dependencies, "GYP_TARGET_DEPENDENCIES", local_pathify=True
)
# Actions must come first, since they can generate more OBJs for use below.
if "actions" in spec:
self.WriteActions(spec["actions"], extra_sources, extra_outputs)
# Rules must be early like actions.
if "rules" in spec:
self.WriteRules(spec["rules"], extra_sources, extra_outputs)
if "copies" in spec:
self.WriteCopies(spec["copies"], extra_outputs)
# GYP generated outputs.
self.WriteList(extra_outputs, "GYP_GENERATED_OUTPUTS", local_pathify=True)
# Set LOCAL_ADDITIONAL_DEPENDENCIES so that Android's build rules depend
# on both our dependency targets and our generated files.
self.WriteLn("# Make sure our deps and generated files are built first.")
self.WriteLn(
"LOCAL_ADDITIONAL_DEPENDENCIES := $(GYP_TARGET_DEPENDENCIES) "
"$(GYP_GENERATED_OUTPUTS)"
)
self.WriteLn()
# Sources.
if spec.get("sources", []) or extra_sources:
self.WriteSources(spec, configs, extra_sources)
self.WriteTarget(
spec, configs, deps, link_deps, part_of_all, write_alias_target
)
# Update global list of target outputs, used in dependency tracking.
target_outputs[qualified_target] = ("path", self.output_binary)
# Update global list of link dependencies.
if self.type == "static_library":
target_link_deps[qualified_target] = ("static", self.android_module)
elif self.type == "shared_library":
target_link_deps[qualified_target] = ("shared", self.android_module)
self.fp.close()
return self.android_module | [
"def",
"Write",
"(",
"self",
",",
"qualified_target",
",",
"relative_target",
",",
"base_path",
",",
"output_filename",
",",
"spec",
",",
"configs",
",",
"part_of_all",
",",
"write_alias_target",
",",
"sdk_version",
",",
")",
":",
"gyp",
".",
"common",
".",
... | https://github.com/nodejs/node-gyp/blob/a2f298870692022302fa27a1d42363c4a72df407/gyp/pylib/gyp/generator/android.py#L111-L251 | |
francisck/DanderSpritz_docs | 86bb7caca5a957147f120b18bb5c31f299914904 | Python/Core/Lib/lib-tk/ttk.py | python | Combobox.configure | (self, cnf=None, **kw) | return Entry.configure(self, cnf, **kw) | Custom Combobox configure, created to properly format the values
option. | Custom Combobox configure, created to properly format the values
option. | [
"Custom",
"Combobox",
"configure",
"created",
"to",
"properly",
"format",
"the",
"values",
"option",
"."
] | def configure(self, cnf=None, **kw):
"""Custom Combobox configure, created to properly format the values
option."""
if 'values' in kw:
kw['values'] = _format_optdict({'v': kw['values']})[1]
return Entry.configure(self, cnf, **kw) | [
"def",
"configure",
"(",
"self",
",",
"cnf",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"'values'",
"in",
"kw",
":",
"kw",
"[",
"'values'",
"]",
"=",
"_format_optdict",
"(",
"{",
"'v'",
":",
"kw",
"[",
"'values'",
"]",
"}",
")",
"[",
"1"... | https://github.com/francisck/DanderSpritz_docs/blob/86bb7caca5a957147f120b18bb5c31f299914904/Python/Core/Lib/lib-tk/ttk.py#L625-L630 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_flaskbb/lib/python2.7/site-packages/click/termui.py | python | style | (text, fg=None, bg=None, bold=None, dim=None, underline=None,
blink=None, reverse=None, reset=True) | return ''.join(bits) | Styles a text with ANSI styles and returns the new string. By
default the styling is self contained which means that at the end
of the string a reset code is issued. This can be prevented by
passing ``reset=False``.
Examples::
click.echo(click.style('Hello World!', fg='green'))
click.echo(click.style('ATTENTION!', blink=True))
click.echo(click.style('Some things', reverse=True, fg='cyan'))
Supported color names:
* ``black`` (might be a gray)
* ``red``
* ``green``
* ``yellow`` (might be an orange)
* ``blue``
* ``magenta``
* ``cyan``
* ``white`` (might be light gray)
* ``reset`` (reset the color code only)
.. versionadded:: 2.0
:param text: the string to style with ansi codes.
:param fg: if provided this will become the foreground color.
:param bg: if provided this will become the background color.
:param bold: if provided this will enable or disable bold mode.
:param dim: if provided this will enable or disable dim mode. This is
badly supported.
:param underline: if provided this will enable or disable underline.
:param blink: if provided this will enable or disable blinking.
:param reverse: if provided this will enable or disable inverse
rendering (foreground becomes background and the
other way round).
:param reset: by default a reset-all code is added at the end of the
string which means that styles do not carry over. This
can be disabled to compose styles. | Styles a text with ANSI styles and returns the new string. By
default the styling is self contained which means that at the end
of the string a reset code is issued. This can be prevented by
passing ``reset=False``. | [
"Styles",
"a",
"text",
"with",
"ANSI",
"styles",
"and",
"returns",
"the",
"new",
"string",
".",
"By",
"default",
"the",
"styling",
"is",
"self",
"contained",
"which",
"means",
"that",
"at",
"the",
"end",
"of",
"the",
"string",
"a",
"reset",
"code",
"is",... | def style(text, fg=None, bg=None, bold=None, dim=None, underline=None,
blink=None, reverse=None, reset=True):
"""Styles a text with ANSI styles and returns the new string. By
default the styling is self contained which means that at the end
of the string a reset code is issued. This can be prevented by
passing ``reset=False``.
Examples::
click.echo(click.style('Hello World!', fg='green'))
click.echo(click.style('ATTENTION!', blink=True))
click.echo(click.style('Some things', reverse=True, fg='cyan'))
Supported color names:
* ``black`` (might be a gray)
* ``red``
* ``green``
* ``yellow`` (might be an orange)
* ``blue``
* ``magenta``
* ``cyan``
* ``white`` (might be light gray)
* ``reset`` (reset the color code only)
.. versionadded:: 2.0
:param text: the string to style with ansi codes.
:param fg: if provided this will become the foreground color.
:param bg: if provided this will become the background color.
:param bold: if provided this will enable or disable bold mode.
:param dim: if provided this will enable or disable dim mode. This is
badly supported.
:param underline: if provided this will enable or disable underline.
:param blink: if provided this will enable or disable blinking.
:param reverse: if provided this will enable or disable inverse
rendering (foreground becomes background and the
other way round).
:param reset: by default a reset-all code is added at the end of the
string which means that styles do not carry over. This
can be disabled to compose styles.
"""
bits = []
if fg:
try:
bits.append('\033[%dm' % (_ansi_colors.index(fg) + 30))
except ValueError:
raise TypeError('Unknown color %r' % fg)
if bg:
try:
bits.append('\033[%dm' % (_ansi_colors.index(bg) + 40))
except ValueError:
raise TypeError('Unknown color %r' % bg)
if bold is not None:
bits.append('\033[%dm' % (1 if bold else 22))
if dim is not None:
bits.append('\033[%dm' % (2 if dim else 22))
if underline is not None:
bits.append('\033[%dm' % (4 if underline else 24))
if blink is not None:
bits.append('\033[%dm' % (5 if blink else 25))
if reverse is not None:
bits.append('\033[%dm' % (7 if reverse else 27))
bits.append(text)
if reset:
bits.append(_ansi_reset_all)
return ''.join(bits) | [
"def",
"style",
"(",
"text",
",",
"fg",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"bold",
"=",
"None",
",",
"dim",
"=",
"None",
",",
"underline",
"=",
"None",
",",
"blink",
"=",
"None",
",",
"reverse",
"=",
"None",
",",
"reset",
"=",
"True",
")... | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_flaskbb/lib/python2.7/site-packages/click/termui.py#L327-L393 | |
cloudera/hue | 23f02102d4547c17c32bd5ea0eb24e9eadd657a4 | desktop/core/ext-py/eventlet-0.24.1/eventlet/dagpool.py | python | DAGPool.spawn_many | (self, depends, function, *args, **kwds) | spawn_many() accepts a single *function* whose parameters are the same
as for :meth:`spawn`.
The difference is that spawn_many() accepts a dependency dict
*depends*. A new greenthread is spawned for each key in the dict. That
dict key's value should be an iterable of other keys on which this
greenthread depends.
If the *depends* dict contains any key already passed to :meth:`spawn`
or :meth:`post`, spawn_many() raises :class:`Collision`. It is
indeterminate how many of the other keys in *depends* will have
successfully spawned greenthreads. | spawn_many() accepts a single *function* whose parameters are the same
as for :meth:`spawn`. | [
"spawn_many",
"()",
"accepts",
"a",
"single",
"*",
"function",
"*",
"whose",
"parameters",
"are",
"the",
"same",
"as",
"for",
":",
"meth",
":",
"spawn",
"."
] | def spawn_many(self, depends, function, *args, **kwds):
"""
spawn_many() accepts a single *function* whose parameters are the same
as for :meth:`spawn`.
The difference is that spawn_many() accepts a dependency dict
*depends*. A new greenthread is spawned for each key in the dict. That
dict key's value should be an iterable of other keys on which this
greenthread depends.
If the *depends* dict contains any key already passed to :meth:`spawn`
or :meth:`post`, spawn_many() raises :class:`Collision`. It is
indeterminate how many of the other keys in *depends* will have
successfully spawned greenthreads.
"""
# Iterate over 'depends' items, relying on self.spawn() not to
# context-switch so no one can modify 'depends' along the way.
for key, deps in six.iteritems(depends):
self.spawn(key, deps, function, *args, **kwds) | [
"def",
"spawn_many",
"(",
"self",
",",
"depends",
",",
"function",
",",
"*",
"args",
",",
"*",
"*",
"kwds",
")",
":",
"# Iterate over 'depends' items, relying on self.spawn() not to",
"# context-switch so no one can modify 'depends' along the way.",
"for",
"key",
",",
"de... | https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/eventlet-0.24.1/eventlet/dagpool.py#L380-L398 | ||
holoviz/holoviews | cc6b27f01710402fdfee2aeef1507425ca78c91f | holoviews/core/spaces.py | python | DynamicMap.unbounded | (self) | return unbounded_dims | Returns a list of key dimensions that are unbounded, excluding
stream parameters. If any of theses key dimensions are
unbounded, the DynamicMap as a whole is also unbounded. | Returns a list of key dimensions that are unbounded, excluding
stream parameters. If any of theses key dimensions are
unbounded, the DynamicMap as a whole is also unbounded. | [
"Returns",
"a",
"list",
"of",
"key",
"dimensions",
"that",
"are",
"unbounded",
"excluding",
"stream",
"parameters",
".",
"If",
"any",
"of",
"theses",
"key",
"dimensions",
"are",
"unbounded",
"the",
"DynamicMap",
"as",
"a",
"whole",
"is",
"also",
"unbounded",
... | def unbounded(self):
"""
Returns a list of key dimensions that are unbounded, excluding
stream parameters. If any of theses key dimensions are
unbounded, the DynamicMap as a whole is also unbounded.
"""
unbounded_dims = []
# Dimensioned streams do not need to be bounded
stream_params = set(self._stream_parameters())
for kdim in self.kdims:
if str(kdim) in stream_params:
continue
if kdim.values:
continue
if None in kdim.range:
unbounded_dims.append(str(kdim))
return unbounded_dims | [
"def",
"unbounded",
"(",
"self",
")",
":",
"unbounded_dims",
"=",
"[",
"]",
"# Dimensioned streams do not need to be bounded",
"stream_params",
"=",
"set",
"(",
"self",
".",
"_stream_parameters",
"(",
")",
")",
"for",
"kdim",
"in",
"self",
".",
"kdims",
":",
"... | https://github.com/holoviz/holoviews/blob/cc6b27f01710402fdfee2aeef1507425ca78c91f/holoviews/core/spaces.py#L834-L850 | |
TencentCloud/tencentcloud-sdk-python | 3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2 | tencentcloud/mrs/v20200910/models.py | python | Summary.__init__ | (self) | r"""
:param Symptom: 症状
注意:此字段可能返回 null,表示取不到有效值。
:type Symptom: list of SymptomInfo
:param Text: 文本
注意:此字段可能返回 null,表示取不到有效值。
:type Text: str | r"""
:param Symptom: 症状
注意:此字段可能返回 null,表示取不到有效值。
:type Symptom: list of SymptomInfo
:param Text: 文本
注意:此字段可能返回 null,表示取不到有效值。
:type Text: str | [
"r",
":",
"param",
"Symptom",
":",
"症状",
"注意:此字段可能返回",
"null,表示取不到有效值。",
":",
"type",
"Symptom",
":",
"list",
"of",
"SymptomInfo",
":",
"param",
"Text",
":",
"文本",
"注意:此字段可能返回",
"null,表示取不到有效值。",
":",
"type",
"Text",
":",
"str"
] | def __init__(self):
r"""
:param Symptom: 症状
注意:此字段可能返回 null,表示取不到有效值。
:type Symptom: list of SymptomInfo
:param Text: 文本
注意:此字段可能返回 null,表示取不到有效值。
:type Text: str
"""
self.Symptom = None
self.Text = None | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"Symptom",
"=",
"None",
"self",
".",
"Text",
"=",
"None"
] | https://github.com/TencentCloud/tencentcloud-sdk-python/blob/3677fd1cdc8c5fd626ce001c13fd3b59d1f279d2/tencentcloud/mrs/v20200910/models.py#L2619-L2629 | ||
lisa-lab/pylearn2 | af81e5c362f0df4df85c3e54e23b2adeec026055 | pylearn2/models/dbm/sampling_procedure.py | python | SamplingProcedure.sample | (self, layer_to_state, theano_rng, layer_to_clamp=None,
num_steps=1) | Samples from self.dbm using `layer_to_state` as starting values.
Parameters
----------
layer_to_state : dict
Maps the DBM's Layer instances to theano variables representing
batches of samples of them.
theano_rng : theano.sandbox.rng_mrg.MRG_RandomStreams
Random number generator
layer_to_clamp : dict, optional
Maps Layers to bools. If a layer is not in the dictionary,
defaults to False. True indicates that this layer should be
clamped, so we are sampling from a conditional distribution
rather than the joint distribution.
num_steps : int, optional
Steps of the sampling procedure. It samples for `num_steps`
times and return the last sample.
Returns
-------
layer_to_updated_state : dict
Maps the DBM's Layer instances to theano variables representing
batches of updated samples of them. | Samples from self.dbm using `layer_to_state` as starting values. | [
"Samples",
"from",
"self",
".",
"dbm",
"using",
"layer_to_state",
"as",
"starting",
"values",
"."
] | def sample(self, layer_to_state, theano_rng, layer_to_clamp=None,
num_steps=1):
"""
Samples from self.dbm using `layer_to_state` as starting values.
Parameters
----------
layer_to_state : dict
Maps the DBM's Layer instances to theano variables representing
batches of samples of them.
theano_rng : theano.sandbox.rng_mrg.MRG_RandomStreams
Random number generator
layer_to_clamp : dict, optional
Maps Layers to bools. If a layer is not in the dictionary,
defaults to False. True indicates that this layer should be
clamped, so we are sampling from a conditional distribution
rather than the joint distribution.
num_steps : int, optional
Steps of the sampling procedure. It samples for `num_steps`
times and return the last sample.
Returns
-------
layer_to_updated_state : dict
Maps the DBM's Layer instances to theano variables representing
batches of updated samples of them.
"""
raise NotImplementedError(str(type(self))+" does not implement " +
"sample.") | [
"def",
"sample",
"(",
"self",
",",
"layer_to_state",
",",
"theano_rng",
",",
"layer_to_clamp",
"=",
"None",
",",
"num_steps",
"=",
"1",
")",
":",
"raise",
"NotImplementedError",
"(",
"str",
"(",
"type",
"(",
"self",
")",
")",
"+",
"\" does not implement \"",... | https://github.com/lisa-lab/pylearn2/blob/af81e5c362f0df4df85c3e54e23b2adeec026055/pylearn2/models/dbm/sampling_procedure.py#L31-L59 | ||
Chaffelson/nipyapi | d3b186fd701ce308c2812746d98af9120955e810 | nipyapi/nifi/models/provenance_dto.py | python | ProvenanceDTO.submission_time | (self) | return self._submission_time | Gets the submission_time of this ProvenanceDTO.
The timestamp when the query was submitted.
:return: The submission_time of this ProvenanceDTO.
:rtype: str | Gets the submission_time of this ProvenanceDTO.
The timestamp when the query was submitted. | [
"Gets",
"the",
"submission_time",
"of",
"this",
"ProvenanceDTO",
".",
"The",
"timestamp",
"when",
"the",
"query",
"was",
"submitted",
"."
] | def submission_time(self):
"""
Gets the submission_time of this ProvenanceDTO.
The timestamp when the query was submitted.
:return: The submission_time of this ProvenanceDTO.
:rtype: str
"""
return self._submission_time | [
"def",
"submission_time",
"(",
"self",
")",
":",
"return",
"self",
".",
"_submission_time"
] | https://github.com/Chaffelson/nipyapi/blob/d3b186fd701ce308c2812746d98af9120955e810/nipyapi/nifi/models/provenance_dto.py#L133-L141 | |
rgalanakis/goless | 3611103a52982d475ae24afe66177ba702080c45 | goless/__init__.py | python | on_panic | (etype, value, tb) | Called when there is an unhandled error in a goroutine.
By default, logs and exits the process. | Called when there is an unhandled error in a goroutine.
By default, logs and exits the process. | [
"Called",
"when",
"there",
"is",
"an",
"unhandled",
"error",
"in",
"a",
"goroutine",
".",
"By",
"default",
"logs",
"and",
"exits",
"the",
"process",
"."
] | def on_panic(etype, value, tb):
"""
Called when there is an unhandled error in a goroutine.
By default, logs and exits the process.
"""
_logging.critical(_traceback.format_exception(etype, value, tb))
_be.propagate_exc(SystemExit, 1) | [
"def",
"on_panic",
"(",
"etype",
",",
"value",
",",
"tb",
")",
":",
"_logging",
".",
"critical",
"(",
"_traceback",
".",
"format_exception",
"(",
"etype",
",",
"value",
",",
"tb",
")",
")",
"_be",
".",
"propagate_exc",
"(",
"SystemExit",
",",
"1",
")"
... | https://github.com/rgalanakis/goless/blob/3611103a52982d475ae24afe66177ba702080c45/goless/__init__.py#L35-L41 | ||
pantsbuild/pex | 473c6ac732ed4bc338b4b20a9ec930d1d722c9b4 | pex/vendor/_vendored/setuptools/setuptools/_vendor/pyparsing.py | python | ParseExpression.ignore | ( self, other ) | return self | [] | def ignore( self, other ):
if isinstance( other, Suppress ):
if other not in self.ignoreExprs:
super( ParseExpression, self).ignore( other )
for e in self.exprs:
e.ignore( self.ignoreExprs[-1] )
else:
super( ParseExpression, self).ignore( other )
for e in self.exprs:
e.ignore( self.ignoreExprs[-1] )
return self | [
"def",
"ignore",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"Suppress",
")",
":",
"if",
"other",
"not",
"in",
"self",
".",
"ignoreExprs",
":",
"super",
"(",
"ParseExpression",
",",
"self",
")",
".",
"ignore",
"(",
"ot... | https://github.com/pantsbuild/pex/blob/473c6ac732ed4bc338b4b20a9ec930d1d722c9b4/pex/vendor/_vendored/setuptools/setuptools/_vendor/pyparsing.py#L3297-L3307 | |||
shaneshixiang/rllabplusplus | 4d55f96ec98e3fe025b7991945e3e6a54fd5449f | rllab/algos/util.py | python | ReplayPool.add_sample | (self, observation, action, reward, terminal, extra=None) | Add a time step record.
Arguments:
observation -- current or observation
action -- action chosen by the agent
reward -- reward received after taking the action
terminal -- boolean indicating whether the episode ended after this
time step | Add a time step record. | [
"Add",
"a",
"time",
"step",
"record",
"."
] | def add_sample(self, observation, action, reward, terminal, extra=None):
"""Add a time step record.
Arguments:
observation -- current or observation
action -- action chosen by the agent
reward -- reward received after taking the action
terminal -- boolean indicating whether the episode ended after this
time step
"""
self.observations[self.top] = observation
self.actions[self.top] = action
self.rewards[self.top] = reward
self.terminals[self.top] = terminal
# self.horizon_terminals[self.top] = horizon_terminal
if extra is not None:
if self.extras is None:
assert self.size == 0, "extra must be consistent"
self.extras = np.zeros(
(self.max_steps,) + extra.shape,
dtype=extra.dtype
)
self.extras[self.top] = extra
else:
assert self.extras is None
if self.size == self.max_steps:
self.bottom = (self.bottom + 1) % self.max_steps
else:
self.size += 1
self.top = (self.top + 1) % self.max_steps | [
"def",
"add_sample",
"(",
"self",
",",
"observation",
",",
"action",
",",
"reward",
",",
"terminal",
",",
"extra",
"=",
"None",
")",
":",
"self",
".",
"observations",
"[",
"self",
".",
"top",
"]",
"=",
"observation",
"self",
".",
"actions",
"[",
"self"... | https://github.com/shaneshixiang/rllabplusplus/blob/4d55f96ec98e3fe025b7991945e3e6a54fd5449f/rllab/algos/util.py#L101-L131 | ||
mila-iqia/myia | 56774a39579b4ec4123f44843ad4ca688acc859b | myia/ir/metagraph.py | python | MultitypeGraph.__call__ | (self, *args) | return fn(*args) | Call like a normal function. | Call like a normal function. | [
"Call",
"like",
"a",
"normal",
"function",
"."
] | def __call__(self, *args):
"""Call like a normal function."""
types = tuple(abstract.to_abstract(arg) for arg in args)
fn = self._getfn(types)
return fn(*args) | [
"def",
"__call__",
"(",
"self",
",",
"*",
"args",
")",
":",
"types",
"=",
"tuple",
"(",
"abstract",
".",
"to_abstract",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
")",
"fn",
"=",
"self",
".",
"_getfn",
"(",
"types",
")",
"return",
"fn",
"(",
"*... | https://github.com/mila-iqia/myia/blob/56774a39579b4ec4123f44843ad4ca688acc859b/myia/ir/metagraph.py#L96-L100 | |
wwqgtxx/wwqLyParse | 33136508e52821babd9294fdecffbdf02d73a6fc | wwqLyParse/lib/python-3.7.2-embed-win32/Crypto/Hash/SHA3_256.py | python | new | (*args, **kwargs) | return SHA3_256_Hash(data, update_after_digest) | Create a new hash object.
Args:
data (byte string/byte array/memoryview):
The very first chunk of the message to hash.
It is equivalent to an early call to :meth:`update`.
update_after_digest (boolean):
Whether :meth:`digest` can be followed by another :meth:`update`
(default: ``False``).
:Return: A :class:`SHA3_256_Hash` hash object | Create a new hash object. | [
"Create",
"a",
"new",
"hash",
"object",
"."
] | def new(*args, **kwargs):
"""Create a new hash object.
Args:
data (byte string/byte array/memoryview):
The very first chunk of the message to hash.
It is equivalent to an early call to :meth:`update`.
update_after_digest (boolean):
Whether :meth:`digest` can be followed by another :meth:`update`
(default: ``False``).
:Return: A :class:`SHA3_256_Hash` hash object
"""
data = kwargs.pop("data", None)
update_after_digest = kwargs.pop("update_after_digest", False)
if len(args) == 1:
if data:
raise ValueError("Initial data for hash specified twice")
data = args[0]
if kwargs:
raise TypeError("Unknown parameters: " + str(kwargs))
return SHA3_256_Hash(data, update_after_digest) | [
"def",
"new",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"pop",
"(",
"\"data\"",
",",
"None",
")",
"update_after_digest",
"=",
"kwargs",
".",
"pop",
"(",
"\"update_after_digest\"",
",",
"False",
")",
"if",
"len",
... | https://github.com/wwqgtxx/wwqLyParse/blob/33136508e52821babd9294fdecffbdf02d73a6fc/wwqLyParse/lib/python-3.7.2-embed-win32/Crypto/Hash/SHA3_256.py#L120-L144 | |
aliyun/aliyun-openapi-python-sdk | bda53176cc9cf07605b1cf769f0df444cca626a0 | aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/packages/urllib3/contrib/securetransport.py | python | extract_from_urllib3 | () | Undo monkey-patching by :func:`inject_into_urllib3`. | Undo monkey-patching by :func:`inject_into_urllib3`. | [
"Undo",
"monkey",
"-",
"patching",
"by",
":",
"func",
":",
"inject_into_urllib3",
"."
] | def extract_from_urllib3():
"""
Undo monkey-patching by :func:`inject_into_urllib3`.
"""
util.ssl_.SSLContext = orig_util_SSLContext
util.HAS_SNI = orig_util_HAS_SNI
util.ssl_.HAS_SNI = orig_util_HAS_SNI
util.IS_SECURETRANSPORT = False
util.ssl_.IS_SECURETRANSPORT = False | [
"def",
"extract_from_urllib3",
"(",
")",
":",
"util",
".",
"ssl_",
".",
"SSLContext",
"=",
"orig_util_SSLContext",
"util",
".",
"HAS_SNI",
"=",
"orig_util_HAS_SNI",
"util",
".",
"ssl_",
".",
"HAS_SNI",
"=",
"orig_util_HAS_SNI",
"util",
".",
"IS_SECURETRANSPORT",
... | https://github.com/aliyun/aliyun-openapi-python-sdk/blob/bda53176cc9cf07605b1cf769f0df444cca626a0/aliyun-python-sdk-core-v3/aliyunsdkcore/vendored/requests/packages/urllib3/contrib/securetransport.py#L165-L173 | ||
trakt/Plex-Trakt-Scrobbler | aeb0bfbe62fad4b06c164f1b95581da7f35dce0b | Trakttv.bundle/Contents/Libraries/Shared/OpenSSL/crypto.py | python | X509StoreContext.verify_certificate | (self) | Verify a certificate in a context.
.. versionadded:: 0.15
:raises X509StoreContextError: If an error occurred when validating a
certificate in the context. Sets ``certificate`` attribute to
indicate which certificate caused the error. | Verify a certificate in a context. | [
"Verify",
"a",
"certificate",
"in",
"a",
"context",
"."
] | def verify_certificate(self):
"""
Verify a certificate in a context.
.. versionadded:: 0.15
:raises X509StoreContextError: If an error occurred when validating a
certificate in the context. Sets ``certificate`` attribute to
indicate which certificate caused the error.
"""
# Always re-initialize the store context in case
# :meth:`verify_certificate` is called multiple times.
self._init()
ret = _lib.X509_verify_cert(self._store_ctx)
self._cleanup()
if ret <= 0:
raise self._exception_from_context() | [
"def",
"verify_certificate",
"(",
"self",
")",
":",
"# Always re-initialize the store context in case",
"# :meth:`verify_certificate` is called multiple times.",
"self",
".",
"_init",
"(",
")",
"ret",
"=",
"_lib",
".",
"X509_verify_cert",
"(",
"self",
".",
"_store_ctx",
"... | https://github.com/trakt/Plex-Trakt-Scrobbler/blob/aeb0bfbe62fad4b06c164f1b95581da7f35dce0b/Trakttv.bundle/Contents/Libraries/Shared/OpenSSL/crypto.py#L1618-L1634 | ||
brython-dev/brython | 9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3 | www/src/Lib/site-packages/simpleaio/events.py | python | BrythonEventLoop.default_exception_handler | (self, context) | Default exception handler.
This is called when an exception occurs and no exception
handler is set, and can be called by a custom exception
handler that wants to defer to the default behavior.
The context parameter has the same meaning as in
`call_exception_handler()`. | Default exception handler. | [
"Default",
"exception",
"handler",
"."
] | def default_exception_handler(self, context):
"""Default exception handler.
This is called when an exception occurs and no exception
handler is set, and can be called by a custom exception
handler that wants to defer to the default behavior.
The context parameter has the same meaning as in
`call_exception_handler()`.
"""
message = context.get('message')
if not message:
message = 'Unhandled exception in event loop'
exception = context.get('exception')
if exception is not None:
#exc_info = (type(exception), exception, exception.__traceback__)
#FIXME: Brython does not provide __traceback__
exc_info = (type(exception), exception)
else:
exc_info = False
if ('source_traceback' not in context
and self._current_handle is not None
and self._current_handle._source_traceback):
context['handle_traceback'] = self._current_handle._source_traceback
log_lines = [message]
for key in sorted(context):
if key in {'message', 'exception'}:
continue
value = context[key]
if key == 'source_traceback':
tb = ''.join(value)
value = 'Object created at (most recent call last):\n'
value += tb.rstrip()
elif key == 'handle_traceback':
tb = ''.join(value)
value = 'Handle created at (most recent call last):\n'
value += tb.rstrip()
else:
value = repr(value)
log_lines.append('{}: {}'.format(key, value))
helpers.error('\n'.join(log_lines), exc_info=exc_info) | [
"def",
"default_exception_handler",
"(",
"self",
",",
"context",
")",
":",
"message",
"=",
"context",
".",
"get",
"(",
"'message'",
")",
"if",
"not",
"message",
":",
"message",
"=",
"'Unhandled exception in event loop'",
"exception",
"=",
"context",
".",
"get",
... | https://github.com/brython-dev/brython/blob/9cba5fb7f43a9b52fff13e89b403e02a1dfaa5f3/www/src/Lib/site-packages/simpleaio/events.py#L69-L112 | ||
saltstack/raet | 54858029568115550c7cb7d93e999d9c52b1494a | raet/road/transacting.py | python | Aliver.__init__ | (self, redoTimeoutMin=None, redoTimeoutMax=None,
cascade=False, **kwa) | Setup instance | Setup instance | [
"Setup",
"instance"
] | def __init__(self, redoTimeoutMin=None, redoTimeoutMax=None,
cascade=False, **kwa):
'''
Setup instance
'''
kwa['kind'] = TrnsKind.alive.value
super(Aliver, self).__init__(**kwa)
self.cascade = cascade
self.redoTimeoutMax = redoTimeoutMax or self.RedoTimeoutMax
self.redoTimeoutMin = redoTimeoutMin or self.RedoTimeoutMin
self.redoTimer = StoreTimer(self.stack.store,
duration=self.redoTimeoutMin)
self.sid = self.remote.sid
self.tid = self.remote.nextTid()
self.prep() | [
"def",
"__init__",
"(",
"self",
",",
"redoTimeoutMin",
"=",
"None",
",",
"redoTimeoutMax",
"=",
"None",
",",
"cascade",
"=",
"False",
",",
"*",
"*",
"kwa",
")",
":",
"kwa",
"[",
"'kind'",
"]",
"=",
"TrnsKind",
".",
"alive",
".",
"value",
"super",
"("... | https://github.com/saltstack/raet/blob/54858029568115550c7cb7d93e999d9c52b1494a/raet/road/transacting.py#L2330-L2347 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | ansible/roles/lib_oa_openshift/src/ansible/oc_process.py | python | main | () | ansible oc module for processing templates | ansible oc module for processing templates | [
"ansible",
"oc",
"module",
"for",
"processing",
"templates"
] | def main():
'''
ansible oc module for processing templates
'''
module = AnsibleModule(
argument_spec=dict(
kubeconfig=dict(default='/etc/origin/master/admin.kubeconfig', type='str'),
state=dict(default='present', type='str', choices=['present', 'list']),
debug=dict(default=False, type='bool'),
namespace=dict(default='default', type='str'),
template_name=dict(default=None, type='str'),
content=dict(default=None, type='str'),
params=dict(default=None, type='dict'),
create=dict(default=False, type='bool'),
reconcile=dict(default=True, type='bool'),
),
supports_check_mode=True,
)
rval = OCProcess.run_ansible(module.params, module.check_mode)
if 'failed' in rval:
module.fail_json(**rval)
module.exit_json(**rval) | [
"def",
"main",
"(",
")",
":",
"module",
"=",
"AnsibleModule",
"(",
"argument_spec",
"=",
"dict",
"(",
"kubeconfig",
"=",
"dict",
"(",
"default",
"=",
"'/etc/origin/master/admin.kubeconfig'",
",",
"type",
"=",
"'str'",
")",
",",
"state",
"=",
"dict",
"(",
"... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/ansible/roles/lib_oa_openshift/src/ansible/oc_process.py#L5-L29 | ||
andresriancho/w3af | cd22e5252243a87aaa6d0ddea47cf58dacfe00a9 | w3af/core/data/kb/shell.py | python | Shell.__repr__ | (self) | return fmt % (self.get_name(), self.get_remote_user(),
self.get_remote_system()) | [] | def __repr__(self):
if not self._rOS:
self.identify_os()
fmt = '<%s object (ruser: "%s" | rsystem: "%s")>'
return fmt % (self.get_name(), self.get_remote_user(),
self.get_remote_system()) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_rOS",
":",
"self",
".",
"identify_os",
"(",
")",
"fmt",
"=",
"'<%s object (ruser: \"%s\" | rsystem: \"%s\")>'",
"return",
"fmt",
"%",
"(",
"self",
".",
"get_name",
"(",
")",
",",
"self",... | https://github.com/andresriancho/w3af/blob/cd22e5252243a87aaa6d0ddea47cf58dacfe00a9/w3af/core/data/kb/shell.py#L267-L272 | |||
knownsec/VxPwn | 6555f49675f0317d4a48568a89d0ec4332658402 | sulley/examples/fuzz_trillian_jabber.py | python | init_message | (sock) | [] | def init_message (sock):
init = '<?xml version="1.0" encoding="UTF-8" ?>\n'
init += '<stream:stream to="152.67.137.126" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams">'
sock.send(init)
sock.recv(1024) | [
"def",
"init_message",
"(",
"sock",
")",
":",
"init",
"=",
"'<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\\n'",
"init",
"+=",
"'<stream:stream to=\"152.67.137.126\" xmlns=\"jabber:client\" xmlns:stream=\"http://etherx.jabber.org/streams\">'",
"sock",
".",
"send",
"(",
"init",
")",
... | https://github.com/knownsec/VxPwn/blob/6555f49675f0317d4a48568a89d0ec4332658402/sulley/examples/fuzz_trillian_jabber.py#L22-L27 | ||||
plotly/plotly.py | cfad7862594b35965c0e000813bd7805e8494a5b | packages/python/plotly/plotly/graph_objs/surface/colorbar/_title.py | python | Title.font | (self) | return self["font"] | Sets this color bar's title font. Note that the title's font
used to be set by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.surface.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size
Returns
-------
plotly.graph_objs.surface.colorbar.title.Font | Sets this color bar's title font. Note that the title's font
used to be set by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.surface.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size | [
"Sets",
"this",
"color",
"bar",
"s",
"title",
"font",
".",
"Note",
"that",
"the",
"title",
"s",
"font",
"used",
"to",
"be",
"set",
"by",
"the",
"now",
"deprecated",
"titlefont",
"attribute",
".",
"The",
"font",
"property",
"is",
"an",
"instance",
"of",
... | def font(self):
"""
Sets this color bar's title font. Note that the title's font
used to be set by the now deprecated `titlefont` attribute.
The 'font' property is an instance of Font
that may be specified as:
- An instance of :class:`plotly.graph_objs.surface.colorbar.title.Font`
- A dict of string/value properties that will be passed
to the Font constructor
Supported dict properties:
color
family
HTML font family - the typeface that will be
applied by the web browser. The web browser
will only be able to apply a font if it is
available on the system which it operates.
Provide multiple font families, separated by
commas, to indicate the preference in which to
apply fonts if they aren't available on the
system. The Chart Studio Cloud (at
https://chart-studio.plotly.com or on-premise)
generates images on a server, where only a
select number of fonts are installed and
supported. These include "Arial", "Balto",
"Courier New", "Droid Sans",, "Droid Serif",
"Droid Sans Mono", "Gravitas One", "Old
Standard TT", "Open Sans", "Overpass", "PT Sans
Narrow", "Raleway", "Times New Roman".
size
Returns
-------
plotly.graph_objs.surface.colorbar.title.Font
"""
return self["font"] | [
"def",
"font",
"(",
"self",
")",
":",
"return",
"self",
"[",
"\"font\"",
"]"
] | https://github.com/plotly/plotly.py/blob/cfad7862594b35965c0e000813bd7805e8494a5b/packages/python/plotly/plotly/graph_objs/surface/colorbar/_title.py#L16-L54 | |
MozillaSecurity/funfuzz | fe5cc4710f82e68a171bf1255f43519f9c1bf784 | src/funfuzz/js/compile_shell.py | python | CompiledShell.get_version | (self) | return self.js_version | Retrieve the version number of the js shell as extracted from js.pc
Returns:
str: Version number of the js shell | Retrieve the version number of the js shell as extracted from js.pc | [
"Retrieve",
"the",
"version",
"number",
"of",
"the",
"js",
"shell",
"as",
"extracted",
"from",
"js",
".",
"pc"
] | def get_version(self):
"""Retrieve the version number of the js shell as extracted from js.pc
Returns:
str: Version number of the js shell
"""
return self.js_version | [
"def",
"get_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"js_version"
] | https://github.com/MozillaSecurity/funfuzz/blob/fe5cc4710f82e68a171bf1255f43519f9c1bf784/src/funfuzz/js/compile_shell.py#L304-L310 | |
rossant/galry | 6201fa32fb5c9ef3cea700cc22caf52fb69ebe31 | galry/glrenderer.py | python | GLVisualRenderer.set_data | (self, **kwargs) | Load data for the specified visual. Uploading does not happen here
but in `update_all_variables` instead, since this needs to happen
after shader program binding in the paint method.
Arguments:
* **kwargs: the data to update as name:value pairs. name can be
any field of the visual, plus one of the following keywords:
* visible: whether this visual should be visible,
* size: the size of the visual,
* primitive_type: the GL primitive type,
* constrain_ratio: whether to constrain the ratio of the visual,
* constrain_navigation: whether to constrain the navigation, | Load data for the specified visual. Uploading does not happen here
but in `update_all_variables` instead, since this needs to happen
after shader program binding in the paint method.
Arguments:
* **kwargs: the data to update as name:value pairs. name can be
any field of the visual, plus one of the following keywords:
* visible: whether this visual should be visible,
* size: the size of the visual,
* primitive_type: the GL primitive type,
* constrain_ratio: whether to constrain the ratio of the visual,
* constrain_navigation: whether to constrain the navigation, | [
"Load",
"data",
"for",
"the",
"specified",
"visual",
".",
"Uploading",
"does",
"not",
"happen",
"here",
"but",
"in",
"update_all_variables",
"instead",
"since",
"this",
"needs",
"to",
"happen",
"after",
"shader",
"program",
"binding",
"in",
"the",
"paint",
"me... | def set_data(self, **kwargs):
"""Load data for the specified visual. Uploading does not happen here
but in `update_all_variables` instead, since this needs to happen
after shader program binding in the paint method.
Arguments:
* **kwargs: the data to update as name:value pairs. name can be
any field of the visual, plus one of the following keywords:
* visible: whether this visual should be visible,
* size: the size of the visual,
* primitive_type: the GL primitive type,
* constrain_ratio: whether to constrain the ratio of the visual,
* constrain_navigation: whether to constrain the navigation,
"""
# handle compound variables
kwargs2 = kwargs.copy()
for name, data in kwargs2.iteritems():
variable = self.get_variable(name)
if variable is None:
# log_info("variable '%s' unknown" % name)
continue
if variable is not None and variable['shader_type'] == 'compound':
fun = variable['fun']
kwargs.pop(name)
# HACK: if the target variable in the compound is a special
# keyword, we update it in kwargs, otherwise we update the
# data in self.data_updating
# print name, fun(data)
# if name in self.special_keywords:
# kwargs.update(**fun(data))
# else:
# self.data_updating.update(**fun(data))
kwargs.update(**fun(data))
# remove non-visible variables
if not variable.get('visible', True):
kwargs.pop(name)
# handle visual visibility
visible = kwargs.pop('visible', None)
if visible is not None:
self.visual['visible'] = visible
# handle size keyword
size = kwargs.pop('size', None)
# print size
if size is not None:
self.slicer.set_size(size)
# handle bounds keyword
bounds = kwargs.pop('bounds', None)
if bounds is not None:
self.slicer.set_bounds(bounds)
# handle primitive type special keyword
primitive_type = kwargs.pop('primitive_type', None)
if primitive_type is not None:
self.visual['primitive_type'] = primitive_type
self.set_primitive_type(primitive_type)
# handle constrain_ratio keyword
constrain_ratio = kwargs.pop('constrain_ratio', None)
if constrain_ratio is not None:
self.visual['constrain_ratio'] = constrain_ratio
# handle constrain_navigation keyword
constrain_navigation = kwargs.pop('constrain_navigation', None)
if constrain_navigation is not None:
self.visual['constrain_navigation'] = constrain_navigation
# flag the other variables as to be updated
self.data_updating.update(**kwargs) | [
"def",
"set_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# handle compound variables",
"kwargs2",
"=",
"kwargs",
".",
"copy",
"(",
")",
"for",
"name",
",",
"data",
"in",
"kwargs2",
".",
"iteritems",
"(",
")",
":",
"variable",
"=",
"self",
".... | https://github.com/rossant/galry/blob/6201fa32fb5c9ef3cea700cc22caf52fb69ebe31/galry/glrenderer.py#L1164-L1236 | ||
alteryx/featuretools | d59e11082962f163540fd6e185901f65c506326a | featuretools/feature_base/feature_base.py | python | AggregationFeature.generate_name | (self) | return self.primitive.generate_name(base_feature_names=[bf.get_name() for bf in self.base_features],
relationship_path_name=self.relationship_path_name(),
parent_dataframe_name=self.parent_dataframe_name,
where_str=self._where_str(),
use_prev_str=self._use_prev_str()) | [] | def generate_name(self):
return self.primitive.generate_name(base_feature_names=[bf.get_name() for bf in self.base_features],
relationship_path_name=self.relationship_path_name(),
parent_dataframe_name=self.parent_dataframe_name,
where_str=self._where_str(),
use_prev_str=self._use_prev_str()) | [
"def",
"generate_name",
"(",
"self",
")",
":",
"return",
"self",
".",
"primitive",
".",
"generate_name",
"(",
"base_feature_names",
"=",
"[",
"bf",
".",
"get_name",
"(",
")",
"for",
"bf",
"in",
"self",
".",
"base_features",
"]",
",",
"relationship_path_name"... | https://github.com/alteryx/featuretools/blob/d59e11082962f163540fd6e185901f65c506326a/featuretools/feature_base/feature_base.py#L609-L614 | |||
samuelclay/NewsBlur | 2c45209df01a1566ea105e04d499367f32ac9ad2 | utils/S3.py | python | CommonPrefixEntry.__init | (self, prefix='') | [] | def __init(self, prefix=''):
self.prefix = prefix | [
"def",
"__init",
"(",
"self",
",",
"prefix",
"=",
"''",
")",
":",
"self",
".",
"prefix",
"=",
"prefix"
] | https://github.com/samuelclay/NewsBlur/blob/2c45209df01a1566ea105e04d499367f32ac9ad2/utils/S3.py#L434-L435 | ||||
liupengsay/2018-Tencent-social-advertising-algorithm-contest | 873694641ef17ea1bcc16eba67b4d296326361fd | 儿须成名酒须醉_v2/src/nffm_final_preliminary/utils.py | python | format_text | (words) | return b" ".join(words) | Convert a sequence words into sentence. | Convert a sequence words into sentence. | [
"Convert",
"a",
"sequence",
"words",
"into",
"sentence",
"."
] | def format_text(words):
"""Convert a sequence words into sentence."""
if (not hasattr(words, "__len__") and # for numpy array
not isinstance(words, collections.Iterable)):
words = [words]
return b" ".join(words) | [
"def",
"format_text",
"(",
"words",
")",
":",
"if",
"(",
"not",
"hasattr",
"(",
"words",
",",
"\"__len__\"",
")",
"and",
"# for numpy array",
"not",
"isinstance",
"(",
"words",
",",
"collections",
".",
"Iterable",
")",
")",
":",
"words",
"=",
"[",
"words... | https://github.com/liupengsay/2018-Tencent-social-advertising-algorithm-contest/blob/873694641ef17ea1bcc16eba67b4d296326361fd/儿须成名酒须醉_v2/src/nffm_final_preliminary/utils.py#L155-L160 | |
xiaobai1217/MBMD | 246f3434bccb9c8357e0f698995b659578bf1afb | lib/slim/datasets/build_imagenet_data.py | python | _is_png | (filename) | return 'n02105855_2933.JPEG' in filename | Determine if a file contains a PNG format image.
Args:
filename: string, path of the image file.
Returns:
boolean indicating if the image is a PNG. | Determine if a file contains a PNG format image. | [
"Determine",
"if",
"a",
"file",
"contains",
"a",
"PNG",
"format",
"image",
"."
] | def _is_png(filename):
"""Determine if a file contains a PNG format image.
Args:
filename: string, path of the image file.
Returns:
boolean indicating if the image is a PNG.
"""
# File list from:
# https://groups.google.com/forum/embed/?place=forum/torch7#!topic/torch7/fOSTXHIESSU
return 'n02105855_2933.JPEG' in filename | [
"def",
"_is_png",
"(",
"filename",
")",
":",
"# File list from:",
"# https://groups.google.com/forum/embed/?place=forum/torch7#!topic/torch7/fOSTXHIESSU",
"return",
"'n02105855_2933.JPEG'",
"in",
"filename"
] | https://github.com/xiaobai1217/MBMD/blob/246f3434bccb9c8357e0f698995b659578bf1afb/lib/slim/datasets/build_imagenet_data.py#L265-L276 | |
lightbulb-framework/lightbulb-framework | 9e8d6f37f28c784963dba3d726a0c8022a605baf | libs/models.py | python | SettingEntry.isDeleted | (self) | return self._deleted | Returns a boolean value indicating if record is deleted.
Args:
None
Returns:
Bool: Valude indicating if record is deleted. | Returns a boolean value indicating if record is deleted.
Args:
None
Returns:
Bool: Valude indicating if record is deleted. | [
"Returns",
"a",
"boolean",
"value",
"indicating",
"if",
"record",
"is",
"deleted",
".",
"Args",
":",
"None",
"Returns",
":",
"Bool",
":",
"Valude",
"indicating",
"if",
"record",
"is",
"deleted",
"."
] | def isDeleted(self):
"""
Returns a boolean value indicating if record is deleted.
Args:
None
Returns:
Bool: Valude indicating if record is deleted.
"""
return self._deleted | [
"def",
"isDeleted",
"(",
"self",
")",
":",
"return",
"self",
".",
"_deleted"
] | https://github.com/lightbulb-framework/lightbulb-framework/blob/9e8d6f37f28c784963dba3d726a0c8022a605baf/libs/models.py#L1266-L1274 | |
sagemath/sage | f9b2db94f675ff16963ccdefba4f1a3393b3fe0d | src/sage/combinat/root_system/pieri_factors.py | python | PieriFactors_type_A_affine.__init__ | (self, W, min_length, max_length, min_support, max_support) | r"""
INPUT:
- ``W`` -- a Weyl group of affine type `A`
- ``min_length``, ``max_length`` -- non negative integers
- ``min_support``, ``max_support`` -- subsets of the index set of `W`
EXAMPLES::
sage: PF = WeylGroup(["A", 3, 1]).pieri_factors(); PF
Pieri factors for Weyl Group of type ['A', 3, 1] (as a matrix group acting on the root space)
TESTS::
sage: PF = WeylGroup(['A',3,1]).pieri_factors()
sage: PF.__class__
<class 'sage.combinat.root_system.pieri_factors.PieriFactors_type_A_affine_with_category'>
sage: TestSuite(PF).run()
sage: PF = WeylGroup(['A',3,1]).pieri_factors(min_length = 3)
sage: [w.reduced_word() for w in PF]
[[2, 1, 0], [1, 0, 3], [0, 3, 2], [3, 2, 1]]
sage: PF = WeylGroup(['A',4,1]).pieri_factors(min_support = [0,2])
sage: [w.reduced_word() for w in PF]
[[2, 0], [2, 1, 0], [3, 2, 0], [0, 4, 2], [3, 2, 1, 0], [2, 1, 0, 4], [0, 4, 3, 2]]
sage: PF = WeylGroup(['A',5,1]).pieri_factors(min_support = [0,1,2], max_support = [0,1,2,3])
sage: [w.reduced_word() for w in PF]
[[2, 1, 0], [3, 2, 1, 0]]
sage: PF = WeylGroup(['A',5,1]).pieri_factors(min_length = 2, max_length = 5)
sage: PF.generating_series()
6*z^5 + 15*z^4 + 20*z^3 + 15*z^2 | r"""
INPUT: | [
"r",
"INPUT",
":"
] | def __init__(self, W, min_length, max_length, min_support, max_support):
r"""
INPUT:
- ``W`` -- a Weyl group of affine type `A`
- ``min_length``, ``max_length`` -- non negative integers
- ``min_support``, ``max_support`` -- subsets of the index set of `W`
EXAMPLES::
sage: PF = WeylGroup(["A", 3, 1]).pieri_factors(); PF
Pieri factors for Weyl Group of type ['A', 3, 1] (as a matrix group acting on the root space)
TESTS::
sage: PF = WeylGroup(['A',3,1]).pieri_factors()
sage: PF.__class__
<class 'sage.combinat.root_system.pieri_factors.PieriFactors_type_A_affine_with_category'>
sage: TestSuite(PF).run()
sage: PF = WeylGroup(['A',3,1]).pieri_factors(min_length = 3)
sage: [w.reduced_word() for w in PF]
[[2, 1, 0], [1, 0, 3], [0, 3, 2], [3, 2, 1]]
sage: PF = WeylGroup(['A',4,1]).pieri_factors(min_support = [0,2])
sage: [w.reduced_word() for w in PF]
[[2, 0], [2, 1, 0], [3, 2, 0], [0, 4, 2], [3, 2, 1, 0], [2, 1, 0, 4], [0, 4, 3, 2]]
sage: PF = WeylGroup(['A',5,1]).pieri_factors(min_support = [0,1,2], max_support = [0,1,2,3])
sage: [w.reduced_word() for w in PF]
[[2, 1, 0], [3, 2, 1, 0]]
sage: PF = WeylGroup(['A',5,1]).pieri_factors(min_length = 2, max_length = 5)
sage: PF.generating_series()
6*z^5 + 15*z^4 + 20*z^3 + 15*z^2
"""
Parent.__init__(self, category=FiniteEnumeratedSets())
self.W = W
self._min_support = frozenset(min_support)
self._max_support = frozenset(max_support)
if not self._min_support.issubset(self._max_support):
raise ValueError("the min support must be a subset "
"of the max support")
self._extra_support = self._max_support.difference(self._min_support)
self._min_length = min_length
self._max_length = max_length | [
"def",
"__init__",
"(",
"self",
",",
"W",
",",
"min_length",
",",
"max_length",
",",
"min_support",
",",
"max_support",
")",
":",
"Parent",
".",
"__init__",
"(",
"self",
",",
"category",
"=",
"FiniteEnumeratedSets",
"(",
")",
")",
"self",
".",
"W",
"=",
... | https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/combinat/root_system/pieri_factors.py#L546-L595 | ||
EmpireProject/EmPyre | c73854ed9d90d2bba1717d3fe6df758d18c20b8f | lib/common/stagers.py | python | Stagers.load_stagers | (self) | Load stagers from the install + "/lib/stagers/*" path | Load stagers from the install + "/lib/stagers/*" path | [
"Load",
"stagers",
"from",
"the",
"install",
"+",
"/",
"lib",
"/",
"stagers",
"/",
"*",
"path"
] | def load_stagers(self):
"""
Load stagers from the install + "/lib/stagers/*" path
"""
rootPath = self.installPath + 'lib/stagers/'
pattern = '*.py'
for root, dirs, files in os.walk(rootPath):
for filename in fnmatch.filter(files, pattern):
filePath = os.path.join(root, filename)
# extract just the module name from the full path
stagerName = filePath.split("/lib/stagers/")[-1][0:-3]
# instantiate the module and save it to the internal cache
self.stagers[stagerName] = imp.load_source(stagerName, filePath).Stager(self.mainMenu, []) | [
"def",
"load_stagers",
"(",
"self",
")",
":",
"rootPath",
"=",
"self",
".",
"installPath",
"+",
"'lib/stagers/'",
"pattern",
"=",
"'*.py'",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"rootPath",
")",
":",
"for",
"filename",
... | https://github.com/EmpireProject/EmPyre/blob/c73854ed9d90d2bba1717d3fe6df758d18c20b8f/lib/common/stagers.py#L49-L65 | ||
klen/graphite-beacon | c1f071e9f557693bc90f6acbc314994985dc3b77 | graphite_beacon/graphite.py | python | GraphiteRecord._values | (self, values) | [] | def _values(self, values):
for value in values:
try:
if self.ignore_nan and float(value) == self.default_nan_value:
continue
yield float(value)
except ValueError:
continue | [
"def",
"_values",
"(",
"self",
",",
"values",
")",
":",
"for",
"value",
"in",
"values",
":",
"try",
":",
"if",
"self",
".",
"ignore_nan",
"and",
"float",
"(",
"value",
")",
"==",
"self",
".",
"default_nan_value",
":",
"continue",
"yield",
"float",
"(",... | https://github.com/klen/graphite-beacon/blob/c1f071e9f557693bc90f6acbc314994985dc3b77/graphite_beacon/graphite.py#L20-L27 | ||||
wxWidgets/Phoenix | b2199e299a6ca6d866aa6f3d0888499136ead9d6 | wx/lib/agw/aui/framemanager.py | python | AuiManager.CreateNotebook | (self) | return notebook | Creates an automatic :class:`~wx.lib.agw.aui.auibook.AuiNotebook` when a pane is docked on
top of another pane. | Creates an automatic :class:`~wx.lib.agw.aui.auibook.AuiNotebook` when a pane is docked on
top of another pane. | [
"Creates",
"an",
"automatic",
":",
"class",
":",
"~wx",
".",
"lib",
".",
"agw",
".",
"aui",
".",
"auibook",
".",
"AuiNotebook",
"when",
"a",
"pane",
"is",
"docked",
"on",
"top",
"of",
"another",
"pane",
"."
] | def CreateNotebook(self):
"""
Creates an automatic :class:`~wx.lib.agw.aui.auibook.AuiNotebook` when a pane is docked on
top of another pane.
"""
notebook = auibook.AuiNotebook(self._frame, -1, wx.Point(0, 0), wx.Size(0, 0), agwStyle=self._autoNBStyle)
# This is so we can get the tab-drag event.
notebook.GetAuiManager().SetMasterManager(self)
notebook.SetArtProvider(self._autoNBTabArt.Clone())
self._notebooks.append(notebook)
return notebook | [
"def",
"CreateNotebook",
"(",
"self",
")",
":",
"notebook",
"=",
"auibook",
".",
"AuiNotebook",
"(",
"self",
".",
"_frame",
",",
"-",
"1",
",",
"wx",
".",
"Point",
"(",
"0",
",",
"0",
")",
",",
"wx",
".",
"Size",
"(",
"0",
",",
"0",
")",
",",
... | https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/agw/aui/framemanager.py#L4977-L4990 | |
googleads/google-ads-python | 2a1d6062221f6aad1992a6bcca0e7e4a93d2db86 | google/ads/googleads/v9/services/services/keyword_plan_ad_group_service/client.py | python | KeywordPlanAdGroupServiceClient.parse_common_project_path | (path: str) | return m.groupdict() if m else {} | Parse a project path into its component segments. | Parse a project path into its component segments. | [
"Parse",
"a",
"project",
"path",
"into",
"its",
"component",
"segments",
"."
] | def parse_common_project_path(path: str) -> Dict[str, str]:
"""Parse a project path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)$", path)
return m.groupdict() if m else {} | [
"def",
"parse_common_project_path",
"(",
"path",
":",
"str",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r\"^projects/(?P<project>.+?)$\"",
",",
"path",
")",
"return",
"m",
".",
"groupdict",
"(",
")",
"if",
... | https://github.com/googleads/google-ads-python/blob/2a1d6062221f6aad1992a6bcca0e7e4a93d2db86/google/ads/googleads/v9/services/services/keyword_plan_ad_group_service/client.py#L259-L262 | |
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit /scripts/sshbackdoors/rpyc/utils/helpers.py | python | _Async.__call__ | (self, *args, **kwargs) | return asyncreq(self.proxy, HANDLE_CALL, args, tuple(kwargs.items())) | [] | def __call__(self, *args, **kwargs):
return asyncreq(self.proxy, HANDLE_CALL, args, tuple(kwargs.items())) | [
"def",
"__call__",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"asyncreq",
"(",
"self",
".",
"proxy",
",",
"HANDLE_CALL",
",",
"args",
",",
"tuple",
"(",
"kwargs",
".",
"items",
"(",
")",
")",
")"
] | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit /scripts/sshbackdoors/rpyc/utils/helpers.py#L95-L96 | |||
joelgrus/data-science-from-scratch | d5d0f117f41b3ccab3b07f1ee1fa21cfcf69afa1 | scratch/deep_learning.py | python | is_1d | (tensor: Tensor) | return not isinstance(tensor[0], list) | If tensor[0] is a list, it's a higher-order tensor.
Otherwise, tensor is 1-dimensonal (that is, a vector). | If tensor[0] is a list, it's a higher-order tensor.
Otherwise, tensor is 1-dimensonal (that is, a vector). | [
"If",
"tensor",
"[",
"0",
"]",
"is",
"a",
"list",
"it",
"s",
"a",
"higher",
"-",
"order",
"tensor",
".",
"Otherwise",
"tensor",
"is",
"1",
"-",
"dimensonal",
"(",
"that",
"is",
"a",
"vector",
")",
"."
] | def is_1d(tensor: Tensor) -> bool:
"""
If tensor[0] is a list, it's a higher-order tensor.
Otherwise, tensor is 1-dimensonal (that is, a vector).
"""
return not isinstance(tensor[0], list) | [
"def",
"is_1d",
"(",
"tensor",
":",
"Tensor",
")",
"->",
"bool",
":",
"return",
"not",
"isinstance",
"(",
"tensor",
"[",
"0",
"]",
",",
"list",
")"
] | https://github.com/joelgrus/data-science-from-scratch/blob/d5d0f117f41b3ccab3b07f1ee1fa21cfcf69afa1/scratch/deep_learning.py#L15-L20 | |
mongodb/mongo-python-driver | c760f900f2e4109a247c2ffc8ad3549362007772 | pymongo/topology_description.py | python | TopologyDescription.has_readable_server | (self, read_preference=ReadPreference.PRIMARY) | return any(self.apply_selector(read_preference)) | Does this topology have any readable servers available matching the
given read preference?
:Parameters:
- `read_preference`: an instance of a read preference from
:mod:`~pymongo.read_preferences`. Defaults to
:attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`.
.. note:: When connected directly to a single server this method
always returns ``True``.
.. versionadded:: 3.4 | Does this topology have any readable servers available matching the
given read preference? | [
"Does",
"this",
"topology",
"have",
"any",
"readable",
"servers",
"available",
"matching",
"the",
"given",
"read",
"preference?"
] | def has_readable_server(self, read_preference=ReadPreference.PRIMARY):
"""Does this topology have any readable servers available matching the
given read preference?
:Parameters:
- `read_preference`: an instance of a read preference from
:mod:`~pymongo.read_preferences`. Defaults to
:attr:`~pymongo.read_preferences.ReadPreference.PRIMARY`.
.. note:: When connected directly to a single server this method
always returns ``True``.
.. versionadded:: 3.4
"""
common.validate_read_preference("read_preference", read_preference)
return any(self.apply_selector(read_preference)) | [
"def",
"has_readable_server",
"(",
"self",
",",
"read_preference",
"=",
"ReadPreference",
".",
"PRIMARY",
")",
":",
"common",
".",
"validate_read_preference",
"(",
"\"read_preference\"",
",",
"read_preference",
")",
"return",
"any",
"(",
"self",
".",
"apply_selector... | https://github.com/mongodb/mongo-python-driver/blob/c760f900f2e4109a247c2ffc8ad3549362007772/pymongo/topology_description.py#L291-L306 | |
FrancescoCeruti/linux-show-player | 39aba4674d9a2caa365687906640d192e2b47e0f | lisp/modules/gst_backend/gst_element.py | python | GstMediaElement.dispose | (self) | Clean up the element | Clean up the element | [
"Clean",
"up",
"the",
"element"
] | def dispose(self):
"""Clean up the element""" | [
"def",
"dispose",
"(",
"self",
")",
":"
] | https://github.com/FrancescoCeruti/linux-show-player/blob/39aba4674d9a2caa365687906640d192e2b47e0f/lisp/modules/gst_backend/gst_element.py#L80-L81 | ||
jmcnamara/XlsxWriter | fd30f221bf4326ca7814cec0d3a87a89b9e3edd5 | xlsxwriter/utility.py | python | quote_sheetname | (sheetname) | return sheetname | Convert a worksheet name to a quoted name if it contains spaces or
special characters.
Args:
sheetname: The worksheet name. String.
Returns:
A quoted worksheet string. | Convert a worksheet name to a quoted name if it contains spaces or
special characters. | [
"Convert",
"a",
"worksheet",
"name",
"to",
"a",
"quoted",
"name",
"if",
"it",
"contains",
"spaces",
"or",
"special",
"characters",
"."
] | def quote_sheetname(sheetname):
"""
Convert a worksheet name to a quoted name if it contains spaces or
special characters.
Args:
sheetname: The worksheet name. String.
Returns:
A quoted worksheet string.
"""
# TODO. Possibly extend this to quote sheetnames that look like ranges.
if not sheetname.isalnum() and not sheetname.startswith("'"):
# Double quote any single quotes.
sheetname = sheetname.replace("'", "''")
# Single quote the sheet name.
sheetname = "'%s'" % sheetname
return sheetname | [
"def",
"quote_sheetname",
"(",
"sheetname",
")",
":",
"# TODO. Possibly extend this to quote sheetnames that look like ranges.",
"if",
"not",
"sheetname",
".",
"isalnum",
"(",
")",
"and",
"not",
"sheetname",
".",
"startswith",
"(",
"\"'\"",
")",
":",
"# Double quote any... | https://github.com/jmcnamara/XlsxWriter/blob/fd30f221bf4326ca7814cec0d3a87a89b9e3edd5/xlsxwriter/utility.py#L266-L287 | |
Lattyware/unrpa | 005b10abec590db374f23fd8d4b111963792a15a | unrpa/versions/version.py | python | Version.postprocess | (self, source: ArchiveView, sink: BinaryIO) | Allows postprocessing over the data extracted from the archive. | Allows postprocessing over the data extracted from the archive. | [
"Allows",
"postprocessing",
"over",
"the",
"data",
"extracted",
"from",
"the",
"archive",
"."
] | def postprocess(self, source: ArchiveView, sink: BinaryIO) -> None:
"""Allows postprocessing over the data extracted from the archive."""
for segment in iter(source.read1, b""):
sink.write(segment) | [
"def",
"postprocess",
"(",
"self",
",",
"source",
":",
"ArchiveView",
",",
"sink",
":",
"BinaryIO",
")",
"->",
"None",
":",
"for",
"segment",
"in",
"iter",
"(",
"source",
".",
"read1",
",",
"b\"\"",
")",
":",
"sink",
".",
"write",
"(",
"segment",
")"... | https://github.com/Lattyware/unrpa/blob/005b10abec590db374f23fd8d4b111963792a15a/unrpa/versions/version.py#L22-L25 | ||
openshift/openshift-tools | 1188778e728a6e4781acf728123e5b356380fe6f | openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_env.py | python | locate_oc_binary | () | return oc_binary | Find and return oc binary file | Find and return oc binary file | [
"Find",
"and",
"return",
"oc",
"binary",
"file"
] | def locate_oc_binary():
''' Find and return oc binary file '''
# https://github.com/openshift/openshift-ansible/issues/3410
# oc can be in /usr/local/bin in some cases, but that may not
# be in $PATH due to ansible/sudo
paths = os.environ.get("PATH", os.defpath).split(os.pathsep) + ADDITIONAL_PATH_LOOKUPS
oc_binary = 'oc'
# Use shutil.which if it is available, otherwise fallback to a naive path search
try:
which_result = shutil.which(oc_binary, path=os.pathsep.join(paths))
if which_result is not None:
oc_binary = which_result
except AttributeError:
for path in paths:
if os.path.exists(os.path.join(path, oc_binary)):
oc_binary = os.path.join(path, oc_binary)
break
return oc_binary | [
"def",
"locate_oc_binary",
"(",
")",
":",
"# https://github.com/openshift/openshift-ansible/issues/3410",
"# oc can be in /usr/local/bin in some cases, but that may not",
"# be in $PATH due to ansible/sudo",
"paths",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"PATH\"",
",",
"o... | https://github.com/openshift/openshift-tools/blob/1188778e728a6e4781acf728123e5b356380fe6f/openshift/installer/vendored/openshift-ansible-3.10.0-0.29.0/roles/lib_vendored_deps/library/oc_env.py#L859-L879 | |
blackye/webdirdig | 11eb3df84d228127dde1dd4afcb922f5075903a2 | thirdparty_libs/requests/sessions.py | python | Session.close | (self) | Closes all adapters and as such the session | Closes all adapters and as such the session | [
"Closes",
"all",
"adapters",
"and",
"as",
"such",
"the",
"session"
] | def close(self):
"""Closes all adapters and as such the session"""
for _, v in self.adapters.items():
v.close() | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"_",
",",
"v",
"in",
"self",
".",
"adapters",
".",
"items",
"(",
")",
":",
"v",
".",
"close",
"(",
")"
] | https://github.com/blackye/webdirdig/blob/11eb3df84d228127dde1dd4afcb922f5075903a2/thirdparty_libs/requests/sessions.py#L501-L504 | ||
omz/PythonistaAppTemplate | f560f93f8876d82a21d108977f90583df08d55af | PythonistaAppTemplate/PythonistaKit.framework/pylib/ast.py | python | walk | (node) | Recursively yield all descendant nodes in the tree starting at *node*
(including *node* itself), in no specified order. This is useful if you
only want to modify nodes in place and don't care about the context. | Recursively yield all descendant nodes in the tree starting at *node*
(including *node* itself), in no specified order. This is useful if you
only want to modify nodes in place and don't care about the context. | [
"Recursively",
"yield",
"all",
"descendant",
"nodes",
"in",
"the",
"tree",
"starting",
"at",
"*",
"node",
"*",
"(",
"including",
"*",
"node",
"*",
"itself",
")",
"in",
"no",
"specified",
"order",
".",
"This",
"is",
"useful",
"if",
"you",
"only",
"want",
... | def walk(node):
"""
Recursively yield all descendant nodes in the tree starting at *node*
(including *node* itself), in no specified order. This is useful if you
only want to modify nodes in place and don't care about the context.
"""
from collections import deque
todo = deque([node])
while todo:
node = todo.popleft()
todo.extend(iter_child_nodes(node))
yield node | [
"def",
"walk",
"(",
"node",
")",
":",
"from",
"collections",
"import",
"deque",
"todo",
"=",
"deque",
"(",
"[",
"node",
"]",
")",
"while",
"todo",
":",
"node",
"=",
"todo",
".",
"popleft",
"(",
")",
"todo",
".",
"extend",
"(",
"iter_child_nodes",
"("... | https://github.com/omz/PythonistaAppTemplate/blob/f560f93f8876d82a21d108977f90583df08d55af/PythonistaAppTemplate/PythonistaKit.framework/pylib/ast.py#L203-L214 | ||
Zardinality/TF_Deformable_Net | 00c86380fd2725ebe7ae22f41d460ffc0bca378d | lib/networks/network.py | python | Network.psroi_pool | (self, input, output_dim, group_size, spatial_scale, name) | return psroi_pooling_op.psroi_pool(input[0], input[1],
output_dim=output_dim,
group_size=group_size,
spatial_scale=spatial_scale,
name=name)[0] | contribution by miraclebiu | contribution by miraclebiu | [
"contribution",
"by",
"miraclebiu"
] | def psroi_pool(self, input, output_dim, group_size, spatial_scale, name):
"""contribution by miraclebiu"""
# only use the first input
if isinstance(input[0], tuple):
input[0] = input[0][0]
if isinstance(input[1], tuple):
input[1] = input[1][0]
return psroi_pooling_op.psroi_pool(input[0], input[1],
output_dim=output_dim,
group_size=group_size,
spatial_scale=spatial_scale,
name=name)[0] | [
"def",
"psroi_pool",
"(",
"self",
",",
"input",
",",
"output_dim",
",",
"group_size",
",",
"spatial_scale",
",",
"name",
")",
":",
"# only use the first input",
"if",
"isinstance",
"(",
"input",
"[",
"0",
"]",
",",
"tuple",
")",
":",
"input",
"[",
"0",
"... | https://github.com/Zardinality/TF_Deformable_Net/blob/00c86380fd2725ebe7ae22f41d460ffc0bca378d/lib/networks/network.py#L286-L299 | |
mdiazcl/fuzzbunch-debian | 2b76c2249ade83a389ae3badb12a1bd09901fd2c | windows/exploits/ZIBE/pyreadline/lineeditor/history.py | python | LineHistory.history_search_forward | (self, partial) | return q | u'''Search forward through the history for the string of characters
between the start of the current line and the point. This is a
non-incremental search. By default, this command is unbound. | u'''Search forward through the history for the string of characters
between the start of the current line and the point. This is a
non-incremental search. By default, this command is unbound. | [
"u",
"Search",
"forward",
"through",
"the",
"history",
"for",
"the",
"string",
"of",
"characters",
"between",
"the",
"start",
"of",
"the",
"current",
"line",
"and",
"the",
"point",
".",
"This",
"is",
"a",
"non",
"-",
"incremental",
"search",
".",
"By",
"... | def history_search_forward(self, partial): # ()
u'''Search forward through the history for the string of characters
between the start of the current line and the point. This is a
non-incremental search. By default, this command is unbound.'''
q= self._search(1, partial)
return q | [
"def",
"history_search_forward",
"(",
"self",
",",
"partial",
")",
":",
"# ()",
"q",
"=",
"self",
".",
"_search",
"(",
"1",
",",
"partial",
")",
"return",
"q"
] | https://github.com/mdiazcl/fuzzbunch-debian/blob/2b76c2249ade83a389ae3badb12a1bd09901fd2c/windows/exploits/ZIBE/pyreadline/lineeditor/history.py#L237-L242 | |
facebookresearch/video-long-term-feature-banks | 941b71303ca6a60ea6561eb883a77fa1733bb615 | tools/lfb_loader.py | python | get_features | (feature_name) | return features | Get features from all GPUs given name. | Get features from all GPUs given name. | [
"Get",
"features",
"from",
"all",
"GPUs",
"given",
"name",
"."
] | def get_features(feature_name):
"""Get features from all GPUs given name."""
features = []
for idx in range(cfg.ROOT_GPU_ID, cfg.ROOT_GPU_ID + cfg.NUM_GPUS):
features.append(workspace.FetchBlob(
'gpu_{}/{}'.format(idx, feature_name)))
return features | [
"def",
"get_features",
"(",
"feature_name",
")",
":",
"features",
"=",
"[",
"]",
"for",
"idx",
"in",
"range",
"(",
"cfg",
".",
"ROOT_GPU_ID",
",",
"cfg",
".",
"ROOT_GPU_ID",
"+",
"cfg",
".",
"NUM_GPUS",
")",
":",
"features",
".",
"append",
"(",
"worksp... | https://github.com/facebookresearch/video-long-term-feature-banks/blob/941b71303ca6a60ea6561eb883a77fa1733bb615/tools/lfb_loader.py#L42-L48 | |
zhl2008/awd-platform | 0416b31abea29743387b10b3914581fbe8e7da5e | web_hxb2/lib/python3.5/site-packages/wagtail_bak/utils/compat.py | python | user_is_authenticated | (user) | [] | def user_is_authenticated(user):
if django.VERSION >= (1, 10):
return user.is_authenticated
else:
return user.is_authenticated() | [
"def",
"user_is_authenticated",
"(",
"user",
")",
":",
"if",
"django",
".",
"VERSION",
">=",
"(",
"1",
",",
"10",
")",
":",
"return",
"user",
".",
"is_authenticated",
"else",
":",
"return",
"user",
".",
"is_authenticated",
"(",
")"
] | https://github.com/zhl2008/awd-platform/blob/0416b31abea29743387b10b3914581fbe8e7da5e/web_hxb2/lib/python3.5/site-packages/wagtail_bak/utils/compat.py#L6-L10 | ||||
pantsbuild/pex | 473c6ac732ed4bc338b4b20a9ec930d1d722c9b4 | pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/_structures.py | python | NegativeInfinity.__repr__ | (self) | return "-Infinity" | [] | def __repr__(self):
return "-Infinity" | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"\"-Infinity\""
] | https://github.com/pantsbuild/pex/blob/473c6ac732ed4bc338b4b20a9ec930d1d722c9b4/pex/vendor/_vendored/setuptools/pkg_resources/_vendor/packaging/_structures.py#L41-L42 | |||
krintoxi/NoobSec-Toolkit | 38738541cbc03cedb9a3b3ed13b629f781ad64f6 | NoobSecToolkit - MAC OSX/tools/inject/plugins/dbms/firebird/fingerprint.py | python | Fingerprint.__init__ | (self) | [] | def __init__(self):
GenericFingerprint.__init__(self, DBMS.FIREBIRD) | [
"def",
"__init__",
"(",
"self",
")",
":",
"GenericFingerprint",
".",
"__init__",
"(",
"self",
",",
"DBMS",
".",
"FIREBIRD",
")"
] | https://github.com/krintoxi/NoobSec-Toolkit/blob/38738541cbc03cedb9a3b3ed13b629f781ad64f6/NoobSecToolkit - MAC OSX/tools/inject/plugins/dbms/firebird/fingerprint.py#L26-L27 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.