id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
248,400 | dariosky/wfcli | wfcli/tossl.py | WebfactionWebsiteToSsl.create_le_verification_app | def create_le_verification_app(self):
""" Create the let's encrypt app to verify the ownership of the domain """
if self.LETSENCRYPT_VERIFY_APP_NAME in self._apps:
logger.debug(
"The LE verification APP already exists as %s" % self.LETSENCRYPT_VERIFY_APP_NAME
)
... | python | def create_le_verification_app(self):
""" Create the let's encrypt app to verify the ownership of the domain """
if self.LETSENCRYPT_VERIFY_APP_NAME in self._apps:
logger.debug(
"The LE verification APP already exists as %s" % self.LETSENCRYPT_VERIFY_APP_NAME
)
... | [
"def",
"create_le_verification_app",
"(",
"self",
")",
":",
"if",
"self",
".",
"LETSENCRYPT_VERIFY_APP_NAME",
"in",
"self",
".",
"_apps",
":",
"logger",
".",
"debug",
"(",
"\"The LE verification APP already exists as %s\"",
"%",
"self",
".",
"LETSENCRYPT_VERIFY_APP_NAME... | Create the let's encrypt app to verify the ownership of the domain | [
"Create",
"the",
"let",
"s",
"encrypt",
"app",
"to",
"verify",
"the",
"ownership",
"of",
"the",
"domain"
] | 87a9ed30dbd456f801135a55099f0541b0614ccb | https://github.com/dariosky/wfcli/blob/87a9ed30dbd456f801135a55099f0541b0614ccb/wfcli/tossl.py#L239-L263 |
248,401 | dariosky/wfcli | wfcli/tossl.py | WebfactionWebsiteToSsl.sync_certificates | def sync_certificates(self, subdomains=None):
""" Check all certificates available in acme in the host
and sync them with the webfaction certificates
"""
result = run(".acme.sh/acme.sh --list", quiet=True)
logger.info("Syncing Webfaction certificates")
for acme_certif... | python | def sync_certificates(self, subdomains=None):
""" Check all certificates available in acme in the host
and sync them with the webfaction certificates
"""
result = run(".acme.sh/acme.sh --list", quiet=True)
logger.info("Syncing Webfaction certificates")
for acme_certif... | [
"def",
"sync_certificates",
"(",
"self",
",",
"subdomains",
"=",
"None",
")",
":",
"result",
"=",
"run",
"(",
"\".acme.sh/acme.sh --list\"",
",",
"quiet",
"=",
"True",
")",
"logger",
".",
"info",
"(",
"\"Syncing Webfaction certificates\"",
")",
"for",
"acme_cert... | Check all certificates available in acme in the host
and sync them with the webfaction certificates | [
"Check",
"all",
"certificates",
"available",
"in",
"acme",
"in",
"the",
"host",
"and",
"sync",
"them",
"with",
"the",
"webfaction",
"certificates"
] | 87a9ed30dbd456f801135a55099f0541b0614ccb | https://github.com/dariosky/wfcli/blob/87a9ed30dbd456f801135a55099f0541b0614ccb/wfcli/tossl.py#L323-L362 |
248,402 | dariosky/wfcli | wfcli/tossl.py | WebfactionWebsiteToSsl.get_remote_content | def get_remote_content(filepath):
""" A handy wrapper to get a remote file content """
with hide('running'):
temp = BytesIO()
get(filepath, temp)
content = temp.getvalue().decode('utf-8')
return content.strip() | python | def get_remote_content(filepath):
""" A handy wrapper to get a remote file content """
with hide('running'):
temp = BytesIO()
get(filepath, temp)
content = temp.getvalue().decode('utf-8')
return content.strip() | [
"def",
"get_remote_content",
"(",
"filepath",
")",
":",
"with",
"hide",
"(",
"'running'",
")",
":",
"temp",
"=",
"BytesIO",
"(",
")",
"get",
"(",
"filepath",
",",
"temp",
")",
"content",
"=",
"temp",
".",
"getvalue",
"(",
")",
".",
"decode",
"(",
"'u... | A handy wrapper to get a remote file content | [
"A",
"handy",
"wrapper",
"to",
"get",
"a",
"remote",
"file",
"content"
] | 87a9ed30dbd456f801135a55099f0541b0614ccb | https://github.com/dariosky/wfcli/blob/87a9ed30dbd456f801135a55099f0541b0614ccb/wfcli/tossl.py#L365-L371 |
248,403 | dariosky/wfcli | wfcli/tossl.py | WebfactionWebsiteToSsl.get_main_domain | def get_main_domain(self, website):
""" Given a list of subdomains, return the main domain of them
If the subdomain are across multiple domain, then we cannot have a single website
it should be splitted
"""
subdomains = website['subdomains']
main_domains = set()
... | python | def get_main_domain(self, website):
""" Given a list of subdomains, return the main domain of them
If the subdomain are across multiple domain, then we cannot have a single website
it should be splitted
"""
subdomains = website['subdomains']
main_domains = set()
... | [
"def",
"get_main_domain",
"(",
"self",
",",
"website",
")",
":",
"subdomains",
"=",
"website",
"[",
"'subdomains'",
"]",
"main_domains",
"=",
"set",
"(",
")",
"for",
"sub",
"in",
"subdomains",
":",
"for",
"d",
"in",
"self",
".",
"_domains",
":",
"if",
... | Given a list of subdomains, return the main domain of them
If the subdomain are across multiple domain, then we cannot have a single website
it should be splitted | [
"Given",
"a",
"list",
"of",
"subdomains",
"return",
"the",
"main",
"domain",
"of",
"them",
"If",
"the",
"subdomain",
"are",
"across",
"multiple",
"domain",
"then",
"we",
"cannot",
"have",
"a",
"single",
"website",
"it",
"should",
"be",
"splitted"
] | 87a9ed30dbd456f801135a55099f0541b0614ccb | https://github.com/dariosky/wfcli/blob/87a9ed30dbd456f801135a55099f0541b0614ccb/wfcli/tossl.py#L404-L422 |
248,404 | ryanjdillon/pyotelem | pyotelem/glides.py | get_stroke_freq | def get_stroke_freq(Ax, Az, fs_a, nperseg, peak_thresh, stroke_ratio=None):
'''Determine stroke frequency to use as a cutoff for filtering
Args
----
Ax: numpy.ndarray, shape (n,)
x-axis accelermeter data (longitudinal)
Ay: numpy.ndarray, shape (n,)
x-axis accelermeter data (lateral)... | python | def get_stroke_freq(Ax, Az, fs_a, nperseg, peak_thresh, stroke_ratio=None):
'''Determine stroke frequency to use as a cutoff for filtering
Args
----
Ax: numpy.ndarray, shape (n,)
x-axis accelermeter data (longitudinal)
Ay: numpy.ndarray, shape (n,)
x-axis accelermeter data (lateral)... | [
"def",
"get_stroke_freq",
"(",
"Ax",
",",
"Az",
",",
"fs_a",
",",
"nperseg",
",",
"peak_thresh",
",",
"stroke_ratio",
"=",
"None",
")",
":",
"import",
"numpy",
"from",
".",
"import",
"dsp",
"from",
".",
"import",
"utils",
"from",
".",
"plots",
"import",
... | Determine stroke frequency to use as a cutoff for filtering
Args
----
Ax: numpy.ndarray, shape (n,)
x-axis accelermeter data (longitudinal)
Ay: numpy.ndarray, shape (n,)
x-axis accelermeter data (lateral)
Az: numpy.ndarray, shape (n,)
z-axis accelermeter data (dorso-ventral)... | [
"Determine",
"stroke",
"frequency",
"to",
"use",
"as",
"a",
"cutoff",
"for",
"filtering"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/glides.py#L2-L104 |
248,405 | ryanjdillon/pyotelem | pyotelem/glides.py | get_stroke_glide_indices | def get_stroke_glide_indices(A_g_hf, fs_a, J, t_max):
'''Get stroke and glide indices from high-pass accelerometer data
Args
----
A_g_hf: 1-D ndarray
Animal frame triaxial accelerometer matrix at sampling rate fs_a.
fs_a: int
Number of accelerometer samples per second
J: float... | python | def get_stroke_glide_indices(A_g_hf, fs_a, J, t_max):
'''Get stroke and glide indices from high-pass accelerometer data
Args
----
A_g_hf: 1-D ndarray
Animal frame triaxial accelerometer matrix at sampling rate fs_a.
fs_a: int
Number of accelerometer samples per second
J: float... | [
"def",
"get_stroke_glide_indices",
"(",
"A_g_hf",
",",
"fs_a",
",",
"J",
",",
"t_max",
")",
":",
"import",
"numpy",
"from",
".",
"import",
"dsp",
"# Check if input array is 1-D",
"if",
"A_g_hf",
".",
"ndim",
">",
"1",
":",
"raise",
"IndexError",
"(",
"'A_g_h... | Get stroke and glide indices from high-pass accelerometer data
Args
----
A_g_hf: 1-D ndarray
Animal frame triaxial accelerometer matrix at sampling rate fs_a.
fs_a: int
Number of accelerometer samples per second
J: float
Frequency threshold for detecting a fluke stroke in ... | [
"Get",
"stroke",
"and",
"glide",
"indices",
"from",
"high",
"-",
"pass",
"accelerometer",
"data"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/glides.py#L107-L185 |
248,406 | mikejarrett/pipcheck | pipcheck/checker.py | Checker.get_updates | def get_updates(
self,
display_all_distributions=False,
verbose=False
): # pragma: no cover
"""
When called, get the environment updates and write updates to a CSV
file and if a new config has been provided, write a new configuration
file.
Args:
... | python | def get_updates(
self,
display_all_distributions=False,
verbose=False
): # pragma: no cover
"""
When called, get the environment updates and write updates to a CSV
file and if a new config has been provided, write a new configuration
file.
Args:
... | [
"def",
"get_updates",
"(",
"self",
",",
"display_all_distributions",
"=",
"False",
",",
"verbose",
"=",
"False",
")",
":",
"# pragma: no cover",
"if",
"verbose",
":",
"logging",
".",
"basicConfig",
"(",
"stream",
"=",
"sys",
".",
"stdout",
",",
"level",
"=",... | When called, get the environment updates and write updates to a CSV
file and if a new config has been provided, write a new configuration
file.
Args:
display_all_distributions (bool): Return distribution even if it is
up-to-date.
verbose (bool): If ``True... | [
"When",
"called",
"get",
"the",
"environment",
"updates",
"and",
"write",
"updates",
"to",
"a",
"CSV",
"file",
"and",
"if",
"a",
"new",
"config",
"has",
"been",
"provided",
"write",
"a",
"new",
"configuration",
"file",
"."
] | 2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/checker.py#L34-L71 |
248,407 | mikejarrett/pipcheck | pipcheck/checker.py | Checker.csv_writer | def csv_writer(csvfile):
""" Get a CSV writer for the version of python that is being run. """
if sys.version_info >= (3,):
writer = csv.writer(csvfile, delimiter=',', lineterminator='\n')
else:
writer = csv.writer(csvfile, delimiter=b',', lineterminator='\n')
re... | python | def csv_writer(csvfile):
""" Get a CSV writer for the version of python that is being run. """
if sys.version_info >= (3,):
writer = csv.writer(csvfile, delimiter=',', lineterminator='\n')
else:
writer = csv.writer(csvfile, delimiter=b',', lineterminator='\n')
re... | [
"def",
"csv_writer",
"(",
"csvfile",
")",
":",
"if",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
")",
":",
"writer",
"=",
"csv",
".",
"writer",
"(",
"csvfile",
",",
"delimiter",
"=",
"','",
",",
"lineterminator",
"=",
"'\\n'",
")",
"else",
":",
... | Get a CSV writer for the version of python that is being run. | [
"Get",
"a",
"CSV",
"writer",
"for",
"the",
"version",
"of",
"python",
"that",
"is",
"being",
"run",
"."
] | 2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/checker.py#L74-L81 |
248,408 | mikejarrett/pipcheck | pipcheck/checker.py | Checker.write_updates_to_csv | def write_updates_to_csv(self, updates):
"""
Given a list of updates, write the updates out to the provided CSV
file.
Args:
updates (list): List of Update objects.
"""
with open(self._csv_file_name, 'w') as csvfile:
csvwriter = self.csv_writer(csv... | python | def write_updates_to_csv(self, updates):
"""
Given a list of updates, write the updates out to the provided CSV
file.
Args:
updates (list): List of Update objects.
"""
with open(self._csv_file_name, 'w') as csvfile:
csvwriter = self.csv_writer(csv... | [
"def",
"write_updates_to_csv",
"(",
"self",
",",
"updates",
")",
":",
"with",
"open",
"(",
"self",
".",
"_csv_file_name",
",",
"'w'",
")",
"as",
"csvfile",
":",
"csvwriter",
"=",
"self",
".",
"csv_writer",
"(",
"csvfile",
")",
"csvwriter",
".",
"writerow",... | Given a list of updates, write the updates out to the provided CSV
file.
Args:
updates (list): List of Update objects. | [
"Given",
"a",
"list",
"of",
"updates",
"write",
"the",
"updates",
"out",
"to",
"the",
"provided",
"CSV",
"file",
"."
] | 2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/checker.py#L83-L102 |
248,409 | mikejarrett/pipcheck | pipcheck/checker.py | Checker.write_new_config | def write_new_config(self, updates):
"""
Given a list of updates, write the updates out to the provided
configuartion file.
Args:
updates (list): List of Update objects.
"""
with open(self._new_config, 'w') as config_file:
for update in updates:
... | python | def write_new_config(self, updates):
"""
Given a list of updates, write the updates out to the provided
configuartion file.
Args:
updates (list): List of Update objects.
"""
with open(self._new_config, 'w') as config_file:
for update in updates:
... | [
"def",
"write_new_config",
"(",
"self",
",",
"updates",
")",
":",
"with",
"open",
"(",
"self",
".",
"_new_config",
",",
"'w'",
")",
"as",
"config_file",
":",
"for",
"update",
"in",
"updates",
":",
"line",
"=",
"'{0}=={1} # The installed version is: {2}\\n'",
... | Given a list of updates, write the updates out to the provided
configuartion file.
Args:
updates (list): List of Update objects. | [
"Given",
"a",
"list",
"of",
"updates",
"write",
"the",
"updates",
"out",
"to",
"the",
"provided",
"configuartion",
"file",
"."
] | 2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/checker.py#L104-L120 |
248,410 | mikejarrett/pipcheck | pipcheck/checker.py | Checker._get_environment_updates | def _get_environment_updates(self, display_all_distributions=False):
"""
Check all pacakges installed in the environment to see if there are
any updates availalble.
Args:
display_all_distributions (bool): Return distribution even if it is
up-to-date. Defaults... | python | def _get_environment_updates(self, display_all_distributions=False):
"""
Check all pacakges installed in the environment to see if there are
any updates availalble.
Args:
display_all_distributions (bool): Return distribution even if it is
up-to-date. Defaults... | [
"def",
"_get_environment_updates",
"(",
"self",
",",
"display_all_distributions",
"=",
"False",
")",
":",
"updates",
"=",
"[",
"]",
"for",
"distribution",
"in",
"self",
".",
"pip",
".",
"get_installed_distributions",
"(",
")",
":",
"versions",
"=",
"self",
"."... | Check all pacakges installed in the environment to see if there are
any updates availalble.
Args:
display_all_distributions (bool): Return distribution even if it is
up-to-date. Defaults to ``False``.
Returns:
list: A list of Update objects ordered based... | [
"Check",
"all",
"pacakges",
"installed",
"in",
"the",
"environment",
"to",
"see",
"if",
"there",
"are",
"any",
"updates",
"availalble",
"."
] | 2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/checker.py#L122-L170 |
248,411 | mikejarrett/pipcheck | pipcheck/checker.py | Checker.get_available_versions | def get_available_versions(self, project_name):
""" Query PyPI to see if package has any available versions.
Args:
project_name (str): The name the project on PyPI.
Returns:
dict: Where keys are tuples of parsed versions and values are the
versions retur... | python | def get_available_versions(self, project_name):
""" Query PyPI to see if package has any available versions.
Args:
project_name (str): The name the project on PyPI.
Returns:
dict: Where keys are tuples of parsed versions and values are the
versions retur... | [
"def",
"get_available_versions",
"(",
"self",
",",
"project_name",
")",
":",
"available_versions",
"=",
"self",
".",
"pypi_client",
".",
"package_releases",
"(",
"project_name",
")",
"if",
"not",
"available_versions",
":",
"available_versions",
"=",
"self",
".",
"... | Query PyPI to see if package has any available versions.
Args:
project_name (str): The name the project on PyPI.
Returns:
dict: Where keys are tuples of parsed versions and values are the
versions returned by PyPI. | [
"Query",
"PyPI",
"to",
"see",
"if",
"package",
"has",
"any",
"available",
"versions",
"."
] | 2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/checker.py#L172-L193 |
248,412 | mikejarrett/pipcheck | pipcheck/checker.py | Checker._parse_version | def _parse_version(version):
""" Parse a version string.
Args:
version (str): A string representing a version e.g. '1.9rc2'
Returns:
tuple: major, minor, patch parts cast as integer and whether or not
it was a pre-release version.
"""
par... | python | def _parse_version(version):
""" Parse a version string.
Args:
version (str): A string representing a version e.g. '1.9rc2'
Returns:
tuple: major, minor, patch parts cast as integer and whether or not
it was a pre-release version.
"""
par... | [
"def",
"_parse_version",
"(",
"version",
")",
":",
"parsed_version",
"=",
"parse_version",
"(",
"version",
")",
"return",
"tuple",
"(",
"int",
"(",
"dot_version",
")",
"for",
"dot_version",
"in",
"parsed_version",
".",
"base_version",
".",
"split",
"(",
"'.'",... | Parse a version string.
Args:
version (str): A string representing a version e.g. '1.9rc2'
Returns:
tuple: major, minor, patch parts cast as integer and whether or not
it was a pre-release version. | [
"Parse",
"a",
"version",
"string",
"."
] | 2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad | https://github.com/mikejarrett/pipcheck/blob/2ff47b9fd8914e1764c6e659ef39b77c1b1a12ad/pipcheck/checker.py#L196-L210 |
248,413 | Carreau/insupportable | insupportable/insupportable.py | S.support | def support(self, version):
"""
return `True` if current python version match version passed.
raise a deprecation warning if only PY2 or PY3 is supported as you probably
have a conditional that should be removed.
"""
if not self._known_version(version):
... | python | def support(self, version):
"""
return `True` if current python version match version passed.
raise a deprecation warning if only PY2 or PY3 is supported as you probably
have a conditional that should be removed.
"""
if not self._known_version(version):
... | [
"def",
"support",
"(",
"self",
",",
"version",
")",
":",
"if",
"not",
"self",
".",
"_known_version",
"(",
"version",
")",
":",
"warn",
"(",
"\"unknown feature: %s\"",
"%",
"version",
")",
"return",
"True",
"else",
":",
"if",
"not",
"self",
".",
"_get_fea... | return `True` if current python version match version passed.
raise a deprecation warning if only PY2 or PY3 is supported as you probably
have a conditional that should be removed. | [
"return",
"True",
"if",
"current",
"python",
"version",
"match",
"version",
"passed",
".",
"raise",
"a",
"deprecation",
"warning",
"if",
"only",
"PY2",
"or",
"PY3",
"is",
"supported",
"as",
"you",
"probably",
"have",
"a",
"conditional",
"that",
"should",
"be... | 318e05e945b33f3e7a6ead8d85a7f3a8c2b7321c | https://github.com/Carreau/insupportable/blob/318e05e945b33f3e7a6ead8d85a7f3a8c2b7321c/insupportable/insupportable.py#L161-L190 |
248,414 | Carreau/insupportable | insupportable/insupportable.py | Context._default_warner | def _default_warner(self, message, stacklevel=1):
"""
default warner function use a pending deprecation warning,
and correct for the correct stacklevel
"""
return warnings.warn(message,
PendingDeprecationWarning,
stacklevel=stacklevel+4) | python | def _default_warner(self, message, stacklevel=1):
"""
default warner function use a pending deprecation warning,
and correct for the correct stacklevel
"""
return warnings.warn(message,
PendingDeprecationWarning,
stacklevel=stacklevel+4) | [
"def",
"_default_warner",
"(",
"self",
",",
"message",
",",
"stacklevel",
"=",
"1",
")",
":",
"return",
"warnings",
".",
"warn",
"(",
"message",
",",
"PendingDeprecationWarning",
",",
"stacklevel",
"=",
"stacklevel",
"+",
"4",
")"
] | default warner function use a pending deprecation warning,
and correct for the correct stacklevel | [
"default",
"warner",
"function",
"use",
"a",
"pending",
"deprecation",
"warning",
"and",
"correct",
"for",
"the",
"correct",
"stacklevel"
] | 318e05e945b33f3e7a6ead8d85a7f3a8c2b7321c | https://github.com/Carreau/insupportable/blob/318e05e945b33f3e7a6ead8d85a7f3a8c2b7321c/insupportable/insupportable.py#L218-L225 |
248,415 | FujiMakoto/IPS-Vagrant | ips_vagrant/installer/V_4_0_11.py | Installer._check_if_complete | def _check_if_complete(self, url, json_response):
"""
Check if a request has been completed and return the redirect URL if it has
@type url: str
@type json_response: list or dict
@rtype: str or bool
"""
if '__done' in json_response and isinstance(j... | python | def _check_if_complete(self, url, json_response):
"""
Check if a request has been completed and return the redirect URL if it has
@type url: str
@type json_response: list or dict
@rtype: str or bool
"""
if '__done' in json_response and isinstance(j... | [
"def",
"_check_if_complete",
"(",
"self",
",",
"url",
",",
"json_response",
")",
":",
"if",
"'__done'",
"in",
"json_response",
"and",
"isinstance",
"(",
"json_response",
",",
"list",
")",
":",
"mr_parts",
"=",
"list",
"(",
"urlparse",
"(",
"url",
")",
")",... | Check if a request has been completed and return the redirect URL if it has
@type url: str
@type json_response: list or dict
@rtype: str or bool | [
"Check",
"if",
"a",
"request",
"has",
"been",
"completed",
"and",
"return",
"the",
"redirect",
"URL",
"if",
"it",
"has"
] | 7b1d6d095034dd8befb026d9315ecc6494d52269 | https://github.com/FujiMakoto/IPS-Vagrant/blob/7b1d6d095034dd8befb026d9315ecc6494d52269/ips_vagrant/installer/V_4_0_11.py#L11-L28 |
248,416 | sykora/djournal | djournal/views.py | entry_index | def entry_index(request, limit=0, template='djournal/entry_index.html'):
'''Returns a reponse of a fixed number of entries; all of them, by default. '''
entries = Entry.public.all()
if limit > 0:
entries = entries[:limit]
context = {
'entries': entries,
}
return render_to_res... | python | def entry_index(request, limit=0, template='djournal/entry_index.html'):
'''Returns a reponse of a fixed number of entries; all of them, by default. '''
entries = Entry.public.all()
if limit > 0:
entries = entries[:limit]
context = {
'entries': entries,
}
return render_to_res... | [
"def",
"entry_index",
"(",
"request",
",",
"limit",
"=",
"0",
",",
"template",
"=",
"'djournal/entry_index.html'",
")",
":",
"entries",
"=",
"Entry",
".",
"public",
".",
"all",
"(",
")",
"if",
"limit",
">",
"0",
":",
"entries",
"=",
"entries",
"[",
":"... | Returns a reponse of a fixed number of entries; all of them, by default. | [
"Returns",
"a",
"reponse",
"of",
"a",
"fixed",
"number",
"of",
"entries",
";",
"all",
"of",
"them",
"by",
"default",
"."
] | c074e1f94e07e2630034a00c7dbd768e933f85e2 | https://github.com/sykora/djournal/blob/c074e1f94e07e2630034a00c7dbd768e933f85e2/djournal/views.py#L10-L26 |
248,417 | sykora/djournal | djournal/views.py | entry_detail | def entry_detail(request, slug, template='djournal/entry_detail.html'):
'''Returns a response of an individual entry, for the given slug.'''
entry = get_object_or_404(Entry.public, slug=slug)
context = {
'entry': entry,
}
return render_to_response(
template,
context,
... | python | def entry_detail(request, slug, template='djournal/entry_detail.html'):
'''Returns a response of an individual entry, for the given slug.'''
entry = get_object_or_404(Entry.public, slug=slug)
context = {
'entry': entry,
}
return render_to_response(
template,
context,
... | [
"def",
"entry_detail",
"(",
"request",
",",
"slug",
",",
"template",
"=",
"'djournal/entry_detail.html'",
")",
":",
"entry",
"=",
"get_object_or_404",
"(",
"Entry",
".",
"public",
",",
"slug",
"=",
"slug",
")",
"context",
"=",
"{",
"'entry'",
":",
"entry",
... | Returns a response of an individual entry, for the given slug. | [
"Returns",
"a",
"response",
"of",
"an",
"individual",
"entry",
"for",
"the",
"given",
"slug",
"."
] | c074e1f94e07e2630034a00c7dbd768e933f85e2 | https://github.com/sykora/djournal/blob/c074e1f94e07e2630034a00c7dbd768e933f85e2/djournal/views.py#L28-L41 |
248,418 | sykora/djournal | djournal/views.py | tagged_entry_index | def tagged_entry_index(request, slug, template='djournal/tagged_entry_index.html'):
'''Returns a response of all entries tagged with a given tag.'''
tag = get_object_or_404(Tag, slug=slug)
entries = Entry.public.filter(tags__in=[tag])
context = {
'entries': entries,
'tag': tag,
}
... | python | def tagged_entry_index(request, slug, template='djournal/tagged_entry_index.html'):
'''Returns a response of all entries tagged with a given tag.'''
tag = get_object_or_404(Tag, slug=slug)
entries = Entry.public.filter(tags__in=[tag])
context = {
'entries': entries,
'tag': tag,
}
... | [
"def",
"tagged_entry_index",
"(",
"request",
",",
"slug",
",",
"template",
"=",
"'djournal/tagged_entry_index.html'",
")",
":",
"tag",
"=",
"get_object_or_404",
"(",
"Tag",
",",
"slug",
"=",
"slug",
")",
"entries",
"=",
"Entry",
".",
"public",
".",
"filter",
... | Returns a response of all entries tagged with a given tag. | [
"Returns",
"a",
"response",
"of",
"all",
"entries",
"tagged",
"with",
"a",
"given",
"tag",
"."
] | c074e1f94e07e2630034a00c7dbd768e933f85e2 | https://github.com/sykora/djournal/blob/c074e1f94e07e2630034a00c7dbd768e933f85e2/djournal/views.py#L43-L59 |
248,419 | tschaume/ccsgp_get_started | ccsgp_get_started/examples/utils.py | getErrorComponent | def getErrorComponent(result, tag):
"""get total error contribution for component with specific tag"""
return math.sqrt(sum(
(error*2)**2
for (var, error) in result.error_components().items()
if var.tag == tag
)) | python | def getErrorComponent(result, tag):
"""get total error contribution for component with specific tag"""
return math.sqrt(sum(
(error*2)**2
for (var, error) in result.error_components().items()
if var.tag == tag
)) | [
"def",
"getErrorComponent",
"(",
"result",
",",
"tag",
")",
":",
"return",
"math",
".",
"sqrt",
"(",
"sum",
"(",
"(",
"error",
"*",
"2",
")",
"**",
"2",
"for",
"(",
"var",
",",
"error",
")",
"in",
"result",
".",
"error_components",
"(",
")",
".",
... | get total error contribution for component with specific tag | [
"get",
"total",
"error",
"contribution",
"for",
"component",
"with",
"specific",
"tag"
] | e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2 | https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/utils.py#L41-L47 |
248,420 | tschaume/ccsgp_get_started | ccsgp_get_started/examples/utils.py | getEdges | def getEdges(npArr):
"""get np array of bin edges"""
edges = np.concatenate(([0], npArr[:,0] + npArr[:,2]))
return np.array([Decimal(str(i)) for i in edges]) | python | def getEdges(npArr):
"""get np array of bin edges"""
edges = np.concatenate(([0], npArr[:,0] + npArr[:,2]))
return np.array([Decimal(str(i)) for i in edges]) | [
"def",
"getEdges",
"(",
"npArr",
")",
":",
"edges",
"=",
"np",
".",
"concatenate",
"(",
"(",
"[",
"0",
"]",
",",
"npArr",
"[",
":",
",",
"0",
"]",
"+",
"npArr",
"[",
":",
",",
"2",
"]",
")",
")",
"return",
"np",
".",
"array",
"(",
"[",
"Dec... | get np array of bin edges | [
"get",
"np",
"array",
"of",
"bin",
"edges"
] | e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2 | https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/utils.py#L49-L52 |
248,421 | tschaume/ccsgp_get_started | ccsgp_get_started/examples/utils.py | getMaskIndices | def getMaskIndices(mask):
"""get lower and upper index of mask"""
return [
list(mask).index(True), len(mask) - 1 - list(mask)[::-1].index(True)
] | python | def getMaskIndices(mask):
"""get lower and upper index of mask"""
return [
list(mask).index(True), len(mask) - 1 - list(mask)[::-1].index(True)
] | [
"def",
"getMaskIndices",
"(",
"mask",
")",
":",
"return",
"[",
"list",
"(",
"mask",
")",
".",
"index",
"(",
"True",
")",
",",
"len",
"(",
"mask",
")",
"-",
"1",
"-",
"list",
"(",
"mask",
")",
"[",
":",
":",
"-",
"1",
"]",
".",
"index",
"(",
... | get lower and upper index of mask | [
"get",
"lower",
"and",
"upper",
"index",
"of",
"mask"
] | e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2 | https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/utils.py#L54-L58 |
248,422 | tschaume/ccsgp_get_started | ccsgp_get_started/examples/utils.py | getCocktailSum | def getCocktailSum(e0, e1, eCocktail, uCocktail):
"""get the cocktail sum for a given data bin range"""
# get mask and according indices
mask = (eCocktail >= e0) & (eCocktail <= e1)
# data bin range wider than single cocktail bin
if np.any(mask):
idx = getMaskIndices(mask)
# determine coinciding flags... | python | def getCocktailSum(e0, e1, eCocktail, uCocktail):
"""get the cocktail sum for a given data bin range"""
# get mask and according indices
mask = (eCocktail >= e0) & (eCocktail <= e1)
# data bin range wider than single cocktail bin
if np.any(mask):
idx = getMaskIndices(mask)
# determine coinciding flags... | [
"def",
"getCocktailSum",
"(",
"e0",
",",
"e1",
",",
"eCocktail",
",",
"uCocktail",
")",
":",
"# get mask and according indices",
"mask",
"=",
"(",
"eCocktail",
">=",
"e0",
")",
"&",
"(",
"eCocktail",
"<=",
"e1",
")",
"# data bin range wider than single cocktail bi... | get the cocktail sum for a given data bin range | [
"get",
"the",
"cocktail",
"sum",
"for",
"a",
"given",
"data",
"bin",
"range"
] | e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2 | https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/utils.py#L64-L108 |
248,423 | Beyond-Digital/django-gaekit | gaekit/boot.py | break_sandbox | def break_sandbox():
"""Patches sandbox to add match-all regex to sandbox whitelist
"""
class EvilCM(object):
def __enter__(self):
return self
def __exit__(self, exc_type, exc, tb):
import re
tb.tb_next.tb_next.tb_next.tb_frame.f_locals[
'... | python | def break_sandbox():
"""Patches sandbox to add match-all regex to sandbox whitelist
"""
class EvilCM(object):
def __enter__(self):
return self
def __exit__(self, exc_type, exc, tb):
import re
tb.tb_next.tb_next.tb_next.tb_frame.f_locals[
'... | [
"def",
"break_sandbox",
"(",
")",
":",
"class",
"EvilCM",
"(",
"object",
")",
":",
"def",
"__enter__",
"(",
"self",
")",
":",
"return",
"self",
"def",
"__exit__",
"(",
"self",
",",
"exc_type",
",",
"exc",
",",
"tb",
")",
":",
"import",
"re",
"tb",
... | Patches sandbox to add match-all regex to sandbox whitelist | [
"Patches",
"sandbox",
"to",
"add",
"match",
"-",
"all",
"regex",
"to",
"sandbox",
"whitelist"
] | b587acd52b5cfd48217a70920d4b61d5f923c8c5 | https://github.com/Beyond-Digital/django-gaekit/blob/b587acd52b5cfd48217a70920d4b61d5f923c8c5/gaekit/boot.py#L1-L17 |
248,424 | kervi/kervi-core | kervi/actions/action.py | _LinkedAction.execute | def execute(self, *args, **kwargs):
"""Executes the action."""
timeout = kwargs.pop("timeout", -1)
run_async = kwargs.pop("run_async", False)
self._is_running = True
result = None
if self._action_lock.acquire(False):
self._state = ACTION_PENDING
se... | python | def execute(self, *args, **kwargs):
"""Executes the action."""
timeout = kwargs.pop("timeout", -1)
run_async = kwargs.pop("run_async", False)
self._is_running = True
result = None
if self._action_lock.acquire(False):
self._state = ACTION_PENDING
se... | [
"def",
"execute",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"timeout",
"=",
"kwargs",
".",
"pop",
"(",
"\"timeout\"",
",",
"-",
"1",
")",
"run_async",
"=",
"kwargs",
".",
"pop",
"(",
"\"run_async\"",
",",
"False",
")",
"self... | Executes the action. | [
"Executes",
"the",
"action",
"."
] | 3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23 | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/actions/action.py#L94-L118 |
248,425 | kervi/kervi-core | kervi/actions/action.py | Action.set_interrupt | def set_interrupt(self, method=None, **kwargs):
"""
Decorator that turns a function or controller method into an action interrupt.
"""
def action_wrap(f):
action_id = kwargs.get("action_id", f.__name__)
name = kwargs.get("name", action_id)
... | python | def set_interrupt(self, method=None, **kwargs):
"""
Decorator that turns a function or controller method into an action interrupt.
"""
def action_wrap(f):
action_id = kwargs.get("action_id", f.__name__)
name = kwargs.get("name", action_id)
... | [
"def",
"set_interrupt",
"(",
"self",
",",
"method",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"action_wrap",
"(",
"f",
")",
":",
"action_id",
"=",
"kwargs",
".",
"get",
"(",
"\"action_id\"",
",",
"f",
".",
"__name__",
")",
"name",
"=",
... | Decorator that turns a function or controller method into an action interrupt. | [
"Decorator",
"that",
"turns",
"a",
"function",
"or",
"controller",
"method",
"into",
"an",
"action",
"interrupt",
"."
] | 3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23 | https://github.com/kervi/kervi-core/blob/3c1e3c8a17a7b4d085d8a28b99180ff2a96b0e23/kervi/actions/action.py#L622-L650 |
248,426 | dmckeone/frosty | frosty/freezers.py | _freezer_lookup | def _freezer_lookup(freezer_string):
"""
Translate a string that may be a freezer name into the internal freezer constant
:param freezer_string
:return:
"""
sanitized = freezer_string.lower().strip()
for freezer in FREEZER.ALL:
freezer_instance = freezer()
freezer_name = six... | python | def _freezer_lookup(freezer_string):
"""
Translate a string that may be a freezer name into the internal freezer constant
:param freezer_string
:return:
"""
sanitized = freezer_string.lower().strip()
for freezer in FREEZER.ALL:
freezer_instance = freezer()
freezer_name = six... | [
"def",
"_freezer_lookup",
"(",
"freezer_string",
")",
":",
"sanitized",
"=",
"freezer_string",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
"for",
"freezer",
"in",
"FREEZER",
".",
"ALL",
":",
"freezer_instance",
"=",
"freezer",
"(",
")",
"freezer_name",
... | Translate a string that may be a freezer name into the internal freezer constant
:param freezer_string
:return: | [
"Translate",
"a",
"string",
"that",
"may",
"be",
"a",
"freezer",
"name",
"into",
"the",
"internal",
"freezer",
"constant"
] | 868d81e72b6c8e354af3697531c20f116cd1fc9a | https://github.com/dmckeone/frosty/blob/868d81e72b6c8e354af3697531c20f116cd1fc9a/frosty/freezers.py#L174-L192 |
248,427 | dmckeone/frosty | frosty/freezers.py | resolve_freezer | def resolve_freezer(freezer):
"""
Locate the appropriate freezer given FREEZER or string input from the programmer.
:param freezer: FREEZER constant or string for the freezer that is requested. (None = FREEZER.DEFAULT)
:return:
"""
# Set default freezer if there was none
if not freezer:
... | python | def resolve_freezer(freezer):
"""
Locate the appropriate freezer given FREEZER or string input from the programmer.
:param freezer: FREEZER constant or string for the freezer that is requested. (None = FREEZER.DEFAULT)
:return:
"""
# Set default freezer if there was none
if not freezer:
... | [
"def",
"resolve_freezer",
"(",
"freezer",
")",
":",
"# Set default freezer if there was none",
"if",
"not",
"freezer",
":",
"return",
"_Default",
"(",
")",
"# Allow character based lookups as well",
"if",
"isinstance",
"(",
"freezer",
",",
"six",
".",
"string_types",
... | Locate the appropriate freezer given FREEZER or string input from the programmer.
:param freezer: FREEZER constant or string for the freezer that is requested. (None = FREEZER.DEFAULT)
:return: | [
"Locate",
"the",
"appropriate",
"freezer",
"given",
"FREEZER",
"or",
"string",
"input",
"from",
"the",
"programmer",
"."
] | 868d81e72b6c8e354af3697531c20f116cd1fc9a | https://github.com/dmckeone/frosty/blob/868d81e72b6c8e354af3697531c20f116cd1fc9a/frosty/freezers.py#L195-L219 |
248,428 | dmckeone/frosty | frosty/freezers.py | _Default._split_packages | def _split_packages(cls, include_packages):
"""
Split an iterable of packages into packages that need to be passed through, and those that need to have their
disk location resolved.
Some modules don't have a '__file__' attribute. AFAIK these aren't packages, so they can just be passed
... | python | def _split_packages(cls, include_packages):
"""
Split an iterable of packages into packages that need to be passed through, and those that need to have their
disk location resolved.
Some modules don't have a '__file__' attribute. AFAIK these aren't packages, so they can just be passed
... | [
"def",
"_split_packages",
"(",
"cls",
",",
"include_packages",
")",
":",
"passthrough_includes",
"=",
"set",
"(",
"[",
"six",
".",
"text_type",
"(",
"package",
".",
"__name__",
")",
"for",
"package",
"in",
"include_packages",
"if",
"not",
"hasattr",
"(",
"pa... | Split an iterable of packages into packages that need to be passed through, and those that need to have their
disk location resolved.
Some modules don't have a '__file__' attribute. AFAIK these aren't packages, so they can just be passed
through to the includes as-is
:return: 2-tuple o... | [
"Split",
"an",
"iterable",
"of",
"packages",
"into",
"packages",
"that",
"need",
"to",
"be",
"passed",
"through",
"and",
"those",
"that",
"need",
"to",
"have",
"their",
"disk",
"location",
"resolved",
"."
] | 868d81e72b6c8e354af3697531c20f116cd1fc9a | https://github.com/dmckeone/frosty/blob/868d81e72b6c8e354af3697531c20f116cd1fc9a/frosty/freezers.py#L22-L41 |
248,429 | KnowledgeLinks/rdfframework | rdfframework/datasets/jsonquery.py | parse_json_qry | def parse_json_qry(qry_str):
""" Parses a json query string into its parts
args:
qry_str: query string
params: variables passed into the string
"""
def param_analyzer(param_list):
rtn_list = []
for param in param_list:
parts = param.strip().split("=")
... | python | def parse_json_qry(qry_str):
""" Parses a json query string into its parts
args:
qry_str: query string
params: variables passed into the string
"""
def param_analyzer(param_list):
rtn_list = []
for param in param_list:
parts = param.strip().split("=")
... | [
"def",
"parse_json_qry",
"(",
"qry_str",
")",
":",
"def",
"param_analyzer",
"(",
"param_list",
")",
":",
"rtn_list",
"=",
"[",
"]",
"for",
"param",
"in",
"param_list",
":",
"parts",
"=",
"param",
".",
"strip",
"(",
")",
".",
"split",
"(",
"\"=\"",
")",... | Parses a json query string into its parts
args:
qry_str: query string
params: variables passed into the string | [
"Parses",
"a",
"json",
"query",
"string",
"into",
"its",
"parts"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datasets/jsonquery.py#L14-L63 |
248,430 | KnowledgeLinks/rdfframework | rdfframework/datasets/jsonquery.py | json_qry | def json_qry(dataset, qry_str, params={}):
""" Takes a json query string and returns the results
args:
dataset: RdfDataset to query against
qry_str: query string
params: dictionary of params
"""
# if qry_str.startswith("$.bf_itemOf[rdf_type=bf_Print].='print',\n"):
# pdb... | python | def json_qry(dataset, qry_str, params={}):
""" Takes a json query string and returns the results
args:
dataset: RdfDataset to query against
qry_str: query string
params: dictionary of params
"""
# if qry_str.startswith("$.bf_itemOf[rdf_type=bf_Print].='print',\n"):
# pdb... | [
"def",
"json_qry",
"(",
"dataset",
",",
"qry_str",
",",
"params",
"=",
"{",
"}",
")",
":",
"# if qry_str.startswith(\"$.bf_itemOf[rdf_type=bf_Print].='print',\\n\"):",
"# pdb.set_trace()",
"if",
"not",
"'$'",
"in",
"qry_str",
":",
"qry_str",
"=",
"\".\"",
".",
"... | Takes a json query string and returns the results
args:
dataset: RdfDataset to query against
qry_str: query string
params: dictionary of params | [
"Takes",
"a",
"json",
"query",
"string",
"and",
"returns",
"the",
"results"
] | 9ec32dcc4bed51650a4b392cc5c15100fef7923a | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/datasets/jsonquery.py#L393-L463 |
248,431 | jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readMixedArray | def readMixedArray(self):
"""
Read mixed array.
@rtype: L{pyamf.MixedArray}
"""
# TODO: something with the length/strict
self.stream.read_ulong() # length
obj = pyamf.MixedArray()
self.context.addObject(obj)
attrs = self.readObjectAttributes(obj... | python | def readMixedArray(self):
"""
Read mixed array.
@rtype: L{pyamf.MixedArray}
"""
# TODO: something with the length/strict
self.stream.read_ulong() # length
obj = pyamf.MixedArray()
self.context.addObject(obj)
attrs = self.readObjectAttributes(obj... | [
"def",
"readMixedArray",
"(",
"self",
")",
":",
"# TODO: something with the length/strict",
"self",
".",
"stream",
".",
"read_ulong",
"(",
")",
"# length",
"obj",
"=",
"pyamf",
".",
"MixedArray",
"(",
")",
"self",
".",
"context",
".",
"addObject",
"(",
"obj",
... | Read mixed array.
@rtype: L{pyamf.MixedArray} | [
"Read",
"mixed",
"array",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L223-L245 |
248,432 | jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readTypedObject | def readTypedObject(self):
"""
Reads an aliased ActionScript object from the stream and attempts to
'cast' it into a python class.
@see: L{pyamf.register_class}
"""
class_alias = self.readString()
try:
alias = self.context.getClassAlias(class_alias)
... | python | def readTypedObject(self):
"""
Reads an aliased ActionScript object from the stream and attempts to
'cast' it into a python class.
@see: L{pyamf.register_class}
"""
class_alias = self.readString()
try:
alias = self.context.getClassAlias(class_alias)
... | [
"def",
"readTypedObject",
"(",
"self",
")",
":",
"class_alias",
"=",
"self",
".",
"readString",
"(",
")",
"try",
":",
"alias",
"=",
"self",
".",
"context",
".",
"getClassAlias",
"(",
"class_alias",
")",
"except",
"pyamf",
".",
"UnknownClassAlias",
":",
"if... | Reads an aliased ActionScript object from the stream and attempts to
'cast' it into a python class.
@see: L{pyamf.register_class} | [
"Reads",
"an",
"aliased",
"ActionScript",
"object",
"from",
"the",
"stream",
"and",
"attempts",
"to",
"cast",
"it",
"into",
"a",
"python",
"class",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L260-L283 |
248,433 | jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readObject | def readObject(self):
"""
Reads an anonymous object from the data stream.
@rtype: L{ASObject<pyamf.ASObject>}
"""
obj = pyamf.ASObject()
self.context.addObject(obj)
obj.update(self.readObjectAttributes(obj))
return obj | python | def readObject(self):
"""
Reads an anonymous object from the data stream.
@rtype: L{ASObject<pyamf.ASObject>}
"""
obj = pyamf.ASObject()
self.context.addObject(obj)
obj.update(self.readObjectAttributes(obj))
return obj | [
"def",
"readObject",
"(",
"self",
")",
":",
"obj",
"=",
"pyamf",
".",
"ASObject",
"(",
")",
"self",
".",
"context",
".",
"addObject",
"(",
"obj",
")",
"obj",
".",
"update",
"(",
"self",
".",
"readObjectAttributes",
"(",
"obj",
")",
")",
"return",
"ob... | Reads an anonymous object from the data stream.
@rtype: L{ASObject<pyamf.ASObject>} | [
"Reads",
"an",
"anonymous",
"object",
"from",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L307-L318 |
248,434 | jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readReference | def readReference(self):
"""
Reads a reference from the data stream.
@raise pyamf.ReferenceError: Unknown reference.
"""
idx = self.stream.read_ushort()
o = self.context.getObject(idx)
if o is None:
raise pyamf.ReferenceError('Unknown reference %d' %... | python | def readReference(self):
"""
Reads a reference from the data stream.
@raise pyamf.ReferenceError: Unknown reference.
"""
idx = self.stream.read_ushort()
o = self.context.getObject(idx)
if o is None:
raise pyamf.ReferenceError('Unknown reference %d' %... | [
"def",
"readReference",
"(",
"self",
")",
":",
"idx",
"=",
"self",
".",
"stream",
".",
"read_ushort",
"(",
")",
"o",
"=",
"self",
".",
"context",
".",
"getObject",
"(",
"idx",
")",
"if",
"o",
"is",
"None",
":",
"raise",
"pyamf",
".",
"ReferenceError"... | Reads a reference from the data stream.
@raise pyamf.ReferenceError: Unknown reference. | [
"Reads",
"a",
"reference",
"from",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L320-L332 |
248,435 | jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readDate | def readDate(self):
"""
Reads a UTC date from the data stream. Client and servers are
responsible for applying their own timezones.
Date: C{0x0B T7 T6} .. C{T0 Z1 Z2 T7} to C{T0} form a 64 bit
Big Endian number that specifies the number of nanoseconds
that have passed si... | python | def readDate(self):
"""
Reads a UTC date from the data stream. Client and servers are
responsible for applying their own timezones.
Date: C{0x0B T7 T6} .. C{T0 Z1 Z2 T7} to C{T0} form a 64 bit
Big Endian number that specifies the number of nanoseconds
that have passed si... | [
"def",
"readDate",
"(",
"self",
")",
":",
"ms",
"=",
"self",
".",
"stream",
".",
"read_double",
"(",
")",
"/",
"1000.0",
"self",
".",
"stream",
".",
"read_short",
"(",
")",
"# tz",
"# Timezones are ignored",
"d",
"=",
"util",
".",
"get_datetime",
"(",
... | Reads a UTC date from the data stream. Client and servers are
responsible for applying their own timezones.
Date: C{0x0B T7 T6} .. C{T0 Z1 Z2 T7} to C{T0} form a 64 bit
Big Endian number that specifies the number of nanoseconds
that have passed since 1/1/1970 0:00 to the specified time.... | [
"Reads",
"a",
"UTC",
"date",
"from",
"the",
"data",
"stream",
".",
"Client",
"and",
"servers",
"are",
"responsible",
"for",
"applying",
"their",
"own",
"timezones",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L334-L357 |
248,436 | jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readLongString | def readLongString(self):
"""
Read UTF8 string.
"""
l = self.stream.read_ulong()
bytes = self.stream.read(l)
return self.context.getStringForBytes(bytes) | python | def readLongString(self):
"""
Read UTF8 string.
"""
l = self.stream.read_ulong()
bytes = self.stream.read(l)
return self.context.getStringForBytes(bytes) | [
"def",
"readLongString",
"(",
"self",
")",
":",
"l",
"=",
"self",
".",
"stream",
".",
"read_ulong",
"(",
")",
"bytes",
"=",
"self",
".",
"stream",
".",
"read",
"(",
"l",
")",
"return",
"self",
".",
"context",
".",
"getStringForBytes",
"(",
"bytes",
"... | Read UTF8 string. | [
"Read",
"UTF8",
"string",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L359-L367 |
248,437 | jmgilman/Neolib | neolib/pyamf/amf0.py | Decoder.readXML | def readXML(self):
"""
Read XML.
"""
data = self.readLongString()
root = xml.fromstring(data)
self.context.addObject(root)
return root | python | def readXML(self):
"""
Read XML.
"""
data = self.readLongString()
root = xml.fromstring(data)
self.context.addObject(root)
return root | [
"def",
"readXML",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"readLongString",
"(",
")",
"root",
"=",
"xml",
".",
"fromstring",
"(",
"data",
")",
"self",
".",
"context",
".",
"addObject",
"(",
"root",
")",
"return",
"root"
] | Read XML. | [
"Read",
"XML",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L369-L378 |
248,438 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeList | def writeList(self, a):
"""
Write array to the stream.
@param a: The array data to be encoded to the AMF0 data stream.
"""
if self.writeReference(a) != -1:
return
self.context.addObject(a)
self.writeType(TYPE_ARRAY)
self.stream.write_ulong(l... | python | def writeList(self, a):
"""
Write array to the stream.
@param a: The array data to be encoded to the AMF0 data stream.
"""
if self.writeReference(a) != -1:
return
self.context.addObject(a)
self.writeType(TYPE_ARRAY)
self.stream.write_ulong(l... | [
"def",
"writeList",
"(",
"self",
",",
"a",
")",
":",
"if",
"self",
".",
"writeReference",
"(",
"a",
")",
"!=",
"-",
"1",
":",
"return",
"self",
".",
"context",
".",
"addObject",
"(",
"a",
")",
"self",
".",
"writeType",
"(",
"TYPE_ARRAY",
")",
"self... | Write array to the stream.
@param a: The array data to be encoded to the AMF0 data stream. | [
"Write",
"array",
"to",
"the",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L432-L447 |
248,439 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeNumber | def writeNumber(self, n):
"""
Write number to the data stream .
@param n: The number data to be encoded to the AMF0 data stream.
"""
self.writeType(TYPE_NUMBER)
self.stream.write_double(float(n)) | python | def writeNumber(self, n):
"""
Write number to the data stream .
@param n: The number data to be encoded to the AMF0 data stream.
"""
self.writeType(TYPE_NUMBER)
self.stream.write_double(float(n)) | [
"def",
"writeNumber",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"writeType",
"(",
"TYPE_NUMBER",
")",
"self",
".",
"stream",
".",
"write_double",
"(",
"float",
"(",
"n",
")",
")"
] | Write number to the data stream .
@param n: The number data to be encoded to the AMF0 data stream. | [
"Write",
"number",
"to",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L449-L456 |
248,440 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeBoolean | def writeBoolean(self, b):
"""
Write boolean to the data stream.
@param b: The boolean data to be encoded to the AMF0 data stream.
"""
self.writeType(TYPE_BOOL)
if b:
self.stream.write_uchar(1)
else:
self.stream.write_uchar(0) | python | def writeBoolean(self, b):
"""
Write boolean to the data stream.
@param b: The boolean data to be encoded to the AMF0 data stream.
"""
self.writeType(TYPE_BOOL)
if b:
self.stream.write_uchar(1)
else:
self.stream.write_uchar(0) | [
"def",
"writeBoolean",
"(",
"self",
",",
"b",
")",
":",
"self",
".",
"writeType",
"(",
"TYPE_BOOL",
")",
"if",
"b",
":",
"self",
".",
"stream",
".",
"write_uchar",
"(",
"1",
")",
"else",
":",
"self",
".",
"stream",
".",
"write_uchar",
"(",
"0",
")"... | Write boolean to the data stream.
@param b: The boolean data to be encoded to the AMF0 data stream. | [
"Write",
"boolean",
"to",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L458-L469 |
248,441 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeBytes | def writeBytes(self, s):
"""
Write a string of bytes to the data stream.
"""
l = len(s)
if l > 0xffff:
self.writeType(TYPE_LONGSTRING)
else:
self.writeType(TYPE_STRING)
if l > 0xffff:
self.stream.write_ulong(l)
else:
... | python | def writeBytes(self, s):
"""
Write a string of bytes to the data stream.
"""
l = len(s)
if l > 0xffff:
self.writeType(TYPE_LONGSTRING)
else:
self.writeType(TYPE_STRING)
if l > 0xffff:
self.stream.write_ulong(l)
else:
... | [
"def",
"writeBytes",
"(",
"self",
",",
"s",
")",
":",
"l",
"=",
"len",
"(",
"s",
")",
"if",
"l",
">",
"0xffff",
":",
"self",
".",
"writeType",
"(",
"TYPE_LONGSTRING",
")",
"else",
":",
"self",
".",
"writeType",
"(",
"TYPE_STRING",
")",
"if",
"l",
... | Write a string of bytes to the data stream. | [
"Write",
"a",
"string",
"of",
"bytes",
"to",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L487-L503 |
248,442 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeString | def writeString(self, u):
"""
Write a unicode to the data stream.
"""
s = self.context.getBytesForString(u)
self.writeBytes(s) | python | def writeString(self, u):
"""
Write a unicode to the data stream.
"""
s = self.context.getBytesForString(u)
self.writeBytes(s) | [
"def",
"writeString",
"(",
"self",
",",
"u",
")",
":",
"s",
"=",
"self",
".",
"context",
".",
"getBytesForString",
"(",
"u",
")",
"self",
".",
"writeBytes",
"(",
"s",
")"
] | Write a unicode to the data stream. | [
"Write",
"a",
"unicode",
"to",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L505-L511 |
248,443 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeReference | def writeReference(self, o):
"""
Write reference to the data stream.
@param o: The reference data to be encoded to the AMF0 datastream.
"""
idx = self.context.getObjectReference(o)
if idx == -1 or idx > 65535:
return -1
self.writeType(TYPE_REFERENCE... | python | def writeReference(self, o):
"""
Write reference to the data stream.
@param o: The reference data to be encoded to the AMF0 datastream.
"""
idx = self.context.getObjectReference(o)
if idx == -1 or idx > 65535:
return -1
self.writeType(TYPE_REFERENCE... | [
"def",
"writeReference",
"(",
"self",
",",
"o",
")",
":",
"idx",
"=",
"self",
".",
"context",
".",
"getObjectReference",
"(",
"o",
")",
"if",
"idx",
"==",
"-",
"1",
"or",
"idx",
">",
"65535",
":",
"return",
"-",
"1",
"self",
".",
"writeType",
"(",
... | Write reference to the data stream.
@param o: The reference data to be encoded to the AMF0 datastream. | [
"Write",
"reference",
"to",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L513-L527 |
248,444 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeMixedArray | def writeMixedArray(self, o):
"""
Write mixed array to the data stream.
@type o: L{pyamf.MixedArray}
"""
if self.writeReference(o) != -1:
return
self.context.addObject(o)
self.writeType(TYPE_MIXEDARRAY)
# TODO: optimise this
# work o... | python | def writeMixedArray(self, o):
"""
Write mixed array to the data stream.
@type o: L{pyamf.MixedArray}
"""
if self.writeReference(o) != -1:
return
self.context.addObject(o)
self.writeType(TYPE_MIXEDARRAY)
# TODO: optimise this
# work o... | [
"def",
"writeMixedArray",
"(",
"self",
",",
"o",
")",
":",
"if",
"self",
".",
"writeReference",
"(",
"o",
")",
"!=",
"-",
"1",
":",
"return",
"self",
".",
"context",
".",
"addObject",
"(",
"o",
")",
"self",
".",
"writeType",
"(",
"TYPE_MIXEDARRAY",
"... | Write mixed array to the data stream.
@type o: L{pyamf.MixedArray} | [
"Write",
"mixed",
"array",
"to",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L542-L569 |
248,445 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeObject | def writeObject(self, o):
"""
Write a Python object to the stream.
@param o: The object data to be encoded to the AMF0 data stream.
"""
if self.writeReference(o) != -1:
return
self.context.addObject(o)
alias = self.context.getClassAlias(o.__class__)
... | python | def writeObject(self, o):
"""
Write a Python object to the stream.
@param o: The object data to be encoded to the AMF0 data stream.
"""
if self.writeReference(o) != -1:
return
self.context.addObject(o)
alias = self.context.getClassAlias(o.__class__)
... | [
"def",
"writeObject",
"(",
"self",
",",
"o",
")",
":",
"if",
"self",
".",
"writeReference",
"(",
"o",
")",
"!=",
"-",
"1",
":",
"return",
"self",
".",
"context",
".",
"addObject",
"(",
"o",
")",
"alias",
"=",
"self",
".",
"context",
".",
"getClassA... | Write a Python object to the stream.
@param o: The object data to be encoded to the AMF0 data stream. | [
"Write",
"a",
"Python",
"object",
"to",
"the",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L574-L611 |
248,446 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeDate | def writeDate(self, d):
"""
Writes a date to the data stream.
@type d: Instance of C{datetime.datetime}
@param d: The date to be encoded to the AMF0 data stream.
"""
if isinstance(d, datetime.time):
raise pyamf.EncodeError('A datetime.time instance was found ... | python | def writeDate(self, d):
"""
Writes a date to the data stream.
@type d: Instance of C{datetime.datetime}
@param d: The date to be encoded to the AMF0 data stream.
"""
if isinstance(d, datetime.time):
raise pyamf.EncodeError('A datetime.time instance was found ... | [
"def",
"writeDate",
"(",
"self",
",",
"d",
")",
":",
"if",
"isinstance",
"(",
"d",
",",
"datetime",
".",
"time",
")",
":",
"raise",
"pyamf",
".",
"EncodeError",
"(",
"'A datetime.time instance was found but '",
"'AMF0 has no way to encode time objects. Please use '",
... | Writes a date to the data stream.
@type d: Instance of C{datetime.datetime}
@param d: The date to be encoded to the AMF0 data stream. | [
"Writes",
"a",
"date",
"to",
"the",
"data",
"stream",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L613-L635 |
248,447 | jmgilman/Neolib | neolib/pyamf/amf0.py | Encoder.writeXML | def writeXML(self, e):
"""
Writes an XML instance.
"""
self.writeType(TYPE_XML)
data = xml.tostring(e)
if isinstance(data, unicode):
data = data.encode('utf-8')
self.stream.write_ulong(len(data))
self.stream.write(data) | python | def writeXML(self, e):
"""
Writes an XML instance.
"""
self.writeType(TYPE_XML)
data = xml.tostring(e)
if isinstance(data, unicode):
data = data.encode('utf-8')
self.stream.write_ulong(len(data))
self.stream.write(data) | [
"def",
"writeXML",
"(",
"self",
",",
"e",
")",
":",
"self",
".",
"writeType",
"(",
"TYPE_XML",
")",
"data",
"=",
"xml",
".",
"tostring",
"(",
"e",
")",
"if",
"isinstance",
"(",
"data",
",",
"unicode",
")",
":",
"data",
"=",
"data",
".",
"encode",
... | Writes an XML instance. | [
"Writes",
"an",
"XML",
"instance",
"."
] | 228fafeaed0f3195676137732384a14820ae285c | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf0.py#L637-L649 |
248,448 | abe-winter/pg13-py | pg13/redismodel.py | RedisModel.des | def des(clas,keyblob,valblob):
"deserialize. translate publish message, basically"
raise NotImplementedError("don't use tuples, it breaks __eq__. this function probably isn't used in real life")
raw_keyvals=msgpack.loads(keyblob)
(namespace,version),keyvals=raw_keyvals[:2],raw_keyvals[2:]
if na... | python | def des(clas,keyblob,valblob):
"deserialize. translate publish message, basically"
raise NotImplementedError("don't use tuples, it breaks __eq__. this function probably isn't used in real life")
raw_keyvals=msgpack.loads(keyblob)
(namespace,version),keyvals=raw_keyvals[:2],raw_keyvals[2:]
if na... | [
"def",
"des",
"(",
"clas",
",",
"keyblob",
",",
"valblob",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"don't use tuples, it breaks __eq__. this function probably isn't used in real life\"",
")",
"raw_keyvals",
"=",
"msgpack",
".",
"loads",
"(",
"keyblob",
")",
"("... | deserialize. translate publish message, basically | [
"deserialize",
".",
"translate",
"publish",
"message",
"basically"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/redismodel.py#L41-L51 |
248,449 | abe-winter/pg13-py | pg13/redismodel.py | RedisSimplePubsub.wait | def wait(self):
"wait for a message, respecting timeout"
data=self.getcon().recv(256) # this can raise socket.timeout
if not data: raise PubsubDisco
if self.reset:
self.reset=False # i.e. ack it. reset is used to tell the wait-thread there was a reconnect (though it's plausible that this neve... | python | def wait(self):
"wait for a message, respecting timeout"
data=self.getcon().recv(256) # this can raise socket.timeout
if not data: raise PubsubDisco
if self.reset:
self.reset=False # i.e. ack it. reset is used to tell the wait-thread there was a reconnect (though it's plausible that this neve... | [
"def",
"wait",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"getcon",
"(",
")",
".",
"recv",
"(",
"256",
")",
"# this can raise socket.timeout\r",
"if",
"not",
"data",
":",
"raise",
"PubsubDisco",
"if",
"self",
".",
"reset",
":",
"self",
".",
"rese... | wait for a message, respecting timeout | [
"wait",
"for",
"a",
"message",
"respecting",
"timeout"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/redismodel.py#L117-L126 |
248,450 | jut-io/jut-python-tools | jut/api/auth.py | TokenManager.get_access_token | def get_access_token(self):
"""
get a valid access token
"""
if self.is_access_token_expired():
if is_debug_enabled():
debug('requesting new access_token')
token = get_access_token(username=self.username,
pas... | python | def get_access_token(self):
"""
get a valid access token
"""
if self.is_access_token_expired():
if is_debug_enabled():
debug('requesting new access_token')
token = get_access_token(username=self.username,
pas... | [
"def",
"get_access_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_access_token_expired",
"(",
")",
":",
"if",
"is_debug_enabled",
"(",
")",
":",
"debug",
"(",
"'requesting new access_token'",
")",
"token",
"=",
"get_access_token",
"(",
"username",
"=",
... | get a valid access token | [
"get",
"a",
"valid",
"access",
"token"
] | 65574d23f51a7bbced9bb25010d02da5ca5d906f | https://github.com/jut-io/jut-python-tools/blob/65574d23f51a7bbced9bb25010d02da5ca5d906f/jut/api/auth.py#L61-L81 |
248,451 | rbarrois/confutils | confutils/configfile.py | ConfigLineList.find_lines | def find_lines(self, line):
"""Find all lines matching a given line."""
for other_line in self.lines:
if other_line.match(line):
yield other_line | python | def find_lines(self, line):
"""Find all lines matching a given line."""
for other_line in self.lines:
if other_line.match(line):
yield other_line | [
"def",
"find_lines",
"(",
"self",
",",
"line",
")",
":",
"for",
"other_line",
"in",
"self",
".",
"lines",
":",
"if",
"other_line",
".",
"match",
"(",
"line",
")",
":",
"yield",
"other_line"
] | Find all lines matching a given line. | [
"Find",
"all",
"lines",
"matching",
"a",
"given",
"line",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L110-L114 |
248,452 | rbarrois/confutils | confutils/configfile.py | Section.remove | def remove(self, line):
"""Delete all lines matching the given line."""
nb = 0
for block in self.blocks:
nb += block.remove(line)
return nb | python | def remove(self, line):
"""Delete all lines matching the given line."""
nb = 0
for block in self.blocks:
nb += block.remove(line)
return nb | [
"def",
"remove",
"(",
"self",
",",
"line",
")",
":",
"nb",
"=",
"0",
"for",
"block",
"in",
"self",
".",
"blocks",
":",
"nb",
"+=",
"block",
".",
"remove",
"(",
"line",
")",
"return",
"nb"
] | Delete all lines matching the given line. | [
"Delete",
"all",
"lines",
"matching",
"the",
"given",
"line",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L227-L233 |
248,453 | rbarrois/confutils | confutils/configfile.py | MultiValuedSectionView.add | def add(self, key, value):
"""Add a new value for a key.
This differs from __setitem__ in adding a new value instead of updating
the list of values, thus avoiding the need to fetch the previous list of
values.
"""
self.configfile.add(self.name, key, value) | python | def add(self, key, value):
"""Add a new value for a key.
This differs from __setitem__ in adding a new value instead of updating
the list of values, thus avoiding the need to fetch the previous list of
values.
"""
self.configfile.add(self.name, key, value) | [
"def",
"add",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"configfile",
".",
"add",
"(",
"self",
".",
"name",
",",
"key",
",",
"value",
")"
] | Add a new value for a key.
This differs from __setitem__ in adding a new value instead of updating
the list of values, thus avoiding the need to fetch the previous list of
values. | [
"Add",
"a",
"new",
"value",
"for",
"a",
"key",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L298-L305 |
248,454 | rbarrois/confutils | confutils/configfile.py | ConfigFile._get_section | def _get_section(self, name, create=True):
"""Retrieve a section by name. Create it on first access."""
try:
return self.sections[name]
except KeyError:
if not create:
raise
section = Section(name)
self.sections[name] = section
... | python | def _get_section(self, name, create=True):
"""Retrieve a section by name. Create it on first access."""
try:
return self.sections[name]
except KeyError:
if not create:
raise
section = Section(name)
self.sections[name] = section
... | [
"def",
"_get_section",
"(",
"self",
",",
"name",
",",
"create",
"=",
"True",
")",
":",
"try",
":",
"return",
"self",
".",
"sections",
"[",
"name",
"]",
"except",
"KeyError",
":",
"if",
"not",
"create",
":",
"raise",
"section",
"=",
"Section",
"(",
"n... | Retrieve a section by name. Create it on first access. | [
"Retrieve",
"a",
"section",
"by",
"name",
".",
"Create",
"it",
"on",
"first",
"access",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L339-L349 |
248,455 | rbarrois/confutils | confutils/configfile.py | ConfigFile.get_line | def get_line(self, section, line):
"""Retrieve all lines compatible with a given line."""
try:
section = self._get_section(section, create=False)
except KeyError:
return []
return section.find_lines(line) | python | def get_line(self, section, line):
"""Retrieve all lines compatible with a given line."""
try:
section = self._get_section(section, create=False)
except KeyError:
return []
return section.find_lines(line) | [
"def",
"get_line",
"(",
"self",
",",
"section",
",",
"line",
")",
":",
"try",
":",
"section",
"=",
"self",
".",
"_get_section",
"(",
"section",
",",
"create",
"=",
"False",
")",
"except",
"KeyError",
":",
"return",
"[",
"]",
"return",
"section",
".",
... | Retrieve all lines compatible with a given line. | [
"Retrieve",
"all",
"lines",
"compatible",
"with",
"a",
"given",
"line",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L358-L364 |
248,456 | rbarrois/confutils | confutils/configfile.py | ConfigFile.iter_lines | def iter_lines(self, section):
"""Iterate over all lines in a section.
This will skip 'header' lines.
"""
try:
section = self._get_section(section, create=False)
except KeyError:
return
for block in section:
for line in block:
... | python | def iter_lines(self, section):
"""Iterate over all lines in a section.
This will skip 'header' lines.
"""
try:
section = self._get_section(section, create=False)
except KeyError:
return
for block in section:
for line in block:
... | [
"def",
"iter_lines",
"(",
"self",
",",
"section",
")",
":",
"try",
":",
"section",
"=",
"self",
".",
"_get_section",
"(",
"section",
",",
"create",
"=",
"False",
")",
"except",
"KeyError",
":",
"return",
"for",
"block",
"in",
"section",
":",
"for",
"li... | Iterate over all lines in a section.
This will skip 'header' lines. | [
"Iterate",
"over",
"all",
"lines",
"in",
"a",
"section",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L366-L378 |
248,457 | rbarrois/confutils | confutils/configfile.py | ConfigFile.enter_block | def enter_block(self, name):
"""Mark 'entering a block'."""
section = self._get_section(name)
block = self.current_block = section.new_block()
self.blocks.append(block)
return block | python | def enter_block(self, name):
"""Mark 'entering a block'."""
section = self._get_section(name)
block = self.current_block = section.new_block()
self.blocks.append(block)
return block | [
"def",
"enter_block",
"(",
"self",
",",
"name",
")",
":",
"section",
"=",
"self",
".",
"_get_section",
"(",
"name",
")",
"block",
"=",
"self",
".",
"current_block",
"=",
"section",
".",
"new_block",
"(",
")",
"self",
".",
"blocks",
".",
"append",
"(",
... | Mark 'entering a block'. | [
"Mark",
"entering",
"a",
"block",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L383-L388 |
248,458 | rbarrois/confutils | confutils/configfile.py | ConfigFile.insert_line | def insert_line(self, line):
"""Insert a new line"""
if self.current_block is not None:
self.current_block.append(line)
else:
self.header.append(line) | python | def insert_line(self, line):
"""Insert a new line"""
if self.current_block is not None:
self.current_block.append(line)
else:
self.header.append(line) | [
"def",
"insert_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"self",
".",
"current_block",
"is",
"not",
"None",
":",
"self",
".",
"current_block",
".",
"append",
"(",
"line",
")",
"else",
":",
"self",
".",
"header",
".",
"append",
"(",
"line",
")"... | Insert a new line | [
"Insert",
"a",
"new",
"line"
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L390-L395 |
248,459 | rbarrois/confutils | confutils/configfile.py | ConfigFile.handle_line | def handle_line(self, line):
"""Read one line."""
if line.kind == ConfigLine.KIND_HEADER:
self.enter_block(line.header)
else:
self.insert_line(line) | python | def handle_line(self, line):
"""Read one line."""
if line.kind == ConfigLine.KIND_HEADER:
self.enter_block(line.header)
else:
self.insert_line(line) | [
"def",
"handle_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"line",
".",
"kind",
"==",
"ConfigLine",
".",
"KIND_HEADER",
":",
"self",
".",
"enter_block",
"(",
"line",
".",
"header",
")",
"else",
":",
"self",
".",
"insert_line",
"(",
"line",
")"
] | Read one line. | [
"Read",
"one",
"line",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L397-L402 |
248,460 | rbarrois/confutils | confutils/configfile.py | ConfigFile.parse | def parse(self, fileobj, name_hint='', parser=None):
"""Fill from a file-like object."""
self.current_block = None # Reset current block
parser = parser or Parser()
for line in parser.parse(fileobj, name_hint=name_hint):
self.handle_line(line) | python | def parse(self, fileobj, name_hint='', parser=None):
"""Fill from a file-like object."""
self.current_block = None # Reset current block
parser = parser or Parser()
for line in parser.parse(fileobj, name_hint=name_hint):
self.handle_line(line) | [
"def",
"parse",
"(",
"self",
",",
"fileobj",
",",
"name_hint",
"=",
"''",
",",
"parser",
"=",
"None",
")",
":",
"self",
".",
"current_block",
"=",
"None",
"# Reset current block",
"parser",
"=",
"parser",
"or",
"Parser",
"(",
")",
"for",
"line",
"in",
... | Fill from a file-like object. | [
"Fill",
"from",
"a",
"file",
"-",
"like",
"object",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L404-L409 |
248,461 | rbarrois/confutils | confutils/configfile.py | ConfigFile.remove_line | def remove_line(self, section, line):
"""Remove all instances of a line.
Returns:
int: the number of lines removed
"""
try:
s = self._get_section(section, create=False)
except KeyError:
# No such section, skip.
return 0
re... | python | def remove_line(self, section, line):
"""Remove all instances of a line.
Returns:
int: the number of lines removed
"""
try:
s = self._get_section(section, create=False)
except KeyError:
# No such section, skip.
return 0
re... | [
"def",
"remove_line",
"(",
"self",
",",
"section",
",",
"line",
")",
":",
"try",
":",
"s",
"=",
"self",
".",
"_get_section",
"(",
"section",
",",
"create",
"=",
"False",
")",
"except",
"KeyError",
":",
"# No such section, skip.",
"return",
"0",
"return",
... | Remove all instances of a line.
Returns:
int: the number of lines removed | [
"Remove",
"all",
"instances",
"of",
"a",
"line",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L448-L460 |
248,462 | rbarrois/confutils | confutils/configfile.py | ConfigFile.add_or_update | def add_or_update(self, section, key, value):
"""Update the key or, if no previous value existed, add it.
Returns:
int: Number of updated lines.
"""
updates = self.update(section, key, value)
if updates == 0:
self.add(section, key, value)
return u... | python | def add_or_update(self, section, key, value):
"""Update the key or, if no previous value existed, add it.
Returns:
int: Number of updated lines.
"""
updates = self.update(section, key, value)
if updates == 0:
self.add(section, key, value)
return u... | [
"def",
"add_or_update",
"(",
"self",
",",
"section",
",",
"key",
",",
"value",
")",
":",
"updates",
"=",
"self",
".",
"update",
"(",
"section",
",",
"key",
",",
"value",
")",
"if",
"updates",
"==",
"0",
":",
"self",
".",
"add",
"(",
"section",
",",... | Update the key or, if no previous value existed, add it.
Returns:
int: Number of updated lines. | [
"Update",
"the",
"key",
"or",
"if",
"no",
"previous",
"value",
"existed",
"add",
"it",
"."
] | 26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4 | https://github.com/rbarrois/confutils/blob/26bbb3f31c09a99ee2104263a9e97d6d3fc8e4f4/confutils/configfile.py#L500-L509 |
248,463 | minhhoit/yacms | yacms/utils/cache.py | cache_set | def cache_set(key, value, timeout=None, refreshed=False):
"""
Wrapper for ``cache.set``. Stores the cache entry packed with
the desired cache expiry time. When the entry is retrieved from
cache, the packed expiry time is also checked, and if past,
the stale cache entry is stored again with an expiry... | python | def cache_set(key, value, timeout=None, refreshed=False):
"""
Wrapper for ``cache.set``. Stores the cache entry packed with
the desired cache expiry time. When the entry is retrieved from
cache, the packed expiry time is also checked, and if past,
the stale cache entry is stored again with an expiry... | [
"def",
"cache_set",
"(",
"key",
",",
"value",
",",
"timeout",
"=",
"None",
",",
"refreshed",
"=",
"False",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"settings",
".",
"CACHE_MIDDLEWARE_SECONDS",
"refresh_time",
"=",
"timeout",
"+",
"time... | Wrapper for ``cache.set``. Stores the cache entry packed with
the desired cache expiry time. When the entry is retrieved from
cache, the packed expiry time is also checked, and if past,
the stale cache entry is stored again with an expiry that has
``CACHE_SET_DELAY_SECONDS`` added to it. In this case th... | [
"Wrapper",
"for",
"cache",
".",
"set",
".",
"Stores",
"the",
"cache",
"entry",
"packed",
"with",
"the",
"desired",
"cache",
"expiry",
"time",
".",
"When",
"the",
"entry",
"is",
"retrieved",
"from",
"cache",
"the",
"packed",
"expiry",
"time",
"is",
"also",
... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L26-L42 |
248,464 | minhhoit/yacms | yacms/utils/cache.py | cache_installed | def cache_installed():
"""
Returns ``True`` if a cache backend is configured, and the
cache middleware classes or subclasses thereof are present.
This will be evaluated once per run, and then cached.
"""
has_key = bool(getattr(settings, "NEVERCACHE_KEY", ""))
def flatten(seqs):
retu... | python | def cache_installed():
"""
Returns ``True`` if a cache backend is configured, and the
cache middleware classes or subclasses thereof are present.
This will be evaluated once per run, and then cached.
"""
has_key = bool(getattr(settings, "NEVERCACHE_KEY", ""))
def flatten(seqs):
retu... | [
"def",
"cache_installed",
"(",
")",
":",
"has_key",
"=",
"bool",
"(",
"getattr",
"(",
"settings",
",",
"\"NEVERCACHE_KEY\"",
",",
"\"\"",
")",
")",
"def",
"flatten",
"(",
"seqs",
")",
":",
"return",
"(",
"item",
"for",
"seq",
"in",
"seqs",
"for",
"item... | Returns ``True`` if a cache backend is configured, and the
cache middleware classes or subclasses thereof are present.
This will be evaluated once per run, and then cached. | [
"Returns",
"True",
"if",
"a",
"cache",
"backend",
"is",
"configured",
"and",
"the",
"cache",
"middleware",
"classes",
"or",
"subclasses",
"thereof",
"are",
"present",
".",
"This",
"will",
"be",
"evaluated",
"once",
"per",
"run",
"and",
"then",
"cached",
"."
... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L63-L83 |
248,465 | minhhoit/yacms | yacms/utils/cache.py | cache_key_prefix | def cache_key_prefix(request):
"""
Cache key for yacms's cache middleware. Adds the current
device and site ID.
"""
cache_key = "%s.%s.%s." % (
settings.CACHE_MIDDLEWARE_KEY_PREFIX,
current_site_id(),
device_from_request(request) or "default",
)
return _i18n_cache_key... | python | def cache_key_prefix(request):
"""
Cache key for yacms's cache middleware. Adds the current
device and site ID.
"""
cache_key = "%s.%s.%s." % (
settings.CACHE_MIDDLEWARE_KEY_PREFIX,
current_site_id(),
device_from_request(request) or "default",
)
return _i18n_cache_key... | [
"def",
"cache_key_prefix",
"(",
"request",
")",
":",
"cache_key",
"=",
"\"%s.%s.%s.\"",
"%",
"(",
"settings",
".",
"CACHE_MIDDLEWARE_KEY_PREFIX",
",",
"current_site_id",
"(",
")",
",",
"device_from_request",
"(",
"request",
")",
"or",
"\"default\"",
",",
")",
"r... | Cache key for yacms's cache middleware. Adds the current
device and site ID. | [
"Cache",
"key",
"for",
"yacms",
"s",
"cache",
"middleware",
".",
"Adds",
"the",
"current",
"device",
"and",
"site",
"ID",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L86-L96 |
248,466 | minhhoit/yacms | yacms/utils/cache.py | add_cache_bypass | def add_cache_bypass(url):
"""
Adds the current time to the querystring of the URL to force a
cache reload. Used for when a form post redirects back to a
page that should display updated content, such as new comments or
ratings.
"""
if not cache_installed():
return url
hash_str =... | python | def add_cache_bypass(url):
"""
Adds the current time to the querystring of the URL to force a
cache reload. Used for when a form post redirects back to a
page that should display updated content, such as new comments or
ratings.
"""
if not cache_installed():
return url
hash_str =... | [
"def",
"add_cache_bypass",
"(",
"url",
")",
":",
"if",
"not",
"cache_installed",
"(",
")",
":",
"return",
"url",
"hash_str",
"=",
"\"\"",
"if",
"\"#\"",
"in",
"url",
":",
"url",
",",
"hash_str",
"=",
"url",
".",
"split",
"(",
"\"#\"",
",",
"1",
")",
... | Adds the current time to the querystring of the URL to force a
cache reload. Used for when a form post redirects back to a
page that should display updated content, such as new comments or
ratings. | [
"Adds",
"the",
"current",
"time",
"to",
"the",
"querystring",
"of",
"the",
"URL",
"to",
"force",
"a",
"cache",
"reload",
".",
"Used",
"for",
"when",
"a",
"form",
"post",
"redirects",
"back",
"to",
"a",
"page",
"that",
"should",
"display",
"updated",
"con... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/utils/cache.py#L107-L121 |
248,467 | xtrementl/focus | focus/plugin/modules/im.py | _dbus_get_object | def _dbus_get_object(bus_name, object_name):
""" Fetches DBUS proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
Returns object or ``None``.
"""
try:
bus = dbus.... | python | def _dbus_get_object(bus_name, object_name):
""" Fetches DBUS proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
Returns object or ``None``.
"""
try:
bus = dbus.... | [
"def",
"_dbus_get_object",
"(",
"bus_name",
",",
"object_name",
")",
":",
"try",
":",
"bus",
"=",
"dbus",
".",
"SessionBus",
"(",
")",
"obj",
"=",
"bus",
".",
"get_object",
"(",
"bus_name",
",",
"object_name",
")",
"return",
"obj",
"except",
"(",
"NameEr... | Fetches DBUS proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
Returns object or ``None``. | [
"Fetches",
"DBUS",
"proxy",
"object",
"given",
"the",
"specified",
"parameters",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L50-L67 |
248,468 | xtrementl/focus | focus/plugin/modules/im.py | _dbus_get_interface | def _dbus_get_interface(bus_name, object_name, interface_name):
""" Fetches DBUS interface proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
`interface_name`
Name of the ... | python | def _dbus_get_interface(bus_name, object_name, interface_name):
""" Fetches DBUS interface proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
`interface_name`
Name of the ... | [
"def",
"_dbus_get_interface",
"(",
"bus_name",
",",
"object_name",
",",
"interface_name",
")",
":",
"try",
":",
"obj",
"=",
"_dbus_get_object",
"(",
"bus_name",
",",
"object_name",
")",
"if",
"not",
"obj",
":",
"raise",
"NameError",
"return",
"dbus",
".",
"I... | Fetches DBUS interface proxy object given the specified parameters.
`bus_name`
Name of the bus interface.
`object_name`
Object path related to the interface.
`interface_name`
Name of the interface.
Returns object or ``None``. | [
"Fetches",
"DBUS",
"interface",
"proxy",
"object",
"given",
"the",
"specified",
"parameters",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L70-L90 |
248,469 | xtrementl/focus | focus/plugin/modules/im.py | _pidgin_status | def _pidgin_status(status, message):
""" Updates status and message for Pidgin IM application.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('im.pidgin.purple.PurpleService',
'/im... | python | def _pidgin_status(status, message):
""" Updates status and message for Pidgin IM application.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('im.pidgin.purple.PurpleService',
'/im... | [
"def",
"_pidgin_status",
"(",
"status",
",",
"message",
")",
":",
"try",
":",
"iface",
"=",
"_dbus_get_interface",
"(",
"'im.pidgin.purple.PurpleService'",
",",
"'/im/pidgin/purple/PurpleObject'",
",",
"'im.pidgin.purple.PurpleInterface'",
")",
"if",
"iface",
":",
"# cr... | Updates status and message for Pidgin IM application.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Pidgin",
"IM",
"application",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L93-L119 |
248,470 | xtrementl/focus | focus/plugin/modules/im.py | _empathy_status | def _empathy_status(status, message):
""" Updates status and message for Empathy IM application.
`status`
Status type.
`message`
Status message.
"""
ACCT_IFACE = 'org.freedesktop.Telepathy.Account'
DBUS_PROP_IFACE = 'org.freedesktop.DBus.Properties'
ACCT... | python | def _empathy_status(status, message):
""" Updates status and message for Empathy IM application.
`status`
Status type.
`message`
Status message.
"""
ACCT_IFACE = 'org.freedesktop.Telepathy.Account'
DBUS_PROP_IFACE = 'org.freedesktop.DBus.Properties'
ACCT... | [
"def",
"_empathy_status",
"(",
"status",
",",
"message",
")",
":",
"ACCT_IFACE",
"=",
"'org.freedesktop.Telepathy.Account'",
"DBUS_PROP_IFACE",
"=",
"'org.freedesktop.DBus.Properties'",
"ACCT_MAN_IFACE",
"=",
"'org.freedesktop.Telepathy.AccountManager'",
"ACCT_MAN_PATH",
"=",
"... | Updates status and message for Empathy IM application.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Empathy",
"IM",
"application",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L165-L213 |
248,471 | xtrementl/focus | focus/plugin/modules/im.py | _linux_skype_status | def _linux_skype_status(status, message):
""" Updates status and message for Skype IM application on Linux.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('com.Skype.API',
'/com/Sk... | python | def _linux_skype_status(status, message):
""" Updates status and message for Skype IM application on Linux.
`status`
Status type.
`message`
Status message.
"""
try:
iface = _dbus_get_interface('com.Skype.API',
'/com/Sk... | [
"def",
"_linux_skype_status",
"(",
"status",
",",
"message",
")",
":",
"try",
":",
"iface",
"=",
"_dbus_get_interface",
"(",
"'com.Skype.API'",
",",
"'/com/Skype'",
",",
"'com.Skype.API'",
")",
"if",
"iface",
":",
"# authenticate",
"if",
"iface",
".",
"Invoke",
... | Updates status and message for Skype IM application on Linux.
`status`
Status type.
`message`
Status message. | [
"Updates",
"status",
"and",
"message",
"for",
"Skype",
"IM",
"application",
"on",
"Linux",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L216-L244 |
248,472 | xtrementl/focus | focus/plugin/modules/im.py | IMStatus._set_status | def _set_status(self, status, message=''):
""" Updates the status and message on all supported IM apps.
`status`
Status type (See ``VALID_STATUSES``).
`message`
Status message.
"""
message = message.strip()
# fetch away messa... | python | def _set_status(self, status, message=''):
""" Updates the status and message on all supported IM apps.
`status`
Status type (See ``VALID_STATUSES``).
`message`
Status message.
"""
message = message.strip()
# fetch away messa... | [
"def",
"_set_status",
"(",
"self",
",",
"status",
",",
"message",
"=",
"''",
")",
":",
"message",
"=",
"message",
".",
"strip",
"(",
")",
"# fetch away message from provided id",
"if",
"message",
".",
"startswith",
"(",
"':'",
")",
":",
"msg_id",
"=",
"mes... | Updates the status and message on all supported IM apps.
`status`
Status type (See ``VALID_STATUSES``).
`message`
Status message. | [
"Updates",
"the",
"status",
"and",
"message",
"on",
"all",
"supported",
"IM",
"apps",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L389-L409 |
248,473 | xtrementl/focus | focus/plugin/modules/im.py | IMStatus.parse_option | def parse_option(self, option, block_name, *values):
""" Parse status, end_status, timer_status and status_msg options.
"""
if option.endswith('status'):
status = values[0]
if status not in self.VALID_STATUSES:
raise ValueError(u'Invalid IM status "{0... | python | def parse_option(self, option, block_name, *values):
""" Parse status, end_status, timer_status and status_msg options.
"""
if option.endswith('status'):
status = values[0]
if status not in self.VALID_STATUSES:
raise ValueError(u'Invalid IM status "{0... | [
"def",
"parse_option",
"(",
"self",
",",
"option",
",",
"block_name",
",",
"*",
"values",
")",
":",
"if",
"option",
".",
"endswith",
"(",
"'status'",
")",
":",
"status",
"=",
"values",
"[",
"0",
"]",
"if",
"status",
"not",
"in",
"self",
".",
"VALID_S... | Parse status, end_status, timer_status and status_msg options. | [
"Parse",
"status",
"end_status",
"timer_status",
"and",
"status_msg",
"options",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/plugin/modules/im.py#L411-L434 |
248,474 | cirruscluster/cirruscluster | cirruscluster/core.py | GetNumCoresOnHosts | def GetNumCoresOnHosts(hosts, private_key):
""" Returns list of the number of cores for each host requested in hosts. """
results = runner.Runner(host_list=hosts, private_key=private_key,
module_name='setup').run()
num_cores_list = []
for _, props in results['contacted'].iteritems():
... | python | def GetNumCoresOnHosts(hosts, private_key):
""" Returns list of the number of cores for each host requested in hosts. """
results = runner.Runner(host_list=hosts, private_key=private_key,
module_name='setup').run()
num_cores_list = []
for _, props in results['contacted'].iteritems():
... | [
"def",
"GetNumCoresOnHosts",
"(",
"hosts",
",",
"private_key",
")",
":",
"results",
"=",
"runner",
".",
"Runner",
"(",
"host_list",
"=",
"hosts",
",",
"private_key",
"=",
"private_key",
",",
"module_name",
"=",
"'setup'",
")",
".",
"run",
"(",
")",
"num_co... | Returns list of the number of cores for each host requested in hosts. | [
"Returns",
"list",
"of",
"the",
"number",
"of",
"cores",
"for",
"each",
"host",
"requested",
"in",
"hosts",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L91-L104 |
248,475 | cirruscluster/cirruscluster | cirruscluster/core.py | RunPlaybookOnHosts | def RunPlaybookOnHosts(playbook_path, hosts, private_key, extra_vars=None):
""" Runs the playbook and returns True if it completes successfully on all
hosts. """
inventory = ansible_inventory.Inventory(hosts)
if not inventory.list_hosts():
raise RuntimeError("Host list is empty.")
stats = callbacks.Aggreg... | python | def RunPlaybookOnHosts(playbook_path, hosts, private_key, extra_vars=None):
""" Runs the playbook and returns True if it completes successfully on all
hosts. """
inventory = ansible_inventory.Inventory(hosts)
if not inventory.list_hosts():
raise RuntimeError("Host list is empty.")
stats = callbacks.Aggreg... | [
"def",
"RunPlaybookOnHosts",
"(",
"playbook_path",
",",
"hosts",
",",
"private_key",
",",
"extra_vars",
"=",
"None",
")",
":",
"inventory",
"=",
"ansible_inventory",
".",
"Inventory",
"(",
"hosts",
")",
"if",
"not",
"inventory",
".",
"list_hosts",
"(",
")",
... | Runs the playbook and returns True if it completes successfully on all
hosts. | [
"Runs",
"the",
"playbook",
"and",
"returns",
"True",
"if",
"it",
"completes",
"successfully",
"on",
"all",
"hosts",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L106-L141 |
248,476 | cirruscluster/cirruscluster | cirruscluster/core.py | RunPlaybookOnHost | def RunPlaybookOnHost(playbook_path, host, private_key, extra_vars=None):
"""
Runs the playbook and returns True if it completes successfully on
a single host.
"""
return RunPlaybookOnHosts(playbook_path, [host], private_key, extra_vars) | python | def RunPlaybookOnHost(playbook_path, host, private_key, extra_vars=None):
"""
Runs the playbook and returns True if it completes successfully on
a single host.
"""
return RunPlaybookOnHosts(playbook_path, [host], private_key, extra_vars) | [
"def",
"RunPlaybookOnHost",
"(",
"playbook_path",
",",
"host",
",",
"private_key",
",",
"extra_vars",
"=",
"None",
")",
":",
"return",
"RunPlaybookOnHosts",
"(",
"playbook_path",
",",
"[",
"host",
"]",
",",
"private_key",
",",
"extra_vars",
")"
] | Runs the playbook and returns True if it completes successfully on
a single host. | [
"Runs",
"the",
"playbook",
"and",
"returns",
"True",
"if",
"it",
"completes",
"successfully",
"on",
"a",
"single",
"host",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L143-L148 |
248,477 | cirruscluster/cirruscluster | cirruscluster/core.py | ExecuteCmd | def ExecuteCmd(cmd, quiet=False):
""" Run a command in a shell. """
result = None
if quiet:
with open(os.devnull, "w") as fnull:
result = subprocess.call(cmd, shell=True, stdout=fnull, stderr=fnull)
else:
result = subprocess.call(cmd, shell=True)
return result | python | def ExecuteCmd(cmd, quiet=False):
""" Run a command in a shell. """
result = None
if quiet:
with open(os.devnull, "w") as fnull:
result = subprocess.call(cmd, shell=True, stdout=fnull, stderr=fnull)
else:
result = subprocess.call(cmd, shell=True)
return result | [
"def",
"ExecuteCmd",
"(",
"cmd",
",",
"quiet",
"=",
"False",
")",
":",
"result",
"=",
"None",
"if",
"quiet",
":",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"\"w\"",
")",
"as",
"fnull",
":",
"result",
"=",
"subprocess",
".",
"call",
"(",
"cmd"... | Run a command in a shell. | [
"Run",
"a",
"command",
"in",
"a",
"shell",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L154-L162 |
248,478 | cirruscluster/cirruscluster | cirruscluster/core.py | CheckOutput | def CheckOutput(*popenargs, **kwargs):
"""
Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
"""
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, _ = process.communicate()
retcode = pr... | python | def CheckOutput(*popenargs, **kwargs):
"""
Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib.
"""
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
output, _ = process.communicate()
retcode = pr... | [
"def",
"CheckOutput",
"(",
"*",
"popenargs",
",",
"*",
"*",
"kwargs",
")",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"*",
"popenargs",
",",
"*",
"*",
"kwargs",
")",
"output",
",",
"_",
"=",
... | Run command with arguments and return its output as a byte string.
Backported from Python 2.7 as it's implemented as pure python on stdlib. | [
"Run",
"command",
"with",
"arguments",
"and",
"return",
"its",
"output",
"as",
"a",
"byte",
"string",
".",
"Backported",
"from",
"Python",
"2",
".",
"7",
"as",
"it",
"s",
"implemented",
"as",
"pure",
"python",
"on",
"stdlib",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L164-L179 |
248,479 | cirruscluster/cirruscluster | cirruscluster/core.py | UrlGet | def UrlGet(url, timeout=10, retries=0):
""" Retrieve content from the given URL. """
# in Python 2.6 we can pass timeout to urllib2.urlopen
socket.setdefaulttimeout(timeout)
attempts = 0
content = None
while not content:
try:
content = urllib2.urlopen(url).read()
except urllib2.URLErr... | python | def UrlGet(url, timeout=10, retries=0):
""" Retrieve content from the given URL. """
# in Python 2.6 we can pass timeout to urllib2.urlopen
socket.setdefaulttimeout(timeout)
attempts = 0
content = None
while not content:
try:
content = urllib2.urlopen(url).read()
except urllib2.URLErr... | [
"def",
"UrlGet",
"(",
"url",
",",
"timeout",
"=",
"10",
",",
"retries",
"=",
"0",
")",
":",
"# in Python 2.6 we can pass timeout to urllib2.urlopen",
"socket",
".",
"setdefaulttimeout",
"(",
"timeout",
")",
"attempts",
"=",
"0",
"content",
"=",
"None",
"while",
... | Retrieve content from the given URL. | [
"Retrieve",
"content",
"from",
"the",
"given",
"URL",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L181-L194 |
248,480 | cirruscluster/cirruscluster | cirruscluster/core.py | ReadRemoteFile | def ReadRemoteFile(remote_file_path, hostname, ssh_key):
""" Reads a remote file into a string. """
cmd = 'sudo cat %s' % remote_file_path
exit_code, output = RunCommandOnHost(cmd, hostname, ssh_key)
if exit_code:
raise IOError('Can not read remote path: %s' % (remote_file_path))
return output | python | def ReadRemoteFile(remote_file_path, hostname, ssh_key):
""" Reads a remote file into a string. """
cmd = 'sudo cat %s' % remote_file_path
exit_code, output = RunCommandOnHost(cmd, hostname, ssh_key)
if exit_code:
raise IOError('Can not read remote path: %s' % (remote_file_path))
return output | [
"def",
"ReadRemoteFile",
"(",
"remote_file_path",
",",
"hostname",
",",
"ssh_key",
")",
":",
"cmd",
"=",
"'sudo cat %s'",
"%",
"remote_file_path",
"exit_code",
",",
"output",
"=",
"RunCommandOnHost",
"(",
"cmd",
",",
"hostname",
",",
"ssh_key",
")",
"if",
"exi... | Reads a remote file into a string. | [
"Reads",
"a",
"remote",
"file",
"into",
"a",
"string",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L226-L232 |
248,481 | cirruscluster/cirruscluster | cirruscluster/core.py | __RemoteExecuteHelper | def __RemoteExecuteHelper(args):
""" Helper for multiprocessing. """
cmd, hostname, ssh_key = args
#Random.atfork() # needed to fix bug in old python 2.6 interpreters
private_key = paramiko.RSAKey.from_private_key(StringIO.StringIO(ssh_key))
client = paramiko.SSHClient()
client.set_missing_host_key_policy(... | python | def __RemoteExecuteHelper(args):
""" Helper for multiprocessing. """
cmd, hostname, ssh_key = args
#Random.atfork() # needed to fix bug in old python 2.6 interpreters
private_key = paramiko.RSAKey.from_private_key(StringIO.StringIO(ssh_key))
client = paramiko.SSHClient()
client.set_missing_host_key_policy(... | [
"def",
"__RemoteExecuteHelper",
"(",
"args",
")",
":",
"cmd",
",",
"hostname",
",",
"ssh_key",
"=",
"args",
"#Random.atfork() # needed to fix bug in old python 2.6 interpreters",
"private_key",
"=",
"paramiko",
".",
"RSAKey",
".",
"from_private_key",
"(",
"StringIO",
"... | Helper for multiprocessing. | [
"Helper",
"for",
"multiprocessing",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L241-L264 |
248,482 | cirruscluster/cirruscluster | cirruscluster/core.py | WaitForHostsReachable | def WaitForHostsReachable(hostnames, ssh_key):
""" Blocks until host is reachable via ssh. """
while True:
unreachable = GetUnreachableHosts(hostnames, ssh_key)
if unreachable:
print 'waiting for unreachable hosts: %s' % unreachable
time.sleep(5)
else:
break
return | python | def WaitForHostsReachable(hostnames, ssh_key):
""" Blocks until host is reachable via ssh. """
while True:
unreachable = GetUnreachableHosts(hostnames, ssh_key)
if unreachable:
print 'waiting for unreachable hosts: %s' % unreachable
time.sleep(5)
else:
break
return | [
"def",
"WaitForHostsReachable",
"(",
"hostnames",
",",
"ssh_key",
")",
":",
"while",
"True",
":",
"unreachable",
"=",
"GetUnreachableHosts",
"(",
"hostnames",
",",
"ssh_key",
")",
"if",
"unreachable",
":",
"print",
"'waiting for unreachable hosts: %s'",
"%",
"unreac... | Blocks until host is reachable via ssh. | [
"Blocks",
"until",
"host",
"is",
"reachable",
"via",
"ssh",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L283-L292 |
248,483 | cirruscluster/cirruscluster | cirruscluster/core.py | GetUnreachableInstances | def GetUnreachableInstances(instances, ssh_key):
""" Returns list of instances unreachable via ssh. """
hostnames = [i.private_ip for i in instances]
ssh_status = AreHostsReachable(hostnames, ssh_key)
assert(len(hostnames) == len(ssh_status))
nonresponsive_instances = [instance for (instance, ssh_ok) in
... | python | def GetUnreachableInstances(instances, ssh_key):
""" Returns list of instances unreachable via ssh. """
hostnames = [i.private_ip for i in instances]
ssh_status = AreHostsReachable(hostnames, ssh_key)
assert(len(hostnames) == len(ssh_status))
nonresponsive_instances = [instance for (instance, ssh_ok) in
... | [
"def",
"GetUnreachableInstances",
"(",
"instances",
",",
"ssh_key",
")",
":",
"hostnames",
"=",
"[",
"i",
".",
"private_ip",
"for",
"i",
"in",
"instances",
"]",
"ssh_status",
"=",
"AreHostsReachable",
"(",
"hostnames",
",",
"ssh_key",
")",
"assert",
"(",
"le... | Returns list of instances unreachable via ssh. | [
"Returns",
"list",
"of",
"instances",
"unreachable",
"via",
"ssh",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L294-L301 |
248,484 | cirruscluster/cirruscluster | cirruscluster/core.py | GetUnreachableHosts | def GetUnreachableHosts(hostnames, ssh_key):
""" Returns list of hosts unreachable via ssh. """
ssh_status = AreHostsReachable(hostnames, ssh_key)
assert(len(hostnames) == len(ssh_status))
nonresponsive_hostnames = [host for (host, ssh_ok) in
zip(hostnames, ssh_status) if not ssh_ok... | python | def GetUnreachableHosts(hostnames, ssh_key):
""" Returns list of hosts unreachable via ssh. """
ssh_status = AreHostsReachable(hostnames, ssh_key)
assert(len(hostnames) == len(ssh_status))
nonresponsive_hostnames = [host for (host, ssh_ok) in
zip(hostnames, ssh_status) if not ssh_ok... | [
"def",
"GetUnreachableHosts",
"(",
"hostnames",
",",
"ssh_key",
")",
":",
"ssh_status",
"=",
"AreHostsReachable",
"(",
"hostnames",
",",
"ssh_key",
")",
"assert",
"(",
"len",
"(",
"hostnames",
")",
"==",
"len",
"(",
"ssh_status",
")",
")",
"nonresponsive_hostn... | Returns list of hosts unreachable via ssh. | [
"Returns",
"list",
"of",
"hosts",
"unreachable",
"via",
"ssh",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L303-L309 |
248,485 | cirruscluster/cirruscluster | cirruscluster/core.py | AreHostsReachable | def AreHostsReachable(hostnames, ssh_key):
""" Returns list of bools indicating if host reachable via ssh. """
# validate input
for hostname in hostnames:
assert(len(hostname))
ssh_ok = [exit_code == 0 for (exit_code, _) in
RunCommandOnHosts('echo test > /dev/null', hostnames, ssh_key)]
return... | python | def AreHostsReachable(hostnames, ssh_key):
""" Returns list of bools indicating if host reachable via ssh. """
# validate input
for hostname in hostnames:
assert(len(hostname))
ssh_ok = [exit_code == 0 for (exit_code, _) in
RunCommandOnHosts('echo test > /dev/null', hostnames, ssh_key)]
return... | [
"def",
"AreHostsReachable",
"(",
"hostnames",
",",
"ssh_key",
")",
":",
"# validate input",
"for",
"hostname",
"in",
"hostnames",
":",
"assert",
"(",
"len",
"(",
"hostname",
")",
")",
"ssh_ok",
"=",
"[",
"exit_code",
"==",
"0",
"for",
"(",
"exit_code",
","... | Returns list of bools indicating if host reachable via ssh. | [
"Returns",
"list",
"of",
"bools",
"indicating",
"if",
"host",
"reachable",
"via",
"ssh",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L311-L318 |
248,486 | cirruscluster/cirruscluster | cirruscluster/core.py | AmiName | def AmiName(ami_release_name, ubuntu_release_name, virtualization_type,
mapr_version, role):
""" Returns AMI name using Cirrus ami naming convention. """
if not role in valid_instance_roles:
raise RuntimeError('Specified role (%s) not a valid role: %s' %
(role, valid_instanc... | python | def AmiName(ami_release_name, ubuntu_release_name, virtualization_type,
mapr_version, role):
""" Returns AMI name using Cirrus ami naming convention. """
if not role in valid_instance_roles:
raise RuntimeError('Specified role (%s) not a valid role: %s' %
(role, valid_instanc... | [
"def",
"AmiName",
"(",
"ami_release_name",
",",
"ubuntu_release_name",
",",
"virtualization_type",
",",
"mapr_version",
",",
"role",
")",
":",
"if",
"not",
"role",
"in",
"valid_instance_roles",
":",
"raise",
"RuntimeError",
"(",
"'Specified role (%s) not a valid role: %... | Returns AMI name using Cirrus ami naming convention. | [
"Returns",
"AMI",
"name",
"using",
"Cirrus",
"ami",
"naming",
"convention",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L324-L337 |
248,487 | cirruscluster/cirruscluster | cirruscluster/core.py | LookupCirrusAmi | def LookupCirrusAmi(ec2, instance_type, ubuntu_release_name, mapr_version, role,
ami_release_name,
ami_owner_id):
""" Returns AMI satisfying provided constraints. """
if not role in valid_instance_roles:
raise RuntimeError('Specified role (%s) not a valid role: %s' % (r... | python | def LookupCirrusAmi(ec2, instance_type, ubuntu_release_name, mapr_version, role,
ami_release_name,
ami_owner_id):
""" Returns AMI satisfying provided constraints. """
if not role in valid_instance_roles:
raise RuntimeError('Specified role (%s) not a valid role: %s' % (r... | [
"def",
"LookupCirrusAmi",
"(",
"ec2",
",",
"instance_type",
",",
"ubuntu_release_name",
",",
"mapr_version",
",",
"role",
",",
"ami_release_name",
",",
"ami_owner_id",
")",
":",
"if",
"not",
"role",
"in",
"valid_instance_roles",
":",
"raise",
"RuntimeError",
"(",
... | Returns AMI satisfying provided constraints. | [
"Returns",
"AMI",
"satisfying",
"provided",
"constraints",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L342-L361 |
248,488 | cirruscluster/cirruscluster | cirruscluster/core.py | GetRegion | def GetRegion(region_name):
""" Converts region name string into boto Region object. """
regions = boto_ec2.regions()
region = None
valid_region_names = []
for r in regions:
valid_region_names.append(r.name)
if r.name == region_name:
region = r
break
if not region:
logging.info( ... | python | def GetRegion(region_name):
""" Converts region name string into boto Region object. """
regions = boto_ec2.regions()
region = None
valid_region_names = []
for r in regions:
valid_region_names.append(r.name)
if r.name == region_name:
region = r
break
if not region:
logging.info( ... | [
"def",
"GetRegion",
"(",
"region_name",
")",
":",
"regions",
"=",
"boto_ec2",
".",
"regions",
"(",
")",
"region",
"=",
"None",
"valid_region_names",
"=",
"[",
"]",
"for",
"r",
"in",
"regions",
":",
"valid_region_names",
".",
"append",
"(",
"r",
".",
"nam... | Converts region name string into boto Region object. | [
"Converts",
"region",
"name",
"string",
"into",
"boto",
"Region",
"object",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L368-L382 |
248,489 | cirruscluster/cirruscluster | cirruscluster/core.py | PrivateToPublicOpenSSH | def PrivateToPublicOpenSSH(key, host):
""" Computes the OpenSSH public key format given a private key. """
# Create public key from private key.
ssh_rsa = '00000007' + base64.b16encode('ssh-rsa')
# Exponent.
exponent = '%x' % (key.e,)
if len(exponent) % 2:
exponent = '0' + exponent
ssh_rsa += '%08x'... | python | def PrivateToPublicOpenSSH(key, host):
""" Computes the OpenSSH public key format given a private key. """
# Create public key from private key.
ssh_rsa = '00000007' + base64.b16encode('ssh-rsa')
# Exponent.
exponent = '%x' % (key.e,)
if len(exponent) % 2:
exponent = '0' + exponent
ssh_rsa += '%08x'... | [
"def",
"PrivateToPublicOpenSSH",
"(",
"key",
",",
"host",
")",
":",
"# Create public key from private key.",
"ssh_rsa",
"=",
"'00000007'",
"+",
"base64",
".",
"b16encode",
"(",
"'ssh-rsa'",
")",
"# Exponent.",
"exponent",
"=",
"'%x'",
"%",
"(",
"key",
".",
"e",
... | Computes the OpenSSH public key format given a private key. | [
"Computes",
"the",
"OpenSSH",
"public",
"key",
"format",
"given",
"a",
"private",
"key",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L500-L519 |
248,490 | cirruscluster/cirruscluster | cirruscluster/core.py | InitKeypair | def InitKeypair(aws_id, aws_secret, ec2, s3, keypair_name, src_region,
dst_regions):
"""
Returns the ssh private key for the given keypair name Cirrus created bucket.
Creates the keypair if it doesn't yet exist and stores private key in S3.
"""
# check if a keypair has been created
metada... | python | def InitKeypair(aws_id, aws_secret, ec2, s3, keypair_name, src_region,
dst_regions):
"""
Returns the ssh private key for the given keypair name Cirrus created bucket.
Creates the keypair if it doesn't yet exist and stores private key in S3.
"""
# check if a keypair has been created
metada... | [
"def",
"InitKeypair",
"(",
"aws_id",
",",
"aws_secret",
",",
"ec2",
",",
"s3",
",",
"keypair_name",
",",
"src_region",
",",
"dst_regions",
")",
":",
"# check if a keypair has been created",
"metadata",
"=",
"CirrusAccessIdMetadata",
"(",
"s3",
",",
"aws_id",
")",
... | Returns the ssh private key for the given keypair name Cirrus created bucket.
Creates the keypair if it doesn't yet exist and stores private key in S3. | [
"Returns",
"the",
"ssh",
"private",
"key",
"for",
"the",
"given",
"keypair",
"name",
"Cirrus",
"created",
"bucket",
".",
"Creates",
"the",
"keypair",
"if",
"it",
"doesn",
"t",
"yet",
"exist",
"and",
"stores",
"private",
"key",
"in",
"S3",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L522-L549 |
248,491 | cirruscluster/cirruscluster | cirruscluster/core.py | __WaitForVolume | def __WaitForVolume(volume, desired_state):
""" Blocks until EBS volume is in desired state. """
print 'Waiting for volume %s to be %s...' % (volume.id, desired_state)
while True:
volume.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % volume.status
if volume.status =... | python | def __WaitForVolume(volume, desired_state):
""" Blocks until EBS volume is in desired state. """
print 'Waiting for volume %s to be %s...' % (volume.id, desired_state)
while True:
volume.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % volume.status
if volume.status =... | [
"def",
"__WaitForVolume",
"(",
"volume",
",",
"desired_state",
")",
":",
"print",
"'Waiting for volume %s to be %s...'",
"%",
"(",
"volume",
".",
"id",
",",
"desired_state",
")",
"while",
"True",
":",
"volume",
".",
"update",
"(",
")",
"sys",
".",
"stdout",
... | Blocks until EBS volume is in desired state. | [
"Blocks",
"until",
"EBS",
"volume",
"is",
"in",
"desired",
"state",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L586-L597 |
248,492 | cirruscluster/cirruscluster | cirruscluster/core.py | WaitForSnapshotCompleted | def WaitForSnapshotCompleted(snapshot):
""" Blocks until snapshot is complete. """
print 'Waiting for snapshot %s to be completed...' % (snapshot)
while True:
snapshot.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % snapshot.status
if snapshot.status == 'co... | python | def WaitForSnapshotCompleted(snapshot):
""" Blocks until snapshot is complete. """
print 'Waiting for snapshot %s to be completed...' % (snapshot)
while True:
snapshot.update()
sys.stdout.write('.')
sys.stdout.flush()
#print 'status is: %s' % snapshot.status
if snapshot.status == 'co... | [
"def",
"WaitForSnapshotCompleted",
"(",
"snapshot",
")",
":",
"print",
"'Waiting for snapshot %s to be completed...'",
"%",
"(",
"snapshot",
")",
"while",
"True",
":",
"snapshot",
".",
"update",
"(",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"'.'",
")",
"s... | Blocks until snapshot is complete. | [
"Blocks",
"until",
"snapshot",
"is",
"complete",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L599-L610 |
248,493 | cirruscluster/cirruscluster | cirruscluster/core.py | __WaitForInstance | def __WaitForInstance(instance, desired_state):
""" Blocks until instance is in desired_state. """
print 'Waiting for instance %s to change to %s' % (instance.id, desired_state)
while True:
try:
instance.update()
state = instance.state
sys.stdout.write('.')
sys.stdout... | python | def __WaitForInstance(instance, desired_state):
""" Blocks until instance is in desired_state. """
print 'Waiting for instance %s to change to %s' % (instance.id, desired_state)
while True:
try:
instance.update()
state = instance.state
sys.stdout.write('.')
sys.stdout... | [
"def",
"__WaitForInstance",
"(",
"instance",
",",
"desired_state",
")",
":",
"print",
"'Waiting for instance %s to change to %s'",
"%",
"(",
"instance",
".",
"id",
",",
"desired_state",
")",
"while",
"True",
":",
"try",
":",
"instance",
".",
"update",
"(",
")",
... | Blocks until instance is in desired_state. | [
"Blocks",
"until",
"instance",
"is",
"in",
"desired_state",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L618-L634 |
248,494 | cirruscluster/cirruscluster | cirruscluster/core.py | SearchUbuntuAmiDatabase | def SearchUbuntuAmiDatabase(release_name, region_name, root_store_type,
virtualization_type):
""" Returns the ubuntu created ami matching the given criteria. """
ami_list_url = 'http://cloud-images.ubuntu.com/query/%s/server/released.txt' \
% (release_name)
url_file = urllib2.urlope... | python | def SearchUbuntuAmiDatabase(release_name, region_name, root_store_type,
virtualization_type):
""" Returns the ubuntu created ami matching the given criteria. """
ami_list_url = 'http://cloud-images.ubuntu.com/query/%s/server/released.txt' \
% (release_name)
url_file = urllib2.urlope... | [
"def",
"SearchUbuntuAmiDatabase",
"(",
"release_name",
",",
"region_name",
",",
"root_store_type",
",",
"virtualization_type",
")",
":",
"ami_list_url",
"=",
"'http://cloud-images.ubuntu.com/query/%s/server/released.txt'",
"%",
"(",
"release_name",
")",
"url_file",
"=",
"ur... | Returns the ubuntu created ami matching the given criteria. | [
"Returns",
"the",
"ubuntu",
"created",
"ami",
"matching",
"the",
"given",
"criteria",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/core.py#L666-L704 |
248,495 | bruth/restlib2 | restlib2/mixins.py | TemplateResponseMixin.render | def render(self, request, context, status=codes.ok, content_type=None,
args=None, kwargs=None):
"Expects the method handler to return the `context` for the template."
if isinstance(self.template_name, (list, tuple)):
template = loader.select_template(self.template_name)
... | python | def render(self, request, context, status=codes.ok, content_type=None,
args=None, kwargs=None):
"Expects the method handler to return the `context` for the template."
if isinstance(self.template_name, (list, tuple)):
template = loader.select_template(self.template_name)
... | [
"def",
"render",
"(",
"self",
",",
"request",
",",
"context",
",",
"status",
"=",
"codes",
".",
"ok",
",",
"content_type",
"=",
"None",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"template_na... | Expects the method handler to return the `context` for the template. | [
"Expects",
"the",
"method",
"handler",
"to",
"return",
"the",
"context",
"for",
"the",
"template",
"."
] | cb147527496ddf08263364f1fb52e7c48f215667 | https://github.com/bruth/restlib2/blob/cb147527496ddf08263364f1fb52e7c48f215667/restlib2/mixins.py#L11-L25 |
248,496 | ddorn/superprompt | superprompt/core.py | prompt_autocomplete | def prompt_autocomplete(prompt, complete, default=None, contains_spaces=True,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt a string with autocompletion
:param complete: A function that returns a list of possible strings that
should be completed on a given ... | python | def prompt_autocomplete(prompt, complete, default=None, contains_spaces=True,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt a string with autocompletion
:param complete: A function that returns a list of possible strings that
should be completed on a given ... | [
"def",
"prompt_autocomplete",
"(",
"prompt",
",",
"complete",
",",
"default",
"=",
"None",
",",
"contains_spaces",
"=",
"True",
",",
"show_default",
"=",
"True",
",",
"prompt_suffix",
"=",
"': '",
",",
"color",
"=",
"None",
")",
":",
"def",
"real_completer",... | Prompt a string with autocompletion
:param complete: A function that returns a list of possible strings that
should be completed on a given text.
def complete(text: str) -> List[str]: ... | [
"Prompt",
"a",
"string",
"with",
"autocompletion"
] | f2ee13a71c0523663ca1740738b545e2ab1eab20 | https://github.com/ddorn/superprompt/blob/f2ee13a71c0523663ca1740738b545e2ab1eab20/superprompt/core.py#L47-L101 |
248,497 | ddorn/superprompt | superprompt/core.py | prompt_file | def prompt_file(prompt, default=None, must_exist=True, is_dir=False,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt a filename using using glob for autocompetion.
If must_exist is True (default) then you can be sure that the value returned
is an existing filename or dir... | python | def prompt_file(prompt, default=None, must_exist=True, is_dir=False,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt a filename using using glob for autocompetion.
If must_exist is True (default) then you can be sure that the value returned
is an existing filename or dir... | [
"def",
"prompt_file",
"(",
"prompt",
",",
"default",
"=",
"None",
",",
"must_exist",
"=",
"True",
",",
"is_dir",
"=",
"False",
",",
"show_default",
"=",
"True",
",",
"prompt_suffix",
"=",
"': '",
",",
"color",
"=",
"None",
")",
":",
"if",
"must_exist",
... | Prompt a filename using using glob for autocompetion.
If must_exist is True (default) then you can be sure that the value returned
is an existing filename or directory name.
If is_dir is True, this will show only the directories for the completion. | [
"Prompt",
"a",
"filename",
"using",
"using",
"glob",
"for",
"autocompetion",
"."
] | f2ee13a71c0523663ca1740738b545e2ab1eab20 | https://github.com/ddorn/superprompt/blob/f2ee13a71c0523663ca1740738b545e2ab1eab20/superprompt/core.py#L104-L125 |
248,498 | ddorn/superprompt | superprompt/core.py | prompt_choice | def prompt_choice(prompt, possibilities, default=None, only_in_poss=True,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt for a string in a given range of possibilities.
This also sets the history to the list of possibilities so
the user can scroll is with the arrow to... | python | def prompt_choice(prompt, possibilities, default=None, only_in_poss=True,
show_default=True, prompt_suffix=': ', color=None):
"""
Prompt for a string in a given range of possibilities.
This also sets the history to the list of possibilities so
the user can scroll is with the arrow to... | [
"def",
"prompt_choice",
"(",
"prompt",
",",
"possibilities",
",",
"default",
"=",
"None",
",",
"only_in_poss",
"=",
"True",
",",
"show_default",
"=",
"True",
",",
"prompt_suffix",
"=",
"': '",
",",
"color",
"=",
"None",
")",
":",
"assert",
"len",
"(",
"p... | Prompt for a string in a given range of possibilities.
This also sets the history to the list of possibilities so
the user can scroll is with the arrow to find what he wants,
If only_in_poss is False, you are not guaranteed that this
will return one of the possibilities. | [
"Prompt",
"for",
"a",
"string",
"in",
"a",
"given",
"range",
"of",
"possibilities",
"."
] | f2ee13a71c0523663ca1740738b545e2ab1eab20 | https://github.com/ddorn/superprompt/blob/f2ee13a71c0523663ca1740738b545e2ab1eab20/superprompt/core.py#L128-L162 |
248,499 | ryanjdillon/pyotelem | pyotelem/plots/plotglides.py | plot_glide_depths | def plot_glide_depths(depths, mask_tag_filt):
'''Plot depth at glides
Args
----
depths: ndarray
Depth values at each sensor sampling
mask_tag_filt: ndarray
Boolean mask to slice filtered sub-glides from tag data
'''
import numpy
from . import plotutils
fig, ax = pl... | python | def plot_glide_depths(depths, mask_tag_filt):
'''Plot depth at glides
Args
----
depths: ndarray
Depth values at each sensor sampling
mask_tag_filt: ndarray
Boolean mask to slice filtered sub-glides from tag data
'''
import numpy
from . import plotutils
fig, ax = pl... | [
"def",
"plot_glide_depths",
"(",
"depths",
",",
"mask_tag_filt",
")",
":",
"import",
"numpy",
"from",
".",
"import",
"plotutils",
"fig",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
")",
"ax",
"=",
"plotutils",
".",
"plot_noncontiguous",
"(",
"ax",
",",
... | Plot depth at glides
Args
----
depths: ndarray
Depth values at each sensor sampling
mask_tag_filt: ndarray
Boolean mask to slice filtered sub-glides from tag data | [
"Plot",
"depth",
"at",
"glides"
] | 816563a9c3feb3fa416f1c2921c6b75db34111ad | https://github.com/ryanjdillon/pyotelem/blob/816563a9c3feb3fa416f1c2921c6b75db34111ad/pyotelem/plots/plotglides.py#L9-L30 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.