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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
39,700 | sci-bots/dmf-device-ui | dmf_device_ui/canvas.py | DmfDeviceCanvas.draw_route | def draw_route(self, df_route, cr, color=None, line_width=None):
'''
Draw a line between electrodes listed in a route.
Arguments
---------
- `df_route`:
* A `pandas.DataFrame` containing a column named `electrode_i`.
* For each row, `electrode_i` corr... | python | def draw_route(self, df_route, cr, color=None, line_width=None):
'''
Draw a line between electrodes listed in a route.
Arguments
---------
- `df_route`:
* A `pandas.DataFrame` containing a column named `electrode_i`.
* For each row, `electrode_i` corr... | [
"def",
"draw_route",
"(",
"self",
",",
"df_route",
",",
"cr",
",",
"color",
"=",
"None",
",",
"line_width",
"=",
"None",
")",
":",
"df_route_centers",
"=",
"(",
"self",
".",
"canvas",
".",
"df_shape_centers",
".",
"ix",
"[",
"df_route",
".",
"electrode_i... | Draw a line between electrodes listed in a route.
Arguments
---------
- `df_route`:
* A `pandas.DataFrame` containing a column named `electrode_i`.
* For each row, `electrode_i` corresponds to the integer index of
the corresponding electrode.
... | [
"Draw",
"a",
"line",
"between",
"electrodes",
"listed",
"in",
"a",
"route",
"."
] | 05b480683c9fa43f91ce5a58de2fa90cdf363fc8 | https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L846-L899 |
39,701 | sci-bots/dmf-device-ui | dmf_device_ui/canvas.py | DmfDeviceCanvas.on_widget__button_press_event | def on_widget__button_press_event(self, widget, event):
'''
Called when any mouse button is pressed.
.. versionchanged:: 0.11
Do not trigger `route-electrode-added` event if `ALT` key is
pressed.
'''
if self.mode == 'register_video' and event.button == 1... | python | def on_widget__button_press_event(self, widget, event):
'''
Called when any mouse button is pressed.
.. versionchanged:: 0.11
Do not trigger `route-electrode-added` event if `ALT` key is
pressed.
'''
if self.mode == 'register_video' and event.button == 1... | [
"def",
"on_widget__button_press_event",
"(",
"self",
",",
"widget",
",",
"event",
")",
":",
"if",
"self",
".",
"mode",
"==",
"'register_video'",
"and",
"event",
".",
"button",
"==",
"1",
":",
"self",
".",
"start_event",
"=",
"event",
".",
"copy",
"(",
")... | Called when any mouse button is pressed.
.. versionchanged:: 0.11
Do not trigger `route-electrode-added` event if `ALT` key is
pressed. | [
"Called",
"when",
"any",
"mouse",
"button",
"is",
"pressed",
"."
] | 05b480683c9fa43f91ce5a58de2fa90cdf363fc8 | https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L920-L944 |
39,702 | sci-bots/dmf-device-ui | dmf_device_ui/canvas.py | DmfDeviceCanvas.on_widget__button_release_event | def on_widget__button_release_event(self, widget, event):
'''
Called when any mouse button is released.
.. versionchanged:: 0.11.3
Always reset pending route, regardless of whether a route was
completed. This includes a) removing temporary routes from routes
... | python | def on_widget__button_release_event(self, widget, event):
'''
Called when any mouse button is released.
.. versionchanged:: 0.11.3
Always reset pending route, regardless of whether a route was
completed. This includes a) removing temporary routes from routes
... | [
"def",
"on_widget__button_release_event",
"(",
"self",
",",
"widget",
",",
"event",
")",
":",
"event",
"=",
"event",
".",
"copy",
"(",
")",
"if",
"self",
".",
"mode",
"==",
"'register_video'",
"and",
"(",
"event",
".",
"button",
"==",
"1",
"and",
"self",... | Called when any mouse button is released.
.. versionchanged:: 0.11.3
Always reset pending route, regardless of whether a route was
completed. This includes a) removing temporary routes from routes
table, and b) resetting the state of the current route electrode
... | [
"Called",
"when",
"any",
"mouse",
"button",
"is",
"released",
"."
] | 05b480683c9fa43f91ce5a58de2fa90cdf363fc8 | https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L946-L1002 |
39,703 | sci-bots/dmf-device-ui | dmf_device_ui/canvas.py | DmfDeviceCanvas.on_widget__motion_notify_event | def on_widget__motion_notify_event(self, widget, event):
'''
Called when mouse pointer is moved within drawing area.
.. versionchanged:: 0.11
Do not trigger `route-electrode-added` event if `ALT` key is
pressed.
'''
if self.canvas is None:
# ... | python | def on_widget__motion_notify_event(self, widget, event):
'''
Called when mouse pointer is moved within drawing area.
.. versionchanged:: 0.11
Do not trigger `route-electrode-added` event if `ALT` key is
pressed.
'''
if self.canvas is None:
# ... | [
"def",
"on_widget__motion_notify_event",
"(",
"self",
",",
"widget",
",",
"event",
")",
":",
"if",
"self",
".",
"canvas",
"is",
"None",
":",
"# Canvas has not been initialized. Nothing to do.",
"return",
"elif",
"event",
".",
"is_hint",
":",
"pointer",
"=",
"even... | Called when mouse pointer is moved within drawing area.
.. versionchanged:: 0.11
Do not trigger `route-electrode-added` event if `ALT` key is
pressed. | [
"Called",
"when",
"mouse",
"pointer",
"is",
"moved",
"within",
"drawing",
"area",
"."
] | 05b480683c9fa43f91ce5a58de2fa90cdf363fc8 | https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L1110-L1154 |
39,704 | sci-bots/dmf-device-ui | dmf_device_ui/canvas.py | DmfDeviceCanvas.register_electrode_command | def register_electrode_command(self, command, title=None, group=None):
'''
Register electrode command.
Add electrode plugin command to context menu.
'''
commands = self.electrode_commands.setdefault(group, OrderedDict())
if title is None:
title = (command[:1]... | python | def register_electrode_command(self, command, title=None, group=None):
'''
Register electrode command.
Add electrode plugin command to context menu.
'''
commands = self.electrode_commands.setdefault(group, OrderedDict())
if title is None:
title = (command[:1]... | [
"def",
"register_electrode_command",
"(",
"self",
",",
"command",
",",
"title",
"=",
"None",
",",
"group",
"=",
"None",
")",
":",
"commands",
"=",
"self",
".",
"electrode_commands",
".",
"setdefault",
"(",
"group",
",",
"OrderedDict",
"(",
")",
")",
"if",
... | Register electrode command.
Add electrode plugin command to context menu. | [
"Register",
"electrode",
"command",
"."
] | 05b480683c9fa43f91ce5a58de2fa90cdf363fc8 | https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L1236-L1245 |
39,705 | sci-bots/dmf-device-ui | dmf_device_ui/canvas.py | DmfDeviceCanvas.register_route_command | def register_route_command(self, command, title=None, group=None):
'''
Register route command.
Add route plugin command to context menu.
'''
commands = self.route_commands.setdefault(group, OrderedDict())
if title is None:
title = (command[:1].upper() + comma... | python | def register_route_command(self, command, title=None, group=None):
'''
Register route command.
Add route plugin command to context menu.
'''
commands = self.route_commands.setdefault(group, OrderedDict())
if title is None:
title = (command[:1].upper() + comma... | [
"def",
"register_route_command",
"(",
"self",
",",
"command",
",",
"title",
"=",
"None",
",",
"group",
"=",
"None",
")",
":",
"commands",
"=",
"self",
".",
"route_commands",
".",
"setdefault",
"(",
"group",
",",
"OrderedDict",
"(",
")",
")",
"if",
"title... | Register route command.
Add route plugin command to context menu. | [
"Register",
"route",
"command",
"."
] | 05b480683c9fa43f91ce5a58de2fa90cdf363fc8 | https://github.com/sci-bots/dmf-device-ui/blob/05b480683c9fa43f91ce5a58de2fa90cdf363fc8/dmf_device_ui/canvas.py#L1249-L1258 |
39,706 | Julian/Minion | minion/request.py | Responder.after | def after(self):
"""
Return a deferred that will fire after the request is finished.
Returns:
Deferred: a new deferred that will fire appropriately
"""
d = Deferred()
self._after_deferreds.append(d)
return d.chain | python | def after(self):
"""
Return a deferred that will fire after the request is finished.
Returns:
Deferred: a new deferred that will fire appropriately
"""
d = Deferred()
self._after_deferreds.append(d)
return d.chain | [
"def",
"after",
"(",
"self",
")",
":",
"d",
"=",
"Deferred",
"(",
")",
"self",
".",
"_after_deferreds",
".",
"append",
"(",
"d",
")",
"return",
"d",
".",
"chain"
] | Return a deferred that will fire after the request is finished.
Returns:
Deferred: a new deferred that will fire appropriately | [
"Return",
"a",
"deferred",
"that",
"will",
"fire",
"after",
"the",
"request",
"is",
"finished",
"."
] | 518d06f9ffd38dcacc0de4d94e72d1f8452157a8 | https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/minion/request.py#L29-L41 |
39,707 | Julian/Minion | minion/request.py | Manager.after_response | def after_response(self, request, fn, *args, **kwargs):
"""
Call the given callable after the given request has its response.
Arguments:
request:
the request to piggyback
fn (callable):
a callable that takes at least two arguments, the... | python | def after_response(self, request, fn, *args, **kwargs):
"""
Call the given callable after the given request has its response.
Arguments:
request:
the request to piggyback
fn (callable):
a callable that takes at least two arguments, the... | [
"def",
"after_response",
"(",
"self",
",",
"request",
",",
"fn",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_requests",
"[",
"id",
"(",
"request",
")",
"]",
"[",
"\"callbacks\"",
"]",
".",
"append",
"(",
"(",
"fn",
",",
"a... | Call the given callable after the given request has its response.
Arguments:
request:
the request to piggyback
fn (callable):
a callable that takes at least two arguments, the request and
the response (in that order), along with any ad... | [
"Call",
"the",
"given",
"callable",
"after",
"the",
"given",
"request",
"has",
"its",
"response",
"."
] | 518d06f9ffd38dcacc0de4d94e72d1f8452157a8 | https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/minion/request.py#L57-L76 |
39,708 | Titan-C/slaveparticles | examples/memoires.py | plot_degbandshalffill | def plot_degbandshalffill():
"""Plot of Quasiparticle weight for degenerate
half-filled bands, showing the Mott transition"""
ulim = [3.45, 5.15, 6.85, 8.55]
bands = range(1, 5)
for band, u_int in zip(bands, ulim):
name = 'Z_half_'+str(band)+'band'
dop = [0.5]
data = ssplt... | python | def plot_degbandshalffill():
"""Plot of Quasiparticle weight for degenerate
half-filled bands, showing the Mott transition"""
ulim = [3.45, 5.15, 6.85, 8.55]
bands = range(1, 5)
for band, u_int in zip(bands, ulim):
name = 'Z_half_'+str(band)+'band'
dop = [0.5]
data = ssplt... | [
"def",
"plot_degbandshalffill",
"(",
")",
":",
"ulim",
"=",
"[",
"3.45",
",",
"5.15",
",",
"6.85",
",",
"8.55",
"]",
"bands",
"=",
"range",
"(",
"1",
",",
"5",
")",
"for",
"band",
",",
"u_int",
"in",
"zip",
"(",
"bands",
",",
"ulim",
")",
":",
... | Plot of Quasiparticle weight for degenerate
half-filled bands, showing the Mott transition | [
"Plot",
"of",
"Quasiparticle",
"weight",
"for",
"degenerate",
"half",
"-",
"filled",
"bands",
"showing",
"the",
"Mott",
"transition"
] | e4c2f5afb1a7b195517ef2f1b5cc758965036aab | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/examples/memoires.py#L14-L25 |
39,709 | Titan-C/slaveparticles | examples/memoires.py | plot_dop | def plot_dop(bands, int_max, dop, hund_cu, name):
"""Plot of Quasiparticle weight for N degenerate bands
under selected doping shows transition only at half-fill
the rest are metallic states"""
data = ssplt.calc_z(bands, dop, np.arange(0, int_max, 0.1), hund_cu, name)
ssplt.plot_curves_z(data,... | python | def plot_dop(bands, int_max, dop, hund_cu, name):
"""Plot of Quasiparticle weight for N degenerate bands
under selected doping shows transition only at half-fill
the rest are metallic states"""
data = ssplt.calc_z(bands, dop, np.arange(0, int_max, 0.1), hund_cu, name)
ssplt.plot_curves_z(data,... | [
"def",
"plot_dop",
"(",
"bands",
",",
"int_max",
",",
"dop",
",",
"hund_cu",
",",
"name",
")",
":",
"data",
"=",
"ssplt",
".",
"calc_z",
"(",
"bands",
",",
"dop",
",",
"np",
".",
"arange",
"(",
"0",
",",
"int_max",
",",
"0.1",
")",
",",
"hund_cu"... | Plot of Quasiparticle weight for N degenerate bands
under selected doping shows transition only at half-fill
the rest are metallic states | [
"Plot",
"of",
"Quasiparticle",
"weight",
"for",
"N",
"degenerate",
"bands",
"under",
"selected",
"doping",
"shows",
"transition",
"only",
"at",
"half",
"-",
"fill",
"the",
"rest",
"are",
"metallic",
"states"
] | e4c2f5afb1a7b195517ef2f1b5cc758965036aab | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/examples/memoires.py#L28-L33 |
39,710 | Titan-C/slaveparticles | examples/memoires.py | plot_dop_phase | def plot_dop_phase(bands, int_max, hund_cu):
"""Phase plot of Quasiparticle weight for N degenerate bands
under doping shows transition only at interger filling
the rest are metallic states"""
name = 'Z_dop_phase_'+str(bands)+'bands_U'+str(int_max)+'J'+str(hund_cu)
dop = np.sort(np.hstack((np.... | python | def plot_dop_phase(bands, int_max, hund_cu):
"""Phase plot of Quasiparticle weight for N degenerate bands
under doping shows transition only at interger filling
the rest are metallic states"""
name = 'Z_dop_phase_'+str(bands)+'bands_U'+str(int_max)+'J'+str(hund_cu)
dop = np.sort(np.hstack((np.... | [
"def",
"plot_dop_phase",
"(",
"bands",
",",
"int_max",
",",
"hund_cu",
")",
":",
"name",
"=",
"'Z_dop_phase_'",
"+",
"str",
"(",
"bands",
")",
"+",
"'bands_U'",
"+",
"str",
"(",
"int_max",
")",
"+",
"'J'",
"+",
"str",
"(",
"hund_cu",
")",
"dop",
"=",... | Phase plot of Quasiparticle weight for N degenerate bands
under doping shows transition only at interger filling
the rest are metallic states | [
"Phase",
"plot",
"of",
"Quasiparticle",
"weight",
"for",
"N",
"degenerate",
"bands",
"under",
"doping",
"shows",
"transition",
"only",
"at",
"interger",
"filling",
"the",
"rest",
"are",
"metallic",
"states"
] | e4c2f5afb1a7b195517ef2f1b5cc758965036aab | https://github.com/Titan-C/slaveparticles/blob/e4c2f5afb1a7b195517ef2f1b5cc758965036aab/examples/memoires.py#L36-L46 |
39,711 | objectrocket/python-client | objectrocket/bases.py | Extensible._register_extensions | def _register_extensions(self, namespace):
"""Register any extensions under the given namespace."""
# Register any extension classes for this class.
extmanager = ExtensionManager(
'extensions.classes.{}'.format(namespace),
propagate_map_exceptions=True
)
... | python | def _register_extensions(self, namespace):
"""Register any extensions under the given namespace."""
# Register any extension classes for this class.
extmanager = ExtensionManager(
'extensions.classes.{}'.format(namespace),
propagate_map_exceptions=True
)
... | [
"def",
"_register_extensions",
"(",
"self",
",",
"namespace",
")",
":",
"# Register any extension classes for this class.",
"extmanager",
"=",
"ExtensionManager",
"(",
"'extensions.classes.{}'",
".",
"format",
"(",
"namespace",
")",
",",
"propagate_map_exceptions",
"=",
"... | Register any extensions under the given namespace. | [
"Register",
"any",
"extensions",
"under",
"the",
"given",
"namespace",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/bases.py#L294-L312 |
39,712 | objectrocket/python-client | objectrocket/bases.py | InstanceAclsInterface.acls | def acls(self):
"""The instance bound ACLs operations layer."""
if self._acls is None:
self._acls = InstanceAcls(instance=self)
return self._acls | python | def acls(self):
"""The instance bound ACLs operations layer."""
if self._acls is None:
self._acls = InstanceAcls(instance=self)
return self._acls | [
"def",
"acls",
"(",
"self",
")",
":",
"if",
"self",
".",
"_acls",
"is",
"None",
":",
"self",
".",
"_acls",
"=",
"InstanceAcls",
"(",
"instance",
"=",
"self",
")",
"return",
"self",
".",
"_acls"
] | The instance bound ACLs operations layer. | [
"The",
"instance",
"bound",
"ACLs",
"operations",
"layer",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/bases.py#L324-L328 |
39,713 | objectrocket/python-client | objectrocket/bases.py | InstanceAcls.all | def all(self):
"""Get all ACLs for this instance."""
return self._instance._client.acls.all(self._instance.name) | python | def all(self):
"""Get all ACLs for this instance."""
return self._instance._client.acls.all(self._instance.name) | [
"def",
"all",
"(",
"self",
")",
":",
"return",
"self",
".",
"_instance",
".",
"_client",
".",
"acls",
".",
"all",
"(",
"self",
".",
"_instance",
".",
"name",
")"
] | Get all ACLs for this instance. | [
"Get",
"all",
"ACLs",
"for",
"this",
"instance",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/bases.py#L337-L339 |
39,714 | objectrocket/python-client | objectrocket/bases.py | InstanceAcls.create | def create(self, cidr_mask, description, **kwargs):
"""Create an ACL for this instance.
See :py:meth:`Acls.create` for call signature.
"""
return self._instance._client.acls.create(
self._instance.name,
cidr_mask,
description,
**kwargs
... | python | def create(self, cidr_mask, description, **kwargs):
"""Create an ACL for this instance.
See :py:meth:`Acls.create` for call signature.
"""
return self._instance._client.acls.create(
self._instance.name,
cidr_mask,
description,
**kwargs
... | [
"def",
"create",
"(",
"self",
",",
"cidr_mask",
",",
"description",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_instance",
".",
"_client",
".",
"acls",
".",
"create",
"(",
"self",
".",
"_instance",
".",
"name",
",",
"cidr_mask",
",",
... | Create an ACL for this instance.
See :py:meth:`Acls.create` for call signature. | [
"Create",
"an",
"ACL",
"for",
"this",
"instance",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/bases.py#L341-L351 |
39,715 | objectrocket/python-client | objectrocket/bases.py | InstanceAcls.get | def get(self, acl):
"""Get the ACL specified by ID belonging to this instance.
See :py:meth:`Acls.get` for call signature.
"""
return self._instance._client.acls.get(self._instance.name, acl) | python | def get(self, acl):
"""Get the ACL specified by ID belonging to this instance.
See :py:meth:`Acls.get` for call signature.
"""
return self._instance._client.acls.get(self._instance.name, acl) | [
"def",
"get",
"(",
"self",
",",
"acl",
")",
":",
"return",
"self",
".",
"_instance",
".",
"_client",
".",
"acls",
".",
"get",
"(",
"self",
".",
"_instance",
".",
"name",
",",
"acl",
")"
] | Get the ACL specified by ID belonging to this instance.
See :py:meth:`Acls.get` for call signature. | [
"Get",
"the",
"ACL",
"specified",
"by",
"ID",
"belonging",
"to",
"this",
"instance",
"."
] | a65868c7511ff49a5fbe304e53bf592b7fc6d5ef | https://github.com/objectrocket/python-client/blob/a65868c7511ff49a5fbe304e53bf592b7fc6d5ef/objectrocket/bases.py#L353-L358 |
39,716 | mixer/beam-interactive-python | beam_interactive/proto/varint.py | _VarintEncoder | def _VarintEncoder():
"""Return an encoder for a basic varint value."""
local_chr = chr
def EncodeVarint(write, value):
bits = value & 0x7f
value >>= 7
while value:
write(0x80|bits)
bits = value & 0x7f
value >>= 7
return write(bits)
return EncodeVarint | python | def _VarintEncoder():
"""Return an encoder for a basic varint value."""
local_chr = chr
def EncodeVarint(write, value):
bits = value & 0x7f
value >>= 7
while value:
write(0x80|bits)
bits = value & 0x7f
value >>= 7
return write(bits)
return EncodeVarint | [
"def",
"_VarintEncoder",
"(",
")",
":",
"local_chr",
"=",
"chr",
"def",
"EncodeVarint",
"(",
"write",
",",
"value",
")",
":",
"bits",
"=",
"value",
"&",
"0x7f",
"value",
">>=",
"7",
"while",
"value",
":",
"write",
"(",
"0x80",
"|",
"bits",
")",
"bits... | Return an encoder for a basic varint value. | [
"Return",
"an",
"encoder",
"for",
"a",
"basic",
"varint",
"value",
"."
] | e035bc45515dea9315b77648a24b5ae8685aa5cf | https://github.com/mixer/beam-interactive-python/blob/e035bc45515dea9315b77648a24b5ae8685aa5cf/beam_interactive/proto/varint.py#L123-L136 |
39,717 | mixer/beam-interactive-python | beam_interactive/proto/varint.py | _SignedVarintEncoder | def _SignedVarintEncoder():
"""Return an encoder for a basic signed varint value."""
local_chr = chr
def EncodeSignedVarint(write, value):
if value < 0:
value += (1 << 64)
bits = value & 0x7f
value >>= 7
while value:
write(0x80|bits)
bits = value & 0x7f
value >>= 7
ret... | python | def _SignedVarintEncoder():
"""Return an encoder for a basic signed varint value."""
local_chr = chr
def EncodeSignedVarint(write, value):
if value < 0:
value += (1 << 64)
bits = value & 0x7f
value >>= 7
while value:
write(0x80|bits)
bits = value & 0x7f
value >>= 7
ret... | [
"def",
"_SignedVarintEncoder",
"(",
")",
":",
"local_chr",
"=",
"chr",
"def",
"EncodeSignedVarint",
"(",
"write",
",",
"value",
")",
":",
"if",
"value",
"<",
"0",
":",
"value",
"+=",
"(",
"1",
"<<",
"64",
")",
"bits",
"=",
"value",
"&",
"0x7f",
"valu... | Return an encoder for a basic signed varint value. | [
"Return",
"an",
"encoder",
"for",
"a",
"basic",
"signed",
"varint",
"value",
"."
] | e035bc45515dea9315b77648a24b5ae8685aa5cf | https://github.com/mixer/beam-interactive-python/blob/e035bc45515dea9315b77648a24b5ae8685aa5cf/beam_interactive/proto/varint.py#L139-L154 |
39,718 | Data-Mechanics/geoql | geoql/geoql.py | match | def match(value, query):
"""
Determine whether a value satisfies a query.
"""
if type(query) in [str, int, float, type(None)]:
return value == query
elif type(query) == dict and len(query.keys()) == 1:
for op in query:
if op == "$eq": return value == query[op]
... | python | def match(value, query):
"""
Determine whether a value satisfies a query.
"""
if type(query) in [str, int, float, type(None)]:
return value == query
elif type(query) == dict and len(query.keys()) == 1:
for op in query:
if op == "$eq": return value == query[op]
... | [
"def",
"match",
"(",
"value",
",",
"query",
")",
":",
"if",
"type",
"(",
"query",
")",
"in",
"[",
"str",
",",
"int",
",",
"float",
",",
"type",
"(",
"None",
")",
"]",
":",
"return",
"value",
"==",
"query",
"elif",
"type",
"(",
"query",
")",
"==... | Determine whether a value satisfies a query. | [
"Determine",
"whether",
"a",
"value",
"satisfies",
"a",
"query",
"."
] | c6184e1734c76a259855d6282e919614839a767e | https://github.com/Data-Mechanics/geoql/blob/c6184e1734c76a259855d6282e919614839a767e/geoql/geoql.py#L31-L49 |
39,719 | Data-Mechanics/geoql | geoql/geoql.py | features_tags_parse_str_to_dict | def features_tags_parse_str_to_dict(obj):
"""
Parse tag strings of all features in the collection into a Python
dictionary, if possible.
"""
features = obj['features']
for i in tqdm(range(len(features))):
tags = features[i]['properties'].get('tags')
if tags is not None:
... | python | def features_tags_parse_str_to_dict(obj):
"""
Parse tag strings of all features in the collection into a Python
dictionary, if possible.
"""
features = obj['features']
for i in tqdm(range(len(features))):
tags = features[i]['properties'].get('tags')
if tags is not None:
... | [
"def",
"features_tags_parse_str_to_dict",
"(",
"obj",
")",
":",
"features",
"=",
"obj",
"[",
"'features'",
"]",
"for",
"i",
"in",
"tqdm",
"(",
"range",
"(",
"len",
"(",
"features",
")",
")",
")",
":",
"tags",
"=",
"features",
"[",
"i",
"]",
"[",
"'pr... | Parse tag strings of all features in the collection into a Python
dictionary, if possible. | [
"Parse",
"tag",
"strings",
"of",
"all",
"features",
"in",
"the",
"collection",
"into",
"a",
"Python",
"dictionary",
"if",
"possible",
"."
] | c6184e1734c76a259855d6282e919614839a767e | https://github.com/Data-Mechanics/geoql/blob/c6184e1734c76a259855d6282e919614839a767e/geoql/geoql.py#L63-L83 |
39,720 | Data-Mechanics/geoql | geoql/geoql.py | features_keep_by_property | def features_keep_by_property(obj, query):
"""
Filter all features in a collection by retaining only those that
satisfy the provided query.
"""
features_keep = []
for feature in tqdm(obj['features']):
if all([match(feature['properties'].get(prop), qry) for (prop, qry) in query.items()]):... | python | def features_keep_by_property(obj, query):
"""
Filter all features in a collection by retaining only those that
satisfy the provided query.
"""
features_keep = []
for feature in tqdm(obj['features']):
if all([match(feature['properties'].get(prop), qry) for (prop, qry) in query.items()]):... | [
"def",
"features_keep_by_property",
"(",
"obj",
",",
"query",
")",
":",
"features_keep",
"=",
"[",
"]",
"for",
"feature",
"in",
"tqdm",
"(",
"obj",
"[",
"'features'",
"]",
")",
":",
"if",
"all",
"(",
"[",
"match",
"(",
"feature",
"[",
"'properties'",
"... | Filter all features in a collection by retaining only those that
satisfy the provided query. | [
"Filter",
"all",
"features",
"in",
"a",
"collection",
"by",
"retaining",
"only",
"those",
"that",
"satisfy",
"the",
"provided",
"query",
"."
] | c6184e1734c76a259855d6282e919614839a767e | https://github.com/Data-Mechanics/geoql/blob/c6184e1734c76a259855d6282e919614839a767e/geoql/geoql.py#L85-L95 |
39,721 | Data-Mechanics/geoql | geoql/geoql.py | features_keep_within_radius | def features_keep_within_radius(obj, center, radius, units):
"""
Filter all features in a collection by retaining only those that
fall within the specified radius.
"""
features_keep = []
for feature in tqdm(obj['features']):
if all([getattr(geopy.distance.vincenty((lat,lon), center), uni... | python | def features_keep_within_radius(obj, center, radius, units):
"""
Filter all features in a collection by retaining only those that
fall within the specified radius.
"""
features_keep = []
for feature in tqdm(obj['features']):
if all([getattr(geopy.distance.vincenty((lat,lon), center), uni... | [
"def",
"features_keep_within_radius",
"(",
"obj",
",",
"center",
",",
"radius",
",",
"units",
")",
":",
"features_keep",
"=",
"[",
"]",
"for",
"feature",
"in",
"tqdm",
"(",
"obj",
"[",
"'features'",
"]",
")",
":",
"if",
"all",
"(",
"[",
"getattr",
"(",... | Filter all features in a collection by retaining only those that
fall within the specified radius. | [
"Filter",
"all",
"features",
"in",
"a",
"collection",
"by",
"retaining",
"only",
"those",
"that",
"fall",
"within",
"the",
"specified",
"radius",
"."
] | c6184e1734c76a259855d6282e919614839a767e | https://github.com/Data-Mechanics/geoql/blob/c6184e1734c76a259855d6282e919614839a767e/geoql/geoql.py#L97-L107 |
39,722 | Data-Mechanics/geoql | geoql/geoql.py | features_keep_using_features | def features_keep_using_features(obj, bounds):
"""
Filter all features in a collection by retaining only those that
fall within the features in the second collection.
"""
# Build an R-tree index of bound features and their shapes.
bounds_shapes = [
(feature, shapely.geometry.shape(featur... | python | def features_keep_using_features(obj, bounds):
"""
Filter all features in a collection by retaining only those that
fall within the features in the second collection.
"""
# Build an R-tree index of bound features and their shapes.
bounds_shapes = [
(feature, shapely.geometry.shape(featur... | [
"def",
"features_keep_using_features",
"(",
"obj",
",",
"bounds",
")",
":",
"# Build an R-tree index of bound features and their shapes.",
"bounds_shapes",
"=",
"[",
"(",
"feature",
",",
"shapely",
".",
"geometry",
".",
"shape",
"(",
"feature",
"[",
"'geometry'",
"]",... | Filter all features in a collection by retaining only those that
fall within the features in the second collection. | [
"Filter",
"all",
"features",
"in",
"a",
"collection",
"by",
"retaining",
"only",
"those",
"that",
"fall",
"within",
"the",
"features",
"in",
"the",
"second",
"collection",
"."
] | c6184e1734c76a259855d6282e919614839a767e | https://github.com/Data-Mechanics/geoql/blob/c6184e1734c76a259855d6282e919614839a767e/geoql/geoql.py#L109-L138 |
39,723 | Data-Mechanics/geoql | geoql/geoql.py | features_node_edge_graph | def features_node_edge_graph(obj):
"""
Transform the features into a more graph-like structure by
appropriately splitting LineString features into two-point
"edges" that connect Point "nodes".
"""
points = {}
features = obj['features']
for feature in tqdm(obj['features']):
for (l... | python | def features_node_edge_graph(obj):
"""
Transform the features into a more graph-like structure by
appropriately splitting LineString features into two-point
"edges" that connect Point "nodes".
"""
points = {}
features = obj['features']
for feature in tqdm(obj['features']):
for (l... | [
"def",
"features_node_edge_graph",
"(",
"obj",
")",
":",
"points",
"=",
"{",
"}",
"features",
"=",
"obj",
"[",
"'features'",
"]",
"for",
"feature",
"in",
"tqdm",
"(",
"obj",
"[",
"'features'",
"]",
")",
":",
"for",
"(",
"lon",
",",
"lat",
")",
"in",
... | Transform the features into a more graph-like structure by
appropriately splitting LineString features into two-point
"edges" that connect Point "nodes". | [
"Transform",
"the",
"features",
"into",
"a",
"more",
"graph",
"-",
"like",
"structure",
"by",
"appropriately",
"splitting",
"LineString",
"features",
"into",
"two",
"-",
"point",
"edges",
"that",
"connect",
"Point",
"nodes",
"."
] | c6184e1734c76a259855d6282e919614839a767e | https://github.com/Data-Mechanics/geoql/blob/c6184e1734c76a259855d6282e919614839a767e/geoql/geoql.py#L147-L179 |
39,724 | trevisanj/a99 | a99/litedb.py | get_table_info | def get_table_info(conn, tablename):
"""Returns TableInfo object"""
r = conn.execute("pragma table_info('{}')".format(tablename))
ret = TableInfo(((row["name"], row) for row in r))
return ret | python | def get_table_info(conn, tablename):
"""Returns TableInfo object"""
r = conn.execute("pragma table_info('{}')".format(tablename))
ret = TableInfo(((row["name"], row) for row in r))
return ret | [
"def",
"get_table_info",
"(",
"conn",
",",
"tablename",
")",
":",
"r",
"=",
"conn",
".",
"execute",
"(",
"\"pragma table_info('{}')\"",
".",
"format",
"(",
"tablename",
")",
")",
"ret",
"=",
"TableInfo",
"(",
"(",
"(",
"row",
"[",
"\"name\"",
"]",
",",
... | Returns TableInfo object | [
"Returns",
"TableInfo",
"object"
] | 193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539 | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/litedb.py#L116-L120 |
39,725 | CodyKochmann/generators | generators/early_warning.py | early_warning | def early_warning(iterable, name='this generator'):
''' This function logs an early warning that the generator is empty.
This is handy for times when you're manually playing with generators and
would appreciate the console warning you ahead of time that your generator
is now empty, instead of being sur... | python | def early_warning(iterable, name='this generator'):
''' This function logs an early warning that the generator is empty.
This is handy for times when you're manually playing with generators and
would appreciate the console warning you ahead of time that your generator
is now empty, instead of being sur... | [
"def",
"early_warning",
"(",
"iterable",
",",
"name",
"=",
"'this generator'",
")",
":",
"nxt",
"=",
"None",
"prev",
"=",
"next",
"(",
"iterable",
")",
"while",
"1",
":",
"try",
":",
"nxt",
"=",
"next",
"(",
"iterable",
")",
"except",
":",
"warning",
... | This function logs an early warning that the generator is empty.
This is handy for times when you're manually playing with generators and
would appreciate the console warning you ahead of time that your generator
is now empty, instead of being surprised with a StopIteration or
GeneratorExit exception w... | [
"This",
"function",
"logs",
"an",
"early",
"warning",
"that",
"the",
"generator",
"is",
"empty",
"."
] | e4ca4dd25d5023a94b0349c69d6224070cc2526f | https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/early_warning.py#L6-L25 |
39,726 | wuher/devil | example/userdb/api/resources.py | User.post | def post(self, data, request, id):
""" Create a new resource using POST """
if id:
# can't post to individual user
raise errors.MethodNotAllowed()
user = self._dict_to_model(data)
user.save()
# according to REST, return 201 and Location header
retu... | python | def post(self, data, request, id):
""" Create a new resource using POST """
if id:
# can't post to individual user
raise errors.MethodNotAllowed()
user = self._dict_to_model(data)
user.save()
# according to REST, return 201 and Location header
retu... | [
"def",
"post",
"(",
"self",
",",
"data",
",",
"request",
",",
"id",
")",
":",
"if",
"id",
":",
"# can't post to individual user",
"raise",
"errors",
".",
"MethodNotAllowed",
"(",
")",
"user",
"=",
"self",
".",
"_dict_to_model",
"(",
"data",
")",
"user",
... | Create a new resource using POST | [
"Create",
"a",
"new",
"resource",
"using",
"POST"
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/example/userdb/api/resources.py#L21-L30 |
39,727 | wuher/devil | example/userdb/api/resources.py | User.get | def get(self, request, id):
""" Get one user or all users """
if id:
return self._get_one(id)
else:
return self._get_all() | python | def get(self, request, id):
""" Get one user or all users """
if id:
return self._get_one(id)
else:
return self._get_all() | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"id",
")",
":",
"if",
"id",
":",
"return",
"self",
".",
"_get_one",
"(",
"id",
")",
"else",
":",
"return",
"self",
".",
"_get_all",
"(",
")"
] | Get one user or all users | [
"Get",
"one",
"user",
"or",
"all",
"users"
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/example/userdb/api/resources.py#L32-L37 |
39,728 | wuher/devil | example/userdb/api/resources.py | User.put | def put(self, data, request, id):
""" Update a single user. """
if not id:
# can't update the whole container
raise errors.MethodNotAllowed()
userdata = self._dict_to_model(data)
userdata.pk = id
try:
userdata.save(force_update=True)
ex... | python | def put(self, data, request, id):
""" Update a single user. """
if not id:
# can't update the whole container
raise errors.MethodNotAllowed()
userdata = self._dict_to_model(data)
userdata.pk = id
try:
userdata.save(force_update=True)
ex... | [
"def",
"put",
"(",
"self",
",",
"data",
",",
"request",
",",
"id",
")",
":",
"if",
"not",
"id",
":",
"# can't update the whole container",
"raise",
"errors",
".",
"MethodNotAllowed",
"(",
")",
"userdata",
"=",
"self",
".",
"_dict_to_model",
"(",
"data",
")... | Update a single user. | [
"Update",
"a",
"single",
"user",
"."
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/example/userdb/api/resources.py#L39-L50 |
39,729 | wuher/devil | example/userdb/api/resources.py | User.delete | def delete(self, request, id):
""" Delete a single user. """
if not id:
# can't delete the whole container
raise errors.MethodNotAllowed()
try:
models.User.objects.get(pk=id).delete()
except models.User.DoesNotExist:
# we never had it, so i... | python | def delete(self, request, id):
""" Delete a single user. """
if not id:
# can't delete the whole container
raise errors.MethodNotAllowed()
try:
models.User.objects.get(pk=id).delete()
except models.User.DoesNotExist:
# we never had it, so i... | [
"def",
"delete",
"(",
"self",
",",
"request",
",",
"id",
")",
":",
"if",
"not",
"id",
":",
"# can't delete the whole container",
"raise",
"errors",
".",
"MethodNotAllowed",
"(",
")",
"try",
":",
"models",
".",
"User",
".",
"objects",
".",
"get",
"(",
"pk... | Delete a single user. | [
"Delete",
"a",
"single",
"user",
"."
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/example/userdb/api/resources.py#L52-L61 |
39,730 | wuher/devil | example/userdb/api/resources.py | User._get_one | def _get_one(self, id):
""" Get one user from db and turn into dict """
try:
return self._to_dict(models.User.objects.get(pk=id))
except models.User.DoesNotExist:
raise errors.NotFound() | python | def _get_one(self, id):
""" Get one user from db and turn into dict """
try:
return self._to_dict(models.User.objects.get(pk=id))
except models.User.DoesNotExist:
raise errors.NotFound() | [
"def",
"_get_one",
"(",
"self",
",",
"id",
")",
":",
"try",
":",
"return",
"self",
".",
"_to_dict",
"(",
"models",
".",
"User",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"id",
")",
")",
"except",
"models",
".",
"User",
".",
"DoesNotExist",
":",
... | Get one user from db and turn into dict | [
"Get",
"one",
"user",
"from",
"db",
"and",
"turn",
"into",
"dict"
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/example/userdb/api/resources.py#L63-L68 |
39,731 | wuher/devil | example/userdb/api/resources.py | User._get_all | def _get_all(self):
""" Get all users from db and turn into list of dicts """
return [self._to_dict(row) for row in models.User.objects.all()] | python | def _get_all(self):
""" Get all users from db and turn into list of dicts """
return [self._to_dict(row) for row in models.User.objects.all()] | [
"def",
"_get_all",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"_to_dict",
"(",
"row",
")",
"for",
"row",
"in",
"models",
".",
"User",
".",
"objects",
".",
"all",
"(",
")",
"]"
] | Get all users from db and turn into list of dicts | [
"Get",
"all",
"users",
"from",
"db",
"and",
"turn",
"into",
"list",
"of",
"dicts"
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/example/userdb/api/resources.py#L70-L72 |
39,732 | wuher/devil | example/userdb/api/resources.py | User._dict_to_model | def _dict_to_model(self, data):
""" Create new user model instance based on the received data.
Note that the created user is not saved into database.
"""
try:
# we can do this because we have same fields
# in the representation and in the model:
user... | python | def _dict_to_model(self, data):
""" Create new user model instance based on the received data.
Note that the created user is not saved into database.
"""
try:
# we can do this because we have same fields
# in the representation and in the model:
user... | [
"def",
"_dict_to_model",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"# we can do this because we have same fields",
"# in the representation and in the model:",
"user",
"=",
"models",
".",
"User",
"(",
"*",
"*",
"data",
")",
"except",
"TypeError",
":",
"# clien... | Create new user model instance based on the received data.
Note that the created user is not saved into database. | [
"Create",
"new",
"user",
"model",
"instance",
"based",
"on",
"the",
"received",
"data",
"."
] | a8834d4f88d915a21754c6b96f99d0ad9123ad4d | https://github.com/wuher/devil/blob/a8834d4f88d915a21754c6b96f99d0ad9123ad4d/example/userdb/api/resources.py#L81-L95 |
39,733 | nmohoric/nypl-digital-collections | nyplcollections/nyplcollections.py | NYPLsearch.captures | def captures(self, uuid, withTitles=False):
"""Return the captures for a given uuid
optional value withTitles=yes"""
picker = lambda x: x.get('capture', [])
return self._get((uuid,), picker, withTitles='yes' if withTitles else 'no') | python | def captures(self, uuid, withTitles=False):
"""Return the captures for a given uuid
optional value withTitles=yes"""
picker = lambda x: x.get('capture', [])
return self._get((uuid,), picker, withTitles='yes' if withTitles else 'no') | [
"def",
"captures",
"(",
"self",
",",
"uuid",
",",
"withTitles",
"=",
"False",
")",
":",
"picker",
"=",
"lambda",
"x",
":",
"x",
".",
"get",
"(",
"'capture'",
",",
"[",
"]",
")",
"return",
"self",
".",
"_get",
"(",
"(",
"uuid",
",",
")",
",",
"p... | Return the captures for a given uuid
optional value withTitles=yes | [
"Return",
"the",
"captures",
"for",
"a",
"given",
"uuid",
"optional",
"value",
"withTitles",
"=",
"yes"
] | f66cd0a11e7ea2b6c3c327d2693211e2c4609231 | https://github.com/nmohoric/nypl-digital-collections/blob/f66cd0a11e7ea2b6c3c327d2693211e2c4609231/nyplcollections/nyplcollections.py#L14-L18 |
39,734 | nmohoric/nypl-digital-collections | nyplcollections/nyplcollections.py | NYPLsearch.uuid | def uuid(self, type, val):
"""Return the item-uuid for a identifier"""
picker = lambda x: x.get('uuid', x)
return self._get((type, val), picker) | python | def uuid(self, type, val):
"""Return the item-uuid for a identifier"""
picker = lambda x: x.get('uuid', x)
return self._get((type, val), picker) | [
"def",
"uuid",
"(",
"self",
",",
"type",
",",
"val",
")",
":",
"picker",
"=",
"lambda",
"x",
":",
"x",
".",
"get",
"(",
"'uuid'",
",",
"x",
")",
"return",
"self",
".",
"_get",
"(",
"(",
"type",
",",
"val",
")",
",",
"picker",
")"
] | Return the item-uuid for a identifier | [
"Return",
"the",
"item",
"-",
"uuid",
"for",
"a",
"identifier"
] | f66cd0a11e7ea2b6c3c327d2693211e2c4609231 | https://github.com/nmohoric/nypl-digital-collections/blob/f66cd0a11e7ea2b6c3c327d2693211e2c4609231/nyplcollections/nyplcollections.py#L20-L23 |
39,735 | nmohoric/nypl-digital-collections | nyplcollections/nyplcollections.py | NYPLsearch.mods | def mods(self, uuid):
"""Return a mods record for a given uuid"""
picker = lambda x: x.get('mods', {})
return self._get(('mods', uuid), picker) | python | def mods(self, uuid):
"""Return a mods record for a given uuid"""
picker = lambda x: x.get('mods', {})
return self._get(('mods', uuid), picker) | [
"def",
"mods",
"(",
"self",
",",
"uuid",
")",
":",
"picker",
"=",
"lambda",
"x",
":",
"x",
".",
"get",
"(",
"'mods'",
",",
"{",
"}",
")",
"return",
"self",
".",
"_get",
"(",
"(",
"'mods'",
",",
"uuid",
")",
",",
"picker",
")"
] | Return a mods record for a given uuid | [
"Return",
"a",
"mods",
"record",
"for",
"a",
"given",
"uuid"
] | f66cd0a11e7ea2b6c3c327d2693211e2c4609231 | https://github.com/nmohoric/nypl-digital-collections/blob/f66cd0a11e7ea2b6c3c327d2693211e2c4609231/nyplcollections/nyplcollections.py#L37-L40 |
39,736 | inveniosoftware-attic/invenio-utils | invenio_utils/date.py | get_i18n_day_name | def get_i18n_day_name(day_nb, display='short', ln=None):
"""Get the string representation of a weekday, internationalized
@param day_nb: number of weekday UNIX like.
=> 0=Sunday
@param ln: language for output
@return: the string representation of the day
"""
ln = default_ln(l... | python | def get_i18n_day_name(day_nb, display='short', ln=None):
"""Get the string representation of a weekday, internationalized
@param day_nb: number of weekday UNIX like.
=> 0=Sunday
@param ln: language for output
@return: the string representation of the day
"""
ln = default_ln(l... | [
"def",
"get_i18n_day_name",
"(",
"day_nb",
",",
"display",
"=",
"'short'",
",",
"ln",
"=",
"None",
")",
":",
"ln",
"=",
"default_ln",
"(",
"ln",
")",
"_",
"=",
"gettext_set_language",
"(",
"ln",
")",
"if",
"display",
"==",
"'short'",
":",
"days",
"=",
... | Get the string representation of a weekday, internationalized
@param day_nb: number of weekday UNIX like.
=> 0=Sunday
@param ln: language for output
@return: the string representation of the day | [
"Get",
"the",
"string",
"representation",
"of",
"a",
"weekday",
"internationalized"
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/date.py#L214-L241 |
39,737 | inveniosoftware-attic/invenio-utils | invenio_utils/date.py | get_i18n_month_name | def get_i18n_month_name(month_nb, display='short', ln=None):
"""Get a non-numeric representation of a month, internationalized.
@param month_nb: number of month, (1 based!)
=>1=jan,..,12=dec
@param ln: language for output
@return: the string representation of month
"""
ln =... | python | def get_i18n_month_name(month_nb, display='short', ln=None):
"""Get a non-numeric representation of a month, internationalized.
@param month_nb: number of month, (1 based!)
=>1=jan,..,12=dec
@param ln: language for output
@return: the string representation of month
"""
ln =... | [
"def",
"get_i18n_month_name",
"(",
"month_nb",
",",
"display",
"=",
"'short'",
",",
"ln",
"=",
"None",
")",
":",
"ln",
"=",
"default_ln",
"(",
"ln",
")",
"_",
"=",
"gettext_set_language",
"(",
"ln",
")",
"if",
"display",
"==",
"'short'",
":",
"months",
... | Get a non-numeric representation of a month, internationalized.
@param month_nb: number of month, (1 based!)
=>1=jan,..,12=dec
@param ln: language for output
@return: the string representation of month | [
"Get",
"a",
"non",
"-",
"numeric",
"representation",
"of",
"a",
"month",
"internationalized",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/date.py#L244-L282 |
39,738 | inveniosoftware-attic/invenio-utils | invenio_utils/date.py | create_month_selectbox | def create_month_selectbox(name, selected_month=0, ln=None):
"""Creates an HTML menu for month selection. Value of selected field is
numeric.
@param name: name of the control, your form will be sent with name=value...
@param selected_month: preselect a month. use 0 for the Label 'Month'
@param ln: ... | python | def create_month_selectbox(name, selected_month=0, ln=None):
"""Creates an HTML menu for month selection. Value of selected field is
numeric.
@param name: name of the control, your form will be sent with name=value...
@param selected_month: preselect a month. use 0 for the Label 'Month'
@param ln: ... | [
"def",
"create_month_selectbox",
"(",
"name",
",",
"selected_month",
"=",
"0",
",",
"ln",
"=",
"None",
")",
":",
"ln",
"=",
"default_ln",
"(",
"ln",
")",
"out",
"=",
"\"<select name=\\\"%s\\\">\\n\"",
"%",
"name",
"for",
"i",
"in",
"range",
"(",
"0",
","... | Creates an HTML menu for month selection. Value of selected field is
numeric.
@param name: name of the control, your form will be sent with name=value...
@param selected_month: preselect a month. use 0 for the Label 'Month'
@param ln: language of the menu
@return: html as string | [
"Creates",
"an",
"HTML",
"menu",
"for",
"month",
"selection",
".",
"Value",
"of",
"selected",
"field",
"is",
"numeric",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/date.py#L308-L326 |
39,739 | inveniosoftware-attic/invenio-utils | invenio_utils/date.py | parse_runtime_limit | def parse_runtime_limit(value, now=None):
"""Parsing CLI option for runtime limit, supplied as VALUE.
Value could be something like: Sunday 23:00-05:00, the format being
[Wee[kday]] [hh[:mm][-hh[:mm]]].
The function will return two valid time ranges. The first could be in the
past, containing the p... | python | def parse_runtime_limit(value, now=None):
"""Parsing CLI option for runtime limit, supplied as VALUE.
Value could be something like: Sunday 23:00-05:00, the format being
[Wee[kday]] [hh[:mm][-hh[:mm]]].
The function will return two valid time ranges. The first could be in the
past, containing the p... | [
"def",
"parse_runtime_limit",
"(",
"value",
",",
"now",
"=",
"None",
")",
":",
"def",
"extract_time",
"(",
"value",
")",
":",
"value",
"=",
"_RE_RUNTIMELIMIT_HOUR",
".",
"search",
"(",
"value",
")",
".",
"groupdict",
"(",
")",
"return",
"timedelta",
"(",
... | Parsing CLI option for runtime limit, supplied as VALUE.
Value could be something like: Sunday 23:00-05:00, the format being
[Wee[kday]] [hh[:mm][-hh[:mm]]].
The function will return two valid time ranges. The first could be in the
past, containing the present or in the future. The second is always in ... | [
"Parsing",
"CLI",
"option",
"for",
"runtime",
"limit",
"supplied",
"as",
"VALUE",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/date.py#L376-L470 |
39,740 | inveniosoftware-attic/invenio-utils | invenio_utils/date.py | guess_datetime | def guess_datetime(datetime_string):
"""Try to guess the datetime contained in a string of unknow format.
@param datetime_string: the datetime representation.
@type datetime_string: string
@return: the guessed time.
@rtype: L{time.struct_time}
@raises ValueError: in case it's not possible to gu... | python | def guess_datetime(datetime_string):
"""Try to guess the datetime contained in a string of unknow format.
@param datetime_string: the datetime representation.
@type datetime_string: string
@return: the guessed time.
@rtype: L{time.struct_time}
@raises ValueError: in case it's not possible to gu... | [
"def",
"guess_datetime",
"(",
"datetime_string",
")",
":",
"if",
"CFG_HAS_EGENIX_DATETIME",
":",
"try",
":",
"return",
"Parser",
".",
"DateTimeFromString",
"(",
"datetime_string",
")",
".",
"timetuple",
"(",
")",
"except",
"ValueError",
":",
"pass",
"else",
":",... | Try to guess the datetime contained in a string of unknow format.
@param datetime_string: the datetime representation.
@type datetime_string: string
@return: the guessed time.
@rtype: L{time.struct_time}
@raises ValueError: in case it's not possible to guess the time. | [
"Try",
"to",
"guess",
"the",
"datetime",
"contained",
"in",
"a",
"string",
"of",
"unknow",
"format",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/date.py#L473-L494 |
39,741 | inveniosoftware-attic/invenio-utils | invenio_utils/date.py | get_dst | def get_dst(date_obj):
"""Determine if dst is locally enabled at this time"""
dst = 0
if date_obj.year >= 1900:
tmp_date = time.mktime(date_obj.timetuple())
# DST is 1 so reduce time with 1 hour.
dst = time.localtime(tmp_date)[-1]
return dst | python | def get_dst(date_obj):
"""Determine if dst is locally enabled at this time"""
dst = 0
if date_obj.year >= 1900:
tmp_date = time.mktime(date_obj.timetuple())
# DST is 1 so reduce time with 1 hour.
dst = time.localtime(tmp_date)[-1]
return dst | [
"def",
"get_dst",
"(",
"date_obj",
")",
":",
"dst",
"=",
"0",
"if",
"date_obj",
".",
"year",
">=",
"1900",
":",
"tmp_date",
"=",
"time",
".",
"mktime",
"(",
"date_obj",
".",
"timetuple",
"(",
")",
")",
"# DST is 1 so reduce time with 1 hour.",
"dst",
"=",
... | Determine if dst is locally enabled at this time | [
"Determine",
"if",
"dst",
"is",
"locally",
"enabled",
"at",
"this",
"time"
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/date.py#L642-L649 |
39,742 | inveniosoftware-attic/invenio-utils | invenio_utils/date.py | utc_to_localtime | def utc_to_localtime(
date_str,
fmt="%Y-%m-%d %H:%M:%S",
input_fmt="%Y-%m-%dT%H:%M:%SZ"):
"""
Convert UTC to localtime
Reference:
- (1) http://www.openarchives.org/OAI/openarchivesprotocol.html#Dates
- (2) http://www.w3.org/TR/NOTE-datetime
This function works only wi... | python | def utc_to_localtime(
date_str,
fmt="%Y-%m-%d %H:%M:%S",
input_fmt="%Y-%m-%dT%H:%M:%SZ"):
"""
Convert UTC to localtime
Reference:
- (1) http://www.openarchives.org/OAI/openarchivesprotocol.html#Dates
- (2) http://www.w3.org/TR/NOTE-datetime
This function works only wi... | [
"def",
"utc_to_localtime",
"(",
"date_str",
",",
"fmt",
"=",
"\"%Y-%m-%d %H:%M:%S\"",
",",
"input_fmt",
"=",
"\"%Y-%m-%dT%H:%M:%SZ\"",
")",
":",
"date_struct",
"=",
"datetime",
".",
"strptime",
"(",
"date_str",
",",
"input_fmt",
")",
"date_struct",
"+=",
"timedelt... | Convert UTC to localtime
Reference:
- (1) http://www.openarchives.org/OAI/openarchivesprotocol.html#Dates
- (2) http://www.w3.org/TR/NOTE-datetime
This function works only with dates complying with the
"Complete date plus hours, minutes and seconds" profile of
ISO 8601 defined by (2), and li... | [
"Convert",
"UTC",
"to",
"localtime"
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/date.py#L652-L672 |
39,743 | blaix/tdubs | tdubs/doubles.py | Spy._handle_call | def _handle_call(self, actual_call, stubbed_call):
"""Extends Stub call handling behavior to be callable by default."""
self._actual_calls.append(actual_call)
use_call = stubbed_call or actual_call
return use_call.return_value | python | def _handle_call(self, actual_call, stubbed_call):
"""Extends Stub call handling behavior to be callable by default."""
self._actual_calls.append(actual_call)
use_call = stubbed_call or actual_call
return use_call.return_value | [
"def",
"_handle_call",
"(",
"self",
",",
"actual_call",
",",
"stubbed_call",
")",
":",
"self",
".",
"_actual_calls",
".",
"append",
"(",
"actual_call",
")",
"use_call",
"=",
"stubbed_call",
"or",
"actual_call",
"return",
"use_call",
".",
"return_value"
] | Extends Stub call handling behavior to be callable by default. | [
"Extends",
"Stub",
"call",
"handling",
"behavior",
"to",
"be",
"callable",
"by",
"default",
"."
] | 5df4ee32bb973dbf52baa4f10640505394089b78 | https://github.com/blaix/tdubs/blob/5df4ee32bb973dbf52baa4f10640505394089b78/tdubs/doubles.py#L135-L139 |
39,744 | blaix/tdubs | tdubs/doubles.py | Call.formatted_args | def formatted_args(self):
"""Format call arguments as a string.
This is used to make test failure messages more helpful by referring
to calls using a string that matches how they were, or should have been
called.
>>> call = Call('arg1', 'arg2', kwarg='kwarg')
>>> call.f... | python | def formatted_args(self):
"""Format call arguments as a string.
This is used to make test failure messages more helpful by referring
to calls using a string that matches how they were, or should have been
called.
>>> call = Call('arg1', 'arg2', kwarg='kwarg')
>>> call.f... | [
"def",
"formatted_args",
"(",
"self",
")",
":",
"arg_reprs",
"=",
"list",
"(",
"map",
"(",
"repr",
",",
"self",
".",
"args",
")",
")",
"kwarg_reprs",
"=",
"[",
"'%s=%s'",
"%",
"(",
"k",
",",
"repr",
"(",
"v",
")",
")",
"for",
"k",
",",
"v",
"in... | Format call arguments as a string.
This is used to make test failure messages more helpful by referring
to calls using a string that matches how they were, or should have been
called.
>>> call = Call('arg1', 'arg2', kwarg='kwarg')
>>> call.formatted_args
"('arg1', 'arg2... | [
"Format",
"call",
"arguments",
"as",
"a",
"string",
"."
] | 5df4ee32bb973dbf52baa4f10640505394089b78 | https://github.com/blaix/tdubs/blob/5df4ee32bb973dbf52baa4f10640505394089b78/tdubs/doubles.py#L223-L237 |
39,745 | evocell/rabifier | rabifier/core.py | Seed.check | def check(self):
""" Check if data and third party tools are available
:raises: RuntimeError
"""
#for path in self.path.values():
# if not os.path.exists(path):
# raise RuntimeError("File '{}' is missing".format(path))
for tool in ('cd-hit', 'prank', ... | python | def check(self):
""" Check if data and third party tools are available
:raises: RuntimeError
"""
#for path in self.path.values():
# if not os.path.exists(path):
# raise RuntimeError("File '{}' is missing".format(path))
for tool in ('cd-hit', 'prank', ... | [
"def",
"check",
"(",
"self",
")",
":",
"#for path in self.path.values():",
"# if not os.path.exists(path):",
"# raise RuntimeError(\"File '{}' is missing\".format(path))",
"for",
"tool",
"in",
"(",
"'cd-hit'",
",",
"'prank'",
",",
"'hmmbuild'",
",",
"'hmmpress'",
",... | Check if data and third party tools are available
:raises: RuntimeError | [
"Check",
"if",
"data",
"and",
"third",
"party",
"tools",
"are",
"available"
] | a5be3d516517e555bde463b94f06aeed106d19b8 | https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/core.py#L98-L110 |
39,746 | evocell/rabifier | rabifier/core.py | Seed.generate_non_rabs | def generate_non_rabs(self):
""" Shrink the non-Rab DB size by reducing sequence redundancy.
"""
logging.info('Building non-Rab DB')
run_cmd([self.pathfinder['cd-hit'], '-i', self.path['non_rab_db'], '-o', self.output['non_rab_db'],
'-d', '100', '-c', str(config['param'... | python | def generate_non_rabs(self):
""" Shrink the non-Rab DB size by reducing sequence redundancy.
"""
logging.info('Building non-Rab DB')
run_cmd([self.pathfinder['cd-hit'], '-i', self.path['non_rab_db'], '-o', self.output['non_rab_db'],
'-d', '100', '-c', str(config['param'... | [
"def",
"generate_non_rabs",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'Building non-Rab DB'",
")",
"run_cmd",
"(",
"[",
"self",
".",
"pathfinder",
"[",
"'cd-hit'",
"]",
",",
"'-i'",
",",
"self",
".",
"path",
"[",
"'non_rab_db'",
"]",
",",
"'-o... | Shrink the non-Rab DB size by reducing sequence redundancy. | [
"Shrink",
"the",
"non",
"-",
"Rab",
"DB",
"size",
"by",
"reducing",
"sequence",
"redundancy",
"."
] | a5be3d516517e555bde463b94f06aeed106d19b8 | https://github.com/evocell/rabifier/blob/a5be3d516517e555bde463b94f06aeed106d19b8/rabifier/core.py#L433-L440 |
39,747 | slickqa/python-client | slickqa/micromodels/packages/PySO8601/durations.py | parse_duration | def parse_duration(duration):
"""Attepmts to parse an ISO8601 formatted ``duration``.
Returns a ``datetime.timedelta`` object.
"""
duration = str(duration).upper().strip()
elements = ELEMENTS.copy()
for pattern in (SIMPLE_DURATION, COMBINED_DURATION):
if pattern.match(duration):
... | python | def parse_duration(duration):
"""Attepmts to parse an ISO8601 formatted ``duration``.
Returns a ``datetime.timedelta`` object.
"""
duration = str(duration).upper().strip()
elements = ELEMENTS.copy()
for pattern in (SIMPLE_DURATION, COMBINED_DURATION):
if pattern.match(duration):
... | [
"def",
"parse_duration",
"(",
"duration",
")",
":",
"duration",
"=",
"str",
"(",
"duration",
")",
".",
"upper",
"(",
")",
".",
"strip",
"(",
")",
"elements",
"=",
"ELEMENTS",
".",
"copy",
"(",
")",
"for",
"pattern",
"in",
"(",
"SIMPLE_DURATION",
",",
... | Attepmts to parse an ISO8601 formatted ``duration``.
Returns a ``datetime.timedelta`` object. | [
"Attepmts",
"to",
"parse",
"an",
"ISO8601",
"formatted",
"duration",
"."
] | 1d36b4977cd4140d7d24917cab2b3f82b60739c2 | https://github.com/slickqa/python-client/blob/1d36b4977cd4140d7d24917cab2b3f82b60739c2/slickqa/micromodels/packages/PySO8601/durations.py#L58-L83 |
39,748 | hackedd/gw2api | gw2api/skins.py | skin_details | def skin_details(skin_id, lang="en"):
"""This resource returns details about a single skin.
:param skin_id: The skin to query for.
:param lang: The language to display the texts in.
The response is an object with at least the following properties. Note that
the availability of some properties depe... | python | def skin_details(skin_id, lang="en"):
"""This resource returns details about a single skin.
:param skin_id: The skin to query for.
:param lang: The language to display the texts in.
The response is an object with at least the following properties. Note that
the availability of some properties depe... | [
"def",
"skin_details",
"(",
"skin_id",
",",
"lang",
"=",
"\"en\"",
")",
":",
"params",
"=",
"{",
"\"skin_id\"",
":",
"skin_id",
",",
"\"lang\"",
":",
"lang",
"}",
"cache_name",
"=",
"\"skin_details.%(skin_id)s.%(lang)s.json\"",
"%",
"params",
"return",
"get_cach... | This resource returns details about a single skin.
:param skin_id: The skin to query for.
:param lang: The language to display the texts in.
The response is an object with at least the following properties. Note that
the availability of some properties depends on the type of item the skin
applies ... | [
"This",
"resource",
"returns",
"details",
"about",
"a",
"single",
"skin",
"."
] | 5543a78e6e3ed0573b7e84c142c44004b4779eac | https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/skins.py#L16-L53 |
39,749 | Aluriak/bubble-tools | bubbletools/converter.py | bubble_to_gexf | def bubble_to_gexf(bblfile:str, gexffile:str=None, oriented:bool=False):
"""Write in bblfile a graph equivalent to those depicted in bubble file"""
tree = BubbleTree.from_bubble_file(bblfile, oriented=bool(oriented))
gexf_converter.tree_to_file(tree, gexffile)
return gexffile | python | def bubble_to_gexf(bblfile:str, gexffile:str=None, oriented:bool=False):
"""Write in bblfile a graph equivalent to those depicted in bubble file"""
tree = BubbleTree.from_bubble_file(bblfile, oriented=bool(oriented))
gexf_converter.tree_to_file(tree, gexffile)
return gexffile | [
"def",
"bubble_to_gexf",
"(",
"bblfile",
":",
"str",
",",
"gexffile",
":",
"str",
"=",
"None",
",",
"oriented",
":",
"bool",
"=",
"False",
")",
":",
"tree",
"=",
"BubbleTree",
".",
"from_bubble_file",
"(",
"bblfile",
",",
"oriented",
"=",
"bool",
"(",
... | Write in bblfile a graph equivalent to those depicted in bubble file | [
"Write",
"in",
"bblfile",
"a",
"graph",
"equivalent",
"to",
"those",
"depicted",
"in",
"bubble",
"file"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/converter.py#L23-L27 |
39,750 | Aluriak/bubble-tools | bubbletools/converter.py | bubble_to_js | def bubble_to_js(bblfile:str, jsdir:str=None, oriented:bool=False, **style):
"""Write in jsdir a graph equivalent to those depicted in bubble file"""
js_converter.bubble_to_dir(bblfile, jsdir, oriented=bool(oriented), **style)
return jsdir | python | def bubble_to_js(bblfile:str, jsdir:str=None, oriented:bool=False, **style):
"""Write in jsdir a graph equivalent to those depicted in bubble file"""
js_converter.bubble_to_dir(bblfile, jsdir, oriented=bool(oriented), **style)
return jsdir | [
"def",
"bubble_to_js",
"(",
"bblfile",
":",
"str",
",",
"jsdir",
":",
"str",
"=",
"None",
",",
"oriented",
":",
"bool",
"=",
"False",
",",
"*",
"*",
"style",
")",
":",
"js_converter",
".",
"bubble_to_dir",
"(",
"bblfile",
",",
"jsdir",
",",
"oriented",... | Write in jsdir a graph equivalent to those depicted in bubble file | [
"Write",
"in",
"jsdir",
"a",
"graph",
"equivalent",
"to",
"those",
"depicted",
"in",
"bubble",
"file"
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/converter.py#L30-L33 |
39,751 | Aluriak/bubble-tools | bubbletools/converter.py | tree_to_graph | def tree_to_graph(bbltree:BubbleTree) -> Graph or Digraph:
"""Compute as a graphviz.Graph instance the given graph.
If given BubbleTree instance is oriented, returned value
is a graphviz.Digraph.
See http://graphviz.readthedocs.io/en/latest/examples.html#cluster-py
for graphviz API
"""
Gr... | python | def tree_to_graph(bbltree:BubbleTree) -> Graph or Digraph:
"""Compute as a graphviz.Graph instance the given graph.
If given BubbleTree instance is oriented, returned value
is a graphviz.Digraph.
See http://graphviz.readthedocs.io/en/latest/examples.html#cluster-py
for graphviz API
"""
Gr... | [
"def",
"tree_to_graph",
"(",
"bbltree",
":",
"BubbleTree",
")",
"->",
"Graph",
"or",
"Digraph",
":",
"GraphObject",
"=",
"Digraph",
"if",
"bbltree",
".",
"oriented",
"else",
"Graph",
"def",
"create",
"(",
"name",
":",
"str",
")",
":",
"\"\"\"Return a graphvi... | Compute as a graphviz.Graph instance the given graph.
If given BubbleTree instance is oriented, returned value
is a graphviz.Digraph.
See http://graphviz.readthedocs.io/en/latest/examples.html#cluster-py
for graphviz API | [
"Compute",
"as",
"a",
"graphviz",
".",
"Graph",
"instance",
"the",
"given",
"graph",
"."
] | f014f4a1986abefc80dc418feaa05ed258c2221a | https://github.com/Aluriak/bubble-tools/blob/f014f4a1986abefc80dc418feaa05ed258c2221a/bubbletools/converter.py#L61-L120 |
39,752 | trevisanj/a99 | a99/parts.py | AttrsPart.to_dict | def to_dict(self):
"""Returns OrderedDict whose keys are self.attrs"""
ret = OrderedDict()
for attrname in self.attrs:
ret[attrname] = self.__getattribute__(attrname)
return ret | python | def to_dict(self):
"""Returns OrderedDict whose keys are self.attrs"""
ret = OrderedDict()
for attrname in self.attrs:
ret[attrname] = self.__getattribute__(attrname)
return ret | [
"def",
"to_dict",
"(",
"self",
")",
":",
"ret",
"=",
"OrderedDict",
"(",
")",
"for",
"attrname",
"in",
"self",
".",
"attrs",
":",
"ret",
"[",
"attrname",
"]",
"=",
"self",
".",
"__getattribute__",
"(",
"attrname",
")",
"return",
"ret"
] | Returns OrderedDict whose keys are self.attrs | [
"Returns",
"OrderedDict",
"whose",
"keys",
"are",
"self",
".",
"attrs"
] | 193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539 | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/parts.py#L108-L113 |
39,753 | trevisanj/a99 | a99/parts.py | AttrsPart.to_list | def to_list(self):
"""Returns list containing values of attributes listed in self.attrs"""
ret = OrderedDict()
for attrname in self.attrs:
ret[attrname] = self.__getattribute__(attrname)
return ret | python | def to_list(self):
"""Returns list containing values of attributes listed in self.attrs"""
ret = OrderedDict()
for attrname in self.attrs:
ret[attrname] = self.__getattribute__(attrname)
return ret | [
"def",
"to_list",
"(",
"self",
")",
":",
"ret",
"=",
"OrderedDict",
"(",
")",
"for",
"attrname",
"in",
"self",
".",
"attrs",
":",
"ret",
"[",
"attrname",
"]",
"=",
"self",
".",
"__getattribute__",
"(",
"attrname",
")",
"return",
"ret"
] | Returns list containing values of attributes listed in self.attrs | [
"Returns",
"list",
"containing",
"values",
"of",
"attributes",
"listed",
"in",
"self",
".",
"attrs"
] | 193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539 | https://github.com/trevisanj/a99/blob/193e6e3c9b3e4f4a0ba7eb3eece846fe7045c539/a99/parts.py#L115-L121 |
39,754 | CodyKochmann/generators | generators/uniq.py | uniq | def uniq(pipe):
''' this works like bash's uniq command where the generator only iterates
if the next value is not the previous '''
pipe = iter(pipe)
previous = next(pipe)
yield previous
for i in pipe:
if i is not previous:
previous = i
yield i | python | def uniq(pipe):
''' this works like bash's uniq command where the generator only iterates
if the next value is not the previous '''
pipe = iter(pipe)
previous = next(pipe)
yield previous
for i in pipe:
if i is not previous:
previous = i
yield i | [
"def",
"uniq",
"(",
"pipe",
")",
":",
"pipe",
"=",
"iter",
"(",
"pipe",
")",
"previous",
"=",
"next",
"(",
"pipe",
")",
"yield",
"previous",
"for",
"i",
"in",
"pipe",
":",
"if",
"i",
"is",
"not",
"previous",
":",
"previous",
"=",
"i",
"yield",
"i... | this works like bash's uniq command where the generator only iterates
if the next value is not the previous | [
"this",
"works",
"like",
"bash",
"s",
"uniq",
"command",
"where",
"the",
"generator",
"only",
"iterates",
"if",
"the",
"next",
"value",
"is",
"not",
"the",
"previous"
] | e4ca4dd25d5023a94b0349c69d6224070cc2526f | https://github.com/CodyKochmann/generators/blob/e4ca4dd25d5023a94b0349c69d6224070cc2526f/generators/uniq.py#L7-L16 |
39,755 | herrersystem/apize | apize/http_request.py | send_request | def send_request(url, method, data,
args, params, headers, cookies, timeout, is_json, verify_cert):
"""
Forge and send HTTP request.
"""
## Parse url args
for p in args:
url = url.replace(':' + p, str(args[p]))
try:
if data:
if is_json:
headers['Content-Type'] = 'application/json'
data = json.du... | python | def send_request(url, method, data,
args, params, headers, cookies, timeout, is_json, verify_cert):
"""
Forge and send HTTP request.
"""
## Parse url args
for p in args:
url = url.replace(':' + p, str(args[p]))
try:
if data:
if is_json:
headers['Content-Type'] = 'application/json'
data = json.du... | [
"def",
"send_request",
"(",
"url",
",",
"method",
",",
"data",
",",
"args",
",",
"params",
",",
"headers",
",",
"cookies",
",",
"timeout",
",",
"is_json",
",",
"verify_cert",
")",
":",
"## Parse url args",
"for",
"p",
"in",
"args",
":",
"url",
"=",
"ur... | Forge and send HTTP request. | [
"Forge",
"and",
"send",
"HTTP",
"request",
"."
] | cf491660f0ee1c89a1e87a574eb8cd3c10257597 | https://github.com/herrersystem/apize/blob/cf491660f0ee1c89a1e87a574eb8cd3c10257597/apize/http_request.py#L10-L68 |
39,756 | volfpeter/graphscraper | src/graphscraper/base.py | Node.neighbors | def neighbors(self) -> List['Node']:
"""
The list of neighbors of the node.
"""
self._load_neighbors()
return [edge.source if edge.source != self else edge.target
for edge in self._neighbors.values()] | python | def neighbors(self) -> List['Node']:
"""
The list of neighbors of the node.
"""
self._load_neighbors()
return [edge.source if edge.source != self else edge.target
for edge in self._neighbors.values()] | [
"def",
"neighbors",
"(",
"self",
")",
"->",
"List",
"[",
"'Node'",
"]",
":",
"self",
".",
"_load_neighbors",
"(",
")",
"return",
"[",
"edge",
".",
"source",
"if",
"edge",
".",
"source",
"!=",
"self",
"else",
"edge",
".",
"target",
"for",
"edge",
"in"... | The list of neighbors of the node. | [
"The",
"list",
"of",
"neighbors",
"of",
"the",
"node",
"."
] | 11d407509956a282ee25190ed6491a162fc0fe7f | https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/base.py#L87-L93 |
39,757 | volfpeter/graphscraper | src/graphscraper/base.py | Node._load_neighbors | def _load_neighbors(self) -> None:
"""
Loads all neighbors of the node from the local database and
from the external data source if needed.
"""
if not self.are_neighbors_cached:
self._load_neighbors_from_external_source()
db: GraphDatabaseInterface ... | python | def _load_neighbors(self) -> None:
"""
Loads all neighbors of the node from the local database and
from the external data source if needed.
"""
if not self.are_neighbors_cached:
self._load_neighbors_from_external_source()
db: GraphDatabaseInterface ... | [
"def",
"_load_neighbors",
"(",
"self",
")",
"->",
"None",
":",
"if",
"not",
"self",
".",
"are_neighbors_cached",
":",
"self",
".",
"_load_neighbors_from_external_source",
"(",
")",
"db",
":",
"GraphDatabaseInterface",
"=",
"self",
".",
"_graph",
".",
"database",... | Loads all neighbors of the node from the local database and
from the external data source if needed. | [
"Loads",
"all",
"neighbors",
"of",
"the",
"node",
"from",
"the",
"local",
"database",
"and",
"from",
"the",
"external",
"data",
"source",
"if",
"needed",
"."
] | 11d407509956a282ee25190ed6491a162fc0fe7f | https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/base.py#L127-L140 |
39,758 | volfpeter/graphscraper | src/graphscraper/base.py | Node._load_neighbors_from_database | def _load_neighbors_from_database(self) -> None:
"""
Loads the neighbors of the node from the local database.
"""
self._are_neighbors_loaded = True
graph: Graph = self._graph
neighbors: List[DBNode] = graph.database.Node.find_by_name(self.name).neighbors
... | python | def _load_neighbors_from_database(self) -> None:
"""
Loads the neighbors of the node from the local database.
"""
self._are_neighbors_loaded = True
graph: Graph = self._graph
neighbors: List[DBNode] = graph.database.Node.find_by_name(self.name).neighbors
... | [
"def",
"_load_neighbors_from_database",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_are_neighbors_loaded",
"=",
"True",
"graph",
":",
"Graph",
"=",
"self",
".",
"_graph",
"neighbors",
":",
"List",
"[",
"DBNode",
"]",
"=",
"graph",
".",
"database",
... | Loads the neighbors of the node from the local database. | [
"Loads",
"the",
"neighbors",
"of",
"the",
"node",
"from",
"the",
"local",
"database",
"."
] | 11d407509956a282ee25190ed6491a162fc0fe7f | https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/base.py#L142-L155 |
39,759 | volfpeter/graphscraper | src/graphscraper/base.py | Edge.key | def key(self) -> Tuple[int, int]:
"""
The unique identifier of the edge consisting of the indexes of its
source and target nodes.
"""
return self._source.index, self._target.index | python | def key(self) -> Tuple[int, int]:
"""
The unique identifier of the edge consisting of the indexes of its
source and target nodes.
"""
return self._source.index, self._target.index | [
"def",
"key",
"(",
"self",
")",
"->",
"Tuple",
"[",
"int",
",",
"int",
"]",
":",
"return",
"self",
".",
"_source",
".",
"index",
",",
"self",
".",
"_target",
".",
"index"
] | The unique identifier of the edge consisting of the indexes of its
source and target nodes. | [
"The",
"unique",
"identifier",
"of",
"the",
"edge",
"consisting",
"of",
"the",
"indexes",
"of",
"its",
"source",
"and",
"target",
"nodes",
"."
] | 11d407509956a282ee25190ed6491a162fc0fe7f | https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/base.py#L207-L212 |
39,760 | volfpeter/graphscraper | src/graphscraper/base.py | EdgeList.edge_list | def edge_list(self) -> List[Edge]:
"""
The ordered list of edges in the container.
"""
return [edge for edge in sorted(self._edges.values(), key=attrgetter("key"))] | python | def edge_list(self) -> List[Edge]:
"""
The ordered list of edges in the container.
"""
return [edge for edge in sorted(self._edges.values(), key=attrgetter("key"))] | [
"def",
"edge_list",
"(",
"self",
")",
"->",
"List",
"[",
"Edge",
"]",
":",
"return",
"[",
"edge",
"for",
"edge",
"in",
"sorted",
"(",
"self",
".",
"_edges",
".",
"values",
"(",
")",
",",
"key",
"=",
"attrgetter",
"(",
"\"key\"",
")",
")",
"]"
] | The ordered list of edges in the container. | [
"The",
"ordered",
"list",
"of",
"edges",
"in",
"the",
"container",
"."
] | 11d407509956a282ee25190ed6491a162fc0fe7f | https://github.com/volfpeter/graphscraper/blob/11d407509956a282ee25190ed6491a162fc0fe7f/src/graphscraper/base.py#L489-L493 |
39,761 | thespacedoctor/fundamentals | fundamentals/nose2_plugins/cprof.py | Profiler.beforeSummaryReport | def beforeSummaryReport(self, event):
'''Output profiling results'''
self.prof.disable()
stats = pstats.Stats(self.prof, stream=event.stream).sort_stats(
self.sort)
event.stream.writeln(nose2.util.ln('Profiling results'))
stats.print_stats()
if self.pfile:
... | python | def beforeSummaryReport(self, event):
'''Output profiling results'''
self.prof.disable()
stats = pstats.Stats(self.prof, stream=event.stream).sort_stats(
self.sort)
event.stream.writeln(nose2.util.ln('Profiling results'))
stats.print_stats()
if self.pfile:
... | [
"def",
"beforeSummaryReport",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"prof",
".",
"disable",
"(",
")",
"stats",
"=",
"pstats",
".",
"Stats",
"(",
"self",
".",
"prof",
",",
"stream",
"=",
"event",
".",
"stream",
")",
".",
"sort_stats",
"(",... | Output profiling results | [
"Output",
"profiling",
"results"
] | 1d2c007ac74442ec2eabde771cfcacdb9c1ab382 | https://github.com/thespacedoctor/fundamentals/blob/1d2c007ac74442ec2eabde771cfcacdb9c1ab382/fundamentals/nose2_plugins/cprof.py#L37-L47 |
39,762 | NickMonzillo/SmartCloud | SmartCloud/wordplay.py | separate | def separate(text):
'''Takes text and separates it into a list of words'''
alphabet = 'abcdefghijklmnopqrstuvwxyz'
words = text.split()
standardwords = []
for word in words:
newstr = ''
for char in word:
if char in alphabet or char in alphabet.upper():
news... | python | def separate(text):
'''Takes text and separates it into a list of words'''
alphabet = 'abcdefghijklmnopqrstuvwxyz'
words = text.split()
standardwords = []
for word in words:
newstr = ''
for char in word:
if char in alphabet or char in alphabet.upper():
news... | [
"def",
"separate",
"(",
"text",
")",
":",
"alphabet",
"=",
"'abcdefghijklmnopqrstuvwxyz'",
"words",
"=",
"text",
".",
"split",
"(",
")",
"standardwords",
"=",
"[",
"]",
"for",
"word",
"in",
"words",
":",
"newstr",
"=",
"''",
"for",
"char",
"in",
"word",
... | Takes text and separates it into a list of words | [
"Takes",
"text",
"and",
"separates",
"it",
"into",
"a",
"list",
"of",
"words"
] | 481d1ef428427b452a8a787999c1d4a8868a3824 | https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/wordplay.py#L1-L13 |
39,763 | NickMonzillo/SmartCloud | SmartCloud/wordplay.py | eliminate_repeats | def eliminate_repeats(text):
'''Returns a list of words that occur in the text. Eliminates stopwords.'''
bannedwords = read_file('stopwords.txt')
alphabet = 'abcdefghijklmnopqrstuvwxyz'
words = text.split()
standardwords = []
for word in words:
newstr = ''
for char in word:
... | python | def eliminate_repeats(text):
'''Returns a list of words that occur in the text. Eliminates stopwords.'''
bannedwords = read_file('stopwords.txt')
alphabet = 'abcdefghijklmnopqrstuvwxyz'
words = text.split()
standardwords = []
for word in words:
newstr = ''
for char in word:
... | [
"def",
"eliminate_repeats",
"(",
"text",
")",
":",
"bannedwords",
"=",
"read_file",
"(",
"'stopwords.txt'",
")",
"alphabet",
"=",
"'abcdefghijklmnopqrstuvwxyz'",
"words",
"=",
"text",
".",
"split",
"(",
")",
"standardwords",
"=",
"[",
"]",
"for",
"word",
"in",... | Returns a list of words that occur in the text. Eliminates stopwords. | [
"Returns",
"a",
"list",
"of",
"words",
"that",
"occur",
"in",
"the",
"text",
".",
"Eliminates",
"stopwords",
"."
] | 481d1ef428427b452a8a787999c1d4a8868a3824 | https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/wordplay.py#L21-L36 |
39,764 | NickMonzillo/SmartCloud | SmartCloud/wordplay.py | wordcount | def wordcount(text):
'''Returns the count of the words in a file.'''
bannedwords = read_file('stopwords.txt')
wordcount = {}
separated = separate(text)
for word in separated:
if word not in bannedwords:
if not wordcount.has_key(word):
wordcount[word] = 1
... | python | def wordcount(text):
'''Returns the count of the words in a file.'''
bannedwords = read_file('stopwords.txt')
wordcount = {}
separated = separate(text)
for word in separated:
if word not in bannedwords:
if not wordcount.has_key(word):
wordcount[word] = 1
... | [
"def",
"wordcount",
"(",
"text",
")",
":",
"bannedwords",
"=",
"read_file",
"(",
"'stopwords.txt'",
")",
"wordcount",
"=",
"{",
"}",
"separated",
"=",
"separate",
"(",
"text",
")",
"for",
"word",
"in",
"separated",
":",
"if",
"word",
"not",
"in",
"banned... | Returns the count of the words in a file. | [
"Returns",
"the",
"count",
"of",
"the",
"words",
"in",
"a",
"file",
"."
] | 481d1ef428427b452a8a787999c1d4a8868a3824 | https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/wordplay.py#L38-L49 |
39,765 | NickMonzillo/SmartCloud | SmartCloud/wordplay.py | tuplecount | def tuplecount(text):
'''Changes a dictionary into a list of tuples.'''
worddict = wordcount(text)
countlist = []
for key in worddict.keys():
countlist.append((key,worddict[key]))
countlist = list(reversed(sorted(countlist,key = lambda x: x[1])))
return countlist | python | def tuplecount(text):
'''Changes a dictionary into a list of tuples.'''
worddict = wordcount(text)
countlist = []
for key in worddict.keys():
countlist.append((key,worddict[key]))
countlist = list(reversed(sorted(countlist,key = lambda x: x[1])))
return countlist | [
"def",
"tuplecount",
"(",
"text",
")",
":",
"worddict",
"=",
"wordcount",
"(",
"text",
")",
"countlist",
"=",
"[",
"]",
"for",
"key",
"in",
"worddict",
".",
"keys",
"(",
")",
":",
"countlist",
".",
"append",
"(",
"(",
"key",
",",
"worddict",
"[",
"... | Changes a dictionary into a list of tuples. | [
"Changes",
"a",
"dictionary",
"into",
"a",
"list",
"of",
"tuples",
"."
] | 481d1ef428427b452a8a787999c1d4a8868a3824 | https://github.com/NickMonzillo/SmartCloud/blob/481d1ef428427b452a8a787999c1d4a8868a3824/SmartCloud/wordplay.py#L51-L58 |
39,766 | akissa/clamavmirror | clamavmirror/__init__.py | get_file_md5 | def get_file_md5(filename):
"""Get a file's MD5"""
if os.path.exists(filename):
blocksize = 65536
try:
hasher = hashlib.md5()
except BaseException:
hasher = hashlib.new('md5', usedForSecurity=False)
with open(filename, 'rb') as afile:
buf = afi... | python | def get_file_md5(filename):
"""Get a file's MD5"""
if os.path.exists(filename):
blocksize = 65536
try:
hasher = hashlib.md5()
except BaseException:
hasher = hashlib.new('md5', usedForSecurity=False)
with open(filename, 'rb') as afile:
buf = afi... | [
"def",
"get_file_md5",
"(",
"filename",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"blocksize",
"=",
"65536",
"try",
":",
"hasher",
"=",
"hashlib",
".",
"md5",
"(",
")",
"except",
"BaseException",
":",
"hasher",
"=",
... | Get a file's MD5 | [
"Get",
"a",
"file",
"s",
"MD5"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L91-L106 |
39,767 | akissa/clamavmirror | clamavmirror/__init__.py | get_md5 | def get_md5(string):
"""Get a string's MD5"""
try:
hasher = hashlib.md5()
except BaseException:
hasher = hashlib.new('md5', usedForSecurity=False)
hasher.update(string)
return hasher.hexdigest() | python | def get_md5(string):
"""Get a string's MD5"""
try:
hasher = hashlib.md5()
except BaseException:
hasher = hashlib.new('md5', usedForSecurity=False)
hasher.update(string)
return hasher.hexdigest() | [
"def",
"get_md5",
"(",
"string",
")",
":",
"try",
":",
"hasher",
"=",
"hashlib",
".",
"md5",
"(",
")",
"except",
"BaseException",
":",
"hasher",
"=",
"hashlib",
".",
"new",
"(",
"'md5'",
",",
"usedForSecurity",
"=",
"False",
")",
"hasher",
".",
"update... | Get a string's MD5 | [
"Get",
"a",
"string",
"s",
"MD5"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L109-L116 |
39,768 | akissa/clamavmirror | clamavmirror/__init__.py | deploy_signature | def deploy_signature(source, dest, user=None, group=None):
"""Deploy a signature fole"""
move(source, dest)
os.chmod(dest, 0644)
if user and group:
try:
uid = pwd.getpwnam(user).pw_uid
gid = grp.getgrnam(group).gr_gid
os.chown(dest, uid, gid)
except (K... | python | def deploy_signature(source, dest, user=None, group=None):
"""Deploy a signature fole"""
move(source, dest)
os.chmod(dest, 0644)
if user and group:
try:
uid = pwd.getpwnam(user).pw_uid
gid = grp.getgrnam(group).gr_gid
os.chown(dest, uid, gid)
except (K... | [
"def",
"deploy_signature",
"(",
"source",
",",
"dest",
",",
"user",
"=",
"None",
",",
"group",
"=",
"None",
")",
":",
"move",
"(",
"source",
",",
"dest",
")",
"os",
".",
"chmod",
"(",
"dest",
",",
"0644",
")",
"if",
"user",
"and",
"group",
":",
"... | Deploy a signature fole | [
"Deploy",
"a",
"signature",
"fole"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L129-L139 |
39,769 | akissa/clamavmirror | clamavmirror/__init__.py | get_local_version | def get_local_version(sigdir, sig):
"""Get the local version of a signature"""
version = None
filename = os.path.join(sigdir, '%s.cvd' % sig)
if os.path.exists(filename):
cmd = ['sigtool', '-i', filename]
sigtool = Popen(cmd, stdout=PIPE, stderr=PIPE)
while True:
line... | python | def get_local_version(sigdir, sig):
"""Get the local version of a signature"""
version = None
filename = os.path.join(sigdir, '%s.cvd' % sig)
if os.path.exists(filename):
cmd = ['sigtool', '-i', filename]
sigtool = Popen(cmd, stdout=PIPE, stderr=PIPE)
while True:
line... | [
"def",
"get_local_version",
"(",
"sigdir",
",",
"sig",
")",
":",
"version",
"=",
"None",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sigdir",
",",
"'%s.cvd'",
"%",
"sig",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
... | Get the local version of a signature | [
"Get",
"the",
"local",
"version",
"of",
"a",
"signature"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L157-L172 |
39,770 | akissa/clamavmirror | clamavmirror/__init__.py | verify_sigfile | def verify_sigfile(sigdir, sig):
"""Verify a signature file"""
cmd = ['sigtool', '-i', '%s/%s.cvd' % (sigdir, sig)]
sigtool = Popen(cmd, stdout=PIPE, stderr=PIPE)
ret_val = sigtool.wait()
return ret_val == 0 | python | def verify_sigfile(sigdir, sig):
"""Verify a signature file"""
cmd = ['sigtool', '-i', '%s/%s.cvd' % (sigdir, sig)]
sigtool = Popen(cmd, stdout=PIPE, stderr=PIPE)
ret_val = sigtool.wait()
return ret_val == 0 | [
"def",
"verify_sigfile",
"(",
"sigdir",
",",
"sig",
")",
":",
"cmd",
"=",
"[",
"'sigtool'",
",",
"'-i'",
",",
"'%s/%s.cvd'",
"%",
"(",
"sigdir",
",",
"sig",
")",
"]",
"sigtool",
"=",
"Popen",
"(",
"cmd",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"... | Verify a signature file | [
"Verify",
"a",
"signature",
"file"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L175-L180 |
39,771 | akissa/clamavmirror | clamavmirror/__init__.py | check_download | def check_download(obj, *args, **kwargs):
"""Verify a download"""
version = args[0]
workdir = args[1]
signame = args[2]
if version:
local_version = get_local_version(workdir, signame)
if not verify_sigfile(workdir, signame) or version != local_version:
error("[-] \033[91m... | python | def check_download(obj, *args, **kwargs):
"""Verify a download"""
version = args[0]
workdir = args[1]
signame = args[2]
if version:
local_version = get_local_version(workdir, signame)
if not verify_sigfile(workdir, signame) or version != local_version:
error("[-] \033[91m... | [
"def",
"check_download",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"version",
"=",
"args",
"[",
"0",
"]",
"workdir",
"=",
"args",
"[",
"1",
"]",
"signame",
"=",
"args",
"[",
"2",
"]",
"if",
"version",
":",
"local_version",
... | Verify a download | [
"Verify",
"a",
"download"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L184-L194 |
39,772 | akissa/clamavmirror | clamavmirror/__init__.py | download_sig | def download_sig(opts, sig, version=None):
"""Download signature from hostname"""
code = None
downloaded = False
useagent = 'ClamAV/0.101.1 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)'
manager = PoolManager(
headers=make_headers(user_agent=useagent),
cert_reqs='CERT_REQUIRED',
... | python | def download_sig(opts, sig, version=None):
"""Download signature from hostname"""
code = None
downloaded = False
useagent = 'ClamAV/0.101.1 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)'
manager = PoolManager(
headers=make_headers(user_agent=useagent),
cert_reqs='CERT_REQUIRED',
... | [
"def",
"download_sig",
"(",
"opts",
",",
"sig",
",",
"version",
"=",
"None",
")",
":",
"code",
"=",
"None",
"downloaded",
"=",
"False",
"useagent",
"=",
"'ClamAV/0.101.1 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64)'",
"manager",
"=",
"PoolManager",
"(",
"headers",
"... | Download signature from hostname | [
"Download",
"signature",
"from",
"hostname"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L197-L224 |
39,773 | akissa/clamavmirror | clamavmirror/__init__.py | copy_sig | def copy_sig(sig, opts, isdiff):
"""Deploy a sig"""
info("[+] \033[92mDeploying signature:\033[0m %s" % sig)
if isdiff:
sourcefile = os.path.join(opts.workdir, '%s.cdiff' % sig)
destfile = os.path.join(opts.mirrordir, '%s.cdiff' % sig)
else:
sourcefile = os.path.join(opts.workdir... | python | def copy_sig(sig, opts, isdiff):
"""Deploy a sig"""
info("[+] \033[92mDeploying signature:\033[0m %s" % sig)
if isdiff:
sourcefile = os.path.join(opts.workdir, '%s.cdiff' % sig)
destfile = os.path.join(opts.mirrordir, '%s.cdiff' % sig)
else:
sourcefile = os.path.join(opts.workdir... | [
"def",
"copy_sig",
"(",
"sig",
",",
"opts",
",",
"isdiff",
")",
":",
"info",
"(",
"\"[+] \\033[92mDeploying signature:\\033[0m %s\"",
"%",
"sig",
")",
"if",
"isdiff",
":",
"sourcefile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"opts",
".",
"workdir",
",",... | Deploy a sig | [
"Deploy",
"a",
"sig"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L247-L257 |
39,774 | akissa/clamavmirror | clamavmirror/__init__.py | create_dns_file | def create_dns_file(opts, record):
"""Create the DNS record file"""
info("[+] \033[92mUpdating dns.txt file\033[0m")
filename = os.path.join(opts.mirrordir, 'dns.txt')
localmd5 = get_file_md5(filename)
remotemd5 = get_md5(record)
if localmd5 != remotemd5:
create_file(filename, record)
... | python | def create_dns_file(opts, record):
"""Create the DNS record file"""
info("[+] \033[92mUpdating dns.txt file\033[0m")
filename = os.path.join(opts.mirrordir, 'dns.txt')
localmd5 = get_file_md5(filename)
remotemd5 = get_md5(record)
if localmd5 != remotemd5:
create_file(filename, record)
... | [
"def",
"create_dns_file",
"(",
"opts",
",",
"record",
")",
":",
"info",
"(",
"\"[+] \\033[92mUpdating dns.txt file\\033[0m\"",
")",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"opts",
".",
"mirrordir",
",",
"'dns.txt'",
")",
"localmd5",
"=",
"get_fil... | Create the DNS record file | [
"Create",
"the",
"DNS",
"record",
"file"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L301-L311 |
39,775 | akissa/clamavmirror | clamavmirror/__init__.py | download_diffs | def download_diffs(queue):
"""Download the cdiff files"""
while True:
options, signature_type, localver, remotever = queue.get()
for num in range(int(localver), int(remotever) + 1):
sig_diff = '%s-%d' % (signature_type, num)
filename = os.path.join(options.mirrordir, '%s.... | python | def download_diffs(queue):
"""Download the cdiff files"""
while True:
options, signature_type, localver, remotever = queue.get()
for num in range(int(localver), int(remotever) + 1):
sig_diff = '%s-%d' % (signature_type, num)
filename = os.path.join(options.mirrordir, '%s.... | [
"def",
"download_diffs",
"(",
"queue",
")",
":",
"while",
"True",
":",
"options",
",",
"signature_type",
",",
"localver",
",",
"remotever",
"=",
"queue",
".",
"get",
"(",
")",
"for",
"num",
"in",
"range",
"(",
"int",
"(",
"localver",
")",
",",
"int",
... | Download the cdiff files | [
"Download",
"the",
"cdiff",
"files"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L314-L323 |
39,776 | akissa/clamavmirror | clamavmirror/__init__.py | work | def work(options):
"""The work functions"""
# pylint: disable=too-many-locals
record = get_record(options)
_, mainv, dailyv, _, _, _, safebrowsingv, bytecodev = record.split(':')
versions = {'main': mainv, 'daily': dailyv,
'safebrowsing': safebrowsingv,
'bytecode': by... | python | def work(options):
"""The work functions"""
# pylint: disable=too-many-locals
record = get_record(options)
_, mainv, dailyv, _, _, _, safebrowsingv, bytecodev = record.split(':')
versions = {'main': mainv, 'daily': dailyv,
'safebrowsing': safebrowsingv,
'bytecode': by... | [
"def",
"work",
"(",
"options",
")",
":",
"# pylint: disable=too-many-locals",
"record",
"=",
"get_record",
"(",
"options",
")",
"_",
",",
"mainv",
",",
"dailyv",
",",
"_",
",",
"_",
",",
"_",
",",
"safebrowsingv",
",",
"bytecodev",
"=",
"record",
".",
"s... | The work functions | [
"The",
"work",
"functions"
] | 6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6 | https://github.com/akissa/clamavmirror/blob/6ef1cfa9fb4fa4a7b8439004f1cd8775f51d77f6/clamavmirror/__init__.py#L326-L369 |
39,777 | mardix/Yass | yass/cli.py | copy_resource | def copy_resource(src, dest):
"""
To copy package data to destination
"""
package_name = "yass"
dest = (dest + "/" + os.path.basename(src)).rstrip("/")
if pkg_resources.resource_isdir(package_name, src):
if not os.path.isdir(dest):
os.makedirs(dest)
for res in pkg_res... | python | def copy_resource(src, dest):
"""
To copy package data to destination
"""
package_name = "yass"
dest = (dest + "/" + os.path.basename(src)).rstrip("/")
if pkg_resources.resource_isdir(package_name, src):
if not os.path.isdir(dest):
os.makedirs(dest)
for res in pkg_res... | [
"def",
"copy_resource",
"(",
"src",
",",
"dest",
")",
":",
"package_name",
"=",
"\"yass\"",
"dest",
"=",
"(",
"dest",
"+",
"\"/\"",
"+",
"os",
".",
"path",
".",
"basename",
"(",
"src",
")",
")",
".",
"rstrip",
"(",
"\"/\"",
")",
"if",
"pkg_resources"... | To copy package data to destination | [
"To",
"copy",
"package",
"data",
"to",
"destination"
] | 32f804c1a916f5b0a13d13fa750e52be3b6d666d | https://github.com/mardix/Yass/blob/32f804c1a916f5b0a13d13fa750e52be3b6d666d/yass/cli.py#L61-L78 |
39,778 | mardix/Yass | yass/cli.py | publish | def publish(endpoint, purge_files, rebuild_manifest, skip_upload):
"""Publish the site"""
print("Publishing site to %s ..." % endpoint.upper())
yass = Yass(CWD)
target = endpoint.lower()
sitename = yass.sitename
if not sitename:
raise ValueError("Missing site name")
endpoint = yas... | python | def publish(endpoint, purge_files, rebuild_manifest, skip_upload):
"""Publish the site"""
print("Publishing site to %s ..." % endpoint.upper())
yass = Yass(CWD)
target = endpoint.lower()
sitename = yass.sitename
if not sitename:
raise ValueError("Missing site name")
endpoint = yas... | [
"def",
"publish",
"(",
"endpoint",
",",
"purge_files",
",",
"rebuild_manifest",
",",
"skip_upload",
")",
":",
"print",
"(",
"\"Publishing site to %s ...\"",
"%",
"endpoint",
".",
"upper",
"(",
")",
")",
"yass",
"=",
"Yass",
"(",
"CWD",
")",
"target",
"=",
... | Publish the site | [
"Publish",
"the",
"site"
] | 32f804c1a916f5b0a13d13fa750e52be3b6d666d | https://github.com/mardix/Yass/blob/32f804c1a916f5b0a13d13fa750e52be3b6d666d/yass/cli.py#L134-L188 |
39,779 | mardix/Yass | yass/cli.py | setup_dns | def setup_dns(endpoint):
"""Setup site domain to route to static site"""
print("Setting up DNS...")
yass = Yass(CWD)
target = endpoint.lower()
sitename = yass.sitename
if not sitename:
raise ValueError("Missing site name")
endpoint = yass.config.get("hosting.%s" % target)
if n... | python | def setup_dns(endpoint):
"""Setup site domain to route to static site"""
print("Setting up DNS...")
yass = Yass(CWD)
target = endpoint.lower()
sitename = yass.sitename
if not sitename:
raise ValueError("Missing site name")
endpoint = yass.config.get("hosting.%s" % target)
if n... | [
"def",
"setup_dns",
"(",
"endpoint",
")",
":",
"print",
"(",
"\"Setting up DNS...\"",
")",
"yass",
"=",
"Yass",
"(",
"CWD",
")",
"target",
"=",
"endpoint",
".",
"lower",
"(",
")",
"sitename",
"=",
"yass",
".",
"sitename",
"if",
"not",
"sitename",
":",
... | Setup site domain to route to static site | [
"Setup",
"site",
"domain",
"to",
"route",
"to",
"static",
"site"
] | 32f804c1a916f5b0a13d13fa750e52be3b6d666d | https://github.com/mardix/Yass/blob/32f804c1a916f5b0a13d13fa750e52be3b6d666d/yass/cli.py#L194-L222 |
39,780 | mardix/Yass | yass/cli.py | create_site | def create_site(sitename):
"""Create a new site directory and init Yass"""
sitepath = os.path.join(CWD, sitename)
if os.path.isdir(sitepath):
print("Site directory '%s' exists already!" % sitename)
else:
print("Creating site: %s..." % sitename)
os.makedirs(sitepath)
copy_... | python | def create_site(sitename):
"""Create a new site directory and init Yass"""
sitepath = os.path.join(CWD, sitename)
if os.path.isdir(sitepath):
print("Site directory '%s' exists already!" % sitename)
else:
print("Creating site: %s..." % sitename)
os.makedirs(sitepath)
copy_... | [
"def",
"create_site",
"(",
"sitename",
")",
":",
"sitepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"CWD",
",",
"sitename",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"sitepath",
")",
":",
"print",
"(",
"\"Site directory '%s' exists already!\"",
... | Create a new site directory and init Yass | [
"Create",
"a",
"new",
"site",
"directory",
"and",
"init",
"Yass"
] | 32f804c1a916f5b0a13d13fa750e52be3b6d666d | https://github.com/mardix/Yass/blob/32f804c1a916f5b0a13d13fa750e52be3b6d666d/yass/cli.py#L227-L240 |
39,781 | mardix/Yass | yass/cli.py | init | def init():
"""Initialize Yass in the current directory """
yass_conf = os.path.join(CWD, "yass.yml")
if os.path.isfile(yass_conf):
print("::ALERT::")
print("It seems like Yass is already initialized here.")
print("If it's a mistake, delete 'yass.yml' in this directory")
else:
... | python | def init():
"""Initialize Yass in the current directory """
yass_conf = os.path.join(CWD, "yass.yml")
if os.path.isfile(yass_conf):
print("::ALERT::")
print("It seems like Yass is already initialized here.")
print("If it's a mistake, delete 'yass.yml' in this directory")
else:
... | [
"def",
"init",
"(",
")",
":",
"yass_conf",
"=",
"os",
".",
"path",
".",
"join",
"(",
"CWD",
",",
"\"yass.yml\"",
")",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"yass_conf",
")",
":",
"print",
"(",
"\"::ALERT::\"",
")",
"print",
"(",
"\"It seems li... | Initialize Yass in the current directory | [
"Initialize",
"Yass",
"in",
"the",
"current",
"directory"
] | 32f804c1a916f5b0a13d13fa750e52be3b6d666d | https://github.com/mardix/Yass/blob/32f804c1a916f5b0a13d13fa750e52be3b6d666d/yass/cli.py#L244-L258 |
39,782 | mardix/Yass | yass/cli.py | create_page | def create_page(pagename):
""" Create a new page Omit the extension, it will create it as .jade file """
page = pagename.lstrip("/").rstrip("/")
_, _ext = os.path.splitext(pagename)
# If the file doesn't have an extension, we'll just create one
if not _ext or _ext == "":
page += ".jade"
... | python | def create_page(pagename):
""" Create a new page Omit the extension, it will create it as .jade file """
page = pagename.lstrip("/").rstrip("/")
_, _ext = os.path.splitext(pagename)
# If the file doesn't have an extension, we'll just create one
if not _ext or _ext == "":
page += ".jade"
... | [
"def",
"create_page",
"(",
"pagename",
")",
":",
"page",
"=",
"pagename",
".",
"lstrip",
"(",
"\"/\"",
")",
".",
"rstrip",
"(",
"\"/\"",
")",
"_",
",",
"_ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"pagename",
")",
"# If the file doesn't have an ... | Create a new page Omit the extension, it will create it as .jade file | [
"Create",
"a",
"new",
"page",
"Omit",
"the",
"extension",
"it",
"will",
"create",
"it",
"as",
".",
"jade",
"file"
] | 32f804c1a916f5b0a13d13fa750e52be3b6d666d | https://github.com/mardix/Yass/blob/32f804c1a916f5b0a13d13fa750e52be3b6d666d/yass/cli.py#L263-L304 |
39,783 | mardix/Yass | yass/cli.py | serve | def serve(port, no_livereload, open_url):
"""Serve the site """
engine = Yass(CWD)
if not port:
port = engine.config.get("local_server.port", 8000)
if no_livereload is None:
no_livereload = True if engine.config.get("local_server.livereload") is False else False
if open_url is None:... | python | def serve(port, no_livereload, open_url):
"""Serve the site """
engine = Yass(CWD)
if not port:
port = engine.config.get("local_server.port", 8000)
if no_livereload is None:
no_livereload = True if engine.config.get("local_server.livereload") is False else False
if open_url is None:... | [
"def",
"serve",
"(",
"port",
",",
"no_livereload",
",",
"open_url",
")",
":",
"engine",
"=",
"Yass",
"(",
"CWD",
")",
"if",
"not",
"port",
":",
"port",
"=",
"engine",
".",
"config",
".",
"get",
"(",
"\"local_server.port\"",
",",
"8000",
")",
"if",
"n... | Serve the site | [
"Serve",
"the",
"site"
] | 32f804c1a916f5b0a13d13fa750e52be3b6d666d | https://github.com/mardix/Yass/blob/32f804c1a916f5b0a13d13fa750e52be3b6d666d/yass/cli.py#L310-L339 |
39,784 | hackedd/gw2api | gw2api/mumble.py | GuildWars2FileMapping.get_map_location | def get_map_location(self):
"""Get the location of the player, converted to world coordinates.
:return: a tuple (x, y, z).
"""
map_data = self.get_map()
(bounds_e, bounds_n), (bounds_w, bounds_s) = map_data["continent_rect"]
(map_e, map_n), (map_w, map_s) = map_data["ma... | python | def get_map_location(self):
"""Get the location of the player, converted to world coordinates.
:return: a tuple (x, y, z).
"""
map_data = self.get_map()
(bounds_e, bounds_n), (bounds_w, bounds_s) = map_data["continent_rect"]
(map_e, map_n), (map_w, map_s) = map_data["ma... | [
"def",
"get_map_location",
"(",
"self",
")",
":",
"map_data",
"=",
"self",
".",
"get_map",
"(",
")",
"(",
"bounds_e",
",",
"bounds_n",
")",
",",
"(",
"bounds_w",
",",
"bounds_s",
")",
"=",
"map_data",
"[",
"\"continent_rect\"",
"]",
"(",
"map_e",
",",
... | Get the location of the player, converted to world coordinates.
:return: a tuple (x, y, z). | [
"Get",
"the",
"location",
"of",
"the",
"player",
"converted",
"to",
"world",
"coordinates",
"."
] | 5543a78e6e3ed0573b7e84c142c44004b4779eac | https://github.com/hackedd/gw2api/blob/5543a78e6e3ed0573b7e84c142c44004b4779eac/gw2api/mumble.py#L93-L117 |
39,785 | nuSTORM/gnomon | gnomon/Graph.py | Graph.CreateVertices | def CreateVertices(self, points):
"""
Returns a dictionary object with keys that are 2tuples
represnting a point.
"""
gr = digraph()
for z, x, Q in points:
node = (z, x, Q)
gr.add_nodes([node])
return gr | python | def CreateVertices(self, points):
"""
Returns a dictionary object with keys that are 2tuples
represnting a point.
"""
gr = digraph()
for z, x, Q in points:
node = (z, x, Q)
gr.add_nodes([node])
return gr | [
"def",
"CreateVertices",
"(",
"self",
",",
"points",
")",
":",
"gr",
"=",
"digraph",
"(",
")",
"for",
"z",
",",
"x",
",",
"Q",
"in",
"points",
":",
"node",
"=",
"(",
"z",
",",
"x",
",",
"Q",
")",
"gr",
".",
"add_nodes",
"(",
"[",
"node",
"]",... | Returns a dictionary object with keys that are 2tuples
represnting a point. | [
"Returns",
"a",
"dictionary",
"object",
"with",
"keys",
"that",
"are",
"2tuples",
"represnting",
"a",
"point",
"."
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/Graph.py#L29-L40 |
39,786 | nuSTORM/gnomon | gnomon/Graph.py | Graph.GetFarthestNode | def GetFarthestNode(self, gr, node):
"""node is start node"""
# Remember: weights are negative
distance = minmax.shortest_path_bellman_ford(gr, node)[1]
# Find the farthest node, which is end of track
min_key = None
for key, value in distance.iteritems():
if ... | python | def GetFarthestNode(self, gr, node):
"""node is start node"""
# Remember: weights are negative
distance = minmax.shortest_path_bellman_ford(gr, node)[1]
# Find the farthest node, which is end of track
min_key = None
for key, value in distance.iteritems():
if ... | [
"def",
"GetFarthestNode",
"(",
"self",
",",
"gr",
",",
"node",
")",
":",
"# Remember: weights are negative",
"distance",
"=",
"minmax",
".",
"shortest_path_bellman_ford",
"(",
"gr",
",",
"node",
")",
"[",
"1",
"]",
"# Find the farthest node, which is end of track",
... | node is start node | [
"node",
"is",
"start",
"node"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/Graph.py#L71-L82 |
39,787 | Julian/Minion | minion/deferred.py | _CallbackChain.on_success | def on_success(self, fn, *args, **kwargs):
"""
Call the given callback if or when the connected deferred succeeds.
"""
self._callbacks.append((fn, args, kwargs))
result = self._resulted_in
if result is not _NOTHING_YET:
self._succeed(result=result) | python | def on_success(self, fn, *args, **kwargs):
"""
Call the given callback if or when the connected deferred succeeds.
"""
self._callbacks.append((fn, args, kwargs))
result = self._resulted_in
if result is not _NOTHING_YET:
self._succeed(result=result) | [
"def",
"on_success",
"(",
"self",
",",
"fn",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_callbacks",
".",
"append",
"(",
"(",
"fn",
",",
"args",
",",
"kwargs",
")",
")",
"result",
"=",
"self",
".",
"_resulted_in",
"if",
"r... | Call the given callback if or when the connected deferred succeeds. | [
"Call",
"the",
"given",
"callback",
"if",
"or",
"when",
"the",
"connected",
"deferred",
"succeeds",
"."
] | 518d06f9ffd38dcacc0de4d94e72d1f8452157a8 | https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/minion/deferred.py#L35-L45 |
39,788 | Julian/Minion | minion/deferred.py | _CallbackChain._succeed | def _succeed(self, result):
"""
Fire the success chain.
"""
for fn, args, kwargs in self._callbacks:
fn(result, *args, **kwargs)
self._resulted_in = result | python | def _succeed(self, result):
"""
Fire the success chain.
"""
for fn, args, kwargs in self._callbacks:
fn(result, *args, **kwargs)
self._resulted_in = result | [
"def",
"_succeed",
"(",
"self",
",",
"result",
")",
":",
"for",
"fn",
",",
"args",
",",
"kwargs",
"in",
"self",
".",
"_callbacks",
":",
"fn",
"(",
"result",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_resulted_in",
"=",
"result"
... | Fire the success chain. | [
"Fire",
"the",
"success",
"chain",
"."
] | 518d06f9ffd38dcacc0de4d94e72d1f8452157a8 | https://github.com/Julian/Minion/blob/518d06f9ffd38dcacc0de4d94e72d1f8452157a8/minion/deferred.py#L53-L61 |
39,789 | nuSTORM/gnomon | gnomon/Configuration.py | fetch_config | def fetch_config(filename):
"""Fetch the Configuration schema information
Finds the schema file, loads the file and reads the JSON, then converts to a dictionary that is returned
"""
# This trick gets the directory of *this* file Configuration.py thus
# allowing to find the schema files relative ... | python | def fetch_config(filename):
"""Fetch the Configuration schema information
Finds the schema file, loads the file and reads the JSON, then converts to a dictionary that is returned
"""
# This trick gets the directory of *this* file Configuration.py thus
# allowing to find the schema files relative ... | [
"def",
"fetch_config",
"(",
"filename",
")",
":",
"# This trick gets the directory of *this* file Configuration.py thus",
"# allowing to find the schema files relative to this file.",
"dir_name",
"=",
"get_source_dir",
"(",
")",
"# Append json",
"filename",
"=",
"os",
".",
"path... | Fetch the Configuration schema information
Finds the schema file, loads the file and reads the JSON, then converts to a dictionary that is returned | [
"Fetch",
"the",
"Configuration",
"schema",
"information"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/Configuration.py#L117-L132 |
39,790 | nuSTORM/gnomon | gnomon/Configuration.py | populate_args_level | def populate_args_level(schema, parser):
"""Use a schema to populate a command line argument parser"""
for key, value in schema['properties'].iteritems():
if key == 'name':
continue
arg = '--%s' % key
desc = value['description']
if 'type' in value:
if va... | python | def populate_args_level(schema, parser):
"""Use a schema to populate a command line argument parser"""
for key, value in schema['properties'].iteritems():
if key == 'name':
continue
arg = '--%s' % key
desc = value['description']
if 'type' in value:
if va... | [
"def",
"populate_args_level",
"(",
"schema",
",",
"parser",
")",
":",
"for",
"key",
",",
"value",
"in",
"schema",
"[",
"'properties'",
"]",
".",
"iteritems",
"(",
")",
":",
"if",
"key",
"==",
"'name'",
":",
"continue",
"arg",
"=",
"'--%s'",
"%",
"key",... | Use a schema to populate a command line argument parser | [
"Use",
"a",
"schema",
"to",
"populate",
"a",
"command",
"line",
"argument",
"parser"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/Configuration.py#L143-L173 |
39,791 | nuSTORM/gnomon | gnomon/Configuration.py | ConfigurationBase.set_json | def set_json(self, config_json):
"""Permanently set the JSON configuration
Unable to call twice."""
if self.configuration_dict is not None:
raise RuntimeError("Can only set configuration once", self.configuration_dict)
schema = fetch_config('ConfigurationSchema.json')
... | python | def set_json(self, config_json):
"""Permanently set the JSON configuration
Unable to call twice."""
if self.configuration_dict is not None:
raise RuntimeError("Can only set configuration once", self.configuration_dict)
schema = fetch_config('ConfigurationSchema.json')
... | [
"def",
"set_json",
"(",
"self",
",",
"config_json",
")",
":",
"if",
"self",
".",
"configuration_dict",
"is",
"not",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"Can only set configuration once\"",
",",
"self",
".",
"configuration_dict",
")",
"schema",
"=",
"fet... | Permanently set the JSON configuration
Unable to call twice. | [
"Permanently",
"set",
"the",
"JSON",
"configuration"
] | 7616486ecd6e26b76f677c380e62db1c0ade558a | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/Configuration.py#L43-L60 |
39,792 | inveniosoftware-attic/invenio-utils | invenio_utils/mimetype.py | file_strip_ext | def file_strip_ext(
afile,
skip_version=False,
only_known_extensions=False,
allow_subformat=True):
"""
Strip in the best way the extension from a filename.
>>> file_strip_ext("foo.tar.gz")
'foo'
>>> file_strip_ext("foo.buz.gz")
'foo.buz'
>>> file_strip_ext("f... | python | def file_strip_ext(
afile,
skip_version=False,
only_known_extensions=False,
allow_subformat=True):
"""
Strip in the best way the extension from a filename.
>>> file_strip_ext("foo.tar.gz")
'foo'
>>> file_strip_ext("foo.buz.gz")
'foo.buz'
>>> file_strip_ext("f... | [
"def",
"file_strip_ext",
"(",
"afile",
",",
"skip_version",
"=",
"False",
",",
"only_known_extensions",
"=",
"False",
",",
"allow_subformat",
"=",
"True",
")",
":",
"import",
"os",
"afile",
"=",
"afile",
".",
"split",
"(",
"';'",
")",
"if",
"len",
"(",
"... | Strip in the best way the extension from a filename.
>>> file_strip_ext("foo.tar.gz")
'foo'
>>> file_strip_ext("foo.buz.gz")
'foo.buz'
>>> file_strip_ext("foo.buz")
'foo'
>>> file_strip_ext("foo.buz", only_known_extensions=True)
'foo.buz'
>>> file_strip_ext("foo.buz;1", skip_version... | [
"Strip",
"in",
"the",
"best",
"way",
"the",
"extension",
"from",
"a",
"filename",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/mimetype.py#L142-L193 |
39,793 | inveniosoftware-attic/invenio-utils | invenio_utils/mimetype.py | guess_extension | def guess_extension(amimetype, normalize=False):
"""
Tries to guess extension for a mimetype.
@param amimetype: name of a mimetype
@time amimetype: string
@return: the extension
@rtype: string
"""
ext = _mimes.guess_extension(amimetype)
if ext and normalize:
# Normalize some... | python | def guess_extension(amimetype, normalize=False):
"""
Tries to guess extension for a mimetype.
@param amimetype: name of a mimetype
@time amimetype: string
@return: the extension
@rtype: string
"""
ext = _mimes.guess_extension(amimetype)
if ext and normalize:
# Normalize some... | [
"def",
"guess_extension",
"(",
"amimetype",
",",
"normalize",
"=",
"False",
")",
":",
"ext",
"=",
"_mimes",
".",
"guess_extension",
"(",
"amimetype",
")",
"if",
"ext",
"and",
"normalize",
":",
"# Normalize some common magic mis-interpreation",
"ext",
"=",
"{",
"... | Tries to guess extension for a mimetype.
@param amimetype: name of a mimetype
@time amimetype: string
@return: the extension
@rtype: string | [
"Tries",
"to",
"guess",
"extension",
"for",
"a",
"mimetype",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/mimetype.py#L208-L223 |
39,794 | inveniosoftware-attic/invenio-utils | invenio_utils/mimetype.py | get_magic_guesses | def get_magic_guesses(fullpath):
"""
Return all the possible guesses from the magic library about
the content of the file.
@param fullpath: location of the file
@type fullpath: string
@return: guesses about content of the file
@rtype: tuple
"""
if CFG_HAS_MAGIC == 1:
magic_c... | python | def get_magic_guesses(fullpath):
"""
Return all the possible guesses from the magic library about
the content of the file.
@param fullpath: location of the file
@type fullpath: string
@return: guesses about content of the file
@rtype: tuple
"""
if CFG_HAS_MAGIC == 1:
magic_c... | [
"def",
"get_magic_guesses",
"(",
"fullpath",
")",
":",
"if",
"CFG_HAS_MAGIC",
"==",
"1",
":",
"magic_cookies",
"=",
"_get_magic_cookies",
"(",
")",
"magic_result",
"=",
"[",
"]",
"for",
"key",
"in",
"magic_cookies",
".",
"keys",
"(",
")",
":",
"magic_result"... | Return all the possible guesses from the magic library about
the content of the file.
@param fullpath: location of the file
@type fullpath: string
@return: guesses about content of the file
@rtype: tuple | [
"Return",
"all",
"the",
"possible",
"guesses",
"from",
"the",
"magic",
"library",
"about",
"the",
"content",
"of",
"the",
"file",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/mimetype.py#L226-L248 |
39,795 | inveniosoftware-attic/invenio-utils | invenio_utils/mimetype.py | LazyMimeCache.mimes | def mimes(self):
"""
Returns extended MimeTypes.
"""
_mimes = MimeTypes(strict=False)
_mimes.suffix_map.update({'.tbz2': '.tar.bz2'})
_mimes.encodings_map.update({'.bz2': 'bzip2'})
if cfg['CFG_BIBDOCFILE_ADDITIONAL_KNOWN_MIMETYPES']:
for key, value in... | python | def mimes(self):
"""
Returns extended MimeTypes.
"""
_mimes = MimeTypes(strict=False)
_mimes.suffix_map.update({'.tbz2': '.tar.bz2'})
_mimes.encodings_map.update({'.bz2': 'bzip2'})
if cfg['CFG_BIBDOCFILE_ADDITIONAL_KNOWN_MIMETYPES']:
for key, value in... | [
"def",
"mimes",
"(",
"self",
")",
":",
"_mimes",
"=",
"MimeTypes",
"(",
"strict",
"=",
"False",
")",
"_mimes",
".",
"suffix_map",
".",
"update",
"(",
"{",
"'.tbz2'",
":",
"'.tar.bz2'",
"}",
")",
"_mimes",
".",
"encodings_map",
".",
"update",
"(",
"{",
... | Returns extended MimeTypes. | [
"Returns",
"extended",
"MimeTypes",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/mimetype.py#L89-L103 |
39,796 | inveniosoftware-attic/invenio-utils | invenio_utils/mimetype.py | LazyMimeCache.extensions | def extensions(self):
"""
Generate the regular expression to match all the known extensions.
@return: the regular expression.
@rtype: regular expression object
"""
_tmp_extensions = self.mimes.encodings_map.keys() + \
self.mimes.suffix_map.keys() + \
... | python | def extensions(self):
"""
Generate the regular expression to match all the known extensions.
@return: the regular expression.
@rtype: regular expression object
"""
_tmp_extensions = self.mimes.encodings_map.keys() + \
self.mimes.suffix_map.keys() + \
... | [
"def",
"extensions",
"(",
"self",
")",
":",
"_tmp_extensions",
"=",
"self",
".",
"mimes",
".",
"encodings_map",
".",
"keys",
"(",
")",
"+",
"self",
".",
"mimes",
".",
"suffix_map",
".",
"keys",
"(",
")",
"+",
"self",
".",
"mimes",
".",
"types_map",
"... | Generate the regular expression to match all the known extensions.
@return: the regular expression.
@rtype: regular expression object | [
"Generate",
"the",
"regular",
"expression",
"to",
"match",
"all",
"the",
"known",
"extensions",
"."
] | 9a1c6db4e3f1370901f329f510480dd8df188296 | https://github.com/inveniosoftware-attic/invenio-utils/blob/9a1c6db4e3f1370901f329f510480dd8df188296/invenio_utils/mimetype.py#L106-L128 |
39,797 | jaraco/jaraco.services | jaraco/services/__init__.py | ServiceManager.start | def start(self, service):
"""
Start the service, catching and logging exceptions
"""
try:
map(self.start_class, service.depends)
if service.is_running():
return
if service in self.failed:
log.warning("%s previously faile... | python | def start(self, service):
"""
Start the service, catching and logging exceptions
"""
try:
map(self.start_class, service.depends)
if service.is_running():
return
if service in self.failed:
log.warning("%s previously faile... | [
"def",
"start",
"(",
"self",
",",
"service",
")",
":",
"try",
":",
"map",
"(",
"self",
".",
"start_class",
",",
"service",
".",
"depends",
")",
"if",
"service",
".",
"is_running",
"(",
")",
":",
"return",
"if",
"service",
"in",
"self",
".",
"failed",... | Start the service, catching and logging exceptions | [
"Start",
"the",
"service",
"catching",
"and",
"logging",
"exceptions"
] | 4ccce53541201f778035b69e9c59e41e34ee5992 | https://github.com/jaraco/jaraco.services/blob/4ccce53541201f778035b69e9c59e41e34ee5992/jaraco/services/__init__.py#L73-L87 |
39,798 | jaraco/jaraco.services | jaraco/services/__init__.py | ServiceManager.start_class | def start_class(self, class_):
"""
Start all services of a given class. If this manager doesn't already
have a service of that class, it constructs one and starts it.
"""
matches = filter(lambda svc: isinstance(svc, class_), self)
if not matches:
svc = class_(... | python | def start_class(self, class_):
"""
Start all services of a given class. If this manager doesn't already
have a service of that class, it constructs one and starts it.
"""
matches = filter(lambda svc: isinstance(svc, class_), self)
if not matches:
svc = class_(... | [
"def",
"start_class",
"(",
"self",
",",
"class_",
")",
":",
"matches",
"=",
"filter",
"(",
"lambda",
"svc",
":",
"isinstance",
"(",
"svc",
",",
"class_",
")",
",",
"self",
")",
"if",
"not",
"matches",
":",
"svc",
"=",
"class_",
"(",
")",
"self",
".... | Start all services of a given class. If this manager doesn't already
have a service of that class, it constructs one and starts it. | [
"Start",
"all",
"services",
"of",
"a",
"given",
"class",
".",
"If",
"this",
"manager",
"doesn",
"t",
"already",
"have",
"a",
"service",
"of",
"that",
"class",
"it",
"constructs",
"one",
"and",
"starts",
"it",
"."
] | 4ccce53541201f778035b69e9c59e41e34ee5992 | https://github.com/jaraco/jaraco.services/blob/4ccce53541201f778035b69e9c59e41e34ee5992/jaraco/services/__init__.py#L94-L105 |
39,799 | jaraco/jaraco.services | jaraco/services/__init__.py | ServiceManager.stop_class | def stop_class(self, class_):
"Stop all services of a given class"
matches = filter(lambda svc: isinstance(svc, class_), self)
map(self.stop, matches) | python | def stop_class(self, class_):
"Stop all services of a given class"
matches = filter(lambda svc: isinstance(svc, class_), self)
map(self.stop, matches) | [
"def",
"stop_class",
"(",
"self",
",",
"class_",
")",
":",
"matches",
"=",
"filter",
"(",
"lambda",
"svc",
":",
"isinstance",
"(",
"svc",
",",
"class_",
")",
",",
"self",
")",
"map",
"(",
"self",
".",
"stop",
",",
"matches",
")"
] | Stop all services of a given class | [
"Stop",
"all",
"services",
"of",
"a",
"given",
"class"
] | 4ccce53541201f778035b69e9c59e41e34ee5992 | https://github.com/jaraco/jaraco.services/blob/4ccce53541201f778035b69e9c59e41e34ee5992/jaraco/services/__init__.py#L110-L113 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.