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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
241,300 | fictorial/filesysdb | filesysdb/__init__.py | _update_indexes_for_mutated_object | def _update_indexes_for_mutated_object(collection, obj):
"""If an object is updated, this will simply remove
it and re-add it to the indexes defined on the
collection."""
for index in _db[collection].indexes.values():
_remove_from_index(index, obj)
_add_to_index(index, obj) | python | def _update_indexes_for_mutated_object(collection, obj):
"""If an object is updated, this will simply remove
it and re-add it to the indexes defined on the
collection."""
for index in _db[collection].indexes.values():
_remove_from_index(index, obj)
_add_to_index(index, obj) | [
"def",
"_update_indexes_for_mutated_object",
"(",
"collection",
",",
"obj",
")",
":",
"for",
"index",
"in",
"_db",
"[",
"collection",
"]",
".",
"indexes",
".",
"values",
"(",
")",
":",
"_remove_from_index",
"(",
"index",
",",
"obj",
")",
"_add_to_index",
"("... | If an object is updated, this will simply remove
it and re-add it to the indexes defined on the
collection. | [
"If",
"an",
"object",
"is",
"updated",
"this",
"will",
"simply",
"remove",
"it",
"and",
"re",
"-",
"add",
"it",
"to",
"the",
"indexes",
"defined",
"on",
"the",
"collection",
"."
] | bbf1e32218b71c7c15c33ada660433fffc6fa6ab | https://github.com/fictorial/filesysdb/blob/bbf1e32218b71c7c15c33ada660433fffc6fa6ab/filesysdb/__init__.py#L276-L282 |
241,301 | fictorial/filesysdb | filesysdb/__init__.py | _update_indexes_for_deleted_object | def _update_indexes_for_deleted_object(collection, obj):
"""If an object is deleted, it should no longer be
indexed so this removes the object from all indexes
on the given collection."""
for index in _db[collection].indexes.values():
_remove_from_index(index, obj) | python | def _update_indexes_for_deleted_object(collection, obj):
"""If an object is deleted, it should no longer be
indexed so this removes the object from all indexes
on the given collection."""
for index in _db[collection].indexes.values():
_remove_from_index(index, obj) | [
"def",
"_update_indexes_for_deleted_object",
"(",
"collection",
",",
"obj",
")",
":",
"for",
"index",
"in",
"_db",
"[",
"collection",
"]",
".",
"indexes",
".",
"values",
"(",
")",
":",
"_remove_from_index",
"(",
"index",
",",
"obj",
")"
] | If an object is deleted, it should no longer be
indexed so this removes the object from all indexes
on the given collection. | [
"If",
"an",
"object",
"is",
"deleted",
"it",
"should",
"no",
"longer",
"be",
"indexed",
"so",
"this",
"removes",
"the",
"object",
"from",
"all",
"indexes",
"on",
"the",
"given",
"collection",
"."
] | bbf1e32218b71c7c15c33ada660433fffc6fa6ab | https://github.com/fictorial/filesysdb/blob/bbf1e32218b71c7c15c33ada660433fffc6fa6ab/filesysdb/__init__.py#L285-L290 |
241,302 | JNRowe/jnrbase | jnrbase/iso_8601.py | parse_delta | def parse_delta(__string: str) -> datetime.timedelta:
"""Parse ISO-8601 duration string.
Args:
__string: Duration string to parse
Returns:
Parsed delta object
"""
if not __string:
return datetime.timedelta(0)
match = re.fullmatch(r"""
P
((?P<days>\d+)D)?
... | python | def parse_delta(__string: str) -> datetime.timedelta:
"""Parse ISO-8601 duration string.
Args:
__string: Duration string to parse
Returns:
Parsed delta object
"""
if not __string:
return datetime.timedelta(0)
match = re.fullmatch(r"""
P
((?P<days>\d+)D)?
... | [
"def",
"parse_delta",
"(",
"__string",
":",
"str",
")",
"->",
"datetime",
".",
"timedelta",
":",
"if",
"not",
"__string",
":",
"return",
"datetime",
".",
"timedelta",
"(",
"0",
")",
"match",
"=",
"re",
".",
"fullmatch",
"(",
"r\"\"\"\n P\n ((?P... | Parse ISO-8601 duration string.
Args:
__string: Duration string to parse
Returns:
Parsed delta object | [
"Parse",
"ISO",
"-",
"8601",
"duration",
"string",
"."
] | ae505ef69a9feb739b5f4e62c5a8e6533104d3ea | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/iso_8601.py#L27-L48 |
241,303 | JNRowe/jnrbase | jnrbase/iso_8601.py | format_delta | def format_delta(__timedelta: datetime.timedelta) -> str:
"""Format ISO-8601 duration string.
Args:
__timedelta: Duration to process
Returns:
ISO-8601 representation of duration
"""
if __timedelta == datetime.timedelta(0):
return ''
days_s = '{}D'.format(__timedelta.days... | python | def format_delta(__timedelta: datetime.timedelta) -> str:
"""Format ISO-8601 duration string.
Args:
__timedelta: Duration to process
Returns:
ISO-8601 representation of duration
"""
if __timedelta == datetime.timedelta(0):
return ''
days_s = '{}D'.format(__timedelta.days... | [
"def",
"format_delta",
"(",
"__timedelta",
":",
"datetime",
".",
"timedelta",
")",
"->",
"str",
":",
"if",
"__timedelta",
"==",
"datetime",
".",
"timedelta",
"(",
"0",
")",
":",
"return",
"''",
"days_s",
"=",
"'{}D'",
".",
"format",
"(",
"__timedelta",
"... | Format ISO-8601 duration string.
Args:
__timedelta: Duration to process
Returns:
ISO-8601 representation of duration | [
"Format",
"ISO",
"-",
"8601",
"duration",
"string",
"."
] | ae505ef69a9feb739b5f4e62c5a8e6533104d3ea | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/iso_8601.py#L51-L69 |
241,304 | JNRowe/jnrbase | jnrbase/iso_8601.py | parse_datetime | def parse_datetime(__string: str) -> datetime.datetime:
"""Parse ISO-8601 datetime string.
Args:
__string: Datetime string to parse
Returns:
Parsed datetime object
"""
if not __string:
datetime_ = datetime.datetime.now(datetime.timezone.utc)
else:
# pylint: disab... | python | def parse_datetime(__string: str) -> datetime.datetime:
"""Parse ISO-8601 datetime string.
Args:
__string: Datetime string to parse
Returns:
Parsed datetime object
"""
if not __string:
datetime_ = datetime.datetime.now(datetime.timezone.utc)
else:
# pylint: disab... | [
"def",
"parse_datetime",
"(",
"__string",
":",
"str",
")",
"->",
"datetime",
".",
"datetime",
":",
"if",
"not",
"__string",
":",
"datetime_",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
"datetime",
".",
"timezone",
".",
"utc",
")",
"else",
":",
... | Parse ISO-8601 datetime string.
Args:
__string: Datetime string to parse
Returns:
Parsed datetime object | [
"Parse",
"ISO",
"-",
"8601",
"datetime",
"string",
"."
] | ae505ef69a9feb739b5f4e62c5a8e6533104d3ea | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/iso_8601.py#L72-L87 |
241,305 | shreyaspotnis/rampage | rampage/daq/daq.py | print_device_info | def print_device_info(dev_name):
"""Prints information about the given device.
Usage:
print_device_info("Dev1")
"""
string_buffer = ctypes.create_string_buffer(1024)
attributes = [pydaq.DAQmx_Dev_ProductType, pydaq.DAQmx_Dev_SerialNum,
pydaq.DAQmx_Dev_AO_PhysicalChans,
... | python | def print_device_info(dev_name):
"""Prints information about the given device.
Usage:
print_device_info("Dev1")
"""
string_buffer = ctypes.create_string_buffer(1024)
attributes = [pydaq.DAQmx_Dev_ProductType, pydaq.DAQmx_Dev_SerialNum,
pydaq.DAQmx_Dev_AO_PhysicalChans,
... | [
"def",
"print_device_info",
"(",
"dev_name",
")",
":",
"string_buffer",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"1024",
")",
"attributes",
"=",
"[",
"pydaq",
".",
"DAQmx_Dev_ProductType",
",",
"pydaq",
".",
"DAQmx_Dev_SerialNum",
",",
"pydaq",
".",
"DAQ... | Prints information about the given device.
Usage:
print_device_info("Dev1") | [
"Prints",
"information",
"about",
"the",
"given",
"device",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/daq.py#L28-L53 |
241,306 | shreyaspotnis/rampage | rampage/daq/daq.py | get_device_name_list | def get_device_name_list():
"""Returns a list of device names installed."""
dev_names = ctypes.create_string_buffer(1024)
pydaq.DAQmxGetSysDevNames(dev_names, len(dev_names))
return dev_names.value.split(', ') | python | def get_device_name_list():
"""Returns a list of device names installed."""
dev_names = ctypes.create_string_buffer(1024)
pydaq.DAQmxGetSysDevNames(dev_names, len(dev_names))
return dev_names.value.split(', ') | [
"def",
"get_device_name_list",
"(",
")",
":",
"dev_names",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"1024",
")",
"pydaq",
".",
"DAQmxGetSysDevNames",
"(",
"dev_names",
",",
"len",
"(",
"dev_names",
")",
")",
"return",
"dev_names",
".",
"value",
".",
... | Returns a list of device names installed. | [
"Returns",
"a",
"list",
"of",
"device",
"names",
"installed",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/daq.py#L56-L60 |
241,307 | shreyaspotnis/rampage | rampage/daq/daq.py | reset_analog_sample_clock | def reset_analog_sample_clock(state=False):
"""Reset the clock line.
Use this just before starting a run to avoid timing issues.
"""
set_digital_line_state(expt_settings.dev1_clock_out_name, state)
set_digital_line_state(expt_settings.dev2_clock_out_name, state)
set_digital_line_state(expt_sett... | python | def reset_analog_sample_clock(state=False):
"""Reset the clock line.
Use this just before starting a run to avoid timing issues.
"""
set_digital_line_state(expt_settings.dev1_clock_out_name, state)
set_digital_line_state(expt_settings.dev2_clock_out_name, state)
set_digital_line_state(expt_sett... | [
"def",
"reset_analog_sample_clock",
"(",
"state",
"=",
"False",
")",
":",
"set_digital_line_state",
"(",
"expt_settings",
".",
"dev1_clock_out_name",
",",
"state",
")",
"set_digital_line_state",
"(",
"expt_settings",
".",
"dev2_clock_out_name",
",",
"state",
")",
"set... | Reset the clock line.
Use this just before starting a run to avoid timing issues. | [
"Reset",
"the",
"clock",
"line",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/daq.py#L69-L77 |
241,308 | shreyaspotnis/rampage | rampage/daq/daq.py | set_digital_line_state | def set_digital_line_state(line_name, state):
"""Set the state of a single digital line.
line_name (str) - The physical name of the line.
e.g line_name="Dev1/port0/line3"
This should be a single digital line. Specifying more than one would
result in unexpected behaviour. For example "De... | python | def set_digital_line_state(line_name, state):
"""Set the state of a single digital line.
line_name (str) - The physical name of the line.
e.g line_name="Dev1/port0/line3"
This should be a single digital line. Specifying more than one would
result in unexpected behaviour. For example "De... | [
"def",
"set_digital_line_state",
"(",
"line_name",
",",
"state",
")",
":",
"# get the line number from the line name. Thats the number of bits to shift",
"bits_to_shift",
"=",
"int",
"(",
"line_name",
".",
"split",
"(",
"'line'",
")",
"[",
"-",
"1",
"]",
")",
"dig_dat... | Set the state of a single digital line.
line_name (str) - The physical name of the line.
e.g line_name="Dev1/port0/line3"
This should be a single digital line. Specifying more than one would
result in unexpected behaviour. For example "Dev1/port0/line0:5" is
not allowed.
see... | [
"Set",
"the",
"state",
"of",
"a",
"single",
"digital",
"line",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/daq.py#L80-L100 |
241,309 | shreyaspotnis/rampage | rampage/daq/daq.py | DigitalOutputTask.StartAndWait | def StartAndWait(self):
"""Starts the task and waits until it is done."""
self.StartTask()
self.WaitUntilTaskDone(pydaq.DAQmx_Val_WaitInfinitely)
self.ClearTask() | python | def StartAndWait(self):
"""Starts the task and waits until it is done."""
self.StartTask()
self.WaitUntilTaskDone(pydaq.DAQmx_Val_WaitInfinitely)
self.ClearTask() | [
"def",
"StartAndWait",
"(",
"self",
")",
":",
"self",
".",
"StartTask",
"(",
")",
"self",
".",
"WaitUntilTaskDone",
"(",
"pydaq",
".",
"DAQmx_Val_WaitInfinitely",
")",
"self",
".",
"ClearTask",
"(",
")"
] | Starts the task and waits until it is done. | [
"Starts",
"the",
"task",
"and",
"waits",
"until",
"it",
"is",
"done",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/daq.py#L164-L168 |
241,310 | shreyaspotnis/rampage | rampage/daq/daq.py | DigitalOutputTask.isDone | def isDone(self):
"""Returns true if task is done."""
done = pydaq.bool32()
self.IsTaskDone(ctypes.byref(done))
return done.value | python | def isDone(self):
"""Returns true if task is done."""
done = pydaq.bool32()
self.IsTaskDone(ctypes.byref(done))
return done.value | [
"def",
"isDone",
"(",
"self",
")",
":",
"done",
"=",
"pydaq",
".",
"bool32",
"(",
")",
"self",
".",
"IsTaskDone",
"(",
"ctypes",
".",
"byref",
"(",
"done",
")",
")",
"return",
"done",
".",
"value"
] | Returns true if task is done. | [
"Returns",
"true",
"if",
"task",
"is",
"done",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/daq.py#L170-L174 |
241,311 | shreyaspotnis/rampage | rampage/daq/daq.py | DigitalOutputTaskWithCallbacks.padDigitalData | def padDigitalData(self, dig_data, n):
"""Pad dig_data with its last element so that the new array is a
multiple of n.
"""
n = int(n)
l0 = len(dig_data)
if l0 % n == 0:
return dig_data # no need of padding
else:
ladd = n - (l0 % n)
... | python | def padDigitalData(self, dig_data, n):
"""Pad dig_data with its last element so that the new array is a
multiple of n.
"""
n = int(n)
l0 = len(dig_data)
if l0 % n == 0:
return dig_data # no need of padding
else:
ladd = n - (l0 % n)
... | [
"def",
"padDigitalData",
"(",
"self",
",",
"dig_data",
",",
"n",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"l0",
"=",
"len",
"(",
"dig_data",
")",
"if",
"l0",
"%",
"n",
"==",
"0",
":",
"return",
"dig_data",
"# no need of padding",
"else",
":",
"lad... | Pad dig_data with its last element so that the new array is a
multiple of n. | [
"Pad",
"dig_data",
"with",
"its",
"last",
"element",
"so",
"that",
"the",
"new",
"array",
"is",
"a",
"multiple",
"of",
"n",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/daq.py#L255-L267 |
241,312 | shreyaspotnis/rampage | rampage/daq/daq.py | DigitalOutputTaskWithCallbacks.EveryNCallback | def EveryNCallback(self):
"""Called by PyDAQmx whenever a callback event occurs."""
# print('ncall ', self.n_callbacks)
if self.do_callbacks:
if self.n_callbacks >= self.callback_step:
# print('n_callbacks', self.n_callbacks)
for func, func_dict in sel... | python | def EveryNCallback(self):
"""Called by PyDAQmx whenever a callback event occurs."""
# print('ncall ', self.n_callbacks)
if self.do_callbacks:
if self.n_callbacks >= self.callback_step:
# print('n_callbacks', self.n_callbacks)
for func, func_dict in sel... | [
"def",
"EveryNCallback",
"(",
"self",
")",
":",
"# print('ncall ', self.n_callbacks)",
"if",
"self",
".",
"do_callbacks",
":",
"if",
"self",
".",
"n_callbacks",
">=",
"self",
".",
"callback_step",
":",
"# print('n_callbacks', self.n_callbacks)",
"for",
"func",
",",
... | Called by PyDAQmx whenever a callback event occurs. | [
"Called",
"by",
"PyDAQmx",
"whenever",
"a",
"callback",
"event",
"occurs",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/daq/daq.py#L269-L292 |
241,313 | bsvetchine/django-payzen | django_payzen/tools.py | get_vads_trans_id | def get_vads_trans_id(vads_site_id, vads_trans_date):
"""
Returns a default value for vads_trans_id field.
vads_trans_id field is mandatory. It is composed by 6 numeric
characters that identifies the transaction. There is a unicity contraint
between vads_site_id and vads_trans_date (the first 8 cha... | python | def get_vads_trans_id(vads_site_id, vads_trans_date):
"""
Returns a default value for vads_trans_id field.
vads_trans_id field is mandatory. It is composed by 6 numeric
characters that identifies the transaction. There is a unicity contraint
between vads_site_id and vads_trans_date (the first 8 cha... | [
"def",
"get_vads_trans_id",
"(",
"vads_site_id",
",",
"vads_trans_date",
")",
":",
"vads_trans_id",
"=",
"\"\"",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"6",
")",
":",
"vads_trans_id",
"+=",
"str",
"(",
"random",
".",
"randint",
"(",
"0",
",",
"9",
"... | Returns a default value for vads_trans_id field.
vads_trans_id field is mandatory. It is composed by 6 numeric
characters that identifies the transaction. There is a unicity contraint
between vads_site_id and vads_trans_date (the first 8 characters
representing the transaction date).
We consider t... | [
"Returns",
"a",
"default",
"value",
"for",
"vads_trans_id",
"field",
"."
] | 944c3026120151495310cb1eb3c6370dc2db3db9 | https://github.com/bsvetchine/django-payzen/blob/944c3026120151495310cb1eb3c6370dc2db3db9/django_payzen/tools.py#L12-L26 |
241,314 | bsvetchine/django-payzen | django_payzen/tools.py | get_signature | def get_signature(payment_request):
"""
Returns the signature for the transaction.
To compute the signature, first you have to get the value of all
the fields that starts by 'vads_', ordering them alphabetically.
All the values are separated by the '+' character. Then you add
the value of the p... | python | def get_signature(payment_request):
"""
Returns the signature for the transaction.
To compute the signature, first you have to get the value of all
the fields that starts by 'vads_', ordering them alphabetically.
All the values are separated by the '+' character. Then you add
the value of the p... | [
"def",
"get_signature",
"(",
"payment_request",
")",
":",
"vads_args",
"=",
"{",
"}",
"for",
"field",
"in",
"payment_request",
".",
"_meta",
".",
"fields",
":",
"if",
"field",
".",
"name",
"[",
":",
"5",
"]",
"==",
"'vads_'",
":",
"field_value",
"=",
"... | Returns the signature for the transaction.
To compute the signature, first you have to get the value of all
the fields that starts by 'vads_', ordering them alphabetically.
All the values are separated by the '+' character. Then you add
the value of the payzen certificate.
Finaly you hash the strin... | [
"Returns",
"the",
"signature",
"for",
"the",
"transaction",
"."
] | 944c3026120151495310cb1eb3c6370dc2db3db9 | https://github.com/bsvetchine/django-payzen/blob/944c3026120151495310cb1eb3c6370dc2db3db9/django_payzen/tools.py#L60-L82 |
241,315 | bsvetchine/django-payzen | django_payzen/tools.py | process_response | def process_response(data):
"""Process a payment response."""
# We check if the signature is valid. If not return
if not is_signature_valid(data):
logger.warning(
"Django-Payzen : Response signature detected as invalid",
extra={"stack": True}
)
return None
... | python | def process_response(data):
"""Process a payment response."""
# We check if the signature is valid. If not return
if not is_signature_valid(data):
logger.warning(
"Django-Payzen : Response signature detected as invalid",
extra={"stack": True}
)
return None
... | [
"def",
"process_response",
"(",
"data",
")",
":",
"# We check if the signature is valid. If not return",
"if",
"not",
"is_signature_valid",
"(",
"data",
")",
":",
"logger",
".",
"warning",
"(",
"\"Django-Payzen : Response signature detected as invalid\"",
",",
"extra",
"=",... | Process a payment response. | [
"Process",
"a",
"payment",
"response",
"."
] | 944c3026120151495310cb1eb3c6370dc2db3db9 | https://github.com/bsvetchine/django-payzen/blob/944c3026120151495310cb1eb3c6370dc2db3db9/django_payzen/tools.py#L95-L129 |
241,316 | fpoirotte/sphinxcontrib-varlinks | sphinxcontrib/varlinks.py | LinkSubstitutionPhase1.apply | def apply(self):
"""Create substitution nodes for hyperlinks"""
# In this phase, we look for hyperlinks (references nodes)
# that contain substitutions (of the form "|foo|").
# We then add actual "substitution"s nodes to those references,
# so that they can be replaced by the sub... | python | def apply(self):
"""Create substitution nodes for hyperlinks"""
# In this phase, we look for hyperlinks (references nodes)
# that contain substitutions (of the form "|foo|").
# We then add actual "substitution"s nodes to those references,
# so that they can be replaced by the sub... | [
"def",
"apply",
"(",
"self",
")",
":",
"# In this phase, we look for hyperlinks (references nodes)",
"# that contain substitutions (of the form \"|foo|\").",
"# We then add actual \"substitution\"s nodes to those references,",
"# so that they can be replaced by the substitution processor.",
"sub... | Create substitution nodes for hyperlinks | [
"Create",
"substitution",
"nodes",
"for",
"hyperlinks"
] | 836899486e841fee4bac32a9d57da2786b2045c6 | https://github.com/fpoirotte/sphinxcontrib-varlinks/blob/836899486e841fee4bac32a9d57da2786b2045c6/sphinxcontrib/varlinks.py#L36-L70 |
241,317 | fpoirotte/sphinxcontrib-varlinks | sphinxcontrib/varlinks.py | LinkSubstitutionPhase2.apply | def apply(self):
"""Replace substitutions in hyperlinks with their contents"""
# In this phase, we replace the substitutions in hyperlinks
# with the contents of the sub-nodes introduced during phase 1.
# We also remove those temporary nodes from the tree.
subst_re = re.compile(s... | python | def apply(self):
"""Replace substitutions in hyperlinks with their contents"""
# In this phase, we replace the substitutions in hyperlinks
# with the contents of the sub-nodes introduced during phase 1.
# We also remove those temporary nodes from the tree.
subst_re = re.compile(s... | [
"def",
"apply",
"(",
"self",
")",
":",
"# In this phase, we replace the substitutions in hyperlinks",
"# with the contents of the sub-nodes introduced during phase 1.",
"# We also remove those temporary nodes from the tree.",
"subst_re",
"=",
"re",
".",
"compile",
"(",
"self",
".",
... | Replace substitutions in hyperlinks with their contents | [
"Replace",
"substitutions",
"in",
"hyperlinks",
"with",
"their",
"contents"
] | 836899486e841fee4bac32a9d57da2786b2045c6 | https://github.com/fpoirotte/sphinxcontrib-varlinks/blob/836899486e841fee4bac32a9d57da2786b2045c6/sphinxcontrib/varlinks.py#L92-L123 |
241,318 | diffeo/yakonfig | yakonfig/yakonfig.py | set_global_config | def set_global_config(path_dict_or_stream):
'''Set the global configuration.
Call this from `main()` with a file system path, stream
object, or a dict. Calling it repeatedly with the same path is
safe. Calling it with a different path or repeatedly with a
stream or dict requires an explicit call ... | python | def set_global_config(path_dict_or_stream):
'''Set the global configuration.
Call this from `main()` with a file system path, stream
object, or a dict. Calling it repeatedly with the same path is
safe. Calling it with a different path or repeatedly with a
stream or dict requires an explicit call ... | [
"def",
"set_global_config",
"(",
"path_dict_or_stream",
")",
":",
"path",
"=",
"None",
"mapping",
"=",
"None",
"stream",
"=",
"None",
"global",
"_config_file_path",
"global",
"_config_cache",
"if",
"isinstance",
"(",
"path_dict_or_stream",
",",
"string_types",
")",
... | Set the global configuration.
Call this from `main()` with a file system path, stream
object, or a dict. Calling it repeatedly with the same path is
safe. Calling it with a different path or repeatedly with a
stream or dict requires an explicit call to :func:`clear_global_config`.
:param path_di... | [
"Set",
"the",
"global",
"configuration",
"."
] | 412e195da29b4f4fc7b72967c192714a6f5eaeb5 | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/yakonfig.py#L70-L114 |
241,319 | diffeo/yakonfig | yakonfig/yakonfig.py | _temporary_config | def _temporary_config():
'''Temporarily replace the global configuration.
Use this in a 'with' statement. The inner block may freely manipulate
the global configuration; the original global configuration is restored
at exit.
>>> with yakonfig.yakonfig._temporary_config():
... yakonfig.yakon... | python | def _temporary_config():
'''Temporarily replace the global configuration.
Use this in a 'with' statement. The inner block may freely manipulate
the global configuration; the original global configuration is restored
at exit.
>>> with yakonfig.yakonfig._temporary_config():
... yakonfig.yakon... | [
"def",
"_temporary_config",
"(",
")",
":",
"global",
"_config_cache",
",",
"_config_file_path",
"old_cc",
"=",
"_config_cache",
"old_cfp",
"=",
"_config_file_path",
"clear_global_config",
"(",
")",
"yield",
"_config_cache",
"=",
"old_cc",
"_config_file_path",
"=",
"ol... | Temporarily replace the global configuration.
Use this in a 'with' statement. The inner block may freely manipulate
the global configuration; the original global configuration is restored
at exit.
>>> with yakonfig.yakonfig._temporary_config():
... yakonfig.yakonfig.set_global_config({'a': 'b'}... | [
"Temporarily",
"replace",
"the",
"global",
"configuration",
"."
] | 412e195da29b4f4fc7b72967c192714a6f5eaeb5 | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/yakonfig.py#L142-L161 |
241,320 | diffeo/yakonfig | yakonfig/yakonfig.py | Loader.include_yaml | def include_yaml(self, node):
'''
load another yaml file from the path specified by node's value
'''
filename = self.construct_scalar(node)
if not filename.startswith('/'):
if self._root is None:
raise Exception('!include_yaml %s is a relative path, '
... | python | def include_yaml(self, node):
'''
load another yaml file from the path specified by node's value
'''
filename = self.construct_scalar(node)
if not filename.startswith('/'):
if self._root is None:
raise Exception('!include_yaml %s is a relative path, '
... | [
"def",
"include_yaml",
"(",
"self",
",",
"node",
")",
":",
"filename",
"=",
"self",
".",
"construct_scalar",
"(",
"node",
")",
"if",
"not",
"filename",
".",
"startswith",
"(",
"'/'",
")",
":",
"if",
"self",
".",
"_root",
"is",
"None",
":",
"raise",
"... | load another yaml file from the path specified by node's value | [
"load",
"another",
"yaml",
"file",
"from",
"the",
"path",
"specified",
"by",
"node",
"s",
"value"
] | 412e195da29b4f4fc7b72967c192714a6f5eaeb5 | https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/yakonfig.py#L39-L50 |
241,321 | maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/stealth.py | paystealth | def paystealth(stealthaddr,ephempriv=None,_doctest_nonce=-1):
'''
Input a stealth address, and optionally an ephemeral private key,
and generate a payment pubkey and stealth OP_RETURN data.
(The OP_RETURN data is just a nonce and the ephemeral public key.)
Works with standard single spend key stea... | python | def paystealth(stealthaddr,ephempriv=None,_doctest_nonce=-1):
'''
Input a stealth address, and optionally an ephemeral private key,
and generate a payment pubkey and stealth OP_RETURN data.
(The OP_RETURN data is just a nonce and the ephemeral public key.)
Works with standard single spend key stea... | [
"def",
"paystealth",
"(",
"stealthaddr",
",",
"ephempriv",
"=",
"None",
",",
"_doctest_nonce",
"=",
"-",
"1",
")",
":",
"if",
"ephempriv",
"is",
"None",
":",
"ephempriv",
"=",
"genkeyhex",
"(",
")",
"addrhex",
"=",
"b58d",
"(",
"stealthaddr",
")",
"asser... | Input a stealth address, and optionally an ephemeral private key,
and generate a payment pubkey and stealth OP_RETURN data.
(The OP_RETURN data is just a nonce and the ephemeral public key.)
Works with standard single spend key stealth addresses, which
begin with the '2a00' version bytes, and have 00-... | [
"Input",
"a",
"stealth",
"address",
"and",
"optionally",
"an",
"ephemeral",
"private",
"key",
"and",
"generate",
"a",
"payment",
"pubkey",
"and",
"stealth",
"OP_RETURN",
"data",
"."
] | ad332433dfcc067e86d2e77fa0c8f1a27daffb63 | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/stealth.py#L36-L117 |
241,322 | maxweisspoker/simplebitcoinfuncs | simplebitcoinfuncs/stealth.py | receivestealth | def receivestealth(scanpriv,spendpriv,ephempub):
'''
Derive the private key for a stealth payment, using the scan and
spend private keys, and the ephemeral public key.
Input private keys should be 64-char hex strings, and ephemeral
public key should be a 66-char hex compressed public key.
>>> ... | python | def receivestealth(scanpriv,spendpriv,ephempub):
'''
Derive the private key for a stealth payment, using the scan and
spend private keys, and the ephemeral public key.
Input private keys should be 64-char hex strings, and ephemeral
public key should be a 66-char hex compressed public key.
>>> ... | [
"def",
"receivestealth",
"(",
"scanpriv",
",",
"spendpriv",
",",
"ephempub",
")",
":",
"return",
"addprivkeys",
"(",
"sha256",
"(",
"multiplypub",
"(",
"ephempub",
",",
"scanpriv",
",",
"True",
")",
")",
",",
"spendpriv",
")"
] | Derive the private key for a stealth payment, using the scan and
spend private keys, and the ephemeral public key.
Input private keys should be 64-char hex strings, and ephemeral
public key should be a 66-char hex compressed public key.
>>> receivestealth('af4afaeb40810e5f8abdbb177c31a2d310913f91cf556... | [
"Derive",
"the",
"private",
"key",
"for",
"a",
"stealth",
"payment",
"using",
"the",
"scan",
"and",
"spend",
"private",
"keys",
"and",
"the",
"ephemeral",
"public",
"key",
"."
] | ad332433dfcc067e86d2e77fa0c8f1a27daffb63 | https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/stealth.py#L120-L134 |
241,323 | ironfroggy/django-better-cache | bettercache/proxy.py | proxy | def proxy(request):
"""Pass an HTTP request on to another server."""
# TODO: don't hardcode http
uri = "http://" + HOST + request.META['PATH_INFO']
if request.META['QUERY_STRING']:
uri += '?' + request.META['QUERY_STRING']
headers = {}
for name, val in six.iteritems(request.environ):
... | python | def proxy(request):
"""Pass an HTTP request on to another server."""
# TODO: don't hardcode http
uri = "http://" + HOST + request.META['PATH_INFO']
if request.META['QUERY_STRING']:
uri += '?' + request.META['QUERY_STRING']
headers = {}
for name, val in six.iteritems(request.environ):
... | [
"def",
"proxy",
"(",
"request",
")",
":",
"# TODO: don't hardcode http",
"uri",
"=",
"\"http://\"",
"+",
"HOST",
"+",
"request",
".",
"META",
"[",
"'PATH_INFO'",
"]",
"if",
"request",
".",
"META",
"[",
"'QUERY_STRING'",
"]",
":",
"uri",
"+=",
"'?'",
"+",
... | Pass an HTTP request on to another server. | [
"Pass",
"an",
"HTTP",
"request",
"on",
"to",
"another",
"server",
"."
] | 5350e8c646cef1c1ca74eab176f856ddd9eaf5c3 | https://github.com/ironfroggy/django-better-cache/blob/5350e8c646cef1c1ca74eab176f856ddd9eaf5c3/bettercache/proxy.py#L37-L62 |
241,324 | mayfield/shellish | shellish/layout/table.py | tabulate | def tabulate(data, header=True, headers=None, accessors=None,
**table_options):
""" Shortcut function to produce tabular output of data without the
need to create and configure a Table instance directly. The function
does however return a table instance when it's done for any further use
by... | python | def tabulate(data, header=True, headers=None, accessors=None,
**table_options):
""" Shortcut function to produce tabular output of data without the
need to create and configure a Table instance directly. The function
does however return a table instance when it's done for any further use
by... | [
"def",
"tabulate",
"(",
"data",
",",
"header",
"=",
"True",
",",
"headers",
"=",
"None",
",",
"accessors",
"=",
"None",
",",
"*",
"*",
"table_options",
")",
":",
"if",
"header",
"and",
"not",
"headers",
":",
"data",
"=",
"iter",
"(",
"data",
")",
"... | Shortcut function to produce tabular output of data without the
need to create and configure a Table instance directly. The function
does however return a table instance when it's done for any further use
by the user. | [
"Shortcut",
"function",
"to",
"produce",
"tabular",
"output",
"of",
"data",
"without",
"the",
"need",
"to",
"create",
"and",
"configure",
"a",
"Table",
"instance",
"directly",
".",
"The",
"function",
"does",
"however",
"return",
"a",
"table",
"instance",
"when... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L1018-L1041 |
241,325 | mayfield/shellish | shellish/layout/table.py | TableRenderer.render_filter | def render_filter(self, next_filter):
""" Produce formatted output from the raw data stream. """
next(next_filter)
while True:
data = (yield)
res = [self.cell_format(access(data)) for access in self.accessors]
next_filter.send(res) | python | def render_filter(self, next_filter):
""" Produce formatted output from the raw data stream. """
next(next_filter)
while True:
data = (yield)
res = [self.cell_format(access(data)) for access in self.accessors]
next_filter.send(res) | [
"def",
"render_filter",
"(",
"self",
",",
"next_filter",
")",
":",
"next",
"(",
"next_filter",
")",
"while",
"True",
":",
"data",
"=",
"(",
"yield",
")",
"res",
"=",
"[",
"self",
".",
"cell_format",
"(",
"access",
"(",
"data",
")",
")",
"for",
"acces... | Produce formatted output from the raw data stream. | [
"Produce",
"formatted",
"output",
"from",
"the",
"raw",
"data",
"stream",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L472-L478 |
241,326 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.viewable_width | def viewable_width(self):
""" The available combined character width when all padding is
removed. """
return sum(self.widths) + sum(x['padding'] for x in self.colspec) | python | def viewable_width(self):
""" The available combined character width when all padding is
removed. """
return sum(self.widths) + sum(x['padding'] for x in self.colspec) | [
"def",
"viewable_width",
"(",
"self",
")",
":",
"return",
"sum",
"(",
"self",
".",
"widths",
")",
"+",
"sum",
"(",
"x",
"[",
"'padding'",
"]",
"for",
"x",
"in",
"self",
".",
"colspec",
")"
] | The available combined character width when all padding is
removed. | [
"The",
"available",
"combined",
"character",
"width",
"when",
"all",
"padding",
"is",
"removed",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L543-L546 |
241,327 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.print_row | def print_row(self, row, rstrip=True):
""" Format and print the pre-rendered data to the output device. """
line = ''.join(map(str, row))
print(line.rstrip() if rstrip else line, file=self.table.file) | python | def print_row(self, row, rstrip=True):
""" Format and print the pre-rendered data to the output device. """
line = ''.join(map(str, row))
print(line.rstrip() if rstrip else line, file=self.table.file) | [
"def",
"print_row",
"(",
"self",
",",
"row",
",",
"rstrip",
"=",
"True",
")",
":",
"line",
"=",
"''",
".",
"join",
"(",
"map",
"(",
"str",
",",
"row",
")",
")",
"print",
"(",
"line",
".",
"rstrip",
"(",
")",
"if",
"rstrip",
"else",
"line",
",",... | Format and print the pre-rendered data to the output device. | [
"Format",
"and",
"print",
"the",
"pre",
"-",
"rendered",
"data",
"to",
"the",
"output",
"device",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L567-L570 |
241,328 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.format_fullwidth | def format_fullwidth(self, value):
""" Return a full width column. Note that the padding is inherited
from the first cell which inherits from column_padding. """
assert isinstance(value, VTMLBuffer)
pad = self.colspec[0]['padding']
fmt = self.make_formatter(self.width - pad, pad,... | python | def format_fullwidth(self, value):
""" Return a full width column. Note that the padding is inherited
from the first cell which inherits from column_padding. """
assert isinstance(value, VTMLBuffer)
pad = self.colspec[0]['padding']
fmt = self.make_formatter(self.width - pad, pad,... | [
"def",
"format_fullwidth",
"(",
"self",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"VTMLBuffer",
")",
"pad",
"=",
"self",
".",
"colspec",
"[",
"0",
"]",
"[",
"'padding'",
"]",
"fmt",
"=",
"self",
".",
"make_formatter",
"(",
"sel... | Return a full width column. Note that the padding is inherited
from the first cell which inherits from column_padding. | [
"Return",
"a",
"full",
"width",
"column",
".",
"Note",
"that",
"the",
"padding",
"is",
"inherited",
"from",
"the",
"first",
"cell",
"which",
"inherits",
"from",
"column_padding",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L595-L602 |
241,329 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.make_formatter | def make_formatter(self, width, padding, alignment, overflow=None):
""" Create formatter function that factors the width and alignment
settings. """
if overflow is None:
overflow = self.overflow_default
if overflow == 'clip':
overflower = lambda x: [x.clip(width, ... | python | def make_formatter(self, width, padding, alignment, overflow=None):
""" Create formatter function that factors the width and alignment
settings. """
if overflow is None:
overflow = self.overflow_default
if overflow == 'clip':
overflower = lambda x: [x.clip(width, ... | [
"def",
"make_formatter",
"(",
"self",
",",
"width",
",",
"padding",
",",
"alignment",
",",
"overflow",
"=",
"None",
")",
":",
"if",
"overflow",
"is",
"None",
":",
"overflow",
"=",
"self",
".",
"overflow_default",
"if",
"overflow",
"==",
"'clip'",
":",
"o... | Create formatter function that factors the width and alignment
settings. | [
"Create",
"formatter",
"function",
"that",
"factors",
"the",
"width",
"and",
"alignment",
"settings",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L604-L619 |
241,330 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.make_formatters | def make_formatters(self):
""" Create a list formatter functions for each column. They can then
be stored in the render spec for faster justification processing. """
return [self.make_formatter(inner_w, spec['padding'], spec['align'],
spec['overflow'])
... | python | def make_formatters(self):
""" Create a list formatter functions for each column. They can then
be stored in the render spec for faster justification processing. """
return [self.make_formatter(inner_w, spec['padding'], spec['align'],
spec['overflow'])
... | [
"def",
"make_formatters",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"make_formatter",
"(",
"inner_w",
",",
"spec",
"[",
"'padding'",
"]",
",",
"spec",
"[",
"'align'",
"]",
",",
"spec",
"[",
"'overflow'",
"]",
")",
"for",
"spec",
",",
"inner_w"... | Create a list formatter functions for each column. They can then
be stored in the render spec for faster justification processing. | [
"Create",
"a",
"list",
"formatter",
"functions",
"for",
"each",
"column",
".",
"They",
"can",
"then",
"be",
"stored",
"in",
"the",
"render",
"spec",
"for",
"faster",
"justification",
"processing",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L621-L626 |
241,331 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer._uniform_dist | def _uniform_dist(self, spread, total):
""" Produce a uniform distribution of `total` across a list of
`spread` size. The result is non-random and uniform. """
fraction, fixed_increment = math.modf(total / spread)
fixed_increment = int(fixed_increment)
balance = 0
dist = ... | python | def _uniform_dist(self, spread, total):
""" Produce a uniform distribution of `total` across a list of
`spread` size. The result is non-random and uniform. """
fraction, fixed_increment = math.modf(total / spread)
fixed_increment = int(fixed_increment)
balance = 0
dist = ... | [
"def",
"_uniform_dist",
"(",
"self",
",",
"spread",
",",
"total",
")",
":",
"fraction",
",",
"fixed_increment",
"=",
"math",
".",
"modf",
"(",
"total",
"/",
"spread",
")",
"fixed_increment",
"=",
"int",
"(",
"fixed_increment",
")",
"balance",
"=",
"0",
"... | Produce a uniform distribution of `total` across a list of
`spread` size. The result is non-random and uniform. | [
"Produce",
"a",
"uniform",
"distribution",
"of",
"total",
"across",
"a",
"list",
"of",
"spread",
"size",
".",
"The",
"result",
"is",
"non",
"-",
"random",
"and",
"uniform",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L628-L641 |
241,332 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.get_filters | def get_filters(self):
""" Coroutine based filters for render pipeline. """
return [
self.compute_style_filter,
self.render_filter,
self.calc_widths_filter,
self.format_row_filter,
self.align_rows_filter,
] | python | def get_filters(self):
""" Coroutine based filters for render pipeline. """
return [
self.compute_style_filter,
self.render_filter,
self.calc_widths_filter,
self.format_row_filter,
self.align_rows_filter,
] | [
"def",
"get_filters",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"compute_style_filter",
",",
"self",
".",
"render_filter",
",",
"self",
".",
"calc_widths_filter",
",",
"self",
".",
"format_row_filter",
",",
"self",
".",
"align_rows_filter",
",",
"]"
] | Coroutine based filters for render pipeline. | [
"Coroutine",
"based",
"filters",
"for",
"render",
"pipeline",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L643-L651 |
241,333 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.format_row_filter | def format_row_filter(self, next_filter):
""" Apply overflow, justification, padding and expansion to a row. """
next(next_filter)
while True:
items = (yield)
assert all(isinstance(x, VTMLBuffer) for x in items)
raw = (fn(x) for x, fn in zip(items, self.format... | python | def format_row_filter(self, next_filter):
""" Apply overflow, justification, padding and expansion to a row. """
next(next_filter)
while True:
items = (yield)
assert all(isinstance(x, VTMLBuffer) for x in items)
raw = (fn(x) for x, fn in zip(items, self.format... | [
"def",
"format_row_filter",
"(",
"self",
",",
"next_filter",
")",
":",
"next",
"(",
"next_filter",
")",
"while",
"True",
":",
"items",
"=",
"(",
"yield",
")",
"assert",
"all",
"(",
"isinstance",
"(",
"x",
",",
"VTMLBuffer",
")",
"for",
"x",
"in",
"item... | Apply overflow, justification, padding and expansion to a row. | [
"Apply",
"overflow",
"justification",
"padding",
"and",
"expansion",
"to",
"a",
"row",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L653-L661 |
241,334 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.width_normalize | def width_normalize(self, width):
""" Handle a width style, which can be a fractional number
representing a percentage of available width or positive integers
which indicate a fixed width. """
if width is not None:
if width > 0 and width < 1:
return int(width ... | python | def width_normalize(self, width):
""" Handle a width style, which can be a fractional number
representing a percentage of available width or positive integers
which indicate a fixed width. """
if width is not None:
if width > 0 and width < 1:
return int(width ... | [
"def",
"width_normalize",
"(",
"self",
",",
"width",
")",
":",
"if",
"width",
"is",
"not",
"None",
":",
"if",
"width",
">",
"0",
"and",
"width",
"<",
"1",
":",
"return",
"int",
"(",
"width",
"*",
"self",
".",
"usable_width",
")",
"else",
":",
"retu... | Handle a width style, which can be a fractional number
representing a percentage of available width or positive integers
which indicate a fixed width. | [
"Handle",
"a",
"width",
"style",
"which",
"can",
"be",
"a",
"fractional",
"number",
"representing",
"a",
"percentage",
"of",
"available",
"width",
"or",
"positive",
"integers",
"which",
"indicate",
"a",
"fixed",
"width",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L733-L741 |
241,335 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.calc_widths_filter | def calc_widths_filter(self, next_filter):
""" Coroutine to analyze the incoming data stream for creating optimal
column width choices. This may buffer some of the incoming stream if
there isn't enough information to make good choices about column
widths. Also it may resize widths if c... | python | def calc_widths_filter(self, next_filter):
""" Coroutine to analyze the incoming data stream for creating optimal
column width choices. This may buffer some of the incoming stream if
there isn't enough information to make good choices about column
widths. Also it may resize widths if c... | [
"def",
"calc_widths_filter",
"(",
"self",
",",
"next_filter",
")",
":",
"window_sent",
"=",
"not",
"not",
"self",
".",
"data_window",
"next_primed",
"=",
"False",
"genexit",
"=",
"None",
"if",
"not",
"self",
".",
"data_window",
":",
"start",
"=",
"time",
"... | Coroutine to analyze the incoming data stream for creating optimal
column width choices. This may buffer some of the incoming stream if
there isn't enough information to make good choices about column
widths. Also it may resize widths if certain conditions are met such
as the terminal ... | [
"Coroutine",
"to",
"analyze",
"the",
"incoming",
"data",
"stream",
"for",
"creating",
"optimal",
"column",
"width",
"choices",
".",
"This",
"may",
"buffer",
"some",
"of",
"the",
"incoming",
"stream",
"if",
"there",
"isn",
"t",
"enough",
"information",
"to",
... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L743-L800 |
241,336 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.calc_flex | def calc_flex(self, data, max_width, cols, preformatted=None):
""" Scan data returning the best width for each column given the
max_width constraint. If some columns will overflow we calculate the
best concession widths. """
if preformatted is None:
preformatted = []
... | python | def calc_flex(self, data, max_width, cols, preformatted=None):
""" Scan data returning the best width for each column given the
max_width constraint. If some columns will overflow we calculate the
best concession widths. """
if preformatted is None:
preformatted = []
... | [
"def",
"calc_flex",
"(",
"self",
",",
"data",
",",
"max_width",
",",
"cols",
",",
"preformatted",
"=",
"None",
")",
":",
"if",
"preformatted",
"is",
"None",
":",
"preformatted",
"=",
"[",
"]",
"colstats",
"=",
"[",
"]",
"for",
"i",
"in",
"cols",
":",... | Scan data returning the best width for each column given the
max_width constraint. If some columns will overflow we calculate the
best concession widths. | [
"Scan",
"data",
"returning",
"the",
"best",
"width",
"for",
"each",
"column",
"given",
"the",
"max_width",
"constraint",
".",
"If",
"some",
"columns",
"will",
"overflow",
"we",
"calculate",
"the",
"best",
"concession",
"widths",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L802-L839 |
241,337 | mayfield/shellish | shellish/layout/table.py | VisualTableRenderer.adjust_widths | def adjust_widths(self, max_width, colstats):
""" Adjust column widths based on the least negative affect it will
have on the viewing experience. We take note of the total character
mass that will be clipped when each column should be narrowed. The
actual score for clipping is based on... | python | def adjust_widths(self, max_width, colstats):
""" Adjust column widths based on the least negative affect it will
have on the viewing experience. We take note of the total character
mass that will be clipped when each column should be narrowed. The
actual score for clipping is based on... | [
"def",
"adjust_widths",
"(",
"self",
",",
"max_width",
",",
"colstats",
")",
":",
"adj_colstats",
"=",
"[",
"]",
"for",
"x",
"in",
"colstats",
":",
"if",
"not",
"x",
"[",
"'preformatted'",
"]",
":",
"adj_colstats",
".",
"append",
"(",
"x",
")",
"else",... | Adjust column widths based on the least negative affect it will
have on the viewing experience. We take note of the total character
mass that will be clipped when each column should be narrowed. The
actual score for clipping is based on percentage of total character
mass, which is the ... | [
"Adjust",
"column",
"widths",
"based",
"on",
"the",
"least",
"negative",
"affect",
"it",
"will",
"have",
"on",
"the",
"viewing",
"experience",
".",
"We",
"take",
"note",
"of",
"the",
"total",
"character",
"mass",
"that",
"will",
"be",
"clipped",
"when",
"e... | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L841-L868 |
241,338 | mayfield/shellish | shellish/layout/table.py | JSONTableRenderer.make_key | def make_key(self, value):
""" Make camelCase variant of value. """
if value:
parts = [self.key_filter.sub('', x)
for x in self.key_split.split(value.lower())]
key = parts[0] + ''.join(map(str.capitalize, parts[1:]))
else:
key = ''
... | python | def make_key(self, value):
""" Make camelCase variant of value. """
if value:
parts = [self.key_filter.sub('', x)
for x in self.key_split.split(value.lower())]
key = parts[0] + ''.join(map(str.capitalize, parts[1:]))
else:
key = ''
... | [
"def",
"make_key",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
":",
"parts",
"=",
"[",
"self",
".",
"key_filter",
".",
"sub",
"(",
"''",
",",
"x",
")",
"for",
"x",
"in",
"self",
".",
"key_split",
".",
"split",
"(",
"value",
".",
"lower",
... | Make camelCase variant of value. | [
"Make",
"camelCase",
"variant",
"of",
"value",
"."
] | df0f0e4612d138c34d8cb99b66ab5b8e47f1414a | https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/layout/table.py#L921-L935 |
241,339 | thisfred/val | val/_val.py | _build_type_validator | def _build_type_validator(value_type):
"""Build a validator that only checks the type of a value."""
def type_validator(data):
"""Validate instances of a particular type."""
if isinstance(data, value_type):
return data
raise NotValid('%r is not of type %r' % (data, value_ty... | python | def _build_type_validator(value_type):
"""Build a validator that only checks the type of a value."""
def type_validator(data):
"""Validate instances of a particular type."""
if isinstance(data, value_type):
return data
raise NotValid('%r is not of type %r' % (data, value_ty... | [
"def",
"_build_type_validator",
"(",
"value_type",
")",
":",
"def",
"type_validator",
"(",
"data",
")",
":",
"\"\"\"Validate instances of a particular type.\"\"\"",
"if",
"isinstance",
"(",
"data",
",",
"value_type",
")",
":",
"return",
"data",
"raise",
"NotValid",
... | Build a validator that only checks the type of a value. | [
"Build",
"a",
"validator",
"that",
"only",
"checks",
"the",
"type",
"of",
"a",
"value",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L25-L35 |
241,340 | thisfred/val | val/_val.py | _build_static_validator | def _build_static_validator(exact_value):
"""Build a validator that checks if the data is equal to an exact value."""
def static_validator(data):
"""Validate by equality."""
if data == exact_value:
return data
raise NotValid('%r is not equal to %r' % (data, exact_value))
... | python | def _build_static_validator(exact_value):
"""Build a validator that checks if the data is equal to an exact value."""
def static_validator(data):
"""Validate by equality."""
if data == exact_value:
return data
raise NotValid('%r is not equal to %r' % (data, exact_value))
... | [
"def",
"_build_static_validator",
"(",
"exact_value",
")",
":",
"def",
"static_validator",
"(",
"data",
")",
":",
"\"\"\"Validate by equality.\"\"\"",
"if",
"data",
"==",
"exact_value",
":",
"return",
"data",
"raise",
"NotValid",
"(",
"'%r is not equal to %r'",
"%",
... | Build a validator that checks if the data is equal to an exact value. | [
"Build",
"a",
"validator",
"that",
"checks",
"if",
"the",
"data",
"is",
"equal",
"to",
"an",
"exact",
"value",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L38-L48 |
241,341 | thisfred/val | val/_val.py | _build_iterable_validator | def _build_iterable_validator(iterable):
"""Build a validator from an iterable."""
sub_schemas = [parse_schema(s) for s in iterable]
def item_validator(value):
"""Validate items in an iterable."""
for sub in sub_schemas:
try:
return sub(value)
except... | python | def _build_iterable_validator(iterable):
"""Build a validator from an iterable."""
sub_schemas = [parse_schema(s) for s in iterable]
def item_validator(value):
"""Validate items in an iterable."""
for sub in sub_schemas:
try:
return sub(value)
except... | [
"def",
"_build_iterable_validator",
"(",
"iterable",
")",
":",
"sub_schemas",
"=",
"[",
"parse_schema",
"(",
"s",
")",
"for",
"s",
"in",
"iterable",
"]",
"def",
"item_validator",
"(",
"value",
")",
":",
"\"\"\"Validate items in an iterable.\"\"\"",
"for",
"sub",
... | Build a validator from an iterable. | [
"Build",
"a",
"validator",
"from",
"an",
"iterable",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L68-L90 |
241,342 | thisfred/val | val/_val.py | _determine_keys | def _determine_keys(dictionary):
"""Determine the different kinds of keys."""
optional = {}
defaults = {}
mandatory = {}
types = {}
for key, value in dictionary.items():
if isinstance(key, Optional):
optional[key.value] = parse_schema(value)
if isinstance(value, B... | python | def _determine_keys(dictionary):
"""Determine the different kinds of keys."""
optional = {}
defaults = {}
mandatory = {}
types = {}
for key, value in dictionary.items():
if isinstance(key, Optional):
optional[key.value] = parse_schema(value)
if isinstance(value, B... | [
"def",
"_determine_keys",
"(",
"dictionary",
")",
":",
"optional",
"=",
"{",
"}",
"defaults",
"=",
"{",
"}",
"mandatory",
"=",
"{",
"}",
"types",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"dictionary",
".",
"items",
"(",
")",
":",
"if",
"isi... | Determine the different kinds of keys. | [
"Determine",
"the",
"different",
"kinds",
"of",
"keys",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L93-L112 |
241,343 | thisfred/val | val/_val.py | _validate_mandatory_keys | def _validate_mandatory_keys(mandatory, validated, data, to_validate):
"""Validate the manditory keys."""
errors = []
for key, sub_schema in mandatory.items():
if key not in data:
errors.append('missing key: %r' % (key,))
continue
try:
validated[key] = sub... | python | def _validate_mandatory_keys(mandatory, validated, data, to_validate):
"""Validate the manditory keys."""
errors = []
for key, sub_schema in mandatory.items():
if key not in data:
errors.append('missing key: %r' % (key,))
continue
try:
validated[key] = sub... | [
"def",
"_validate_mandatory_keys",
"(",
"mandatory",
",",
"validated",
",",
"data",
",",
"to_validate",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"key",
",",
"sub_schema",
"in",
"mandatory",
".",
"items",
"(",
")",
":",
"if",
"key",
"not",
"in",
"data",
... | Validate the manditory keys. | [
"Validate",
"the",
"manditory",
"keys",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L115-L127 |
241,344 | thisfred/val | val/_val.py | _validate_optional_key | def _validate_optional_key(key, missing, value, validated, optional):
"""Validate an optional key."""
try:
validated[key] = optional[key](value)
except NotValid as ex:
return ['%r: %s' % (key, arg) for arg in ex.args]
if key in missing:
missing.remove(key)
return [] | python | def _validate_optional_key(key, missing, value, validated, optional):
"""Validate an optional key."""
try:
validated[key] = optional[key](value)
except NotValid as ex:
return ['%r: %s' % (key, arg) for arg in ex.args]
if key in missing:
missing.remove(key)
return [] | [
"def",
"_validate_optional_key",
"(",
"key",
",",
"missing",
",",
"value",
",",
"validated",
",",
"optional",
")",
":",
"try",
":",
"validated",
"[",
"key",
"]",
"=",
"optional",
"[",
"key",
"]",
"(",
"value",
")",
"except",
"NotValid",
"as",
"ex",
":"... | Validate an optional key. | [
"Validate",
"an",
"optional",
"key",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L130-L138 |
241,345 | thisfred/val | val/_val.py | _validate_type_key | def _validate_type_key(key, value, types, validated):
"""Validate a key's value by type."""
for key_schema, value_schema in types.items():
if not isinstance(key, key_schema):
continue
try:
validated[key] = value_schema(value)
except NotValid:
continue
... | python | def _validate_type_key(key, value, types, validated):
"""Validate a key's value by type."""
for key_schema, value_schema in types.items():
if not isinstance(key, key_schema):
continue
try:
validated[key] = value_schema(value)
except NotValid:
continue
... | [
"def",
"_validate_type_key",
"(",
"key",
",",
"value",
",",
"types",
",",
"validated",
")",
":",
"for",
"key_schema",
",",
"value_schema",
"in",
"types",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"key",
",",
"key_schema",
")",
":",
"... | Validate a key's value by type. | [
"Validate",
"a",
"key",
"s",
"value",
"by",
"type",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L141-L153 |
241,346 | thisfred/val | val/_val.py | _validate_other_keys | def _validate_other_keys(optional, types, missing, validated, data,
to_validate):
"""Validate the rest of the keys present in the data."""
errors = []
for key in to_validate:
value = data[key]
if key in optional:
errors.extend(
_validate_o... | python | def _validate_other_keys(optional, types, missing, validated, data,
to_validate):
"""Validate the rest of the keys present in the data."""
errors = []
for key in to_validate:
value = data[key]
if key in optional:
errors.extend(
_validate_o... | [
"def",
"_validate_other_keys",
"(",
"optional",
",",
"types",
",",
"missing",
",",
"validated",
",",
"data",
",",
"to_validate",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"key",
"in",
"to_validate",
":",
"value",
"=",
"data",
"[",
"key",
"]",
"if",
"ke... | Validate the rest of the keys present in the data. | [
"Validate",
"the",
"rest",
"of",
"the",
"keys",
"present",
"in",
"the",
"data",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L156-L168 |
241,347 | thisfred/val | val/_val.py | _build_dict_validator | def _build_dict_validator(dictionary):
"""Build a validator from a dictionary."""
mandatory, optional, types, defaults = _determine_keys(dictionary)
def dict_validator(data):
"""Validate dictionaries."""
missing = list(defaults.keys())
if not isinstance(data, dict):
rais... | python | def _build_dict_validator(dictionary):
"""Build a validator from a dictionary."""
mandatory, optional, types, defaults = _determine_keys(dictionary)
def dict_validator(data):
"""Validate dictionaries."""
missing = list(defaults.keys())
if not isinstance(data, dict):
rais... | [
"def",
"_build_dict_validator",
"(",
"dictionary",
")",
":",
"mandatory",
",",
"optional",
",",
"types",
",",
"defaults",
"=",
"_determine_keys",
"(",
"dictionary",
")",
"def",
"dict_validator",
"(",
"data",
")",
":",
"\"\"\"Validate dictionaries.\"\"\"",
"missing",... | Build a validator from a dictionary. | [
"Build",
"a",
"validator",
"from",
"a",
"dictionary",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L171-L195 |
241,348 | thisfred/val | val/_val.py | parse_schema | def parse_schema(schema):
"""Parse a val schema definition."""
if isinstance(schema, BaseSchema):
return schema.validate
if type(schema) is type:
return _build_type_validator(schema)
if isinstance(schema, dict):
return _build_dict_validator(schema)
if type(schema) in (lis... | python | def parse_schema(schema):
"""Parse a val schema definition."""
if isinstance(schema, BaseSchema):
return schema.validate
if type(schema) is type:
return _build_type_validator(schema)
if isinstance(schema, dict):
return _build_dict_validator(schema)
if type(schema) in (lis... | [
"def",
"parse_schema",
"(",
"schema",
")",
":",
"if",
"isinstance",
"(",
"schema",
",",
"BaseSchema",
")",
":",
"return",
"schema",
".",
"validate",
"if",
"type",
"(",
"schema",
")",
"is",
"type",
":",
"return",
"_build_type_validator",
"(",
"schema",
")",... | Parse a val schema definition. | [
"Parse",
"a",
"val",
"schema",
"definition",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L198-L216 |
241,349 | thisfred/val | val/_val.py | BaseSchema.validate | def validate(self, data):
"""Validate data. Raise NotValid error for invalid data."""
validated = self._validated(data)
errors = []
for validator in self.additional_validators:
if not validator(validated):
errors.append(
"%s invalidated by ... | python | def validate(self, data):
"""Validate data. Raise NotValid error for invalid data."""
validated = self._validated(data)
errors = []
for validator in self.additional_validators:
if not validator(validated):
errors.append(
"%s invalidated by ... | [
"def",
"validate",
"(",
"self",
",",
"data",
")",
":",
"validated",
"=",
"self",
".",
"_validated",
"(",
"data",
")",
"errors",
"=",
"[",
"]",
"for",
"validator",
"in",
"self",
".",
"additional_validators",
":",
"if",
"not",
"validator",
"(",
"validated"... | Validate data. Raise NotValid error for invalid data. | [
"Validate",
"data",
".",
"Raise",
"NotValid",
"error",
"for",
"invalid",
"data",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L243-L265 |
241,350 | thisfred/val | val/_val.py | Or._validated | def _validated(self, data):
"""Validate data if any subschema validates it."""
errors = []
for sub in self.schemas:
try:
return sub(data)
except NotValid as ex:
errors.extend(ex.args)
raise NotValid(' and '.join(errors)) | python | def _validated(self, data):
"""Validate data if any subschema validates it."""
errors = []
for sub in self.schemas:
try:
return sub(data)
except NotValid as ex:
errors.extend(ex.args)
raise NotValid(' and '.join(errors)) | [
"def",
"_validated",
"(",
"self",
",",
"data",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"sub",
"in",
"self",
".",
"schemas",
":",
"try",
":",
"return",
"sub",
"(",
"data",
")",
"except",
"NotValid",
"as",
"ex",
":",
"errors",
".",
"extend",
"(",
... | Validate data if any subschema validates it. | [
"Validate",
"data",
"if",
"any",
"subschema",
"validates",
"it",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L310-L319 |
241,351 | thisfred/val | val/_val.py | And._validated | def _validated(self, data):
"""Validate data if all subschemas validate it."""
for sub in self.schemas:
data = sub(data)
return data | python | def _validated(self, data):
"""Validate data if all subschemas validate it."""
for sub in self.schemas:
data = sub(data)
return data | [
"def",
"_validated",
"(",
"self",
",",
"data",
")",
":",
"for",
"sub",
"in",
"self",
".",
"schemas",
":",
"data",
"=",
"sub",
"(",
"data",
")",
"return",
"data"
] | Validate data if all subschemas validate it. | [
"Validate",
"data",
"if",
"all",
"subschemas",
"validate",
"it",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L339-L343 |
241,352 | thisfred/val | val/_val.py | Convert._validated | def _validated(self, data):
"""Convert data or die trying."""
try:
return self.convert(data)
except (TypeError, ValueError) as ex:
raise NotValid(*ex.args) | python | def _validated(self, data):
"""Convert data or die trying."""
try:
return self.convert(data)
except (TypeError, ValueError) as ex:
raise NotValid(*ex.args) | [
"def",
"_validated",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"return",
"self",
".",
"convert",
"(",
"data",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
"as",
"ex",
":",
"raise",
"NotValid",
"(",
"*",
"ex",
".",
"args",
")"
] | Convert data or die trying. | [
"Convert",
"data",
"or",
"die",
"trying",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L358-L363 |
241,353 | thisfred/val | val/_val.py | Ordered._validated | def _validated(self, values):
"""Validate if the values are validated one by one in order."""
if self.length != len(values):
raise NotValid(
"%r does not have exactly %d values. (Got %d.)" % (
values, self.length, len(values)))
return type(self.sch... | python | def _validated(self, values):
"""Validate if the values are validated one by one in order."""
if self.length != len(values):
raise NotValid(
"%r does not have exactly %d values. (Got %d.)" % (
values, self.length, len(values)))
return type(self.sch... | [
"def",
"_validated",
"(",
"self",
",",
"values",
")",
":",
"if",
"self",
".",
"length",
"!=",
"len",
"(",
"values",
")",
":",
"raise",
"NotValid",
"(",
"\"%r does not have exactly %d values. (Got %d.)\"",
"%",
"(",
"values",
",",
"self",
".",
"length",
",",
... | Validate if the values are validated one by one in order. | [
"Validate",
"if",
"the",
"values",
"are",
"validated",
"one",
"by",
"one",
"in",
"order",
"."
] | ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c | https://github.com/thisfred/val/blob/ba022e0c6c47acb3b8a45e7c44c84cc0f495c41c/val/_val.py#L380-L387 |
241,354 | esterhui/pypu | pypu/service_facebook.py | service_facebook._connectToFB | def _connectToFB(self):
"""Establish the actual TCP connection to FB"""
if self.connected_to_fb:
logger.debug("Already connected to fb")
return True
logger.debug("Connecting to fb")
token = facebook_login.get_fb_token()
try:
self.fb = faceb... | python | def _connectToFB(self):
"""Establish the actual TCP connection to FB"""
if self.connected_to_fb:
logger.debug("Already connected to fb")
return True
logger.debug("Connecting to fb")
token = facebook_login.get_fb_token()
try:
self.fb = faceb... | [
"def",
"_connectToFB",
"(",
"self",
")",
":",
"if",
"self",
".",
"connected_to_fb",
":",
"logger",
".",
"debug",
"(",
"\"Already connected to fb\"",
")",
"return",
"True",
"logger",
".",
"debug",
"(",
"\"Connecting to fb\"",
")",
"token",
"=",
"facebook_login",
... | Establish the actual TCP connection to FB | [
"Establish",
"the",
"actual",
"TCP",
"connection",
"to",
"FB"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L45-L64 |
241,355 | esterhui/pypu | pypu/service_facebook.py | service_facebook.KnowsFile | def KnowsFile(self,filename):
"""Looks at extension and decides if it knows
how to manage this file"""
if self._isMediaFile(filename) or self._isConfigFile(filename):
return True
return False | python | def KnowsFile(self,filename):
"""Looks at extension and decides if it knows
how to manage this file"""
if self._isMediaFile(filename) or self._isConfigFile(filename):
return True
return False | [
"def",
"KnowsFile",
"(",
"self",
",",
"filename",
")",
":",
"if",
"self",
".",
"_isMediaFile",
"(",
"filename",
")",
"or",
"self",
".",
"_isConfigFile",
"(",
"filename",
")",
":",
"return",
"True",
"return",
"False"
] | Looks at extension and decides if it knows
how to manage this file | [
"Looks",
"at",
"extension",
"and",
"decides",
"if",
"it",
"knows",
"how",
"to",
"manage",
"this",
"file"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L86-L91 |
241,356 | esterhui/pypu | pypu/service_facebook.py | service_facebook.Remove | def Remove(self,directory,filename):
"""Deletes files from fb"""
if self._isMediaFile(filename):
return self._remove_media(directory,filename)
elif self._isConfigFile(filename):
return True
print "Not handled!"
return False | python | def Remove(self,directory,filename):
"""Deletes files from fb"""
if self._isMediaFile(filename):
return self._remove_media(directory,filename)
elif self._isConfigFile(filename):
return True
print "Not handled!"
return False | [
"def",
"Remove",
"(",
"self",
",",
"directory",
",",
"filename",
")",
":",
"if",
"self",
".",
"_isMediaFile",
"(",
"filename",
")",
":",
"return",
"self",
".",
"_remove_media",
"(",
"directory",
",",
"filename",
")",
"elif",
"self",
".",
"_isConfigFile",
... | Deletes files from fb | [
"Deletes",
"files",
"from",
"fb"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L103-L111 |
241,357 | esterhui/pypu | pypu/service_facebook.py | service_facebook._update_config | def _update_config(self,directory,filename):
"""Manages FB config files"""
basefilename=os.path.splitext(filename)[0]
ext=os.path.splitext(filename)[1].lower()
#if filename==LOCATION_FILE:
#return self._update_config_location(directory)
#FIXME
#elif filename==... | python | def _update_config(self,directory,filename):
"""Manages FB config files"""
basefilename=os.path.splitext(filename)[0]
ext=os.path.splitext(filename)[1].lower()
#if filename==LOCATION_FILE:
#return self._update_config_location(directory)
#FIXME
#elif filename==... | [
"def",
"_update_config",
"(",
"self",
",",
"directory",
",",
"filename",
")",
":",
"basefilename",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"0",
"]",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"["... | Manages FB config files | [
"Manages",
"FB",
"config",
"files"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L113-L132 |
241,358 | esterhui/pypu | pypu/service_facebook.py | service_facebook._get_title | def _get_title(self,directory,filename):
"""Loads image title if any"""
# =========== LOAD TITLE ========
fullfile=os.path.join(directory,filename+'.title')
try:
logger.debug('trying to open [%s]'%(fullfile))
_title=(open(fullfile).readline().strip())
... | python | def _get_title(self,directory,filename):
"""Loads image title if any"""
# =========== LOAD TITLE ========
fullfile=os.path.join(directory,filename+'.title')
try:
logger.debug('trying to open [%s]'%(fullfile))
_title=(open(fullfile).readline().strip())
... | [
"def",
"_get_title",
"(",
"self",
",",
"directory",
",",
"filename",
")",
":",
"# =========== LOAD TITLE ========",
"fullfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"filename",
"+",
"'.title'",
")",
"try",
":",
"logger",
".",
"debug",
... | Loads image title if any | [
"Loads",
"image",
"title",
"if",
"any"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L134-L145 |
241,359 | esterhui/pypu | pypu/service_facebook.py | service_facebook._load_megapixels | def _load_megapixels(self,directory):
"""Opens megapixel file, if contains '3.5' for instance,
will scale all uploaded photos in directory this this size,
the original photo is untouched. Returns None if
file not found
"""
#FIXME: should check if DB tracking file... | python | def _load_megapixels(self,directory):
"""Opens megapixel file, if contains '3.5' for instance,
will scale all uploaded photos in directory this this size,
the original photo is untouched. Returns None if
file not found
"""
#FIXME: should check if DB tracking file... | [
"def",
"_load_megapixels",
"(",
"self",
",",
"directory",
")",
":",
"#FIXME: should check if DB tracking file before using it",
"fullfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"MEGAPIXEL_FILE",
")",
"try",
":",
"mp",
"=",
"float",
"(",
"o... | Opens megapixel file, if contains '3.5' for instance,
will scale all uploaded photos in directory this this size,
the original photo is untouched. Returns None if
file not found | [
"Opens",
"megapixel",
"file",
"if",
"contains",
"3",
".",
"5",
"for",
"instance",
"will",
"scale",
"all",
"uploaded",
"photos",
"in",
"directory",
"this",
"this",
"size",
"the",
"original",
"photo",
"is",
"untouched",
".",
"Returns",
"None",
"if",
"file",
... | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L147-L165 |
241,360 | esterhui/pypu | pypu/service_facebook.py | service_facebook._load_sets | def _load_sets(self,directory):
"""Loads sets from set file and return
as list of strings
"""
# --- Read sets out of file
_sets=[]
try:
fullfile=os.path.join(directory,SET_FILE)
lsets=open(fullfile).readline().split(',')
for tag in lset... | python | def _load_sets(self,directory):
"""Loads sets from set file and return
as list of strings
"""
# --- Read sets out of file
_sets=[]
try:
fullfile=os.path.join(directory,SET_FILE)
lsets=open(fullfile).readline().split(',')
for tag in lset... | [
"def",
"_load_sets",
"(",
"self",
",",
"directory",
")",
":",
"# --- Read sets out of file",
"_sets",
"=",
"[",
"]",
"try",
":",
"fullfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"SET_FILE",
")",
"lsets",
"=",
"open",
"(",
"fullfile... | Loads sets from set file and return
as list of strings | [
"Loads",
"sets",
"from",
"set",
"file",
"and",
"return",
"as",
"list",
"of",
"strings"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L167-L183 |
241,361 | esterhui/pypu | pypu/service_facebook.py | service_facebook._get_album | def _get_album(self,directory):
"""
Loads set name from SET_FILE, looks up album_id on fb,
it it doesn't exists, creates album. Returns album id and album name
"""
if not self._connectToFB():
print("%s - Couldn't connect to fb"%(directory))
return None,No... | python | def _get_album(self,directory):
"""
Loads set name from SET_FILE, looks up album_id on fb,
it it doesn't exists, creates album. Returns album id and album name
"""
if not self._connectToFB():
print("%s - Couldn't connect to fb"%(directory))
return None,No... | [
"def",
"_get_album",
"(",
"self",
",",
"directory",
")",
":",
"if",
"not",
"self",
".",
"_connectToFB",
"(",
")",
":",
"print",
"(",
"\"%s - Couldn't connect to fb\"",
"%",
"(",
"directory",
")",
")",
"return",
"None",
",",
"None",
"# Load sets from SET_FILE",... | Loads set name from SET_FILE, looks up album_id on fb,
it it doesn't exists, creates album. Returns album id and album name | [
"Loads",
"set",
"name",
"from",
"SET_FILE",
"looks",
"up",
"album_id",
"on",
"fb",
"it",
"it",
"doesn",
"t",
"exists",
"creates",
"album",
".",
"Returns",
"album",
"id",
"and",
"album",
"name"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L201-L230 |
241,362 | esterhui/pypu | pypu/service_facebook.py | service_facebook._getphoto_originalsize | def _getphoto_originalsize(self,pid):
"""Asks fb for photo original size
returns tuple with width,height
"""
logger.debug('%s - Getting original size from fb'%(pid))
i=self.fb.get_object(pid)
width=i['images'][0]['width']
height=i['images'][0]['height']
re... | python | def _getphoto_originalsize(self,pid):
"""Asks fb for photo original size
returns tuple with width,height
"""
logger.debug('%s - Getting original size from fb'%(pid))
i=self.fb.get_object(pid)
width=i['images'][0]['width']
height=i['images'][0]['height']
re... | [
"def",
"_getphoto_originalsize",
"(",
"self",
",",
"pid",
")",
":",
"logger",
".",
"debug",
"(",
"'%s - Getting original size from fb'",
"%",
"(",
"pid",
")",
")",
"i",
"=",
"self",
".",
"fb",
".",
"get_object",
"(",
"pid",
")",
"width",
"=",
"i",
"[",
... | Asks fb for photo original size
returns tuple with width,height | [
"Asks",
"fb",
"for",
"photo",
"original",
"size",
"returns",
"tuple",
"with",
"width",
"height"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L251-L259 |
241,363 | esterhui/pypu | pypu/service_facebook.py | service_facebook._getphoto_location | def _getphoto_location(self,pid):
"""Asks fb for photo location information
returns tuple with lat,lon,accuracy
"""
logger.debug('%s - Getting location from fb'%(pid))
lat=None
lon=None
accuracy=None
resp=self.fb.photos_geo_getLocation(photo_id=pid)
... | python | def _getphoto_location(self,pid):
"""Asks fb for photo location information
returns tuple with lat,lon,accuracy
"""
logger.debug('%s - Getting location from fb'%(pid))
lat=None
lon=None
accuracy=None
resp=self.fb.photos_geo_getLocation(photo_id=pid)
... | [
"def",
"_getphoto_location",
"(",
"self",
",",
"pid",
")",
":",
"logger",
".",
"debug",
"(",
"'%s - Getting location from fb'",
"%",
"(",
"pid",
")",
")",
"lat",
"=",
"None",
"lon",
"=",
"None",
"accuracy",
"=",
"None",
"resp",
"=",
"self",
".",
"fb",
... | Asks fb for photo location information
returns tuple with lat,lon,accuracy | [
"Asks",
"fb",
"for",
"photo",
"location",
"information",
"returns",
"tuple",
"with",
"lat",
"lon",
"accuracy"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L262-L285 |
241,364 | esterhui/pypu | pypu/service_facebook.py | service_facebook._remove_media | def _remove_media(self,directory,files=None):
"""Removes specified files from fb"""
# Connect if we aren't already
if not self._connectToFB():
logger.error("%s - Couldn't connect to fb")
return False
db=self._loadDB(directory)
# If no files given, use fil... | python | def _remove_media(self,directory,files=None):
"""Removes specified files from fb"""
# Connect if we aren't already
if not self._connectToFB():
logger.error("%s - Couldn't connect to fb")
return False
db=self._loadDB(directory)
# If no files given, use fil... | [
"def",
"_remove_media",
"(",
"self",
",",
"directory",
",",
"files",
"=",
"None",
")",
":",
"# Connect if we aren't already",
"if",
"not",
"self",
".",
"_connectToFB",
"(",
")",
":",
"logger",
".",
"error",
"(",
"\"%s - Couldn't connect to fb\"",
")",
"return",
... | Removes specified files from fb | [
"Removes",
"specified",
"files",
"from",
"fb"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L287-L322 |
241,365 | esterhui/pypu | pypu/service_facebook.py | service_facebook._upload_media | def _upload_media(self,directory,files=None,resize_request=None, \
movealbum_request=None,changetitle_request=None):
"""Uploads media file to FB, returns True if
uploaded successfully, Will replace
if already uploaded, If megapixels > 0, will
scale photos before upload
... | python | def _upload_media(self,directory,files=None,resize_request=None, \
movealbum_request=None,changetitle_request=None):
"""Uploads media file to FB, returns True if
uploaded successfully, Will replace
if already uploaded, If megapixels > 0, will
scale photos before upload
... | [
"def",
"_upload_media",
"(",
"self",
",",
"directory",
",",
"files",
"=",
"None",
",",
"resize_request",
"=",
"None",
",",
"movealbum_request",
"=",
"None",
",",
"changetitle_request",
"=",
"None",
")",
":",
"# Connect if we aren't already",
"if",
"not",
"self",... | Uploads media file to FB, returns True if
uploaded successfully, Will replace
if already uploaded, If megapixels > 0, will
scale photos before upload
If no filename given, will go through all files in DB | [
"Uploads",
"media",
"file",
"to",
"FB",
"returns",
"True",
"if",
"uploaded",
"successfully",
"Will",
"replace",
"if",
"already",
"uploaded",
"If",
"megapixels",
">",
"0",
"will",
"scale",
"photos",
"before",
"upload",
"If",
"no",
"filename",
"given",
"will",
... | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L324-L375 |
241,366 | esterhui/pypu | pypu/service_facebook.py | service_facebook._title_uptodate | def _title_uptodate(self,fullfile,pid,_title):
"""Check fb photo title against provided title,
returns true if they match"""
i=self.fb.get_object(pid)
if i.has_key('name'):
if _title == i['name']:
return True
return False | python | def _title_uptodate(self,fullfile,pid,_title):
"""Check fb photo title against provided title,
returns true if they match"""
i=self.fb.get_object(pid)
if i.has_key('name'):
if _title == i['name']:
return True
return False | [
"def",
"_title_uptodate",
"(",
"self",
",",
"fullfile",
",",
"pid",
",",
"_title",
")",
":",
"i",
"=",
"self",
".",
"fb",
".",
"get_object",
"(",
"pid",
")",
"if",
"i",
".",
"has_key",
"(",
"'name'",
")",
":",
"if",
"_title",
"==",
"i",
"[",
"'na... | Check fb photo title against provided title,
returns true if they match | [
"Check",
"fb",
"photo",
"title",
"against",
"provided",
"title",
"returns",
"true",
"if",
"they",
"match"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L468-L476 |
241,367 | esterhui/pypu | pypu/service_facebook.py | service_facebook._already_in_album | def _already_in_album(self,fullfile,pid,album_id):
"""Check to see if photo with given pid is already
in the album_id, returns true if this is the case
"""
logger.debug("fb: Checking if pid %s in album %s",pid,album_id)
pid_in_album=[]
# Get all photos in album
p... | python | def _already_in_album(self,fullfile,pid,album_id):
"""Check to see if photo with given pid is already
in the album_id, returns true if this is the case
"""
logger.debug("fb: Checking if pid %s in album %s",pid,album_id)
pid_in_album=[]
# Get all photos in album
p... | [
"def",
"_already_in_album",
"(",
"self",
",",
"fullfile",
",",
"pid",
",",
"album_id",
")",
":",
"logger",
".",
"debug",
"(",
"\"fb: Checking if pid %s in album %s\"",
",",
"pid",
",",
"album_id",
")",
"pid_in_album",
"=",
"[",
"]",
"# Get all photos in album",
... | Check to see if photo with given pid is already
in the album_id, returns true if this is the case | [
"Check",
"to",
"see",
"if",
"photo",
"with",
"given",
"pid",
"is",
"already",
"in",
"the",
"album_id",
"returns",
"true",
"if",
"this",
"is",
"the",
"case"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L478-L498 |
241,368 | esterhui/pypu | pypu/service_facebook.py | service_facebook.PrintSets | def PrintSets(self):
"""Prints set name and number of photos in set"""
sets=self._getphotosets()
for setname in sets:
print("%s [%d]"%(setname,sets[setname]['number_photos'])) | python | def PrintSets(self):
"""Prints set name and number of photos in set"""
sets=self._getphotosets()
for setname in sets:
print("%s [%d]"%(setname,sets[setname]['number_photos'])) | [
"def",
"PrintSets",
"(",
"self",
")",
":",
"sets",
"=",
"self",
".",
"_getphotosets",
"(",
")",
"for",
"setname",
"in",
"sets",
":",
"print",
"(",
"\"%s [%d]\"",
"%",
"(",
"setname",
",",
"sets",
"[",
"setname",
"]",
"[",
"'number_photos'",
"]",
")",
... | Prints set name and number of photos in set | [
"Prints",
"set",
"name",
"and",
"number",
"of",
"photos",
"in",
"set"
] | cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec | https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_facebook.py#L550-L554 |
241,369 | JNRowe/jnrbase | jnrbase/context.py | chdir | def chdir(__path: str) -> ContextManager:
"""Context handler to temporarily switch directories.
Args:
__path: Directory to change to
Yields:
Execution context in ``path``
"""
old = os.getcwd()
try:
os.chdir(__path)
yield
finally:
os.chdir(old) | python | def chdir(__path: str) -> ContextManager:
"""Context handler to temporarily switch directories.
Args:
__path: Directory to change to
Yields:
Execution context in ``path``
"""
old = os.getcwd()
try:
os.chdir(__path)
yield
finally:
os.chdir(old) | [
"def",
"chdir",
"(",
"__path",
":",
"str",
")",
"->",
"ContextManager",
":",
"old",
"=",
"os",
".",
"getcwd",
"(",
")",
"try",
":",
"os",
".",
"chdir",
"(",
"__path",
")",
"yield",
"finally",
":",
"os",
".",
"chdir",
"(",
"old",
")"
] | Context handler to temporarily switch directories.
Args:
__path: Directory to change to
Yields:
Execution context in ``path`` | [
"Context",
"handler",
"to",
"temporarily",
"switch",
"directories",
"."
] | ae505ef69a9feb739b5f4e62c5a8e6533104d3ea | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/context.py#L27-L41 |
241,370 | JNRowe/jnrbase | jnrbase/context.py | env | def env(**kwargs: Union[Dict[str, str], None]) -> ContextManager:
"""Context handler to temporarily alter environment.
If you supply a value of ``None``, then the associated key will be deleted
from the environment.
Args:
kwargs: Environment variables to override
Yields:
Execution... | python | def env(**kwargs: Union[Dict[str, str], None]) -> ContextManager:
"""Context handler to temporarily alter environment.
If you supply a value of ``None``, then the associated key will be deleted
from the environment.
Args:
kwargs: Environment variables to override
Yields:
Execution... | [
"def",
"env",
"(",
"*",
"*",
"kwargs",
":",
"Union",
"[",
"Dict",
"[",
"str",
",",
"str",
"]",
",",
"None",
"]",
")",
"->",
"ContextManager",
":",
"old",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"try",
":",
"os",
".",
"environ",
".",
... | Context handler to temporarily alter environment.
If you supply a value of ``None``, then the associated key will be deleted
from the environment.
Args:
kwargs: Environment variables to override
Yields:
Execution context with modified environment | [
"Context",
"handler",
"to",
"temporarily",
"alter",
"environment",
"."
] | ae505ef69a9feb739b5f4e62c5a8e6533104d3ea | https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/context.py#L45-L77 |
241,371 | stevepeak/stuffed | stuffed/address.py | Address.distance_to | def distance_to(self, address, measure="Miles", httpclient=None):
"""Distance to another address
"""
if isinstance(address, Address) and self.latlng and address.latlng:
lat1, lon1 = map(float, self.latlng)
lat2, lon2 = map(float, address.latlng)
elif self.latlng a... | python | def distance_to(self, address, measure="Miles", httpclient=None):
"""Distance to another address
"""
if isinstance(address, Address) and self.latlng and address.latlng:
lat1, lon1 = map(float, self.latlng)
lat2, lon2 = map(float, address.latlng)
elif self.latlng a... | [
"def",
"distance_to",
"(",
"self",
",",
"address",
",",
"measure",
"=",
"\"Miles\"",
",",
"httpclient",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"address",
",",
"Address",
")",
"and",
"self",
".",
"latlng",
"and",
"address",
".",
"latlng",
":",
... | Distance to another address | [
"Distance",
"to",
"another",
"address"
] | cc18d5d34b36225035d618d666275c913f5f66de | https://github.com/stevepeak/stuffed/blob/cc18d5d34b36225035d618d666275c913f5f66de/stuffed/address.py#L93-L120 |
241,372 | Fuyukai/ConfigMaster | configmaster/JSONConfigFile.py | json_dump_hook | def json_dump_hook(cfg, text: bool=False):
"""
Dumps all the data into a JSON file.
"""
data = cfg.config.dump()
if not text:
json.dump(data, cfg.fd)
else:
return json.dumps(data) | python | def json_dump_hook(cfg, text: bool=False):
"""
Dumps all the data into a JSON file.
"""
data = cfg.config.dump()
if not text:
json.dump(data, cfg.fd)
else:
return json.dumps(data) | [
"def",
"json_dump_hook",
"(",
"cfg",
",",
"text",
":",
"bool",
"=",
"False",
")",
":",
"data",
"=",
"cfg",
".",
"config",
".",
"dump",
"(",
")",
"if",
"not",
"text",
":",
"json",
".",
"dump",
"(",
"data",
",",
"cfg",
".",
"fd",
")",
"else",
":"... | Dumps all the data into a JSON file. | [
"Dumps",
"all",
"the",
"data",
"into",
"a",
"JSON",
"file",
"."
] | 8018aa415da55c84edaa8a49664f674758a14edd | https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/JSONConfigFile.py#L49-L58 |
241,373 | skitazaki/python-clitool | clitool/config.py | ConfigLoader.load | def load(self, env=None):
""" Load a section values of given environment.
If nothing to specified, use environmental variable.
If unknown environment was specified, warn it on logger.
:param env: environment key to load in a coercive manner
:type env: string
:rtype: dict... | python | def load(self, env=None):
""" Load a section values of given environment.
If nothing to specified, use environmental variable.
If unknown environment was specified, warn it on logger.
:param env: environment key to load in a coercive manner
:type env: string
:rtype: dict... | [
"def",
"load",
"(",
"self",
",",
"env",
"=",
"None",
")",
":",
"self",
".",
"_load",
"(",
")",
"e",
"=",
"env",
"or",
"os",
".",
"environ",
".",
"get",
"(",
"RUNNING_MODE_ENVKEY",
",",
"DEFAULT_RUNNING_MODE",
")",
"if",
"e",
"in",
"self",
".",
"con... | Load a section values of given environment.
If nothing to specified, use environmental variable.
If unknown environment was specified, warn it on logger.
:param env: environment key to load in a coercive manner
:type env: string
:rtype: dict | [
"Load",
"a",
"section",
"values",
"of",
"given",
"environment",
".",
"If",
"nothing",
"to",
"specified",
"use",
"environmental",
"variable",
".",
"If",
"unknown",
"environment",
"was",
"specified",
"warn",
"it",
"on",
"logger",
"."
] | 4971f8d093d51c6fd0e6cc536bbb597f78b570ab | https://github.com/skitazaki/python-clitool/blob/4971f8d093d51c6fd0e6cc536bbb597f78b570ab/clitool/config.py#L78-L92 |
241,374 | dusty-phillips/opterator | examples/ls.py | main | def main(show_details:['-l']=False, cols:['-w', '--width']='', *files):
'''
List information about a particular file or set of files
:param show_details: Whether to show detailed info about files
:param cols: specify screen width
'''
print(files)
print(show_details)
print(cols) | python | def main(show_details:['-l']=False, cols:['-w', '--width']='', *files):
'''
List information about a particular file or set of files
:param show_details: Whether to show detailed info about files
:param cols: specify screen width
'''
print(files)
print(show_details)
print(cols) | [
"def",
"main",
"(",
"show_details",
":",
"[",
"'-l'",
"]",
"=",
"False",
",",
"cols",
":",
"[",
"'-w'",
",",
"'--width'",
"]",
"=",
"''",
",",
"*",
"files",
")",
":",
"print",
"(",
"files",
")",
"print",
"(",
"show_details",
")",
"print",
"(",
"c... | List information about a particular file or set of files
:param show_details: Whether to show detailed info about files
:param cols: specify screen width | [
"List",
"information",
"about",
"a",
"particular",
"file",
"or",
"set",
"of",
"files"
] | 84fe31f22c73dc0a3666ed82c179461b1799c257 | https://github.com/dusty-phillips/opterator/blob/84fe31f22c73dc0a3666ed82c179461b1799c257/examples/ls.py#L7-L16 |
241,375 | jpablo128/simplystatic | simplystatic/util.py | random_date | def random_date():
'''Return a valid random date.'''
d = datetime.datetime.now().date()
d = d - datetime.timedelta(random.randint(20,2001))
return d | python | def random_date():
'''Return a valid random date.'''
d = datetime.datetime.now().date()
d = d - datetime.timedelta(random.randint(20,2001))
return d | [
"def",
"random_date",
"(",
")",
":",
"d",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"date",
"(",
")",
"d",
"=",
"d",
"-",
"datetime",
".",
"timedelta",
"(",
"random",
".",
"randint",
"(",
"20",
",",
"2001",
")",
")",
"return",
... | Return a valid random date. | [
"Return",
"a",
"valid",
"random",
"date",
"."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/util.py#L65-L69 |
241,376 | jpablo128/simplystatic | simplystatic/util.py | random_md_page | def random_md_page():
'''Generate random markdown page content..
If the parameters are zero, instead of a fixed number of elements
it uses a random number.
'''
# headers #, ##
# blockquote >
# lists *
# codeblock (indent 4 spaces)
# hrule, 3 or more - in a line
# emphasis: wor... | python | def random_md_page():
'''Generate random markdown page content..
If the parameters are zero, instead of a fixed number of elements
it uses a random number.
'''
# headers #, ##
# blockquote >
# lists *
# codeblock (indent 4 spaces)
# hrule, 3 or more - in a line
# emphasis: wor... | [
"def",
"random_md_page",
"(",
")",
":",
"# headers #, ##",
"# blockquote >",
"# lists *",
"# codeblock (indent 4 spaces)",
"# hrule, 3 or more - in a line",
"# emphasis: word surrounded by one * or _",
"lines",
"=",
"[",
"]",
"lines",
".",
"append",
"(",
"\"\\n# \"",
"+",
"... | Generate random markdown page content..
If the parameters are zero, instead of a fixed number of elements
it uses a random number. | [
"Generate",
"random",
"markdown",
"page",
"content",
".."
] | 91ac579c8f34fa240bef9b87adb0116c6b40b24d | https://github.com/jpablo128/simplystatic/blob/91ac579c8f34fa240bef9b87adb0116c6b40b24d/simplystatic/util.py#L83-L106 |
241,377 | thomasbiddle/Kippt-for-Python | kippt/lists.py | Lists.all | def all(self, **args):
""" Return all Lists.
"""
limit = args['limit'] if 'limit' in args else 20
offset = args['offset'] if 'offset' in args else 0
r = requests.get(
"https://kippt.com/api/lists?limit=%s&offset=%s" % (limit, offset),
headers=self.kippt.... | python | def all(self, **args):
""" Return all Lists.
"""
limit = args['limit'] if 'limit' in args else 20
offset = args['offset'] if 'offset' in args else 0
r = requests.get(
"https://kippt.com/api/lists?limit=%s&offset=%s" % (limit, offset),
headers=self.kippt.... | [
"def",
"all",
"(",
"self",
",",
"*",
"*",
"args",
")",
":",
"limit",
"=",
"args",
"[",
"'limit'",
"]",
"if",
"'limit'",
"in",
"args",
"else",
"20",
"offset",
"=",
"args",
"[",
"'offset'",
"]",
"if",
"'offset'",
"in",
"args",
"else",
"0",
"r",
"="... | Return all Lists. | [
"Return",
"all",
"Lists",
"."
] | dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267 | https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/lists.py#L19-L30 |
241,378 | thomasbiddle/Kippt-for-Python | kippt/lists.py | Lists.create | def create(self, title, **args):
""" Create a new Kippt List.
Parameters:
- title (Required)
- args Dictionary of other fields
Accepted fields can be found here:
https://github.com/kippt/api-documentation/blob/master/objects/list.md
"""
# Merge our t... | python | def create(self, title, **args):
""" Create a new Kippt List.
Parameters:
- title (Required)
- args Dictionary of other fields
Accepted fields can be found here:
https://github.com/kippt/api-documentation/blob/master/objects/list.md
"""
# Merge our t... | [
"def",
"create",
"(",
"self",
",",
"title",
",",
"*",
"*",
"args",
")",
":",
"# Merge our title as a parameter and JSONify it.",
"data",
"=",
"json",
".",
"dumps",
"(",
"dict",
"(",
"{",
"'title'",
":",
"title",
"}",
",",
"*",
"*",
"args",
")",
")",
"r... | Create a new Kippt List.
Parameters:
- title (Required)
- args Dictionary of other fields
Accepted fields can be found here:
https://github.com/kippt/api-documentation/blob/master/objects/list.md | [
"Create",
"a",
"new",
"Kippt",
"List",
"."
] | dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267 | https://github.com/thomasbiddle/Kippt-for-Python/blob/dddd0ff84d70ccf2d84e50e3cff7aad89f9c1267/kippt/lists.py#L48-L65 |
241,379 | inveniosoftware-contrib/record-recommender | record_recommender/cli.py | cli | def cli(config_path, verbose):
"""Record-Recommender command line version."""
global config, store
if not config_path:
config_path = '/etc/record_recommender.yml'
config = get_config(config_path)
setup_logging(config)
store = FileStore(config) | python | def cli(config_path, verbose):
"""Record-Recommender command line version."""
global config, store
if not config_path:
config_path = '/etc/record_recommender.yml'
config = get_config(config_path)
setup_logging(config)
store = FileStore(config) | [
"def",
"cli",
"(",
"config_path",
",",
"verbose",
")",
":",
"global",
"config",
",",
"store",
"if",
"not",
"config_path",
":",
"config_path",
"=",
"'/etc/record_recommender.yml'",
"config",
"=",
"get_config",
"(",
"config_path",
")",
"setup_logging",
"(",
"confi... | Record-Recommender command line version. | [
"Record",
"-",
"Recommender",
"command",
"line",
"version",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L49-L56 |
241,380 | inveniosoftware-contrib/record-recommender | record_recommender/cli.py | fetch | def fetch(weeks, force):
"""Fetch newest PageViews and Downloads."""
weeks = get_last_weeks(weeks)
print(weeks)
recommender = RecordRecommender(config)
recommender.fetch_weeks(weeks, overwrite=force) | python | def fetch(weeks, force):
"""Fetch newest PageViews and Downloads."""
weeks = get_last_weeks(weeks)
print(weeks)
recommender = RecordRecommender(config)
recommender.fetch_weeks(weeks, overwrite=force) | [
"def",
"fetch",
"(",
"weeks",
",",
"force",
")",
":",
"weeks",
"=",
"get_last_weeks",
"(",
"weeks",
")",
"print",
"(",
"weeks",
")",
"recommender",
"=",
"RecordRecommender",
"(",
"config",
")",
"recommender",
".",
"fetch_weeks",
"(",
"weeks",
",",
"overwri... | Fetch newest PageViews and Downloads. | [
"Fetch",
"newest",
"PageViews",
"and",
"Downloads",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L75-L80 |
241,381 | inveniosoftware-contrib/record-recommender | record_recommender/cli.py | update_recommender | def update_recommender(ctx, weeks, processes):
"""
Download and build the recommendations.
- Fetch new statistics from the current week.
- Generate recommendations.
- Update the recommendations.
"""
weeks = get_last_weeks(weeks)
recommender = RecordRecommender(config)
# Redownload i... | python | def update_recommender(ctx, weeks, processes):
"""
Download and build the recommendations.
- Fetch new statistics from the current week.
- Generate recommendations.
- Update the recommendations.
"""
weeks = get_last_weeks(weeks)
recommender = RecordRecommender(config)
# Redownload i... | [
"def",
"update_recommender",
"(",
"ctx",
",",
"weeks",
",",
"processes",
")",
":",
"weeks",
"=",
"get_last_weeks",
"(",
"weeks",
")",
"recommender",
"=",
"RecordRecommender",
"(",
"config",
")",
"# Redownload incomplete weeks",
"first_weeks",
"=",
"weeks",
"[",
... | Download and build the recommendations.
- Fetch new statistics from the current week.
- Generate recommendations.
- Update the recommendations. | [
"Download",
"and",
"build",
"the",
"recommendations",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L87-L107 |
241,382 | inveniosoftware-contrib/record-recommender | record_recommender/cli.py | profiles | def profiles(weeks):
"""
Number of weeks to build.
Starting with the current week.
"""
profiles = Profiles(store)
weeks = get_last_weeks(weeks) if isinstance(weeks, int) else weeks
print(weeks)
profiles.create(weeks) | python | def profiles(weeks):
"""
Number of weeks to build.
Starting with the current week.
"""
profiles = Profiles(store)
weeks = get_last_weeks(weeks) if isinstance(weeks, int) else weeks
print(weeks)
profiles.create(weeks) | [
"def",
"profiles",
"(",
"weeks",
")",
":",
"profiles",
"=",
"Profiles",
"(",
"store",
")",
"weeks",
"=",
"get_last_weeks",
"(",
"weeks",
")",
"if",
"isinstance",
"(",
"weeks",
",",
"int",
")",
"else",
"weeks",
"print",
"(",
"weeks",
")",
"profiles",
".... | Number of weeks to build.
Starting with the current week. | [
"Number",
"of",
"weeks",
"to",
"build",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L112-L121 |
241,383 | inveniosoftware-contrib/record-recommender | record_recommender/cli.py | build | def build(processes):
"""
Calculate all recommendations using the number of specified processes.
The recommendations are calculated from the generated Profiles file.
"""
recommender = RecordRecommender(config)
recommender.create_all_recommendations(processes, ip_views=True) | python | def build(processes):
"""
Calculate all recommendations using the number of specified processes.
The recommendations are calculated from the generated Profiles file.
"""
recommender = RecordRecommender(config)
recommender.create_all_recommendations(processes, ip_views=True) | [
"def",
"build",
"(",
"processes",
")",
":",
"recommender",
"=",
"RecordRecommender",
"(",
"config",
")",
"recommender",
".",
"create_all_recommendations",
"(",
"processes",
",",
"ip_views",
"=",
"True",
")"
] | Calculate all recommendations using the number of specified processes.
The recommendations are calculated from the generated Profiles file. | [
"Calculate",
"all",
"recommendations",
"using",
"the",
"number",
"of",
"specified",
"processes",
"."
] | 07f71e783369e6373218b5e6ba0bf15901e9251a | https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/cli.py#L126-L133 |
241,384 | klmitch/appathy | appathy/response.py | ResponseObject._bind | def _bind(self, _descriptor):
"""
Bind a ResponseObject to a given action descriptor. This
updates the default HTTP response code and selects the
appropriate content type and serializer for the response.
"""
# If the method has a default code, use it
self._defco... | python | def _bind(self, _descriptor):
"""
Bind a ResponseObject to a given action descriptor. This
updates the default HTTP response code and selects the
appropriate content type and serializer for the response.
"""
# If the method has a default code, use it
self._defco... | [
"def",
"_bind",
"(",
"self",
",",
"_descriptor",
")",
":",
"# If the method has a default code, use it",
"self",
".",
"_defcode",
"=",
"getattr",
"(",
"_descriptor",
".",
"method",
",",
"'_wsgi_code'",
",",
"200",
")",
"# Set up content type and serializer",
"self",
... | Bind a ResponseObject to a given action descriptor. This
updates the default HTTP response code and selects the
appropriate content type and serializer for the response. | [
"Bind",
"a",
"ResponseObject",
"to",
"a",
"given",
"action",
"descriptor",
".",
"This",
"updates",
"the",
"default",
"HTTP",
"response",
"code",
"and",
"selects",
"the",
"appropriate",
"content",
"type",
"and",
"serializer",
"for",
"the",
"response",
"."
] | a10aa7d21d38622e984a8fe106ab37114af90dc2 | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/response.py#L122-L133 |
241,385 | klmitch/appathy | appathy/response.py | ResponseObject._serialize | def _serialize(self):
"""
Serialize the ResponseObject. Returns a webob `Response`
object.
"""
# Do something appropriate if the response object is unbound
if self._defcode is None:
raise exceptions.UnboundResponse()
# Build the response
res... | python | def _serialize(self):
"""
Serialize the ResponseObject. Returns a webob `Response`
object.
"""
# Do something appropriate if the response object is unbound
if self._defcode is None:
raise exceptions.UnboundResponse()
# Build the response
res... | [
"def",
"_serialize",
"(",
"self",
")",
":",
"# Do something appropriate if the response object is unbound",
"if",
"self",
".",
"_defcode",
"is",
"None",
":",
"raise",
"exceptions",
".",
"UnboundResponse",
"(",
")",
"# Build the response",
"resp",
"=",
"self",
".",
"... | Serialize the ResponseObject. Returns a webob `Response`
object. | [
"Serialize",
"the",
"ResponseObject",
".",
"Returns",
"a",
"webob",
"Response",
"object",
"."
] | a10aa7d21d38622e984a8fe106ab37114af90dc2 | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/response.py#L135-L155 |
241,386 | klmitch/appathy | appathy/response.py | ResponseObject.code | def code(self):
"""
The HTTP response code associated with this ResponseObject.
If instantiated directly without overriding the code, returns
200 even if the default for the method is some other value.
Can be set or deleted; in the latter case, the default will be
restore... | python | def code(self):
"""
The HTTP response code associated with this ResponseObject.
If instantiated directly without overriding the code, returns
200 even if the default for the method is some other value.
Can be set or deleted; in the latter case, the default will be
restore... | [
"def",
"code",
"(",
"self",
")",
":",
"if",
"self",
".",
"_code",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_code",
"elif",
"self",
".",
"_defcode",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_defcode",
"return",
"200"
] | The HTTP response code associated with this ResponseObject.
If instantiated directly without overriding the code, returns
200 even if the default for the method is some other value.
Can be set or deleted; in the latter case, the default will be
restored. | [
"The",
"HTTP",
"response",
"code",
"associated",
"with",
"this",
"ResponseObject",
".",
"If",
"instantiated",
"directly",
"without",
"overriding",
"the",
"code",
"returns",
"200",
"even",
"if",
"the",
"default",
"for",
"the",
"method",
"is",
"some",
"other",
"... | a10aa7d21d38622e984a8fe106ab37114af90dc2 | https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/response.py#L158-L171 |
241,387 | deviantony/valigator | valigator/notify.py | report_message | def report_message(report):
"""Report message."""
body = 'Error: return code != 0\n\n'
body += 'Archive: {}\n\n'.format(report['archive'])
body += 'Docker image: {}\n\n'.format(report['image'])
body += 'Docker container: {}\n\n'.format(report['container_id'])
return body | python | def report_message(report):
"""Report message."""
body = 'Error: return code != 0\n\n'
body += 'Archive: {}\n\n'.format(report['archive'])
body += 'Docker image: {}\n\n'.format(report['image'])
body += 'Docker container: {}\n\n'.format(report['container_id'])
return body | [
"def",
"report_message",
"(",
"report",
")",
":",
"body",
"=",
"'Error: return code != 0\\n\\n'",
"body",
"+=",
"'Archive: {}\\n\\n'",
".",
"format",
"(",
"report",
"[",
"'archive'",
"]",
")",
"body",
"+=",
"'Docker image: {}\\n\\n'",
".",
"format",
"(",
"report",... | Report message. | [
"Report",
"message",
"."
] | 0557029bc58ea1270e358c14ca382d3807ed5b6f | https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/notify.py#L53-L59 |
241,388 | deviantony/valigator | valigator/notify.py | task_failure_message | def task_failure_message(task_report):
"""Task failure message."""
trace_list = traceback.format_tb(task_report['traceback'])
body = 'Error: task failure\n\n'
body += 'Task ID: {}\n\n'.format(task_report['task_id'])
body += 'Archive: {}\n\n'.format(task_report['archive'])
body += 'Docker image: ... | python | def task_failure_message(task_report):
"""Task failure message."""
trace_list = traceback.format_tb(task_report['traceback'])
body = 'Error: task failure\n\n'
body += 'Task ID: {}\n\n'.format(task_report['task_id'])
body += 'Archive: {}\n\n'.format(task_report['archive'])
body += 'Docker image: ... | [
"def",
"task_failure_message",
"(",
"task_report",
")",
":",
"trace_list",
"=",
"traceback",
".",
"format_tb",
"(",
"task_report",
"[",
"'traceback'",
"]",
")",
"body",
"=",
"'Error: task failure\\n\\n'",
"body",
"+=",
"'Task ID: {}\\n\\n'",
".",
"format",
"(",
"t... | Task failure message. | [
"Task",
"failure",
"message",
"."
] | 0557029bc58ea1270e358c14ca382d3807ed5b6f | https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/notify.py#L62-L72 |
241,389 | deviantony/valigator | valigator/notify.py | MailNotifier.send_email | def send_email(self, message):
"""Initiate a SMTP session and send an email."""
msg = MIMEMultipart()
msg['From'] = self.from_address
msg['To'] = self.to_address
msg['Subject'] = self.title
msg.attach(MIMEText('<pre>' + cgi.escape(message) + '</pre>', 'html'))
smt... | python | def send_email(self, message):
"""Initiate a SMTP session and send an email."""
msg = MIMEMultipart()
msg['From'] = self.from_address
msg['To'] = self.to_address
msg['Subject'] = self.title
msg.attach(MIMEText('<pre>' + cgi.escape(message) + '</pre>', 'html'))
smt... | [
"def",
"send_email",
"(",
"self",
",",
"message",
")",
":",
"msg",
"=",
"MIMEMultipart",
"(",
")",
"msg",
"[",
"'From'",
"]",
"=",
"self",
".",
"from_address",
"msg",
"[",
"'To'",
"]",
"=",
"self",
".",
"to_address",
"msg",
"[",
"'Subject'",
"]",
"="... | Initiate a SMTP session and send an email. | [
"Initiate",
"a",
"SMTP",
"session",
"and",
"send",
"an",
"email",
"."
] | 0557029bc58ea1270e358c14ca382d3807ed5b6f | https://github.com/deviantony/valigator/blob/0557029bc58ea1270e358c14ca382d3807ed5b6f/valigator/notify.py#L27-L40 |
241,390 | honzamach/pynspect | pynspect/jpath.py | jpath_parse | def jpath_parse(jpath):
"""
Parse given JPath into chunks.
Returns list of dictionaries describing all of the JPath chunks.
:param str jpath: JPath to be parsed into chunks
:return: JPath chunks as list of dicts
:rtype: :py:class:`list`
:raises JPathException: in case of invalid JPath synt... | python | def jpath_parse(jpath):
"""
Parse given JPath into chunks.
Returns list of dictionaries describing all of the JPath chunks.
:param str jpath: JPath to be parsed into chunks
:return: JPath chunks as list of dicts
:rtype: :py:class:`list`
:raises JPathException: in case of invalid JPath synt... | [
"def",
"jpath_parse",
"(",
"jpath",
")",
":",
"result",
"=",
"[",
"]",
"breadcrumbs",
"=",
"[",
"]",
"# Split JPath into chunks based on '.' character.",
"chunks",
"=",
"jpath",
".",
"split",
"(",
"'.'",
")",
"for",
"chnk",
"in",
"chunks",
":",
"match",
"=",... | Parse given JPath into chunks.
Returns list of dictionaries describing all of the JPath chunks.
:param str jpath: JPath to be parsed into chunks
:return: JPath chunks as list of dicts
:rtype: :py:class:`list`
:raises JPathException: in case of invalid JPath syntax | [
"Parse",
"given",
"JPath",
"into",
"chunks",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L191-L235 |
241,391 | honzamach/pynspect | pynspect/jpath.py | jpath_values | def jpath_values(structure, jpath):
"""
Return all values at given JPath within given data structure.
For performance reasons this method is intentionally not written as
recursive.
:param str structure: data structure to be searched
:param str jpath: JPath to be evaluated
:return: found va... | python | def jpath_values(structure, jpath):
"""
Return all values at given JPath within given data structure.
For performance reasons this method is intentionally not written as
recursive.
:param str structure: data structure to be searched
:param str jpath: JPath to be evaluated
:return: found va... | [
"def",
"jpath_values",
"(",
"structure",
",",
"jpath",
")",
":",
"# Current working node set.",
"nodes_a",
"=",
"[",
"structure",
"]",
"# Next iteration working node set.",
"nodes_b",
"=",
"[",
"]",
"# Process sequentially all JPath chunks.",
"chunks",
"=",
"jpath_parse_c... | Return all values at given JPath within given data structure.
For performance reasons this method is intentionally not written as
recursive.
:param str structure: data structure to be searched
:param str jpath: JPath to be evaluated
:return: found values as a list
:rtype: :py:class:`list` | [
"Return",
"all",
"values",
"at",
"given",
"JPath",
"within",
"given",
"data",
"structure",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L252-L313 |
241,392 | honzamach/pynspect | pynspect/jpath.py | jpath_exists | def jpath_exists(structure, jpath):
"""
Check if node at given JPath within given data structure does exist.
:param str structure: data structure to be searched
:param str jpath: JPath to be evaluated
:return: True or False
:rtype: bool
"""
result = jpath_value(structure, jpath)
if ... | python | def jpath_exists(structure, jpath):
"""
Check if node at given JPath within given data structure does exist.
:param str structure: data structure to be searched
:param str jpath: JPath to be evaluated
:return: True or False
:rtype: bool
"""
result = jpath_value(structure, jpath)
if ... | [
"def",
"jpath_exists",
"(",
"structure",
",",
"jpath",
")",
":",
"result",
"=",
"jpath_value",
"(",
"structure",
",",
"jpath",
")",
"if",
"not",
"result",
"is",
"None",
":",
"return",
"True",
"return",
"False"
] | Check if node at given JPath within given data structure does exist.
:param str structure: data structure to be searched
:param str jpath: JPath to be evaluated
:return: True or False
:rtype: bool | [
"Check",
"if",
"node",
"at",
"given",
"JPath",
"within",
"given",
"data",
"structure",
"does",
"exist",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L333-L345 |
241,393 | honzamach/pynspect | pynspect/jpath.py | jpath_set | def jpath_set(structure, jpath, value, overwrite = True, unique = False):
"""
Set given JPath to given value within given structure.
For performance reasons this method is intentionally not written as
recursive.
:param str structure: data structure to be searched
:param str jpath: JPath to be ... | python | def jpath_set(structure, jpath, value, overwrite = True, unique = False):
"""
Set given JPath to given value within given structure.
For performance reasons this method is intentionally not written as
recursive.
:param str structure: data structure to be searched
:param str jpath: JPath to be ... | [
"def",
"jpath_set",
"(",
"structure",
",",
"jpath",
",",
"value",
",",
"overwrite",
"=",
"True",
",",
"unique",
"=",
"False",
")",
":",
"chunks",
"=",
"jpath_parse_c",
"(",
"jpath",
")",
"size",
"=",
"len",
"(",
"chunks",
")",
"-",
"1",
"current",
"=... | Set given JPath to given value within given structure.
For performance reasons this method is intentionally not written as
recursive.
:param str structure: data structure to be searched
:param str jpath: JPath to be evaluated
:param any value: value of any type to be set at given path
:param b... | [
"Set",
"given",
"JPath",
"to",
"given",
"value",
"within",
"given",
"structure",
"."
] | 0582dcc1f7aafe50e25a21c792ea1b3367ea5881 | https://github.com/honzamach/pynspect/blob/0582dcc1f7aafe50e25a21c792ea1b3367ea5881/pynspect/jpath.py#L348-L440 |
241,394 | shreyaspotnis/rampage | rampage/queuer.py | queue_ramp_dicts | def queue_ramp_dicts(ramp_dict_list, server_ip_and_port):
"""Simple utility function to queue up a list of dictionaries."""
client = server.ClientForServer(server.BECServer, server_ip_and_port)
for dct in ramp_dict_list:
client.queue_ramp(dct)
client.start({}) | python | def queue_ramp_dicts(ramp_dict_list, server_ip_and_port):
"""Simple utility function to queue up a list of dictionaries."""
client = server.ClientForServer(server.BECServer, server_ip_and_port)
for dct in ramp_dict_list:
client.queue_ramp(dct)
client.start({}) | [
"def",
"queue_ramp_dicts",
"(",
"ramp_dict_list",
",",
"server_ip_and_port",
")",
":",
"client",
"=",
"server",
".",
"ClientForServer",
"(",
"server",
".",
"BECServer",
",",
"server_ip_and_port",
")",
"for",
"dct",
"in",
"ramp_dict_list",
":",
"client",
".",
"qu... | Simple utility function to queue up a list of dictionaries. | [
"Simple",
"utility",
"function",
"to",
"queue",
"up",
"a",
"list",
"of",
"dictionaries",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/queuer.py#L48-L53 |
241,395 | shreyaspotnis/rampage | rampage/queuer.py | flatten_dict | def flatten_dict(dct, separator='-->', allowed_types=[int, float, bool]):
"""Returns a list of string identifiers for each element in dct.
Recursively scans through dct and finds every element whose type is in
allowed_types and adds a string indentifier for it.
eg:
dct = {
'a': 'a stri... | python | def flatten_dict(dct, separator='-->', allowed_types=[int, float, bool]):
"""Returns a list of string identifiers for each element in dct.
Recursively scans through dct and finds every element whose type is in
allowed_types and adds a string indentifier for it.
eg:
dct = {
'a': 'a stri... | [
"def",
"flatten_dict",
"(",
"dct",
",",
"separator",
"=",
"'-->'",
",",
"allowed_types",
"=",
"[",
"int",
",",
"float",
",",
"bool",
"]",
")",
":",
"flat_list",
"=",
"[",
"]",
"for",
"key",
"in",
"sorted",
"(",
"dct",
")",
":",
"if",
"key",
"[",
... | Returns a list of string identifiers for each element in dct.
Recursively scans through dct and finds every element whose type is in
allowed_types and adds a string indentifier for it.
eg:
dct = {
'a': 'a string',
'b': {
'c': 1.0,
'd': True
... | [
"Returns",
"a",
"list",
"of",
"string",
"identifiers",
"for",
"each",
"element",
"in",
"dct",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/queuer.py#L57-L86 |
241,396 | shreyaspotnis/rampage | rampage/queuer.py | set_dict_item | def set_dict_item(dct, name_string, set_to):
"""Sets dictionary item identified by name_string to set_to.
name_string is the indentifier generated using flatten_dict.
Maintains the type of the orginal object in dct and tries to convert set_to
to that type.
"""
key_strings = str(name_string).sp... | python | def set_dict_item(dct, name_string, set_to):
"""Sets dictionary item identified by name_string to set_to.
name_string is the indentifier generated using flatten_dict.
Maintains the type of the orginal object in dct and tries to convert set_to
to that type.
"""
key_strings = str(name_string).sp... | [
"def",
"set_dict_item",
"(",
"dct",
",",
"name_string",
",",
"set_to",
")",
":",
"key_strings",
"=",
"str",
"(",
"name_string",
")",
".",
"split",
"(",
"'-->'",
")",
"d",
"=",
"dct",
"for",
"ks",
"in",
"key_strings",
"[",
":",
"-",
"1",
"]",
":",
"... | Sets dictionary item identified by name_string to set_to.
name_string is the indentifier generated using flatten_dict.
Maintains the type of the orginal object in dct and tries to convert set_to
to that type. | [
"Sets",
"dictionary",
"item",
"identified",
"by",
"name_string",
"to",
"set_to",
"."
] | e2565aef7ee16ee06523de975e8aa41aca14e3b2 | https://github.com/shreyaspotnis/rampage/blob/e2565aef7ee16ee06523de975e8aa41aca14e3b2/rampage/queuer.py#L89-L102 |
241,397 | bitlabstudio/django-localized-names | localized_names/templatetags/localized_names_tags.py | get_name | def get_name(obj, setting_name='LONG_NAME_FORMAT'):
"""
Returns the correct order of the name according to the current language.
"""
nickname = obj.get_nickname()
romanized_first_name = obj.get_romanized_first_name()
romanized_last_name = obj.get_romanized_last_name()
non_romanized_first_na... | python | def get_name(obj, setting_name='LONG_NAME_FORMAT'):
"""
Returns the correct order of the name according to the current language.
"""
nickname = obj.get_nickname()
romanized_first_name = obj.get_romanized_first_name()
romanized_last_name = obj.get_romanized_last_name()
non_romanized_first_na... | [
"def",
"get_name",
"(",
"obj",
",",
"setting_name",
"=",
"'LONG_NAME_FORMAT'",
")",
":",
"nickname",
"=",
"obj",
".",
"get_nickname",
"(",
")",
"romanized_first_name",
"=",
"obj",
".",
"get_romanized_first_name",
"(",
")",
"romanized_last_name",
"=",
"obj",
".",... | Returns the correct order of the name according to the current language. | [
"Returns",
"the",
"correct",
"order",
"of",
"the",
"name",
"according",
"to",
"the",
"current",
"language",
"."
] | d2a67fd256f6bf61f0e17b5d77aac1ec7ccfa0cb | https://github.com/bitlabstudio/django-localized-names/blob/d2a67fd256f6bf61f0e17b5d77aac1ec7ccfa0cb/localized_names/templatetags/localized_names_tags.py#L11-L65 |
241,398 | Vito2015/pyextend | pyextend/core/wrappers/timethis.py | timethis | def timethis(func):
"""A wrapper use for timeit."""
func_module, func_name = func.__module__, func.__name__
@functools.wraps(func)
def wrapper(*args, **kwargs):
start = _time_perf_counter()
r = func(*args, **kwargs)
end = _time_perf_counter()
print('timethis : <{}.{}> : ... | python | def timethis(func):
"""A wrapper use for timeit."""
func_module, func_name = func.__module__, func.__name__
@functools.wraps(func)
def wrapper(*args, **kwargs):
start = _time_perf_counter()
r = func(*args, **kwargs)
end = _time_perf_counter()
print('timethis : <{}.{}> : ... | [
"def",
"timethis",
"(",
"func",
")",
":",
"func_module",
",",
"func_name",
"=",
"func",
".",
"__module__",
",",
"func",
".",
"__name__",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")... | A wrapper use for timeit. | [
"A",
"wrapper",
"use",
"for",
"timeit",
"."
] | 36861dfe1087e437ffe9b5a1da9345c85b4fa4a1 | https://github.com/Vito2015/pyextend/blob/36861dfe1087e437ffe9b5a1da9345c85b4fa4a1/pyextend/core/wrappers/timethis.py#L23-L34 |
241,399 | biocore/mustached-octo-ironman | moi/group.py | create_info | def create_info(name, info_type, url=None, parent=None, id=None,
context=ctx_default, store=False):
"""Return a group object"""
id = str(uuid4()) if id is None else id
pubsub = _pubsub_key(id)
info = {'id': id,
'type': info_type,
'pubsub': pubsub,
'ur... | python | def create_info(name, info_type, url=None, parent=None, id=None,
context=ctx_default, store=False):
"""Return a group object"""
id = str(uuid4()) if id is None else id
pubsub = _pubsub_key(id)
info = {'id': id,
'type': info_type,
'pubsub': pubsub,
'ur... | [
"def",
"create_info",
"(",
"name",
",",
"info_type",
",",
"url",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"id",
"=",
"None",
",",
"context",
"=",
"ctx_default",
",",
"store",
"=",
"False",
")",
":",
"id",
"=",
"str",
"(",
"uuid4",
"(",
")",
... | Return a group object | [
"Return",
"a",
"group",
"object"
] | 54128d8fdff327e1b7ffd9bb77bf38c3df9526d7 | https://github.com/biocore/mustached-octo-ironman/blob/54128d8fdff327e1b7ffd9bb77bf38c3df9526d7/moi/group.py#L351-L376 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.