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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
45,700 | theolind/pymysensors | mysensors/__init__.py | BaseTransportGateway.send | def send(self, message):
"""Write a message to the gateway."""
if not message or not self.protocol or not self.protocol.transport:
return
if not self.can_log:
_LOGGER.debug('Sending %s', message.strip())
try:
self.protocol.transport.write(message.encod... | python | def send(self, message):
"""Write a message to the gateway."""
if not message or not self.protocol or not self.protocol.transport:
return
if not self.can_log:
_LOGGER.debug('Sending %s', message.strip())
try:
self.protocol.transport.write(message.encod... | [
"def",
"send",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"message",
"or",
"not",
"self",
".",
"protocol",
"or",
"not",
"self",
".",
"protocol",
".",
"transport",
":",
"return",
"if",
"not",
"self",
".",
"can_log",
":",
"_LOGGER",
".",
"debu... | Write a message to the gateway. | [
"Write",
"a",
"message",
"to",
"the",
"gateway",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L303-L316 |
45,701 | theolind/pymysensors | mysensors/__init__.py | BaseAsyncGateway.stop | def stop(self):
"""Stop the gateway."""
_LOGGER.info('Stopping gateway')
self._disconnect()
if self.connect_task and not self.connect_task.cancelled():
self.connect_task.cancel()
self.connect_task = None
if not self.persistence:
return
... | python | def stop(self):
"""Stop the gateway."""
_LOGGER.info('Stopping gateway')
self._disconnect()
if self.connect_task and not self.connect_task.cancelled():
self.connect_task.cancel()
self.connect_task = None
if not self.persistence:
return
... | [
"def",
"stop",
"(",
"self",
")",
":",
"_LOGGER",
".",
"info",
"(",
"'Stopping gateway'",
")",
"self",
".",
"_disconnect",
"(",
")",
"if",
"self",
".",
"connect_task",
"and",
"not",
"self",
".",
"connect_task",
".",
"cancelled",
"(",
")",
":",
"self",
"... | Stop the gateway. | [
"Stop",
"the",
"gateway",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L350-L363 |
45,702 | theolind/pymysensors | mysensors/__init__.py | BaseAsyncGateway.add_job | def add_job(self, func, *args):
"""Add a job that should return a reply to be sent.
A job is a tuple of function and optional args. Keyword arguments
can be passed via use of functools.partial. The job should return a
string that should be sent by the gateway protocol.
The asyn... | python | def add_job(self, func, *args):
"""Add a job that should return a reply to be sent.
A job is a tuple of function and optional args. Keyword arguments
can be passed via use of functools.partial. The job should return a
string that should be sent by the gateway protocol.
The asyn... | [
"def",
"add_job",
"(",
"self",
",",
"func",
",",
"*",
"args",
")",
":",
"job",
"=",
"func",
",",
"args",
"reply",
"=",
"self",
".",
"run_job",
"(",
"job",
")",
"self",
".",
"send",
"(",
"reply",
")"
] | Add a job that should return a reply to be sent.
A job is a tuple of function and optional args. Keyword arguments
can be passed via use of functools.partial. The job should return a
string that should be sent by the gateway protocol.
The async version of this method will send the repl... | [
"Add",
"a",
"job",
"that",
"should",
"return",
"a",
"reply",
"to",
"be",
"sent",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L365-L376 |
45,703 | theolind/pymysensors | mysensors/__init__.py | BaseMySensorsProtocol.connection_made | def connection_made(self, transport):
"""Handle created connection."""
super().connection_made(transport)
if hasattr(self.transport, 'serial'):
_LOGGER.info('Connected to %s', self.transport.serial)
else:
_LOGGER.info('Connected to %s', self.transport) | python | def connection_made(self, transport):
"""Handle created connection."""
super().connection_made(transport)
if hasattr(self.transport, 'serial'):
_LOGGER.info('Connected to %s', self.transport.serial)
else:
_LOGGER.info('Connected to %s', self.transport) | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"super",
"(",
")",
".",
"connection_made",
"(",
"transport",
")",
"if",
"hasattr",
"(",
"self",
".",
"transport",
",",
"'serial'",
")",
":",
"_LOGGER",
".",
"info",
"(",
"'Connected to %s'"... | Handle created connection. | [
"Handle",
"created",
"connection",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L425-L431 |
45,704 | theolind/pymysensors | mysensors/__init__.py | BaseMySensorsProtocol.handle_line | def handle_line(self, line):
"""Handle incoming string data one line at a time."""
if not self.gateway.can_log:
_LOGGER.debug('Receiving %s', line)
self.gateway.add_job(self.gateway.logic, line) | python | def handle_line(self, line):
"""Handle incoming string data one line at a time."""
if not self.gateway.can_log:
_LOGGER.debug('Receiving %s', line)
self.gateway.add_job(self.gateway.logic, line) | [
"def",
"handle_line",
"(",
"self",
",",
"line",
")",
":",
"if",
"not",
"self",
".",
"gateway",
".",
"can_log",
":",
"_LOGGER",
".",
"debug",
"(",
"'Receiving %s'",
",",
"line",
")",
"self",
".",
"gateway",
".",
"add_job",
"(",
"self",
".",
"gateway",
... | Handle incoming string data one line at a time. | [
"Handle",
"incoming",
"string",
"data",
"one",
"line",
"at",
"a",
"time",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L433-L437 |
45,705 | theolind/pymysensors | mysensors/sensor.py | Sensor.add_child_sensor | def add_child_sensor(self, child_id, child_type, description=''):
"""Create and add a child sensor."""
if child_id in self.children:
_LOGGER.warning(
'child_id %s already exists in children of node %s, '
'cannot add child', child_id, self.sensor_id)
... | python | def add_child_sensor(self, child_id, child_type, description=''):
"""Create and add a child sensor."""
if child_id in self.children:
_LOGGER.warning(
'child_id %s already exists in children of node %s, '
'cannot add child', child_id, self.sensor_id)
... | [
"def",
"add_child_sensor",
"(",
"self",
",",
"child_id",
",",
"child_type",
",",
"description",
"=",
"''",
")",
":",
"if",
"child_id",
"in",
"self",
".",
"children",
":",
"_LOGGER",
".",
"warning",
"(",
"'child_id %s already exists in children of node %s, '",
"'ca... | Create and add a child sensor. | [
"Create",
"and",
"add",
"a",
"child",
"sensor",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/sensor.py#L93-L102 |
45,706 | theolind/pymysensors | mysensors/sensor.py | Sensor.set_child_value | def set_child_value(self, child_id, value_type, value, **kwargs):
"""Set a child sensor's value."""
children = kwargs.get('children', self.children)
if not isinstance(children, dict) or child_id not in children:
return None
msg_type = kwargs.get('msg_type', 1)
ack = k... | python | def set_child_value(self, child_id, value_type, value, **kwargs):
"""Set a child sensor's value."""
children = kwargs.get('children', self.children)
if not isinstance(children, dict) or child_id not in children:
return None
msg_type = kwargs.get('msg_type', 1)
ack = k... | [
"def",
"set_child_value",
"(",
"self",
",",
"child_id",
",",
"value_type",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"children",
"=",
"kwargs",
".",
"get",
"(",
"'children'",
",",
"self",
".",
"children",
")",
"if",
"not",
"isinstance",
"(",
"ch... | Set a child sensor's value. | [
"Set",
"a",
"child",
"sensor",
"s",
"value",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/sensor.py#L104-L129 |
45,707 | theolind/pymysensors | mysensors/sensor.py | ChildSensor.get_schema | def get_schema(self, protocol_version):
"""Return the child schema for the correct const version."""
const = get_const(protocol_version)
custom_schema = vol.Schema({
typ.value: const.VALID_SETREQ[typ]
for typ in const.VALID_TYPES[const.Presentation.S_CUSTOM]})
ret... | python | def get_schema(self, protocol_version):
"""Return the child schema for the correct const version."""
const = get_const(protocol_version)
custom_schema = vol.Schema({
typ.value: const.VALID_SETREQ[typ]
for typ in const.VALID_TYPES[const.Presentation.S_CUSTOM]})
ret... | [
"def",
"get_schema",
"(",
"self",
",",
"protocol_version",
")",
":",
"const",
"=",
"get_const",
"(",
"protocol_version",
")",
"custom_schema",
"=",
"vol",
".",
"Schema",
"(",
"{",
"typ",
".",
"value",
":",
"const",
".",
"VALID_SETREQ",
"[",
"typ",
"]",
"... | Return the child schema for the correct const version. | [
"Return",
"the",
"child",
"schema",
"for",
"the",
"correct",
"const",
"version",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/sensor.py#L157-L165 |
45,708 | theolind/pymysensors | mysensors/sensor.py | ChildSensor.validate | def validate(self, protocol_version, values=None):
"""Validate child value types and values against protocol_version."""
if values is None:
values = self.values
return self.get_schema(protocol_version)(values) | python | def validate(self, protocol_version, values=None):
"""Validate child value types and values against protocol_version."""
if values is None:
values = self.values
return self.get_schema(protocol_version)(values) | [
"def",
"validate",
"(",
"self",
",",
"protocol_version",
",",
"values",
"=",
"None",
")",
":",
"if",
"values",
"is",
"None",
":",
"values",
"=",
"self",
".",
"values",
"return",
"self",
".",
"get_schema",
"(",
"protocol_version",
")",
"(",
"values",
")"
... | Validate child value types and values against protocol_version. | [
"Validate",
"child",
"value",
"types",
"and",
"values",
"against",
"protocol_version",
"."
] | a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6 | https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/sensor.py#L167-L171 |
45,709 | happyleavesaoc/python-myusps | myusps/__init__.py | _get_shipped_from | def _get_shipped_from(row):
"""Get where package was shipped from."""
try:
spans = row.find('div', {'id': 'coltextR2'}).find_all('span')
if len(spans) < 2:
return None
return spans[1].string
except AttributeError:
return None | python | def _get_shipped_from(row):
"""Get where package was shipped from."""
try:
spans = row.find('div', {'id': 'coltextR2'}).find_all('span')
if len(spans) < 2:
return None
return spans[1].string
except AttributeError:
return None | [
"def",
"_get_shipped_from",
"(",
"row",
")",
":",
"try",
":",
"spans",
"=",
"row",
".",
"find",
"(",
"'div'",
",",
"{",
"'id'",
":",
"'coltextR2'",
"}",
")",
".",
"find_all",
"(",
"'span'",
")",
"if",
"len",
"(",
"spans",
")",
"<",
"2",
":",
"ret... | Get where package was shipped from. | [
"Get",
"where",
"package",
"was",
"shipped",
"from",
"."
] | 827e74f25d1c1ef0149bb7fda7c606297b743c02 | https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L78-L86 |
45,710 | happyleavesaoc/python-myusps | myusps/__init__.py | _get_status_timestamp | def _get_status_timestamp(row):
"""Get latest package timestamp."""
try:
divs = row.find('div', {'id': 'coltextR3'}).find_all('div')
if len(divs) < 2:
return None
timestamp_string = divs[1].string
except AttributeError:
return None
try:
return parse(ti... | python | def _get_status_timestamp(row):
"""Get latest package timestamp."""
try:
divs = row.find('div', {'id': 'coltextR3'}).find_all('div')
if len(divs) < 2:
return None
timestamp_string = divs[1].string
except AttributeError:
return None
try:
return parse(ti... | [
"def",
"_get_status_timestamp",
"(",
"row",
")",
":",
"try",
":",
"divs",
"=",
"row",
".",
"find",
"(",
"'div'",
",",
"{",
"'id'",
":",
"'coltextR3'",
"}",
")",
".",
"find_all",
"(",
"'div'",
")",
"if",
"len",
"(",
"divs",
")",
"<",
"2",
":",
"re... | Get latest package timestamp. | [
"Get",
"latest",
"package",
"timestamp",
"."
] | 827e74f25d1c1ef0149bb7fda7c606297b743c02 | https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L89-L101 |
45,711 | happyleavesaoc/python-myusps | myusps/__init__.py | _get_driver | def _get_driver(driver_type):
"""Get webdriver."""
if driver_type == 'phantomjs':
return webdriver.PhantomJS(service_log_path=os.path.devnull)
if driver_type == 'firefox':
return webdriver.Firefox(firefox_options=FIREFOXOPTIONS)
elif driver_type == 'chrome':
chrome_options = webd... | python | def _get_driver(driver_type):
"""Get webdriver."""
if driver_type == 'phantomjs':
return webdriver.PhantomJS(service_log_path=os.path.devnull)
if driver_type == 'firefox':
return webdriver.Firefox(firefox_options=FIREFOXOPTIONS)
elif driver_type == 'chrome':
chrome_options = webd... | [
"def",
"_get_driver",
"(",
"driver_type",
")",
":",
"if",
"driver_type",
"==",
"'phantomjs'",
":",
"return",
"webdriver",
".",
"PhantomJS",
"(",
"service_log_path",
"=",
"os",
".",
"path",
".",
"devnull",
")",
"if",
"driver_type",
"==",
"'firefox'",
":",
"re... | Get webdriver. | [
"Get",
"webdriver",
"."
] | 827e74f25d1c1ef0149bb7fda7c606297b743c02 | https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L144-L156 |
45,712 | happyleavesaoc/python-myusps | myusps/__init__.py | get_profile | def get_profile(session):
"""Get profile data."""
response = session.get(PROFILE_URL, allow_redirects=False)
if response.status_code == 302:
raise USPSError('expired session')
parsed = BeautifulSoup(response.text, HTML_PARSER)
profile = parsed.find('div', {'class': 'atg_store_myProfileInfo'}... | python | def get_profile(session):
"""Get profile data."""
response = session.get(PROFILE_URL, allow_redirects=False)
if response.status_code == 302:
raise USPSError('expired session')
parsed = BeautifulSoup(response.text, HTML_PARSER)
profile = parsed.find('div', {'class': 'atg_store_myProfileInfo'}... | [
"def",
"get_profile",
"(",
"session",
")",
":",
"response",
"=",
"session",
".",
"get",
"(",
"PROFILE_URL",
",",
"allow_redirects",
"=",
"False",
")",
"if",
"response",
".",
"status_code",
"==",
"302",
":",
"raise",
"USPSError",
"(",
"'expired session'",
")"... | Get profile data. | [
"Get",
"profile",
"data",
"."
] | 827e74f25d1c1ef0149bb7fda7c606297b743c02 | https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L221-L235 |
45,713 | happyleavesaoc/python-myusps | myusps/__init__.py | get_packages | def get_packages(session):
"""Get package data."""
_LOGGER.info("attempting to get package data")
response = _get_dashboard(session)
parsed = BeautifulSoup(response.text, HTML_PARSER)
packages = []
for row in parsed.find_all('div', {'class': 'pack_row'}):
packages.append({
't... | python | def get_packages(session):
"""Get package data."""
_LOGGER.info("attempting to get package data")
response = _get_dashboard(session)
parsed = BeautifulSoup(response.text, HTML_PARSER)
packages = []
for row in parsed.find_all('div', {'class': 'pack_row'}):
packages.append({
't... | [
"def",
"get_packages",
"(",
"session",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"attempting to get package data\"",
")",
"response",
"=",
"_get_dashboard",
"(",
"session",
")",
"parsed",
"=",
"BeautifulSoup",
"(",
"response",
".",
"text",
",",
"HTML_PARSER",
")"... | Get package data. | [
"Get",
"package",
"data",
"."
] | 827e74f25d1c1ef0149bb7fda7c606297b743c02 | https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L239-L254 |
45,714 | happyleavesaoc/python-myusps | myusps/__init__.py | get_mail | def get_mail(session, date=None):
"""Get mail data."""
_LOGGER.info("attempting to get mail data")
if not date:
date = datetime.datetime.now().date()
response = _get_dashboard(session, date)
parsed = BeautifulSoup(response.text, HTML_PARSER)
mail = []
for row in parsed.find_all('div'... | python | def get_mail(session, date=None):
"""Get mail data."""
_LOGGER.info("attempting to get mail data")
if not date:
date = datetime.datetime.now().date()
response = _get_dashboard(session, date)
parsed = BeautifulSoup(response.text, HTML_PARSER)
mail = []
for row in parsed.find_all('div'... | [
"def",
"get_mail",
"(",
"session",
",",
"date",
"=",
"None",
")",
":",
"_LOGGER",
".",
"info",
"(",
"\"attempting to get mail data\"",
")",
"if",
"not",
"date",
":",
"date",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"date",
"(",
")",... | Get mail data. | [
"Get",
"mail",
"data",
"."
] | 827e74f25d1c1ef0149bb7fda7c606297b743c02 | https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L258-L275 |
45,715 | happyleavesaoc/python-myusps | myusps/__init__.py | get_session | def get_session(username, password, cookie_path=COOKIE_PATH, cache=True,
cache_expiry=300, cache_path=CACHE_PATH, driver='phantomjs'):
"""Get session, existing or new."""
class USPSAuth(AuthBase): # pylint: disable=too-few-public-methods
"""USPS authorization storage."""
def __... | python | def get_session(username, password, cookie_path=COOKIE_PATH, cache=True,
cache_expiry=300, cache_path=CACHE_PATH, driver='phantomjs'):
"""Get session, existing or new."""
class USPSAuth(AuthBase): # pylint: disable=too-few-public-methods
"""USPS authorization storage."""
def __... | [
"def",
"get_session",
"(",
"username",
",",
"password",
",",
"cookie_path",
"=",
"COOKIE_PATH",
",",
"cache",
"=",
"True",
",",
"cache_expiry",
"=",
"300",
",",
"cache_path",
"=",
"CACHE_PATH",
",",
"driver",
"=",
"'phantomjs'",
")",
":",
"class",
"USPSAuth"... | Get session, existing or new. | [
"Get",
"session",
"existing",
"or",
"new",
"."
] | 827e74f25d1c1ef0149bb7fda7c606297b743c02 | https://github.com/happyleavesaoc/python-myusps/blob/827e74f25d1c1ef0149bb7fda7c606297b743c02/myusps/__init__.py#L278-L306 |
45,716 | jbremer/rc4 | rc4/__init__.py | rc4 | def rc4(data, key):
"""RC4 encryption and decryption method."""
S, j, out = list(range(256)), 0, []
for i in range(256):
j = (j + S[i] + ord(key[i % len(key)])) % 256
S[i], S[j] = S[j], S[i]
i = j = 0
for ch in data:
i = (i + 1) % 256
j = (j + S[i]) % 256
S[... | python | def rc4(data, key):
"""RC4 encryption and decryption method."""
S, j, out = list(range(256)), 0, []
for i in range(256):
j = (j + S[i] + ord(key[i % len(key)])) % 256
S[i], S[j] = S[j], S[i]
i = j = 0
for ch in data:
i = (i + 1) % 256
j = (j + S[i]) % 256
S[... | [
"def",
"rc4",
"(",
"data",
",",
"key",
")",
":",
"S",
",",
"j",
",",
"out",
"=",
"list",
"(",
"range",
"(",
"256",
")",
")",
",",
"0",
",",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"256",
")",
":",
"j",
"=",
"(",
"j",
"+",
"S",
"[",
... | RC4 encryption and decryption method. | [
"RC4",
"encryption",
"and",
"decryption",
"method",
"."
] | 49d6e916c96dcf990b5873c8389248436d443c13 | https://github.com/jbremer/rc4/blob/49d6e916c96dcf990b5873c8389248436d443c13/rc4/__init__.py#L4-L19 |
45,717 | vinta/django-email-confirm-la | email_confirm_la/models.py | EmailConfirmationManager.verify_email_for_object | def verify_email_for_object(self, email, content_object, email_field_name='email'):
"""
Create an email confirmation for `content_object` and send a confirmation mail.
The email will be directly saved to `content_object.email_field_name` when `is_primary` and `skip_verify` both are true.
... | python | def verify_email_for_object(self, email, content_object, email_field_name='email'):
"""
Create an email confirmation for `content_object` and send a confirmation mail.
The email will be directly saved to `content_object.email_field_name` when `is_primary` and `skip_verify` both are true.
... | [
"def",
"verify_email_for_object",
"(",
"self",
",",
"email",
",",
"content_object",
",",
"email_field_name",
"=",
"'email'",
")",
":",
"confirmation_key",
"=",
"generate_random_token",
"(",
")",
"try",
":",
"confirmation",
"=",
"EmailConfirmation",
"(",
")",
"conf... | Create an email confirmation for `content_object` and send a confirmation mail.
The email will be directly saved to `content_object.email_field_name` when `is_primary` and `skip_verify` both are true. | [
"Create",
"an",
"email",
"confirmation",
"for",
"content_object",
"and",
"send",
"a",
"confirmation",
"mail",
"."
] | 7f6ed29f29325f91929c14b4e468a23be53354bb | https://github.com/vinta/django-email-confirm-la/blob/7f6ed29f29325f91929c14b4e468a23be53354bb/email_confirm_la/models.py#L24-L48 |
45,718 | vinta/django-email-confirm-la | email_confirm_la/models.py | EmailConfirmation.clean | def clean(self):
"""
delete all confirmations for the same content_object and the same field
"""
EmailConfirmation.objects.filter(content_type=self.content_type, object_id=self.object_id, email_field_name=self.email_field_name).delete() | python | def clean(self):
"""
delete all confirmations for the same content_object and the same field
"""
EmailConfirmation.objects.filter(content_type=self.content_type, object_id=self.object_id, email_field_name=self.email_field_name).delete() | [
"def",
"clean",
"(",
"self",
")",
":",
"EmailConfirmation",
".",
"objects",
".",
"filter",
"(",
"content_type",
"=",
"self",
".",
"content_type",
",",
"object_id",
"=",
"self",
".",
"object_id",
",",
"email_field_name",
"=",
"self",
".",
"email_field_name",
... | delete all confirmations for the same content_object and the same field | [
"delete",
"all",
"confirmations",
"for",
"the",
"same",
"content_object",
"and",
"the",
"same",
"field"
] | 7f6ed29f29325f91929c14b4e468a23be53354bb | https://github.com/vinta/django-email-confirm-la/blob/7f6ed29f29325f91929c14b4e468a23be53354bb/email_confirm_la/models.py#L161-L166 |
45,719 | aisayko/Django-tinymce-filebrowser | mce_filebrowser/utils.py | render_paginate | def render_paginate(request, template, objects, per_page, extra_context={}):
"""
Paginated list of objects.
"""
paginator = Paginator(objects, per_page)
page = request.GET.get('page', 1)
get_params = '&'.join(['%s=%s' % (k, request.GET[k])
for k in request.GET if k != ... | python | def render_paginate(request, template, objects, per_page, extra_context={}):
"""
Paginated list of objects.
"""
paginator = Paginator(objects, per_page)
page = request.GET.get('page', 1)
get_params = '&'.join(['%s=%s' % (k, request.GET[k])
for k in request.GET if k != ... | [
"def",
"render_paginate",
"(",
"request",
",",
"template",
",",
"objects",
",",
"per_page",
",",
"extra_context",
"=",
"{",
"}",
")",
":",
"paginator",
"=",
"Paginator",
"(",
"objects",
",",
"per_page",
")",
"page",
"=",
"request",
".",
"GET",
".",
"get"... | Paginated list of objects. | [
"Paginated",
"list",
"of",
"objects",
"."
] | f34c9e8f8c5e32c1d1221270314f31ee07f24409 | https://github.com/aisayko/Django-tinymce-filebrowser/blob/f34c9e8f8c5e32c1d1221270314f31ee07f24409/mce_filebrowser/utils.py#L9-L41 |
45,720 | jbasko/configmanager | configmanager/changesets.py | _ChangesetContext.values | def values(self):
"""
Returns a mapping of items to their new values. The mapping includes only items whose value or raw string value
has changed in the context.
"""
report = {}
for k, k_changes in self._changes.items():
if len(k_changes) == 1:
... | python | def values(self):
"""
Returns a mapping of items to their new values. The mapping includes only items whose value or raw string value
has changed in the context.
"""
report = {}
for k, k_changes in self._changes.items():
if len(k_changes) == 1:
... | [
"def",
"values",
"(",
"self",
")",
":",
"report",
"=",
"{",
"}",
"for",
"k",
",",
"k_changes",
"in",
"self",
".",
"_changes",
".",
"items",
"(",
")",
":",
"if",
"len",
"(",
"k_changes",
")",
"==",
"1",
":",
"report",
"[",
"k",
"]",
"=",
"k_chan... | Returns a mapping of items to their new values. The mapping includes only items whose value or raw string value
has changed in the context. | [
"Returns",
"a",
"mapping",
"of",
"items",
"to",
"their",
"new",
"values",
".",
"The",
"mapping",
"includes",
"only",
"items",
"whose",
"value",
"or",
"raw",
"string",
"value",
"has",
"changed",
"in",
"the",
"context",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/changesets.py#L41-L52 |
45,721 | jbasko/configmanager | configmanager/changesets.py | _ChangesetContext.changes | def changes(self):
"""
Returns a mapping of items to their effective change objects which include the old values
and the new. The mapping includes only items whose value or raw string value has changed in the context.
"""
report = {}
for k, k_changes in self._changes.item... | python | def changes(self):
"""
Returns a mapping of items to their effective change objects which include the old values
and the new. The mapping includes only items whose value or raw string value has changed in the context.
"""
report = {}
for k, k_changes in self._changes.item... | [
"def",
"changes",
"(",
"self",
")",
":",
"report",
"=",
"{",
"}",
"for",
"k",
",",
"k_changes",
"in",
"self",
".",
"_changes",
".",
"items",
"(",
")",
":",
"if",
"len",
"(",
"k_changes",
")",
"==",
"1",
":",
"report",
"[",
"k",
"]",
"=",
"k_cha... | Returns a mapping of items to their effective change objects which include the old values
and the new. The mapping includes only items whose value or raw string value has changed in the context. | [
"Returns",
"a",
"mapping",
"of",
"items",
"to",
"their",
"effective",
"change",
"objects",
"which",
"include",
"the",
"old",
"values",
"and",
"the",
"new",
".",
"The",
"mapping",
"includes",
"only",
"items",
"whose",
"value",
"or",
"raw",
"string",
"value",
... | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/changesets.py#L55-L74 |
45,722 | jbasko/configmanager | configmanager/persistence.py | ConfigPersistenceAdapter.load | def load(self, source, as_defaults=False):
"""
Load configuration values from the specified source.
Args:
source:
as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items.
"""
if isinstance(source, six.stri... | python | def load(self, source, as_defaults=False):
"""
Load configuration values from the specified source.
Args:
source:
as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items.
"""
if isinstance(source, six.stri... | [
"def",
"load",
"(",
"self",
",",
"source",
",",
"as_defaults",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"source",
",",
"six",
".",
"string_types",
")",
":",
"source",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"source",
")",
"with",
"ope... | Load configuration values from the specified source.
Args:
source:
as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items. | [
"Load",
"configuration",
"values",
"from",
"the",
"specified",
"source",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/persistence.py#L35-L55 |
45,723 | jbasko/configmanager | configmanager/persistence.py | ConfigPersistenceAdapter.loads | def loads(self, config_str, as_defaults=False):
"""
Load configuration values from the specified source string.
Args:
config_str:
as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items.
"""
self._rw.load_... | python | def loads(self, config_str, as_defaults=False):
"""
Load configuration values from the specified source string.
Args:
config_str:
as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items.
"""
self._rw.load_... | [
"def",
"loads",
"(",
"self",
",",
"config_str",
",",
"as_defaults",
"=",
"False",
")",
":",
"self",
".",
"_rw",
".",
"load_config_from_string",
"(",
"self",
".",
"_config",
",",
"config_str",
",",
"as_defaults",
"=",
"as_defaults",
")"
] | Load configuration values from the specified source string.
Args:
config_str:
as_defaults (bool): if ``True``, contents of ``source`` will be treated as schema of configuration items. | [
"Load",
"configuration",
"values",
"from",
"the",
"specified",
"source",
"string",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/persistence.py#L57-L66 |
45,724 | jbasko/configmanager | configmanager/persistence.py | ConfigPersistenceAdapter.dump | def dump(self, destination, with_defaults=False):
"""
Write configuration values to the specified destination.
Args:
destination:
with_defaults (bool): if ``True``, values of items with no custom values will be included in the output
if they have a defaul... | python | def dump(self, destination, with_defaults=False):
"""
Write configuration values to the specified destination.
Args:
destination:
with_defaults (bool): if ``True``, values of items with no custom values will be included in the output
if they have a defaul... | [
"def",
"dump",
"(",
"self",
",",
"destination",
",",
"with_defaults",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"destination",
",",
"six",
".",
"string_types",
")",
":",
"with",
"open",
"(",
"destination",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8... | Write configuration values to the specified destination.
Args:
destination:
with_defaults (bool): if ``True``, values of items with no custom values will be included in the output
if they have a default value set. | [
"Write",
"configuration",
"values",
"to",
"the",
"specified",
"destination",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/persistence.py#L68-L81 |
45,725 | jbasko/configmanager | configmanager/persistence.py | ConfigPersistenceAdapter.dumps | def dumps(self, with_defaults=False):
"""
Generate a string representing all the configuration values.
Args:
with_defaults (bool): if ``True``, values of items with no custom values will be included in the output
if they have a default value set.
"""
... | python | def dumps(self, with_defaults=False):
"""
Generate a string representing all the configuration values.
Args:
with_defaults (bool): if ``True``, values of items with no custom values will be included in the output
if they have a default value set.
"""
... | [
"def",
"dumps",
"(",
"self",
",",
"with_defaults",
"=",
"False",
")",
":",
"return",
"self",
".",
"_rw",
".",
"dump_config_to_string",
"(",
"self",
".",
"_config",
",",
"with_defaults",
"=",
"with_defaults",
")"
] | Generate a string representing all the configuration values.
Args:
with_defaults (bool): if ``True``, values of items with no custom values will be included in the output
if they have a default value set. | [
"Generate",
"a",
"string",
"representing",
"all",
"the",
"configuration",
"values",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/persistence.py#L83-L91 |
45,726 | jbasko/configmanager | configmanager/sections.py | Section._default_key_setter | def _default_key_setter(self, name, subject):
"""
This method is used only when there is a custom key_setter set.
Do not override this method.
"""
if is_config_item(subject):
self.add_item(name, subject)
elif is_config_section(subject):
self.add_s... | python | def _default_key_setter(self, name, subject):
"""
This method is used only when there is a custom key_setter set.
Do not override this method.
"""
if is_config_item(subject):
self.add_item(name, subject)
elif is_config_section(subject):
self.add_s... | [
"def",
"_default_key_setter",
"(",
"self",
",",
"name",
",",
"subject",
")",
":",
"if",
"is_config_item",
"(",
"subject",
")",
":",
"self",
".",
"add_item",
"(",
"name",
",",
"subject",
")",
"elif",
"is_config_section",
"(",
"subject",
")",
":",
"self",
... | This method is used only when there is a custom key_setter set.
Do not override this method. | [
"This",
"method",
"is",
"used",
"only",
"when",
"there",
"is",
"a",
"custom",
"key_setter",
"set",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L127-L144 |
45,727 | jbasko/configmanager | configmanager/sections.py | Section.get_section | def get_section(self, *key):
"""
The recommended way of retrieving a section by key when extending configmanager's behaviour.
"""
section = self._get_item_or_section(key)
if not section.is_section:
raise RuntimeError('{} is an item, not a section'.format(key))
... | python | def get_section(self, *key):
"""
The recommended way of retrieving a section by key when extending configmanager's behaviour.
"""
section = self._get_item_or_section(key)
if not section.is_section:
raise RuntimeError('{} is an item, not a section'.format(key))
... | [
"def",
"get_section",
"(",
"self",
",",
"*",
"key",
")",
":",
"section",
"=",
"self",
".",
"_get_item_or_section",
"(",
"key",
")",
"if",
"not",
"section",
".",
"is_section",
":",
"raise",
"RuntimeError",
"(",
"'{} is an item, not a section'",
".",
"format",
... | The recommended way of retrieving a section by key when extending configmanager's behaviour. | [
"The",
"recommended",
"way",
"of",
"retrieving",
"a",
"section",
"by",
"key",
"when",
"extending",
"configmanager",
"s",
"behaviour",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L246-L253 |
45,728 | jbasko/configmanager | configmanager/sections.py | Section.add_item | def add_item(self, alias, item):
"""
Add a config item to this section.
"""
if not isinstance(alias, six.string_types):
raise TypeError('Item name must be a string, got a {!r}'.format(type(alias)))
item = copy.deepcopy(item)
if item.name is not_set:
... | python | def add_item(self, alias, item):
"""
Add a config item to this section.
"""
if not isinstance(alias, six.string_types):
raise TypeError('Item name must be a string, got a {!r}'.format(type(alias)))
item = copy.deepcopy(item)
if item.name is not_set:
... | [
"def",
"add_item",
"(",
"self",
",",
"alias",
",",
"item",
")",
":",
"if",
"not",
"isinstance",
"(",
"alias",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'Item name must be a string, got a {!r}'",
".",
"format",
"(",
"type",
"(",
... | Add a config item to this section. | [
"Add",
"a",
"config",
"item",
"to",
"this",
"section",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L289-L317 |
45,729 | jbasko/configmanager | configmanager/sections.py | Section.add_section | def add_section(self, alias, section):
"""
Add a sub-section to this section.
"""
if not isinstance(alias, six.string_types):
raise TypeError('Section name must be a string, got a {!r}'.format(type(alias)))
self._tree[alias] = section
if self.settings.str_pa... | python | def add_section(self, alias, section):
"""
Add a sub-section to this section.
"""
if not isinstance(alias, six.string_types):
raise TypeError('Section name must be a string, got a {!r}'.format(type(alias)))
self._tree[alias] = section
if self.settings.str_pa... | [
"def",
"add_section",
"(",
"self",
",",
"alias",
",",
"section",
")",
":",
"if",
"not",
"isinstance",
"(",
"alias",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'Section name must be a string, got a {!r}'",
".",
"format",
"(",
"type",... | Add a sub-section to this section. | [
"Add",
"a",
"sub",
"-",
"section",
"to",
"this",
"section",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L319-L337 |
45,730 | jbasko/configmanager | configmanager/sections.py | Section._get_recursive_iterator | def _get_recursive_iterator(self, recursive=False):
"""
Basic recursive iterator whose only purpose is to yield all items
and sections in order, with their full paths as keys.
Main challenge is to de-duplicate items and sections which
have aliases.
Do not add any new fe... | python | def _get_recursive_iterator(self, recursive=False):
"""
Basic recursive iterator whose only purpose is to yield all items
and sections in order, with their full paths as keys.
Main challenge is to de-duplicate items and sections which
have aliases.
Do not add any new fe... | [
"def",
"_get_recursive_iterator",
"(",
"self",
",",
"recursive",
"=",
"False",
")",
":",
"names_yielded",
"=",
"set",
"(",
")",
"for",
"obj_alias",
",",
"obj",
"in",
"self",
".",
"_tree",
".",
"items",
"(",
")",
":",
"if",
"obj",
".",
"is_section",
":"... | Basic recursive iterator whose only purpose is to yield all items
and sections in order, with their full paths as keys.
Main challenge is to de-duplicate items and sections which
have aliases.
Do not add any new features to this iterator, instead
build others that extend this o... | [
"Basic",
"recursive",
"iterator",
"whose",
"only",
"purpose",
"is",
"to",
"yield",
"all",
"items",
"and",
"sections",
"in",
"order",
"with",
"their",
"full",
"paths",
"as",
"keys",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L366-L401 |
45,731 | jbasko/configmanager | configmanager/sections.py | Section.reset | def reset(self):
"""
Recursively resets values of all items contained in this section
and its subsections to their default values.
"""
for _, item in self.iter_items(recursive=True):
item.reset() | python | def reset(self):
"""
Recursively resets values of all items contained in this section
and its subsections to their default values.
"""
for _, item in self.iter_items(recursive=True):
item.reset() | [
"def",
"reset",
"(",
"self",
")",
":",
"for",
"_",
",",
"item",
"in",
"self",
".",
"iter_items",
"(",
"recursive",
"=",
"True",
")",
":",
"item",
".",
"reset",
"(",
")"
] | Recursively resets values of all items contained in this section
and its subsections to their default values. | [
"Recursively",
"resets",
"values",
"of",
"all",
"items",
"contained",
"in",
"this",
"section",
"and",
"its",
"subsections",
"to",
"their",
"default",
"values",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L487-L493 |
45,732 | jbasko/configmanager | configmanager/sections.py | Section.is_default | def is_default(self):
"""
``True`` if values of all config items in this section and its subsections
have their values equal to defaults or have no value set.
"""
for _, item in self.iter_items(recursive=True):
if not item.is_default:
return False
... | python | def is_default(self):
"""
``True`` if values of all config items in this section and its subsections
have their values equal to defaults or have no value set.
"""
for _, item in self.iter_items(recursive=True):
if not item.is_default:
return False
... | [
"def",
"is_default",
"(",
"self",
")",
":",
"for",
"_",
",",
"item",
"in",
"self",
".",
"iter_items",
"(",
"recursive",
"=",
"True",
")",
":",
"if",
"not",
"item",
".",
"is_default",
":",
"return",
"False",
"return",
"True"
] | ``True`` if values of all config items in this section and its subsections
have their values equal to defaults or have no value set. | [
"True",
"if",
"values",
"of",
"all",
"config",
"items",
"in",
"this",
"section",
"and",
"its",
"subsections",
"have",
"their",
"values",
"equal",
"to",
"defaults",
"or",
"have",
"no",
"value",
"set",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L496-L504 |
45,733 | jbasko/configmanager | configmanager/sections.py | Section.dump_values | def dump_values(self, with_defaults=True, dict_cls=dict, flat=False):
"""
Export values of all items contained in this section to a dictionary.
Items with no values set (and no defaults set if ``with_defaults=True``) will be excluded.
Returns:
dict: A dictionary of key-valu... | python | def dump_values(self, with_defaults=True, dict_cls=dict, flat=False):
"""
Export values of all items contained in this section to a dictionary.
Items with no values set (and no defaults set if ``with_defaults=True``) will be excluded.
Returns:
dict: A dictionary of key-valu... | [
"def",
"dump_values",
"(",
"self",
",",
"with_defaults",
"=",
"True",
",",
"dict_cls",
"=",
"dict",
",",
"flat",
"=",
"False",
")",
":",
"values",
"=",
"dict_cls",
"(",
")",
"if",
"flat",
":",
"for",
"str_path",
",",
"item",
"in",
"self",
".",
"iter_... | Export values of all items contained in this section to a dictionary.
Items with no values set (and no defaults set if ``with_defaults=True``) will be excluded.
Returns:
dict: A dictionary of key-value pairs, where for sections values are dictionaries
of their contents. | [
"Export",
"values",
"of",
"all",
"items",
"contained",
"in",
"this",
"section",
"to",
"a",
"dictionary",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L506-L534 |
45,734 | jbasko/configmanager | configmanager/sections.py | Section.load_values | def load_values(self, dictionary, as_defaults=False, flat=False):
"""
Import config values from a dictionary.
When ``as_defaults`` is set to ``True``, the values
imported will be set as defaults. This can be used to
declare the sections and items of configuration.
Values... | python | def load_values(self, dictionary, as_defaults=False, flat=False):
"""
Import config values from a dictionary.
When ``as_defaults`` is set to ``True``, the values
imported will be set as defaults. This can be used to
declare the sections and items of configuration.
Values... | [
"def",
"load_values",
"(",
"self",
",",
"dictionary",
",",
"as_defaults",
"=",
"False",
",",
"flat",
"=",
"False",
")",
":",
"if",
"flat",
":",
"# Deflatten the dictionary and then pass on to the normal case.",
"separator",
"=",
"self",
".",
"settings",
".",
"str_... | Import config values from a dictionary.
When ``as_defaults`` is set to ``True``, the values
imported will be set as defaults. This can be used to
declare the sections and items of configuration.
Values of sections and items in ``dictionary`` can be
dictionaries as well as instan... | [
"Import",
"config",
"values",
"from",
"a",
"dictionary",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L536-L587 |
45,735 | jbasko/configmanager | configmanager/sections.py | Section.create_section | def create_section(self, *args, **kwargs):
"""
Internal factory method used to create an instance of configuration section.
Should only be used when extending or modifying configmanager's functionality.
Under normal circumstances you should let configmanager create sections
and ... | python | def create_section(self, *args, **kwargs):
"""
Internal factory method used to create an instance of configuration section.
Should only be used when extending or modifying configmanager's functionality.
Under normal circumstances you should let configmanager create sections
and ... | [
"def",
"create_section",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'section'",
",",
"self",
")",
"return",
"self",
".",
"settings",
".",
"section_factory",
"(",
"*",
"args",
",",
"*",
"*",
"k... | Internal factory method used to create an instance of configuration section.
Should only be used when extending or modifying configmanager's functionality.
Under normal circumstances you should let configmanager create sections
and items when parsing configuration schemas.
Do not overr... | [
"Internal",
"factory",
"method",
"used",
"to",
"create",
"an",
"instance",
"of",
"configuration",
"section",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L603-L616 |
45,736 | jbasko/configmanager | configmanager/sections.py | Section.item_attribute | def item_attribute(self, f=None, name=None):
"""
A decorator to register a dynamic item attribute provider.
By default, uses function name for attribute name. Override that with ``name=``.
"""
def decorator(func):
attr_name = name or func.__name__
if attr... | python | def item_attribute(self, f=None, name=None):
"""
A decorator to register a dynamic item attribute provider.
By default, uses function name for attribute name. Override that with ``name=``.
"""
def decorator(func):
attr_name = name or func.__name__
if attr... | [
"def",
"item_attribute",
"(",
"self",
",",
"f",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"attr_name",
"=",
"name",
"or",
"func",
".",
"__name__",
"if",
"attr_name",
".",
"startswith",
"(",
"'_'",
")"... | A decorator to register a dynamic item attribute provider.
By default, uses function name for attribute name. Override that with ``name=``. | [
"A",
"decorator",
"to",
"register",
"a",
"dynamic",
"item",
"attribute",
"provider",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L668-L684 |
45,737 | jbasko/configmanager | configmanager/sections.py | Section.get_item_attribute | def get_item_attribute(self, item, name):
"""
Method called by item when an attribute is not found.
"""
if name in self.__item_attributes:
return self.__item_attributes[name](item)
elif self.section:
return self.section.get_item_attribute(item, name)
... | python | def get_item_attribute(self, item, name):
"""
Method called by item when an attribute is not found.
"""
if name in self.__item_attributes:
return self.__item_attributes[name](item)
elif self.section:
return self.section.get_item_attribute(item, name)
... | [
"def",
"get_item_attribute",
"(",
"self",
",",
"item",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"__item_attributes",
":",
"return",
"self",
".",
"__item_attributes",
"[",
"name",
"]",
"(",
"item",
")",
"elif",
"self",
".",
"section",
":",
... | Method called by item when an attribute is not found. | [
"Method",
"called",
"by",
"item",
"when",
"an",
"attribute",
"is",
"not",
"found",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L686-L695 |
45,738 | jbasko/configmanager | configmanager/sections.py | Section.dispatch_event | def dispatch_event(self, event_, **kwargs):
"""
Dispatch section event.
Notes:
You MUST NOT call event.trigger() directly because
it will circumvent the section settings as well
as ignore the section tree.
If hooks are disabled somewhere up in th... | python | def dispatch_event(self, event_, **kwargs):
"""
Dispatch section event.
Notes:
You MUST NOT call event.trigger() directly because
it will circumvent the section settings as well
as ignore the section tree.
If hooks are disabled somewhere up in th... | [
"def",
"dispatch_event",
"(",
"self",
",",
"event_",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"settings",
".",
"hooks_enabled",
":",
"result",
"=",
"self",
".",
"hooks",
".",
"dispatch_event",
"(",
"event_",
",",
"*",
"*",
"kwargs",
")",
... | Dispatch section event.
Notes:
You MUST NOT call event.trigger() directly because
it will circumvent the section settings as well
as ignore the section tree.
If hooks are disabled somewhere up in the tree, and enabled
down below, events will still be... | [
"Dispatch",
"section",
"event",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/sections.py#L701-L726 |
45,739 | jbasko/configmanager | configmanager/managers.py | Config.load | def load(self):
"""
Load user configuration based on settings.
"""
# Must reverse because we want the sources assigned to higher-up Config instances
# to overrides sources assigned to lower Config instances.
for section in reversed(list(self.iter_sections(recursive=True,... | python | def load(self):
"""
Load user configuration based on settings.
"""
# Must reverse because we want the sources assigned to higher-up Config instances
# to overrides sources assigned to lower Config instances.
for section in reversed(list(self.iter_sections(recursive=True,... | [
"def",
"load",
"(",
"self",
")",
":",
"# Must reverse because we want the sources assigned to higher-up Config instances",
"# to overrides sources assigned to lower Config instances.",
"for",
"section",
"in",
"reversed",
"(",
"list",
"(",
"self",
".",
"iter_sections",
"(",
"rec... | Load user configuration based on settings. | [
"Load",
"user",
"configuration",
"based",
"on",
"settings",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/managers.py#L214-L228 |
45,740 | jbasko/configmanager | configmanager/click_ext.py | ClickExtension.option | def option(self, *args, **kwargs):
"""
Registers a click.option which falls back to a configmanager Item
if user hasn't provided a value in the command line.
Item must be the last of ``args``.
Examples::
config = Config({'greeting': 'Hello'})
@click.co... | python | def option(self, *args, **kwargs):
"""
Registers a click.option which falls back to a configmanager Item
if user hasn't provided a value in the command line.
Item must be the last of ``args``.
Examples::
config = Config({'greeting': 'Hello'})
@click.co... | [
"def",
"option",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
",",
"kwargs",
"=",
"_config_parameter",
"(",
"args",
",",
"kwargs",
")",
"return",
"self",
".",
"_click",
".",
"option",
"(",
"*",
"args",
",",
"*",
"*",
... | Registers a click.option which falls back to a configmanager Item
if user hasn't provided a value in the command line.
Item must be the last of ``args``.
Examples::
config = Config({'greeting': 'Hello'})
@click.command()
@config.click.option('--greeting', ... | [
"Registers",
"a",
"click",
".",
"option",
"which",
"falls",
"back",
"to",
"a",
"configmanager",
"Item",
"if",
"user",
"hasn",
"t",
"provided",
"a",
"value",
"in",
"the",
"command",
"line",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/click_ext.py#L42-L60 |
45,741 | jbasko/configmanager | configmanager/click_ext.py | ClickExtension.argument | def argument(self, *args, **kwargs):
"""
Registers a click.argument which falls back to a configmanager Item
if user hasn't provided a value in the command line.
Item must be the last of ``args``.
"""
if kwargs.get('required', True):
raise TypeError(
... | python | def argument(self, *args, **kwargs):
"""
Registers a click.argument which falls back to a configmanager Item
if user hasn't provided a value in the command line.
Item must be the last of ``args``.
"""
if kwargs.get('required', True):
raise TypeError(
... | [
"def",
"argument",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"kwargs",
".",
"get",
"(",
"'required'",
",",
"True",
")",
":",
"raise",
"TypeError",
"(",
"'In click framework, arguments are mandatory, unless marked required=False. '",
... | Registers a click.argument which falls back to a configmanager Item
if user hasn't provided a value in the command line.
Item must be the last of ``args``. | [
"Registers",
"a",
"click",
".",
"argument",
"which",
"falls",
"back",
"to",
"a",
"configmanager",
"Item",
"if",
"user",
"hasn",
"t",
"provided",
"a",
"value",
"in",
"the",
"command",
"line",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/click_ext.py#L62-L78 |
45,742 | jbasko/configmanager | configmanager/items.py | Item._get_kwarg | def _get_kwarg(self, name, kwargs):
"""
Helper to get value of a named attribute irrespective of whether it is passed
with or without "@" prefix.
"""
at_name = '@{}'.format(name)
if name in kwargs:
if at_name in kwargs:
raise ValueError('Both ... | python | def _get_kwarg(self, name, kwargs):
"""
Helper to get value of a named attribute irrespective of whether it is passed
with or without "@" prefix.
"""
at_name = '@{}'.format(name)
if name in kwargs:
if at_name in kwargs:
raise ValueError('Both ... | [
"def",
"_get_kwarg",
"(",
"self",
",",
"name",
",",
"kwargs",
")",
":",
"at_name",
"=",
"'@{}'",
".",
"format",
"(",
"name",
")",
"if",
"name",
"in",
"kwargs",
":",
"if",
"at_name",
"in",
"kwargs",
":",
"raise",
"ValueError",
"(",
"'Both {!r} and {!r} sp... | Helper to get value of a named attribute irrespective of whether it is passed
with or without "@" prefix. | [
"Helper",
"to",
"get",
"value",
"of",
"a",
"named",
"attribute",
"irrespective",
"of",
"whether",
"it",
"is",
"passed",
"with",
"or",
"without"
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L61-L76 |
45,743 | jbasko/configmanager | configmanager/items.py | Item._get_envvar_value | def _get_envvar_value(self):
"""
Internal helper to get item value from an environment variable
if item is controlled by one, and if the variable is set.
Returns not_set otherwise.
"""
envvar_name = None
if self.envvar is True:
envvar_name = self.env... | python | def _get_envvar_value(self):
"""
Internal helper to get item value from an environment variable
if item is controlled by one, and if the variable is set.
Returns not_set otherwise.
"""
envvar_name = None
if self.envvar is True:
envvar_name = self.env... | [
"def",
"_get_envvar_value",
"(",
"self",
")",
":",
"envvar_name",
"=",
"None",
"if",
"self",
".",
"envvar",
"is",
"True",
":",
"envvar_name",
"=",
"self",
".",
"envvar_name",
"if",
"envvar_name",
"is",
"None",
":",
"envvar_name",
"=",
"'_'",
".",
"join",
... | Internal helper to get item value from an environment variable
if item is controlled by one, and if the variable is set.
Returns not_set otherwise. | [
"Internal",
"helper",
"to",
"get",
"item",
"value",
"from",
"an",
"environment",
"variable",
"if",
"item",
"is",
"controlled",
"by",
"one",
"and",
"if",
"the",
"variable",
"is",
"set",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L178-L197 |
45,744 | jbasko/configmanager | configmanager/items.py | Item.get | def get(self, fallback=not_set):
"""
Returns config value.
See Also:
:meth:`.set` and :attr:`.value`
"""
envvar_value = self._get_envvar_value()
if envvar_value is not not_set:
return envvar_value
if self.has_value:
if self._... | python | def get(self, fallback=not_set):
"""
Returns config value.
See Also:
:meth:`.set` and :attr:`.value`
"""
envvar_value = self._get_envvar_value()
if envvar_value is not not_set:
return envvar_value
if self.has_value:
if self._... | [
"def",
"get",
"(",
"self",
",",
"fallback",
"=",
"not_set",
")",
":",
"envvar_value",
"=",
"self",
".",
"_get_envvar_value",
"(",
")",
"if",
"envvar_value",
"is",
"not",
"not_set",
":",
"return",
"envvar_value",
"if",
"self",
".",
"has_value",
":",
"if",
... | Returns config value.
See Also:
:meth:`.set` and :attr:`.value` | [
"Returns",
"config",
"value",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L199-L220 |
45,745 | jbasko/configmanager | configmanager/items.py | Item.set | def set(self, value):
"""
Sets config value.
"""
old_value = self._value
old_raw_str_value = self.raw_str_value
self.type.set_item_value(self, value)
new_value = self._value
if old_value is not_set and new_value is not_set:
# Nothing to repo... | python | def set(self, value):
"""
Sets config value.
"""
old_value = self._value
old_raw_str_value = self.raw_str_value
self.type.set_item_value(self, value)
new_value = self._value
if old_value is not_set and new_value is not_set:
# Nothing to repo... | [
"def",
"set",
"(",
"self",
",",
"value",
")",
":",
"old_value",
"=",
"self",
".",
"_value",
"old_raw_str_value",
"=",
"self",
".",
"raw_str_value",
"self",
".",
"type",
".",
"set_item_value",
"(",
"self",
",",
"value",
")",
"new_value",
"=",
"self",
".",... | Sets config value. | [
"Sets",
"config",
"value",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L231-L254 |
45,746 | jbasko/configmanager | configmanager/items.py | Item.reset | def reset(self):
"""
Resets the value of config item to its default value.
"""
old_value = self._value
old_raw_str_value = self.raw_str_value
self._value = not_set
self.raw_str_value = not_set
new_value = self._value
if old_value is not_set:
... | python | def reset(self):
"""
Resets the value of config item to its default value.
"""
old_value = self._value
old_raw_str_value = self.raw_str_value
self._value = not_set
self.raw_str_value = not_set
new_value = self._value
if old_value is not_set:
... | [
"def",
"reset",
"(",
"self",
")",
":",
"old_value",
"=",
"self",
".",
"_value",
"old_raw_str_value",
"=",
"self",
".",
"raw_str_value",
"self",
".",
"_value",
"=",
"not_set",
"self",
".",
"raw_str_value",
"=",
"not_set",
"new_value",
"=",
"self",
".",
"_va... | Resets the value of config item to its default value. | [
"Resets",
"the",
"value",
"of",
"config",
"item",
"to",
"its",
"default",
"value",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L256-L280 |
45,747 | jbasko/configmanager | configmanager/items.py | Item.is_default | def is_default(self):
"""
``True`` if the item's value is its default value or if no value and no default value are set.
If the item is backed by an environment variable, this will be ``True`` only
if the environment variable is set and is different to the
default value of the i... | python | def is_default(self):
"""
``True`` if the item's value is its default value or if no value and no default value are set.
If the item is backed by an environment variable, this will be ``True`` only
if the environment variable is set and is different to the
default value of the i... | [
"def",
"is_default",
"(",
"self",
")",
":",
"envvar_value",
"=",
"self",
".",
"_get_envvar_value",
"(",
")",
"if",
"envvar_value",
"is",
"not",
"not_set",
":",
"return",
"envvar_value",
"==",
"self",
".",
"default",
"else",
":",
"return",
"self",
".",
"_va... | ``True`` if the item's value is its default value or if no value and no default value are set.
If the item is backed by an environment variable, this will be ``True`` only
if the environment variable is set and is different to the
default value of the item. | [
"True",
"if",
"the",
"item",
"s",
"value",
"is",
"its",
"default",
"value",
"or",
"if",
"no",
"value",
"and",
"no",
"default",
"value",
"are",
"set",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L283-L295 |
45,748 | jbasko/configmanager | configmanager/items.py | Item.has_value | def has_value(self):
"""
``True`` if item has a default value or custom value set.
"""
if self._get_envvar_value() is not not_set:
return True
else:
return self.default is not not_set or self._value is not not_set | python | def has_value(self):
"""
``True`` if item has a default value or custom value set.
"""
if self._get_envvar_value() is not not_set:
return True
else:
return self.default is not not_set or self._value is not not_set | [
"def",
"has_value",
"(",
"self",
")",
":",
"if",
"self",
".",
"_get_envvar_value",
"(",
")",
"is",
"not",
"not_set",
":",
"return",
"True",
"else",
":",
"return",
"self",
".",
"default",
"is",
"not",
"not_set",
"or",
"self",
".",
"_value",
"is",
"not",... | ``True`` if item has a default value or custom value set. | [
"True",
"if",
"item",
"has",
"a",
"default",
"value",
"or",
"custom",
"value",
"set",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L298-L305 |
45,749 | jbasko/configmanager | configmanager/items.py | Item.validate | def validate(self):
"""
Validate item.
"""
if self.required and not self.has_value:
raise RequiredValueMissing(name=self.name, item=self) | python | def validate(self):
"""
Validate item.
"""
if self.required and not self.has_value:
raise RequiredValueMissing(name=self.name, item=self) | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"self",
".",
"required",
"and",
"not",
"self",
".",
"has_value",
":",
"raise",
"RequiredValueMissing",
"(",
"name",
"=",
"self",
".",
"name",
",",
"item",
"=",
"self",
")"
] | Validate item. | [
"Validate",
"item",
"."
] | 1d7229ce367143c7210d8e5f0782de03945a1721 | https://github.com/jbasko/configmanager/blob/1d7229ce367143c7210d8e5f0782de03945a1721/configmanager/items.py#L329-L334 |
45,750 | aisayko/Django-tinymce-filebrowser | mce_filebrowser/views.py | filebrowser | def filebrowser(request, file_type):
""" Trigger view for filebrowser """
template = 'filebrowser.html'
upload_form = FileUploadForm()
uploaded_file = None
upload_tab_active = False
is_images_dialog = (file_type == 'img')
is_documents_dialog = (file_type == 'doc')
files = FileBrowse... | python | def filebrowser(request, file_type):
""" Trigger view for filebrowser """
template = 'filebrowser.html'
upload_form = FileUploadForm()
uploaded_file = None
upload_tab_active = False
is_images_dialog = (file_type == 'img')
is_documents_dialog = (file_type == 'doc')
files = FileBrowse... | [
"def",
"filebrowser",
"(",
"request",
",",
"file_type",
")",
":",
"template",
"=",
"'filebrowser.html'",
"upload_form",
"=",
"FileUploadForm",
"(",
")",
"uploaded_file",
"=",
"None",
"upload_tab_active",
"=",
"False",
"is_images_dialog",
"=",
"(",
"file_type",
"==... | Trigger view for filebrowser | [
"Trigger",
"view",
"for",
"filebrowser"
] | f34c9e8f8c5e32c1d1221270314f31ee07f24409 | https://github.com/aisayko/Django-tinymce-filebrowser/blob/f34c9e8f8c5e32c1d1221270314f31ee07f24409/mce_filebrowser/views.py#L15-L43 |
45,751 | saippuakauppias/temp-mail | tempmail.py | TempMail.available_domains | def available_domains(self):
"""
Return list of available domains for use in email address.
"""
if not hasattr(self, '_available_domains'):
url = 'http://{0}/request/domains/format/json/'.format(
self.api_domain)
req = requests.get(url)
... | python | def available_domains(self):
"""
Return list of available domains for use in email address.
"""
if not hasattr(self, '_available_domains'):
url = 'http://{0}/request/domains/format/json/'.format(
self.api_domain)
req = requests.get(url)
... | [
"def",
"available_domains",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_available_domains'",
")",
":",
"url",
"=",
"'http://{0}/request/domains/format/json/'",
".",
"format",
"(",
"self",
".",
"api_domain",
")",
"req",
"=",
"requests",
... | Return list of available domains for use in email address. | [
"Return",
"list",
"of",
"available",
"domains",
"for",
"use",
"in",
"email",
"address",
"."
] | 52254a6d614043ffd47a8c6b929fce77596d5053 | https://github.com/saippuakauppias/temp-mail/blob/52254a6d614043ffd47a8c6b929fce77596d5053/tempmail.py#L28-L38 |
45,752 | saippuakauppias/temp-mail | tempmail.py | TempMail.generate_login | def generate_login(self, min_length=6, max_length=10, digits=True):
"""
Generate string for email address login with defined length and
alphabet.
:param min_length: (optional) min login length.
Default value is ``6``.
:param max_length: (optional) max login length.
... | python | def generate_login(self, min_length=6, max_length=10, digits=True):
"""
Generate string for email address login with defined length and
alphabet.
:param min_length: (optional) min login length.
Default value is ``6``.
:param max_length: (optional) max login length.
... | [
"def",
"generate_login",
"(",
"self",
",",
"min_length",
"=",
"6",
",",
"max_length",
"=",
"10",
",",
"digits",
"=",
"True",
")",
":",
"chars",
"=",
"string",
".",
"ascii_lowercase",
"if",
"digits",
":",
"chars",
"+=",
"string",
".",
"digits",
"length",
... | Generate string for email address login with defined length and
alphabet.
:param min_length: (optional) min login length.
Default value is ``6``.
:param max_length: (optional) max login length.
Default value is ``10``.
:param digits: (optional) use digits in login genera... | [
"Generate",
"string",
"for",
"email",
"address",
"login",
"with",
"defined",
"length",
"and",
"alphabet",
"."
] | 52254a6d614043ffd47a8c6b929fce77596d5053 | https://github.com/saippuakauppias/temp-mail/blob/52254a6d614043ffd47a8c6b929fce77596d5053/tempmail.py#L40-L56 |
45,753 | saippuakauppias/temp-mail | tempmail.py | TempMail.get_email_address | def get_email_address(self):
"""
Return full email address from login and domain from params in class
initialization or generate new.
"""
if self.login is None:
self.login = self.generate_login()
available_domains = self.available_domains
if self.doma... | python | def get_email_address(self):
"""
Return full email address from login and domain from params in class
initialization or generate new.
"""
if self.login is None:
self.login = self.generate_login()
available_domains = self.available_domains
if self.doma... | [
"def",
"get_email_address",
"(",
"self",
")",
":",
"if",
"self",
".",
"login",
"is",
"None",
":",
"self",
".",
"login",
"=",
"self",
".",
"generate_login",
"(",
")",
"available_domains",
"=",
"self",
".",
"available_domains",
"if",
"self",
".",
"domain",
... | Return full email address from login and domain from params in class
initialization or generate new. | [
"Return",
"full",
"email",
"address",
"from",
"login",
"and",
"domain",
"from",
"params",
"in",
"class",
"initialization",
"or",
"generate",
"new",
"."
] | 52254a6d614043ffd47a8c6b929fce77596d5053 | https://github.com/saippuakauppias/temp-mail/blob/52254a6d614043ffd47a8c6b929fce77596d5053/tempmail.py#L58-L71 |
45,754 | saippuakauppias/temp-mail | tempmail.py | TempMail.get_mailbox | def get_mailbox(self, email=None, email_hash=None):
"""
Return list of emails in given email address
or dict with `error` key if mail box is empty.
:param email: (optional) email address.
:param email_hash: (optional) md5 hash from email address.
"""
if email is ... | python | def get_mailbox(self, email=None, email_hash=None):
"""
Return list of emails in given email address
or dict with `error` key if mail box is empty.
:param email: (optional) email address.
:param email_hash: (optional) md5 hash from email address.
"""
if email is ... | [
"def",
"get_mailbox",
"(",
"self",
",",
"email",
"=",
"None",
",",
"email_hash",
"=",
"None",
")",
":",
"if",
"email",
"is",
"None",
":",
"email",
"=",
"self",
".",
"get_email_address",
"(",
")",
"if",
"email_hash",
"is",
"None",
":",
"email_hash",
"="... | Return list of emails in given email address
or dict with `error` key if mail box is empty.
:param email: (optional) email address.
:param email_hash: (optional) md5 hash from email address. | [
"Return",
"list",
"of",
"emails",
"in",
"given",
"email",
"address",
"or",
"dict",
"with",
"error",
"key",
"if",
"mail",
"box",
"is",
"empty",
"."
] | 52254a6d614043ffd47a8c6b929fce77596d5053 | https://github.com/saippuakauppias/temp-mail/blob/52254a6d614043ffd47a8c6b929fce77596d5053/tempmail.py#L81-L97 |
45,755 | leonjza/pytel | pytel/utils/sockets.py | setup_domain_socket | def setup_domain_socket(location):
'''
Setup Domain Socket
Setup a connection to a Unix Domain Socket
--
@param location:str The path to the Unix Domain Socket to connect to.
@return <class 'socket._socketobject'>
'''
clientsocket = socket.socket(socket.AF_UNI... | python | def setup_domain_socket(location):
'''
Setup Domain Socket
Setup a connection to a Unix Domain Socket
--
@param location:str The path to the Unix Domain Socket to connect to.
@return <class 'socket._socketobject'>
'''
clientsocket = socket.socket(socket.AF_UNI... | [
"def",
"setup_domain_socket",
"(",
"location",
")",
":",
"clientsocket",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_UNIX",
",",
"socket",
".",
"SOCK_STREAM",
")",
"clientsocket",
".",
"settimeout",
"(",
"timeout",
")",
"clientsocket",
".",
"connect"... | Setup Domain Socket
Setup a connection to a Unix Domain Socket
--
@param location:str The path to the Unix Domain Socket to connect to.
@return <class 'socket._socketobject'> | [
"Setup",
"Domain",
"Socket"
] | db9bca21d1ce0b2dfb6bf5068d65fc7309265e28 | https://github.com/leonjza/pytel/blob/db9bca21d1ce0b2dfb6bf5068d65fc7309265e28/pytel/utils/sockets.py#L33-L49 |
45,756 | leonjza/pytel | pytel/utils/sockets.py | setup_tcp_socket | def setup_tcp_socket(location, port):
'''
Setup TCP Socket
Setup a connection to a TCP Socket
--
@param location:str The Hostname / IP Address of the remote TCP Socket.
@param port:int The TCP Port the remote Socket is listening on.
@return <class 'sock... | python | def setup_tcp_socket(location, port):
'''
Setup TCP Socket
Setup a connection to a TCP Socket
--
@param location:str The Hostname / IP Address of the remote TCP Socket.
@param port:int The TCP Port the remote Socket is listening on.
@return <class 'sock... | [
"def",
"setup_tcp_socket",
"(",
"location",
",",
"port",
")",
":",
"clientsocket",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"clientsocket",
".",
"settimeout",
"(",
"timeout",
")",
"clientsocket",
".... | Setup TCP Socket
Setup a connection to a TCP Socket
--
@param location:str The Hostname / IP Address of the remote TCP Socket.
@param port:int The TCP Port the remote Socket is listening on.
@return <class 'socket._socketobject'> | [
"Setup",
"TCP",
"Socket"
] | db9bca21d1ce0b2dfb6bf5068d65fc7309265e28 | https://github.com/leonjza/pytel/blob/db9bca21d1ce0b2dfb6bf5068d65fc7309265e28/pytel/utils/sockets.py#L51-L68 |
45,757 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.create_primary_zone | def create_primary_zone(self, account_name, zone_name):
"""Creates a new primary zone.
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It must be unique.
"""
zone_properties = {"name": zone_name, "accou... | python | def create_primary_zone(self, account_name, zone_name):
"""Creates a new primary zone.
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It must be unique.
"""
zone_properties = {"name": zone_name, "accou... | [
"def",
"create_primary_zone",
"(",
"self",
",",
"account_name",
",",
"zone_name",
")",
":",
"zone_properties",
"=",
"{",
"\"name\"",
":",
"zone_name",
",",
"\"accountName\"",
":",
"account_name",
",",
"\"type\"",
":",
"\"PRIMARY\"",
"}",
"primary_zone_info",
"=",
... | Creates a new primary zone.
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It must be unique. | [
"Creates",
"a",
"new",
"primary",
"zone",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L29-L40 |
45,758 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.create_primary_zone_by_upload | def create_primary_zone_by_upload(self, account_name, zone_name, bind_file):
"""Creates a new primary zone by uploading a bind file
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It must be unique.
bind_file --... | python | def create_primary_zone_by_upload(self, account_name, zone_name, bind_file):
"""Creates a new primary zone by uploading a bind file
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It must be unique.
bind_file --... | [
"def",
"create_primary_zone_by_upload",
"(",
"self",
",",
"account_name",
",",
"zone_name",
",",
"bind_file",
")",
":",
"zone_properties",
"=",
"{",
"\"name\"",
":",
"zone_name",
",",
"\"accountName\"",
":",
"account_name",
",",
"\"type\"",
":",
"\"PRIMARY\"",
"}"... | Creates a new primary zone by uploading a bind file
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It must be unique.
bind_file -- The file to upload. | [
"Creates",
"a",
"new",
"primary",
"zone",
"by",
"uploading",
"a",
"bind",
"file"
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L43-L57 |
45,759 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.create_primary_zone_by_axfr | def create_primary_zone_by_axfr(self, account_name, zone_name, master, tsig_key=None, key_value=None):
"""Creates a new primary zone by zone transferring off a master.
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It ... | python | def create_primary_zone_by_axfr(self, account_name, zone_name, master, tsig_key=None, key_value=None):
"""Creates a new primary zone by zone transferring off a master.
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It ... | [
"def",
"create_primary_zone_by_axfr",
"(",
"self",
",",
"account_name",
",",
"zone_name",
",",
"master",
",",
"tsig_key",
"=",
"None",
",",
"key_value",
"=",
"None",
")",
":",
"zone_properties",
"=",
"{",
"\"name\"",
":",
"zone_name",
",",
"\"accountName\"",
"... | Creates a new primary zone by zone transferring off a master.
Arguments:
account_name -- The name of the account that will contain this zone.
zone_name -- The name of the zone. It must be unique.
master -- Primary name server IP address.
Keyword Arguments:
tsig_key -- ... | [
"Creates",
"a",
"new",
"primary",
"zone",
"by",
"zone",
"transferring",
"off",
"a",
"master",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L60-L81 |
45,760 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.create_secondary_zone | def create_secondary_zone(self, account_name, zone_name, master, tsig_key=None, key_value=None):
"""Creates a new secondary zone.
Arguments:
account_name -- The name of the account.
zone_name -- The name of the zone.
master -- Primary name server IP address.
Keyword Arg... | python | def create_secondary_zone(self, account_name, zone_name, master, tsig_key=None, key_value=None):
"""Creates a new secondary zone.
Arguments:
account_name -- The name of the account.
zone_name -- The name of the zone.
master -- Primary name server IP address.
Keyword Arg... | [
"def",
"create_secondary_zone",
"(",
"self",
",",
"account_name",
",",
"zone_name",
",",
"master",
",",
"tsig_key",
"=",
"None",
",",
"key_value",
"=",
"None",
")",
":",
"zone_properties",
"=",
"{",
"\"name\"",
":",
"zone_name",
",",
"\"accountName\"",
":",
... | Creates a new secondary zone.
Arguments:
account_name -- The name of the account.
zone_name -- The name of the zone.
master -- Primary name server IP address.
Keyword Arguments:
tsig_key -- For TSIG-enabled zones: The transaction signature key.
NOTE:... | [
"Creates",
"a",
"new",
"secondary",
"zone",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L84-L107 |
45,761 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.get_zones_of_account | def get_zones_of_account(self, account_name, q=None, **kwargs):
"""Returns a list of zones for the specified account.
Arguments:
account_name -- The name of the account.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
name - substring mat... | python | def get_zones_of_account(self, account_name, q=None, **kwargs):
"""Returns a list of zones for the specified account.
Arguments:
account_name -- The name of the account.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
name - substring mat... | [
"def",
"get_zones_of_account",
"(",
"self",
",",
"account_name",
",",
"q",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"uri",
"=",
"\"/v1/accounts/\"",
"+",
"account_name",
"+",
"\"/zones\"",
"params",
"=",
"build_params",
"(",
"q",
",",
"kwargs",
")",... | Returns a list of zones for the specified account.
Arguments:
account_name -- The name of the account.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
name - substring match of the zone name
zone_type - one of:
PRIMAR... | [
"Returns",
"a",
"list",
"of",
"zones",
"for",
"the",
"specified",
"account",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L130-L155 |
45,762 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.get_zones | def get_zones(self, q=None, **kwargs):
"""Returns a list of zones across all of the user's accounts.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
name - substring match of the zone name
zone_type - one of:
PRIMARY
... | python | def get_zones(self, q=None, **kwargs):
"""Returns a list of zones across all of the user's accounts.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
name - substring match of the zone name
zone_type - one of:
PRIMARY
... | [
"def",
"get_zones",
"(",
"self",
",",
"q",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"uri",
"=",
"\"/v1/zones\"",
"params",
"=",
"build_params",
"(",
"q",
",",
"kwargs",
")",
"return",
"self",
".",
"rest_api_connection",
".",
"get",
"(",
"uri",
... | Returns a list of zones across all of the user's accounts.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
name - substring match of the zone name
zone_type - one of:
PRIMARY
SECONDARY
ALIAS
sor... | [
"Returns",
"a",
"list",
"of",
"zones",
"across",
"all",
"of",
"the",
"user",
"s",
"accounts",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L158-L180 |
45,763 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.edit_secondary_name_server | def edit_secondary_name_server(self, zone_name, primary=None, backup=None, second_backup=None):
"""Edit the axfr name servers of a secondary zone.
Arguments:
zone_name -- The name of the secondary zone being edited.
primary -- The primary name server value.
Keyword Arguments:
... | python | def edit_secondary_name_server(self, zone_name, primary=None, backup=None, second_backup=None):
"""Edit the axfr name servers of a secondary zone.
Arguments:
zone_name -- The name of the secondary zone being edited.
primary -- The primary name server value.
Keyword Arguments:
... | [
"def",
"edit_secondary_name_server",
"(",
"self",
",",
"zone_name",
",",
"primary",
"=",
"None",
",",
"backup",
"=",
"None",
",",
"second_backup",
"=",
"None",
")",
":",
"name_server_info",
"=",
"{",
"}",
"if",
"primary",
"is",
"not",
"None",
":",
"name_se... | Edit the axfr name servers of a secondary zone.
Arguments:
zone_name -- The name of the secondary zone being edited.
primary -- The primary name server value.
Keyword Arguments:
backup -- The backup name server if any.
second_backup -- The second backup name server. | [
"Edit",
"the",
"axfr",
"name",
"servers",
"of",
"a",
"secondary",
"zone",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L203-L225 |
45,764 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.get_rrsets | def get_rrsets(self, zone_name, q=None, **kwargs):
"""Returns the list of RRSets in the specified zone.
Arguments:
zone_name -- The name of the zone.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
ttl - must match the TTL for the rrset
... | python | def get_rrsets(self, zone_name, q=None, **kwargs):
"""Returns the list of RRSets in the specified zone.
Arguments:
zone_name -- The name of the zone.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
ttl - must match the TTL for the rrset
... | [
"def",
"get_rrsets",
"(",
"self",
",",
"zone_name",
",",
"q",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"uri",
"=",
"\"/v1/zones/\"",
"+",
"zone_name",
"+",
"\"/rrsets\"",
"params",
"=",
"build_params",
"(",
"q",
",",
"kwargs",
")",
"return",
"se... | Returns the list of RRSets in the specified zone.
Arguments:
zone_name -- The name of the zone.
Keyword Arguments:
q -- The search parameters, in a dict. Valid keys are:
ttl - must match the TTL for the rrset
owner - substring match of the owner name
... | [
"Returns",
"the",
"list",
"of",
"RRSets",
"in",
"the",
"specified",
"zone",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L229-L251 |
45,765 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.create_rrset | def create_rrset(self, zone_name, rtype, owner_name, ttl, rdata):
"""Creates a new RRSet in the specified zone.
Arguments:
zone_name -- The zone that will contain the new RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
i... | python | def create_rrset(self, zone_name, rtype, owner_name, ttl, rdata):
"""Creates a new RRSet in the specified zone.
Arguments:
zone_name -- The zone that will contain the new RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
i... | [
"def",
"create_rrset",
"(",
"self",
",",
"zone_name",
",",
"rtype",
",",
"owner_name",
",",
"ttl",
",",
"rdata",
")",
":",
"if",
"type",
"(",
"rdata",
")",
"is",
"not",
"list",
":",
"rdata",
"=",
"[",
"rdata",
"]",
"rrset",
"=",
"{",
"\"ttl\"",
":"... | Creates a new RRSet in the specified zone.
Arguments:
zone_name -- The zone that will contain the new RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
if a well-known name is defined for the type (A), you can use it instead.
... | [
"Creates",
"a",
"new",
"RRSet",
"in",
"the",
"specified",
"zone",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L311-L330 |
45,766 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.edit_rrset | def edit_rrset(self, zone_name, rtype, owner_name, ttl, rdata, profile=None):
"""Updates an existing RRSet in the specified zone.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
... | python | def edit_rrset(self, zone_name, rtype, owner_name, ttl, rdata, profile=None):
"""Updates an existing RRSet in the specified zone.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
... | [
"def",
"edit_rrset",
"(",
"self",
",",
"zone_name",
",",
"rtype",
",",
"owner_name",
",",
"ttl",
",",
"rdata",
",",
"profile",
"=",
"None",
")",
":",
"if",
"type",
"(",
"rdata",
")",
"is",
"not",
"list",
":",
"rdata",
"=",
"[",
"rdata",
"]",
"rrset... | Updates an existing RRSet in the specified zone.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
if a well-known name is defined for the type (A), you can use it instead.
... | [
"Updates",
"an",
"existing",
"RRSet",
"in",
"the",
"specified",
"zone",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L333-L356 |
45,767 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.edit_rrset_rdata | def edit_rrset_rdata(self, zone_name, rtype, owner_name, rdata, profile=None):
"""Updates an existing RRSet's Rdata in the specified zone.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or... | python | def edit_rrset_rdata(self, zone_name, rtype, owner_name, rdata, profile=None):
"""Updates an existing RRSet's Rdata in the specified zone.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or... | [
"def",
"edit_rrset_rdata",
"(",
"self",
",",
"zone_name",
",",
"rtype",
",",
"owner_name",
",",
"rdata",
",",
"profile",
"=",
"None",
")",
":",
"if",
"type",
"(",
"rdata",
")",
"is",
"not",
"list",
":",
"rdata",
"=",
"[",
"rdata",
"]",
"rrset",
"=",
... | Updates an existing RRSet's Rdata in the specified zone.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
if a well-known name is defined for the type (A), you can use it instead... | [
"Updates",
"an",
"existing",
"RRSet",
"s",
"Rdata",
"in",
"the",
"specified",
"zone",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L359-L383 |
45,768 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.delete_rrset | def delete_rrset(self, zone_name, rtype, owner_name):
"""Deletes an RRSet.
Arguments:
zone_name -- The zone containing the RRSet to be deleted. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
if a well-known name is defined for... | python | def delete_rrset(self, zone_name, rtype, owner_name):
"""Deletes an RRSet.
Arguments:
zone_name -- The zone containing the RRSet to be deleted. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
if a well-known name is defined for... | [
"def",
"delete_rrset",
"(",
"self",
",",
"zone_name",
",",
"rtype",
",",
"owner_name",
")",
":",
"return",
"self",
".",
"rest_api_connection",
".",
"delete",
"(",
"\"/v1/zones/\"",
"+",
"zone_name",
"+",
"\"/rrsets/\"",
"+",
"rtype",
"+",
"\"/\"",
"+",
"owne... | Deletes an RRSet.
Arguments:
zone_name -- The zone containing the RRSet to be deleted. The trailing dot is optional.
rtype -- The type of the RRSet. This can be numeric (1) or
if a well-known name is defined for the type (A), you can use it instead.
owner_name -- The ... | [
"Deletes",
"an",
"RRSet",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L386-L398 |
45,769 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.create_web_forward | def create_web_forward(self, zone_name, request_to, redirect_to, forward_type):
"""Create a web forward record.
Arguments:
zone_name -- The zone in which the web forward is to be created.
request_to -- The URL to be redirected. You may use http:// and ftp://.
forward_type -- The... | python | def create_web_forward(self, zone_name, request_to, redirect_to, forward_type):
"""Create a web forward record.
Arguments:
zone_name -- The zone in which the web forward is to be created.
request_to -- The URL to be redirected. You may use http:// and ftp://.
forward_type -- The... | [
"def",
"create_web_forward",
"(",
"self",
",",
"zone_name",
",",
"request_to",
",",
"redirect_to",
",",
"forward_type",
")",
":",
"web_forward",
"=",
"{",
"\"requestTo\"",
":",
"request_to",
",",
"\"defaultRedirectTo\"",
":",
"redirect_to",
",",
"\"defaultForwardTyp... | Create a web forward record.
Arguments:
zone_name -- The zone in which the web forward is to be created.
request_to -- The URL to be redirected. You may use http:// and ftp://.
forward_type -- The type of forward. Valid options include:
Framed
... | [
"Create",
"a",
"web",
"forward",
"record",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L413-L428 |
45,770 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.create_sb_pool | def create_sb_pool(self, zone_name, owner_name, ttl, pool_info, rdata_info, backup_record_list):
"""Creates a new SB Pool.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
owner_name -- The owner name for the RRSet.
If no tra... | python | def create_sb_pool(self, zone_name, owner_name, ttl, pool_info, rdata_info, backup_record_list):
"""Creates a new SB Pool.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
owner_name -- The owner name for the RRSet.
If no tra... | [
"def",
"create_sb_pool",
"(",
"self",
",",
"zone_name",
",",
"owner_name",
",",
"ttl",
",",
"pool_info",
",",
"rdata_info",
",",
"backup_record_list",
")",
":",
"rrset",
"=",
"self",
".",
"_build_sb_rrset",
"(",
"backup_record_list",
",",
"pool_info",
",",
"rd... | Creates a new SB Pool.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
owner_name -- The owner name for the RRSet.
If no trailing dot is supplied, the owner_name is assumed to be relative (foo).
If a trailing d... | [
"Creates",
"a",
"new",
"SB",
"Pool",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L551-L571 |
45,771 | ultradns/python_rest_api_client | ultra_rest_client/ultra_rest_client.py | RestApiClient.create_tc_pool | def create_tc_pool(self, zone_name, owner_name, ttl, pool_info, rdata_info, backup_record):
"""Creates a new TC Pool.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
owner_name -- The owner name for the RRSet.
If no trailing... | python | def create_tc_pool(self, zone_name, owner_name, ttl, pool_info, rdata_info, backup_record):
"""Creates a new TC Pool.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
owner_name -- The owner name for the RRSet.
If no trailing... | [
"def",
"create_tc_pool",
"(",
"self",
",",
"zone_name",
",",
"owner_name",
",",
"ttl",
",",
"pool_info",
",",
"rdata_info",
",",
"backup_record",
")",
":",
"rrset",
"=",
"self",
".",
"_build_tc_rrset",
"(",
"backup_record",
",",
"pool_info",
",",
"rdata_info",... | Creates a new TC Pool.
Arguments:
zone_name -- The zone that contains the RRSet. The trailing dot is optional.
owner_name -- The owner name for the RRSet.
If no trailing dot is supplied, the owner_name is assumed to be relative (foo).
If a trailing d... | [
"Creates",
"a",
"new",
"TC",
"Pool",
"."
] | e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec | https://github.com/ultradns/python_rest_api_client/blob/e4095f28f5cb5e258b768c06ef7cf8b1915aa5ec/ultra_rest_client/ultra_rest_client.py#L661-L681 |
45,772 | mabuchilab/QNET | src/qnet/algebra/core/hilbert_space_algebra.py | ProductSpace.remove | def remove(self, other):
"""Remove a particular factor from a tensor product space."""
if other is FullSpace:
return TrivialSpace
if other is TrivialSpace:
return self
if isinstance(other, ProductSpace):
oops = set(other.operands)
else:
... | python | def remove(self, other):
"""Remove a particular factor from a tensor product space."""
if other is FullSpace:
return TrivialSpace
if other is TrivialSpace:
return self
if isinstance(other, ProductSpace):
oops = set(other.operands)
else:
... | [
"def",
"remove",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"FullSpace",
":",
"return",
"TrivialSpace",
"if",
"other",
"is",
"TrivialSpace",
":",
"return",
"self",
"if",
"isinstance",
"(",
"other",
",",
"ProductSpace",
")",
":",
"oops",
"=... | Remove a particular factor from a tensor product space. | [
"Remove",
"a",
"particular",
"factor",
"from",
"a",
"tensor",
"product",
"space",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/hilbert_space_algebra.py#L770-L781 |
45,773 | mabuchilab/QNET | src/qnet/algebra/core/hilbert_space_algebra.py | ProductSpace.intersect | def intersect(self, other):
"""Find the mutual tensor factors of two Hilbert spaces."""
if other is FullSpace:
return self
if other is TrivialSpace:
return TrivialSpace
if isinstance(other, ProductSpace):
other_ops = set(other.operands)
else:
... | python | def intersect(self, other):
"""Find the mutual tensor factors of two Hilbert spaces."""
if other is FullSpace:
return self
if other is TrivialSpace:
return TrivialSpace
if isinstance(other, ProductSpace):
other_ops = set(other.operands)
else:
... | [
"def",
"intersect",
"(",
"self",
",",
"other",
")",
":",
"if",
"other",
"is",
"FullSpace",
":",
"return",
"self",
"if",
"other",
"is",
"TrivialSpace",
":",
"return",
"TrivialSpace",
"if",
"isinstance",
"(",
"other",
",",
"ProductSpace",
")",
":",
"other_op... | Find the mutual tensor factors of two Hilbert spaces. | [
"Find",
"the",
"mutual",
"tensor",
"factors",
"of",
"two",
"Hilbert",
"spaces",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/hilbert_space_algebra.py#L794-L805 |
45,774 | mabuchilab/QNET | src/qnet/printing/base.py | QnetBasePrinter._isinstance | def _isinstance(expr, classname):
"""Check whether `expr` is an instance of the class with name
`classname`
This is like the builtin `isinstance`, but it take the `classname` a
string, instead of the class directly. Useful for when we don't want to
import the class for which we ... | python | def _isinstance(expr, classname):
"""Check whether `expr` is an instance of the class with name
`classname`
This is like the builtin `isinstance`, but it take the `classname` a
string, instead of the class directly. Useful for when we don't want to
import the class for which we ... | [
"def",
"_isinstance",
"(",
"expr",
",",
"classname",
")",
":",
"for",
"cls",
"in",
"type",
"(",
"expr",
")",
".",
"__mro__",
":",
"if",
"cls",
".",
"__name__",
"==",
"classname",
":",
"return",
"True",
"return",
"False"
] | Check whether `expr` is an instance of the class with name
`classname`
This is like the builtin `isinstance`, but it take the `classname` a
string, instead of the class directly. Useful for when we don't want to
import the class for which we want to check (also, remember that
pr... | [
"Check",
"whether",
"expr",
"is",
"an",
"instance",
"of",
"the",
"class",
"with",
"name",
"classname"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/base.py#L99-L112 |
45,775 | mabuchilab/QNET | src/qnet/algebra/core/operator_algebra.py | decompose_space | def decompose_space(H, A):
"""Simplifies OperatorTrace expressions over tensor-product spaces by
turning it into iterated partial traces.
Args:
H (ProductSpace): The full space.
A (Operator):
Returns:
Operator: Iterative partial trace expression
"""
return OperatorTrace... | python | def decompose_space(H, A):
"""Simplifies OperatorTrace expressions over tensor-product spaces by
turning it into iterated partial traces.
Args:
H (ProductSpace): The full space.
A (Operator):
Returns:
Operator: Iterative partial trace expression
"""
return OperatorTrace... | [
"def",
"decompose_space",
"(",
"H",
",",
"A",
")",
":",
"return",
"OperatorTrace",
".",
"create",
"(",
"OperatorTrace",
".",
"create",
"(",
"A",
",",
"over_space",
"=",
"H",
".",
"operands",
"[",
"-",
"1",
"]",
")",
",",
"over_space",
"=",
"ProductSpac... | Simplifies OperatorTrace expressions over tensor-product spaces by
turning it into iterated partial traces.
Args:
H (ProductSpace): The full space.
A (Operator):
Returns:
Operator: Iterative partial trace expression | [
"Simplifies",
"OperatorTrace",
"expressions",
"over",
"tensor",
"-",
"product",
"spaces",
"by",
"turning",
"it",
"into",
"iterated",
"partial",
"traces",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/operator_algebra.py#L872-L885 |
45,776 | mabuchilab/QNET | src/qnet/algebra/core/operator_algebra.py | factor_coeff | def factor_coeff(cls, ops, kwargs):
"""Factor out coefficients of all factors."""
coeffs, nops = zip(*map(_coeff_term, ops))
coeff = 1
for c in coeffs:
coeff *= c
if coeff == 1:
return nops, coeffs
else:
return coeff * cls.create(*nops, **kwargs) | python | def factor_coeff(cls, ops, kwargs):
"""Factor out coefficients of all factors."""
coeffs, nops = zip(*map(_coeff_term, ops))
coeff = 1
for c in coeffs:
coeff *= c
if coeff == 1:
return nops, coeffs
else:
return coeff * cls.create(*nops, **kwargs) | [
"def",
"factor_coeff",
"(",
"cls",
",",
"ops",
",",
"kwargs",
")",
":",
"coeffs",
",",
"nops",
"=",
"zip",
"(",
"*",
"map",
"(",
"_coeff_term",
",",
"ops",
")",
")",
"coeff",
"=",
"1",
"for",
"c",
"in",
"coeffs",
":",
"coeff",
"*=",
"c",
"if",
... | Factor out coefficients of all factors. | [
"Factor",
"out",
"coefficients",
"of",
"all",
"factors",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/operator_algebra.py#L932-L941 |
45,777 | mabuchilab/QNET | src/qnet/algebra/core/operator_algebra.py | Commutator.doit | def doit(self, classes=None, recursive=True, **kwargs):
"""Write out commutator
Write out the commutator according to its definition
$[\Op{A}, \Op{B}] = \Op{A}\Op{B} - \Op{A}\Op{B}$.
See :meth:`.Expression.doit`.
"""
return super().doit(classes, recursive, **kwargs) | python | def doit(self, classes=None, recursive=True, **kwargs):
"""Write out commutator
Write out the commutator according to its definition
$[\Op{A}, \Op{B}] = \Op{A}\Op{B} - \Op{A}\Op{B}$.
See :meth:`.Expression.doit`.
"""
return super().doit(classes, recursive, **kwargs) | [
"def",
"doit",
"(",
"self",
",",
"classes",
"=",
"None",
",",
"recursive",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
")",
".",
"doit",
"(",
"classes",
",",
"recursive",
",",
"*",
"*",
"kwargs",
")"
] | Write out commutator
Write out the commutator according to its definition
$[\Op{A}, \Op{B}] = \Op{A}\Op{B} - \Op{A}\Op{B}$.
See :meth:`.Expression.doit`. | [
"Write",
"out",
"commutator"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/operator_algebra.py#L559-L567 |
45,778 | mabuchilab/QNET | src/qnet/printing/dot.py | _attrprint | def _attrprint(d, delimiter=', '):
"""Print a dictionary of attributes in the DOT format"""
return delimiter.join(('"%s"="%s"' % item) for item in sorted(d.items())) | python | def _attrprint(d, delimiter=', '):
"""Print a dictionary of attributes in the DOT format"""
return delimiter.join(('"%s"="%s"' % item) for item in sorted(d.items())) | [
"def",
"_attrprint",
"(",
"d",
",",
"delimiter",
"=",
"', '",
")",
":",
"return",
"delimiter",
".",
"join",
"(",
"(",
"'\"%s\"=\"%s\"'",
"%",
"item",
")",
"for",
"item",
"in",
"sorted",
"(",
"d",
".",
"items",
"(",
")",
")",
")"
] | Print a dictionary of attributes in the DOT format | [
"Print",
"a",
"dictionary",
"of",
"attributes",
"in",
"the",
"DOT",
"format"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/dot.py#L76-L78 |
45,779 | mabuchilab/QNET | src/qnet/printing/dot.py | _styleof | def _styleof(expr, styles):
"""Merge style dictionaries in order"""
style = dict()
for expr_filter, sty in styles:
if expr_filter(expr):
style.update(sty)
return style | python | def _styleof(expr, styles):
"""Merge style dictionaries in order"""
style = dict()
for expr_filter, sty in styles:
if expr_filter(expr):
style.update(sty)
return style | [
"def",
"_styleof",
"(",
"expr",
",",
"styles",
")",
":",
"style",
"=",
"dict",
"(",
")",
"for",
"expr_filter",
",",
"sty",
"in",
"styles",
":",
"if",
"expr_filter",
"(",
"expr",
")",
":",
"style",
".",
"update",
"(",
"sty",
")",
"return",
"style"
] | Merge style dictionaries in order | [
"Merge",
"style",
"dictionaries",
"in",
"order"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/dot.py#L81-L87 |
45,780 | mabuchilab/QNET | src/qnet/__init__.py | _git_version | def _git_version():
"""If installed with 'pip installe -e .' from inside a git repo, the
current git revision as a string"""
import subprocess
import os
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH']:
v = os.e... | python | def _git_version():
"""If installed with 'pip installe -e .' from inside a git repo, the
current git revision as a string"""
import subprocess
import os
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH']:
v = os.e... | [
"def",
"_git_version",
"(",
")",
":",
"import",
"subprocess",
"import",
"os",
"def",
"_minimal_ext_cmd",
"(",
"cmd",
")",
":",
"# construct minimal environment",
"env",
"=",
"{",
"}",
"for",
"k",
"in",
"[",
"'SYSTEMROOT'",
",",
"'PATH'",
"]",
":",
"v",
"="... | If installed with 'pip installe -e .' from inside a git repo, the
current git revision as a string | [
"If",
"installed",
"with",
"pip",
"installe",
"-",
"e",
".",
"from",
"inside",
"a",
"git",
"repo",
"the",
"current",
"git",
"revision",
"as",
"a",
"string"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/__init__.py#L23-L52 |
45,781 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | pad_with_identity | def pad_with_identity(circuit, k, n):
"""Pad a circuit by adding a `n`-channel identity circuit at index `k`
That is, a circuit of channel dimension $N$ is extended to one of channel
dimension $N+n$, where the channels $k$, $k+1$, ...$k+n-1$, just pass
through the system unaffected. E.g. let ``A``, ``... | python | def pad_with_identity(circuit, k, n):
"""Pad a circuit by adding a `n`-channel identity circuit at index `k`
That is, a circuit of channel dimension $N$ is extended to one of channel
dimension $N+n$, where the channels $k$, $k+1$, ...$k+n-1$, just pass
through the system unaffected. E.g. let ``A``, ``... | [
"def",
"pad_with_identity",
"(",
"circuit",
",",
"k",
",",
"n",
")",
":",
"circuit_n",
"=",
"circuit",
".",
"cdim",
"combined_circuit",
"=",
"circuit",
"+",
"circuit_identity",
"(",
"n",
")",
"permutation",
"=",
"(",
"list",
"(",
"range",
"(",
"k",
")",
... | Pad a circuit by adding a `n`-channel identity circuit at index `k`
That is, a circuit of channel dimension $N$ is extended to one of channel
dimension $N+n$, where the channels $k$, $k+1$, ...$k+n-1$, just pass
through the system unaffected. E.g. let ``A``, ``B`` be two single channel
systems::
... | [
"Pad",
"a",
"circuit",
"by",
"adding",
"a",
"n",
"-",
"channel",
"identity",
"circuit",
"at",
"index",
"k"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1421-L1452 |
45,782 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | move_drive_to_H | def move_drive_to_H(slh, which=None, expand_simplify=True):
r'''Move coherent drives from the Lindblad operators to the Hamiltonian.
For the given SLH model, move inhomogeneities in the Lindblad operators (resulting
from the presence of a coherent drive, see :class:`CoherentDriveCC`) to the
Hamiltonian... | python | def move_drive_to_H(slh, which=None, expand_simplify=True):
r'''Move coherent drives from the Lindblad operators to the Hamiltonian.
For the given SLH model, move inhomogeneities in the Lindblad operators (resulting
from the presence of a coherent drive, see :class:`CoherentDriveCC`) to the
Hamiltonian... | [
"def",
"move_drive_to_H",
"(",
"slh",
",",
"which",
"=",
"None",
",",
"expand_simplify",
"=",
"True",
")",
":",
"if",
"which",
"is",
"None",
":",
"which",
"=",
"[",
"]",
"scalarcs",
"=",
"[",
"]",
"for",
"jj",
",",
"L",
"in",
"enumerate",
"(",
"slh... | r'''Move coherent drives from the Lindblad operators to the Hamiltonian.
For the given SLH model, move inhomogeneities in the Lindblad operators (resulting
from the presence of a coherent drive, see :class:`CoherentDriveCC`) to the
Hamiltonian.
This exploits the invariance of the Lindblad master equat... | [
"r",
"Move",
"coherent",
"drives",
"from",
"the",
"Lindblad",
"operators",
"to",
"the",
"Hamiltonian",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1613-L1674 |
45,783 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | prepare_adiabatic_limit | def prepare_adiabatic_limit(slh, k=None):
"""Prepare the adiabatic elimination on an SLH object
Args:
slh: The SLH object to take the limit for
k: The scaling parameter $k \rightarrow \infty$. The default is a
positive symbol 'k'
Returns:
tuple: The objects ``Y, A, B, F... | python | def prepare_adiabatic_limit(slh, k=None):
"""Prepare the adiabatic elimination on an SLH object
Args:
slh: The SLH object to take the limit for
k: The scaling parameter $k \rightarrow \infty$. The default is a
positive symbol 'k'
Returns:
tuple: The objects ``Y, A, B, F... | [
"def",
"prepare_adiabatic_limit",
"(",
"slh",
",",
"k",
"=",
"None",
")",
":",
"if",
"k",
"is",
"None",
":",
"k",
"=",
"symbols",
"(",
"'k'",
",",
"positive",
"=",
"True",
")",
"Ld",
"=",
"slh",
".",
"L",
".",
"dag",
"(",
")",
"LdL",
"=",
"(",
... | Prepare the adiabatic elimination on an SLH object
Args:
slh: The SLH object to take the limit for
k: The scaling parameter $k \rightarrow \infty$. The default is a
positive symbol 'k'
Returns:
tuple: The objects ``Y, A, B, F, G, N``
necessary to compute the limitin... | [
"Prepare",
"the",
"adiabatic",
"elimination",
"on",
"an",
"SLH",
"object"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1677-L1698 |
45,784 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | eval_adiabatic_limit | def eval_adiabatic_limit(YABFGN, Ytilde, P0):
"""Compute the limiting SLH model for the adiabatic approximation
Args:
YABFGN: The tuple (Y, A, B, F, G, N)
as returned by prepare_adiabatic_limit.
Ytilde: The pseudo-inverse of Y, satisfying Y * Ytilde = P0.
P0: The projector o... | python | def eval_adiabatic_limit(YABFGN, Ytilde, P0):
"""Compute the limiting SLH model for the adiabatic approximation
Args:
YABFGN: The tuple (Y, A, B, F, G, N)
as returned by prepare_adiabatic_limit.
Ytilde: The pseudo-inverse of Y, satisfying Y * Ytilde = P0.
P0: The projector o... | [
"def",
"eval_adiabatic_limit",
"(",
"YABFGN",
",",
"Ytilde",
",",
"P0",
")",
":",
"Y",
",",
"A",
",",
"B",
",",
"F",
",",
"G",
",",
"N",
"=",
"YABFGN",
"Klim",
"=",
"(",
"P0",
"*",
"(",
"B",
"-",
"A",
"*",
"Ytilde",
"*",
"A",
")",
"*",
"P0"... | Compute the limiting SLH model for the adiabatic approximation
Args:
YABFGN: The tuple (Y, A, B, F, G, N)
as returned by prepare_adiabatic_limit.
Ytilde: The pseudo-inverse of Y, satisfying Y * Ytilde = P0.
P0: The projector onto the null-space of Y.
Returns:
SLH: L... | [
"Compute",
"the",
"limiting",
"SLH",
"model",
"for",
"the",
"adiabatic",
"approximation"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1701-L1723 |
45,785 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | try_adiabatic_elimination | def try_adiabatic_elimination(slh, k=None, fock_trunc=6, sub_P0=True):
"""Attempt to automatically do adiabatic elimination on an SLH object
This will project the `Y` operator onto a truncated basis with dimension
specified by `fock_trunc`. `sub_P0` controls whether an attempt is made to
replace the k... | python | def try_adiabatic_elimination(slh, k=None, fock_trunc=6, sub_P0=True):
"""Attempt to automatically do adiabatic elimination on an SLH object
This will project the `Y` operator onto a truncated basis with dimension
specified by `fock_trunc`. `sub_P0` controls whether an attempt is made to
replace the k... | [
"def",
"try_adiabatic_elimination",
"(",
"slh",
",",
"k",
"=",
"None",
",",
"fock_trunc",
"=",
"6",
",",
"sub_P0",
"=",
"True",
")",
":",
"ops",
"=",
"prepare_adiabatic_limit",
"(",
"slh",
",",
"k",
")",
"Y",
"=",
"ops",
"[",
"0",
"]",
"if",
"isinsta... | Attempt to automatically do adiabatic elimination on an SLH object
This will project the `Y` operator onto a truncated basis with dimension
specified by `fock_trunc`. `sub_P0` controls whether an attempt is made to
replace the kernel projector P0 by an :class:`.IdentityOperator`. | [
"Attempt",
"to",
"automatically",
"do",
"adiabatic",
"elimination",
"on",
"an",
"SLH",
"object"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L1726-L1775 |
45,786 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | Circuit.index_in_block | def index_in_block(self, channel_index: int) -> int:
"""Return the index a channel has within the subblock it belongs to
I.e., only for reducible circuits, this gives a result different from
the argument itself.
Args:
channel_index (int): The index of the external channel
... | python | def index_in_block(self, channel_index: int) -> int:
"""Return the index a channel has within the subblock it belongs to
I.e., only for reducible circuits, this gives a result different from
the argument itself.
Args:
channel_index (int): The index of the external channel
... | [
"def",
"index_in_block",
"(",
"self",
",",
"channel_index",
":",
"int",
")",
"->",
"int",
":",
"if",
"channel_index",
"<",
"0",
"or",
"channel_index",
">=",
"self",
".",
"cdim",
":",
"raise",
"ValueError",
"(",
")",
"struct",
"=",
"self",
".",
"block_str... | Return the index a channel has within the subblock it belongs to
I.e., only for reducible circuits, this gives a result different from
the argument itself.
Args:
channel_index (int): The index of the external channel
Raises:
ValueError: for an invalid `channel_... | [
"Return",
"the",
"index",
"a",
"channel",
"has",
"within",
"the",
"subblock",
"it",
"belongs",
"to"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L102-L128 |
45,787 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | Circuit.get_blocks | def get_blocks(self, block_structure=None):
"""For a reducible circuit, get a sequence of subblocks that when
concatenated again yield the original circuit. The block structure
given has to be compatible with the circuits actual block structure,
i.e. it can only be more coarse-grained.
... | python | def get_blocks(self, block_structure=None):
"""For a reducible circuit, get a sequence of subblocks that when
concatenated again yield the original circuit. The block structure
given has to be compatible with the circuits actual block structure,
i.e. it can only be more coarse-grained.
... | [
"def",
"get_blocks",
"(",
"self",
",",
"block_structure",
"=",
"None",
")",
":",
"if",
"block_structure",
"is",
"None",
":",
"block_structure",
"=",
"self",
".",
"block_structure",
"try",
":",
"return",
"self",
".",
"_get_blocks",
"(",
"block_structure",
")",
... | For a reducible circuit, get a sequence of subblocks that when
concatenated again yield the original circuit. The block structure
given has to be compatible with the circuits actual block structure,
i.e. it can only be more coarse-grained.
Args:
block_structure (tuple): The... | [
"For",
"a",
"reducible",
"circuit",
"get",
"a",
"sequence",
"of",
"subblocks",
"that",
"when",
"concatenated",
"again",
"yield",
"the",
"original",
"circuit",
".",
"The",
"block",
"structure",
"given",
"has",
"to",
"be",
"compatible",
"with",
"the",
"circuits"... | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L130-L152 |
45,788 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | Circuit.show | def show(self):
"""Show the circuit expression in an IPython notebook."""
# noinspection PyPackageRequirements
from IPython.display import Image, display
fname = self.render()
display(Image(filename=fname)) | python | def show(self):
"""Show the circuit expression in an IPython notebook."""
# noinspection PyPackageRequirements
from IPython.display import Image, display
fname = self.render()
display(Image(filename=fname)) | [
"def",
"show",
"(",
"self",
")",
":",
"# noinspection PyPackageRequirements",
"from",
"IPython",
".",
"display",
"import",
"Image",
",",
"display",
"fname",
"=",
"self",
".",
"render",
"(",
")",
"display",
"(",
"Image",
"(",
"filename",
"=",
"fname",
")",
... | Show the circuit expression in an IPython notebook. | [
"Show",
"the",
"circuit",
"expression",
"in",
"an",
"IPython",
"notebook",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L196-L203 |
45,789 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | Circuit.render | def render(self, fname=''):
"""Render the circuit expression and store the result in a file
Args:
fname (str): Path to an image file to store the result in.
Returns:
str: The path to the image file
"""
import qnet.visualization.circuit_pyx as circuit_vis... | python | def render(self, fname=''):
"""Render the circuit expression and store the result in a file
Args:
fname (str): Path to an image file to store the result in.
Returns:
str: The path to the image file
"""
import qnet.visualization.circuit_pyx as circuit_vis... | [
"def",
"render",
"(",
"self",
",",
"fname",
"=",
"''",
")",
":",
"import",
"qnet",
".",
"visualization",
".",
"circuit_pyx",
"as",
"circuit_visualization",
"from",
"tempfile",
"import",
"gettempdir",
"from",
"time",
"import",
"time",
",",
"sleep",
"if",
"not... | Render the circuit expression and store the result in a file
Args:
fname (str): Path to an image file to store the result in.
Returns:
str: The path to the image file | [
"Render",
"the",
"circuit",
"expression",
"and",
"store",
"the",
"result",
"in",
"a",
"file"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L205-L235 |
45,790 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | SLH.space | def space(self):
"""Total Hilbert space"""
args_spaces = (self.S.space, self.L.space, self.H.space)
return ProductSpace.create(*args_spaces) | python | def space(self):
"""Total Hilbert space"""
args_spaces = (self.S.space, self.L.space, self.H.space)
return ProductSpace.create(*args_spaces) | [
"def",
"space",
"(",
"self",
")",
":",
"args_spaces",
"=",
"(",
"self",
".",
"S",
".",
"space",
",",
"self",
".",
"L",
".",
"space",
",",
"self",
".",
"H",
".",
"space",
")",
"return",
"ProductSpace",
".",
"create",
"(",
"*",
"args_spaces",
")"
] | Total Hilbert space | [
"Total",
"Hilbert",
"space"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L368-L371 |
45,791 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | SLH.free_symbols | def free_symbols(self):
"""Set of all symbols occcuring in S, L, or H"""
return set.union(
self.S.free_symbols, self.L.free_symbols, self.H.free_symbols) | python | def free_symbols(self):
"""Set of all symbols occcuring in S, L, or H"""
return set.union(
self.S.free_symbols, self.L.free_symbols, self.H.free_symbols) | [
"def",
"free_symbols",
"(",
"self",
")",
":",
"return",
"set",
".",
"union",
"(",
"self",
".",
"S",
".",
"free_symbols",
",",
"self",
".",
"L",
".",
"free_symbols",
",",
"self",
".",
"H",
".",
"free_symbols",
")"
] | Set of all symbols occcuring in S, L, or H | [
"Set",
"of",
"all",
"symbols",
"occcuring",
"in",
"S",
"L",
"or",
"H"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L374-L377 |
45,792 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | SLH.expand | def expand(self):
"""Expand out all operator expressions within S, L and H
Return a new :class:`SLH` object with these expanded expressions.
"""
return SLH(self.S.expand(), self.L.expand(), self.H.expand()) | python | def expand(self):
"""Expand out all operator expressions within S, L and H
Return a new :class:`SLH` object with these expanded expressions.
"""
return SLH(self.S.expand(), self.L.expand(), self.H.expand()) | [
"def",
"expand",
"(",
"self",
")",
":",
"return",
"SLH",
"(",
"self",
".",
"S",
".",
"expand",
"(",
")",
",",
"self",
".",
"L",
".",
"expand",
"(",
")",
",",
"self",
".",
"H",
".",
"expand",
"(",
")",
")"
] | Expand out all operator expressions within S, L and H
Return a new :class:`SLH` object with these expanded expressions. | [
"Expand",
"out",
"all",
"operator",
"expressions",
"within",
"S",
"L",
"and",
"H"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L419-L424 |
45,793 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | SLH.simplify_scalar | def simplify_scalar(self, func=sympy.simplify):
"""Simplify all scalar expressions within S, L and H
Return a new :class:`SLH` object with the simplified expressions.
See also: :meth:`.QuantumExpression.simplify_scalar`
"""
return SLH(
self.S.simplify_scalar(func=fu... | python | def simplify_scalar(self, func=sympy.simplify):
"""Simplify all scalar expressions within S, L and H
Return a new :class:`SLH` object with the simplified expressions.
See also: :meth:`.QuantumExpression.simplify_scalar`
"""
return SLH(
self.S.simplify_scalar(func=fu... | [
"def",
"simplify_scalar",
"(",
"self",
",",
"func",
"=",
"sympy",
".",
"simplify",
")",
":",
"return",
"SLH",
"(",
"self",
".",
"S",
".",
"simplify_scalar",
"(",
"func",
"=",
"func",
")",
",",
"self",
".",
"L",
".",
"simplify_scalar",
"(",
"func",
"=... | Simplify all scalar expressions within S, L and H
Return a new :class:`SLH` object with the simplified expressions.
See also: :meth:`.QuantumExpression.simplify_scalar` | [
"Simplify",
"all",
"scalar",
"expressions",
"within",
"S",
"L",
"and",
"H"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L426-L436 |
45,794 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | SLH.symbolic_master_equation | def symbolic_master_equation(self, rho=None):
"""Compute the symbolic Liouvillian acting on a state rho
If no rho is given, an OperatorSymbol is created in its place.
This correspnds to the RHS of the master equation
in which an average is taken over the external noise degrees of
... | python | def symbolic_master_equation(self, rho=None):
"""Compute the symbolic Liouvillian acting on a state rho
If no rho is given, an OperatorSymbol is created in its place.
This correspnds to the RHS of the master equation
in which an average is taken over the external noise degrees of
... | [
"def",
"symbolic_master_equation",
"(",
"self",
",",
"rho",
"=",
"None",
")",
":",
"L",
",",
"H",
"=",
"self",
".",
"L",
",",
"self",
".",
"H",
"if",
"rho",
"is",
"None",
":",
"rho",
"=",
"OperatorSymbol",
"(",
"'rho'",
",",
"hs",
"=",
"self",
".... | Compute the symbolic Liouvillian acting on a state rho
If no rho is given, an OperatorSymbol is created in its place.
This correspnds to the RHS of the master equation
in which an average is taken over the external noise degrees of
freedom.
Args:
rho (Operator): A s... | [
"Compute",
"the",
"symbolic",
"Liouvillian",
"acting",
"on",
"a",
"state",
"rho"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L501-L522 |
45,795 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | SLH.symbolic_heisenberg_eom | def symbolic_heisenberg_eom(
self, X=None, noises=None, expand_simplify=True):
"""Compute the symbolic Heisenberg equations of motion of a system
operator X. If no X is given, an OperatorSymbol is created in its
place. If no noises are given, this correspnds to the
ensemble... | python | def symbolic_heisenberg_eom(
self, X=None, noises=None, expand_simplify=True):
"""Compute the symbolic Heisenberg equations of motion of a system
operator X. If no X is given, an OperatorSymbol is created in its
place. If no noises are given, this correspnds to the
ensemble... | [
"def",
"symbolic_heisenberg_eom",
"(",
"self",
",",
"X",
"=",
"None",
",",
"noises",
"=",
"None",
",",
"expand_simplify",
"=",
"True",
")",
":",
"L",
",",
"H",
"=",
"self",
".",
"L",
",",
"self",
".",
"H",
"if",
"X",
"is",
"None",
":",
"X",
"=",
... | Compute the symbolic Heisenberg equations of motion of a system
operator X. If no X is given, an OperatorSymbol is created in its
place. If no noises are given, this correspnds to the
ensemble-averaged Heisenberg equation of motion.
Args:
X (Operator): A system operator
... | [
"Compute",
"the",
"symbolic",
"Heisenberg",
"equations",
"of",
"motion",
"of",
"a",
"system",
"operator",
"X",
".",
"If",
"no",
"X",
"is",
"given",
"an",
"OperatorSymbol",
"is",
"created",
"in",
"its",
"place",
".",
"If",
"no",
"noises",
"are",
"given",
... | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L524-L566 |
45,796 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | CPermutation.block_perms | def block_perms(self):
"""If the circuit is reducible into permutations within subranges of
the full range of channels, this yields a tuple with the internal
permutations for each such block.
:type: tuple
"""
if not self._block_perms:
self._block_perms = perm... | python | def block_perms(self):
"""If the circuit is reducible into permutations within subranges of
the full range of channels, this yields a tuple with the internal
permutations for each such block.
:type: tuple
"""
if not self._block_perms:
self._block_perms = perm... | [
"def",
"block_perms",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_block_perms",
":",
"self",
".",
"_block_perms",
"=",
"permutation_to_block_permutations",
"(",
"self",
".",
"permutation",
")",
"return",
"self",
".",
"_block_perms"
] | If the circuit is reducible into permutations within subranges of
the full range of channels, this yields a tuple with the internal
permutations for each such block.
:type: tuple | [
"If",
"the",
"circuit",
"is",
"reducible",
"into",
"permutations",
"within",
"subranges",
"of",
"the",
"full",
"range",
"of",
"channels",
"this",
"yields",
"a",
"tuple",
"with",
"the",
"internal",
"permutations",
"for",
"each",
"such",
"block",
"."
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L794-L804 |
45,797 | mabuchilab/QNET | src/qnet/algebra/core/circuit_algebra.py | CPermutation.series_with_permutation | def series_with_permutation(self, other):
"""Compute the series product with another channel permutation circuit
Args:
other (CPermutation):
Returns:
Circuit: The composite permutation circuit (could also be the
identity circuit for n channels)
"... | python | def series_with_permutation(self, other):
"""Compute the series product with another channel permutation circuit
Args:
other (CPermutation):
Returns:
Circuit: The composite permutation circuit (could also be the
identity circuit for n channels)
"... | [
"def",
"series_with_permutation",
"(",
"self",
",",
"other",
")",
":",
"combined_permutation",
"=",
"tuple",
"(",
"[",
"self",
".",
"permutation",
"[",
"p",
"]",
"for",
"p",
"in",
"other",
".",
"permutation",
"]",
")",
"return",
"CPermutation",
".",
"creat... | Compute the series product with another channel permutation circuit
Args:
other (CPermutation):
Returns:
Circuit: The composite permutation circuit (could also be the
identity circuit for n channels) | [
"Compute",
"the",
"series",
"product",
"with",
"another",
"channel",
"permutation",
"circuit"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/algebra/core/circuit_algebra.py#L822-L834 |
45,798 | niloch/iplotter | iplotter/chartjs_plotter.py | ChartJSPlotter.save | def save(self,
data,
chart_type,
options=None,
filename='chart',
w=800,
h=420,
overwrite=True):
"""Save the rendered html to a file in the same directory as the notebook."""
html = self.render(
data=da... | python | def save(self,
data,
chart_type,
options=None,
filename='chart',
w=800,
h=420,
overwrite=True):
"""Save the rendered html to a file in the same directory as the notebook."""
html = self.render(
data=da... | [
"def",
"save",
"(",
"self",
",",
"data",
",",
"chart_type",
",",
"options",
"=",
"None",
",",
"filename",
"=",
"'chart'",
",",
"w",
"=",
"800",
",",
"h",
"=",
"420",
",",
"overwrite",
"=",
"True",
")",
":",
"html",
"=",
"self",
".",
"render",
"("... | Save the rendered html to a file in the same directory as the notebook. | [
"Save",
"the",
"rendered",
"html",
"to",
"a",
"file",
"in",
"the",
"same",
"directory",
"as",
"the",
"notebook",
"."
] | 0403486d8633f601a33c4d2b9c9fa3ec88e9327b | https://github.com/niloch/iplotter/blob/0403486d8633f601a33c4d2b9c9fa3ec88e9327b/iplotter/chartjs_plotter.py#L79-L105 |
45,799 | mabuchilab/QNET | src/qnet/printing/_unicode_mappings.py | _unicode_sub_super | def _unicode_sub_super(string, mapping, max_len=None):
"""Try to render a subscript or superscript string in unicode, fall back on
ascii if this is not possible"""
string = str(string)
if string.startswith('(') and string.endswith(')'):
len_string = len(string) - 2
else:
len_string =... | python | def _unicode_sub_super(string, mapping, max_len=None):
"""Try to render a subscript or superscript string in unicode, fall back on
ascii if this is not possible"""
string = str(string)
if string.startswith('(') and string.endswith(')'):
len_string = len(string) - 2
else:
len_string =... | [
"def",
"_unicode_sub_super",
"(",
"string",
",",
"mapping",
",",
"max_len",
"=",
"None",
")",
":",
"string",
"=",
"str",
"(",
"string",
")",
"if",
"string",
".",
"startswith",
"(",
"'('",
")",
"and",
"string",
".",
"endswith",
"(",
"')'",
")",
":",
"... | Try to render a subscript or superscript string in unicode, fall back on
ascii if this is not possible | [
"Try",
"to",
"render",
"a",
"subscript",
"or",
"superscript",
"string",
"in",
"unicode",
"fall",
"back",
"on",
"ascii",
"if",
"this",
"is",
"not",
"possible"
] | cc20d26dad78691d34c67173e5cd67dcac94208a | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/printing/_unicode_mappings.py#L123-L137 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.