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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
52,100 | Projectplace/basepage | basepage/base_page.py | BasePage.wait_for_attribute | def wait_for_attribute(self, locator, attribute, value, params=None, timeout=5):
"""
Waits for an element attribute to get a certain value.
Note: This function re-get's the element in a loop to avoid caching or stale element issues.
:Example:
Wait for the class attribute to... | python | def wait_for_attribute(self, locator, attribute, value, params=None, timeout=5):
"""
Waits for an element attribute to get a certain value.
Note: This function re-get's the element in a loop to avoid caching or stale element issues.
:Example:
Wait for the class attribute to... | [
"def",
"wait_for_attribute",
"(",
"self",
",",
"locator",
",",
"attribute",
",",
"value",
",",
"params",
"=",
"None",
",",
"timeout",
"=",
"5",
")",
":",
"def",
"_do_wait",
"(",
")",
":",
"element",
"=",
"self",
".",
"get_present_element",
"(",
"locator"... | Waits for an element attribute to get a certain value.
Note: This function re-get's the element in a loop to avoid caching or stale element issues.
:Example:
Wait for the class attribute to get 'board-hidden' value
:param locator: locator tuple
:param attribute: element at... | [
"Waits",
"for",
"an",
"element",
"attribute",
"to",
"get",
"a",
"certain",
"value",
"."
] | 735476877eb100db0981590a6d12140e68652167 | https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/base_page.py#L740-L760 |
52,101 | Projectplace/basepage | basepage/base_page.py | BasePage.wait_for_ajax_calls_to_complete | def wait_for_ajax_calls_to_complete(self, timeout=5):
"""
Waits until there are no active or pending ajax requests.
Raises TimeoutException should silence not be had.
:param timeout: time to wait for silence (default: 5 seconds)
:return: None
"""
from selenium.w... | python | def wait_for_ajax_calls_to_complete(self, timeout=5):
"""
Waits until there are no active or pending ajax requests.
Raises TimeoutException should silence not be had.
:param timeout: time to wait for silence (default: 5 seconds)
:return: None
"""
from selenium.w... | [
"def",
"wait_for_ajax_calls_to_complete",
"(",
"self",
",",
"timeout",
"=",
"5",
")",
":",
"from",
"selenium",
".",
"webdriver",
".",
"support",
".",
"ui",
"import",
"WebDriverWait",
"WebDriverWait",
"(",
"self",
".",
"driver",
",",
"timeout",
")",
".",
"unt... | Waits until there are no active or pending ajax requests.
Raises TimeoutException should silence not be had.
:param timeout: time to wait for silence (default: 5 seconds)
:return: None | [
"Waits",
"until",
"there",
"are",
"no",
"active",
"or",
"pending",
"ajax",
"requests",
"."
] | 735476877eb100db0981590a6d12140e68652167 | https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/base_page.py#L762-L773 |
52,102 | tjguk/networkzero | networkzero/core.py | _find_ip4_broadcast_addresses | def _find_ip4_broadcast_addresses():
"""Yield each IP4 broadcast address, and the all-broadcast
"""
yield "255.255.255.255"
for interface in netifaces.interfaces():
ifaddresses = netifaces.ifaddresses(interface)
for family in ifaddresses:
if family == netifaces.AF_INET:
... | python | def _find_ip4_broadcast_addresses():
"""Yield each IP4 broadcast address, and the all-broadcast
"""
yield "255.255.255.255"
for interface in netifaces.interfaces():
ifaddresses = netifaces.ifaddresses(interface)
for family in ifaddresses:
if family == netifaces.AF_INET:
... | [
"def",
"_find_ip4_broadcast_addresses",
"(",
")",
":",
"yield",
"\"255.255.255.255\"",
"for",
"interface",
"in",
"netifaces",
".",
"interfaces",
"(",
")",
":",
"ifaddresses",
"=",
"netifaces",
".",
"ifaddresses",
"(",
"interface",
")",
"for",
"family",
"in",
"if... | Yield each IP4 broadcast address, and the all-broadcast | [
"Yield",
"each",
"IP4",
"broadcast",
"address",
"and",
"the",
"all",
"-",
"broadcast"
] | 0e3e81d2e9200b25a83ac07741612283599486d7 | https://github.com/tjguk/networkzero/blob/0e3e81d2e9200b25a83ac07741612283599486d7/networkzero/core.py#L122-L133 |
52,103 | tjguk/networkzero | networkzero/core.py | _find_ip4_addresses | def _find_ip4_addresses():
"""Find all the IP4 addresses currently bound to interfaces
"""
global _ip4_addresses
proto = socket.AF_INET
if _ip4_addresses is None:
_ip4_addresses = []
#
# Determine the interface for the default gateway
# (if any) and, later, prioritis... | python | def _find_ip4_addresses():
"""Find all the IP4 addresses currently bound to interfaces
"""
global _ip4_addresses
proto = socket.AF_INET
if _ip4_addresses is None:
_ip4_addresses = []
#
# Determine the interface for the default gateway
# (if any) and, later, prioritis... | [
"def",
"_find_ip4_addresses",
"(",
")",
":",
"global",
"_ip4_addresses",
"proto",
"=",
"socket",
".",
"AF_INET",
"if",
"_ip4_addresses",
"is",
"None",
":",
"_ip4_addresses",
"=",
"[",
"]",
"#",
"# Determine the interface for the default gateway",
"# (if any) and, later,... | Find all the IP4 addresses currently bound to interfaces | [
"Find",
"all",
"the",
"IP4",
"addresses",
"currently",
"bound",
"to",
"interfaces"
] | 0e3e81d2e9200b25a83ac07741612283599486d7 | https://github.com/tjguk/networkzero/blob/0e3e81d2e9200b25a83ac07741612283599486d7/networkzero/core.py#L136-L163 |
52,104 | wbond/vat_moss-python | vat_moss/phone_number.py | calculate_rate | def calculate_rate(phone_number, address_country_code=None, address_exception=None):
"""
Calculates the VAT rate based on a telephone number
:param phone_number:
The string phone number, in international format with leading +
:param address_country_code:
The user's country_code, as det... | python | def calculate_rate(phone_number, address_country_code=None, address_exception=None):
"""
Calculates the VAT rate based on a telephone number
:param phone_number:
The string phone number, in international format with leading +
:param address_country_code:
The user's country_code, as det... | [
"def",
"calculate_rate",
"(",
"phone_number",
",",
"address_country_code",
"=",
"None",
",",
"address_exception",
"=",
"None",
")",
":",
"if",
"not",
"phone_number",
":",
"raise",
"ValueError",
"(",
"'No phone number provided'",
")",
"if",
"not",
"isinstance",
"("... | Calculates the VAT rate based on a telephone number
:param phone_number:
The string phone number, in international format with leading +
:param address_country_code:
The user's country_code, as detected from billing_address or
declared_residence. This prevents an UndefinitiveError from... | [
"Calculates",
"the",
"VAT",
"rate",
"based",
"on",
"a",
"telephone",
"number"
] | 5089dcf036eb2e9abc58e78186fd46b522a50620 | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/phone_number.py#L18-L88 |
52,105 | tkem/uritools | uritools/split.py | uriunsplit | def uriunsplit(parts):
"""Combine the elements of a five-item iterable into a URI reference's
string representation.
"""
scheme, authority, path, query, fragment = parts
if isinstance(path, bytes):
result = SplitResultBytes
else:
result = SplitResultUnicode
return result(sch... | python | def uriunsplit(parts):
"""Combine the elements of a five-item iterable into a URI reference's
string representation.
"""
scheme, authority, path, query, fragment = parts
if isinstance(path, bytes):
result = SplitResultBytes
else:
result = SplitResultUnicode
return result(sch... | [
"def",
"uriunsplit",
"(",
"parts",
")",
":",
"scheme",
",",
"authority",
",",
"path",
",",
"query",
",",
"fragment",
"=",
"parts",
"if",
"isinstance",
"(",
"path",
",",
"bytes",
")",
":",
"result",
"=",
"SplitResultBytes",
"else",
":",
"result",
"=",
"... | Combine the elements of a five-item iterable into a URI reference's
string representation. | [
"Combine",
"the",
"elements",
"of",
"a",
"five",
"-",
"item",
"iterable",
"into",
"a",
"URI",
"reference",
"s",
"string",
"representation",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L388-L398 |
52,106 | tkem/uritools | uritools/split.py | SplitResult.geturi | def geturi(self):
"""Return the re-combined version of the original URI reference as a
string.
"""
scheme, authority, path, query, fragment = self
# RFC 3986 5.3. Component Recomposition
result = []
if scheme is not None:
result.extend([scheme, self.... | python | def geturi(self):
"""Return the re-combined version of the original URI reference as a
string.
"""
scheme, authority, path, query, fragment = self
# RFC 3986 5.3. Component Recomposition
result = []
if scheme is not None:
result.extend([scheme, self.... | [
"def",
"geturi",
"(",
"self",
")",
":",
"scheme",
",",
"authority",
",",
"path",
",",
"query",
",",
"fragment",
"=",
"self",
"# RFC 3986 5.3. Component Recomposition",
"result",
"=",
"[",
"]",
"if",
"scheme",
"is",
"not",
"None",
":",
"result",
".",
"exten... | Return the re-combined version of the original URI reference as a
string. | [
"Return",
"the",
"re",
"-",
"combined",
"version",
"of",
"the",
"original",
"URI",
"reference",
"as",
"a",
"string",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L81-L99 |
52,107 | tkem/uritools | uritools/split.py | SplitResult.getauthority | def getauthority(self, default=None, encoding='utf-8', errors='strict'):
"""Return the decoded userinfo, host and port subcomponents of the URI
authority as a three-item tuple.
"""
# TBD: (userinfo, host, port) kwargs, default string?
if default is None:
default = (N... | python | def getauthority(self, default=None, encoding='utf-8', errors='strict'):
"""Return the decoded userinfo, host and port subcomponents of the URI
authority as a three-item tuple.
"""
# TBD: (userinfo, host, port) kwargs, default string?
if default is None:
default = (N... | [
"def",
"getauthority",
"(",
"self",
",",
"default",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"# TBD: (userinfo, host, port) kwargs, default string?",
"if",
"default",
"is",
"None",
":",
"default",
"=",
"(",
"None",
... | Return the decoded userinfo, host and port subcomponents of the URI
authority as a three-item tuple. | [
"Return",
"the",
"decoded",
"userinfo",
"host",
"and",
"port",
"subcomponents",
"of",
"the",
"URI",
"authority",
"as",
"a",
"three",
"-",
"item",
"tuple",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L114-L131 |
52,108 | tkem/uritools | uritools/split.py | SplitResult.getuserinfo | def getuserinfo(self, default=None, encoding='utf-8', errors='strict'):
"""Return the decoded userinfo subcomponent of the URI authority, or
`default` if the original URI reference did not contain a
userinfo field.
"""
userinfo = self.userinfo
if userinfo is None:
... | python | def getuserinfo(self, default=None, encoding='utf-8', errors='strict'):
"""Return the decoded userinfo subcomponent of the URI authority, or
`default` if the original URI reference did not contain a
userinfo field.
"""
userinfo = self.userinfo
if userinfo is None:
... | [
"def",
"getuserinfo",
"(",
"self",
",",
"default",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"userinfo",
"=",
"self",
".",
"userinfo",
"if",
"userinfo",
"is",
"None",
":",
"return",
"default",
"else",
":",
... | Return the decoded userinfo subcomponent of the URI authority, or
`default` if the original URI reference did not contain a
userinfo field. | [
"Return",
"the",
"decoded",
"userinfo",
"subcomponent",
"of",
"the",
"URI",
"authority",
"or",
"default",
"if",
"the",
"original",
"URI",
"reference",
"did",
"not",
"contain",
"a",
"userinfo",
"field",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L133-L143 |
52,109 | tkem/uritools | uritools/split.py | SplitResult.getpath | def getpath(self, encoding='utf-8', errors='strict'):
"""Return the normalized decoded URI path."""
path = self.__remove_dot_segments(self.path)
return uridecode(path, encoding, errors) | python | def getpath(self, encoding='utf-8', errors='strict'):
"""Return the normalized decoded URI path."""
path = self.__remove_dot_segments(self.path)
return uridecode(path, encoding, errors) | [
"def",
"getpath",
"(",
"self",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"path",
"=",
"self",
".",
"__remove_dot_segments",
"(",
"self",
".",
"path",
")",
"return",
"uridecode",
"(",
"path",
",",
"encoding",
",",
"errors"... | Return the normalized decoded URI path. | [
"Return",
"the",
"normalized",
"decoded",
"URI",
"path",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L173-L176 |
52,110 | tkem/uritools | uritools/split.py | SplitResult.getquery | def getquery(self, default=None, encoding='utf-8', errors='strict'):
"""Return the decoded query string, or `default` if the original URI
reference did not contain a query component.
"""
query = self.query
if query is None:
return default
else:
re... | python | def getquery(self, default=None, encoding='utf-8', errors='strict'):
"""Return the decoded query string, or `default` if the original URI
reference did not contain a query component.
"""
query = self.query
if query is None:
return default
else:
re... | [
"def",
"getquery",
"(",
"self",
",",
"default",
"=",
"None",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"query",
"=",
"self",
".",
"query",
"if",
"query",
"is",
"None",
":",
"return",
"default",
"else",
":",
"return",
... | Return the decoded query string, or `default` if the original URI
reference did not contain a query component. | [
"Return",
"the",
"decoded",
"query",
"string",
"or",
"default",
"if",
"the",
"original",
"URI",
"reference",
"did",
"not",
"contain",
"a",
"query",
"component",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L178-L187 |
52,111 | tkem/uritools | uritools/split.py | SplitResult.getquerydict | def getquerydict(self, sep='&', encoding='utf-8', errors='strict'):
"""Split the query component into individual `name=value` pairs
separated by `sep` and return a dictionary of query variables.
The dictionary keys are the unique query variable names and
the values are lists of values fo... | python | def getquerydict(self, sep='&', encoding='utf-8', errors='strict'):
"""Split the query component into individual `name=value` pairs
separated by `sep` and return a dictionary of query variables.
The dictionary keys are the unique query variable names and
the values are lists of values fo... | [
"def",
"getquerydict",
"(",
"self",
",",
"sep",
"=",
"'&'",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"dict",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"name",
",",
"value",
"in",
"self",
".",
"... | Split the query component into individual `name=value` pairs
separated by `sep` and return a dictionary of query variables.
The dictionary keys are the unique query variable names and
the values are lists of values for each name. | [
"Split",
"the",
"query",
"component",
"into",
"individual",
"name",
"=",
"value",
"pairs",
"separated",
"by",
"sep",
"and",
"return",
"a",
"dictionary",
"of",
"query",
"variables",
".",
"The",
"dictionary",
"keys",
"are",
"the",
"unique",
"query",
"variable",
... | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/split.py#L189-L199 |
52,112 | wbond/vat_moss-python | vat_moss/declared_residence.py | calculate_rate | def calculate_rate(country_code, exception_name):
"""
Calculates the VAT rate for a customer based on their declared country
and any declared exception information.
:param country_code:
The two-character country code where the user resides
:param exception_name:
The name of an exce... | python | def calculate_rate(country_code, exception_name):
"""
Calculates the VAT rate for a customer based on their declared country
and any declared exception information.
:param country_code:
The two-character country code where the user resides
:param exception_name:
The name of an exce... | [
"def",
"calculate_rate",
"(",
"country_code",
",",
"exception_name",
")",
":",
"if",
"not",
"country_code",
"or",
"not",
"isinstance",
"(",
"country_code",
",",
"str_cls",
")",
"or",
"len",
"(",
"country_code",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"("... | Calculates the VAT rate for a customer based on their declared country
and any declared exception information.
:param country_code:
The two-character country code where the user resides
:param exception_name:
The name of an exception for the country, as returned from
vat_moss.decla... | [
"Calculates",
"the",
"VAT",
"rate",
"for",
"a",
"customer",
"based",
"on",
"their",
"declared",
"country",
"and",
"any",
"declared",
"exception",
"information",
"."
] | 5089dcf036eb2e9abc58e78186fd46b522a50620 | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/declared_residence.py#L16-L62 |
52,113 | wbond/vat_moss-python | vat_moss/declared_residence.py | exceptions_by_country | def exceptions_by_country(country_code):
"""
Returns a list of exception names for the given country
:param country_code:
The two-character country code for the user
:raises:
ValueError - if country_code is not two characers
:return:
A list of strings that are VAT exceptio... | python | def exceptions_by_country(country_code):
"""
Returns a list of exception names for the given country
:param country_code:
The two-character country code for the user
:raises:
ValueError - if country_code is not two characers
:return:
A list of strings that are VAT exceptio... | [
"def",
"exceptions_by_country",
"(",
"country_code",
")",
":",
"if",
"not",
"country_code",
"or",
"not",
"isinstance",
"(",
"country_code",
",",
"str_cls",
")",
"or",
"len",
"(",
"country_code",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'Invalidly form... | Returns a list of exception names for the given country
:param country_code:
The two-character country code for the user
:raises:
ValueError - if country_code is not two characers
:return:
A list of strings that are VAT exceptions for the country specified | [
"Returns",
"a",
"list",
"of",
"exception",
"names",
"for",
"the",
"given",
"country"
] | 5089dcf036eb2e9abc58e78186fd46b522a50620 | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/declared_residence.py#L65-L84 |
52,114 | wbond/vat_moss-python | vat_moss/id.py | normalize | def normalize(vat_id):
"""
Accepts a VAT ID and normaizes it, getting rid of spaces, periods, dashes
etc and converting it to upper case.
:param vat_id:
The VAT ID to check. Allows "GR" prefix for Greece, even though it
should be "EL".
:raises:
ValueError - If the is not a ... | python | def normalize(vat_id):
"""
Accepts a VAT ID and normaizes it, getting rid of spaces, periods, dashes
etc and converting it to upper case.
:param vat_id:
The VAT ID to check. Allows "GR" prefix for Greece, even though it
should be "EL".
:raises:
ValueError - If the is not a ... | [
"def",
"normalize",
"(",
"vat_id",
")",
":",
"if",
"not",
"vat_id",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"vat_id",
",",
"str_cls",
")",
":",
"raise",
"ValueError",
"(",
"'VAT ID is not a string'",
")",
"if",
"len",
"(",
"vat_id",
")",
"... | Accepts a VAT ID and normaizes it, getting rid of spaces, periods, dashes
etc and converting it to upper case.
:param vat_id:
The VAT ID to check. Allows "GR" prefix for Greece, even though it
should be "EL".
:raises:
ValueError - If the is not a string or is not in the format of t... | [
"Accepts",
"a",
"VAT",
"ID",
"and",
"normaizes",
"it",
"getting",
"rid",
"of",
"spaces",
"periods",
"dashes",
"etc",
"and",
"converting",
"it",
"to",
"upper",
"case",
"."
] | 5089dcf036eb2e9abc58e78186fd46b522a50620 | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/id.py#L22-L64 |
52,115 | Projectplace/basepage | basepage/decorators.py | handle_stale | def handle_stale(msg='', exceptions=None):
"""
Decorator to handle stale element reference exceptions.
:param msg: Error message
:param exceptions: Extra exceptions to handle
:return: the result of the decorated function
"""
exc = [StaleElementReferenceException]
if exceptions is not No... | python | def handle_stale(msg='', exceptions=None):
"""
Decorator to handle stale element reference exceptions.
:param msg: Error message
:param exceptions: Extra exceptions to handle
:return: the result of the decorated function
"""
exc = [StaleElementReferenceException]
if exceptions is not No... | [
"def",
"handle_stale",
"(",
"msg",
"=",
"''",
",",
"exceptions",
"=",
"None",
")",
":",
"exc",
"=",
"[",
"StaleElementReferenceException",
"]",
"if",
"exceptions",
"is",
"not",
"None",
":",
"try",
":",
"exc",
".",
"extend",
"(",
"iter",
"(",
"exceptions"... | Decorator to handle stale element reference exceptions.
:param msg: Error message
:param exceptions: Extra exceptions to handle
:return: the result of the decorated function | [
"Decorator",
"to",
"handle",
"stale",
"element",
"reference",
"exceptions",
"."
] | 735476877eb100db0981590a6d12140e68652167 | https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/decorators.py#L43-L79 |
52,116 | Projectplace/basepage | basepage/decorators.py | wait | def wait(msg='', exceptions=None, timeout=10):
"""
Decorator to handle generic waiting situations.
Will handle StaleElementReferenceErrors.
:param msg: Error message
:param exceptions: Extra exceptions to handle
:param timeout: time to keep trying (default: 10 seconds)
:return: the result ... | python | def wait(msg='', exceptions=None, timeout=10):
"""
Decorator to handle generic waiting situations.
Will handle StaleElementReferenceErrors.
:param msg: Error message
:param exceptions: Extra exceptions to handle
:param timeout: time to keep trying (default: 10 seconds)
:return: the result ... | [
"def",
"wait",
"(",
"msg",
"=",
"''",
",",
"exceptions",
"=",
"None",
",",
"timeout",
"=",
"10",
")",
":",
"exc",
"=",
"[",
"StaleElementReferenceException",
"]",
"if",
"exceptions",
"is",
"not",
"None",
":",
"try",
":",
"exc",
".",
"extend",
"(",
"i... | Decorator to handle generic waiting situations.
Will handle StaleElementReferenceErrors.
:param msg: Error message
:param exceptions: Extra exceptions to handle
:param timeout: time to keep trying (default: 10 seconds)
:return: the result of the decorated function | [
"Decorator",
"to",
"handle",
"generic",
"waiting",
"situations",
"."
] | 735476877eb100db0981590a6d12140e68652167 | https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/decorators.py#L82-L123 |
52,117 | wbond/vat_moss-python | vat_moss/billing_address.py | calculate_rate | def calculate_rate(country_code, postal_code, city):
"""
Calculates the VAT rate that should be collected based on address
information provided
:param country_code:
The two-character country code
:param postal_code:
The postal code for the user
:param city:
The city na... | python | def calculate_rate(country_code, postal_code, city):
"""
Calculates the VAT rate that should be collected based on address
information provided
:param country_code:
The two-character country code
:param postal_code:
The postal code for the user
:param city:
The city na... | [
"def",
"calculate_rate",
"(",
"country_code",
",",
"postal_code",
",",
"city",
")",
":",
"if",
"not",
"country_code",
"or",
"not",
"isinstance",
"(",
"country_code",
",",
"str_cls",
")",
":",
"raise",
"ValueError",
"(",
"'Invalidly formatted country code'",
")",
... | Calculates the VAT rate that should be collected based on address
information provided
:param country_code:
The two-character country code
:param postal_code:
The postal code for the user
:param city:
The city name for the user
:raises:
ValueError - If country cod... | [
"Calculates",
"the",
"VAT",
"rate",
"that",
"should",
"be",
"collected",
"based",
"on",
"address",
"information",
"provided"
] | 5089dcf036eb2e9abc58e78186fd46b522a50620 | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/billing_address.py#L17-L104 |
52,118 | andrey-git/pysensibo | pysensibo/__init__.py | SensiboClient.async_get_device | def async_get_device(self, uid, fields='*'):
"""Get specific device by ID."""
return (yield from self._get('/pods/{}'.format(uid),
fields=fields)) | python | def async_get_device(self, uid, fields='*'):
"""Get specific device by ID."""
return (yield from self._get('/pods/{}'.format(uid),
fields=fields)) | [
"def",
"async_get_device",
"(",
"self",
",",
"uid",
",",
"fields",
"=",
"'*'",
")",
":",
"return",
"(",
"yield",
"from",
"self",
".",
"_get",
"(",
"'/pods/{}'",
".",
"format",
"(",
"uid",
")",
",",
"fields",
"=",
"fields",
")",
")"
] | Get specific device by ID. | [
"Get",
"specific",
"device",
"by",
"ID",
"."
] | c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8 | https://github.com/andrey-git/pysensibo/blob/c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8/pysensibo/__init__.py#L38-L41 |
52,119 | andrey-git/pysensibo | pysensibo/__init__.py | SensiboClient.async_get_measurements | def async_get_measurements(self, uid, fields='*'):
"""Get measurements of a device."""
return (yield from self._get('/pods/{}/measurements'.format(uid),
fields=fields))[0] | python | def async_get_measurements(self, uid, fields='*'):
"""Get measurements of a device."""
return (yield from self._get('/pods/{}/measurements'.format(uid),
fields=fields))[0] | [
"def",
"async_get_measurements",
"(",
"self",
",",
"uid",
",",
"fields",
"=",
"'*'",
")",
":",
"return",
"(",
"yield",
"from",
"self",
".",
"_get",
"(",
"'/pods/{}/measurements'",
".",
"format",
"(",
"uid",
")",
",",
"fields",
"=",
"fields",
")",
")",
... | Get measurements of a device. | [
"Get",
"measurements",
"of",
"a",
"device",
"."
] | c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8 | https://github.com/andrey-git/pysensibo/blob/c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8/pysensibo/__init__.py#L44-L47 |
52,120 | andrey-git/pysensibo | pysensibo/__init__.py | SensiboClient.async_get_ac_states | def async_get_ac_states(self, uid, limit=1, offset=0, fields='*'):
"""Get log entries of a device."""
return (yield from self._get('/pods/{}/acStates'.format(uid),
limit=limit,
fields=fields,
o... | python | def async_get_ac_states(self, uid, limit=1, offset=0, fields='*'):
"""Get log entries of a device."""
return (yield from self._get('/pods/{}/acStates'.format(uid),
limit=limit,
fields=fields,
o... | [
"def",
"async_get_ac_states",
"(",
"self",
",",
"uid",
",",
"limit",
"=",
"1",
",",
"offset",
"=",
"0",
",",
"fields",
"=",
"'*'",
")",
":",
"return",
"(",
"yield",
"from",
"self",
".",
"_get",
"(",
"'/pods/{}/acStates'",
".",
"format",
"(",
"uid",
"... | Get log entries of a device. | [
"Get",
"log",
"entries",
"of",
"a",
"device",
"."
] | c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8 | https://github.com/andrey-git/pysensibo/blob/c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8/pysensibo/__init__.py#L50-L55 |
52,121 | andrey-git/pysensibo | pysensibo/__init__.py | SensiboClient.async_get_ac_state_log | def async_get_ac_state_log(self, uid, log_id, fields='*'):
"""Get a specific log entry."""
return (
yield from self._get('/pods/{}/acStates/{}'.format(uid, log_id),
fields=fields)) | python | def async_get_ac_state_log(self, uid, log_id, fields='*'):
"""Get a specific log entry."""
return (
yield from self._get('/pods/{}/acStates/{}'.format(uid, log_id),
fields=fields)) | [
"def",
"async_get_ac_state_log",
"(",
"self",
",",
"uid",
",",
"log_id",
",",
"fields",
"=",
"'*'",
")",
":",
"return",
"(",
"yield",
"from",
"self",
".",
"_get",
"(",
"'/pods/{}/acStates/{}'",
".",
"format",
"(",
"uid",
",",
"log_id",
")",
",",
"fields"... | Get a specific log entry. | [
"Get",
"a",
"specific",
"log",
"entry",
"."
] | c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8 | https://github.com/andrey-git/pysensibo/blob/c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8/pysensibo/__init__.py#L58-L62 |
52,122 | andrey-git/pysensibo | pysensibo/__init__.py | SensiboClient.async_set_ac_state_property | def async_set_ac_state_property(
self, uid, name, value, ac_state=None, assumed_state=False):
"""Set a specific device property."""
if ac_state is None:
ac_state = yield from self.async_get_ac_states(uid)
ac_state = ac_state[0]['acState']
data = {
... | python | def async_set_ac_state_property(
self, uid, name, value, ac_state=None, assumed_state=False):
"""Set a specific device property."""
if ac_state is None:
ac_state = yield from self.async_get_ac_states(uid)
ac_state = ac_state[0]['acState']
data = {
... | [
"def",
"async_set_ac_state_property",
"(",
"self",
",",
"uid",
",",
"name",
",",
"value",
",",
"ac_state",
"=",
"None",
",",
"assumed_state",
"=",
"False",
")",
":",
"if",
"ac_state",
"is",
"None",
":",
"ac_state",
"=",
"yield",
"from",
"self",
".",
"asy... | Set a specific device property. | [
"Set",
"a",
"specific",
"device",
"property",
"."
] | c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8 | https://github.com/andrey-git/pysensibo/blob/c471c99ee64bbcc78f3a10aabc0e3b326a1f64f8/pysensibo/__init__.py#L65-L86 |
52,123 | tjguk/networkzero | networkzero/discovery.py | _bind_with_timeout | def _bind_with_timeout(bind_function, args, n_tries=3, retry_interval_s=0.5):
"""Attempt to bind a socket a number of times with a short interval in between
Especially on Linux, crashing out of a networkzero process can leave the sockets
lingering and unable to re-bind on startup. We give it a few goes... | python | def _bind_with_timeout(bind_function, args, n_tries=3, retry_interval_s=0.5):
"""Attempt to bind a socket a number of times with a short interval in between
Especially on Linux, crashing out of a networkzero process can leave the sockets
lingering and unable to re-bind on startup. We give it a few goes... | [
"def",
"_bind_with_timeout",
"(",
"bind_function",
",",
"args",
",",
"n_tries",
"=",
"3",
",",
"retry_interval_s",
"=",
"0.5",
")",
":",
"n_tries_left",
"=",
"n_tries",
"while",
"n_tries_left",
">",
"0",
":",
"try",
":",
"return",
"bind_function",
"(",
"*",
... | Attempt to bind a socket a number of times with a short interval in between
Especially on Linux, crashing out of a networkzero process can leave the sockets
lingering and unable to re-bind on startup. We give it a few goes here to see if
we can bind within a couple of seconds. | [
"Attempt",
"to",
"bind",
"a",
"socket",
"a",
"number",
"of",
"times",
"with",
"a",
"short",
"interval",
"in",
"between",
"Especially",
"on",
"Linux",
"crashing",
"out",
"of",
"a",
"networkzero",
"process",
"can",
"leave",
"the",
"sockets",
"lingering",
"and"... | 0e3e81d2e9200b25a83ac07741612283599486d7 | https://github.com/tjguk/networkzero/blob/0e3e81d2e9200b25a83ac07741612283599486d7/networkzero/discovery.py#L80-L101 |
52,124 | tjguk/networkzero | networkzero/discovery.py | _start_beacon | def _start_beacon(port=None):
"""Start a beacon thread within this process if no beacon is currently
running on this machine.
In general this is called automatically when an attempt is made to
advertise or discover. It might be convenient, though, to call this
function directly if you want to h... | python | def _start_beacon(port=None):
"""Start a beacon thread within this process if no beacon is currently
running on this machine.
In general this is called automatically when an attempt is made to
advertise or discover. It might be convenient, though, to call this
function directly if you want to h... | [
"def",
"_start_beacon",
"(",
"port",
"=",
"None",
")",
":",
"global",
"_beacon",
"if",
"_beacon",
"is",
"None",
":",
"_logger",
".",
"debug",
"(",
"\"About to start beacon with port %s\"",
",",
"port",
")",
"try",
":",
"_beacon",
"=",
"_Beacon",
"(",
"port",... | Start a beacon thread within this process if no beacon is currently
running on this machine.
In general this is called automatically when an attempt is made to
advertise or discover. It might be convenient, though, to call this
function directly if you want to have a process whose only job is
t... | [
"Start",
"a",
"beacon",
"thread",
"within",
"this",
"process",
"if",
"no",
"beacon",
"is",
"currently",
"running",
"on",
"this",
"machine",
".",
"In",
"general",
"this",
"is",
"called",
"automatically",
"when",
"an",
"attempt",
"is",
"made",
"to",
"advertise... | 0e3e81d2e9200b25a83ac07741612283599486d7 | https://github.com/tjguk/networkzero/blob/0e3e81d2e9200b25a83ac07741612283599486d7/networkzero/discovery.py#L433-L461 |
52,125 | tjguk/networkzero | networkzero/discovery.py | _Beacon.poll_command_request | def poll_command_request(self):
"""If the command RPC socket has an incoming request,
separate it into its action and its params and put it
on the command request queue.
"""
try:
message = self.rpc.recv(zmq.NOBLOCK)
except zmq.ZMQError as exc:
if e... | python | def poll_command_request(self):
"""If the command RPC socket has an incoming request,
separate it into its action and its params and put it
on the command request queue.
"""
try:
message = self.rpc.recv(zmq.NOBLOCK)
except zmq.ZMQError as exc:
if e... | [
"def",
"poll_command_request",
"(",
"self",
")",
":",
"try",
":",
"message",
"=",
"self",
".",
"rpc",
".",
"recv",
"(",
"zmq",
".",
"NOBLOCK",
")",
"except",
"zmq",
".",
"ZMQError",
"as",
"exc",
":",
"if",
"exc",
".",
"errno",
"==",
"zmq",
".",
"EA... | If the command RPC socket has an incoming request,
separate it into its action and its params and put it
on the command request queue. | [
"If",
"the",
"command",
"RPC",
"socket",
"has",
"an",
"incoming",
"request",
"separate",
"it",
"into",
"its",
"action",
"and",
"its",
"params",
"and",
"put",
"it",
"on",
"the",
"command",
"request",
"queue",
"."
] | 0e3e81d2e9200b25a83ac07741612283599486d7 | https://github.com/tjguk/networkzero/blob/0e3e81d2e9200b25a83ac07741612283599486d7/networkzero/discovery.py#L320-L337 |
52,126 | tjguk/networkzero | networkzero/discovery.py | _Beacon.poll_command_reponse | def poll_command_reponse(self):
"""If the latest request has a response, issue it as a
reply to the RPC socket.
"""
if self._command.response is not Empty:
_logger.debug("Sending response %s", self._command.response)
self.rpc.send(_pack(self._command.response))
... | python | def poll_command_reponse(self):
"""If the latest request has a response, issue it as a
reply to the RPC socket.
"""
if self._command.response is not Empty:
_logger.debug("Sending response %s", self._command.response)
self.rpc.send(_pack(self._command.response))
... | [
"def",
"poll_command_reponse",
"(",
"self",
")",
":",
"if",
"self",
".",
"_command",
".",
"response",
"is",
"not",
"Empty",
":",
"_logger",
".",
"debug",
"(",
"\"Sending response %s\"",
",",
"self",
".",
"_command",
".",
"response",
")",
"self",
".",
"rpc"... | If the latest request has a response, issue it as a
reply to the RPC socket. | [
"If",
"the",
"latest",
"request",
"has",
"a",
"response",
"issue",
"it",
"as",
"a",
"reply",
"to",
"the",
"RPC",
"socket",
"."
] | 0e3e81d2e9200b25a83ac07741612283599486d7 | https://github.com/tjguk/networkzero/blob/0e3e81d2e9200b25a83ac07741612283599486d7/networkzero/discovery.py#L373-L380 |
52,127 | wbond/vat_moss-python | vat_moss/geoip2.py | calculate_rate | def calculate_rate(country_code, subdivision, city, address_country_code=None, address_exception=None):
"""
Calculates the VAT rate from the data returned by a GeoLite2 database
:param country_code:
Two-character country code
:param subdivision:
The first subdivision name
:param c... | python | def calculate_rate(country_code, subdivision, city, address_country_code=None, address_exception=None):
"""
Calculates the VAT rate from the data returned by a GeoLite2 database
:param country_code:
Two-character country code
:param subdivision:
The first subdivision name
:param c... | [
"def",
"calculate_rate",
"(",
"country_code",
",",
"subdivision",
",",
"city",
",",
"address_country_code",
"=",
"None",
",",
"address_exception",
"=",
"None",
")",
":",
"if",
"not",
"country_code",
"or",
"not",
"isinstance",
"(",
"country_code",
",",
"str_cls",... | Calculates the VAT rate from the data returned by a GeoLite2 database
:param country_code:
Two-character country code
:param subdivision:
The first subdivision name
:param city:
The city name
:param address_country_code:
The user's country_code, as detected from billi... | [
"Calculates",
"the",
"VAT",
"rate",
"from",
"the",
"data",
"returned",
"by",
"a",
"GeoLite2",
"database"
] | 5089dcf036eb2e9abc58e78186fd46b522a50620 | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/geoip2.py#L17-L99 |
52,128 | wbond/vat_moss-python | vat_moss/exchange_rates.py | setup_xrates | def setup_xrates(base, rates):
"""
If using the Python money package, this will set up the xrates exchange
rate data.
:param base:
The string currency code to use as the base
:param rates:
A dict with keys that are string currency codes and values that are
a Decimal of the ... | python | def setup_xrates(base, rates):
"""
If using the Python money package, this will set up the xrates exchange
rate data.
:param base:
The string currency code to use as the base
:param rates:
A dict with keys that are string currency codes and values that are
a Decimal of the ... | [
"def",
"setup_xrates",
"(",
"base",
",",
"rates",
")",
":",
"xrates",
".",
"install",
"(",
"'money.exchange.SimpleBackend'",
")",
"xrates",
".",
"base",
"=",
"base",
"for",
"code",
",",
"value",
"in",
"rates",
".",
"items",
"(",
")",
":",
"xrates",
".",
... | If using the Python money package, this will set up the xrates exchange
rate data.
:param base:
The string currency code to use as the base
:param rates:
A dict with keys that are string currency codes and values that are
a Decimal of the exchange rate for that currency. | [
"If",
"using",
"the",
"Python",
"money",
"package",
"this",
"will",
"set",
"up",
"the",
"xrates",
"exchange",
"rate",
"data",
"."
] | 5089dcf036eb2e9abc58e78186fd46b522a50620 | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/exchange_rates.py#L161-L177 |
52,129 | wbond/vat_moss-python | vat_moss/exchange_rates.py | format | def format(amount, currency=None):
"""
Formats a decimal or Money object into an unambiguous string representation
for the purpose of invoices in English.
:param amount:
A Decimal or Money object
:param currency:
If the amount is a Decimal, the currency of the amount
:return:
... | python | def format(amount, currency=None):
"""
Formats a decimal or Money object into an unambiguous string representation
for the purpose of invoices in English.
:param amount:
A Decimal or Money object
:param currency:
If the amount is a Decimal, the currency of the amount
:return:
... | [
"def",
"format",
"(",
"amount",
",",
"currency",
"=",
"None",
")",
":",
"if",
"currency",
"is",
"None",
"and",
"hasattr",
"(",
"amount",
",",
"'currency'",
")",
":",
"currency",
"=",
"amount",
".",
"currency",
"# Allow Money objects",
"if",
"not",
"isinsta... | Formats a decimal or Money object into an unambiguous string representation
for the purpose of invoices in English.
:param amount:
A Decimal or Money object
:param currency:
If the amount is a Decimal, the currency of the amount
:return:
A string representation of the amount i... | [
"Formats",
"a",
"decimal",
"or",
"Money",
"object",
"into",
"an",
"unambiguous",
"string",
"representation",
"for",
"the",
"purpose",
"of",
"invoices",
"in",
"English",
"."
] | 5089dcf036eb2e9abc58e78186fd46b522a50620 | https://github.com/wbond/vat_moss-python/blob/5089dcf036eb2e9abc58e78186fd46b522a50620/vat_moss/exchange_rates.py#L180-L230 |
52,130 | what-studio/gauge | recipes/namedgauge.py | NamedGauge.get_momentum_by_name | def get_momentum_by_name(self, name):
"""Gets a momentum by the given name.
:param name: the momentum name.
:returns: a momentum found.
:raises TypeError: `name` is ``None``.
:raises KeyError: failed to find a momentum named `name`.
"""
if name is None:
... | python | def get_momentum_by_name(self, name):
"""Gets a momentum by the given name.
:param name: the momentum name.
:returns: a momentum found.
:raises TypeError: `name` is ``None``.
:raises KeyError: failed to find a momentum named `name`.
"""
if name is None:
... | [
"def",
"get_momentum_by_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"'\\'name\\' should not be None'",
")",
"for",
"momentum",
"in",
"self",
".",
"momenta",
":",
"if",
"momentum",
".",
"name",
"==",
... | Gets a momentum by the given name.
:param name: the momentum name.
:returns: a momentum found.
:raises TypeError: `name` is ``None``.
:raises KeyError: failed to find a momentum named `name`. | [
"Gets",
"a",
"momentum",
"by",
"the",
"given",
"name",
"."
] | 4624602c87c9287de1a8a0bcb2a68f827af49ccb | https://github.com/what-studio/gauge/blob/4624602c87c9287de1a8a0bcb2a68f827af49ccb/recipes/namedgauge.py#L36-L51 |
52,131 | what-studio/gauge | recipes/namedgauge.py | NamedGauge.pop_momentum_by_name | def pop_momentum_by_name(self, name):
"""Removes and returns a momentum by the given name.
:param name: the momentum name.
:returns: a momentum removed.
:raises TypeError: `name` is ``None``.
:raises KeyError: failed to find a momentum named `name`.
"""
momentu... | python | def pop_momentum_by_name(self, name):
"""Removes and returns a momentum by the given name.
:param name: the momentum name.
:returns: a momentum removed.
:raises TypeError: `name` is ``None``.
:raises KeyError: failed to find a momentum named `name`.
"""
momentu... | [
"def",
"pop_momentum_by_name",
"(",
"self",
",",
"name",
")",
":",
"momentum",
"=",
"self",
".",
"get_momentum_by_name",
"(",
"name",
")",
"self",
".",
"remove_momentum",
"(",
"momentum",
")",
"return",
"momentum"
] | Removes and returns a momentum by the given name.
:param name: the momentum name.
:returns: a momentum removed.
:raises TypeError: `name` is ``None``.
:raises KeyError: failed to find a momentum named `name`. | [
"Removes",
"and",
"returns",
"a",
"momentum",
"by",
"the",
"given",
"name",
"."
] | 4624602c87c9287de1a8a0bcb2a68f827af49ccb | https://github.com/what-studio/gauge/blob/4624602c87c9287de1a8a0bcb2a68f827af49ccb/recipes/namedgauge.py#L53-L65 |
52,132 | what-studio/gauge | recipes/namedgauge.py | NamedGauge.update_momentum_by_name | def update_momentum_by_name(self, name, **kwargs):
"""Updates a momentum by the given name.
:param name: the momentum name.
:param velocity: (keyword-only) a new value for `velocity`.
:param since: (keyword-only) a new value for `since`.
:param until: (keyword-only) a new value ... | python | def update_momentum_by_name(self, name, **kwargs):
"""Updates a momentum by the given name.
:param name: the momentum name.
:param velocity: (keyword-only) a new value for `velocity`.
:param since: (keyword-only) a new value for `since`.
:param until: (keyword-only) a new value ... | [
"def",
"update_momentum_by_name",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"momentum",
"=",
"self",
".",
"pop_momentum_by_name",
"(",
"name",
")",
"velocity",
",",
"since",
",",
"until",
"=",
"momentum",
"[",
":",
"3",
"]",
"velocity"... | Updates a momentum by the given name.
:param name: the momentum name.
:param velocity: (keyword-only) a new value for `velocity`.
:param since: (keyword-only) a new value for `since`.
:param until: (keyword-only) a new value for `until`.
:returns: a momentum updated.
:... | [
"Updates",
"a",
"momentum",
"by",
"the",
"given",
"name",
"."
] | 4624602c87c9287de1a8a0bcb2a68f827af49ccb | https://github.com/what-studio/gauge/blob/4624602c87c9287de1a8a0bcb2a68f827af49ccb/recipes/namedgauge.py#L67-L85 |
52,133 | what-studio/gauge | recipes/namedgauge.py | NamedGauge.snap_momentum_by_name | def snap_momentum_by_name(self, name, velocity, at=None):
"""Changes the velocity of a momentum named `name`.
:param name: the momentum name.
:param velocity: a new velocity.
:param at: the time to snap. (default: now)
:returns: a momentum updated.
:raises TypeError: `... | python | def snap_momentum_by_name(self, name, velocity, at=None):
"""Changes the velocity of a momentum named `name`.
:param name: the momentum name.
:param velocity: a new velocity.
:param at: the time to snap. (default: now)
:returns: a momentum updated.
:raises TypeError: `... | [
"def",
"snap_momentum_by_name",
"(",
"self",
",",
"name",
",",
"velocity",
",",
"at",
"=",
"None",
")",
":",
"at",
"=",
"now_or",
"(",
"at",
")",
"self",
".",
"forget_past",
"(",
"at",
"=",
"at",
")",
"return",
"self",
".",
"update_momentum_by_name",
"... | Changes the velocity of a momentum named `name`.
:param name: the momentum name.
:param velocity: a new velocity.
:param at: the time to snap. (default: now)
:returns: a momentum updated.
:raises TypeError: `name` is ``None``.
:raises KeyError: failed to find a momentu... | [
"Changes",
"the",
"velocity",
"of",
"a",
"momentum",
"named",
"name",
"."
] | 4624602c87c9287de1a8a0bcb2a68f827af49ccb | https://github.com/what-studio/gauge/blob/4624602c87c9287de1a8a0bcb2a68f827af49ccb/recipes/namedgauge.py#L87-L101 |
52,134 | tkem/uritools | uritools/compose.py | uricompose | def uricompose(scheme=None, authority=None, path='', query=None,
fragment=None, userinfo=None, host=None, port=None,
querysep='&', encoding='utf-8'):
"""Compose a URI reference string from its individual components."""
# RFC 3986 3.1: Scheme names consist of a sequence of characte... | python | def uricompose(scheme=None, authority=None, path='', query=None,
fragment=None, userinfo=None, host=None, port=None,
querysep='&', encoding='utf-8'):
"""Compose a URI reference string from its individual components."""
# RFC 3986 3.1: Scheme names consist of a sequence of characte... | [
"def",
"uricompose",
"(",
"scheme",
"=",
"None",
",",
"authority",
"=",
"None",
",",
"path",
"=",
"''",
",",
"query",
"=",
"None",
",",
"fragment",
"=",
"None",
",",
"userinfo",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
... | Compose a URI reference string from its individual components. | [
"Compose",
"a",
"URI",
"reference",
"string",
"from",
"its",
"individual",
"components",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/compose.py#L124-L210 |
52,135 | Projectplace/basepage | basepage/wait.py | ActionWait.until | def until(self, func, message='', *args, **kwargs):
"""
Continues to execute the function until successful or time runs out.
:param func: function to execute
:param message: message to print if time ran out
:param args: arguments
:param kwargs: key word arguments
... | python | def until(self, func, message='', *args, **kwargs):
"""
Continues to execute the function until successful or time runs out.
:param func: function to execute
:param message: message to print if time ran out
:param args: arguments
:param kwargs: key word arguments
... | [
"def",
"until",
"(",
"self",
",",
"func",
",",
"message",
"=",
"''",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"value",
"=",
"None",
"end_time",
"=",
"time",
".",
"time",
"(",
")",
"+",
"self",
".",
"_timeout",
"while",
"True",
":",
... | Continues to execute the function until successful or time runs out.
:param func: function to execute
:param message: message to print if time ran out
:param args: arguments
:param kwargs: key word arguments
:return: result of function or None | [
"Continues",
"to",
"execute",
"the",
"function",
"until",
"successful",
"or",
"time",
"runs",
"out",
"."
] | 735476877eb100db0981590a6d12140e68652167 | https://github.com/Projectplace/basepage/blob/735476877eb100db0981590a6d12140e68652167/basepage/wait.py#L46-L69 |
52,136 | johnhw/pyspacenavigator | spacenavigator.py | DeviceSpec.describe_connection | def describe_connection(self):
"""Return string representation of the device, including
the connection state"""
if self.device==None:
return "%s [disconnected]" % (self.name)
else:
return "%s connected to %s %s version: %s [serial: %s]" % (self.name,
... | python | def describe_connection(self):
"""Return string representation of the device, including
the connection state"""
if self.device==None:
return "%s [disconnected]" % (self.name)
else:
return "%s connected to %s %s version: %s [serial: %s]" % (self.name,
... | [
"def",
"describe_connection",
"(",
"self",
")",
":",
"if",
"self",
".",
"device",
"==",
"None",
":",
"return",
"\"%s [disconnected]\"",
"%",
"(",
"self",
".",
"name",
")",
"else",
":",
"return",
"\"%s connected to %s %s version: %s [serial: %s]\"",
"%",
"(",
"se... | Return string representation of the device, including
the connection state | [
"Return",
"string",
"representation",
"of",
"the",
"device",
"including",
"the",
"connection",
"state"
] | 518bd89f94b83156f12dae261f95c517fb78ebe4 | https://github.com/johnhw/pyspacenavigator/blob/518bd89f94b83156f12dae261f95c517fb78ebe4/spacenavigator.py#L45-L53 |
52,137 | Yelp/pysensu-yelp | pysensu_yelp/__init__.py | send_event | def send_event(
name,
runbook,
status,
output,
team,
page=False,
tip=None,
notification_email=None,
check_every='30s',
realert_every=-1,
alert_after='0s',
dependencies=[],
irc_channels=None,
slack_channels=None,
ticket=False,
project=None,
priority=Non... | python | def send_event(
name,
runbook,
status,
output,
team,
page=False,
tip=None,
notification_email=None,
check_every='30s',
realert_every=-1,
alert_after='0s',
dependencies=[],
irc_channels=None,
slack_channels=None,
ticket=False,
project=None,
priority=Non... | [
"def",
"send_event",
"(",
"name",
",",
"runbook",
",",
"status",
",",
"output",
",",
"team",
",",
"page",
"=",
"False",
",",
"tip",
"=",
"None",
",",
"notification_email",
"=",
"None",
",",
"check_every",
"=",
"'30s'",
",",
"realert_every",
"=",
"-",
"... | Send a new event with the given information. Requires a name, runbook,
status code, event output, and team but the other keys are kwargs and have
defaults.
:type name: str
:param name: Name of the check
:type runbook: str
:param runbook: The runbook associated with the check
:type status:... | [
"Send",
"a",
"new",
"event",
"with",
"the",
"given",
"information",
".",
"Requires",
"a",
"name",
"runbook",
"status",
"code",
"event",
"output",
"and",
"team",
"but",
"the",
"other",
"keys",
"are",
"kwargs",
"and",
"have",
"defaults",
"."
] | 00522f6804ed130b9e959cab1fd75e67418aa507 | https://github.com/Yelp/pysensu-yelp/blob/00522f6804ed130b9e959cab1fd75e67418aa507/pysensu_yelp/__init__.py#L172-L374 |
52,138 | tkem/uritools | uritools/encoding.py | uriencode | def uriencode(uristring, safe='', encoding='utf-8', errors='strict'):
"""Encode a URI string or string component."""
if not isinstance(uristring, bytes):
uristring = uristring.encode(encoding, errors)
if not isinstance(safe, bytes):
safe = safe.encode('ascii')
try:
encoded = _enc... | python | def uriencode(uristring, safe='', encoding='utf-8', errors='strict'):
"""Encode a URI string or string component."""
if not isinstance(uristring, bytes):
uristring = uristring.encode(encoding, errors)
if not isinstance(safe, bytes):
safe = safe.encode('ascii')
try:
encoded = _enc... | [
"def",
"uriencode",
"(",
"uristring",
",",
"safe",
"=",
"''",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"not",
"isinstance",
"(",
"uristring",
",",
"bytes",
")",
":",
"uristring",
"=",
"uristring",
".",
"encode",
... | Encode a URI string or string component. | [
"Encode",
"a",
"URI",
"string",
"or",
"string",
"component",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/encoding.py#L40-L53 |
52,139 | tkem/uritools | uritools/encoding.py | uridecode | def uridecode(uristring, encoding='utf-8', errors='strict'):
"""Decode a URI string or string component."""
if not isinstance(uristring, bytes):
uristring = uristring.encode(encoding or 'ascii', errors)
parts = uristring.split(b'%')
result = [parts[0]]
append = result.append
decode = _de... | python | def uridecode(uristring, encoding='utf-8', errors='strict'):
"""Decode a URI string or string component."""
if not isinstance(uristring, bytes):
uristring = uristring.encode(encoding or 'ascii', errors)
parts = uristring.split(b'%')
result = [parts[0]]
append = result.append
decode = _de... | [
"def",
"uridecode",
"(",
"uristring",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"not",
"isinstance",
"(",
"uristring",
",",
"bytes",
")",
":",
"uristring",
"=",
"uristring",
".",
"encode",
"(",
"encoding",
"or",
"'a... | Decode a URI string or string component. | [
"Decode",
"a",
"URI",
"string",
"or",
"string",
"component",
"."
] | e77ba4acd937b68da9850138563debd4c925ef9f | https://github.com/tkem/uritools/blob/e77ba4acd937b68da9850138563debd4c925ef9f/uritools/encoding.py#L56-L70 |
52,140 | phn/lineid_plot | lineid_plot/lineid_plot.py | _convert_to_array | def _convert_to_array(x, size, name):
"""Check length of array or convert scalar to array.
Check to see is `x` has the given length `size`. If this is true
then return Numpy array equivalent of `x`. If not then raise
ValueError, using `name` as an idnetification. If len(x) returns
TypeError, then a... | python | def _convert_to_array(x, size, name):
"""Check length of array or convert scalar to array.
Check to see is `x` has the given length `size`. If this is true
then return Numpy array equivalent of `x`. If not then raise
ValueError, using `name` as an idnetification. If len(x) returns
TypeError, then a... | [
"def",
"_convert_to_array",
"(",
"x",
",",
"size",
",",
"name",
")",
":",
"try",
":",
"l",
"=",
"len",
"(",
"x",
")",
"if",
"l",
"!=",
"size",
":",
"raise",
"ValueError",
"(",
"\"{0} must be scalar or of length {1}\"",
".",
"format",
"(",
"name",
",",
... | Check length of array or convert scalar to array.
Check to see is `x` has the given length `size`. If this is true
then return Numpy array equivalent of `x`. If not then raise
ValueError, using `name` as an idnetification. If len(x) returns
TypeError, then assume it is a scalar and create a Numpy array... | [
"Check",
"length",
"of",
"array",
"or",
"convert",
"scalar",
"to",
"array",
"."
] | 7c7a1af53fe439b3a7c5a57f01680575837fb978 | https://github.com/phn/lineid_plot/blob/7c7a1af53fe439b3a7c5a57f01680575837fb978/lineid_plot/lineid_plot.py#L16-L37 |
52,141 | phn/lineid_plot | lineid_plot/lineid_plot.py | unique_labels | def unique_labels(line_labels):
"""If a label occurs more than once, add num. as suffix."""
from collections import defaultdict
d = defaultdict(int)
for i in line_labels:
d[i] += 1
d = dict((i, k) for i, k in d.items() if k != 1)
line_labels_u = []
for lab in reversed(line_labels):
... | python | def unique_labels(line_labels):
"""If a label occurs more than once, add num. as suffix."""
from collections import defaultdict
d = defaultdict(int)
for i in line_labels:
d[i] += 1
d = dict((i, k) for i, k in d.items() if k != 1)
line_labels_u = []
for lab in reversed(line_labels):
... | [
"def",
"unique_labels",
"(",
"line_labels",
")",
":",
"from",
"collections",
"import",
"defaultdict",
"d",
"=",
"defaultdict",
"(",
"int",
")",
"for",
"i",
"in",
"line_labels",
":",
"d",
"[",
"i",
"]",
"+=",
"1",
"d",
"=",
"dict",
"(",
"(",
"i",
",",... | If a label occurs more than once, add num. as suffix. | [
"If",
"a",
"label",
"occurs",
"more",
"than",
"once",
"add",
"num",
".",
"as",
"suffix",
"."
] | 7c7a1af53fe439b3a7c5a57f01680575837fb978 | https://github.com/phn/lineid_plot/blob/7c7a1af53fe439b3a7c5a57f01680575837fb978/lineid_plot/lineid_plot.py#L45-L62 |
52,142 | phn/lineid_plot | lineid_plot/lineid_plot.py | get_box_loc | def get_box_loc(fig, ax, line_wave, arrow_tip, box_axes_space=0.06):
"""Box loc in data coords, given Fig. coords offset from arrow_tip.
Parameters
----------
fig: matplotlib Figure artist
Figure on which the boxes will be placed.
ax: matplotlib Axes artist
Axes on which the boxes w... | python | def get_box_loc(fig, ax, line_wave, arrow_tip, box_axes_space=0.06):
"""Box loc in data coords, given Fig. coords offset from arrow_tip.
Parameters
----------
fig: matplotlib Figure artist
Figure on which the boxes will be placed.
ax: matplotlib Axes artist
Axes on which the boxes w... | [
"def",
"get_box_loc",
"(",
"fig",
",",
"ax",
",",
"line_wave",
",",
"arrow_tip",
",",
"box_axes_space",
"=",
"0.06",
")",
":",
"# Plot boxes in their original x position, at a height given by the",
"# key word box_axes_spacing above the arrow tip. The default",
"# is set to 0.06.... | Box loc in data coords, given Fig. coords offset from arrow_tip.
Parameters
----------
fig: matplotlib Figure artist
Figure on which the boxes will be placed.
ax: matplotlib Axes artist
Axes on which the boxes will be placed.
arrow_tip: list or array of floats
Location of ti... | [
"Box",
"loc",
"in",
"data",
"coords",
"given",
"Fig",
".",
"coords",
"offset",
"from",
"arrow_tip",
"."
] | 7c7a1af53fe439b3a7c5a57f01680575837fb978 | https://github.com/phn/lineid_plot/blob/7c7a1af53fe439b3a7c5a57f01680575837fb978/lineid_plot/lineid_plot.py#L65-L121 |
52,143 | phn/lineid_plot | lineid_plot/lineid_plot.py | adjust_boxes | def adjust_boxes(line_wave, box_widths, left_edge, right_edge,
max_iter=1000, adjust_factor=0.35,
factor_decrement=3.0, fd_p=0.75):
"""Ajdust given boxes so that they don't overlap.
Parameters
----------
line_wave: list or array of floats
Line wave lengths. The... | python | def adjust_boxes(line_wave, box_widths, left_edge, right_edge,
max_iter=1000, adjust_factor=0.35,
factor_decrement=3.0, fd_p=0.75):
"""Ajdust given boxes so that they don't overlap.
Parameters
----------
line_wave: list or array of floats
Line wave lengths. The... | [
"def",
"adjust_boxes",
"(",
"line_wave",
",",
"box_widths",
",",
"left_edge",
",",
"right_edge",
",",
"max_iter",
"=",
"1000",
",",
"adjust_factor",
"=",
"0.35",
",",
"factor_decrement",
"=",
"3.0",
",",
"fd_p",
"=",
"0.75",
")",
":",
"# Adjust positions.",
... | Ajdust given boxes so that they don't overlap.
Parameters
----------
line_wave: list or array of floats
Line wave lengths. These are assumed to be the initial y (wave
length) location of the boxes.
box_widths: list or array of floats
Width of box containing labels for each line ... | [
"Ajdust",
"given",
"boxes",
"so",
"that",
"they",
"don",
"t",
"overlap",
"."
] | 7c7a1af53fe439b3a7c5a57f01680575837fb978 | https://github.com/phn/lineid_plot/blob/7c7a1af53fe439b3a7c5a57f01680575837fb978/lineid_plot/lineid_plot.py#L124-L219 |
52,144 | phn/lineid_plot | lineid_plot/lineid_plot.py | prepare_axes | def prepare_axes(wave, flux, fig=None, ax_lower=(0.1, 0.1),
ax_dim=(0.85, 0.65)):
"""Create fig and axes if needed and layout axes in fig."""
# Axes location in figure.
if not fig:
fig = plt.figure()
ax = fig.add_axes([ax_lower[0], ax_lower[1], ax_dim[0], ax_dim[1]])
ax.plot... | python | def prepare_axes(wave, flux, fig=None, ax_lower=(0.1, 0.1),
ax_dim=(0.85, 0.65)):
"""Create fig and axes if needed and layout axes in fig."""
# Axes location in figure.
if not fig:
fig = plt.figure()
ax = fig.add_axes([ax_lower[0], ax_lower[1], ax_dim[0], ax_dim[1]])
ax.plot... | [
"def",
"prepare_axes",
"(",
"wave",
",",
"flux",
",",
"fig",
"=",
"None",
",",
"ax_lower",
"=",
"(",
"0.1",
",",
"0.1",
")",
",",
"ax_dim",
"=",
"(",
"0.85",
",",
"0.65",
")",
")",
":",
"# Axes location in figure.",
"if",
"not",
"fig",
":",
"fig",
... | Create fig and axes if needed and layout axes in fig. | [
"Create",
"fig",
"and",
"axes",
"if",
"needed",
"and",
"layout",
"axes",
"in",
"fig",
"."
] | 7c7a1af53fe439b3a7c5a57f01680575837fb978 | https://github.com/phn/lineid_plot/blob/7c7a1af53fe439b3a7c5a57f01680575837fb978/lineid_plot/lineid_plot.py#L222-L230 |
52,145 | phn/lineid_plot | lineid_plot/lineid_plot.py | initial_annotate_kwargs | def initial_annotate_kwargs():
"""Return default parameters passed to Axes.annotate to create labels."""
return dict(
xycoords="data", textcoords="data",
rotation=90, horizontalalignment="center", verticalalignment="center",
arrowprops=dict(arrowstyle="-", relpos=(0.5, 0.0))
) | python | def initial_annotate_kwargs():
"""Return default parameters passed to Axes.annotate to create labels."""
return dict(
xycoords="data", textcoords="data",
rotation=90, horizontalalignment="center", verticalalignment="center",
arrowprops=dict(arrowstyle="-", relpos=(0.5, 0.0))
) | [
"def",
"initial_annotate_kwargs",
"(",
")",
":",
"return",
"dict",
"(",
"xycoords",
"=",
"\"data\"",
",",
"textcoords",
"=",
"\"data\"",
",",
"rotation",
"=",
"90",
",",
"horizontalalignment",
"=",
"\"center\"",
",",
"verticalalignment",
"=",
"\"center\"",
",",
... | Return default parameters passed to Axes.annotate to create labels. | [
"Return",
"default",
"parameters",
"passed",
"to",
"Axes",
".",
"annotate",
"to",
"create",
"labels",
"."
] | 7c7a1af53fe439b3a7c5a57f01680575837fb978 | https://github.com/phn/lineid_plot/blob/7c7a1af53fe439b3a7c5a57f01680575837fb978/lineid_plot/lineid_plot.py#L233-L239 |
52,146 | RI-imaging/qpsphere | qpsphere/models/mod_rytov.py | interpolate_grid | def interpolate_grid(cin, cout, data, fillval=0):
"""Return the 2D field averaged radially w.r.t. the center"""
if np.iscomplexobj(data):
phase = interpolate_grid(
cin, cout, unwrap.unwrap_phase(np.angle(data)), fillval=0)
ampli = interpolate_grid(cin, cout, np.abs(data), fillval=1)
... | python | def interpolate_grid(cin, cout, data, fillval=0):
"""Return the 2D field averaged radially w.r.t. the center"""
if np.iscomplexobj(data):
phase = interpolate_grid(
cin, cout, unwrap.unwrap_phase(np.angle(data)), fillval=0)
ampli = interpolate_grid(cin, cout, np.abs(data), fillval=1)
... | [
"def",
"interpolate_grid",
"(",
"cin",
",",
"cout",
",",
"data",
",",
"fillval",
"=",
"0",
")",
":",
"if",
"np",
".",
"iscomplexobj",
"(",
"data",
")",
":",
"phase",
"=",
"interpolate_grid",
"(",
"cin",
",",
"cout",
",",
"unwrap",
".",
"unwrap_phase",
... | Return the 2D field averaged radially w.r.t. the center | [
"Return",
"the",
"2D",
"field",
"averaged",
"radially",
"w",
".",
"r",
".",
"t",
".",
"the",
"center"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/mod_rytov.py#L9-L22 |
52,147 | RI-imaging/qpsphere | qpsphere/models/mod_rytov.py | rytov | def rytov(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, pixel_size=.5e-6, grid_size=(80, 80),
center=(39.5, 39.5), focus=0, radius_sampling=42):
"""Field behind a dielectric sphere in the Rytov approximation
Parameters
----------
radius: float
Radiu... | python | def rytov(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, pixel_size=.5e-6, grid_size=(80, 80),
center=(39.5, 39.5), focus=0, radius_sampling=42):
"""Field behind a dielectric sphere in the Rytov approximation
Parameters
----------
radius: float
Radiu... | [
"def",
"rytov",
"(",
"radius",
"=",
"5e-6",
",",
"sphere_index",
"=",
"1.339",
",",
"medium_index",
"=",
"1.333",
",",
"wavelength",
"=",
"550e-9",
",",
"pixel_size",
"=",
".5e-6",
",",
"grid_size",
"=",
"(",
"80",
",",
"80",
")",
",",
"center",
"=",
... | Field behind a dielectric sphere in the Rytov approximation
Parameters
----------
radius: float
Radius of the sphere [m]
sphere_index: float
Refractive index of the sphere
medium_index: float
Refractive index of the surrounding medium
wavelength: float
Vacuum wav... | [
"Field",
"behind",
"a",
"dielectric",
"sphere",
"in",
"the",
"Rytov",
"approximation"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/mod_rytov.py#L25-L105 |
52,148 | tuxpiper/cloudcast | cloudcast/__init__.py | _run_resources_file | def _run_resources_file(path, stack):
"""
With a bit of import magic, we load the given path as a python module,
while providing it access to the given stack under the import name '_context'.
This function returns the module's global dictionary.
"""
import imp, sys, random, string, copy
clas... | python | def _run_resources_file(path, stack):
"""
With a bit of import magic, we load the given path as a python module,
while providing it access to the given stack under the import name '_context'.
This function returns the module's global dictionary.
"""
import imp, sys, random, string, copy
clas... | [
"def",
"_run_resources_file",
"(",
"path",
",",
"stack",
")",
":",
"import",
"imp",
",",
"sys",
",",
"random",
",",
"string",
",",
"copy",
"class",
"ContextImporter",
"(",
"object",
")",
":",
"def",
"find_module",
"(",
"self",
",",
"fullname",
",",
"path... | With a bit of import magic, we load the given path as a python module,
while providing it access to the given stack under the import name '_context'.
This function returns the module's global dictionary. | [
"With",
"a",
"bit",
"of",
"import",
"magic",
"we",
"load",
"the",
"given",
"path",
"as",
"a",
"python",
"module",
"while",
"providing",
"it",
"access",
"to",
"the",
"given",
"stack",
"under",
"the",
"import",
"name",
"_context",
".",
"This",
"function",
... | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/__init__.py#L20-L58 |
52,149 | tuxpiper/cloudcast | cloudcast/__init__.py | _stackElements.load_template_srcmodule | def load_template_srcmodule(self, stack, path):
"""
This function actually fills the stack with definitions coming from a template file
"""
srcmodule = _run_resources_file(path, stack)
# Process the loaded module and find the stack elements
elements = self.find_stack_elem... | python | def load_template_srcmodule(self, stack, path):
"""
This function actually fills the stack with definitions coming from a template file
"""
srcmodule = _run_resources_file(path, stack)
# Process the loaded module and find the stack elements
elements = self.find_stack_elem... | [
"def",
"load_template_srcmodule",
"(",
"self",
",",
"stack",
",",
"path",
")",
":",
"srcmodule",
"=",
"_run_resources_file",
"(",
"path",
",",
"stack",
")",
"# Process the loaded module and find the stack elements",
"elements",
"=",
"self",
".",
"find_stack_elements",
... | This function actually fills the stack with definitions coming from a template file | [
"This",
"function",
"actually",
"fills",
"the",
"stack",
"with",
"definitions",
"coming",
"from",
"a",
"template",
"file"
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/__init__.py#L87-L99 |
52,150 | tuxpiper/cloudcast | cloudcast/__init__.py | _stackElements.dump_to_template_obj | def dump_to_template_obj(self, stack, t):
"""
Add resource definitions to the given template object
"""
if len(self.Parameters) > 0:
t['Parameters'] = dict([e.contents(stack) for e in self.Parameters])
if len(self.Mappings) > 0:
t['Mappings'] = dict([e.con... | python | def dump_to_template_obj(self, stack, t):
"""
Add resource definitions to the given template object
"""
if len(self.Parameters) > 0:
t['Parameters'] = dict([e.contents(stack) for e in self.Parameters])
if len(self.Mappings) > 0:
t['Mappings'] = dict([e.con... | [
"def",
"dump_to_template_obj",
"(",
"self",
",",
"stack",
",",
"t",
")",
":",
"if",
"len",
"(",
"self",
".",
"Parameters",
")",
">",
"0",
":",
"t",
"[",
"'Parameters'",
"]",
"=",
"dict",
"(",
"[",
"e",
".",
"contents",
"(",
"stack",
")",
"for",
"... | Add resource definitions to the given template object | [
"Add",
"resource",
"definitions",
"to",
"the",
"given",
"template",
"object"
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/__init__.py#L170-L181 |
52,151 | tuxpiper/cloudcast | cloudcast/__init__.py | Stack.dump_json | def dump_json(self, pretty=True):
"""
Return a string representation of this CloudFormation template.
"""
# Build template
t = {}
t['AWSTemplateFormatVersion'] = '2010-09-09'
if self.description is not None:
t['Description'] = self.description
... | python | def dump_json(self, pretty=True):
"""
Return a string representation of this CloudFormation template.
"""
# Build template
t = {}
t['AWSTemplateFormatVersion'] = '2010-09-09'
if self.description is not None:
t['Description'] = self.description
... | [
"def",
"dump_json",
"(",
"self",
",",
"pretty",
"=",
"True",
")",
":",
"# Build template",
"t",
"=",
"{",
"}",
"t",
"[",
"'AWSTemplateFormatVersion'",
"]",
"=",
"'2010-09-09'",
"if",
"self",
".",
"description",
"is",
"not",
"None",
":",
"t",
"[",
"'Descr... | Return a string representation of this CloudFormation template. | [
"Return",
"a",
"string",
"representation",
"of",
"this",
"CloudFormation",
"template",
"."
] | 06ca62045c483e9c3e7ee960ba70d90ea6a13776 | https://github.com/tuxpiper/cloudcast/blob/06ca62045c483e9c3e7ee960ba70d90ea6a13776/cloudcast/__init__.py#L244-L256 |
52,152 | Pixelapse/pyglass | pyglass/quicklook/export.py | embedded_preview | def embedded_preview(src_path):
''' Returns path to temporary copy of embedded QuickLook preview, if it exists '''
try:
assert(exists(src_path) and isdir(src_path))
preview_list = glob(join(src_path, '[Q|q]uicklook', '[P|p]review.*'))
assert(preview_list) # Assert there's at least one preview file
... | python | def embedded_preview(src_path):
''' Returns path to temporary copy of embedded QuickLook preview, if it exists '''
try:
assert(exists(src_path) and isdir(src_path))
preview_list = glob(join(src_path, '[Q|q]uicklook', '[P|p]review.*'))
assert(preview_list) # Assert there's at least one preview file
... | [
"def",
"embedded_preview",
"(",
"src_path",
")",
":",
"try",
":",
"assert",
"(",
"exists",
"(",
"src_path",
")",
"and",
"isdir",
"(",
"src_path",
")",
")",
"preview_list",
"=",
"glob",
"(",
"join",
"(",
"src_path",
",",
"'[Q|q]uicklook'",
",",
"'[P|p]revie... | Returns path to temporary copy of embedded QuickLook preview, if it exists | [
"Returns",
"path",
"to",
"temporary",
"copy",
"of",
"embedded",
"QuickLook",
"preview",
"if",
"it",
"exists"
] | 83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33 | https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/quicklook/export.py#L20-L36 |
52,153 | Pixelapse/pyglass | pyglass/quicklook/export.py | thumbnail_preview | def thumbnail_preview(src_path):
''' Returns the path to small thumbnail preview. '''
try:
assert(exists(src_path))
width = '1980'
dest_dir = mkdtemp(prefix='pyglass')
cmd = [QLMANAGE, '-t', '-s', width, src_path, '-o', dest_dir]
assert(check_call(cmd) == 0)
src_filename = basename(src_pa... | python | def thumbnail_preview(src_path):
''' Returns the path to small thumbnail preview. '''
try:
assert(exists(src_path))
width = '1980'
dest_dir = mkdtemp(prefix='pyglass')
cmd = [QLMANAGE, '-t', '-s', width, src_path, '-o', dest_dir]
assert(check_call(cmd) == 0)
src_filename = basename(src_pa... | [
"def",
"thumbnail_preview",
"(",
"src_path",
")",
":",
"try",
":",
"assert",
"(",
"exists",
"(",
"src_path",
")",
")",
"width",
"=",
"'1980'",
"dest_dir",
"=",
"mkdtemp",
"(",
"prefix",
"=",
"'pyglass'",
")",
"cmd",
"=",
"[",
"QLMANAGE",
",",
"'-t'",
"... | Returns the path to small thumbnail preview. | [
"Returns",
"the",
"path",
"to",
"small",
"thumbnail",
"preview",
"."
] | 83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33 | https://github.com/Pixelapse/pyglass/blob/83cd0ff2b0b7cdaf4ec6f54559a626e67455cd33/pyglass/quicklook/export.py#L60-L80 |
52,154 | sci-bots/pygtkhelpers | pygtkhelpers/gthreads.py | invoke_in_mainloop | def invoke_in_mainloop(func, *args, **kwargs):
"""
Invoke a function in the mainloop, pass the data back.
"""
results = queue.Queue()
@gcall
def run():
try:
data = func(*args, **kwargs)
results.put(data)
results.put(None)
except BaseException:... | python | def invoke_in_mainloop(func, *args, **kwargs):
"""
Invoke a function in the mainloop, pass the data back.
"""
results = queue.Queue()
@gcall
def run():
try:
data = func(*args, **kwargs)
results.put(data)
results.put(None)
except BaseException:... | [
"def",
"invoke_in_mainloop",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"results",
"=",
"queue",
".",
"Queue",
"(",
")",
"@",
"gcall",
"def",
"run",
"(",
")",
":",
"try",
":",
"data",
"=",
"func",
"(",
"*",
"args",
",",
"... | Invoke a function in the mainloop, pass the data back. | [
"Invoke",
"a",
"function",
"in",
"the",
"mainloop",
"pass",
"the",
"data",
"back",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/gthreads.py#L201-L225 |
52,155 | sci-bots/pygtkhelpers | pygtkhelpers/gthreads.py | gtk_threadsafe | def gtk_threadsafe(func):
'''
Decorator to make wrapped function threadsafe by forcing it to execute
within the GTK main thread.
.. versionadded:: 0.18
.. versionchanged:: 0.22
Add support for keyword arguments in callbacks by supporting functions
wrapped by `functools.partial()`. ... | python | def gtk_threadsafe(func):
'''
Decorator to make wrapped function threadsafe by forcing it to execute
within the GTK main thread.
.. versionadded:: 0.18
.. versionchanged:: 0.22
Add support for keyword arguments in callbacks by supporting functions
wrapped by `functools.partial()`. ... | [
"def",
"gtk_threadsafe",
"(",
"func",
")",
":",
"# Set up GDK threading.",
"# XXX This must be done to support running multiple threads in GTK",
"# applications.",
"gtk",
".",
"gdk",
".",
"threads_init",
"(",
")",
"# Support",
"wraps_func",
"=",
"func",
".",
"func",
"if",... | Decorator to make wrapped function threadsafe by forcing it to execute
within the GTK main thread.
.. versionadded:: 0.18
.. versionchanged:: 0.22
Add support for keyword arguments in callbacks by supporting functions
wrapped by `functools.partial()`. Also, ignore callback return value
... | [
"Decorator",
"to",
"make",
"wrapped",
"function",
"threadsafe",
"by",
"forcing",
"it",
"to",
"execute",
"within",
"the",
"GTK",
"main",
"thread",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/gthreads.py#L228-L264 |
52,156 | sci-bots/pygtkhelpers | pygtkhelpers/gthreads.py | AsyncTask.start | def start(self, *args, **kwargs):
"""Start the task.
This is:
* not threadsave
* assumed to be called in the gtk mainloop
"""
args = (self.counter,) + args
thread = threading.Thread(
target=self._work_callback,
args=args, k... | python | def start(self, *args, **kwargs):
"""Start the task.
This is:
* not threadsave
* assumed to be called in the gtk mainloop
"""
args = (self.counter,) + args
thread = threading.Thread(
target=self._work_callback,
args=args, k... | [
"def",
"start",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"(",
"self",
".",
"counter",
",",
")",
"+",
"args",
"thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_work_callback",
",",
... | Start the task.
This is:
* not threadsave
* assumed to be called in the gtk mainloop | [
"Start",
"the",
"task",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/gthreads.py#L85-L98 |
52,157 | dcaune/perseus-lib-python-common | majormode/perseus/utils/image_util.py | convert_image_to_rgb_mode | def convert_image_to_rgb_mode(image, fill_color=(255, 255, 255)):
"""
Convert the specified image instance to RGB mode.
@param image: a Python Library Image (PIL) instance to convert its
pixel format to RGB, discarding the alpha channel.
@param fill_color: color to be used to fill transparent... | python | def convert_image_to_rgb_mode(image, fill_color=(255, 255, 255)):
"""
Convert the specified image instance to RGB mode.
@param image: a Python Library Image (PIL) instance to convert its
pixel format to RGB, discarding the alpha channel.
@param fill_color: color to be used to fill transparent... | [
"def",
"convert_image_to_rgb_mode",
"(",
"image",
",",
"fill_color",
"=",
"(",
"255",
",",
"255",
",",
"255",
")",
")",
":",
"if",
"image",
".",
"mode",
"not",
"in",
"(",
"'RGBA'",
",",
"'LA'",
")",
":",
"return",
"image",
"# In most cases simply discardin... | Convert the specified image instance to RGB mode.
@param image: a Python Library Image (PIL) instance to convert its
pixel format to RGB, discarding the alpha channel.
@param fill_color: color to be used to fill transparent pixels when
discaring the alpha channel. By default, the white color... | [
"Convert",
"the",
"specified",
"image",
"instance",
"to",
"RGB",
"mode",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/image_util.py#L106-L129 |
52,158 | dcaune/perseus-lib-python-common | majormode/perseus/utils/image_util.py | generate_multiple_pixel_resolutions | def generate_multiple_pixel_resolutions(image, pixel_resolutions,
filter=Filter.NearestNeighbor,
does_crop=False,
crop_aligment=CropAlignment.center,
match_orientation=False):
"""
Generate multiple resolution images of the given image.
@param image: a Python Library Image (... | python | def generate_multiple_pixel_resolutions(image, pixel_resolutions,
filter=Filter.NearestNeighbor,
does_crop=False,
crop_aligment=CropAlignment.center,
match_orientation=False):
"""
Generate multiple resolution images of the given image.
@param image: a Python Library Image (... | [
"def",
"generate_multiple_pixel_resolutions",
"(",
"image",
",",
"pixel_resolutions",
",",
"filter",
"=",
"Filter",
".",
"NearestNeighbor",
",",
"does_crop",
"=",
"False",
",",
"crop_aligment",
"=",
"CropAlignment",
".",
"center",
",",
"match_orientation",
"=",
"Fal... | Generate multiple resolution images of the given image.
@param image: a Python Library Image (PIL) instance to generate
multiple pixel resolutions from.
@param pixel_resolutions: a list of tuples ``(logical_size, width, height)``
where:
* ``logical_size``: string representation of th... | [
"Generate",
"multiple",
"resolution",
"images",
"of",
"the",
"given",
"image",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/image_util.py#L132-L177 |
52,159 | dcaune/perseus-lib-python-common | majormode/perseus/utils/image_util.py | get_exposure | def get_exposure(image, filters=None):
"""
Determine the exposure of a photo, which can be under-exposed,
normally exposed or over-exposed.
@param image: a Python Library Image (PIL) object to determine the
exposure.
@param filters: a list of ``ColorComponentFilter`` filter or ``None``
... | python | def get_exposure(image, filters=None):
"""
Determine the exposure of a photo, which can be under-exposed,
normally exposed or over-exposed.
@param image: a Python Library Image (PIL) object to determine the
exposure.
@param filters: a list of ``ColorComponentFilter`` filter or ``None``
... | [
"def",
"get_exposure",
"(",
"image",
",",
"filters",
"=",
"None",
")",
":",
"def",
"_get_exposure",
"(",
"histogram",
")",
":",
"total",
"=",
"sum",
"(",
"histogram",
")",
"range_offset",
"=",
"len",
"(",
"histogram",
")",
"/",
"4",
"dark",
"=",
"float... | Determine the exposure of a photo, which can be under-exposed,
normally exposed or over-exposed.
@param image: a Python Library Image (PIL) object to determine the
exposure.
@param filters: a list of ``ColorComponentFilter`` filter or ``None``
to use all the filters.
@return: an ``E... | [
"Determine",
"the",
"exposure",
"of",
"a",
"photo",
"which",
"can",
"be",
"under",
"-",
"exposed",
"normally",
"exposed",
"or",
"over",
"-",
"exposed",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/image_util.py#L180-L224 |
52,160 | dcaune/perseus-lib-python-common | majormode/perseus/utils/image_util.py | is_image_file_valid | def is_image_file_valid(file_path_name):
"""
Indicate whether the specified image file is valid or not.
@param file_path_name: absolute path and file name of an image.
@return: ``True`` if the image file is valid, ``False`` if the file is
truncated or does not correspond to a supported image... | python | def is_image_file_valid(file_path_name):
"""
Indicate whether the specified image file is valid or not.
@param file_path_name: absolute path and file name of an image.
@return: ``True`` if the image file is valid, ``False`` if the file is
truncated or does not correspond to a supported image... | [
"def",
"is_image_file_valid",
"(",
"file_path_name",
")",
":",
"# Image.verify is only implemented for PNG images, and it only verifies",
"# the CRC checksum in the image. The only way to check from within",
"# Pillow is to load the image in a try/except and check the error. If",
"# as much info... | Indicate whether the specified image file is valid or not.
@param file_path_name: absolute path and file name of an image.
@return: ``True`` if the image file is valid, ``False`` if the file is
truncated or does not correspond to a supported image. | [
"Indicate",
"whether",
"the",
"specified",
"image",
"file",
"is",
"valid",
"or",
"not",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/image_util.py#L227-L250 |
52,161 | dcaune/perseus-lib-python-common | majormode/perseus/utils/image_util.py | open_and_reorient_image | def open_and_reorient_image(handle):
"""
Load the image from the specified file and orient the image accordingly
to the Exif tag that the file might embed, which would indicate the
orientation of the camera relative to the captured scene.
@param handle: a Python file object.
@return: an inst... | python | def open_and_reorient_image(handle):
"""
Load the image from the specified file and orient the image accordingly
to the Exif tag that the file might embed, which would indicate the
orientation of the camera relative to the captured scene.
@param handle: a Python file object.
@return: an inst... | [
"def",
"open_and_reorient_image",
"(",
"handle",
")",
":",
"# Retrieve tags from the Exchangeable image file format (Exif)",
"# included in the picture. If the orientation of the picture is not",
"# top left side, rotate it accordingly.",
"# @deprecated",
"# exif_tags = dict([ (exif_tag.tag, ex... | Load the image from the specified file and orient the image accordingly
to the Exif tag that the file might embed, which would indicate the
orientation of the camera relative to the captured scene.
@param handle: a Python file object.
@return: an instance returned by the Python Library Image library... | [
"Load",
"the",
"image",
"from",
"the",
"specified",
"file",
"and",
"orient",
"the",
"image",
"accordingly",
"to",
"the",
"Exif",
"tag",
"that",
"the",
"file",
"might",
"embed",
"which",
"would",
"indicate",
"the",
"orientation",
"of",
"the",
"camera",
"relat... | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/image_util.py#L253-L286 |
52,162 | dcaune/perseus-lib-python-common | majormode/perseus/utils/image_util.py | realign_image | def realign_image(image, shift_x, shift_y, max_shift_x, max_shift_y,
shift_angle=0.0, filter=Filter.NearestNeighbor,
stretch_factor=None,
cropping_box=None):
"""
Realign the given image providing the specific horizontal and vertical
shifts, and crop the image providing the maximum ho... | python | def realign_image(image, shift_x, shift_y, max_shift_x, max_shift_y,
shift_angle=0.0, filter=Filter.NearestNeighbor,
stretch_factor=None,
cropping_box=None):
"""
Realign the given image providing the specific horizontal and vertical
shifts, and crop the image providing the maximum ho... | [
"def",
"realign_image",
"(",
"image",
",",
"shift_x",
",",
"shift_y",
",",
"max_shift_x",
",",
"max_shift_y",
",",
"shift_angle",
"=",
"0.0",
",",
"filter",
"=",
"Filter",
".",
"NearestNeighbor",
",",
"stretch_factor",
"=",
"None",
",",
"cropping_box",
"=",
... | Realign the given image providing the specific horizontal and vertical
shifts, and crop the image providing the maximum horizontal and
vertical shifts of images of a same set so that they all have the same
size.
@param image: an instance of Python Image Library (PIL) image.
@param shift_x: horizo... | [
"Realign",
"the",
"given",
"image",
"providing",
"the",
"specific",
"horizontal",
"and",
"vertical",
"shifts",
"and",
"crop",
"the",
"image",
"providing",
"the",
"maximum",
"horizontal",
"and",
"vertical",
"shifts",
"of",
"images",
"of",
"a",
"same",
"set",
"s... | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/image_util.py#L299-L390 |
52,163 | dcaune/perseus-lib-python-common | majormode/perseus/utils/image_util.py | resize_image | def resize_image(image, canvas_size,
filter=Filter.NearestNeighbor,
does_crop=False,
crop_aligment=CropAlignment.center,
crop_form=CropForm.rectangle,
match_orientation=False):
"""
Resize the specified image to the required dimension.
@param image: a Python Image Li... | python | def resize_image(image, canvas_size,
filter=Filter.NearestNeighbor,
does_crop=False,
crop_aligment=CropAlignment.center,
crop_form=CropForm.rectangle,
match_orientation=False):
"""
Resize the specified image to the required dimension.
@param image: a Python Image Li... | [
"def",
"resize_image",
"(",
"image",
",",
"canvas_size",
",",
"filter",
"=",
"Filter",
".",
"NearestNeighbor",
",",
"does_crop",
"=",
"False",
",",
"crop_aligment",
"=",
"CropAlignment",
".",
"center",
",",
"crop_form",
"=",
"CropForm",
".",
"rectangle",
",",
... | Resize the specified image to the required dimension.
@param image: a Python Image Library (PIL) image instance.
@param canvas_size: requested size in pixels, as a 2-tuple
``(width, height)``.
@param filter: indicate the filter to use when resizing the image.
@param does_crop: indicate whet... | [
"Resize",
"the",
"specified",
"image",
"to",
"the",
"required",
"dimension",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/image_util.py#L393-L463 |
52,164 | rionbr/VTT | vtt/__init__.py | VTT.__get_vtt_angles | def __get_vtt_angles(self, pvals, nvals):
""" Fit the angles to the model
Args:
pvals (array-like) : positive values
nvals (array-like) : negative values
Returns: normalized coef_ values
"""
# https://www.khanacademy.org/math/trigonometry/unit-circle-trig-func/inverse_trig_functions/v/inverse-trig-fun... | python | def __get_vtt_angles(self, pvals, nvals):
""" Fit the angles to the model
Args:
pvals (array-like) : positive values
nvals (array-like) : negative values
Returns: normalized coef_ values
"""
# https://www.khanacademy.org/math/trigonometry/unit-circle-trig-func/inverse_trig_functions/v/inverse-trig-fun... | [
"def",
"__get_vtt_angles",
"(",
"self",
",",
"pvals",
",",
"nvals",
")",
":",
"# https://www.khanacademy.org/math/trigonometry/unit-circle-trig-func/inverse_trig_functions/v/inverse-trig-functions--arctan",
"angles",
"=",
"np",
".",
"arctan2",
"(",
"pvals",
",",
"nvals",
")",... | Fit the angles to the model
Args:
pvals (array-like) : positive values
nvals (array-like) : negative values
Returns: normalized coef_ values | [
"Fit",
"the",
"angles",
"to",
"the",
"model"
] | f55396aa65ea748cedff2deea301558adc63c755 | https://github.com/rionbr/VTT/blob/f55396aa65ea748cedff2deea301558adc63c755/vtt/__init__.py#L41-L57 |
52,165 | rionbr/VTT | vtt/__init__.py | VTT.set_params | def set_params(self, **params):
""" Set the parameters of the estimator.
Args:
bias (array-like) : bias of the estimator. Also known as the intercept in a linear model.
weights (array-like) : weights of the features. Also known as coeficients.
NER biases (array-like) : NER entities infering column positio... | python | def set_params(self, **params):
""" Set the parameters of the estimator.
Args:
bias (array-like) : bias of the estimator. Also known as the intercept in a linear model.
weights (array-like) : weights of the features. Also known as coeficients.
NER biases (array-like) : NER entities infering column positio... | [
"def",
"set_params",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"if",
"'bias'",
"in",
"params",
".",
"keys",
"(",
")",
":",
"self",
".",
"intercept_",
"=",
"params",
"[",
"'bias'",
"]",
"if",
"'weights'",
"in",
"params",
".",
"keys",
"(",
")",... | Set the parameters of the estimator.
Args:
bias (array-like) : bias of the estimator. Also known as the intercept in a linear model.
weights (array-like) : weights of the features. Also known as coeficients.
NER biases (array-like) : NER entities infering column position on X and bias value. Ex: `b_4=10, b_... | [
"Set",
"the",
"parameters",
"of",
"the",
"estimator",
"."
] | f55396aa65ea748cedff2deea301558adc63c755 | https://github.com/rionbr/VTT/blob/f55396aa65ea748cedff2deea301558adc63c755/vtt/__init__.py#L121-L141 |
52,166 | rionbr/VTT | vtt/__init__.py | VTT.get_params | def get_params(self, deep=True):
""" Get parameters for the estimator.
Args:
deep (boolean, optional) : If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:
params : mapping of string to any contained subobjects that are estimators.
"""
params =... | python | def get_params(self, deep=True):
""" Get parameters for the estimator.
Args:
deep (boolean, optional) : If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:
params : mapping of string to any contained subobjects that are estimators.
"""
params =... | [
"def",
"get_params",
"(",
"self",
",",
"deep",
"=",
"True",
")",
":",
"params",
"=",
"{",
"'weights'",
":",
"self",
".",
"coef_",
",",
"'bias'",
":",
"self",
".",
"intercept_",
"}",
"if",
"deep",
":",
"for",
"key",
",",
"value",
"in",
"self",
".",
... | Get parameters for the estimator.
Args:
deep (boolean, optional) : If True, will return the parameters for this estimator and contained subobjects that are estimators.
Returns:
params : mapping of string to any contained subobjects that are estimators. | [
"Get",
"parameters",
"for",
"the",
"estimator",
"."
] | f55396aa65ea748cedff2deea301558adc63c755 | https://github.com/rionbr/VTT/blob/f55396aa65ea748cedff2deea301558adc63c755/vtt/__init__.py#L143-L157 |
52,167 | dcaune/perseus-lib-python-common | majormode/perseus/utils/email_util.py | send_email | def send_email(hostname, username, password,
author_name, author_email_address, recipient_email_addresses,
subject, content,
file_path_names=None,
port_number=587,
unsubscribe_mailto_link=None,
unsubscribe_url=None):
"""
Send a electronic mail to a list of recipie... | python | def send_email(hostname, username, password,
author_name, author_email_address, recipient_email_addresses,
subject, content,
file_path_names=None,
port_number=587,
unsubscribe_mailto_link=None,
unsubscribe_url=None):
"""
Send a electronic mail to a list of recipie... | [
"def",
"send_email",
"(",
"hostname",
",",
"username",
",",
"password",
",",
"author_name",
",",
"author_email_address",
",",
"recipient_email_addresses",
",",
"subject",
",",
"content",
",",
"file_path_names",
"=",
"None",
",",
"port_number",
"=",
"587",
",",
"... | Send a electronic mail to a list of recipients.
@note: Outlook and Gmail leverage the list-unsubscribe option for
senders with good sending reputations:
"In order to receive unsubscribe feedback, senders must include an
RFC2369-compliant List-Unsubscribe header containing a mailto: addres... | [
"Send",
"a",
"electronic",
"mail",
"to",
"a",
"list",
"of",
"recipients",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/email_util.py#L78-L217 |
52,168 | WalletGuild/desw | desw/__init__.py | confirm_send | def confirm_send(address, amount, ref_id=None, session=ses):
"""
Confirm that a send has completed. Does not actually check confirmations,
but instead assumes that if this is called, the transaction has been
completed. This is because we assume our own sends are safe.
:param session:
:param str... | python | def confirm_send(address, amount, ref_id=None, session=ses):
"""
Confirm that a send has completed. Does not actually check confirmations,
but instead assumes that if this is called, the transaction has been
completed. This is because we assume our own sends are safe.
:param session:
:param str... | [
"def",
"confirm_send",
"(",
"address",
",",
"amount",
",",
"ref_id",
"=",
"None",
",",
"session",
"=",
"ses",
")",
":",
"debitq",
"=",
"session",
".",
"query",
"(",
"wm",
".",
"Debit",
")",
"debitq",
"=",
"debitq",
".",
"filter",
"(",
"wm",
".",
"D... | Confirm that a send has completed. Does not actually check confirmations,
but instead assumes that if this is called, the transaction has been
completed. This is because we assume our own sends are safe.
:param session:
:param str ref_id: The updated ref_id for the transaction in question
:param st... | [
"Confirm",
"that",
"a",
"send",
"has",
"completed",
".",
"Does",
"not",
"actually",
"check",
"confirmations",
"but",
"instead",
"assumes",
"that",
"if",
"this",
"is",
"called",
"the",
"transaction",
"has",
"been",
"completed",
".",
"This",
"is",
"because",
"... | f966c612e675961d9dbd8268749e349ba10a47c2 | https://github.com/WalletGuild/desw/blob/f966c612e675961d9dbd8268749e349ba10a47c2/desw/__init__.py#L17-L39 |
52,169 | dev-pipeline/dev-pipeline-configure | lib/devpipeline_configure/parser.py | read_config | def read_config(path):
"""
Read a configuration from disk.
Arguments
path -- the loation to deserialize
"""
parser = _make_parser()
if parser.read(path):
return parser
raise Exception("Failed to read {}".format(path)) | python | def read_config(path):
"""
Read a configuration from disk.
Arguments
path -- the loation to deserialize
"""
parser = _make_parser()
if parser.read(path):
return parser
raise Exception("Failed to read {}".format(path)) | [
"def",
"read_config",
"(",
"path",
")",
":",
"parser",
"=",
"_make_parser",
"(",
")",
"if",
"parser",
".",
"read",
"(",
"path",
")",
":",
"return",
"parser",
"raise",
"Exception",
"(",
"\"Failed to read {}\"",
".",
"format",
"(",
"path",
")",
")"
] | Read a configuration from disk.
Arguments
path -- the loation to deserialize | [
"Read",
"a",
"configuration",
"from",
"disk",
"."
] | 26de2dd1b39d9a77d5417244f09319e7dce47495 | https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/parser.py#L12-L22 |
52,170 | RI-imaging/qpsphere | qpsphere/models/mod_rytov_sc.py | correct_rytov_sc_input | def correct_rytov_sc_input(radius_sc, sphere_index_sc, medium_index,
radius_sampling):
"""Inverse correction of refractive index and radius for Rytov
This method returns the inverse of :func:`correct_rytov_output`.
Parameters
----------
radius_sc: float
Systemati... | python | def correct_rytov_sc_input(radius_sc, sphere_index_sc, medium_index,
radius_sampling):
"""Inverse correction of refractive index and radius for Rytov
This method returns the inverse of :func:`correct_rytov_output`.
Parameters
----------
radius_sc: float
Systemati... | [
"def",
"correct_rytov_sc_input",
"(",
"radius_sc",
",",
"sphere_index_sc",
",",
"medium_index",
",",
"radius_sampling",
")",
":",
"params",
"=",
"get_params",
"(",
"radius_sampling",
")",
"# sage script:",
"# var('sphere_index, sphere_index_sc, na, nb, medium_index')",
"# x =... | Inverse correction of refractive index and radius for Rytov
This method returns the inverse of :func:`correct_rytov_output`.
Parameters
----------
radius_sc: float
Systematically corrected radius of the sphere [m]
sphere_index_sc: float
Systematically corrected refractive index of ... | [
"Inverse",
"correction",
"of",
"refractive",
"index",
"and",
"radius",
"for",
"Rytov"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/mod_rytov_sc.py#L15-L66 |
52,171 | RI-imaging/qpsphere | qpsphere/models/mod_rytov_sc.py | correct_rytov_output | def correct_rytov_output(radius, sphere_index, medium_index, radius_sampling):
r"""Error-correction of refractive index and radius for Rytov
This method corrects the fitting results for `radius`
:math:`r_\text{Ryt}` and `sphere_index` :math:`n_\text{Ryt}`
obtained using :func:`qpsphere.models.rytov` us... | python | def correct_rytov_output(radius, sphere_index, medium_index, radius_sampling):
r"""Error-correction of refractive index and radius for Rytov
This method corrects the fitting results for `radius`
:math:`r_\text{Ryt}` and `sphere_index` :math:`n_\text{Ryt}`
obtained using :func:`qpsphere.models.rytov` us... | [
"def",
"correct_rytov_output",
"(",
"radius",
",",
"sphere_index",
",",
"medium_index",
",",
"radius_sampling",
")",
":",
"params",
"=",
"get_params",
"(",
"radius_sampling",
")",
"x",
"=",
"sphere_index",
"/",
"medium_index",
"-",
"1",
"radius_sc",
"=",
"radius... | r"""Error-correction of refractive index and radius for Rytov
This method corrects the fitting results for `radius`
:math:`r_\text{Ryt}` and `sphere_index` :math:`n_\text{Ryt}`
obtained using :func:`qpsphere.models.rytov` using
the approach described in :cite:`Mueller2018` (eqns. 3,4, and 5).
.. m... | [
"r",
"Error",
"-",
"correction",
"of",
"refractive",
"index",
"and",
"radius",
"for",
"Rytov"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/mod_rytov_sc.py#L69-L126 |
52,172 | RI-imaging/qpsphere | qpsphere/models/mod_rytov_sc.py | rytov_sc | def rytov_sc(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, pixel_size=1e-7, grid_size=(80, 80),
center=(39.5, 39.5), radius_sampling=42):
r"""Field behind a dielectric sphere, systematically corrected Rytov
This method implements a correction of
:func:`qp... | python | def rytov_sc(radius=5e-6, sphere_index=1.339, medium_index=1.333,
wavelength=550e-9, pixel_size=1e-7, grid_size=(80, 80),
center=(39.5, 39.5), radius_sampling=42):
r"""Field behind a dielectric sphere, systematically corrected Rytov
This method implements a correction of
:func:`qp... | [
"def",
"rytov_sc",
"(",
"radius",
"=",
"5e-6",
",",
"sphere_index",
"=",
"1.339",
",",
"medium_index",
"=",
"1.333",
",",
"wavelength",
"=",
"550e-9",
",",
"pixel_size",
"=",
"1e-7",
",",
"grid_size",
"=",
"(",
"80",
",",
"80",
")",
",",
"center",
"=",... | r"""Field behind a dielectric sphere, systematically corrected Rytov
This method implements a correction of
:func:`qpsphere.models.rytov`, where the
`radius` :math:`r_\text{Ryt}` and the `sphere_index`
:math:`n_\text{Ryt}` are corrected using
the approach described in :cite:`Mueller2018` (eqns. 3,4... | [
"r",
"Field",
"behind",
"a",
"dielectric",
"sphere",
"systematically",
"corrected",
"Rytov"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/models/mod_rytov_sc.py#L137-L206 |
52,173 | sci-bots/pygtkhelpers | pygtkhelpers/utils.py | gsignal | def gsignal(name, *args, **kwargs):
"""Add a GObject signal to the current object.
It current supports the following types:
- str, int, float, long, object, enum
:param name: name of the signal
:param args: types for signal parameters,
if the first one is a string 'override', the signa... | python | def gsignal(name, *args, **kwargs):
"""Add a GObject signal to the current object.
It current supports the following types:
- str, int, float, long, object, enum
:param name: name of the signal
:param args: types for signal parameters,
if the first one is a string 'override', the signa... | [
"def",
"gsignal",
"(",
"name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
"1",
")",
"try",
":",
"locals",
"=",
"frame",
".",
"f_locals",
"finally",
":",
"del",
"frame",
"dict",
"=",
"locals",
... | Add a GObject signal to the current object.
It current supports the following types:
- str, int, float, long, object, enum
:param name: name of the signal
:param args: types for signal parameters,
if the first one is a string 'override', the signal will be
overridden and must there... | [
"Add",
"a",
"GObject",
"signal",
"to",
"the",
"current",
"object",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/utils.py#L25-L71 |
52,174 | sci-bots/pygtkhelpers | pygtkhelpers/utils.py | gproperty | def gproperty(name, ptype, default=None, nick='', blurb='',
flags=gobject.PARAM_READWRITE, **kwargs):
"""Add a GObject property to the current object.
:param name: name of property
:param ptype: type of property
:param default: default value
:param nick: short description
... | python | def gproperty(name, ptype, default=None, nick='', blurb='',
flags=gobject.PARAM_READWRITE, **kwargs):
"""Add a GObject property to the current object.
:param name: name of property
:param ptype: type of property
:param default: default value
:param nick: short description
... | [
"def",
"gproperty",
"(",
"name",
",",
"ptype",
",",
"default",
"=",
"None",
",",
"nick",
"=",
"''",
",",
"blurb",
"=",
"''",
",",
"flags",
"=",
"gobject",
".",
"PARAM_READWRITE",
",",
"*",
"*",
"kwargs",
")",
":",
"# General type checking",
"if",
"defa... | Add a GObject property to the current object.
:param name: name of property
:param ptype: type of property
:param default: default value
:param nick: short description
:param blurb: long description
:param flags: parameter flags, a combination of:
- PARAM_READABLE
- P... | [
"Add",
"a",
"GObject",
"property",
"to",
"the",
"current",
"object",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/utils.py#L85-L157 |
52,175 | sci-bots/pygtkhelpers | pygtkhelpers/utils.py | refresh_gui | def refresh_gui(delay=0.0001, wait=0.0001):
"""Use up all the events waiting to be run
:param delay: Time to wait before using events
:param wait: Time to wait between iterations of events
This function will block until all pending events are emitted. This is
useful in testing to ensure signals an... | python | def refresh_gui(delay=0.0001, wait=0.0001):
"""Use up all the events waiting to be run
:param delay: Time to wait before using events
:param wait: Time to wait between iterations of events
This function will block until all pending events are emitted. This is
useful in testing to ensure signals an... | [
"def",
"refresh_gui",
"(",
"delay",
"=",
"0.0001",
",",
"wait",
"=",
"0.0001",
")",
":",
"time",
".",
"sleep",
"(",
"delay",
")",
"while",
"gtk",
".",
"events_pending",
"(",
")",
":",
"gtk",
".",
"main_iteration_do",
"(",
"block",
"=",
"False",
")",
... | Use up all the events waiting to be run
:param delay: Time to wait before using events
:param wait: Time to wait between iterations of events
This function will block until all pending events are emitted. This is
useful in testing to ensure signals and other asynchronous functionality
is required ... | [
"Use",
"up",
"all",
"the",
"events",
"waiting",
"to",
"be",
"run"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/utils.py#L160-L173 |
52,176 | sci-bots/pygtkhelpers | pygtkhelpers/utils.py | run_in_window | def run_in_window(target, on_destroy=gtk.main_quit):
"""Run a widget, or a delegate in a Window
"""
w = _get_in_window(target)
if on_destroy:
w.connect('destroy', on_destroy)
w.resize(500, 400)
w.move(100, 100)
w.show_all()
gtk.main() | python | def run_in_window(target, on_destroy=gtk.main_quit):
"""Run a widget, or a delegate in a Window
"""
w = _get_in_window(target)
if on_destroy:
w.connect('destroy', on_destroy)
w.resize(500, 400)
w.move(100, 100)
w.show_all()
gtk.main() | [
"def",
"run_in_window",
"(",
"target",
",",
"on_destroy",
"=",
"gtk",
".",
"main_quit",
")",
":",
"w",
"=",
"_get_in_window",
"(",
"target",
")",
"if",
"on_destroy",
":",
"w",
".",
"connect",
"(",
"'destroy'",
",",
"on_destroy",
")",
"w",
".",
"resize",
... | Run a widget, or a delegate in a Window | [
"Run",
"a",
"widget",
"or",
"a",
"delegate",
"in",
"a",
"Window"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/utils.py#L188-L197 |
52,177 | sci-bots/pygtkhelpers | pygtkhelpers/utils.py | dict_to_form | def dict_to_form(dict):
'''
Generate a flatland form based on a pandas Series.
'''
from flatland import Boolean, Form, String, Integer, Float
def is_float(v):
try:
return (float(str(v)), True)[1]
except (ValueError, TypeError):
return False
def is_int(v)... | python | def dict_to_form(dict):
'''
Generate a flatland form based on a pandas Series.
'''
from flatland import Boolean, Form, String, Integer, Float
def is_float(v):
try:
return (float(str(v)), True)[1]
except (ValueError, TypeError):
return False
def is_int(v)... | [
"def",
"dict_to_form",
"(",
"dict",
")",
":",
"from",
"flatland",
"import",
"Boolean",
",",
"Form",
",",
"String",
",",
"Integer",
",",
"Float",
"def",
"is_float",
"(",
"v",
")",
":",
"try",
":",
"return",
"(",
"float",
"(",
"str",
"(",
"v",
")",
"... | Generate a flatland form based on a pandas Series. | [
"Generate",
"a",
"flatland",
"form",
"based",
"on",
"a",
"pandas",
"Series",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/utils.py#L287-L323 |
52,178 | mogproject/mog-commons-python | src/mog_commons/terminal.py | TerminalHandler._detect_term_type | def _detect_term_type():
"""
Detect the type of the terminal.
"""
if os.name == 'nt':
if os.environ.get('TERM') == 'xterm':
# maybe MinTTY
return 'mintty'
else:
return 'nt'
if platform.system().upper().starts... | python | def _detect_term_type():
"""
Detect the type of the terminal.
"""
if os.name == 'nt':
if os.environ.get('TERM') == 'xterm':
# maybe MinTTY
return 'mintty'
else:
return 'nt'
if platform.system().upper().starts... | [
"def",
"_detect_term_type",
"(",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'TERM'",
")",
"==",
"'xterm'",
":",
"# maybe MinTTY",
"return",
"'mintty'",
"else",
":",
"return",
"'nt'",
"if",
"platf... | Detect the type of the terminal. | [
"Detect",
"the",
"type",
"of",
"the",
"terminal",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/terminal.py#L71-L83 |
52,179 | mogproject/mog-commons-python | src/mog_commons/terminal.py | TerminalHandler.clear | def clear(self):
"""
Clear the terminal screen.
"""
if hasattr(self.stdout, 'isatty') and self.stdout.isatty() or self.term_type == 'mintty':
cmd, shell = {
'posix': ('clear', False),
'nt': ('cls', True),
'cygwin': (['echo', '-e... | python | def clear(self):
"""
Clear the terminal screen.
"""
if hasattr(self.stdout, 'isatty') and self.stdout.isatty() or self.term_type == 'mintty':
cmd, shell = {
'posix': ('clear', False),
'nt': ('cls', True),
'cygwin': (['echo', '-e... | [
"def",
"clear",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"stdout",
",",
"'isatty'",
")",
"and",
"self",
".",
"stdout",
".",
"isatty",
"(",
")",
"or",
"self",
".",
"term_type",
"==",
"'mintty'",
":",
"cmd",
",",
"shell",
"=",
"{",
... | Clear the terminal screen. | [
"Clear",
"the",
"terminal",
"screen",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/terminal.py#L124-L135 |
52,180 | mogproject/mog-commons-python | src/mog_commons/terminal.py | TerminalHandler.clear_input_buffer | def clear_input_buffer(self):
"""
Clear the input buffer.
"""
if hasattr(self.stdin, 'isatty') and self.stdin.isatty():
if os.name == 'nt':
while msvcrt.kbhit():
msvcrt.getch()
else:
try:
self... | python | def clear_input_buffer(self):
"""
Clear the input buffer.
"""
if hasattr(self.stdin, 'isatty') and self.stdin.isatty():
if os.name == 'nt':
while msvcrt.kbhit():
msvcrt.getch()
else:
try:
self... | [
"def",
"clear_input_buffer",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"stdin",
",",
"'isatty'",
")",
"and",
"self",
".",
"stdin",
".",
"isatty",
"(",
")",
":",
"if",
"os",
".",
"name",
"==",
"'nt'",
":",
"while",
"msvcrt",
".",
"kb... | Clear the input buffer. | [
"Clear",
"the",
"input",
"buffer",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/terminal.py#L137-L149 |
52,181 | mogproject/mog-commons-python | src/mog_commons/terminal.py | TerminalHandler.getch | def getch(self):
"""
Read one character from stdin.
If stdin is not a tty or set `getch_enabled`=False, read input as one line.
:return: unicode:
"""
ch = self._get_one_char()
if self.keep_input_clean:
self.clear_input_buffer()
try:
... | python | def getch(self):
"""
Read one character from stdin.
If stdin is not a tty or set `getch_enabled`=False, read input as one line.
:return: unicode:
"""
ch = self._get_one_char()
if self.keep_input_clean:
self.clear_input_buffer()
try:
... | [
"def",
"getch",
"(",
"self",
")",
":",
"ch",
"=",
"self",
".",
"_get_one_char",
"(",
")",
"if",
"self",
".",
"keep_input_clean",
":",
"self",
".",
"clear_input_buffer",
"(",
")",
"try",
":",
"# accept only unicode characters (for Python 2)",
"uch",
"=",
"to_un... | Read one character from stdin.
If stdin is not a tty or set `getch_enabled`=False, read input as one line.
:return: unicode: | [
"Read",
"one",
"character",
"from",
"stdin",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/terminal.py#L151-L168 |
52,182 | mogproject/mog-commons-python | src/mog_commons/terminal.py | TerminalHandler.gets | def gets(self):
"""
Read line from stdin.
The trailing newline will be omitted.
:return: string:
"""
ret = self.stdin.readline()
if ret == '':
raise EOFError # To break out of EOF loop
return ret.rstrip('\n') | python | def gets(self):
"""
Read line from stdin.
The trailing newline will be omitted.
:return: string:
"""
ret = self.stdin.readline()
if ret == '':
raise EOFError # To break out of EOF loop
return ret.rstrip('\n') | [
"def",
"gets",
"(",
"self",
")",
":",
"ret",
"=",
"self",
".",
"stdin",
".",
"readline",
"(",
")",
"if",
"ret",
"==",
"''",
":",
"raise",
"EOFError",
"# To break out of EOF loop",
"return",
"ret",
".",
"rstrip",
"(",
"'\\n'",
")"
] | Read line from stdin.
The trailing newline will be omitted.
:return: string: | [
"Read",
"line",
"from",
"stdin",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/terminal.py#L195-L205 |
52,183 | bbengfort/commis | commis/command.py | Command.create_parser | def create_parser(self, subparsers):
"""
Creates the subparser for this particular command
"""
self.parser = subparsers.add_parser(self.name, help=self.help, parents=self.parents)
self.add_arguments()
self.parser.set_defaults(func=self.handle)
return self.parser | python | def create_parser(self, subparsers):
"""
Creates the subparser for this particular command
"""
self.parser = subparsers.add_parser(self.name, help=self.help, parents=self.parents)
self.add_arguments()
self.parser.set_defaults(func=self.handle)
return self.parser | [
"def",
"create_parser",
"(",
"self",
",",
"subparsers",
")",
":",
"self",
".",
"parser",
"=",
"subparsers",
".",
"add_parser",
"(",
"self",
".",
"name",
",",
"help",
"=",
"self",
".",
"help",
",",
"parents",
"=",
"self",
".",
"parents",
")",
"self",
... | Creates the subparser for this particular command | [
"Creates",
"the",
"subparser",
"for",
"this",
"particular",
"command"
] | cea696ccd1fec9c22974ae396b7e66c4275240ad | https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/command.py#L77-L84 |
52,184 | bbengfort/commis | commis/command.py | Command.add_arguments | def add_arguments(self):
"""
Definition and addition of all arguments.
"""
if self.parser is None:
raise TypeError("Parser cannot be None, has create_parser been called?")
for keys, kwargs in self.args.items():
if not isinstance(keys, tuple):
... | python | def add_arguments(self):
"""
Definition and addition of all arguments.
"""
if self.parser is None:
raise TypeError("Parser cannot be None, has create_parser been called?")
for keys, kwargs in self.args.items():
if not isinstance(keys, tuple):
... | [
"def",
"add_arguments",
"(",
"self",
")",
":",
"if",
"self",
".",
"parser",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"Parser cannot be None, has create_parser been called?\"",
")",
"for",
"keys",
",",
"kwargs",
"in",
"self",
".",
"args",
".",
"items",
"... | Definition and addition of all arguments. | [
"Definition",
"and",
"addition",
"of",
"all",
"arguments",
"."
] | cea696ccd1fec9c22974ae396b7e66c4275240ad | https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/command.py#L86-L96 |
52,185 | deeshugupta/tes | es_commands/cat_api.py | allocation | def allocation(node,format,h):
'''
Allocation provides a snapshot of how shards have located around the
cluster and the state of disk usage
'''
try:
response = base.es.cat.allocation(node_id=node,bytes=format, h=h, format='json')
table = base.draw_table(response)
except Exception... | python | def allocation(node,format,h):
'''
Allocation provides a snapshot of how shards have located around the
cluster and the state of disk usage
'''
try:
response = base.es.cat.allocation(node_id=node,bytes=format, h=h, format='json')
table = base.draw_table(response)
except Exception... | [
"def",
"allocation",
"(",
"node",
",",
"format",
",",
"h",
")",
":",
"try",
":",
"response",
"=",
"base",
".",
"es",
".",
"cat",
".",
"allocation",
"(",
"node_id",
"=",
"node",
",",
"bytes",
"=",
"format",
",",
"h",
"=",
"h",
",",
"format",
"=",
... | Allocation provides a snapshot of how shards have located around the
cluster and the state of disk usage | [
"Allocation",
"provides",
"a",
"snapshot",
"of",
"how",
"shards",
"have",
"located",
"around",
"the",
"cluster",
"and",
"the",
"state",
"of",
"disk",
"usage"
] | 217db49aa211ebca2d9258380765a0c31abfca91 | https://github.com/deeshugupta/tes/blob/217db49aa211ebca2d9258380765a0c31abfca91/es_commands/cat_api.py#L46-L57 |
52,186 | deeshugupta/tes | es_commands/cat_api.py | count | def count(index,h):
'''
Gives count of the documents stored in Elasticsearch. If index option is
provided, it will provide document count of that index.
'''
try:
response = base.es.cat.count(index,h=h)
table = base.draw_table(response)
except Exception as e:
click.echo(e)... | python | def count(index,h):
'''
Gives count of the documents stored in Elasticsearch. If index option is
provided, it will provide document count of that index.
'''
try:
response = base.es.cat.count(index,h=h)
table = base.draw_table(response)
except Exception as e:
click.echo(e)... | [
"def",
"count",
"(",
"index",
",",
"h",
")",
":",
"try",
":",
"response",
"=",
"base",
".",
"es",
".",
"cat",
".",
"count",
"(",
"index",
",",
"h",
"=",
"h",
")",
"table",
"=",
"base",
".",
"draw_table",
"(",
"response",
")",
"except",
"Exception... | Gives count of the documents stored in Elasticsearch. If index option is
provided, it will provide document count of that index. | [
"Gives",
"count",
"of",
"the",
"documents",
"stored",
"in",
"Elasticsearch",
".",
"If",
"index",
"option",
"is",
"provided",
"it",
"will",
"provide",
"document",
"count",
"of",
"that",
"index",
"."
] | 217db49aa211ebca2d9258380765a0c31abfca91 | https://github.com/deeshugupta/tes/blob/217db49aa211ebca2d9258380765a0c31abfca91/es_commands/cat_api.py#L63-L74 |
52,187 | dcaune/perseus-lib-python-common | majormode/perseus/utils/amqp.py | AmqpConnection.close | def close(self):
"""
Close the connection to the AMQP compliant broker.
"""
if self.channel is not None: self.channel.close()
if self.__connection is not None: self.__connection.close() | python | def close(self):
"""
Close the connection to the AMQP compliant broker.
"""
if self.channel is not None: self.channel.close()
if self.__connection is not None: self.__connection.close() | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"channel",
"is",
"not",
"None",
":",
"self",
".",
"channel",
".",
"close",
"(",
")",
"if",
"self",
".",
"__connection",
"is",
"not",
"None",
":",
"self",
".",
"__connection",
".",
"close",
"... | Close the connection to the AMQP compliant broker. | [
"Close",
"the",
"connection",
"to",
"the",
"AMQP",
"compliant",
"broker",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/amqp.py#L96-L101 |
52,188 | dcaune/perseus-lib-python-common | majormode/perseus/utils/amqp.py | AmqpConnection.open | def open(self):
"""
Open a connection to the AMQP compliant broker.
"""
self._connection = \
amqp.Connection(host='%s:%s' % (self.hostname, self.port),
userid=self.username, password=self.password,
virtual_host=self.virtual_ho... | python | def open(self):
"""
Open a connection to the AMQP compliant broker.
"""
self._connection = \
amqp.Connection(host='%s:%s' % (self.hostname, self.port),
userid=self.username, password=self.password,
virtual_host=self.virtual_ho... | [
"def",
"open",
"(",
"self",
")",
":",
"self",
".",
"_connection",
"=",
"amqp",
".",
"Connection",
"(",
"host",
"=",
"'%s:%s'",
"%",
"(",
"self",
".",
"hostname",
",",
"self",
".",
"port",
")",
",",
"userid",
"=",
"self",
".",
"username",
",",
"pass... | Open a connection to the AMQP compliant broker. | [
"Open",
"a",
"connection",
"to",
"the",
"AMQP",
"compliant",
"broker",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/amqp.py#L103-L111 |
52,189 | dcaune/perseus-lib-python-common | majormode/perseus/utils/amqp.py | AmqpConnection.publish | def publish(self, message_type, message_payload):
"""
Publish the specified object that the function automatically converts
into a JSON string representation.
This function use the lowered class name of the service as the AMQP
routing key. For instance, if the class ``ExampleSe... | python | def publish(self, message_type, message_payload):
"""
Publish the specified object that the function automatically converts
into a JSON string representation.
This function use the lowered class name of the service as the AMQP
routing key. For instance, if the class ``ExampleSe... | [
"def",
"publish",
"(",
"self",
",",
"message_type",
",",
"message_payload",
")",
":",
"payload",
"=",
"json",
".",
"dumps",
"(",
"jsonpickle",
".",
"Pickler",
"(",
"unpicklable",
"=",
"False",
")",
".",
"flatten",
"(",
"message_payload",
")",
")",
"message... | Publish the specified object that the function automatically converts
into a JSON string representation.
This function use the lowered class name of the service as the AMQP
routing key. For instance, if the class ``ExampleService`` inherits
from the base class ``BaseService``, the meth... | [
"Publish",
"the",
"specified",
"object",
"that",
"the",
"function",
"automatically",
"converts",
"into",
"a",
"JSON",
"string",
"representation",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/amqp.py#L113-L139 |
52,190 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/__init__.py | get_py_dtypes | def get_py_dtypes(data_frame):
'''
Return a `pandas.DataFrame` containing Python type information for the
columns in `data_frame`.
Args:
data_frame (pandas.DataFrame) : Data frame containing data columns.
Returns:
(pandas.DataFrame) : Data frame indexed by the column names from
... | python | def get_py_dtypes(data_frame):
'''
Return a `pandas.DataFrame` containing Python type information for the
columns in `data_frame`.
Args:
data_frame (pandas.DataFrame) : Data frame containing data columns.
Returns:
(pandas.DataFrame) : Data frame indexed by the column names from
... | [
"def",
"get_py_dtypes",
"(",
"data_frame",
")",
":",
"df_py_dtypes",
"=",
"data_frame",
".",
"dtypes",
".",
"map",
"(",
"get_py_dtype",
")",
".",
"to_frame",
"(",
"'dtype'",
")",
".",
"copy",
"(",
")",
"df_py_dtypes",
".",
"loc",
"[",
"df_py_dtypes",
".",
... | Return a `pandas.DataFrame` containing Python type information for the
columns in `data_frame`.
Args:
data_frame (pandas.DataFrame) : Data frame containing data columns.
Returns:
(pandas.DataFrame) : Data frame indexed by the column names from
`data_frame`, with the columns `... | [
"Return",
"a",
"pandas",
".",
"DataFrame",
"containing",
"Python",
"type",
"information",
"for",
"the",
"columns",
"in",
"data_frame",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/__init__.py#L40-L64 |
52,191 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/__init__.py | get_list_store | def get_list_store(data_frame):
'''
Return a `pandas.DataFrame` containing Python type information for the
columns in `data_frame` and a `gtk.ListStore` matching the contents of the
data frame.
Args:
data_frame (pandas.DataFrame) : Data frame containing data columns.
Returns:
... | python | def get_list_store(data_frame):
'''
Return a `pandas.DataFrame` containing Python type information for the
columns in `data_frame` and a `gtk.ListStore` matching the contents of the
data frame.
Args:
data_frame (pandas.DataFrame) : Data frame containing data columns.
Returns:
... | [
"def",
"get_list_store",
"(",
"data_frame",
")",
":",
"df_py_dtypes",
"=",
"get_py_dtypes",
"(",
"data_frame",
")",
"list_store",
"=",
"gtk",
".",
"ListStore",
"(",
"*",
"df_py_dtypes",
".",
"dtype",
")",
"for",
"i",
",",
"row_i",
"in",
"data_frame",
".",
... | Return a `pandas.DataFrame` containing Python type information for the
columns in `data_frame` and a `gtk.ListStore` matching the contents of the
data frame.
Args:
data_frame (pandas.DataFrame) : Data frame containing data columns.
Returns:
(tuple) : The first element is a data frame... | [
"Return",
"a",
"pandas",
".",
"DataFrame",
"containing",
"Python",
"type",
"information",
"for",
"the",
"columns",
"in",
"data_frame",
"and",
"a",
"gtk",
".",
"ListStore",
"matching",
"the",
"contents",
"of",
"the",
"data",
"frame",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/__init__.py#L67-L87 |
52,192 | sci-bots/pygtkhelpers | pygtkhelpers/ui/objectlist/__init__.py | add_columns | def add_columns(tree_view, df_py_dtypes, list_store):
'''
Add columns to a `gtk.TreeView` for the types listed in `df_py_dtypes`.
Args:
tree_view (gtk.TreeView) : Tree view to append columns to.
df_py_dtypes (pandas.DataFrame) : Data frame containing type
information for one or... | python | def add_columns(tree_view, df_py_dtypes, list_store):
'''
Add columns to a `gtk.TreeView` for the types listed in `df_py_dtypes`.
Args:
tree_view (gtk.TreeView) : Tree view to append columns to.
df_py_dtypes (pandas.DataFrame) : Data frame containing type
information for one or... | [
"def",
"add_columns",
"(",
"tree_view",
",",
"df_py_dtypes",
",",
"list_store",
")",
":",
"tree_view",
".",
"set_model",
"(",
"list_store",
")",
"for",
"column_i",
",",
"(",
"i",
",",
"dtype_i",
")",
"in",
"df_py_dtypes",
"[",
"[",
"'i'",
",",
"'dtype'",
... | Add columns to a `gtk.TreeView` for the types listed in `df_py_dtypes`.
Args:
tree_view (gtk.TreeView) : Tree view to append columns to.
df_py_dtypes (pandas.DataFrame) : Data frame containing type
information for one or more columns in `list_store`.
list_store (gtk.ListStore) ... | [
"Add",
"columns",
"to",
"a",
"gtk",
".",
"TreeView",
"for",
"the",
"types",
"listed",
"in",
"df_py_dtypes",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/objectlist/__init__.py#L90-L128 |
52,193 | decryptus/sonicprobe | sonicprobe/libs/daemonize.py | daemonize | def daemonize():
"""
Daemonize the program, ie. make it run in the "background", detach
it from its controlling terminal and from its controlling process
group session.
NOTES:
- This function also umask(0) and chdir("/")
- stdin, stdout, and stderr are redirected from/to /dev/null
... | python | def daemonize():
"""
Daemonize the program, ie. make it run in the "background", detach
it from its controlling terminal and from its controlling process
group session.
NOTES:
- This function also umask(0) and chdir("/")
- stdin, stdout, and stderr are redirected from/to /dev/null
... | [
"def",
"daemonize",
"(",
")",
":",
"try",
":",
"pid",
"=",
"os",
".",
"fork",
"(",
")",
"if",
"pid",
">",
"0",
":",
"os",
".",
"_exit",
"(",
"0",
")",
"# pylint: disable-msg=W0212",
"except",
"OSError",
",",
"e",
":",
"log",
".",
"exception",
"(",
... | Daemonize the program, ie. make it run in the "background", detach
it from its controlling terminal and from its controlling process
group session.
NOTES:
- This function also umask(0) and chdir("/")
- stdin, stdout, and stderr are redirected from/to /dev/null
SEE ALSO:
http://... | [
"Daemonize",
"the",
"program",
"ie",
".",
"make",
"it",
"run",
"in",
"the",
"background",
"detach",
"it",
"from",
"its",
"controlling",
"terminal",
"and",
"from",
"its",
"controlling",
"process",
"group",
"session",
"."
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/libs/daemonize.py#L186-L234 |
52,194 | AngryDevelopersLLC/res-core | res/core/logger.py | Logger.redirect_stream | def redirect_stream(system_stream, target_stream):
""" Redirect a system stream to a specified file.
`system_stream` is a standard system stream such as
``sys.stdout``. `target_stream` is an open file object that
should replace the corresponding system stream object.
... | python | def redirect_stream(system_stream, target_stream):
""" Redirect a system stream to a specified file.
`system_stream` is a standard system stream such as
``sys.stdout``. `target_stream` is an open file object that
should replace the corresponding system stream object.
... | [
"def",
"redirect_stream",
"(",
"system_stream",
",",
"target_stream",
")",
":",
"if",
"target_stream",
"is",
"None",
":",
"target_fd",
"=",
"os",
".",
"open",
"(",
"os",
".",
"devnull",
",",
"os",
".",
"O_RDWR",
")",
"else",
":",
"target_fd",
"=",
"targe... | Redirect a system stream to a specified file.
`system_stream` is a standard system stream such as
``sys.stdout``. `target_stream` is an open file object that
should replace the corresponding system stream object.
If `target_stream` is ``None``, defaults to opening the
... | [
"Redirect",
"a",
"system",
"stream",
"to",
"a",
"specified",
"file",
".",
"system_stream",
"is",
"a",
"standard",
"system",
"stream",
"such",
"as",
"sys",
".",
"stdout",
".",
"target_stream",
"is",
"an",
"open",
"file",
"object",
"that",
"should",
"replace",... | dabe8dda77a1cb7fc9ad121171b38da80ba0a458 | https://github.com/AngryDevelopersLLC/res-core/blob/dabe8dda77a1cb7fc9ad121171b38da80ba0a458/res/core/logger.py#L131-L143 |
52,195 | AngryDevelopersLLC/res-core | res/core/logger.py | Logger.ensure_utf8_streams | def ensure_utf8_streams():
"""Forces UTF-8 on stdout and stderr; in some crazy environments,
they use 'ascii' encoding by default
"""
def ensure_utf8_stream(stream):
if not isinstance(stream, io.StringIO):
stream = getwriter("utf-8")(getattr(stream, "buffer",... | python | def ensure_utf8_streams():
"""Forces UTF-8 on stdout and stderr; in some crazy environments,
they use 'ascii' encoding by default
"""
def ensure_utf8_stream(stream):
if not isinstance(stream, io.StringIO):
stream = getwriter("utf-8")(getattr(stream, "buffer",... | [
"def",
"ensure_utf8_streams",
"(",
")",
":",
"def",
"ensure_utf8_stream",
"(",
"stream",
")",
":",
"if",
"not",
"isinstance",
"(",
"stream",
",",
"io",
".",
"StringIO",
")",
":",
"stream",
"=",
"getwriter",
"(",
"\"utf-8\"",
")",
"(",
"getattr",
"(",
"st... | Forces UTF-8 on stdout and stderr; in some crazy environments,
they use 'ascii' encoding by default | [
"Forces",
"UTF",
"-",
"8",
"on",
"stdout",
"and",
"stderr",
";",
"in",
"some",
"crazy",
"environments",
"they",
"use",
"ascii",
"encoding",
"by",
"default"
] | dabe8dda77a1cb7fc9ad121171b38da80ba0a458 | https://github.com/AngryDevelopersLLC/res-core/blob/dabe8dda77a1cb7fc9ad121171b38da80ba0a458/res/core/logger.py#L146-L158 |
52,196 | deeshugupta/tes | es_commands/tes.py | configure | def configure(name, host, port, auth, current):
'''
Configure is used to add various ES ports you are working on.
The user can add as many es ports as the one wants,
but one will remain active at one point.
'''
Config = ConfigParser.ConfigParser()
if not os.path.exists(os.path.dirname(filena... | python | def configure(name, host, port, auth, current):
'''
Configure is used to add various ES ports you are working on.
The user can add as many es ports as the one wants,
but one will remain active at one point.
'''
Config = ConfigParser.ConfigParser()
if not os.path.exists(os.path.dirname(filena... | [
"def",
"configure",
"(",
"name",
",",
"host",
",",
"port",
",",
"auth",
",",
"current",
")",
":",
"Config",
"=",
"ConfigParser",
".",
"ConfigParser",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"dirname",
"... | Configure is used to add various ES ports you are working on.
The user can add as many es ports as the one wants,
but one will remain active at one point. | [
"Configure",
"is",
"used",
"to",
"add",
"various",
"ES",
"ports",
"you",
"are",
"working",
"on",
".",
"The",
"user",
"can",
"add",
"as",
"many",
"es",
"ports",
"as",
"the",
"one",
"wants",
"but",
"one",
"will",
"remain",
"active",
"at",
"one",
"point",... | 217db49aa211ebca2d9258380765a0c31abfca91 | https://github.com/deeshugupta/tes/blob/217db49aa211ebca2d9258380765a0c31abfca91/es_commands/tes.py#L32-L58 |
52,197 | AbletonAG/abl.vpath | abl/vpath/base/zip.py | compare_parts | def compare_parts(list1, list2):
"""
if list2 does not start with list1, we can't really check and return 0
"""
for i, item in enumerate(list1):
if item != list2[i]:
return 0
if len(list2) > len(list1):
return ISDIR
else:
return ISFILE | python | def compare_parts(list1, list2):
"""
if list2 does not start with list1, we can't really check and return 0
"""
for i, item in enumerate(list1):
if item != list2[i]:
return 0
if len(list2) > len(list1):
return ISDIR
else:
return ISFILE | [
"def",
"compare_parts",
"(",
"list1",
",",
"list2",
")",
":",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"list1",
")",
":",
"if",
"item",
"!=",
"list2",
"[",
"i",
"]",
":",
"return",
"0",
"if",
"len",
"(",
"list2",
")",
">",
"len",
"(",
"... | if list2 does not start with list1, we can't really check and return 0 | [
"if",
"list2",
"does",
"not",
"start",
"with",
"list1",
"we",
"can",
"t",
"really",
"check",
"and",
"return",
"0"
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/zip.py#L78-L89 |
52,198 | arindampradhan/yaaHN | yaaHN/thread_request.py | fetch_event | def fetch_event(urls):
"""
This parallel fetcher uses gevent one uses gevent
"""
rs = (grequests.get(u) for u in urls)
return [content.json() for content in grequests.map(rs)] | python | def fetch_event(urls):
"""
This parallel fetcher uses gevent one uses gevent
"""
rs = (grequests.get(u) for u in urls)
return [content.json() for content in grequests.map(rs)] | [
"def",
"fetch_event",
"(",
"urls",
")",
":",
"rs",
"=",
"(",
"grequests",
".",
"get",
"(",
"u",
")",
"for",
"u",
"in",
"urls",
")",
"return",
"[",
"content",
".",
"json",
"(",
")",
"for",
"content",
"in",
"grequests",
".",
"map",
"(",
"rs",
")",
... | This parallel fetcher uses gevent one uses gevent | [
"This",
"parallel",
"fetcher",
"uses",
"gevent",
"one",
"uses",
"gevent"
] | 680e9fed49ef6b325ed7ca1b325aaae12290f314 | https://github.com/arindampradhan/yaaHN/blob/680e9fed49ef6b325ed7ca1b325aaae12290f314/yaaHN/thread_request.py#L12-L17 |
52,199 | lvh/txeasymail | txeasymail/mailer.py | sendTemplate | def sendTemplate(mailer, sender, recipient, template, context, hook=_nop):
"""
Simple case for sending some e-mail using a template.
"""
headers, parts = template.evaluate(context)
headers["From"] = sender
headers["To"] = recipient
hook(headers, parts)
content = mime.buildMessage(header... | python | def sendTemplate(mailer, sender, recipient, template, context, hook=_nop):
"""
Simple case for sending some e-mail using a template.
"""
headers, parts = template.evaluate(context)
headers["From"] = sender
headers["To"] = recipient
hook(headers, parts)
content = mime.buildMessage(header... | [
"def",
"sendTemplate",
"(",
"mailer",
",",
"sender",
",",
"recipient",
",",
"template",
",",
"context",
",",
"hook",
"=",
"_nop",
")",
":",
"headers",
",",
"parts",
"=",
"template",
".",
"evaluate",
"(",
"context",
")",
"headers",
"[",
"\"From\"",
"]",
... | Simple case for sending some e-mail using a template. | [
"Simple",
"case",
"for",
"sending",
"some",
"e",
"-",
"mail",
"using",
"a",
"template",
"."
] | 7b845a5238b1371824854468646d54653a426f09 | https://github.com/lvh/txeasymail/blob/7b845a5238b1371824854468646d54653a426f09/txeasymail/mailer.py#L41-L51 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.