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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
49,200 | mperlet/PyDect200 | PyDect200/PyDect200.py | PyDect200.switch_onoff | def switch_onoff(self, device, status):
"""Switch a Socket"""
if status == 1 or status == True or status == '1':
return self.switch_on(device)
else:
return self.switch_off(device) | python | def switch_onoff(self, device, status):
"""Switch a Socket"""
if status == 1 or status == True or status == '1':
return self.switch_on(device)
else:
return self.switch_off(device) | [
"def",
"switch_onoff",
"(",
"self",
",",
"device",
",",
"status",
")",
":",
"if",
"status",
"==",
"1",
"or",
"status",
"==",
"True",
"or",
"status",
"==",
"'1'",
":",
"return",
"self",
".",
"switch_on",
"(",
"device",
")",
"else",
":",
"return",
"sel... | Switch a Socket | [
"Switch",
"a",
"Socket"
] | 4758d80c663324a612c2772e6442db1472016913 | https://github.com/mperlet/PyDect200/blob/4758d80c663324a612c2772e6442db1472016913/PyDect200/PyDect200.py#L123-L128 |
49,201 | mperlet/PyDect200 | PyDect200/PyDect200.py | PyDect200.switch_toggle | def switch_toggle(self, device):
"""Toggles the current state of the given device"""
state = self.get_state(device)
if(state == '1'):
return self.switch_off(device)
elif(state == '0'):
return self.switch_on(device)
else:
return state | python | def switch_toggle(self, device):
"""Toggles the current state of the given device"""
state = self.get_state(device)
if(state == '1'):
return self.switch_off(device)
elif(state == '0'):
return self.switch_on(device)
else:
return state | [
"def",
"switch_toggle",
"(",
"self",
",",
"device",
")",
":",
"state",
"=",
"self",
".",
"get_state",
"(",
"device",
")",
"if",
"(",
"state",
"==",
"'1'",
")",
":",
"return",
"self",
".",
"switch_off",
"(",
"device",
")",
"elif",
"(",
"state",
"==",
... | Toggles the current state of the given device | [
"Toggles",
"the",
"current",
"state",
"of",
"the",
"given",
"device"
] | 4758d80c663324a612c2772e6442db1472016913 | https://github.com/mperlet/PyDect200/blob/4758d80c663324a612c2772e6442db1472016913/PyDect200/PyDect200.py#L130-L139 |
49,202 | mperlet/PyDect200 | PyDect200/PyDect200.py | PyDect200.get_power | def get_power(self):
"""Returns the Power in Watt"""
power_dict = self.get_power_all()
for device in power_dict.keys():
power_dict[device] = float(power_dict[device]) / 1000.0
return power_dict | python | def get_power(self):
"""Returns the Power in Watt"""
power_dict = self.get_power_all()
for device in power_dict.keys():
power_dict[device] = float(power_dict[device]) / 1000.0
return power_dict | [
"def",
"get_power",
"(",
"self",
")",
":",
"power_dict",
"=",
"self",
".",
"get_power_all",
"(",
")",
"for",
"device",
"in",
"power_dict",
".",
"keys",
"(",
")",
":",
"power_dict",
"[",
"device",
"]",
"=",
"float",
"(",
"power_dict",
"[",
"device",
"]"... | Returns the Power in Watt | [
"Returns",
"the",
"Power",
"in",
"Watt"
] | 4758d80c663324a612c2772e6442db1472016913 | https://github.com/mperlet/PyDect200/blob/4758d80c663324a612c2772e6442db1472016913/PyDect200/PyDect200.py#L141-L146 |
49,203 | mperlet/PyDect200 | PyDect200/PyDect200.py | PyDect200.get_device_names | def get_device_names(self):
"""Returns a Dict with devicenames"""
dev_names = {}
for device in self.get_device_ids():
dev_names[device] = self.get_device_name(device)
return dev_names | python | def get_device_names(self):
"""Returns a Dict with devicenames"""
dev_names = {}
for device in self.get_device_ids():
dev_names[device] = self.get_device_name(device)
return dev_names | [
"def",
"get_device_names",
"(",
"self",
")",
":",
"dev_names",
"=",
"{",
"}",
"for",
"device",
"in",
"self",
".",
"get_device_ids",
"(",
")",
":",
"dev_names",
"[",
"device",
"]",
"=",
"self",
".",
"get_device_name",
"(",
"device",
")",
"return",
"dev_na... | Returns a Dict with devicenames | [
"Returns",
"a",
"Dict",
"with",
"devicenames"
] | 4758d80c663324a612c2772e6442db1472016913 | https://github.com/mperlet/PyDect200/blob/4758d80c663324a612c2772e6442db1472016913/PyDect200/PyDect200.py#L152-L157 |
49,204 | mperlet/PyDect200 | PyDect200/PyDect200.py | PyDect200.get_power_all | def get_power_all(self):
"""Returns the power in mW for all devices"""
power_dict = {}
for device in self.get_device_names().keys():
power_dict[device] = self.get_power_single(device)
return power_dict | python | def get_power_all(self):
"""Returns the power in mW for all devices"""
power_dict = {}
for device in self.get_device_names().keys():
power_dict[device] = self.get_power_single(device)
return power_dict | [
"def",
"get_power_all",
"(",
"self",
")",
":",
"power_dict",
"=",
"{",
"}",
"for",
"device",
"in",
"self",
".",
"get_device_names",
"(",
")",
".",
"keys",
"(",
")",
":",
"power_dict",
"[",
"device",
"]",
"=",
"self",
".",
"get_power_single",
"(",
"devi... | Returns the power in mW for all devices | [
"Returns",
"the",
"power",
"in",
"mW",
"for",
"all",
"devices"
] | 4758d80c663324a612c2772e6442db1472016913 | https://github.com/mperlet/PyDect200/blob/4758d80c663324a612c2772e6442db1472016913/PyDect200/PyDect200.py#L178-L183 |
49,205 | mperlet/PyDect200 | PyDect200/PyDect200.py | PyDect200.get_state_all | def get_state_all(self):
"""Returns all device states"""
state_dict = {}
for device in self.get_device_names().keys():
state_dict[device] = self.get_state(device)
return state_dict | python | def get_state_all(self):
"""Returns all device states"""
state_dict = {}
for device in self.get_device_names().keys():
state_dict[device] = self.get_state(device)
return state_dict | [
"def",
"get_state_all",
"(",
"self",
")",
":",
"state_dict",
"=",
"{",
"}",
"for",
"device",
"in",
"self",
".",
"get_device_names",
"(",
")",
".",
"keys",
"(",
")",
":",
"state_dict",
"[",
"device",
"]",
"=",
"self",
".",
"get_state",
"(",
"device",
... | Returns all device states | [
"Returns",
"all",
"device",
"states"
] | 4758d80c663324a612c2772e6442db1472016913 | https://github.com/mperlet/PyDect200/blob/4758d80c663324a612c2772e6442db1472016913/PyDect200/PyDect200.py#L199-L204 |
49,206 | inveniosoftware/invenio-base | invenio_base/cli.py | list_entrypoints | def list_entrypoints(entry_point):
"""List defined entry points."""
found_entry_points = {}
for dist in working_set:
entry_map = dist.get_entry_map()
for group_name, entry_points in entry_map.items():
# Filter entry points
if entry_point is None and \
n... | python | def list_entrypoints(entry_point):
"""List defined entry points."""
found_entry_points = {}
for dist in working_set:
entry_map = dist.get_entry_map()
for group_name, entry_points in entry_map.items():
# Filter entry points
if entry_point is None and \
n... | [
"def",
"list_entrypoints",
"(",
"entry_point",
")",
":",
"found_entry_points",
"=",
"{",
"}",
"for",
"dist",
"in",
"working_set",
":",
"entry_map",
"=",
"dist",
".",
"get_entry_map",
"(",
")",
"for",
"group_name",
",",
"entry_points",
"in",
"entry_map",
".",
... | List defined entry points. | [
"List",
"defined",
"entry",
"points",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/cli.py#L46-L69 |
49,207 | inveniosoftware/invenio-base | invenio_base/cli.py | migrate_secret_key | def migrate_secret_key(old_key):
"""Call entry points exposed for the SECRET_KEY change."""
if 'SECRET_KEY' not in current_app.config or \
current_app.config['SECRET_KEY'] is None:
raise click.ClickException(
'SECRET_KEY is not set in the configuration.')
for ep in iter_entr... | python | def migrate_secret_key(old_key):
"""Call entry points exposed for the SECRET_KEY change."""
if 'SECRET_KEY' not in current_app.config or \
current_app.config['SECRET_KEY'] is None:
raise click.ClickException(
'SECRET_KEY is not set in the configuration.')
for ep in iter_entr... | [
"def",
"migrate_secret_key",
"(",
"old_key",
")",
":",
"if",
"'SECRET_KEY'",
"not",
"in",
"current_app",
".",
"config",
"or",
"current_app",
".",
"config",
"[",
"'SECRET_KEY'",
"]",
"is",
"None",
":",
"raise",
"click",
".",
"ClickException",
"(",
"'SECRET_KEY ... | Call entry points exposed for the SECRET_KEY change. | [
"Call",
"entry",
"points",
"exposed",
"for",
"the",
"SECRET_KEY",
"change",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/cli.py#L75-L89 |
49,208 | inveniosoftware/invenio-base | invenio_base/cli.py | generate_secret_key | def generate_secret_key():
"""Generate secret key."""
import string
import random
rng = random.SystemRandom()
return ''.join(
rng.choice(string.ascii_letters + string.digits)
for dummy in range(0, 256)
) | python | def generate_secret_key():
"""Generate secret key."""
import string
import random
rng = random.SystemRandom()
return ''.join(
rng.choice(string.ascii_letters + string.digits)
for dummy in range(0, 256)
) | [
"def",
"generate_secret_key",
"(",
")",
":",
"import",
"string",
"import",
"random",
"rng",
"=",
"random",
".",
"SystemRandom",
"(",
")",
"return",
"''",
".",
"join",
"(",
"rng",
".",
"choice",
"(",
"string",
".",
"ascii_letters",
"+",
"string",
".",
"di... | Generate secret key. | [
"Generate",
"secret",
"key",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/cli.py#L92-L101 |
49,209 | idlesign/django-sitemetrics | sitemetrics/utils.py | get_provider_choices | def get_provider_choices():
"""Returns a list of currently available metrics providers
suitable for use as model fields choices.
"""
choices = []
for provider in METRICS_PROVIDERS:
choices.append((provider.alias, provider.title))
return choices | python | def get_provider_choices():
"""Returns a list of currently available metrics providers
suitable for use as model fields choices.
"""
choices = []
for provider in METRICS_PROVIDERS:
choices.append((provider.alias, provider.title))
return choices | [
"def",
"get_provider_choices",
"(",
")",
":",
"choices",
"=",
"[",
"]",
"for",
"provider",
"in",
"METRICS_PROVIDERS",
":",
"choices",
".",
"append",
"(",
"(",
"provider",
".",
"alias",
",",
"provider",
".",
"title",
")",
")",
"return",
"choices"
] | Returns a list of currently available metrics providers
suitable for use as model fields choices. | [
"Returns",
"a",
"list",
"of",
"currently",
"available",
"metrics",
"providers",
"suitable",
"for",
"use",
"as",
"model",
"fields",
"choices",
"."
] | be5d6b8a607d9662e91c5919dca971cd3eb665ff | https://github.com/idlesign/django-sitemetrics/blob/be5d6b8a607d9662e91c5919dca971cd3eb665ff/sitemetrics/utils.py#L4-L12 |
49,210 | xsleonard/pystmark | pystmark.py | send_batch | def send_batch(messages, api_key=None, secure=None, test=None, **request_args):
'''Send a batch of messages.
:param messages: Messages to send.
:type message: A list of `dict` or :class:`Message`
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https ... | python | def send_batch(messages, api_key=None, secure=None, test=None, **request_args):
'''Send a batch of messages.
:param messages: Messages to send.
:type message: A list of `dict` or :class:`Message`
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https ... | [
"def",
"send_batch",
"(",
"messages",
",",
"api_key",
"=",
"None",
",",
"secure",
"=",
"None",
",",
"test",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"return",
"_default_pyst_batch_sender",
".",
"send",
"(",
"messages",
"=",
"messages",
",",
... | Send a batch of messages.
:param messages: Messages to send.
:type message: A list of `dict` or :class:`Message`
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postma... | [
"Send",
"a",
"batch",
"of",
"messages",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L123-L138 |
49,211 | xsleonard/pystmark | pystmark.py | get_delivery_stats | def get_delivery_stats(api_key=None, secure=None, test=None, **request_args):
'''Get delivery stats for your Postmark account.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use ... | python | def get_delivery_stats(api_key=None, secure=None, test=None, **request_args):
'''Get delivery stats for your Postmark account.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use ... | [
"def",
"get_delivery_stats",
"(",
"api_key",
"=",
"None",
",",
"secure",
"=",
"None",
",",
"test",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"return",
"_default_delivery_stats",
".",
"get",
"(",
"api_key",
"=",
"api_key",
",",
"secure",
"=",
... | Get delivery stats for your Postmark account.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postmark Test API. Defaults to `False`.
:param \*\*request_args: Keyword argu... | [
"Get",
"delivery",
"stats",
"for",
"your",
"Postmark",
"account",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L141-L153 |
49,212 | xsleonard/pystmark | pystmark.py | get_bounces | def get_bounces(api_key=None, secure=None, test=None, **request_args):
'''Get a paginated list of bounces.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postmark Test AP... | python | def get_bounces(api_key=None, secure=None, test=None, **request_args):
'''Get a paginated list of bounces.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postmark Test AP... | [
"def",
"get_bounces",
"(",
"api_key",
"=",
"None",
",",
"secure",
"=",
"None",
",",
"test",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"return",
"_default_bounces",
".",
"get",
"(",
"api_key",
"=",
"api_key",
",",
"secure",
"=",
"secure",
",... | Get a paginated list of bounces.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postmark Test API. Defaults to `False`.
:param \*\*request_args: Keyword arguments to pass... | [
"Get",
"a",
"paginated",
"list",
"of",
"bounces",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L156-L168 |
49,213 | xsleonard/pystmark | pystmark.py | get_bounce | def get_bounce(bounce_id, api_key=None, secure=None, test=None,
**request_args):
'''Get a single bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme f... | python | def get_bounce(bounce_id, api_key=None, secure=None, test=None,
**request_args):
'''Get a single bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme f... | [
"def",
"get_bounce",
"(",
"bounce_id",
",",
"api_key",
"=",
"None",
",",
"secure",
"=",
"None",
",",
"test",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"return",
"_default_bounce",
".",
"get",
"(",
"bounce_id",
",",
"api_key",
"=",
"api_key",
... | Get a single bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postmark Test API. Defaults to... | [
"Get",
"a",
"single",
"bounce",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L171-L185 |
49,214 | xsleonard/pystmark | pystmark.py | get_bounce_dump | def get_bounce_dump(bounce_id, api_key=None, secure=None, test=None,
**request_args):
'''Get the raw email dump for a single bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:par... | python | def get_bounce_dump(bounce_id, api_key=None, secure=None, test=None,
**request_args):
'''Get the raw email dump for a single bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:par... | [
"def",
"get_bounce_dump",
"(",
"bounce_id",
",",
"api_key",
"=",
"None",
",",
"secure",
"=",
"None",
",",
"test",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"return",
"_default_bounce_dump",
".",
"get",
"(",
"bounce_id",
",",
"api_key",
"=",
"... | Get the raw email dump for a single bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postmar... | [
"Get",
"the",
"raw",
"email",
"dump",
"for",
"a",
"single",
"bounce",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L188-L202 |
49,215 | xsleonard/pystmark | pystmark.py | get_bounce_tags | def get_bounce_tags(api_key=None, secure=None, test=None, **request_args):
'''Get a list of tags for bounces associated with your Postmark server.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
... | python | def get_bounce_tags(api_key=None, secure=None, test=None, **request_args):
'''Get a list of tags for bounces associated with your Postmark server.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
... | [
"def",
"get_bounce_tags",
"(",
"api_key",
"=",
"None",
",",
"secure",
"=",
"None",
",",
"test",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"return",
"_default_bounce_tags",
".",
"get",
"(",
"api_key",
"=",
"api_key",
",",
"secure",
"=",
"secur... | Get a list of tags for bounces associated with your Postmark server.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postmark Test API. Defaults to `False`.
:param \*\*req... | [
"Get",
"a",
"list",
"of",
"tags",
"for",
"bounces",
"associated",
"with",
"your",
"Postmark",
"server",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L205-L217 |
49,216 | xsleonard/pystmark | pystmark.py | activate_bounce | def activate_bounce(bounce_id, api_key=None, secure=None, test=None,
**request_args):
'''Activate a deactivated bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Us... | python | def activate_bounce(bounce_id, api_key=None, secure=None, test=None,
**request_args):
'''Activate a deactivated bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Us... | [
"def",
"activate_bounce",
"(",
"bounce_id",
",",
"api_key",
"=",
"None",
",",
"secure",
"=",
"None",
",",
"test",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"return",
"_default_bounce_activate",
".",
"activate",
"(",
"bounce_id",
",",
"api_key",
... | Activate a deactivated bounce.
:param bounce_id: The bounce's id. Get the id with :func:`get_bounces`.
:param api_key: Your Postmark API key. Required, if `test` is not `True`.
:param secure: Use the https scheme for the Postmark API.
Defaults to `True`
:param test: Use the Postmark Test API. D... | [
"Activate",
"a",
"deactivated",
"bounce",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L220-L235 |
49,217 | xsleonard/pystmark | pystmark.py | Message.data | def data(self):
'''Returns data formatted for a POST request to the Postmark send API.
:rtype: `dict`
'''
d = {}
for val, key in self._fields.items():
val = getattr(self, val)
if val is not None:
d[key] = val
return d | python | def data(self):
'''Returns data formatted for a POST request to the Postmark send API.
:rtype: `dict`
'''
d = {}
for val, key in self._fields.items():
val = getattr(self, val)
if val is not None:
d[key] = val
return d | [
"def",
"data",
"(",
"self",
")",
":",
"d",
"=",
"{",
"}",
"for",
"val",
",",
"key",
"in",
"self",
".",
"_fields",
".",
"items",
"(",
")",
":",
"val",
"=",
"getattr",
"(",
"self",
",",
"val",
")",
"if",
"val",
"is",
"not",
"None",
":",
"d",
... | Returns data formatted for a POST request to the Postmark send API.
:rtype: `dict` | [
"Returns",
"data",
"formatted",
"for",
"a",
"POST",
"request",
"to",
"the",
"Postmark",
"send",
"API",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L321-L331 |
49,218 | xsleonard/pystmark | pystmark.py | Message.add_header | def add_header(self, name, value):
'''Attach an email header to send with the message.
:param name: The name of the header value.
:param value: The header value.
'''
if self.headers is None:
self.headers = []
self.headers.append(dict(Name=name, Value=value)) | python | def add_header(self, name, value):
'''Attach an email header to send with the message.
:param name: The name of the header value.
:param value: The header value.
'''
if self.headers is None:
self.headers = []
self.headers.append(dict(Name=name, Value=value)) | [
"def",
"add_header",
"(",
"self",
",",
"name",
",",
"value",
")",
":",
"if",
"self",
".",
"headers",
"is",
"None",
":",
"self",
".",
"headers",
"=",
"[",
"]",
"self",
".",
"headers",
".",
"append",
"(",
"dict",
"(",
"Name",
"=",
"name",
",",
"Val... | Attach an email header to send with the message.
:param name: The name of the header value.
:param value: The header value. | [
"Attach",
"an",
"email",
"header",
"to",
"send",
"with",
"the",
"message",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L379-L387 |
49,219 | xsleonard/pystmark | pystmark.py | Message.attach_binary | def attach_binary(self, data, filename, content_type=None,
content_id=None):
'''Attach a file to the message given raw binary data.
:param data: Raw data to attach to the message.
:param filename: Name of the file for the data.
:param content_type: mimetype of the ... | python | def attach_binary(self, data, filename, content_type=None,
content_id=None):
'''Attach a file to the message given raw binary data.
:param data: Raw data to attach to the message.
:param filename: Name of the file for the data.
:param content_type: mimetype of the ... | [
"def",
"attach_binary",
"(",
"self",
",",
"data",
",",
"filename",
",",
"content_type",
"=",
"None",
",",
"content_id",
"=",
"None",
")",
":",
"if",
"self",
".",
"attachments",
"is",
"None",
":",
"self",
".",
"attachments",
"=",
"[",
"]",
"if",
"conten... | Attach a file to the message given raw binary data.
:param data: Raw data to attach to the message.
:param filename: Name of the file for the data.
:param content_type: mimetype of the data. It will be guessed from the
filename if not provided.
:param content_id: ContentID U... | [
"Attach",
"a",
"file",
"to",
"the",
"message",
"given",
"raw",
"binary",
"data",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L389-L416 |
49,220 | xsleonard/pystmark | pystmark.py | Message.attach_file | def attach_file(self, filename, content_type=None,
content_id=None):
'''Attach a file to the message given a filename.
:param filename: Name of the file to attach.
:param content_type: mimetype of the data. It will be guessed from the
filename if not provided.
... | python | def attach_file(self, filename, content_type=None,
content_id=None):
'''Attach a file to the message given a filename.
:param filename: Name of the file to attach.
:param content_type: mimetype of the data. It will be guessed from the
filename if not provided.
... | [
"def",
"attach_file",
"(",
"self",
",",
"filename",
",",
"content_type",
"=",
"None",
",",
"content_id",
"=",
"None",
")",
":",
"# Open the file, grab the filename, detect content type",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filename",
")",
"if"... | Attach a file to the message given a filename.
:param filename: Name of the file to attach.
:param content_type: mimetype of the data. It will be guessed from the
filename if not provided.
:param content_id: ContentID URL of the attachment. A RFC 2392-
compliant URL for... | [
"Attach",
"a",
"file",
"to",
"the",
"message",
"given",
"a",
"filename",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L418-L437 |
49,221 | xsleonard/pystmark | pystmark.py | Message.recipients | def recipients(self):
'''A list of all recipients for this message.
'''
cc = self._cc or []
bcc = self._bcc or []
return self._to + cc + bcc | python | def recipients(self):
'''A list of all recipients for this message.
'''
cc = self._cc or []
bcc = self._bcc or []
return self._to + cc + bcc | [
"def",
"recipients",
"(",
"self",
")",
":",
"cc",
"=",
"self",
".",
"_cc",
"or",
"[",
"]",
"bcc",
"=",
"self",
".",
"_bcc",
"or",
"[",
"]",
"return",
"self",
".",
"_to",
"+",
"cc",
"+",
"bcc"
] | A list of all recipients for this message. | [
"A",
"list",
"of",
"all",
"recipients",
"for",
"this",
"message",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L458-L463 |
49,222 | xsleonard/pystmark | pystmark.py | Message._detect_content_type | def _detect_content_type(self, filename):
'''Determine the mimetype for a file.
:param filename: Filename of file to detect.
'''
name, ext = os.path.splitext(filename)
if not ext:
raise MessageError('File requires an extension.')
ext = ext.lower()
if ... | python | def _detect_content_type(self, filename):
'''Determine the mimetype for a file.
:param filename: Filename of file to detect.
'''
name, ext = os.path.splitext(filename)
if not ext:
raise MessageError('File requires an extension.')
ext = ext.lower()
if ... | [
"def",
"_detect_content_type",
"(",
"self",
",",
"filename",
")",
":",
"name",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"if",
"not",
"ext",
":",
"raise",
"MessageError",
"(",
"'File requires an extension.'",
")",
"ext",
"=... | Determine the mimetype for a file.
:param filename: Filename of file to detect. | [
"Determine",
"the",
"mimetype",
"for",
"a",
"file",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L534-L548 |
49,223 | xsleonard/pystmark | pystmark.py | Message._verify_attachments | def _verify_attachments(self):
'''Verify that attachment values match the format expected by the
Postmark API.
'''
if self.attachments is None:
return
keys = ('Name', 'Content', 'ContentType')
self._verify_dict_list(self.attachments, keys, 'Attachment') | python | def _verify_attachments(self):
'''Verify that attachment values match the format expected by the
Postmark API.
'''
if self.attachments is None:
return
keys = ('Name', 'Content', 'ContentType')
self._verify_dict_list(self.attachments, keys, 'Attachment') | [
"def",
"_verify_attachments",
"(",
"self",
")",
":",
"if",
"self",
".",
"attachments",
"is",
"None",
":",
"return",
"keys",
"=",
"(",
"'Name'",
",",
"'Content'",
",",
"'ContentType'",
")",
"self",
".",
"_verify_dict_list",
"(",
"self",
".",
"attachments",
... | Verify that attachment values match the format expected by the
Postmark API. | [
"Verify",
"that",
"attachment",
"values",
"match",
"the",
"format",
"expected",
"by",
"the",
"Postmark",
"API",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L558-L565 |
49,224 | xsleonard/pystmark | pystmark.py | Message._verify_dict_list | def _verify_dict_list(self, values, keys, name):
'''Validate a list of `dict`, ensuring it has specific keys
and no others.
:param values: A list of `dict` to validate.
:param keys: A list of keys to validate each `dict` against.
:param name: Name describing the values, to show ... | python | def _verify_dict_list(self, values, keys, name):
'''Validate a list of `dict`, ensuring it has specific keys
and no others.
:param values: A list of `dict` to validate.
:param keys: A list of keys to validate each `dict` against.
:param name: Name describing the values, to show ... | [
"def",
"_verify_dict_list",
"(",
"self",
",",
"values",
",",
"keys",
",",
"name",
")",
":",
"keys",
"=",
"set",
"(",
"keys",
")",
"name",
"=",
"name",
".",
"title",
"(",
")",
"for",
"value",
"in",
"values",
":",
"if",
"not",
"isinstance",
"(",
"val... | Validate a list of `dict`, ensuring it has specific keys
and no others.
:param values: A list of `dict` to validate.
:param keys: A list of keys to validate each `dict` against.
:param name: Name describing the values, to show in error messages. | [
"Validate",
"a",
"list",
"of",
"dict",
"ensuring",
"it",
"has",
"specific",
"keys",
"and",
"no",
"others",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L567-L588 |
49,225 | xsleonard/pystmark | pystmark.py | BouncedMessage.dump | def dump(self, sender=None, **kwargs):
'''Retrieve raw email dump for this bounce.
:param sender: A :class:`BounceDump` object to get dump with.
Defaults to `None`.
:param \*\*kwargs: Keyword arguments passed to
:func:`requests.request`.
'''
if sender is ... | python | def dump(self, sender=None, **kwargs):
'''Retrieve raw email dump for this bounce.
:param sender: A :class:`BounceDump` object to get dump with.
Defaults to `None`.
:param \*\*kwargs: Keyword arguments passed to
:func:`requests.request`.
'''
if sender is ... | [
"def",
"dump",
"(",
"self",
",",
"sender",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"sender",
"is",
"None",
":",
"if",
"self",
".",
"_sender",
"is",
"None",
":",
"sender",
"=",
"_default_bounce_dump",
"else",
":",
"sender",
"=",
"BounceD... | Retrieve raw email dump for this bounce.
:param sender: A :class:`BounceDump` object to get dump with.
Defaults to `None`.
:param \*\*kwargs: Keyword arguments passed to
:func:`requests.request`. | [
"Retrieve",
"raw",
"email",
"dump",
"for",
"this",
"bounce",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L626-L641 |
49,226 | xsleonard/pystmark | pystmark.py | Response.raise_for_status | def raise_for_status(self):
'''Raise Postmark-specific HTTP errors. If there isn't one, the
standard HTTP error is raised.
HTTP 401 raises :class:`UnauthorizedError`
HTTP 422 raises :class:`UnprocessableEntityError`
HTTP 500 raises :class:`InternalServerError`
'''
... | python | def raise_for_status(self):
'''Raise Postmark-specific HTTP errors. If there isn't one, the
standard HTTP error is raised.
HTTP 401 raises :class:`UnauthorizedError`
HTTP 422 raises :class:`UnprocessableEntityError`
HTTP 500 raises :class:`InternalServerError`
'''
... | [
"def",
"raise_for_status",
"(",
"self",
")",
":",
"if",
"self",
".",
"status_code",
"==",
"401",
":",
"raise",
"UnauthorizedError",
"(",
"self",
".",
"_requests_response",
")",
"elif",
"self",
".",
"status_code",
"==",
"422",
":",
"raise",
"UnprocessableEntity... | Raise Postmark-specific HTTP errors. If there isn't one, the
standard HTTP error is raised.
HTTP 401 raises :class:`UnauthorizedError`
HTTP 422 raises :class:`UnprocessableEntityError`
HTTP 500 raises :class:`InternalServerError` | [
"Raise",
"Postmark",
"-",
"specific",
"HTTP",
"errors",
".",
"If",
"there",
"isn",
"t",
"one",
"the",
"standard",
"HTTP",
"error",
"is",
"raised",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L720-L736 |
49,227 | xsleonard/pystmark | pystmark.py | Interface._get_api_url | def _get_api_url(self, secure=None, **formatters):
'''Constructs Postmark API url
:param secure: Use the https Postmark API.
:param \*\*formatters: :func:`string.format` keyword arguments to
format the url with.
:rtype: Postmark API url
'''
if self.endpoint i... | python | def _get_api_url(self, secure=None, **formatters):
'''Constructs Postmark API url
:param secure: Use the https Postmark API.
:param \*\*formatters: :func:`string.format` keyword arguments to
format the url with.
:rtype: Postmark API url
'''
if self.endpoint i... | [
"def",
"_get_api_url",
"(",
"self",
",",
"secure",
"=",
"None",
",",
"*",
"*",
"formatters",
")",
":",
"if",
"self",
".",
"endpoint",
"is",
"None",
":",
"raise",
"NotImplementedError",
"(",
"'endpoint must be defined on a subclass'",
")",
"if",
"secure",
"is",... | Constructs Postmark API url
:param secure: Use the https Postmark API.
:param \*\*formatters: :func:`string.format` keyword arguments to
format the url with.
:rtype: Postmark API url | [
"Constructs",
"Postmark",
"API",
"url"
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L923-L942 |
49,228 | xsleonard/pystmark | pystmark.py | Interface._get_headers | def _get_headers(self, api_key=None, test=None, request_args=None):
'''Constructs the headers to use for the request.
:param api_key: Your Postmark API key. Defaults to `None`.
:param test: Use the Postmark test API. Defaults to `self.test`.
:param request_args: Keyword args to pass to ... | python | def _get_headers(self, api_key=None, test=None, request_args=None):
'''Constructs the headers to use for the request.
:param api_key: Your Postmark API key. Defaults to `None`.
:param test: Use the Postmark test API. Defaults to `self.test`.
:param request_args: Keyword args to pass to ... | [
"def",
"_get_headers",
"(",
"self",
",",
"api_key",
"=",
"None",
",",
"test",
"=",
"None",
",",
"request_args",
"=",
"None",
")",
":",
"if",
"request_args",
"is",
"None",
":",
"request_args",
"=",
"{",
"}",
"headers",
"=",
"{",
"}",
"headers",
".",
"... | Constructs the headers to use for the request.
:param api_key: Your Postmark API key. Defaults to `None`.
:param test: Use the Postmark test API. Defaults to `self.test`.
:param request_args: Keyword args to pass to :func:`requests.request`.
Defaults to `None`.
:rtype: `dict... | [
"Constructs",
"the",
"headers",
"to",
"use",
"for",
"the",
"request",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L944-L966 |
49,229 | xsleonard/pystmark | pystmark.py | Sender._get_request_content | def _get_request_content(self, message=None):
'''Updates message with default message paramaters.
:param message: Postmark message data
:type message: `dict`
:rtype: JSON encoded `unicode`
'''
message = self._cast_message(message=message)
return message.json() | python | def _get_request_content(self, message=None):
'''Updates message with default message paramaters.
:param message: Postmark message data
:type message: `dict`
:rtype: JSON encoded `unicode`
'''
message = self._cast_message(message=message)
return message.json() | [
"def",
"_get_request_content",
"(",
"self",
",",
"message",
"=",
"None",
")",
":",
"message",
"=",
"self",
".",
"_cast_message",
"(",
"message",
"=",
"message",
")",
"return",
"message",
".",
"json",
"(",
")"
] | Updates message with default message paramaters.
:param message: Postmark message data
:type message: `dict`
:rtype: JSON encoded `unicode` | [
"Updates",
"message",
"with",
"default",
"message",
"paramaters",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L1059-L1067 |
49,230 | xsleonard/pystmark | pystmark.py | BatchSender._get_request_content | def _get_request_content(self, message=None):
'''Updates all messages in message with default message
parameters.
:param message: A collection of Postmark message data
:type message: a collection of message `dict`s
:rtype: JSON encoded `str`
'''
if not message:
... | python | def _get_request_content(self, message=None):
'''Updates all messages in message with default message
parameters.
:param message: A collection of Postmark message data
:type message: a collection of message `dict`s
:rtype: JSON encoded `str`
'''
if not message:
... | [
"def",
"_get_request_content",
"(",
"self",
",",
"message",
"=",
"None",
")",
":",
"if",
"not",
"message",
":",
"raise",
"MessageError",
"(",
"'No messages to send.'",
")",
"if",
"len",
"(",
"message",
")",
">",
"MAX_BATCH_MESSAGES",
":",
"err",
"=",
"'Maxim... | Updates all messages in message with default message
parameters.
:param message: A collection of Postmark message data
:type message: a collection of message `dict`s
:rtype: JSON encoded `str` | [
"Updates",
"all",
"messages",
"in",
"message",
"with",
"default",
"message",
"parameters",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L1126-L1141 |
49,231 | xsleonard/pystmark | pystmark.py | Bounce.get | def get(self, bounce_id, api_key=None, secure=None, test=None,
**request_args):
'''Retrieves a single bounce's data.
:param bounce_id: A bounce's ID retrieved with :class:`Bounces`.
:param api_key: Your Postmark API key. Defaults to `self.api_key`.
:param secure: Use the htt... | python | def get(self, bounce_id, api_key=None, secure=None, test=None,
**request_args):
'''Retrieves a single bounce's data.
:param bounce_id: A bounce's ID retrieved with :class:`Bounces`.
:param api_key: Your Postmark API key. Defaults to `self.api_key`.
:param secure: Use the htt... | [
"def",
"get",
"(",
"self",
",",
"bounce_id",
",",
"api_key",
"=",
"None",
",",
"secure",
"=",
"None",
",",
"test",
"=",
"None",
",",
"*",
"*",
"request_args",
")",
":",
"url",
"=",
"self",
".",
"_get_api_url",
"(",
"secure",
"=",
"secure",
",",
"bo... | Retrieves a single bounce's data.
:param bounce_id: A bounce's ID retrieved with :class:`Bounces`.
:param api_key: Your Postmark API key. Defaults to `self.api_key`.
:param secure: Use the https scheme for Postmark API.
Defaults to `self.secure`.
:param test: Make a test req... | [
"Retrieves",
"a",
"single",
"bounce",
"s",
"data",
"."
] | 329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6 | https://github.com/xsleonard/pystmark/blob/329ccae1a7c8d57f28fa72cd8dbbee3e39413ed6/pystmark.py#L1274-L1291 |
49,232 | inveniosoftware/invenio-base | invenio_base/app.py | create_app_factory | def create_app_factory(app_name, config_loader=None,
extension_entry_points=None, extensions=None,
blueprint_entry_points=None, blueprints=None,
converter_entry_points=None, converters=None,
wsgi_factory=None, **app_kwargs):
... | python | def create_app_factory(app_name, config_loader=None,
extension_entry_points=None, extensions=None,
blueprint_entry_points=None, blueprints=None,
converter_entry_points=None, converters=None,
wsgi_factory=None, **app_kwargs):
... | [
"def",
"create_app_factory",
"(",
"app_name",
",",
"config_loader",
"=",
"None",
",",
"extension_entry_points",
"=",
"None",
",",
"extensions",
"=",
"None",
",",
"blueprint_entry_points",
"=",
"None",
",",
"blueprints",
"=",
"None",
",",
"converter_entry_points",
... | Create a Flask application factory.
The application factory will load Flask extensions and blueprints specified
using both entry points and directly in the arguments. Loading order of
entry points are not guaranteed and can happen in any order.
:param app_name: Flask application name.
:param confi... | [
"Create",
"a",
"Flask",
"application",
"factory",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/app.py#L27-L127 |
49,233 | inveniosoftware/invenio-base | invenio_base/app.py | create_cli | def create_cli(create_app=None):
"""Create CLI for ``inveniomanage`` command.
:param create_app: Flask application factory.
:returns: Click command group.
.. versionadded: 1.0.0
"""
def create_cli_app(info):
"""Application factory for CLI app.
Internal function for creating th... | python | def create_cli(create_app=None):
"""Create CLI for ``inveniomanage`` command.
:param create_app: Flask application factory.
:returns: Click command group.
.. versionadded: 1.0.0
"""
def create_cli_app(info):
"""Application factory for CLI app.
Internal function for creating th... | [
"def",
"create_cli",
"(",
"create_app",
"=",
"None",
")",
":",
"def",
"create_cli_app",
"(",
"info",
")",
":",
"\"\"\"Application factory for CLI app.\n\n Internal function for creating the CLI. When invoked via\n ``inveniomanage`` FLASK_APP must be set.\n \"\"\"",
... | Create CLI for ``inveniomanage`` command.
:param create_app: Flask application factory.
:returns: Click command group.
.. versionadded: 1.0.0 | [
"Create",
"CLI",
"for",
"inveniomanage",
"command",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/app.py#L130-L157 |
49,234 | inveniosoftware/invenio-base | invenio_base/app.py | app_loader | def app_loader(app, entry_points=None, modules=None):
"""Run default application loader.
:param entry_points: List of entry points providing to Flask extensions.
:param modules: List of Flask extensions.
.. versionadded: 1.0.0
"""
_loader(app, lambda ext: ext(app), entry_points=entry_points,
... | python | def app_loader(app, entry_points=None, modules=None):
"""Run default application loader.
:param entry_points: List of entry points providing to Flask extensions.
:param modules: List of Flask extensions.
.. versionadded: 1.0.0
"""
_loader(app, lambda ext: ext(app), entry_points=entry_points,
... | [
"def",
"app_loader",
"(",
"app",
",",
"entry_points",
"=",
"None",
",",
"modules",
"=",
"None",
")",
":",
"_loader",
"(",
"app",
",",
"lambda",
"ext",
":",
"ext",
"(",
"app",
")",
",",
"entry_points",
"=",
"entry_points",
",",
"modules",
"=",
"modules"... | Run default application loader.
:param entry_points: List of entry points providing to Flask extensions.
:param modules: List of Flask extensions.
.. versionadded: 1.0.0 | [
"Run",
"default",
"application",
"loader",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/app.py#L160-L169 |
49,235 | inveniosoftware/invenio-base | invenio_base/app.py | blueprint_loader | def blueprint_loader(app, entry_points=None, modules=None):
"""Run default blueprint loader.
The value of any entry_point or module passed can be either an instance of
``flask.Blueprint`` or a callable accepting a ``flask.Flask`` application
instance as a single argument and returning an instance of
... | python | def blueprint_loader(app, entry_points=None, modules=None):
"""Run default blueprint loader.
The value of any entry_point or module passed can be either an instance of
``flask.Blueprint`` or a callable accepting a ``flask.Flask`` application
instance as a single argument and returning an instance of
... | [
"def",
"blueprint_loader",
"(",
"app",
",",
"entry_points",
"=",
"None",
",",
"modules",
"=",
"None",
")",
":",
"url_prefixes",
"=",
"app",
".",
"config",
".",
"get",
"(",
"'BLUEPRINTS_URL_PREFIXES'",
",",
"{",
"}",
")",
"def",
"loader_init_func",
"(",
"bp... | Run default blueprint loader.
The value of any entry_point or module passed can be either an instance of
``flask.Blueprint`` or a callable accepting a ``flask.Flask`` application
instance as a single argument and returning an instance of
``flask.Blueprint``.
:param entry_points: List of entry poin... | [
"Run",
"default",
"blueprint",
"loader",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/app.py#L172-L191 |
49,236 | inveniosoftware/invenio-base | invenio_base/app.py | converter_loader | def converter_loader(app, entry_points=None, modules=None):
"""Run default converter loader.
:param entry_points: List of entry points providing to Blue.
:param modules: Map of coverters.
.. versionadded: 1.0.0
"""
if entry_points:
for entry_point in entry_points:
for ep in... | python | def converter_loader(app, entry_points=None, modules=None):
"""Run default converter loader.
:param entry_points: List of entry points providing to Blue.
:param modules: Map of coverters.
.. versionadded: 1.0.0
"""
if entry_points:
for entry_point in entry_points:
for ep in... | [
"def",
"converter_loader",
"(",
"app",
",",
"entry_points",
"=",
"None",
",",
"modules",
"=",
"None",
")",
":",
"if",
"entry_points",
":",
"for",
"entry_point",
"in",
"entry_points",
":",
"for",
"ep",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"en... | Run default converter loader.
:param entry_points: List of entry points providing to Blue.
:param modules: Map of coverters.
.. versionadded: 1.0.0 | [
"Run",
"default",
"converter",
"loader",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/app.py#L194-L213 |
49,237 | inveniosoftware/invenio-base | invenio_base/app.py | _loader | def _loader(app, init_func, entry_points=None, modules=None):
"""Run generic loader.
Used to load and initialize entry points and modules using an custom
initialization function.
.. versionadded: 1.0.0
"""
if entry_points:
for entry_point in entry_points:
for ep in pkg_reso... | python | def _loader(app, init_func, entry_points=None, modules=None):
"""Run generic loader.
Used to load and initialize entry points and modules using an custom
initialization function.
.. versionadded: 1.0.0
"""
if entry_points:
for entry_point in entry_points:
for ep in pkg_reso... | [
"def",
"_loader",
"(",
"app",
",",
"init_func",
",",
"entry_points",
"=",
"None",
",",
"modules",
"=",
"None",
")",
":",
"if",
"entry_points",
":",
"for",
"entry_point",
"in",
"entry_points",
":",
"for",
"ep",
"in",
"pkg_resources",
".",
"iter_entry_points",... | Run generic loader.
Used to load and initialize entry points and modules using an custom
initialization function.
.. versionadded: 1.0.0 | [
"Run",
"generic",
"loader",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/app.py#L216-L239 |
49,238 | inveniosoftware/invenio-base | invenio_base/app.py | base_app | def base_app(import_name, instance_path=None, static_folder=None,
static_url_path='/static', template_folder='templates',
instance_relative_config=True, app_class=Flask):
"""Invenio base application factory.
If the instance folder does not exists, it will be created.
:param impor... | python | def base_app(import_name, instance_path=None, static_folder=None,
static_url_path='/static', template_folder='templates',
instance_relative_config=True, app_class=Flask):
"""Invenio base application factory.
If the instance folder does not exists, it will be created.
:param impor... | [
"def",
"base_app",
"(",
"import_name",
",",
"instance_path",
"=",
"None",
",",
"static_folder",
"=",
"None",
",",
"static_url_path",
"=",
"'/static'",
",",
"template_folder",
"=",
"'templates'",
",",
"instance_relative_config",
"=",
"True",
",",
"app_class",
"=",
... | Invenio base application factory.
If the instance folder does not exists, it will be created.
:param import_name: The name of the application package.
:param env_prefix: Environment variable prefix.
:param instance_path: Instance path for Flask application.
:param static_folder: Static folder path... | [
"Invenio",
"base",
"application",
"factory",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/app.py#L242-L279 |
49,239 | inveniosoftware/invenio-base | invenio_base/app.py | configure_warnings | def configure_warnings():
"""Configure warnings by routing warnings to the logging system.
It also unhides ``DeprecationWarning``.
.. versionadded: 1.0.0
"""
if not sys.warnoptions:
# Route warnings through python logging
logging.captureWarnings(True)
# DeprecationWarning ... | python | def configure_warnings():
"""Configure warnings by routing warnings to the logging system.
It also unhides ``DeprecationWarning``.
.. versionadded: 1.0.0
"""
if not sys.warnoptions:
# Route warnings through python logging
logging.captureWarnings(True)
# DeprecationWarning ... | [
"def",
"configure_warnings",
"(",
")",
":",
"if",
"not",
"sys",
".",
"warnoptions",
":",
"# Route warnings through python logging",
"logging",
".",
"captureWarnings",
"(",
"True",
")",
"# DeprecationWarning is by default hidden, hence we force the",
"# 'default' behavior on dep... | Configure warnings by routing warnings to the logging system.
It also unhides ``DeprecationWarning``.
.. versionadded: 1.0.0 | [
"Configure",
"warnings",
"by",
"routing",
"warnings",
"to",
"the",
"logging",
"system",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/app.py#L282-L297 |
49,240 | inveniosoftware/invenio-base | examples/app.py | config_loader | def config_loader(app, **kwargs):
"""Custom config loader."""
app.config.from_object(Config)
app.config.update(**kwargs) | python | def config_loader(app, **kwargs):
"""Custom config loader."""
app.config.from_object(Config)
app.config.update(**kwargs) | [
"def",
"config_loader",
"(",
"app",
",",
"*",
"*",
"kwargs",
")",
":",
"app",
".",
"config",
".",
"from_object",
"(",
"Config",
")",
"app",
".",
"config",
".",
"update",
"(",
"*",
"*",
"kwargs",
")"
] | Custom config loader. | [
"Custom",
"config",
"loader",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/examples/app.py#L30-L33 |
49,241 | Scifabric/enki | enki/__init__.py | Enki.get_project | def get_project(self, project_short_name):
"""Return project object."""
project = pbclient.find_project(short_name=project_short_name,
all=self.all)
if (len(project) == 1):
return project[0]
else:
raise ProjectNotFound(proje... | python | def get_project(self, project_short_name):
"""Return project object."""
project = pbclient.find_project(short_name=project_short_name,
all=self.all)
if (len(project) == 1):
return project[0]
else:
raise ProjectNotFound(proje... | [
"def",
"get_project",
"(",
"self",
",",
"project_short_name",
")",
":",
"project",
"=",
"pbclient",
".",
"find_project",
"(",
"short_name",
"=",
"project_short_name",
",",
"all",
"=",
"self",
".",
"all",
")",
"if",
"(",
"len",
"(",
"project",
")",
"==",
... | Return project object. | [
"Return",
"project",
"object",
"."
] | eae8d000276704abe6535ae45ecb6d8067986f9f | https://github.com/Scifabric/enki/blob/eae8d000276704abe6535ae45ecb6d8067986f9f/enki/__init__.py#L47-L54 |
49,242 | Scifabric/enki | enki/__init__.py | Enki.get_tasks | def get_tasks(self, task_id=None, state='completed', json_file=None):
"""Load all project Tasks."""
if self.project is None:
raise ProjectError
loader = create_tasks_loader(self.project.id, task_id,
state, json_file, self.all)
self.tasks ... | python | def get_tasks(self, task_id=None, state='completed', json_file=None):
"""Load all project Tasks."""
if self.project is None:
raise ProjectError
loader = create_tasks_loader(self.project.id, task_id,
state, json_file, self.all)
self.tasks ... | [
"def",
"get_tasks",
"(",
"self",
",",
"task_id",
"=",
"None",
",",
"state",
"=",
"'completed'",
",",
"json_file",
"=",
"None",
")",
":",
"if",
"self",
".",
"project",
"is",
"None",
":",
"raise",
"ProjectError",
"loader",
"=",
"create_tasks_loader",
"(",
... | Load all project Tasks. | [
"Load",
"all",
"project",
"Tasks",
"."
] | eae8d000276704abe6535ae45ecb6d8067986f9f | https://github.com/Scifabric/enki/blob/eae8d000276704abe6535ae45ecb6d8067986f9f/enki/__init__.py#L60-L70 |
49,243 | Scifabric/enki | enki/__init__.py | Enki.get_task_runs | def get_task_runs(self, json_file=None):
"""Load all project Task Runs from Tasks."""
if self.project is None:
raise ProjectError
loader = create_task_runs_loader(self.project.id, self.tasks,
json_file, self.all)
self.task_runs, self.t... | python | def get_task_runs(self, json_file=None):
"""Load all project Task Runs from Tasks."""
if self.project is None:
raise ProjectError
loader = create_task_runs_loader(self.project.id, self.tasks,
json_file, self.all)
self.task_runs, self.t... | [
"def",
"get_task_runs",
"(",
"self",
",",
"json_file",
"=",
"None",
")",
":",
"if",
"self",
".",
"project",
"is",
"None",
":",
"raise",
"ProjectError",
"loader",
"=",
"create_task_runs_loader",
"(",
"self",
".",
"project",
".",
"id",
",",
"self",
".",
"t... | Load all project Task Runs from Tasks. | [
"Load",
"all",
"project",
"Task",
"Runs",
"from",
"Tasks",
"."
] | eae8d000276704abe6535ae45ecb6d8067986f9f | https://github.com/Scifabric/enki/blob/eae8d000276704abe6535ae45ecb6d8067986f9f/enki/__init__.py#L72-L81 |
49,244 | Scifabric/enki | enki/__init__.py | Enki.describe | def describe(self, element): # pragma: no cover
"""Return tasks or task_runs Panda describe."""
if (element == 'tasks'):
return self.tasks_df.describe()
elif (element == 'task_runs'):
return self.task_runs_df.describe()
else:
return "ERROR: %s not fou... | python | def describe(self, element): # pragma: no cover
"""Return tasks or task_runs Panda describe."""
if (element == 'tasks'):
return self.tasks_df.describe()
elif (element == 'task_runs'):
return self.task_runs_df.describe()
else:
return "ERROR: %s not fou... | [
"def",
"describe",
"(",
"self",
",",
"element",
")",
":",
"# pragma: no cover",
"if",
"(",
"element",
"==",
"'tasks'",
")",
":",
"return",
"self",
".",
"tasks_df",
".",
"describe",
"(",
")",
"elif",
"(",
"element",
"==",
"'task_runs'",
")",
":",
"return"... | Return tasks or task_runs Panda describe. | [
"Return",
"tasks",
"or",
"task_runs",
"Panda",
"describe",
"."
] | eae8d000276704abe6535ae45ecb6d8067986f9f | https://github.com/Scifabric/enki/blob/eae8d000276704abe6535ae45ecb6d8067986f9f/enki/__init__.py#L88-L95 |
49,245 | inveniosoftware/invenio-base | invenio_base/wsgi.py | create_wsgi_factory | def create_wsgi_factory(mounts_factories):
"""Create a WSGI application factory.
Usage example:
.. code-block:: python
wsgi_factory = create_wsgi_factory({'/api': create_api})
:param mounts_factories: Dictionary of mount points per application
factory.
.. versionadded:: 1.0.0
... | python | def create_wsgi_factory(mounts_factories):
"""Create a WSGI application factory.
Usage example:
.. code-block:: python
wsgi_factory = create_wsgi_factory({'/api': create_api})
:param mounts_factories: Dictionary of mount points per application
factory.
.. versionadded:: 1.0.0
... | [
"def",
"create_wsgi_factory",
"(",
"mounts_factories",
")",
":",
"def",
"create_wsgi",
"(",
"app",
",",
"*",
"*",
"kwargs",
")",
":",
"mounts",
"=",
"{",
"mount",
":",
"factory",
"(",
"*",
"*",
"kwargs",
")",
"for",
"mount",
",",
"factory",
"in",
"moun... | Create a WSGI application factory.
Usage example:
.. code-block:: python
wsgi_factory = create_wsgi_factory({'/api': create_api})
:param mounts_factories: Dictionary of mount points per application
factory.
.. versionadded:: 1.0.0 | [
"Create",
"a",
"WSGI",
"application",
"factory",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/wsgi.py#L17-L37 |
49,246 | inveniosoftware/invenio-base | invenio_base/wsgi.py | wsgi_proxyfix | def wsgi_proxyfix(factory=None):
"""Fix ``REMOTE_ADDR`` based on ``X-Forwarded-For`` headers.
.. note::
You must set ``WSGI_PROXIES`` to the correct number of proxies,
otherwise you application is susceptible to malicious attacks.
.. versionadded:: 1.0.0
"""
def create_wsgi(app, **k... | python | def wsgi_proxyfix(factory=None):
"""Fix ``REMOTE_ADDR`` based on ``X-Forwarded-For`` headers.
.. note::
You must set ``WSGI_PROXIES`` to the correct number of proxies,
otherwise you application is susceptible to malicious attacks.
.. versionadded:: 1.0.0
"""
def create_wsgi(app, **k... | [
"def",
"wsgi_proxyfix",
"(",
"factory",
"=",
"None",
")",
":",
"def",
"create_wsgi",
"(",
"app",
",",
"*",
"*",
"kwargs",
")",
":",
"wsgi_app",
"=",
"factory",
"(",
"app",
",",
"*",
"*",
"kwargs",
")",
"if",
"factory",
"else",
"app",
".",
"wsgi_app",... | Fix ``REMOTE_ADDR`` based on ``X-Forwarded-For`` headers.
.. note::
You must set ``WSGI_PROXIES`` to the correct number of proxies,
otherwise you application is susceptible to malicious attacks.
.. versionadded:: 1.0.0 | [
"Fix",
"REMOTE_ADDR",
"based",
"on",
"X",
"-",
"Forwarded",
"-",
"For",
"headers",
"."
] | ed4b7a76516ab2675e19270844400f4e2308f52d | https://github.com/inveniosoftware/invenio-base/blob/ed4b7a76516ab2675e19270844400f4e2308f52d/invenio_base/wsgi.py#L40-L55 |
49,247 | xperscore/alley | alley/migrations.py | Migrations.get_migration_files | def get_migration_files(self):
"""Find migrations files."""
migrations = (re.match(MigrationFile.PATTERN, filename)
for filename in os.listdir(self.directory))
migrations = (MigrationFile(m.group('id'), m.group(0))
for m in migrations if m)
ret... | python | def get_migration_files(self):
"""Find migrations files."""
migrations = (re.match(MigrationFile.PATTERN, filename)
for filename in os.listdir(self.directory))
migrations = (MigrationFile(m.group('id'), m.group(0))
for m in migrations if m)
ret... | [
"def",
"get_migration_files",
"(",
"self",
")",
":",
"migrations",
"=",
"(",
"re",
".",
"match",
"(",
"MigrationFile",
".",
"PATTERN",
",",
"filename",
")",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"directory",
")",
")",
"migratio... | Find migrations files. | [
"Find",
"migrations",
"files",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L55-L61 |
49,248 | xperscore/alley | alley/migrations.py | Migrations.get_unregistered_migrations | def get_unregistered_migrations(self):
"""Find unregistered migrations."""
return [m for m in self.get_migration_files()
if not self.collection.find_one({'filename': m.filename})] | python | def get_unregistered_migrations(self):
"""Find unregistered migrations."""
return [m for m in self.get_migration_files()
if not self.collection.find_one({'filename': m.filename})] | [
"def",
"get_unregistered_migrations",
"(",
"self",
")",
":",
"return",
"[",
"m",
"for",
"m",
"in",
"self",
".",
"get_migration_files",
"(",
")",
"if",
"not",
"self",
".",
"collection",
".",
"find_one",
"(",
"{",
"'filename'",
":",
"m",
".",
"filename",
"... | Find unregistered migrations. | [
"Find",
"unregistered",
"migrations",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L63-L66 |
49,249 | xperscore/alley | alley/migrations.py | Migrations.check_directory | def check_directory(self):
"""Check if migrations directory exists."""
exists = os.path.exists(self.directory)
if not exists:
logger.error("No migrations directory found. Check your path or create a migration first.")
logger.error("Directory: %s" % self.directory)
... | python | def check_directory(self):
"""Check if migrations directory exists."""
exists = os.path.exists(self.directory)
if not exists:
logger.error("No migrations directory found. Check your path or create a migration first.")
logger.error("Directory: %s" % self.directory)
... | [
"def",
"check_directory",
"(",
"self",
")",
":",
"exists",
"=",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"directory",
")",
"if",
"not",
"exists",
":",
"logger",
".",
"error",
"(",
"\"No migrations directory found. Check your path or create a migration f... | Check if migrations directory exists. | [
"Check",
"if",
"migrations",
"directory",
"exists",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L68-L74 |
49,250 | xperscore/alley | alley/migrations.py | Migrations.show_status | def show_status(self):
"""Show status of unregistered migrations"""
if not self.check_directory():
return
migrations = self.get_unregistered_migrations()
if migrations:
logger.info('Unregistered migrations:')
for migration in migrations:
... | python | def show_status(self):
"""Show status of unregistered migrations"""
if not self.check_directory():
return
migrations = self.get_unregistered_migrations()
if migrations:
logger.info('Unregistered migrations:')
for migration in migrations:
... | [
"def",
"show_status",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"check_directory",
"(",
")",
":",
"return",
"migrations",
"=",
"self",
".",
"get_unregistered_migrations",
"(",
")",
"if",
"migrations",
":",
"logger",
".",
"info",
"(",
"'Unregistered mi... | Show status of unregistered migrations | [
"Show",
"status",
"of",
"unregistered",
"migrations"
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L76-L87 |
49,251 | xperscore/alley | alley/migrations.py | Migrations.get_new_filename | def get_new_filename(self, name):
"""Generate filename for new migration."""
name = MigrationFile.normalize_name(name)
migrations = self.get_migration_files()
migration_id = migrations[-1].id if migrations else 0
migration_id += 1
return '{:04}_{}.py'.format(migration_id,... | python | def get_new_filename(self, name):
"""Generate filename for new migration."""
name = MigrationFile.normalize_name(name)
migrations = self.get_migration_files()
migration_id = migrations[-1].id if migrations else 0
migration_id += 1
return '{:04}_{}.py'.format(migration_id,... | [
"def",
"get_new_filename",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"MigrationFile",
".",
"normalize_name",
"(",
"name",
")",
"migrations",
"=",
"self",
".",
"get_migration_files",
"(",
")",
"migration_id",
"=",
"migrations",
"[",
"-",
"1",
"]",
".... | Generate filename for new migration. | [
"Generate",
"filename",
"for",
"new",
"migration",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L89-L95 |
49,252 | xperscore/alley | alley/migrations.py | Migrations.create | def create(self, name):
"""Create a new empty migration."""
if not os.path.exists(self.directory):
os.makedirs(self.directory)
filename = self.get_new_filename(name)
with open(os.path.join(self.directory, filename), 'w') as fp:
fp.write("def up(db): pass\n\n\n")
... | python | def create(self, name):
"""Create a new empty migration."""
if not os.path.exists(self.directory):
os.makedirs(self.directory)
filename = self.get_new_filename(name)
with open(os.path.join(self.directory, filename), 'w') as fp:
fp.write("def up(db): pass\n\n\n")
... | [
"def",
"create",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"directory",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"directory",
")",
"filename",
"=",
"self",
".",
"get_new_filename",
... | Create a new empty migration. | [
"Create",
"a",
"new",
"empty",
"migration",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L97-L106 |
49,253 | xperscore/alley | alley/migrations.py | Migrations.load_migration_file | def load_migration_file(self, filename):
"""Load migration file as module."""
path = os.path.join(self.directory, filename)
# spec = spec_from_file_location("migration", path)
# module = module_from_spec(spec)
# spec.loader.exec_module(module)
module = imp.load_source("mi... | python | def load_migration_file(self, filename):
"""Load migration file as module."""
path = os.path.join(self.directory, filename)
# spec = spec_from_file_location("migration", path)
# module = module_from_spec(spec)
# spec.loader.exec_module(module)
module = imp.load_source("mi... | [
"def",
"load_migration_file",
"(",
"self",
",",
"filename",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"directory",
",",
"filename",
")",
"# spec = spec_from_file_location(\"migration\", path)",
"# module = module_from_spec(spec)",
"# spe... | Load migration file as module. | [
"Load",
"migration",
"file",
"as",
"module",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L108-L115 |
49,254 | xperscore/alley | alley/migrations.py | Migrations.get_migrations_to_up | def get_migrations_to_up(self, migration_id=None):
"""Find migrations to execute."""
if migration_id is not None:
migration_id = MigrationFile.validate_id(migration_id)
if not migration_id:
return []
migrations = self.get_unregistered_migrations()
... | python | def get_migrations_to_up(self, migration_id=None):
"""Find migrations to execute."""
if migration_id is not None:
migration_id = MigrationFile.validate_id(migration_id)
if not migration_id:
return []
migrations = self.get_unregistered_migrations()
... | [
"def",
"get_migrations_to_up",
"(",
"self",
",",
"migration_id",
"=",
"None",
")",
":",
"if",
"migration_id",
"is",
"not",
"None",
":",
"migration_id",
"=",
"MigrationFile",
".",
"validate_id",
"(",
"migration_id",
")",
"if",
"not",
"migration_id",
":",
"retur... | Find migrations to execute. | [
"Find",
"migrations",
"to",
"execute",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L117-L141 |
49,255 | xperscore/alley | alley/migrations.py | Migrations.up | def up(self, migration_id=None, fake=False):
"""Executes migrations."""
if not self.check_directory():
return
for migration in self.get_migrations_to_up(migration_id):
logger.info('Executing migration: %s' % migration.filename)
migration_module = self.load_m... | python | def up(self, migration_id=None, fake=False):
"""Executes migrations."""
if not self.check_directory():
return
for migration in self.get_migrations_to_up(migration_id):
logger.info('Executing migration: %s' % migration.filename)
migration_module = self.load_m... | [
"def",
"up",
"(",
"self",
",",
"migration_id",
"=",
"None",
",",
"fake",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"check_directory",
"(",
")",
":",
"return",
"for",
"migration",
"in",
"self",
".",
"get_migrations_to_up",
"(",
"migration_id",
")"... | Executes migrations. | [
"Executes",
"migrations",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L143-L160 |
49,256 | xperscore/alley | alley/migrations.py | Migrations.get_migrations_to_down | def get_migrations_to_down(self, migration_id):
"""Find migrations to rollback."""
migration_id = MigrationFile.validate_id(migration_id)
if not migration_id:
return []
migrations = self.get_migration_files()
last_migration_id = self.get_last_migrated_id()
i... | python | def get_migrations_to_down(self, migration_id):
"""Find migrations to rollback."""
migration_id = MigrationFile.validate_id(migration_id)
if not migration_id:
return []
migrations = self.get_migration_files()
last_migration_id = self.get_last_migrated_id()
i... | [
"def",
"get_migrations_to_down",
"(",
"self",
",",
"migration_id",
")",
":",
"migration_id",
"=",
"MigrationFile",
".",
"validate_id",
"(",
"migration_id",
")",
"if",
"not",
"migration_id",
":",
"return",
"[",
"]",
"migrations",
"=",
"self",
".",
"get_migration_... | Find migrations to rollback. | [
"Find",
"migrations",
"to",
"rollback",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L166-L186 |
49,257 | xperscore/alley | alley/migrations.py | Migrations.down | def down(self, migration_id):
"""Rollback to migration."""
if not self.check_directory():
return
for migration in self.get_migrations_to_down(migration_id):
logger.info('Rollback migration %s' % migration.filename)
migration_module = self.load_migration_file... | python | def down(self, migration_id):
"""Rollback to migration."""
if not self.check_directory():
return
for migration in self.get_migrations_to_down(migration_id):
logger.info('Rollback migration %s' % migration.filename)
migration_module = self.load_migration_file... | [
"def",
"down",
"(",
"self",
",",
"migration_id",
")",
":",
"if",
"not",
"self",
".",
"check_directory",
"(",
")",
":",
"return",
"for",
"migration",
"in",
"self",
".",
"get_migrations_to_down",
"(",
"migration_id",
")",
":",
"logger",
".",
"info",
"(",
"... | Rollback to migration. | [
"Rollback",
"to",
"migration",
"."
] | f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e | https://github.com/xperscore/alley/blob/f9a5e9e2970230e38fd8a48b6a0bc1d43a38548e/alley/migrations.py#L188-L202 |
49,258 | inveniosoftware/invenio-userprofiles | invenio_userprofiles/models.py | UserProfile.username | def username(self, username):
"""Set username.
.. note:: The username will be converted to lowercase. The display name
will contain the original version.
"""
validate_username(username)
self._username = username.lower()
self._displayname = username | python | def username(self, username):
"""Set username.
.. note:: The username will be converted to lowercase. The display name
will contain the original version.
"""
validate_username(username)
self._username = username.lower()
self._displayname = username | [
"def",
"username",
"(",
"self",
",",
"username",
")",
":",
"validate_username",
"(",
"username",
")",
"self",
".",
"_username",
"=",
"username",
".",
"lower",
"(",
")",
"self",
".",
"_displayname",
"=",
"username"
] | Set username.
.. note:: The username will be converted to lowercase. The display name
will contain the original version. | [
"Set",
"username",
"."
] | 4c682e7d67a4cab8dc38472a31fa1c34cbba03dd | https://github.com/inveniosoftware/invenio-userprofiles/blob/4c682e7d67a4cab8dc38472a31fa1c34cbba03dd/invenio_userprofiles/models.py#L67-L75 |
49,259 | inveniosoftware/invenio-userprofiles | invenio_userprofiles/models.py | UserProfile.get_by_username | def get_by_username(cls, username):
"""Get profile by username.
:param username: A username to query for (case insensitive).
"""
return cls.query.filter(
UserProfile._username == username.lower()
).one() | python | def get_by_username(cls, username):
"""Get profile by username.
:param username: A username to query for (case insensitive).
"""
return cls.query.filter(
UserProfile._username == username.lower()
).one() | [
"def",
"get_by_username",
"(",
"cls",
",",
"username",
")",
":",
"return",
"cls",
".",
"query",
".",
"filter",
"(",
"UserProfile",
".",
"_username",
"==",
"username",
".",
"lower",
"(",
")",
")",
".",
"one",
"(",
")"
] | Get profile by username.
:param username: A username to query for (case insensitive). | [
"Get",
"profile",
"by",
"username",
"."
] | 4c682e7d67a4cab8dc38472a31fa1c34cbba03dd | https://github.com/inveniosoftware/invenio-userprofiles/blob/4c682e7d67a4cab8dc38472a31fa1c34cbba03dd/invenio_userprofiles/models.py#L78-L85 |
49,260 | ionelmc/nose-htmloutput | src/nose_htmloutput/__init__.py | nice_classname | def nice_classname(obj):
"""Returns a nice name for class object or class instance.
>>> nice_classname(Exception()) # doctest: +ELLIPSIS
'...Exception'
>>> nice_classname(Exception) # doctest: +ELLIPSIS
'...Exception'
"""
if inspect.isclass(obj):
cls_name = obj.__na... | python | def nice_classname(obj):
"""Returns a nice name for class object or class instance.
>>> nice_classname(Exception()) # doctest: +ELLIPSIS
'...Exception'
>>> nice_classname(Exception) # doctest: +ELLIPSIS
'...Exception'
"""
if inspect.isclass(obj):
cls_name = obj.__na... | [
"def",
"nice_classname",
"(",
"obj",
")",
":",
"if",
"inspect",
".",
"isclass",
"(",
"obj",
")",
":",
"cls_name",
"=",
"obj",
".",
"__name__",
"else",
":",
"cls_name",
"=",
"obj",
".",
"__class__",
".",
"__name__",
"mod",
"=",
"inspect",
".",
"getmodul... | Returns a nice name for class object or class instance.
>>> nice_classname(Exception()) # doctest: +ELLIPSIS
'...Exception'
>>> nice_classname(Exception) # doctest: +ELLIPSIS
'...Exception' | [
"Returns",
"a",
"nice",
"name",
"for",
"class",
"object",
"or",
"class",
"instance",
"."
] | 1cda401c09fcffdb30bc240fb15c31b68d7a6594 | https://github.com/ionelmc/nose-htmloutput/blob/1cda401c09fcffdb30bc240fb15c31b68d7a6594/src/nose_htmloutput/__init__.py#L28-L49 |
49,261 | ionelmc/nose-htmloutput | src/nose_htmloutput/__init__.py | exc_message | def exc_message(exc_info):
"""Return the exception's message."""
exc = exc_info[1]
if exc is None:
# str exception
result = exc_info[0]
else:
try:
result = str(exc)
except UnicodeEncodeError:
try:
result = unicode(exc) # flake8: no... | python | def exc_message(exc_info):
"""Return the exception's message."""
exc = exc_info[1]
if exc is None:
# str exception
result = exc_info[0]
else:
try:
result = str(exc)
except UnicodeEncodeError:
try:
result = unicode(exc) # flake8: no... | [
"def",
"exc_message",
"(",
"exc_info",
")",
":",
"exc",
"=",
"exc_info",
"[",
"1",
"]",
"if",
"exc",
"is",
"None",
":",
"# str exception",
"result",
"=",
"exc_info",
"[",
"0",
"]",
"else",
":",
"try",
":",
"result",
"=",
"str",
"(",
"exc",
")",
"ex... | Return the exception's message. | [
"Return",
"the",
"exception",
"s",
"message",
"."
] | 1cda401c09fcffdb30bc240fb15c31b68d7a6594 | https://github.com/ionelmc/nose-htmloutput/blob/1cda401c09fcffdb30bc240fb15c31b68d7a6594/src/nose_htmloutput/__init__.py#L52-L68 |
49,262 | ionelmc/nose-htmloutput | src/nose_htmloutput/__init__.py | HtmlOutput.options | def options(self, parser, env):
"""Sets additional command line options."""
Plugin.options(self, parser, env)
parser.add_option(
'--html-file', action='store',
dest='html_file', metavar="FILE",
default=env.get('NOSE_HTML_FILE', 'nosetests.html'),
h... | python | def options(self, parser, env):
"""Sets additional command line options."""
Plugin.options(self, parser, env)
parser.add_option(
'--html-file', action='store',
dest='html_file', metavar="FILE",
default=env.get('NOSE_HTML_FILE', 'nosetests.html'),
h... | [
"def",
"options",
"(",
"self",
",",
"parser",
",",
"env",
")",
":",
"Plugin",
".",
"options",
"(",
"self",
",",
"parser",
",",
"env",
")",
"parser",
".",
"add_option",
"(",
"'--html-file'",
",",
"action",
"=",
"'store'",
",",
"dest",
"=",
"'html_file'"... | Sets additional command line options. | [
"Sets",
"additional",
"command",
"line",
"options",
"."
] | 1cda401c09fcffdb30bc240fb15c31b68d7a6594 | https://github.com/ionelmc/nose-htmloutput/blob/1cda401c09fcffdb30bc240fb15c31b68d7a6594/src/nose_htmloutput/__init__.py#L87-L96 |
49,263 | ionelmc/nose-htmloutput | src/nose_htmloutput/__init__.py | HtmlOutput.configure | def configure(self, options, config):
"""Configures the xunit plugin."""
Plugin.configure(self, options, config)
self.config = config
if self.enabled:
self.jinja = Environment(
loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')),
... | python | def configure(self, options, config):
"""Configures the xunit plugin."""
Plugin.configure(self, options, config)
self.config = config
if self.enabled:
self.jinja = Environment(
loader=FileSystemLoader(os.path.join(os.path.dirname(__file__), 'templates')),
... | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"config",
")",
":",
"Plugin",
".",
"configure",
"(",
"self",
",",
"options",
",",
"config",
")",
"self",
".",
"config",
"=",
"config",
"if",
"self",
".",
"enabled",
":",
"self",
".",
"jinja",
"=",... | Configures the xunit plugin. | [
"Configures",
"the",
"xunit",
"plugin",
"."
] | 1cda401c09fcffdb30bc240fb15c31b68d7a6594 | https://github.com/ionelmc/nose-htmloutput/blob/1cda401c09fcffdb30bc240fb15c31b68d7a6594/src/nose_htmloutput/__init__.py#L98-L110 |
49,264 | ionelmc/nose-htmloutput | src/nose_htmloutput/__init__.py | HtmlOutput.report | def report(self, stream):
"""Writes an Xunit-formatted XML file
The file includes a report of test errors and failures.
"""
from collections import OrderedDict
self.stats['total'] = sum(self.stats.values())
for group in self.report_data.values():
group.stats... | python | def report(self, stream):
"""Writes an Xunit-formatted XML file
The file includes a report of test errors and failures.
"""
from collections import OrderedDict
self.stats['total'] = sum(self.stats.values())
for group in self.report_data.values():
group.stats... | [
"def",
"report",
"(",
"self",
",",
"stream",
")",
":",
"from",
"collections",
"import",
"OrderedDict",
"self",
".",
"stats",
"[",
"'total'",
"]",
"=",
"sum",
"(",
"self",
".",
"stats",
".",
"values",
"(",
")",
")",
"for",
"group",
"in",
"self",
".",
... | Writes an Xunit-formatted XML file
The file includes a report of test errors and failures. | [
"Writes",
"an",
"Xunit",
"-",
"formatted",
"XML",
"file"
] | 1cda401c09fcffdb30bc240fb15c31b68d7a6594 | https://github.com/ionelmc/nose-htmloutput/blob/1cda401c09fcffdb30bc240fb15c31b68d7a6594/src/nose_htmloutput/__init__.py#L112-L129 |
49,265 | ionelmc/nose-htmloutput | src/nose_htmloutput/__init__.py | HtmlOutput.addError | def addError(self, test, err, capt=None):
"""Add error output to Xunit report.
"""
exc_type, exc_val, tb = err
tb = ''.join(traceback.format_exception(
exc_type,
exc_val if isinstance(exc_val, exc_type) else exc_type(exc_val),
tb
))
nam... | python | def addError(self, test, err, capt=None):
"""Add error output to Xunit report.
"""
exc_type, exc_val, tb = err
tb = ''.join(traceback.format_exception(
exc_type,
exc_val if isinstance(exc_val, exc_type) else exc_type(exc_val),
tb
))
nam... | [
"def",
"addError",
"(",
"self",
",",
"test",
",",
"err",
",",
"capt",
"=",
"None",
")",
":",
"exc_type",
",",
"exc_val",
",",
"tb",
"=",
"err",
"tb",
"=",
"''",
".",
"join",
"(",
"traceback",
".",
"format_exception",
"(",
"exc_type",
",",
"exc_val",
... | Add error output to Xunit report. | [
"Add",
"error",
"output",
"to",
"Xunit",
"report",
"."
] | 1cda401c09fcffdb30bc240fb15c31b68d7a6594 | https://github.com/ionelmc/nose-htmloutput/blob/1cda401c09fcffdb30bc240fb15c31b68d7a6594/src/nose_htmloutput/__init__.py#L141-L167 |
49,266 | AliLozano/django-messages-extends | messages_extends/storages.py | FallbackStorage._get | def _get(self, *args, **kwargs):
"""
Gets a single list of messages from all storage backends.
"""
all_messages = []
for storage in self.storages:
messages, all_retrieved = storage._get()
# If the backend hasn't been used, no more retrieval is necessary.
... | python | def _get(self, *args, **kwargs):
"""
Gets a single list of messages from all storage backends.
"""
all_messages = []
for storage in self.storages:
messages, all_retrieved = storage._get()
# If the backend hasn't been used, no more retrieval is necessary.
... | [
"def",
"_get",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"all_messages",
"=",
"[",
"]",
"for",
"storage",
"in",
"self",
".",
"storages",
":",
"messages",
",",
"all_retrieved",
"=",
"storage",
".",
"_get",
"(",
")",
"# If the b... | Gets a single list of messages from all storage backends. | [
"Gets",
"a",
"single",
"list",
"of",
"messages",
"from",
"all",
"storage",
"backends",
"."
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/storages.py#L54-L71 |
49,267 | AliLozano/django-messages-extends | messages_extends/storages.py | FallbackStorage._store | def _store(self, messages, response, *args, **kwargs):
"""
Stores the messages, returning any unstored messages after trying all
backends.
For each storage backend, any messages not stored are passed on to the
next backend.
"""
for storage in self.storages:
... | python | def _store(self, messages, response, *args, **kwargs):
"""
Stores the messages, returning any unstored messages after trying all
backends.
For each storage backend, any messages not stored are passed on to the
next backend.
"""
for storage in self.storages:
... | [
"def",
"_store",
"(",
"self",
",",
"messages",
",",
"response",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"storage",
"in",
"self",
".",
"storages",
":",
"if",
"messages",
":",
"messages",
"=",
"storage",
".",
"_store",
"(",
"message... | Stores the messages, returning any unstored messages after trying all
backends.
For each storage backend, any messages not stored are passed on to the
next backend. | [
"Stores",
"the",
"messages",
"returning",
"any",
"unstored",
"messages",
"after",
"trying",
"all",
"backends",
"."
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/storages.py#L73-L90 |
49,268 | AliLozano/django-messages-extends | messages_extends/storages.py | PersistentStorage._message_queryset | def _message_queryset(self, include_read=False):
"""
Return a queryset of messages for the request user
"""
expire = timezone.now()
qs = PersistentMessage.objects.\
filter(user=self.get_user()).\
filter(Q(expires=None) | Q(expires__gt=expire))
if not inc... | python | def _message_queryset(self, include_read=False):
"""
Return a queryset of messages for the request user
"""
expire = timezone.now()
qs = PersistentMessage.objects.\
filter(user=self.get_user()).\
filter(Q(expires=None) | Q(expires__gt=expire))
if not inc... | [
"def",
"_message_queryset",
"(",
"self",
",",
"include_read",
"=",
"False",
")",
":",
"expire",
"=",
"timezone",
".",
"now",
"(",
")",
"qs",
"=",
"PersistentMessage",
".",
"objects",
".",
"filter",
"(",
"user",
"=",
"self",
".",
"get_user",
"(",
")",
"... | Return a queryset of messages for the request user | [
"Return",
"a",
"queryset",
"of",
"messages",
"for",
"the",
"request",
"user"
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/storages.py#L134-L146 |
49,269 | AliLozano/django-messages-extends | messages_extends/storages.py | PersistentStorage.process_message | def process_message(self, message, *args, **kwargs):
"""
If its level is into persist levels, convert the message to models and save it
"""
if not message.level in PERSISTENT_MESSAGE_LEVELS:
return message
user = kwargs.get("user") or self.get_user()
try:
... | python | def process_message(self, message, *args, **kwargs):
"""
If its level is into persist levels, convert the message to models and save it
"""
if not message.level in PERSISTENT_MESSAGE_LEVELS:
return message
user = kwargs.get("user") or self.get_user()
try:
... | [
"def",
"process_message",
"(",
"self",
",",
"message",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"message",
".",
"level",
"in",
"PERSISTENT_MESSAGE_LEVELS",
":",
"return",
"message",
"user",
"=",
"kwargs",
".",
"get",
"(",
"\"user... | If its level is into persist levels, convert the message to models and save it | [
"If",
"its",
"level",
"is",
"into",
"persist",
"levels",
"convert",
"the",
"message",
"to",
"models",
"and",
"save",
"it"
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/storages.py#L167-L191 |
49,270 | AliLozano/django-messages-extends | messages_extends/storages.py | PersistentStorage.add | def add(self, level, message, extra_tags='', *args, **kwargs):
"""
Queues a message to be stored.
The message is only queued if it contained something and its level is
not less than the recording level (``self.level``).
"""
if not message:
return
... | python | def add(self, level, message, extra_tags='', *args, **kwargs):
"""
Queues a message to be stored.
The message is only queued if it contained something and its level is
not less than the recording level (``self.level``).
"""
if not message:
return
... | [
"def",
"add",
"(",
"self",
",",
"level",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"message",
":",
"return",
"# Check that the message level is not less than the recording level.",
"level",
... | Queues a message to be stored.
The message is only queued if it contained something and its level is
not less than the recording level (``self.level``). | [
"Queues",
"a",
"message",
"to",
"be",
"stored",
"."
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/storages.py#L193-L211 |
49,271 | AliLozano/django-messages-extends | messages_extends/storages.py | StickyStorage._store | def _store(self, messages, response, *args, **kwargs):
"""
Delete all messages that are sticky and return the other messages
This storage never save objects
"""
return [message for message in messages if not message.level in STICKY_MESSAGE_LEVELS] | python | def _store(self, messages, response, *args, **kwargs):
"""
Delete all messages that are sticky and return the other messages
This storage never save objects
"""
return [message for message in messages if not message.level in STICKY_MESSAGE_LEVELS] | [
"def",
"_store",
"(",
"self",
",",
"messages",
",",
"response",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"message",
"for",
"message",
"in",
"messages",
"if",
"not",
"message",
".",
"level",
"in",
"STICKY_MESSAGE_LEVELS",
"]"
] | Delete all messages that are sticky and return the other messages
This storage never save objects | [
"Delete",
"all",
"messages",
"that",
"are",
"sticky",
"and",
"return",
"the",
"other",
"messages",
"This",
"storage",
"never",
"save",
"objects"
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/storages.py#L234-L239 |
49,272 | inveniosoftware/invenio-userprofiles | invenio_userprofiles/api.py | _get_current_userprofile | def _get_current_userprofile():
"""Get current user profile.
.. note:: If the user is anonymous, then a
:class:`invenio_userprofiles.models.AnonymousUserProfile` instance is
returned.
:returns: The :class:`invenio_userprofiles.models.UserProfile` instance.
"""
if current_user.is_an... | python | def _get_current_userprofile():
"""Get current user profile.
.. note:: If the user is anonymous, then a
:class:`invenio_userprofiles.models.AnonymousUserProfile` instance is
returned.
:returns: The :class:`invenio_userprofiles.models.UserProfile` instance.
"""
if current_user.is_an... | [
"def",
"_get_current_userprofile",
"(",
")",
":",
"if",
"current_user",
".",
"is_anonymous",
":",
"return",
"AnonymousUserProfile",
"(",
")",
"profile",
"=",
"g",
".",
"get",
"(",
"'userprofile'",
",",
"UserProfile",
".",
"get_by_userid",
"(",
"current_user",
".... | Get current user profile.
.. note:: If the user is anonymous, then a
:class:`invenio_userprofiles.models.AnonymousUserProfile` instance is
returned.
:returns: The :class:`invenio_userprofiles.models.UserProfile` instance. | [
"Get",
"current",
"user",
"profile",
"."
] | 4c682e7d67a4cab8dc38472a31fa1c34cbba03dd | https://github.com/inveniosoftware/invenio-userprofiles/blob/4c682e7d67a4cab8dc38472a31fa1c34cbba03dd/invenio_userprofiles/api.py#L20-L39 |
49,273 | quantrocket-llc/ibapi-grease | ibapi_grease/log.py | silence_ibapi_logging | def silence_ibapi_logging(levels=["DEBUG", "INFO"]):
"""
Silences the excessive ibapi logging to the root logger.
"""
levels = levels or ["DEBUG", "INFO"]
for level in levels:
if level not in ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"):
raise ValueError("unknown log level:... | python | def silence_ibapi_logging(levels=["DEBUG", "INFO"]):
"""
Silences the excessive ibapi logging to the root logger.
"""
levels = levels or ["DEBUG", "INFO"]
for level in levels:
if level not in ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"):
raise ValueError("unknown log level:... | [
"def",
"silence_ibapi_logging",
"(",
"levels",
"=",
"[",
"\"DEBUG\"",
",",
"\"INFO\"",
"]",
")",
":",
"levels",
"=",
"levels",
"or",
"[",
"\"DEBUG\"",
",",
"\"INFO\"",
"]",
"for",
"level",
"in",
"levels",
":",
"if",
"level",
"not",
"in",
"(",
"\"DEBUG\""... | Silences the excessive ibapi logging to the root logger. | [
"Silences",
"the",
"excessive",
"ibapi",
"logging",
"to",
"the",
"root",
"logger",
"."
] | d157477114ce7280d49ffe1e39d68e49f66647e3 | https://github.com/quantrocket-llc/ibapi-grease/blob/d157477114ce7280d49ffe1e39d68e49f66647e3/ibapi_grease/log.py#L24-L40 |
49,274 | AliLozano/django-messages-extends | messages_extends/__init__.py | persistant_debug | def persistant_debug(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``DEBUG`` level.
"""
add_message(request, DEBUG_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | python | def persistant_debug(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``DEBUG`` level.
"""
add_message(request, DEBUG_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | [
"def",
"persistant_debug",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"add_message",
"(",
"request",
",",
"DEBUG_PERSISTENT",
",",
"message",
",",
... | Adds a persistant message with the ``DEBUG`` level. | [
"Adds",
"a",
"persistant",
"message",
"with",
"the",
"DEBUG",
"level",
"."
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/__init__.py#L20-L25 |
49,275 | AliLozano/django-messages-extends | messages_extends/__init__.py | persistant_info | def persistant_info(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``INFO`` level.
"""
add_message(request, INFO_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | python | def persistant_info(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``INFO`` level.
"""
add_message(request, INFO_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | [
"def",
"persistant_info",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"add_message",
"(",
"request",
",",
"INFO_PERSISTENT",
",",
"message",
",",
"... | Adds a persistant message with the ``INFO`` level. | [
"Adds",
"a",
"persistant",
"message",
"with",
"the",
"INFO",
"level",
"."
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/__init__.py#L30-L35 |
49,276 | AliLozano/django-messages-extends | messages_extends/__init__.py | persistant_success | def persistant_success(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``SUCCESS`` level.
"""
add_message(request, SUCCESS_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | python | def persistant_success(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``SUCCESS`` level.
"""
add_message(request, SUCCESS_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | [
"def",
"persistant_success",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"add_message",
"(",
"request",
",",
"SUCCESS_PERSISTENT",
",",
"message",
",... | Adds a persistant message with the ``SUCCESS`` level. | [
"Adds",
"a",
"persistant",
"message",
"with",
"the",
"SUCCESS",
"level",
"."
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/__init__.py#L40-L45 |
49,277 | AliLozano/django-messages-extends | messages_extends/__init__.py | persistant_warning | def persistant_warning(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``WARNING`` level.
"""
add_message(request, WARNING_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | python | def persistant_warning(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``WARNING`` level.
"""
add_message(request, WARNING_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | [
"def",
"persistant_warning",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"add_message",
"(",
"request",
",",
"WARNING_PERSISTENT",
",",
"message",
",... | Adds a persistant message with the ``WARNING`` level. | [
"Adds",
"a",
"persistant",
"message",
"with",
"the",
"WARNING",
"level",
"."
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/__init__.py#L50-L55 |
49,278 | AliLozano/django-messages-extends | messages_extends/__init__.py | persistant_error | def persistant_error(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``ERROR`` level.
"""
add_message(request, ERROR_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | python | def persistant_error(request, message, extra_tags='', fail_silently=False, *args, **kwargs):
"""
Adds a persistant message with the ``ERROR`` level.
"""
add_message(request, ERROR_PERSISTENT, message, extra_tags=extra_tags,
fail_silently=fail_silently, *args, **kwargs) | [
"def",
"persistant_error",
"(",
"request",
",",
"message",
",",
"extra_tags",
"=",
"''",
",",
"fail_silently",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"add_message",
"(",
"request",
",",
"ERROR_PERSISTENT",
",",
"message",
",",
... | Adds a persistant message with the ``ERROR`` level. | [
"Adds",
"a",
"persistant",
"message",
"with",
"the",
"ERROR",
"level",
"."
] | 141011981d44a6f28c6e82f9832815423b3b205f | https://github.com/AliLozano/django-messages-extends/blob/141011981d44a6f28c6e82f9832815423b3b205f/messages_extends/__init__.py#L60-L65 |
49,279 | bogdal/django-gcm | gcm/api.py | GCMMessage._chunks | def _chunks(self, items, limit):
"""
Yield successive chunks from list \a items with a minimum size \a limit
"""
for i in range(0, len(items), limit):
yield items[i:i + limit] | python | def _chunks(self, items, limit):
"""
Yield successive chunks from list \a items with a minimum size \a limit
"""
for i in range(0, len(items), limit):
yield items[i:i + limit] | [
"def",
"_chunks",
"(",
"self",
",",
"items",
",",
"limit",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"items",
")",
",",
"limit",
")",
":",
"yield",
"items",
"[",
"i",
":",
"i",
"+",
"limit",
"]"
] | Yield successive chunks from list \a items with a minimum size \a limit | [
"Yield",
"successive",
"chunks",
"from",
"list",
"\\",
"a",
"items",
"with",
"a",
"minimum",
"size",
"\\",
"a",
"limit"
] | d11f8fcb038677e292bf8ffb4057ef51cf3a2938 | https://github.com/bogdal/django-gcm/blob/d11f8fcb038677e292bf8ffb4057ef51cf3a2938/gcm/api.py#L19-L24 |
49,280 | gisle/isoweek | isoweek.py | Week.fromordinal | def fromordinal(cls, ordinal):
"""Return the week corresponding to the proleptic Gregorian ordinal,
where January 1 of year 1 starts the week with ordinal 1.
"""
if ordinal < 1:
raise ValueError("ordinal must be >= 1")
return super(Week, cls).__new__(cls, *(date.fromo... | python | def fromordinal(cls, ordinal):
"""Return the week corresponding to the proleptic Gregorian ordinal,
where January 1 of year 1 starts the week with ordinal 1.
"""
if ordinal < 1:
raise ValueError("ordinal must be >= 1")
return super(Week, cls).__new__(cls, *(date.fromo... | [
"def",
"fromordinal",
"(",
"cls",
",",
"ordinal",
")",
":",
"if",
"ordinal",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"ordinal must be >= 1\"",
")",
"return",
"super",
"(",
"Week",
",",
"cls",
")",
".",
"__new__",
"(",
"cls",
",",
"*",
"(",
"date",... | Return the week corresponding to the proleptic Gregorian ordinal,
where January 1 of year 1 starts the week with ordinal 1. | [
"Return",
"the",
"week",
"corresponding",
"to",
"the",
"proleptic",
"Gregorian",
"ordinal",
"where",
"January",
"1",
"of",
"year",
"1",
"starts",
"the",
"week",
"with",
"ordinal",
"1",
"."
] | c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b | https://github.com/gisle/isoweek/blob/c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b/isoweek.py#L46-L52 |
49,281 | gisle/isoweek | isoweek.py | Week.fromstring | def fromstring(cls, isostring):
"""Return a week initialized from an ISO formatted string like "2011W08" or "2011-W08"."""
if isinstance(isostring, basestring) and len(isostring) == 7 and isostring[4] == 'W':
return cls(int(isostring[0:4]), int(isostring[5:7]))
elif isinstance(isostri... | python | def fromstring(cls, isostring):
"""Return a week initialized from an ISO formatted string like "2011W08" or "2011-W08"."""
if isinstance(isostring, basestring) and len(isostring) == 7 and isostring[4] == 'W':
return cls(int(isostring[0:4]), int(isostring[5:7]))
elif isinstance(isostri... | [
"def",
"fromstring",
"(",
"cls",
",",
"isostring",
")",
":",
"if",
"isinstance",
"(",
"isostring",
",",
"basestring",
")",
"and",
"len",
"(",
"isostring",
")",
"==",
"7",
"and",
"isostring",
"[",
"4",
"]",
"==",
"'W'",
":",
"return",
"cls",
"(",
"int... | Return a week initialized from an ISO formatted string like "2011W08" or "2011-W08". | [
"Return",
"a",
"week",
"initialized",
"from",
"an",
"ISO",
"formatted",
"string",
"like",
"2011W08",
"or",
"2011",
"-",
"W08",
"."
] | c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b | https://github.com/gisle/isoweek/blob/c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b/isoweek.py#L55-L62 |
49,282 | gisle/isoweek | isoweek.py | Week.weeks_of_year | def weeks_of_year(cls, year):
"""Return an iterator over the weeks of the given year.
Years have either 52 or 53 weeks."""
w = cls(year, 1)
while w.year == year:
yield w
w += 1 | python | def weeks_of_year(cls, year):
"""Return an iterator over the weeks of the given year.
Years have either 52 or 53 weeks."""
w = cls(year, 1)
while w.year == year:
yield w
w += 1 | [
"def",
"weeks_of_year",
"(",
"cls",
",",
"year",
")",
":",
"w",
"=",
"cls",
"(",
"year",
",",
"1",
")",
"while",
"w",
".",
"year",
"==",
"year",
":",
"yield",
"w",
"w",
"+=",
"1"
] | Return an iterator over the weeks of the given year.
Years have either 52 or 53 weeks. | [
"Return",
"an",
"iterator",
"over",
"the",
"weeks",
"of",
"the",
"given",
"year",
".",
"Years",
"have",
"either",
"52",
"or",
"53",
"weeks",
"."
] | c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b | https://github.com/gisle/isoweek/blob/c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b/isoweek.py#L70-L76 |
49,283 | gisle/isoweek | isoweek.py | Week.last_week_of_year | def last_week_of_year(cls, year):
"""Return the last week of the given year.
This week with either have week-number 52 or 53.
This will be the same as Week(year+1, 0), but will even work for
year 9999 where this expression would overflow.
The first week of a given year is simpl... | python | def last_week_of_year(cls, year):
"""Return the last week of the given year.
This week with either have week-number 52 or 53.
This will be the same as Week(year+1, 0), but will even work for
year 9999 where this expression would overflow.
The first week of a given year is simpl... | [
"def",
"last_week_of_year",
"(",
"cls",
",",
"year",
")",
":",
"if",
"year",
"==",
"cls",
".",
"max",
".",
"year",
":",
"return",
"cls",
".",
"max",
"return",
"cls",
"(",
"year",
"+",
"1",
",",
"0",
")"
] | Return the last week of the given year.
This week with either have week-number 52 or 53.
This will be the same as Week(year+1, 0), but will even work for
year 9999 where this expression would overflow.
The first week of a given year is simply Week(year, 1), so there
is no dedic... | [
"Return",
"the",
"last",
"week",
"of",
"the",
"given",
"year",
".",
"This",
"week",
"with",
"either",
"have",
"week",
"-",
"number",
"52",
"or",
"53",
"."
] | c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b | https://github.com/gisle/isoweek/blob/c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b/isoweek.py#L79-L91 |
49,284 | gisle/isoweek | isoweek.py | Week.day | def day(self, num):
"""Return the given day of week as a date object. Day 0 is the Monday."""
d = date(self.year, 1, 4) # The Jan 4th must be in week 1 according to ISO
return d + timedelta(weeks=self.week-1, days=-d.weekday() + num) | python | def day(self, num):
"""Return the given day of week as a date object. Day 0 is the Monday."""
d = date(self.year, 1, 4) # The Jan 4th must be in week 1 according to ISO
return d + timedelta(weeks=self.week-1, days=-d.weekday() + num) | [
"def",
"day",
"(",
"self",
",",
"num",
")",
":",
"d",
"=",
"date",
"(",
"self",
".",
"year",
",",
"1",
",",
"4",
")",
"# The Jan 4th must be in week 1 according to ISO",
"return",
"d",
"+",
"timedelta",
"(",
"weeks",
"=",
"self",
".",
"week",
"-",
"1",... | Return the given day of week as a date object. Day 0 is the Monday. | [
"Return",
"the",
"given",
"day",
"of",
"week",
"as",
"a",
"date",
"object",
".",
"Day",
"0",
"is",
"the",
"Monday",
"."
] | c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b | https://github.com/gisle/isoweek/blob/c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b/isoweek.py#L93-L96 |
49,285 | gisle/isoweek | isoweek.py | Week.replace | def replace(self, year=None, week=None):
"""Return a Week with either the year or week attribute value replaced"""
return self.__class__(self.year if year is None else year,
self.week if week is None else week) | python | def replace(self, year=None, week=None):
"""Return a Week with either the year or week attribute value replaced"""
return self.__class__(self.year if year is None else year,
self.week if week is None else week) | [
"def",
"replace",
"(",
"self",
",",
"year",
"=",
"None",
",",
"week",
"=",
"None",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"year",
"if",
"year",
"is",
"None",
"else",
"year",
",",
"self",
".",
"week",
"if",
"week",
"is",
"... | Return a Week with either the year or week attribute value replaced | [
"Return",
"a",
"Week",
"with",
"either",
"the",
"year",
"or",
"week",
"attribute",
"value",
"replaced"
] | c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b | https://github.com/gisle/isoweek/blob/c6f2cc01f1dbc7cfdf75294421ad14ab4007d93b/isoweek.py#L139-L142 |
49,286 | zebpalmer/WeatherAlerts | weatheralerts/alert.py | _ts_parse | def _ts_parse(ts):
"""Parse alert timestamp, return UTC datetime object to maintain Python 2 compatibility."""
dt = datetime.strptime(ts[:19],"%Y-%m-%dT%H:%M:%S")
if ts[19] == '+':
dt -= timedelta(hours=int(ts[20:22]),minutes=int(ts[23:]))
elif ts[19] == '-':
dt += timedelta(hours=int(ts... | python | def _ts_parse(ts):
"""Parse alert timestamp, return UTC datetime object to maintain Python 2 compatibility."""
dt = datetime.strptime(ts[:19],"%Y-%m-%dT%H:%M:%S")
if ts[19] == '+':
dt -= timedelta(hours=int(ts[20:22]),minutes=int(ts[23:]))
elif ts[19] == '-':
dt += timedelta(hours=int(ts... | [
"def",
"_ts_parse",
"(",
"ts",
")",
":",
"dt",
"=",
"datetime",
".",
"strptime",
"(",
"ts",
"[",
":",
"19",
"]",
",",
"\"%Y-%m-%dT%H:%M:%S\"",
")",
"if",
"ts",
"[",
"19",
"]",
"==",
"'+'",
":",
"dt",
"-=",
"timedelta",
"(",
"hours",
"=",
"int",
"... | Parse alert timestamp, return UTC datetime object to maintain Python 2 compatibility. | [
"Parse",
"alert",
"timestamp",
"return",
"UTC",
"datetime",
"object",
"to",
"maintain",
"Python",
"2",
"compatibility",
"."
] | b99513571571fa0d65b90be883bb3bc000994027 | https://github.com/zebpalmer/WeatherAlerts/blob/b99513571571fa0d65b90be883bb3bc000994027/weatheralerts/alert.py#L4-L11 |
49,287 | zebpalmer/WeatherAlerts | weatheralerts/alert.py | Alert._serialized | def _serialized(self):
"""Provides a sanitized & serializeable dict of the alert mainly for forward & backwards compatibility"""
return {'title': self.title,
'summary': self.summary,
'areadesc': self.areadesc,
'event': self.event,
'samecode... | python | def _serialized(self):
"""Provides a sanitized & serializeable dict of the alert mainly for forward & backwards compatibility"""
return {'title': self.title,
'summary': self.summary,
'areadesc': self.areadesc,
'event': self.event,
'samecode... | [
"def",
"_serialized",
"(",
"self",
")",
":",
"return",
"{",
"'title'",
":",
"self",
".",
"title",
",",
"'summary'",
":",
"self",
".",
"summary",
",",
"'areadesc'",
":",
"self",
".",
"areadesc",
",",
"'event'",
":",
"self",
".",
"event",
",",
"'samecode... | Provides a sanitized & serializeable dict of the alert mainly for forward & backwards compatibility | [
"Provides",
"a",
"sanitized",
"&",
"serializeable",
"dict",
"of",
"the",
"alert",
"mainly",
"for",
"forward",
"&",
"backwards",
"compatibility"
] | b99513571571fa0d65b90be883bb3bc000994027 | https://github.com/zebpalmer/WeatherAlerts/blob/b99513571571fa0d65b90be883bb3bc000994027/weatheralerts/alert.py#L29-L46 |
49,288 | RIPE-NCC/ripe.atlas.sagan | ripe/atlas/sagan/base.py | ParsingDict.clean_protocol | def clean_protocol(self, protocol):
"""
A lot of measurement types make use of a protocol value, so we handle
that here.
"""
if protocol is not None:
try:
return self.PROTOCOL_MAP[protocol]
except KeyError:
self._handle_malf... | python | def clean_protocol(self, protocol):
"""
A lot of measurement types make use of a protocol value, so we handle
that here.
"""
if protocol is not None:
try:
return self.PROTOCOL_MAP[protocol]
except KeyError:
self._handle_malf... | [
"def",
"clean_protocol",
"(",
"self",
",",
"protocol",
")",
":",
"if",
"protocol",
"is",
"not",
"None",
":",
"try",
":",
"return",
"self",
".",
"PROTOCOL_MAP",
"[",
"protocol",
"]",
"except",
"KeyError",
":",
"self",
".",
"_handle_malformation",
"(",
"'\"{... | A lot of measurement types make use of a protocol value, so we handle
that here. | [
"A",
"lot",
"of",
"measurement",
"types",
"make",
"use",
"of",
"a",
"protocol",
"value",
"so",
"we",
"handle",
"that",
"here",
"."
] | f0e57221cf0ba3504baddd3ea460fc955bc41cc6 | https://github.com/RIPE-NCC/ripe.atlas.sagan/blob/f0e57221cf0ba3504baddd3ea460fc955bc41cc6/ripe/atlas/sagan/base.py#L122-L135 |
49,289 | RIPE-NCC/ripe.atlas.sagan | ripe/atlas/sagan/base.py | Result.calculate_median | def calculate_median(given_list):
"""
Returns the median of values in the given list.
"""
median = None
if not given_list:
return median
given_list = sorted(given_list)
list_length = len(given_list)
if list_length % 2:
median = g... | python | def calculate_median(given_list):
"""
Returns the median of values in the given list.
"""
median = None
if not given_list:
return median
given_list = sorted(given_list)
list_length = len(given_list)
if list_length % 2:
median = g... | [
"def",
"calculate_median",
"(",
"given_list",
")",
":",
"median",
"=",
"None",
"if",
"not",
"given_list",
":",
"return",
"median",
"given_list",
"=",
"sorted",
"(",
"given_list",
")",
"list_length",
"=",
"len",
"(",
"given_list",
")",
"if",
"list_length",
"%... | Returns the median of values in the given list. | [
"Returns",
"the",
"median",
"of",
"values",
"in",
"the",
"given",
"list",
"."
] | f0e57221cf0ba3504baddd3ea460fc955bc41cc6 | https://github.com/RIPE-NCC/ripe.atlas.sagan/blob/f0e57221cf0ba3504baddd3ea460fc955bc41cc6/ripe/atlas/sagan/base.py#L264-L281 |
49,290 | RIPE-NCC/ripe.atlas.sagan | ripe/atlas/sagan/ssl.py | Certificate._get_subject_alternative_names | def _get_subject_alternative_names(self, ext):
"""
Return a list of Subject Alternative Name values for the given x509
extension object.
"""
values = []
for san in ext.value:
if isinstance(san.value, string):
# Pass on simple string SAN values
... | python | def _get_subject_alternative_names(self, ext):
"""
Return a list of Subject Alternative Name values for the given x509
extension object.
"""
values = []
for san in ext.value:
if isinstance(san.value, string):
# Pass on simple string SAN values
... | [
"def",
"_get_subject_alternative_names",
"(",
"self",
",",
"ext",
")",
":",
"values",
"=",
"[",
"]",
"for",
"san",
"in",
"ext",
".",
"value",
":",
"if",
"isinstance",
"(",
"san",
".",
"value",
",",
"string",
")",
":",
"# Pass on simple string SAN values",
... | Return a list of Subject Alternative Name values for the given x509
extension object. | [
"Return",
"a",
"list",
"of",
"Subject",
"Alternative",
"Name",
"values",
"for",
"the",
"given",
"x509",
"extension",
"object",
"."
] | f0e57221cf0ba3504baddd3ea460fc955bc41cc6 | https://github.com/RIPE-NCC/ripe.atlas.sagan/blob/f0e57221cf0ba3504baddd3ea460fc955bc41cc6/ripe/atlas/sagan/ssl.py#L113-L128 |
49,291 | DancingQuanta/pyusbiss | usbiss/spi.py | SPI.configure | def configure(self):
"""
Configure SPI controller with the SPI mode and operating frequency
"""
# Convert standard SPI sheme to USBISS scheme
lookup_table = [0, 2, 1, 3]
mode = lookup_table[self._mode]
# Add signal for SPI switch
iss_mode = self._usbiss.... | python | def configure(self):
"""
Configure SPI controller with the SPI mode and operating frequency
"""
# Convert standard SPI sheme to USBISS scheme
lookup_table = [0, 2, 1, 3]
mode = lookup_table[self._mode]
# Add signal for SPI switch
iss_mode = self._usbiss.... | [
"def",
"configure",
"(",
"self",
")",
":",
"# Convert standard SPI sheme to USBISS scheme",
"lookup_table",
"=",
"[",
"0",
",",
"2",
",",
"1",
",",
"3",
"]",
"mode",
"=",
"lookup_table",
"[",
"self",
".",
"_mode",
"]",
"# Add signal for SPI switch",
"iss_mode",
... | Configure SPI controller with the SPI mode and operating frequency | [
"Configure",
"SPI",
"controller",
"with",
"the",
"SPI",
"mode",
"and",
"operating",
"frequency"
] | fc64e123f1c97f53ad153c474d230ad38044c3cb | https://github.com/DancingQuanta/pyusbiss/blob/fc64e123f1c97f53ad153c474d230ad38044c3cb/usbiss/spi.py#L32-L45 |
49,292 | DancingQuanta/pyusbiss | usbiss/spi.py | SPI.iss_spi_divisor | def iss_spi_divisor(self, sck):
"""
Calculate a USBISS SPI divisor value from the input SPI clock speed
:param sck: SPI clock frequency
:type sck: int
:returns: ISS SCK divisor
:rtype: int
"""
_divisor = (6000000 / sck) - 1
divisor = int(_divisor)... | python | def iss_spi_divisor(self, sck):
"""
Calculate a USBISS SPI divisor value from the input SPI clock speed
:param sck: SPI clock frequency
:type sck: int
:returns: ISS SCK divisor
:rtype: int
"""
_divisor = (6000000 / sck) - 1
divisor = int(_divisor)... | [
"def",
"iss_spi_divisor",
"(",
"self",
",",
"sck",
")",
":",
"_divisor",
"=",
"(",
"6000000",
"/",
"sck",
")",
"-",
"1",
"divisor",
"=",
"int",
"(",
"_divisor",
")",
"if",
"divisor",
"!=",
"_divisor",
":",
"raise",
"ValueError",
"(",
"'Non-integer SCK di... | Calculate a USBISS SPI divisor value from the input SPI clock speed
:param sck: SPI clock frequency
:type sck: int
:returns: ISS SCK divisor
:rtype: int | [
"Calculate",
"a",
"USBISS",
"SPI",
"divisor",
"value",
"from",
"the",
"input",
"SPI",
"clock",
"speed"
] | fc64e123f1c97f53ad153c474d230ad38044c3cb | https://github.com/DancingQuanta/pyusbiss/blob/fc64e123f1c97f53ad153c474d230ad38044c3cb/usbiss/spi.py#L95-L116 |
49,293 | DancingQuanta/pyusbiss | usbiss/spi.py | SPI.exchange | def exchange(self, data):
"""
Perform SPI transaction.
The first received byte is either ACK or NACK.
:TODO: enforce rule that up to 63 bytes of data can be sent.
:TODO: enforce rule that there is no gaps in data bytes (what define a gap?)
:param data: List of bytes
... | python | def exchange(self, data):
"""
Perform SPI transaction.
The first received byte is either ACK or NACK.
:TODO: enforce rule that up to 63 bytes of data can be sent.
:TODO: enforce rule that there is no gaps in data bytes (what define a gap?)
:param data: List of bytes
... | [
"def",
"exchange",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_usbiss",
".",
"write_data",
"(",
"[",
"self",
".",
"_usbiss",
".",
"SPI_CMD",
"]",
"+",
"data",
")",
"response",
"=",
"self",
".",
"_usbiss",
".",
"read_data",
"(",
"1",
"+",
"le... | Perform SPI transaction.
The first received byte is either ACK or NACK.
:TODO: enforce rule that up to 63 bytes of data can be sent.
:TODO: enforce rule that there is no gaps in data bytes (what define a gap?)
:param data: List of bytes
:returns: List of bytes
:rtype: ... | [
"Perform",
"SPI",
"transaction",
"."
] | fc64e123f1c97f53ad153c474d230ad38044c3cb | https://github.com/DancingQuanta/pyusbiss/blob/fc64e123f1c97f53ad153c474d230ad38044c3cb/usbiss/spi.py#L118-L140 |
49,294 | zebpalmer/WeatherAlerts | weatheralerts/feed.py | AlertsFeed._get_feed_cache | def _get_feed_cache(self):
"""If a recent cache exists, return it, else return None"""
feed_cache = None
if os.path.exists(self._feed_cache_file):
maxage = datetime.now() - timedelta(minutes=self._cachetime)
file_ts = datetime.fromtimestamp(os.stat(self._feed_cache_file).... | python | def _get_feed_cache(self):
"""If a recent cache exists, return it, else return None"""
feed_cache = None
if os.path.exists(self._feed_cache_file):
maxage = datetime.now() - timedelta(minutes=self._cachetime)
file_ts = datetime.fromtimestamp(os.stat(self._feed_cache_file).... | [
"def",
"_get_feed_cache",
"(",
"self",
")",
":",
"feed_cache",
"=",
"None",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_feed_cache_file",
")",
":",
"maxage",
"=",
"datetime",
".",
"now",
"(",
")",
"-",
"timedelta",
"(",
"minutes",
"=",
... | If a recent cache exists, return it, else return None | [
"If",
"a",
"recent",
"cache",
"exists",
"return",
"it",
"else",
"return",
"None"
] | b99513571571fa0d65b90be883bb3bc000994027 | https://github.com/zebpalmer/WeatherAlerts/blob/b99513571571fa0d65b90be883bb3bc000994027/weatheralerts/feed.py#L24-L36 |
49,295 | RIPE-NCC/ripe.atlas.sagan | ripe/atlas/sagan/ntp.py | NtpResult._set_medians_and_extremes | def _set_medians_and_extremes(self):
"""
Sets median values for rtt and the offset of result packets.
"""
rtts = sorted([p.rtt for p in self.packets if p.rtt is not None])
if rtts:
self.rtt_min = rtts[0]
self.rtt_max = rtts[-1]
self.rtt_median... | python | def _set_medians_and_extremes(self):
"""
Sets median values for rtt and the offset of result packets.
"""
rtts = sorted([p.rtt for p in self.packets if p.rtt is not None])
if rtts:
self.rtt_min = rtts[0]
self.rtt_max = rtts[-1]
self.rtt_median... | [
"def",
"_set_medians_and_extremes",
"(",
"self",
")",
":",
"rtts",
"=",
"sorted",
"(",
"[",
"p",
".",
"rtt",
"for",
"p",
"in",
"self",
".",
"packets",
"if",
"p",
".",
"rtt",
"is",
"not",
"None",
"]",
")",
"if",
"rtts",
":",
"self",
".",
"rtt_min",
... | Sets median values for rtt and the offset of result packets. | [
"Sets",
"median",
"values",
"for",
"rtt",
"and",
"the",
"offset",
"of",
"result",
"packets",
"."
] | f0e57221cf0ba3504baddd3ea460fc955bc41cc6 | https://github.com/RIPE-NCC/ripe.atlas.sagan/blob/f0e57221cf0ba3504baddd3ea460fc955bc41cc6/ripe/atlas/sagan/ntp.py#L138-L155 |
49,296 | zebpalmer/WeatherAlerts | weatheralerts/weather_alerts.py | WeatherAlerts.county_state_alerts | def county_state_alerts(self, county, state):
"""Given a county and state, return alerts"""
samecode = self.geo.lookup_samecode(county, state)
return self.samecode_alerts(samecode) | python | def county_state_alerts(self, county, state):
"""Given a county and state, return alerts"""
samecode = self.geo.lookup_samecode(county, state)
return self.samecode_alerts(samecode) | [
"def",
"county_state_alerts",
"(",
"self",
",",
"county",
",",
"state",
")",
":",
"samecode",
"=",
"self",
".",
"geo",
".",
"lookup_samecode",
"(",
"county",
",",
"state",
")",
"return",
"self",
".",
"samecode_alerts",
"(",
"samecode",
")"
] | Given a county and state, return alerts | [
"Given",
"a",
"county",
"and",
"state",
"return",
"alerts"
] | b99513571571fa0d65b90be883bb3bc000994027 | https://github.com/zebpalmer/WeatherAlerts/blob/b99513571571fa0d65b90be883bb3bc000994027/weatheralerts/weather_alerts.py#L94-L97 |
49,297 | m0n5t3r/gstats | gstats/__init__.py | start_request | def start_request(req, collect=False, collector_addr='tcp://127.0.0.2:2345', prefix='my_app'):
"""
register a request
registers a request in the internal request table, optionally also sends it to the collector
:param req: request, can be mostly any hash-able object
:param collect: whether to send... | python | def start_request(req, collect=False, collector_addr='tcp://127.0.0.2:2345', prefix='my_app'):
"""
register a request
registers a request in the internal request table, optionally also sends it to the collector
:param req: request, can be mostly any hash-able object
:param collect: whether to send... | [
"def",
"start_request",
"(",
"req",
",",
"collect",
"=",
"False",
",",
"collector_addr",
"=",
"'tcp://127.0.0.2:2345'",
",",
"prefix",
"=",
"'my_app'",
")",
":",
"if",
"collect",
":",
"collector",
"=",
"get_context",
"(",
")",
".",
"socket",
"(",
"zmq",
".... | register a request
registers a request in the internal request table, optionally also sends it to the collector
:param req: request, can be mostly any hash-able object
:param collect: whether to send the request started event to the collector (bool)
:param collector_addr: collector address, in zeromq ... | [
"register",
"a",
"request"
] | ae600d309ae8a159079fe1d6e6fa1c9097125f5b | https://github.com/m0n5t3r/gstats/blob/ae600d309ae8a159079fe1d6e6fa1c9097125f5b/gstats/__init__.py#L37-L56 |
49,298 | m0n5t3r/gstats | gstats/__init__.py | end_request | def end_request(req, collector_addr='tcp://127.0.0.2:2345', prefix='my_app'):
"""
registers the end of a request
registers the end of a request, computes elapsed time, sends it to the collector
:param req: request, can be mostly any hash-able object
:param collector_addr: collector address, in zer... | python | def end_request(req, collector_addr='tcp://127.0.0.2:2345', prefix='my_app'):
"""
registers the end of a request
registers the end of a request, computes elapsed time, sends it to the collector
:param req: request, can be mostly any hash-able object
:param collector_addr: collector address, in zer... | [
"def",
"end_request",
"(",
"req",
",",
"collector_addr",
"=",
"'tcp://127.0.0.2:2345'",
",",
"prefix",
"=",
"'my_app'",
")",
":",
"req_end",
"=",
"time",
"(",
")",
"hreq",
"=",
"hash",
"(",
"req",
")",
"if",
"hreq",
"in",
"requests",
":",
"req_time",
"="... | registers the end of a request
registers the end of a request, computes elapsed time, sends it to the collector
:param req: request, can be mostly any hash-able object
:param collector_addr: collector address, in zeromq format (string, default tcp://127.0.0.2:2345)
:param prefix: label under which to ... | [
"registers",
"the",
"end",
"of",
"a",
"request"
] | ae600d309ae8a159079fe1d6e6fa1c9097125f5b | https://github.com/m0n5t3r/gstats/blob/ae600d309ae8a159079fe1d6e6fa1c9097125f5b/gstats/__init__.py#L58-L84 |
49,299 | zebpalmer/WeatherAlerts | weatheralerts/cap.py | build_target_areas | def build_target_areas(entry):
"""Cleanup the raw target areas description string"""
target_areas = []
areas = str(entry['cap:areaDesc']).split(';')
for area in areas:
target_areas.append(area.strip())
return target_areas | python | def build_target_areas(entry):
"""Cleanup the raw target areas description string"""
target_areas = []
areas = str(entry['cap:areaDesc']).split(';')
for area in areas:
target_areas.append(area.strip())
return target_areas | [
"def",
"build_target_areas",
"(",
"entry",
")",
":",
"target_areas",
"=",
"[",
"]",
"areas",
"=",
"str",
"(",
"entry",
"[",
"'cap:areaDesc'",
"]",
")",
".",
"split",
"(",
"';'",
")",
"for",
"area",
"in",
"areas",
":",
"target_areas",
".",
"append",
"("... | Cleanup the raw target areas description string | [
"Cleanup",
"the",
"raw",
"target",
"areas",
"description",
"string"
] | b99513571571fa0d65b90be883bb3bc000994027 | https://github.com/zebpalmer/WeatherAlerts/blob/b99513571571fa0d65b90be883bb3bc000994027/weatheralerts/cap.py#L7-L13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.