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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
250,000 | limpyd/redis-limpyd-extensions | limpyd_extensions/related.py | RelatedCollectionForList.lrem | def lrem(self, *values):
"""
Do a "lrem" call with self.instance as parameter for each value. Values
must be primary keys of the related model.
The "count" argument of the final call will be 0 to remove all the
matching values.
"""
self._reverse_call(lambda relate... | python | def lrem(self, *values):
"""
Do a "lrem" call with self.instance as parameter for each value. Values
must be primary keys of the related model.
The "count" argument of the final call will be 0 to remove all the
matching values.
"""
self._reverse_call(lambda relate... | [
"def",
"lrem",
"(",
"self",
",",
"*",
"values",
")",
":",
"self",
".",
"_reverse_call",
"(",
"lambda",
"related_field",
",",
"value",
":",
"related_field",
".",
"lrem",
"(",
"0",
",",
"value",
")",
",",
"*",
"values",
")"
] | Do a "lrem" call with self.instance as parameter for each value. Values
must be primary keys of the related model.
The "count" argument of the final call will be 0 to remove all the
matching values. | [
"Do",
"a",
"lrem",
"call",
"with",
"self",
".",
"instance",
"as",
"parameter",
"for",
"each",
"value",
".",
"Values",
"must",
"be",
"primary",
"keys",
"of",
"the",
"related",
"model",
".",
"The",
"count",
"argument",
"of",
"the",
"final",
"call",
"will",... | 13f34e39efd2f802761457da30ab2a4213b63934 | https://github.com/limpyd/redis-limpyd-extensions/blob/13f34e39efd2f802761457da30ab2a4213b63934/limpyd_extensions/related.py#L123-L130 |
250,001 | rerb/django-fortune | fortune/views.py | PackViewSet.loaded | def loaded(self, request, *args, **kwargs):
"""Return a list of loaded Packs.
"""
serializer = self.get_serializer(list(Pack.objects.all()),
many=True)
return Response(serializer.data) | python | def loaded(self, request, *args, **kwargs):
"""Return a list of loaded Packs.
"""
serializer = self.get_serializer(list(Pack.objects.all()),
many=True)
return Response(serializer.data) | [
"def",
"loaded",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"serializer",
"=",
"self",
".",
"get_serializer",
"(",
"list",
"(",
"Pack",
".",
"objects",
".",
"all",
"(",
")",
")",
",",
"many",
"=",
"True",
")... | Return a list of loaded Packs. | [
"Return",
"a",
"list",
"of",
"loaded",
"Packs",
"."
] | f84d34f616ecabd4fab8351ad7d3062cc9d6b127 | https://github.com/rerb/django-fortune/blob/f84d34f616ecabd4fab8351ad7d3062cc9d6b127/fortune/views.py#L30-L35 |
250,002 | pjuren/pyokit | src/pyokit/io/indexedFile.py | IndexedFile.indexed_file | def indexed_file(self, f):
"""
Setter for information about the file this object indexes.
:param f: a tuple of (filename, handle), either (or both) of which can be
None. If the handle is None, but filename is provided, then
handle is created from the filename. If both handle and... | python | def indexed_file(self, f):
"""
Setter for information about the file this object indexes.
:param f: a tuple of (filename, handle), either (or both) of which can be
None. If the handle is None, but filename is provided, then
handle is created from the filename. If both handle and... | [
"def",
"indexed_file",
"(",
"self",
",",
"f",
")",
":",
"filename",
",",
"handle",
"=",
"f",
"if",
"handle",
"is",
"None",
"and",
"filename",
"is",
"not",
"None",
":",
"handle",
"=",
"open",
"(",
"filename",
")",
"if",
"(",
"handle",
"is",
"None",
... | Setter for information about the file this object indexes.
:param f: a tuple of (filename, handle), either (or both) of which can be
None. If the handle is None, but filename is provided, then
handle is created from the filename. If both handle and filename
are None, or th... | [
"Setter",
"for",
"information",
"about",
"the",
"file",
"this",
"object",
"indexes",
"."
] | fddae123b5d817daa39496183f19c000d9c3791f | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/indexedFile.py#L122-L147 |
250,003 | pjuren/pyokit | src/pyokit/io/indexedFile.py | IndexedFile.write_index | def write_index(self, fh, to_str_func=str, generate=True, verbose=False):
"""
Write this index to a file.
Only the index dictionary itself is stored, no informatiom about the
indexed file, or the open filehandle is retained. The Output format is
just a tab-separated file, one record per line. The l... | python | def write_index(self, fh, to_str_func=str, generate=True, verbose=False):
"""
Write this index to a file.
Only the index dictionary itself is stored, no informatiom about the
indexed file, or the open filehandle is retained. The Output format is
just a tab-separated file, one record per line. The l... | [
"def",
"write_index",
"(",
"self",
",",
"fh",
",",
"to_str_func",
"=",
"str",
",",
"generate",
"=",
"True",
",",
"verbose",
"=",
"False",
")",
":",
"try",
":",
"handle",
"=",
"open",
"(",
"fh",
",",
"\"w\"",
")",
"except",
"TypeError",
":",
"# okay, ... | Write this index to a file.
Only the index dictionary itself is stored, no informatiom about the
indexed file, or the open filehandle is retained. The Output format is
just a tab-separated file, one record per line. The last column is the
file location for the record and all columns before that are col... | [
"Write",
"this",
"index",
"to",
"a",
"file",
"."
] | fddae123b5d817daa39496183f19c000d9c3791f | https://github.com/pjuren/pyokit/blob/fddae123b5d817daa39496183f19c000d9c3791f/src/pyokit/io/indexedFile.py#L248-L278 |
250,004 | eallik/spinoff | spinoff/actor/uri.py | Uri.steps | def steps(self):
"""Returns an iterable containing the steps to this `Uri` from the root `Uri`, including the root `Uri`."""
def _iter(uri, acc):
acc.appendleft(uri.name if uri.name else '')
return _iter(uri.parent, acc) if uri.parent else acc
return _iter(self, acc=deque... | python | def steps(self):
"""Returns an iterable containing the steps to this `Uri` from the root `Uri`, including the root `Uri`."""
def _iter(uri, acc):
acc.appendleft(uri.name if uri.name else '')
return _iter(uri.parent, acc) if uri.parent else acc
return _iter(self, acc=deque... | [
"def",
"steps",
"(",
"self",
")",
":",
"def",
"_iter",
"(",
"uri",
",",
"acc",
")",
":",
"acc",
".",
"appendleft",
"(",
"uri",
".",
"name",
"if",
"uri",
".",
"name",
"else",
"''",
")",
"return",
"_iter",
"(",
"uri",
".",
"parent",
",",
"acc",
"... | Returns an iterable containing the steps to this `Uri` from the root `Uri`, including the root `Uri`. | [
"Returns",
"an",
"iterable",
"containing",
"the",
"steps",
"to",
"this",
"Uri",
"from",
"the",
"root",
"Uri",
"including",
"the",
"root",
"Uri",
"."
] | 06b00d6b86c7422c9cb8f9a4b2915906e92b7d52 | https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/actor/uri.py#L51-L56 |
250,005 | eallik/spinoff | spinoff/actor/uri.py | Uri.parse | def parse(cls, addr):
"""Parses a new `Uri` instance from a string representation of a URI.
>>> u1 = Uri.parse('/foo/bar')
>>> u1.node, u1.steps, u1.path, u1.name
(None, ['', 'foo', 'bar'], '/foo/bar', 'bar')
>>> u2 = Uri.parse('somenode:123/foo/bar')
>>> u2.node, u1.ste... | python | def parse(cls, addr):
"""Parses a new `Uri` instance from a string representation of a URI.
>>> u1 = Uri.parse('/foo/bar')
>>> u1.node, u1.steps, u1.path, u1.name
(None, ['', 'foo', 'bar'], '/foo/bar', 'bar')
>>> u2 = Uri.parse('somenode:123/foo/bar')
>>> u2.node, u1.ste... | [
"def",
"parse",
"(",
"cls",
",",
"addr",
")",
":",
"if",
"addr",
".",
"endswith",
"(",
"'/'",
")",
":",
"raise",
"ValueError",
"(",
"\"Uris must not end in '/'\"",
")",
"# pragma: no cover",
"parts",
"=",
"addr",
".",
"split",
"(",
"'/'",
")",
"if",
"':'... | Parses a new `Uri` instance from a string representation of a URI.
>>> u1 = Uri.parse('/foo/bar')
>>> u1.node, u1.steps, u1.path, u1.name
(None, ['', 'foo', 'bar'], '/foo/bar', 'bar')
>>> u2 = Uri.parse('somenode:123/foo/bar')
>>> u2.node, u1.steps, u2.path, ur2.name
('s... | [
"Parses",
"a",
"new",
"Uri",
"instance",
"from",
"a",
"string",
"representation",
"of",
"a",
"URI",
"."
] | 06b00d6b86c7422c9cb8f9a4b2915906e92b7d52 | https://github.com/eallik/spinoff/blob/06b00d6b86c7422c9cb8f9a4b2915906e92b7d52/spinoff/actor/uri.py#L69-L95 |
250,006 | benzrf/parthial | parthial/context.py | Environment.new_scope | def new_scope(self, new_scope={}):
"""Add a new innermost scope for the duration of the with block.
Args:
new_scope (dict-like): The scope to add.
"""
old_scopes, self.scopes = self.scopes, self.scopes.new_child(new_scope)
yield
self.scopes = old_scopes | python | def new_scope(self, new_scope={}):
"""Add a new innermost scope for the duration of the with block.
Args:
new_scope (dict-like): The scope to add.
"""
old_scopes, self.scopes = self.scopes, self.scopes.new_child(new_scope)
yield
self.scopes = old_scopes | [
"def",
"new_scope",
"(",
"self",
",",
"new_scope",
"=",
"{",
"}",
")",
":",
"old_scopes",
",",
"self",
".",
"scopes",
"=",
"self",
".",
"scopes",
",",
"self",
".",
"scopes",
".",
"new_child",
"(",
"new_scope",
")",
"yield",
"self",
".",
"scopes",
"="... | Add a new innermost scope for the duration of the with block.
Args:
new_scope (dict-like): The scope to add. | [
"Add",
"a",
"new",
"innermost",
"scope",
"for",
"the",
"duration",
"of",
"the",
"with",
"block",
"."
] | ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f | https://github.com/benzrf/parthial/blob/ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f/parthial/context.py#L51-L59 |
250,007 | benzrf/parthial | parthial/context.py | Environment.new | def new(self, val):
"""Add a new value to me.
Args:
val (LispVal): The value to be added.
Returns:
LispVal: The added value.
Raises:
~parthial.errs.LimitationError: If I already contain the maximum
number of elements.
"""
... | python | def new(self, val):
"""Add a new value to me.
Args:
val (LispVal): The value to be added.
Returns:
LispVal: The added value.
Raises:
~parthial.errs.LimitationError: If I already contain the maximum
number of elements.
"""
... | [
"def",
"new",
"(",
"self",
",",
"val",
")",
":",
"if",
"len",
"(",
"self",
".",
"things",
")",
">=",
"self",
".",
"max_things",
":",
"raise",
"LimitationError",
"(",
"'too many things'",
")",
"self",
".",
"things",
".",
"add",
"(",
"val",
")",
"retur... | Add a new value to me.
Args:
val (LispVal): The value to be added.
Returns:
LispVal: The added value.
Raises:
~parthial.errs.LimitationError: If I already contain the maximum
number of elements. | [
"Add",
"a",
"new",
"value",
"to",
"me",
"."
] | ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f | https://github.com/benzrf/parthial/blob/ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f/parthial/context.py#L61-L77 |
250,008 | benzrf/parthial | parthial/context.py | Environment.rec_new | def rec_new(self, val):
"""Recursively add a new value and its children to me.
Args:
val (LispVal): The value to be added.
Returns:
LispVal: The added value.
"""
if val not in self.things:
for child in val.children():
self.rec... | python | def rec_new(self, val):
"""Recursively add a new value and its children to me.
Args:
val (LispVal): The value to be added.
Returns:
LispVal: The added value.
"""
if val not in self.things:
for child in val.children():
self.rec... | [
"def",
"rec_new",
"(",
"self",
",",
"val",
")",
":",
"if",
"val",
"not",
"in",
"self",
".",
"things",
":",
"for",
"child",
"in",
"val",
".",
"children",
"(",
")",
":",
"self",
".",
"rec_new",
"(",
"child",
")",
"self",
".",
"new",
"(",
"val",
"... | Recursively add a new value and its children to me.
Args:
val (LispVal): The value to be added.
Returns:
LispVal: The added value. | [
"Recursively",
"add",
"a",
"new",
"value",
"and",
"its",
"children",
"to",
"me",
"."
] | ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f | https://github.com/benzrf/parthial/blob/ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f/parthial/context.py#L79-L92 |
250,009 | benzrf/parthial | parthial/context.py | Environment.add_rec_new | def add_rec_new(self, k, val):
"""Recursively add a new value and its children to me, and assign a
variable to it.
Args:
k (str): The name of the variable to assign.
val (LispVal): The value to be added and assigned.
Returns:
LispVal: The added value... | python | def add_rec_new(self, k, val):
"""Recursively add a new value and its children to me, and assign a
variable to it.
Args:
k (str): The name of the variable to assign.
val (LispVal): The value to be added and assigned.
Returns:
LispVal: The added value... | [
"def",
"add_rec_new",
"(",
"self",
",",
"k",
",",
"val",
")",
":",
"self",
".",
"rec_new",
"(",
"val",
")",
"self",
"[",
"k",
"]",
"=",
"val",
"return",
"val"
] | Recursively add a new value and its children to me, and assign a
variable to it.
Args:
k (str): The name of the variable to assign.
val (LispVal): The value to be added and assigned.
Returns:
LispVal: The added value. | [
"Recursively",
"add",
"a",
"new",
"value",
"and",
"its",
"children",
"to",
"me",
"and",
"assign",
"a",
"variable",
"to",
"it",
"."
] | ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f | https://github.com/benzrf/parthial/blob/ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f/parthial/context.py#L94-L107 |
250,010 | benzrf/parthial | parthial/context.py | Context.eval | def eval(self, expr):
"""Evaluate an expression.
This does **not** add its argument (or its result) as an element of me!
That is the responsibility of the code that created the object. This
means that you need to :meth:`Environment.rec_new` any expression you
get from user input... | python | def eval(self, expr):
"""Evaluate an expression.
This does **not** add its argument (or its result) as an element of me!
That is the responsibility of the code that created the object. This
means that you need to :meth:`Environment.rec_new` any expression you
get from user input... | [
"def",
"eval",
"(",
"self",
",",
"expr",
")",
":",
"if",
"self",
".",
"depth",
">=",
"self",
".",
"max_depth",
":",
"raise",
"LimitationError",
"(",
"'too much nesting'",
")",
"if",
"self",
".",
"steps",
">=",
"self",
".",
"max_steps",
":",
"raise",
"L... | Evaluate an expression.
This does **not** add its argument (or its result) as an element of me!
That is the responsibility of the code that created the object. This
means that you need to :meth:`Environment.rec_new` any expression you
get from user input before evaluating it.
T... | [
"Evaluate",
"an",
"expression",
"."
] | ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f | https://github.com/benzrf/parthial/blob/ab1e316aec87ed34dda0ec0e145fe0c8cc8e907f/parthial/context.py#L212-L243 |
250,011 | brbsix/subsystem | subsystem/subsystem.py | error | def error(*args):
"""Display error message via stderr or GUI."""
if sys.stdin.isatty():
print('ERROR:', *args, file=sys.stderr)
else:
notify_error(*args) | python | def error(*args):
"""Display error message via stderr or GUI."""
if sys.stdin.isatty():
print('ERROR:', *args, file=sys.stderr)
else:
notify_error(*args) | [
"def",
"error",
"(",
"*",
"args",
")",
":",
"if",
"sys",
".",
"stdin",
".",
"isatty",
"(",
")",
":",
"print",
"(",
"'ERROR:'",
",",
"*",
"args",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"else",
":",
"notify_error",
"(",
"*",
"args",
")"
] | Display error message via stderr or GUI. | [
"Display",
"error",
"message",
"via",
"stderr",
"or",
"GUI",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L168-L173 |
250,012 | brbsix/subsystem | subsystem/subsystem.py | have | def have(cmd):
"""Determine whether supplied argument is a command on the PATH."""
try:
# Python 3.3+ only
from shutil import which
except ImportError:
def which(cmd):
"""
Given a command, return the path which conforms to the given mode
on the PA... | python | def have(cmd):
"""Determine whether supplied argument is a command on the PATH."""
try:
# Python 3.3+ only
from shutil import which
except ImportError:
def which(cmd):
"""
Given a command, return the path which conforms to the given mode
on the PA... | [
"def",
"have",
"(",
"cmd",
")",
":",
"try",
":",
"# Python 3.3+ only",
"from",
"shutil",
"import",
"which",
"except",
"ImportError",
":",
"def",
"which",
"(",
"cmd",
")",
":",
"\"\"\"\n Given a command, return the path which conforms to the given mode\n ... | Determine whether supplied argument is a command on the PATH. | [
"Determine",
"whether",
"supplied",
"argument",
"is",
"a",
"command",
"on",
"the",
"PATH",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L198-L238 |
250,013 | brbsix/subsystem | subsystem/subsystem.py | multithreader | def multithreader(args, paths):
"""Execute multiple processes at once."""
def shellprocess(path):
"""Return a ready-to-use subprocess."""
import subprocess
return subprocess.Popen(args + [path],
stderr=subprocess.DEVNULL,
s... | python | def multithreader(args, paths):
"""Execute multiple processes at once."""
def shellprocess(path):
"""Return a ready-to-use subprocess."""
import subprocess
return subprocess.Popen(args + [path],
stderr=subprocess.DEVNULL,
s... | [
"def",
"multithreader",
"(",
"args",
",",
"paths",
")",
":",
"def",
"shellprocess",
"(",
"path",
")",
":",
"\"\"\"Return a ready-to-use subprocess.\"\"\"",
"import",
"subprocess",
"return",
"subprocess",
".",
"Popen",
"(",
"args",
"+",
"[",
"path",
"]",
",",
"... | Execute multiple processes at once. | [
"Execute",
"multiple",
"processes",
"at",
"once",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L276-L289 |
250,014 | brbsix/subsystem | subsystem/subsystem.py | prompt_gui | def prompt_gui(path):
"""Prompt for a new filename via GUI."""
import subprocess
filepath, extension = os.path.splitext(path)
basename = os.path.basename(filepath)
dirname = os.path.dirname(filepath)
retry_text = 'Sorry, please try again...'
icon = 'video-x-generic'
# detect and conf... | python | def prompt_gui(path):
"""Prompt for a new filename via GUI."""
import subprocess
filepath, extension = os.path.splitext(path)
basename = os.path.basename(filepath)
dirname = os.path.dirname(filepath)
retry_text = 'Sorry, please try again...'
icon = 'video-x-generic'
# detect and conf... | [
"def",
"prompt_gui",
"(",
"path",
")",
":",
"import",
"subprocess",
"filepath",
",",
"extension",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"path",
")",
"basename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"filepath",
")",
"dirname",
"=",
"os"... | Prompt for a new filename via GUI. | [
"Prompt",
"for",
"a",
"new",
"filename",
"via",
"GUI",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L386-L441 |
250,015 | brbsix/subsystem | subsystem/subsystem.py | prompt_terminal | def prompt_terminal(path):
"""Prompt for a new filename via terminal."""
def rlinput(prompt_msg, prefill=''):
"""
One line is read from standard input. Display `prompt_msg` on
standard error. `prefill` is placed into the editing buffer
before editing begins.
"""
... | python | def prompt_terminal(path):
"""Prompt for a new filename via terminal."""
def rlinput(prompt_msg, prefill=''):
"""
One line is read from standard input. Display `prompt_msg` on
standard error. `prefill` is placed into the editing buffer
before editing begins.
"""
... | [
"def",
"prompt_terminal",
"(",
"path",
")",
":",
"def",
"rlinput",
"(",
"prompt_msg",
",",
"prefill",
"=",
"''",
")",
":",
"\"\"\"\n One line is read from standard input. Display `prompt_msg` on\n standard error. `prefill` is placed into the editing buffer\n befo... | Prompt for a new filename via terminal. | [
"Prompt",
"for",
"a",
"new",
"filename",
"via",
"terminal",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L444-L476 |
250,016 | brbsix/subsystem | subsystem/subsystem.py | rename | def rename(path):
"""Rename a file if necessary."""
new_path = prompt(path)
if path != new_path:
try:
from shutil import move
except ImportError:
from os import rename as move
move(path, new_path)
return new_path | python | def rename(path):
"""Rename a file if necessary."""
new_path = prompt(path)
if path != new_path:
try:
from shutil import move
except ImportError:
from os import rename as move
move(path, new_path)
return new_path | [
"def",
"rename",
"(",
"path",
")",
":",
"new_path",
"=",
"prompt",
"(",
"path",
")",
"if",
"path",
"!=",
"new_path",
":",
"try",
":",
"from",
"shutil",
"import",
"move",
"except",
"ImportError",
":",
"from",
"os",
"import",
"rename",
"as",
"move",
"mov... | Rename a file if necessary. | [
"Rename",
"a",
"file",
"if",
"necessary",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L479-L492 |
250,017 | brbsix/subsystem | subsystem/subsystem.py | scan | def scan(subtitles):
"""Remove advertising from subtitles."""
from importlib.util import find_spec
try:
import subnuker
except ImportError:
fatal('Unable to scan subtitles. Please install subnuker.')
# check whether aeidon is available
aeidon = find_spec('aeidon') is not None
... | python | def scan(subtitles):
"""Remove advertising from subtitles."""
from importlib.util import find_spec
try:
import subnuker
except ImportError:
fatal('Unable to scan subtitles. Please install subnuker.')
# check whether aeidon is available
aeidon = find_spec('aeidon') is not None
... | [
"def",
"scan",
"(",
"subtitles",
")",
":",
"from",
"importlib",
".",
"util",
"import",
"find_spec",
"try",
":",
"import",
"subnuker",
"except",
"ImportError",
":",
"fatal",
"(",
"'Unable to scan subtitles. Please install subnuker.'",
")",
"# check whether aeidon is avai... | Remove advertising from subtitles. | [
"Remove",
"advertising",
"from",
"subtitles",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L495-L520 |
250,018 | brbsix/subsystem | subsystem/subsystem.py | Downloader.getavailable | def getavailable(self):
"""Return a list of subtitle downloaders available."""
from importlib import import_module
available = []
for script in self.SCRIPTS:
if have(script):
available.append(script)
for module in self.MODULES:
try:
... | python | def getavailable(self):
"""Return a list of subtitle downloaders available."""
from importlib import import_module
available = []
for script in self.SCRIPTS:
if have(script):
available.append(script)
for module in self.MODULES:
try:
... | [
"def",
"getavailable",
"(",
"self",
")",
":",
"from",
"importlib",
"import",
"import_module",
"available",
"=",
"[",
"]",
"for",
"script",
"in",
"self",
".",
"SCRIPTS",
":",
"if",
"have",
"(",
"script",
")",
":",
"available",
".",
"append",
"(",
"script"... | Return a list of subtitle downloaders available. | [
"Return",
"a",
"list",
"of",
"subtitle",
"downloaders",
"available",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L59-L77 |
250,019 | brbsix/subsystem | subsystem/subsystem.py | Downloader.getdefault | def getdefault(self):
"""Return an available default downloader."""
if not self.available:
error('No supported downloaders available')
print('\nPlease install one of the following:', file=sys.stderr)
print(self.SUPPORTED, file=sys.stderr)
sys.exit(1)
... | python | def getdefault(self):
"""Return an available default downloader."""
if not self.available:
error('No supported downloaders available')
print('\nPlease install one of the following:', file=sys.stderr)
print(self.SUPPORTED, file=sys.stderr)
sys.exit(1)
... | [
"def",
"getdefault",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"available",
":",
"error",
"(",
"'No supported downloaders available'",
")",
"print",
"(",
"'\\nPlease install one of the following:'",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"print",
"(... | Return an available default downloader. | [
"Return",
"an",
"available",
"default",
"downloader",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L79-L96 |
250,020 | brbsix/subsystem | subsystem/subsystem.py | Downloader.download | def download(self, paths, tool, language):
"""Download subtitles via a number of tools."""
if tool not in self.available:
fatal('{!r} is not installed'.format(tool))
try:
from . import plugins
downloader = plugins.__getattribute__(tool)
except Attrib... | python | def download(self, paths, tool, language):
"""Download subtitles via a number of tools."""
if tool not in self.available:
fatal('{!r} is not installed'.format(tool))
try:
from . import plugins
downloader = plugins.__getattribute__(tool)
except Attrib... | [
"def",
"download",
"(",
"self",
",",
"paths",
",",
"tool",
",",
"language",
")",
":",
"if",
"tool",
"not",
"in",
"self",
".",
"available",
":",
"fatal",
"(",
"'{!r} is not installed'",
".",
"format",
"(",
"tool",
")",
")",
"try",
":",
"from",
".",
"i... | Download subtitles via a number of tools. | [
"Download",
"subtitles",
"via",
"a",
"number",
"of",
"tools",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L98-L119 |
250,021 | brbsix/subsystem | subsystem/subsystem.py | Downloader.epilog | def epilog(self):
"""Return text formatted for the usage description's epilog."""
bold = '\033[1m'
end = '\033[0m'
available = self.available.copy()
index = available.index(Config.DOWNLOADER_DEFAULT)
available[index] = bold + '(' + available[index] + ')' + end
fo... | python | def epilog(self):
"""Return text formatted for the usage description's epilog."""
bold = '\033[1m'
end = '\033[0m'
available = self.available.copy()
index = available.index(Config.DOWNLOADER_DEFAULT)
available[index] = bold + '(' + available[index] + ')' + end
fo... | [
"def",
"epilog",
"(",
"self",
")",
":",
"bold",
"=",
"'\\033[1m'",
"end",
"=",
"'\\033[0m'",
"available",
"=",
"self",
".",
"available",
".",
"copy",
"(",
")",
"index",
"=",
"available",
".",
"index",
"(",
"Config",
".",
"DOWNLOADER_DEFAULT",
")",
"avail... | Return text formatted for the usage description's epilog. | [
"Return",
"text",
"formatted",
"for",
"the",
"usage",
"description",
"s",
"epilog",
"."
] | 57705bc20d71ceaed9e22e21246265d717e98eb8 | https://github.com/brbsix/subsystem/blob/57705bc20d71ceaed9e22e21246265d717e98eb8/subsystem/subsystem.py#L121-L130 |
250,022 | alfred82santa/aio-service-client | service_client/mocks.py | MockManager.patch_mock_desc | def patch_mock_desc(self, patch, *args, **kwarg):
"""
Context manager or decorator in order to patch a mock definition of service
endpoint in a test.
:param patch: Dictionary in order to update endpoint's mock definition
:type patch: dict
:param service_name: Name of ser... | python | def patch_mock_desc(self, patch, *args, **kwarg):
"""
Context manager or decorator in order to patch a mock definition of service
endpoint in a test.
:param patch: Dictionary in order to update endpoint's mock definition
:type patch: dict
:param service_name: Name of ser... | [
"def",
"patch_mock_desc",
"(",
"self",
",",
"patch",
",",
"*",
"args",
",",
"*",
"*",
"kwarg",
")",
":",
"return",
"PatchMockDescDefinition",
"(",
"patch",
",",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwarg",
")"
] | Context manager or decorator in order to patch a mock definition of service
endpoint in a test.
:param patch: Dictionary in order to update endpoint's mock definition
:type patch: dict
:param service_name: Name of service where you want to use mock. If None it will be used
a... | [
"Context",
"manager",
"or",
"decorator",
"in",
"order",
"to",
"patch",
"a",
"mock",
"definition",
"of",
"service",
"endpoint",
"in",
"a",
"test",
"."
] | dd9ad49e23067b22178534915aa23ba24f6ff39b | https://github.com/alfred82santa/aio-service-client/blob/dd9ad49e23067b22178534915aa23ba24f6ff39b/service_client/mocks.py#L60-L80 |
250,023 | alfred82santa/aio-service-client | service_client/mocks.py | MockManager.use_mock | def use_mock(self, mock, *args, **kwarg):
"""
Context manager or decorator in order to use a coroutine as mock of service
endpoint in a test.
:param mock: Coroutine to use as mock. It should behave like :meth:`~ClientSession.request`.
:type mock: coroutine
:param service... | python | def use_mock(self, mock, *args, **kwarg):
"""
Context manager or decorator in order to use a coroutine as mock of service
endpoint in a test.
:param mock: Coroutine to use as mock. It should behave like :meth:`~ClientSession.request`.
:type mock: coroutine
:param service... | [
"def",
"use_mock",
"(",
"self",
",",
"mock",
",",
"*",
"args",
",",
"*",
"*",
"kwarg",
")",
":",
"return",
"UseMockDefinition",
"(",
"mock",
",",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwarg",
")"
] | Context manager or decorator in order to use a coroutine as mock of service
endpoint in a test.
:param mock: Coroutine to use as mock. It should behave like :meth:`~ClientSession.request`.
:type mock: coroutine
:param service_name: Name of service where you want to use mock. If None it ... | [
"Context",
"manager",
"or",
"decorator",
"in",
"order",
"to",
"use",
"a",
"coroutine",
"as",
"mock",
"of",
"service",
"endpoint",
"in",
"a",
"test",
"."
] | dd9ad49e23067b22178534915aa23ba24f6ff39b | https://github.com/alfred82santa/aio-service-client/blob/dd9ad49e23067b22178534915aa23ba24f6ff39b/service_client/mocks.py#L82-L101 |
250,024 | ploneintranet/ploneintranet.workspace | src/ploneintranet/workspace/setuphandlers.py | post_install | def post_install(context):
"""
- sets an acl user group to hold all intranet users
- setup the dynamic groups plugin
- sets the addable types for the ploneintranet policy
"""
marker = 'ploneintranet-workspace.marker'
if context.readDataFile(marker) is None:
return
portal = api.p... | python | def post_install(context):
"""
- sets an acl user group to hold all intranet users
- setup the dynamic groups plugin
- sets the addable types for the ploneintranet policy
"""
marker = 'ploneintranet-workspace.marker'
if context.readDataFile(marker) is None:
return
portal = api.p... | [
"def",
"post_install",
"(",
"context",
")",
":",
"marker",
"=",
"'ploneintranet-workspace.marker'",
"if",
"context",
".",
"readDataFile",
"(",
"marker",
")",
"is",
"None",
":",
"return",
"portal",
"=",
"api",
".",
"portal",
".",
"get",
"(",
")",
"# Set up a ... | - sets an acl user group to hold all intranet users
- setup the dynamic groups plugin
- sets the addable types for the ploneintranet policy | [
"-",
"sets",
"an",
"acl",
"user",
"group",
"to",
"hold",
"all",
"intranet",
"users",
"-",
"setup",
"the",
"dynamic",
"groups",
"plugin",
"-",
"sets",
"the",
"addable",
"types",
"for",
"the",
"ploneintranet",
"policy"
] | a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba | https://github.com/ploneintranet/ploneintranet.workspace/blob/a4fc7a5c61f9c6d4d4ad25478ff5250f342ffbba/src/ploneintranet/workspace/setuphandlers.py#L10-L63 |
250,025 | kodexlab/reliure | reliure/types.py | GenericType.serialize | def serialize(self, value, **kwargs):
""" pre-serialize value """
if self._serialize is not None:
return self._serialize(value, **kwargs)
else:
return value | python | def serialize(self, value, **kwargs):
""" pre-serialize value """
if self._serialize is not None:
return self._serialize(value, **kwargs)
else:
return value | [
"def",
"serialize",
"(",
"self",
",",
"value",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_serialize",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_serialize",
"(",
"value",
",",
"*",
"*",
"kwargs",
")",
"else",
":",
"return",
"va... | pre-serialize value | [
"pre",
"-",
"serialize",
"value"
] | 0450c7a9254c5c003162738458bbe0c49e777ba5 | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/types.py#L132-L137 |
250,026 | abe-winter/pg13-py | pg13/stubredis.py | complete_message | def complete_message(buf):
"returns msg,buf_remaining or None,buf"
# todo: read dollar-length for strings; I dont think I can blindly trust newlines. learn about escaping
# note: all the length checks are +1 over what I need because I'm asking for *complete* lines.
lines=buf.split('\r\n')
if len(lines)<=... | python | def complete_message(buf):
"returns msg,buf_remaining or None,buf"
# todo: read dollar-length for strings; I dont think I can blindly trust newlines. learn about escaping
# note: all the length checks are +1 over what I need because I'm asking for *complete* lines.
lines=buf.split('\r\n')
if len(lines)<=... | [
"def",
"complete_message",
"(",
"buf",
")",
":",
"# todo: read dollar-length for strings; I dont think I can blindly trust newlines. learn about escaping\r",
"# note: all the length checks are +1 over what I need because I'm asking for *complete* lines.\r",
"lines",
"=",
"buf",
".",
"split",... | returns msg,buf_remaining or None,buf | [
"returns",
"msg",
"buf_remaining",
"or",
"None",
"buf"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/stubredis.py#L80-L101 |
250,027 | abe-winter/pg13-py | pg13/stubredis.py | RedisState.process_message | def process_message(self,msg,sock):
"serialize and deserialize"
command=msg[0]
try: f={'GET':self.get,'SET':self.set,'SUBSCRIBE':self.sub,'PUBLISH':self.pub,
'PING':self.ping,'GETSET':self.getset,'EXPIRE':self.expire,'DEL':self.delete}[command]
except KeyError: print msg; raise
args=msg[... | python | def process_message(self,msg,sock):
"serialize and deserialize"
command=msg[0]
try: f={'GET':self.get,'SET':self.set,'SUBSCRIBE':self.sub,'PUBLISH':self.pub,
'PING':self.ping,'GETSET':self.getset,'EXPIRE':self.expire,'DEL':self.delete}[command]
except KeyError: print msg; raise
args=msg[... | [
"def",
"process_message",
"(",
"self",
",",
"msg",
",",
"sock",
")",
":",
"command",
"=",
"msg",
"[",
"0",
"]",
"try",
":",
"f",
"=",
"{",
"'GET'",
":",
"self",
".",
"get",
",",
"'SET'",
":",
"self",
".",
"set",
",",
"'SUBSCRIBE'",
":",
"self",
... | serialize and deserialize | [
"serialize",
"and",
"deserialize"
] | c78806f99f35541a8756987e86edca3438aa97f5 | https://github.com/abe-winter/pg13-py/blob/c78806f99f35541a8756987e86edca3438aa97f5/pg13/stubredis.py#L22-L33 |
250,028 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook._load_playbook_from_file | def _load_playbook_from_file(self, path, vars={}):
'''
run top level error checking on playbooks and allow them to include other playbooks.
'''
playbook_data = utils.parse_yaml_from_file(path)
accumulated_plays = []
play_basedirs = []
if type(playbook_data) != ... | python | def _load_playbook_from_file(self, path, vars={}):
'''
run top level error checking on playbooks and allow them to include other playbooks.
'''
playbook_data = utils.parse_yaml_from_file(path)
accumulated_plays = []
play_basedirs = []
if type(playbook_data) != ... | [
"def",
"_load_playbook_from_file",
"(",
"self",
",",
"path",
",",
"vars",
"=",
"{",
"}",
")",
":",
"playbook_data",
"=",
"utils",
".",
"parse_yaml_from_file",
"(",
"path",
")",
"accumulated_plays",
"=",
"[",
"]",
"play_basedirs",
"=",
"[",
"]",
"if",
"type... | run top level error checking on playbooks and allow them to include other playbooks. | [
"run",
"top",
"level",
"error",
"checking",
"on",
"playbooks",
"and",
"allow",
"them",
"to",
"include",
"other",
"playbooks",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L125-L186 |
250,029 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook.run | def run(self):
''' run all patterns in the playbook '''
plays = []
matched_tags_all = set()
unmatched_tags_all = set()
# loop through all patterns and run them
self.callbacks.on_start()
for (play_ds, play_basedir) in zip(self.playbook, self.play_basedirs):
... | python | def run(self):
''' run all patterns in the playbook '''
plays = []
matched_tags_all = set()
unmatched_tags_all = set()
# loop through all patterns and run them
self.callbacks.on_start()
for (play_ds, play_basedir) in zip(self.playbook, self.play_basedirs):
... | [
"def",
"run",
"(",
"self",
")",
":",
"plays",
"=",
"[",
"]",
"matched_tags_all",
"=",
"set",
"(",
")",
"unmatched_tags_all",
"=",
"set",
"(",
")",
"# loop through all patterns and run them",
"self",
".",
"callbacks",
".",
"on_start",
"(",
")",
"for",
"(",
... | run all patterns in the playbook | [
"run",
"all",
"patterns",
"in",
"the",
"playbook"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L190-L229 |
250,030 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook._async_poll | def _async_poll(self, poller, async_seconds, async_poll_interval):
''' launch an async job, if poll_interval is set, wait for completion '''
results = poller.wait(async_seconds, async_poll_interval)
# mark any hosts that are still listed as started as failed
# since these likely got ki... | python | def _async_poll(self, poller, async_seconds, async_poll_interval):
''' launch an async job, if poll_interval is set, wait for completion '''
results = poller.wait(async_seconds, async_poll_interval)
# mark any hosts that are still listed as started as failed
# since these likely got ki... | [
"def",
"_async_poll",
"(",
"self",
",",
"poller",
",",
"async_seconds",
",",
"async_poll_interval",
")",
":",
"results",
"=",
"poller",
".",
"wait",
"(",
"async_seconds",
",",
"async_poll_interval",
")",
"# mark any hosts that are still listed as started as failed",
"# ... | launch an async job, if poll_interval is set, wait for completion | [
"launch",
"an",
"async",
"job",
"if",
"poll_interval",
"is",
"set",
"wait",
"for",
"completion"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L233-L245 |
250,031 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook._list_available_hosts | def _list_available_hosts(self, *args):
''' returns a list of hosts that haven't failed and aren't dark '''
return [ h for h in self.inventory.list_hosts(*args) if (h not in self.stats.failures) and (h not in self.stats.dark)] | python | def _list_available_hosts(self, *args):
''' returns a list of hosts that haven't failed and aren't dark '''
return [ h for h in self.inventory.list_hosts(*args) if (h not in self.stats.failures) and (h not in self.stats.dark)] | [
"def",
"_list_available_hosts",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"[",
"h",
"for",
"h",
"in",
"self",
".",
"inventory",
".",
"list_hosts",
"(",
"*",
"args",
")",
"if",
"(",
"h",
"not",
"in",
"self",
".",
"stats",
".",
"failures",
"... | returns a list of hosts that haven't failed and aren't dark | [
"returns",
"a",
"list",
"of",
"hosts",
"that",
"haven",
"t",
"failed",
"and",
"aren",
"t",
"dark"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L249-L252 |
250,032 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook._run_task_internal | def _run_task_internal(self, task):
''' run a particular module step in a playbook '''
hosts = self._list_available_hosts()
self.inventory.restrict_to(hosts)
runner = cirruscluster.ext.ansible.runner.Runner(
pattern=task.play.hosts, inventory=self.inventory, module_name=tas... | python | def _run_task_internal(self, task):
''' run a particular module step in a playbook '''
hosts = self._list_available_hosts()
self.inventory.restrict_to(hosts)
runner = cirruscluster.ext.ansible.runner.Runner(
pattern=task.play.hosts, inventory=self.inventory, module_name=tas... | [
"def",
"_run_task_internal",
"(",
"self",
",",
"task",
")",
":",
"hosts",
"=",
"self",
".",
"_list_available_hosts",
"(",
")",
"self",
".",
"inventory",
".",
"restrict_to",
"(",
"hosts",
")",
"runner",
"=",
"cirruscluster",
".",
"ext",
".",
"ansible",
".",... | run a particular module step in a playbook | [
"run",
"a",
"particular",
"module",
"step",
"in",
"a",
"playbook"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L256-L293 |
250,033 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook._run_task | def _run_task(self, play, task, is_handler):
''' run a single task in the playbook and recursively run any subtasks. '''
self.callbacks.on_task_start(utils.template(play.basedir, task.name, task.module_vars, lookup_fatal=False), is_handler)
# load up an appropriate ansible runner to run the t... | python | def _run_task(self, play, task, is_handler):
''' run a single task in the playbook and recursively run any subtasks. '''
self.callbacks.on_task_start(utils.template(play.basedir, task.name, task.module_vars, lookup_fatal=False), is_handler)
# load up an appropriate ansible runner to run the t... | [
"def",
"_run_task",
"(",
"self",
",",
"play",
",",
"task",
",",
"is_handler",
")",
":",
"self",
".",
"callbacks",
".",
"on_task_start",
"(",
"utils",
".",
"template",
"(",
"play",
".",
"basedir",
",",
"task",
".",
"name",
",",
"task",
".",
"module_vars... | run a single task in the playbook and recursively run any subtasks. | [
"run",
"a",
"single",
"task",
"in",
"the",
"playbook",
"and",
"recursively",
"run",
"any",
"subtasks",
"."
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L297-L335 |
250,034 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook._flag_handler | def _flag_handler(self, play, handler_name, host):
'''
if a task has any notify elements, flag handlers for run
at end of execution cycle for hosts that have indicated
changes have been made
'''
found = False
for x in play.handlers():
if handler_name ... | python | def _flag_handler(self, play, handler_name, host):
'''
if a task has any notify elements, flag handlers for run
at end of execution cycle for hosts that have indicated
changes have been made
'''
found = False
for x in play.handlers():
if handler_name ... | [
"def",
"_flag_handler",
"(",
"self",
",",
"play",
",",
"handler_name",
",",
"host",
")",
":",
"found",
"=",
"False",
"for",
"x",
"in",
"play",
".",
"handlers",
"(",
")",
":",
"if",
"handler_name",
"==",
"utils",
".",
"template",
"(",
"play",
".",
"ba... | if a task has any notify elements, flag handlers for run
at end of execution cycle for hosts that have indicated
changes have been made | [
"if",
"a",
"task",
"has",
"any",
"notify",
"elements",
"flag",
"handlers",
"for",
"run",
"at",
"end",
"of",
"execution",
"cycle",
"for",
"hosts",
"that",
"have",
"indicated",
"changes",
"have",
"been",
"made"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L339-L353 |
250,035 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook._do_setup_step | def _do_setup_step(self, play):
''' get facts from the remote system '''
host_list = self._list_available_hosts(play.hosts)
if play.gather_facts is False:
return {}
elif play.gather_facts is None:
host_list = [h for h in host_list if h not in self.SETUP_CACHE or... | python | def _do_setup_step(self, play):
''' get facts from the remote system '''
host_list = self._list_available_hosts(play.hosts)
if play.gather_facts is False:
return {}
elif play.gather_facts is None:
host_list = [h for h in host_list if h not in self.SETUP_CACHE or... | [
"def",
"_do_setup_step",
"(",
"self",
",",
"play",
")",
":",
"host_list",
"=",
"self",
".",
"_list_available_hosts",
"(",
"play",
".",
"hosts",
")",
"if",
"play",
".",
"gather_facts",
"is",
"False",
":",
"return",
"{",
"}",
"elif",
"play",
".",
"gather_f... | get facts from the remote system | [
"get",
"facts",
"from",
"the",
"remote",
"system"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L357-L391 |
250,036 | cirruscluster/cirruscluster | cirruscluster/ext/ansible/playbook/__init__.py | PlayBook._run_play | def _run_play(self, play):
''' run a list of tasks for a given pattern, in order '''
self.callbacks.on_play_start(play.name)
# if no hosts matches this play, drop out
if not self.inventory.list_hosts(play.hosts):
self.callbacks.on_no_hosts_matched()
return True
... | python | def _run_play(self, play):
''' run a list of tasks for a given pattern, in order '''
self.callbacks.on_play_start(play.name)
# if no hosts matches this play, drop out
if not self.inventory.list_hosts(play.hosts):
self.callbacks.on_no_hosts_matched()
return True
... | [
"def",
"_run_play",
"(",
"self",
",",
"play",
")",
":",
"self",
".",
"callbacks",
".",
"on_play_start",
"(",
"play",
".",
"name",
")",
"# if no hosts matches this play, drop out",
"if",
"not",
"self",
".",
"inventory",
".",
"list_hosts",
"(",
"play",
".",
"h... | run a list of tasks for a given pattern, in order | [
"run",
"a",
"list",
"of",
"tasks",
"for",
"a",
"given",
"pattern",
"in",
"order"
] | 977409929dd81322d886425cdced10608117d5d7 | https://github.com/cirruscluster/cirruscluster/blob/977409929dd81322d886425cdced10608117d5d7/cirruscluster/ext/ansible/playbook/__init__.py#L395-L461 |
250,037 | bwesterb/mirte | src/main.py | parse_cmdLine_instructions | def parse_cmdLine_instructions(args):
""" Parses command-line arguments. These are
instruction to the manager to create instances and
put settings. """
instructions = dict()
rargs = list()
for arg in args:
if arg[:2] == '--':
tmp = arg[2:]
bits = tmp.spli... | python | def parse_cmdLine_instructions(args):
""" Parses command-line arguments. These are
instruction to the manager to create instances and
put settings. """
instructions = dict()
rargs = list()
for arg in args:
if arg[:2] == '--':
tmp = arg[2:]
bits = tmp.spli... | [
"def",
"parse_cmdLine_instructions",
"(",
"args",
")",
":",
"instructions",
"=",
"dict",
"(",
")",
"rargs",
"=",
"list",
"(",
")",
"for",
"arg",
"in",
"args",
":",
"if",
"arg",
"[",
":",
"2",
"]",
"==",
"'--'",
":",
"tmp",
"=",
"arg",
"[",
"2",
"... | Parses command-line arguments. These are
instruction to the manager to create instances and
put settings. | [
"Parses",
"command",
"-",
"line",
"arguments",
".",
"These",
"are",
"instruction",
"to",
"the",
"manager",
"to",
"create",
"instances",
"and",
"put",
"settings",
"."
] | c58db8c993cd15ffdc64b52703cd466213913200 | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/main.py#L14-L29 |
250,038 | bwesterb/mirte | src/main.py | main | def main():
""" Entry-point """
sarah.coloredLogging.basicConfig(level=logging.DEBUG,
formatter=MirteFormatter())
l = logging.getLogger('mirte')
instructions, args = parse_cmdLine_instructions(sys.argv[1:])
m = Manager(l)
load_mirteFile(args[0] if args else '... | python | def main():
""" Entry-point """
sarah.coloredLogging.basicConfig(level=logging.DEBUG,
formatter=MirteFormatter())
l = logging.getLogger('mirte')
instructions, args = parse_cmdLine_instructions(sys.argv[1:])
m = Manager(l)
load_mirteFile(args[0] if args else '... | [
"def",
"main",
"(",
")",
":",
"sarah",
".",
"coloredLogging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"DEBUG",
",",
"formatter",
"=",
"MirteFormatter",
"(",
")",
")",
"l",
"=",
"logging",
".",
"getLogger",
"(",
"'mirte'",
")",
"instruction... | Entry-point | [
"Entry",
"-",
"point"
] | c58db8c993cd15ffdc64b52703cd466213913200 | https://github.com/bwesterb/mirte/blob/c58db8c993cd15ffdc64b52703cd466213913200/src/main.py#L86-L95 |
250,039 | minhhoit/yacms | yacms/pages/middleware.py | PageMiddleware.installed | def installed(cls):
"""
Used in ``yacms.pages.views.page`` to ensure
``PageMiddleware`` or a subclass has been installed. We cache
the result on the ``PageMiddleware._installed`` to only run
this once. Short path is to just check for the dotted path to
``PageMiddleware`` ... | python | def installed(cls):
"""
Used in ``yacms.pages.views.page`` to ensure
``PageMiddleware`` or a subclass has been installed. We cache
the result on the ``PageMiddleware._installed`` to only run
this once. Short path is to just check for the dotted path to
``PageMiddleware`` ... | [
"def",
"installed",
"(",
"cls",
")",
":",
"try",
":",
"return",
"cls",
".",
"_installed",
"except",
"AttributeError",
":",
"name",
"=",
"\"yacms.pages.middleware.PageMiddleware\"",
"mw_setting",
"=",
"get_middleware_setting",
"(",
")",
"installed",
"=",
"name",
"i... | Used in ``yacms.pages.views.page`` to ensure
``PageMiddleware`` or a subclass has been installed. We cache
the result on the ``PageMiddleware._installed`` to only run
this once. Short path is to just check for the dotted path to
``PageMiddleware`` in ``MIDDLEWARE_CLASSES`` - if not found... | [
"Used",
"in",
"yacms",
".",
"pages",
".",
"views",
".",
"page",
"to",
"ensure",
"PageMiddleware",
"or",
"a",
"subclass",
"has",
"been",
"installed",
".",
"We",
"cache",
"the",
"result",
"on",
"the",
"PageMiddleware",
".",
"_installed",
"to",
"only",
"run",... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/middleware.py#L43-L64 |
250,040 | minhhoit/yacms | yacms/pages/middleware.py | PageMiddleware.process_view | def process_view(self, request, view_func, view_args, view_kwargs):
"""
Per-request mechanics for the current page object.
"""
# Load the closest matching page by slug, and assign it to the
# request object. If none found, skip all further processing.
slug = path_to_slug... | python | def process_view(self, request, view_func, view_args, view_kwargs):
"""
Per-request mechanics for the current page object.
"""
# Load the closest matching page by slug, and assign it to the
# request object. If none found, skip all further processing.
slug = path_to_slug... | [
"def",
"process_view",
"(",
"self",
",",
"request",
",",
"view_func",
",",
"view_args",
",",
"view_kwargs",
")",
":",
"# Load the closest matching page by slug, and assign it to the",
"# request object. If none found, skip all further processing.",
"slug",
"=",
"path_to_slug",
... | Per-request mechanics for the current page object. | [
"Per",
"-",
"request",
"mechanics",
"for",
"the",
"current",
"page",
"object",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/pages/middleware.py#L66-L125 |
250,041 | tomprince/nomenclature | nomenclature/syscalls.py | unshare | def unshare(flags):
"""
Disassociate parts of the process execution context.
:param flags int: A bitmask that specifies which parts of the execution
context should be unshared.
"""
res = lib.unshare(flags)
if res != 0:
_check_error(ffi.errno) | python | def unshare(flags):
"""
Disassociate parts of the process execution context.
:param flags int: A bitmask that specifies which parts of the execution
context should be unshared.
"""
res = lib.unshare(flags)
if res != 0:
_check_error(ffi.errno) | [
"def",
"unshare",
"(",
"flags",
")",
":",
"res",
"=",
"lib",
".",
"unshare",
"(",
"flags",
")",
"if",
"res",
"!=",
"0",
":",
"_check_error",
"(",
"ffi",
".",
"errno",
")"
] | Disassociate parts of the process execution context.
:param flags int: A bitmask that specifies which parts of the execution
context should be unshared. | [
"Disassociate",
"parts",
"of",
"the",
"process",
"execution",
"context",
"."
] | 81af4a590034f75211f028d485c0d83fceda5af2 | https://github.com/tomprince/nomenclature/blob/81af4a590034f75211f028d485c0d83fceda5af2/nomenclature/syscalls.py#L15-L24 |
250,042 | tomprince/nomenclature | nomenclature/syscalls.py | setns | def setns(fd, nstype):
"""
Reassociate thread with a namespace
:param fd int: The file descriptor referreing to one of the namespace
entries in a :directory::`/proc/<pid>/ns/` directory.
:param nstype int: The type of namespace the calling thread should be
reasscoiated with.
"""
... | python | def setns(fd, nstype):
"""
Reassociate thread with a namespace
:param fd int: The file descriptor referreing to one of the namespace
entries in a :directory::`/proc/<pid>/ns/` directory.
:param nstype int: The type of namespace the calling thread should be
reasscoiated with.
"""
... | [
"def",
"setns",
"(",
"fd",
",",
"nstype",
")",
":",
"res",
"=",
"lib",
".",
"setns",
"(",
"fd",
",",
"nstype",
")",
"if",
"res",
"!=",
"0",
":",
"_check_error",
"(",
"ffi",
".",
"errno",
")"
] | Reassociate thread with a namespace
:param fd int: The file descriptor referreing to one of the namespace
entries in a :directory::`/proc/<pid>/ns/` directory.
:param nstype int: The type of namespace the calling thread should be
reasscoiated with. | [
"Reassociate",
"thread",
"with",
"a",
"namespace"
] | 81af4a590034f75211f028d485c0d83fceda5af2 | https://github.com/tomprince/nomenclature/blob/81af4a590034f75211f028d485c0d83fceda5af2/nomenclature/syscalls.py#L27-L38 |
250,043 | xtrementl/focus | focus/task.py | Task._reset | def _reset(self):
""" Resets class properties.
"""
self._name = None
self._start_time = None
self._owner = os.getuid()
self._paths['task_dir'] = None
self._paths['task_config'] = None
self._loaded = False | python | def _reset(self):
""" Resets class properties.
"""
self._name = None
self._start_time = None
self._owner = os.getuid()
self._paths['task_dir'] = None
self._paths['task_config'] = None
self._loaded = False | [
"def",
"_reset",
"(",
"self",
")",
":",
"self",
".",
"_name",
"=",
"None",
"self",
".",
"_start_time",
"=",
"None",
"self",
".",
"_owner",
"=",
"os",
".",
"getuid",
"(",
")",
"self",
".",
"_paths",
"[",
"'task_dir'",
"]",
"=",
"None",
"self",
".",
... | Resets class properties. | [
"Resets",
"class",
"properties",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L51-L60 |
250,044 | xtrementl/focus | focus/task.py | Task._save_active_file | def _save_active_file(self):
""" Saves current task information to active file.
Example format::
active_task {
name "task name";
start_time "2012-04-23 15:18:22";
}
"""
_parser = parser.SettingParser()
... | python | def _save_active_file(self):
""" Saves current task information to active file.
Example format::
active_task {
name "task name";
start_time "2012-04-23 15:18:22";
}
"""
_parser = parser.SettingParser()
... | [
"def",
"_save_active_file",
"(",
"self",
")",
":",
"_parser",
"=",
"parser",
".",
"SettingParser",
"(",
")",
"# add name",
"_parser",
".",
"add_option",
"(",
"None",
",",
"'name'",
",",
"common",
".",
"to_utf8",
"(",
"self",
".",
"_name",
")",
")",
"# ad... | Saves current task information to active file.
Example format::
active_task {
name "task name";
start_time "2012-04-23 15:18:22";
} | [
"Saves",
"current",
"task",
"information",
"to",
"active",
"file",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L73-L94 |
250,045 | xtrementl/focus | focus/task.py | Task._clean_prior | def _clean_prior(self):
""" Cleans up from a previous task that didn't exit cleanly.
Returns ``True`` if previous task was cleaned.
"""
if self._loaded:
try:
pid_file = daemon.get_daemon_pidfile(self)
# check if it exists so we don't... | python | def _clean_prior(self):
""" Cleans up from a previous task that didn't exit cleanly.
Returns ``True`` if previous task was cleaned.
"""
if self._loaded:
try:
pid_file = daemon.get_daemon_pidfile(self)
# check if it exists so we don't... | [
"def",
"_clean_prior",
"(",
"self",
")",
":",
"if",
"self",
".",
"_loaded",
":",
"try",
":",
"pid_file",
"=",
"daemon",
".",
"get_daemon_pidfile",
"(",
"self",
")",
"# check if it exists so we don't raise",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"pid_f... | Cleans up from a previous task that didn't exit cleanly.
Returns ``True`` if previous task was cleaned. | [
"Cleans",
"up",
"from",
"a",
"previous",
"task",
"that",
"didn",
"t",
"exit",
"cleanly",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L96-L120 |
250,046 | xtrementl/focus | focus/task.py | Task.load | def load(self):
""" Loads a task if the active file is available.
"""
try:
_parser = parser.parse_config(self._paths['active_file'],
self.HEADER_ACTIVE_FILE)
# parse expected options into a dict to de-dupe
keys =... | python | def load(self):
""" Loads a task if the active file is available.
"""
try:
_parser = parser.parse_config(self._paths['active_file'],
self.HEADER_ACTIVE_FILE)
# parse expected options into a dict to de-dupe
keys =... | [
"def",
"load",
"(",
"self",
")",
":",
"try",
":",
"_parser",
"=",
"parser",
".",
"parse_config",
"(",
"self",
".",
"_paths",
"[",
"'active_file'",
"]",
",",
"self",
".",
"HEADER_ACTIVE_FILE",
")",
"# parse expected options into a dict to de-dupe",
"keys",
"=",
... | Loads a task if the active file is available. | [
"Loads",
"a",
"task",
"if",
"the",
"active",
"file",
"is",
"available",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L129-L177 |
250,047 | xtrementl/focus | focus/task.py | Task.exists | def exists(self, task_name):
""" Determines if task directory exists.
`task_name`
Task name.
Returns ``True`` if task exists.
"""
try:
return os.path.exists(self._get_task_dir(task_name))
except OSError:
return False | python | def exists(self, task_name):
""" Determines if task directory exists.
`task_name`
Task name.
Returns ``True`` if task exists.
"""
try:
return os.path.exists(self._get_task_dir(task_name))
except OSError:
return False | [
"def",
"exists",
"(",
"self",
",",
"task_name",
")",
":",
"try",
":",
"return",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"_get_task_dir",
"(",
"task_name",
")",
")",
"except",
"OSError",
":",
"return",
"False"
] | Determines if task directory exists.
`task_name`
Task name.
Returns ``True`` if task exists. | [
"Determines",
"if",
"task",
"directory",
"exists",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L179-L192 |
250,048 | xtrementl/focus | focus/task.py | Task.create | def create(self, task_name, clone_task=None):
""" Creates a new task directory.
`task_name`
Task name.
`clone_task`
Existing task name to use as a template for new task.
Returns boolean.
* Raises ``Value`` if task name is invalid... | python | def create(self, task_name, clone_task=None):
""" Creates a new task directory.
`task_name`
Task name.
`clone_task`
Existing task name to use as a template for new task.
Returns boolean.
* Raises ``Value`` if task name is invalid... | [
"def",
"create",
"(",
"self",
",",
"task_name",
",",
"clone_task",
"=",
"None",
")",
":",
"if",
"not",
"task_name",
"or",
"task_name",
".",
"startswith",
"(",
"'-'",
")",
":",
"raise",
"ValueError",
"(",
"'Invalid task name'",
")",
"try",
":",
"task_dir",
... | Creates a new task directory.
`task_name`
Task name.
`clone_task`
Existing task name to use as a template for new task.
Returns boolean.
* Raises ``Value`` if task name is invalid, ``TaskExists`` if task
already exists, or ... | [
"Creates",
"a",
"new",
"task",
"directory",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L205-L248 |
250,049 | xtrementl/focus | focus/task.py | Task.rename | def rename(self, old_task_name, new_task_name):
""" Renames an existing task directory.
`old_task_name`
Current task name.
`new_task_name`
New task name.
Returns ``True`` if rename successful.
"""
if not old_task_name or ... | python | def rename(self, old_task_name, new_task_name):
""" Renames an existing task directory.
`old_task_name`
Current task name.
`new_task_name`
New task name.
Returns ``True`` if rename successful.
"""
if not old_task_name or ... | [
"def",
"rename",
"(",
"self",
",",
"old_task_name",
",",
"new_task_name",
")",
":",
"if",
"not",
"old_task_name",
"or",
"old_task_name",
".",
"startswith",
"(",
"'-'",
")",
":",
"raise",
"ValueError",
"(",
"'Old task name is invalid'",
")",
"if",
"not",
"new_t... | Renames an existing task directory.
`old_task_name`
Current task name.
`new_task_name`
New task name.
Returns ``True`` if rename successful. | [
"Renames",
"an",
"existing",
"task",
"directory",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L250-L283 |
250,050 | xtrementl/focus | focus/task.py | Task.remove | def remove(self, task_name):
""" Removes an existing task directory.
`task_name`
Task name.
Returns ``True`` if removal successful.
"""
try:
task_dir = self._get_task_dir(task_name)
shutil.rmtree(task_dir)
return ... | python | def remove(self, task_name):
""" Removes an existing task directory.
`task_name`
Task name.
Returns ``True`` if removal successful.
"""
try:
task_dir = self._get_task_dir(task_name)
shutil.rmtree(task_dir)
return ... | [
"def",
"remove",
"(",
"self",
",",
"task_name",
")",
":",
"try",
":",
"task_dir",
"=",
"self",
".",
"_get_task_dir",
"(",
"task_name",
")",
"shutil",
".",
"rmtree",
"(",
"task_dir",
")",
"return",
"True",
"except",
"OSError",
":",
"return",
"False"
] | Removes an existing task directory.
`task_name`
Task name.
Returns ``True`` if removal successful. | [
"Removes",
"an",
"existing",
"task",
"directory",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L285-L300 |
250,051 | xtrementl/focus | focus/task.py | Task.get_list_info | def get_list_info(self, task_name=None):
""" Lists all tasks and associated information.
`task_name`
Task name to limit. Default: return all valid tasks.
Returns list of tuples (task_name, options, block_options)
"""
try:
tasks = []
... | python | def get_list_info(self, task_name=None):
""" Lists all tasks and associated information.
`task_name`
Task name to limit. Default: return all valid tasks.
Returns list of tuples (task_name, options, block_options)
"""
try:
tasks = []
... | [
"def",
"get_list_info",
"(",
"self",
",",
"task_name",
"=",
"None",
")",
":",
"try",
":",
"tasks",
"=",
"[",
"]",
"# get all tasks dirs",
"tasks_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_paths",
"[",
"'base_dir'",
"]",
",",
"'tasks... | Lists all tasks and associated information.
`task_name`
Task name to limit. Default: return all valid tasks.
Returns list of tuples (task_name, options, block_options) | [
"Lists",
"all",
"tasks",
"and",
"associated",
"information",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L302-L345 |
250,052 | xtrementl/focus | focus/task.py | Task.start | def start(self, task_name):
""" Starts a new task matching the provided name.
`task_name`
Name of existing task to start.
Returns boolean.
* Raises a ``TaskNotFound`` exception if task doesn't exist, an
``InvalidTaskConfig` exception if task c... | python | def start(self, task_name):
""" Starts a new task matching the provided name.
`task_name`
Name of existing task to start.
Returns boolean.
* Raises a ``TaskNotFound`` exception if task doesn't exist, an
``InvalidTaskConfig` exception if task c... | [
"def",
"start",
"(",
"self",
",",
"task_name",
")",
":",
"self",
".",
"_clean_prior",
"(",
")",
"if",
"self",
".",
"_loaded",
":",
"raise",
"errors",
".",
"ActiveTask",
"# get paths",
"task_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
... | Starts a new task matching the provided name.
`task_name`
Name of existing task to start.
Returns boolean.
* Raises a ``TaskNotFound`` exception if task doesn't exist, an
``InvalidTaskConfig` exception if task config file is invalid, or
... | [
"Starts",
"a",
"new",
"task",
"matching",
"the",
"provided",
"name",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L347-L417 |
250,053 | xtrementl/focus | focus/task.py | Task.stop | def stop(self):
""" Stops the current task and cleans up, including removing active
task config file.
* Raises ``NoActiveTask`` exception if no active task found.
"""
self._clean_prior()
if not self._loaded:
raise errors.NoActiveTask
se... | python | def stop(self):
""" Stops the current task and cleans up, including removing active
task config file.
* Raises ``NoActiveTask`` exception if no active task found.
"""
self._clean_prior()
if not self._loaded:
raise errors.NoActiveTask
se... | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"_clean_prior",
"(",
")",
"if",
"not",
"self",
".",
"_loaded",
":",
"raise",
"errors",
".",
"NoActiveTask",
"self",
".",
"_clean",
"(",
")"
] | Stops the current task and cleans up, including removing active
task config file.
* Raises ``NoActiveTask`` exception if no active task found. | [
"Stops",
"the",
"current",
"task",
"and",
"cleans",
"up",
"including",
"removing",
"active",
"task",
"config",
"file",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L419-L431 |
250,054 | xtrementl/focus | focus/task.py | Task.set_total_duration | def set_total_duration(self, duration):
""" Set the total task duration in minutes.
"""
if duration < 1:
raise ValueError(u'Duration must be postive')
elif self.duration > duration:
raise ValueError(u'{0} must be greater than current duration')
self.... | python | def set_total_duration(self, duration):
""" Set the total task duration in minutes.
"""
if duration < 1:
raise ValueError(u'Duration must be postive')
elif self.duration > duration:
raise ValueError(u'{0} must be greater than current duration')
self.... | [
"def",
"set_total_duration",
"(",
"self",
",",
"duration",
")",
":",
"if",
"duration",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"u'Duration must be postive'",
")",
"elif",
"self",
".",
"duration",
">",
"duration",
":",
"raise",
"ValueError",
"(",
"u'{0} must... | Set the total task duration in minutes. | [
"Set",
"the",
"total",
"task",
"duration",
"in",
"minutes",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L433-L442 |
250,055 | xtrementl/focus | focus/task.py | Task.active | def active(self):
""" Returns if task is active.
"""
if not os.path.isfile(self._paths['active_file']):
return False
return self._loaded | python | def active(self):
""" Returns if task is active.
"""
if not os.path.isfile(self._paths['active_file']):
return False
return self._loaded | [
"def",
"active",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"_paths",
"[",
"'active_file'",
"]",
")",
":",
"return",
"False",
"return",
"self",
".",
"_loaded"
] | Returns if task is active. | [
"Returns",
"if",
"task",
"is",
"active",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L454-L459 |
250,056 | xtrementl/focus | focus/task.py | Task.duration | def duration(self):
""" Returns task's current duration in minutes.
"""
if not self._loaded:
return 0
delta = datetime.datetime.now() - self._start_time
total_secs = (delta.microseconds +
(delta.seconds + delta.days * 24 * 3600) *
... | python | def duration(self):
""" Returns task's current duration in minutes.
"""
if not self._loaded:
return 0
delta = datetime.datetime.now() - self._start_time
total_secs = (delta.microseconds +
(delta.seconds + delta.days * 24 * 3600) *
... | [
"def",
"duration",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_loaded",
":",
"return",
"0",
"delta",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"-",
"self",
".",
"_start_time",
"total_secs",
"=",
"(",
"delta",
".",
"microseconds",
... | Returns task's current duration in minutes. | [
"Returns",
"task",
"s",
"current",
"duration",
"in",
"minutes",
"."
] | cbbbc0b49a7409f9e0dc899de5b7e057f50838e4 | https://github.com/xtrementl/focus/blob/cbbbc0b49a7409f9e0dc899de5b7e057f50838e4/focus/task.py#L474-L486 |
250,057 | heikomuller/sco-client | scocli/cli.py | SCOCmdLine.list_objects | def list_objects(self, resources):
"""Generate a listing for a set of resource handles consisting of
resource identifier, name, and timestamp.
Parameters
----------
resources : list(ResourceHandle)
List of resource handles
Returns
-------
lis... | python | def list_objects(self, resources):
"""Generate a listing for a set of resource handles consisting of
resource identifier, name, and timestamp.
Parameters
----------
resources : list(ResourceHandle)
List of resource handles
Returns
-------
lis... | [
"def",
"list_objects",
"(",
"self",
",",
"resources",
")",
":",
"result",
"=",
"[",
"]",
"for",
"res",
"in",
"resources",
":",
"result",
".",
"append",
"(",
"'\\t'",
".",
"join",
"(",
"[",
"res",
".",
"identifier",
",",
"res",
".",
"name",
",",
"st... | Generate a listing for a set of resource handles consisting of
resource identifier, name, and timestamp.
Parameters
----------
resources : list(ResourceHandle)
List of resource handles
Returns
-------
list(string) | [
"Generate",
"a",
"listing",
"for",
"a",
"set",
"of",
"resource",
"handles",
"consisting",
"of",
"resource",
"identifier",
"name",
"and",
"timestamp",
"."
] | c4afab71297f73003379bba4c1679be9dcf7cef8 | https://github.com/heikomuller/sco-client/blob/c4afab71297f73003379bba4c1679be9dcf7cef8/scocli/cli.py#L49-L65 |
250,058 | klen/muffin-babel | example/__init__.py | set_locale | def set_locale(request):
"""Return locale from GET lang param or automatically."""
return request.query.get('lang', app.ps.babel.select_locale_by_request(request)) | python | def set_locale(request):
"""Return locale from GET lang param or automatically."""
return request.query.get('lang', app.ps.babel.select_locale_by_request(request)) | [
"def",
"set_locale",
"(",
"request",
")",
":",
"return",
"request",
".",
"query",
".",
"get",
"(",
"'lang'",
",",
"app",
".",
"ps",
".",
"babel",
".",
"select_locale_by_request",
"(",
"request",
")",
")"
] | Return locale from GET lang param or automatically. | [
"Return",
"locale",
"from",
"GET",
"lang",
"param",
"or",
"automatically",
"."
] | f48ebbbf7806c6c727f66d8d0df331b29f6ead08 | https://github.com/klen/muffin-babel/blob/f48ebbbf7806c6c727f66d8d0df331b29f6ead08/example/__init__.py#L26-L28 |
250,059 | MitalAshok/objecttools | objecttools/serializable.py | SerializableFunction.globals | def globals(self):
"""Find the globals of `self` by importing `self.module`"""
try:
return vars(__import__(self.module, fromlist=self.module.split('.')))
except ImportError:
if self.warn_import:
warnings.warn(ImportWarning(
'Cannot impo... | python | def globals(self):
"""Find the globals of `self` by importing `self.module`"""
try:
return vars(__import__(self.module, fromlist=self.module.split('.')))
except ImportError:
if self.warn_import:
warnings.warn(ImportWarning(
'Cannot impo... | [
"def",
"globals",
"(",
"self",
")",
":",
"try",
":",
"return",
"vars",
"(",
"__import__",
"(",
"self",
".",
"module",
",",
"fromlist",
"=",
"self",
".",
"module",
".",
"split",
"(",
"'.'",
")",
")",
")",
"except",
"ImportError",
":",
"if",
"self",
... | Find the globals of `self` by importing `self.module` | [
"Find",
"the",
"globals",
"of",
"self",
"by",
"importing",
"self",
".",
"module"
] | bddd14d1f702c8b559d3fcc2099bc22370e16de7 | https://github.com/MitalAshok/objecttools/blob/bddd14d1f702c8b559d3fcc2099bc22370e16de7/objecttools/serializable.py#L161-L170 |
250,060 | MitalAshok/objecttools | objecttools/serializable.py | SerializableConstant.value | def value(self):
"""Import the constant from `self.module`"""
module = __import__(self.module, fromlist=self.module.split('.'))
if self.name is None:
return module
return getattr(module, self.name) | python | def value(self):
"""Import the constant from `self.module`"""
module = __import__(self.module, fromlist=self.module.split('.'))
if self.name is None:
return module
return getattr(module, self.name) | [
"def",
"value",
"(",
"self",
")",
":",
"module",
"=",
"__import__",
"(",
"self",
".",
"module",
",",
"fromlist",
"=",
"self",
".",
"module",
".",
"split",
"(",
"'.'",
")",
")",
"if",
"self",
".",
"name",
"is",
"None",
":",
"return",
"module",
"retu... | Import the constant from `self.module` | [
"Import",
"the",
"constant",
"from",
"self",
".",
"module"
] | bddd14d1f702c8b559d3fcc2099bc22370e16de7 | https://github.com/MitalAshok/objecttools/blob/bddd14d1f702c8b559d3fcc2099bc22370e16de7/objecttools/serializable.py#L260-L265 |
250,061 | emlazzarin/acrylic | acrylic/groupby.py | GroupbyTable.agg | def agg(self, func, *fields, **name):
"""
Calls the aggregation function `func` on each group in the GroubyTable,
and leaves the results in a new column with the name of the aggregation
function.
Call `.agg` with `name='desired_column_name' to choose a column
name for th... | python | def agg(self, func, *fields, **name):
"""
Calls the aggregation function `func` on each group in the GroubyTable,
and leaves the results in a new column with the name of the aggregation
function.
Call `.agg` with `name='desired_column_name' to choose a column
name for th... | [
"def",
"agg",
"(",
"self",
",",
"func",
",",
"*",
"fields",
",",
"*",
"*",
"name",
")",
":",
"if",
"name",
":",
"if",
"len",
"(",
"name",
")",
">",
"1",
"or",
"'name'",
"not",
"in",
"name",
":",
"raise",
"TypeError",
"(",
"\"Unknown keyword args pa... | Calls the aggregation function `func` on each group in the GroubyTable,
and leaves the results in a new column with the name of the aggregation
function.
Call `.agg` with `name='desired_column_name' to choose a column
name for this aggregation. | [
"Calls",
"the",
"aggregation",
"function",
"func",
"on",
"each",
"group",
"in",
"the",
"GroubyTable",
"and",
"leaves",
"the",
"results",
"in",
"a",
"new",
"column",
"with",
"the",
"name",
"of",
"the",
"aggregation",
"function",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/groupby.py#L71-L117 |
250,062 | emlazzarin/acrylic | acrylic/groupby.py | GroupbyTable.collect | def collect(self):
"""
After adding the desired aggregation columns, `collect`
finalizes the groupby operation by converting the
GroupbyTable into a DataTable.
The first columns of the resulting table are the groupfields,
followed by the aggregation columns specified in ... | python | def collect(self):
"""
After adding the desired aggregation columns, `collect`
finalizes the groupby operation by converting the
GroupbyTable into a DataTable.
The first columns of the resulting table are the groupfields,
followed by the aggregation columns specified in ... | [
"def",
"collect",
"(",
"self",
")",
":",
"# The final order of columns is determined by the",
"# group keys and the aggregation columns",
"final_field_order",
"=",
"list",
"(",
"self",
".",
"__groupfields",
")",
"+",
"self",
".",
"__grouptable",
".",
"fields",
"# Transfor... | After adding the desired aggregation columns, `collect`
finalizes the groupby operation by converting the
GroupbyTable into a DataTable.
The first columns of the resulting table are the groupfields,
followed by the aggregation columns specified in preceeding
`agg` calls. | [
"After",
"adding",
"the",
"desired",
"aggregation",
"columns",
"collect",
"finalizes",
"the",
"groupby",
"operation",
"by",
"converting",
"the",
"GroupbyTable",
"into",
"a",
"DataTable",
"."
] | 08c6702d73b9660ead1024653f4fa016f6340e46 | https://github.com/emlazzarin/acrylic/blob/08c6702d73b9660ead1024653f4fa016f6340e46/acrylic/groupby.py#L124-L149 |
250,063 | eisensheng/kaviar | kaviar/api.py | kv_format_dict | def kv_format_dict(d, keys=None, separator=DEFAULT_SEPARATOR):
"""Formats the given dictionary ``d``.
For more details see :func:`kv_format`.
:param collections.Mapping d:
Dictionary containing values to format.
:param collections.Iterable keys:
List of keys to extract from the dict.
... | python | def kv_format_dict(d, keys=None, separator=DEFAULT_SEPARATOR):
"""Formats the given dictionary ``d``.
For more details see :func:`kv_format`.
:param collections.Mapping d:
Dictionary containing values to format.
:param collections.Iterable keys:
List of keys to extract from the dict.
... | [
"def",
"kv_format_dict",
"(",
"d",
",",
"keys",
"=",
"None",
",",
"separator",
"=",
"DEFAULT_SEPARATOR",
")",
":",
"return",
"_format_pairs",
"(",
"dump_dict",
"(",
"d",
",",
"keys",
")",
",",
"separator",
"=",
"separator",
")"
] | Formats the given dictionary ``d``.
For more details see :func:`kv_format`.
:param collections.Mapping d:
Dictionary containing values to format.
:param collections.Iterable keys:
List of keys to extract from the dict.
:param str separator:
Value between two pairs.
:return:... | [
"Formats",
"the",
"given",
"dictionary",
"d",
"."
] | 77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f | https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/kaviar/api.py#L18-L34 |
250,064 | eisensheng/kaviar | kaviar/api.py | kv_format_object | def kv_format_object(o, keys=None, separator=DEFAULT_SEPARATOR):
"""Formats an object's attributes. Useful for object representation
implementation. Will skip methods or private attributes.
For more details see :func:`kv_format`.
:param o:
Object to format.
:param collections.Sequence ke... | python | def kv_format_object(o, keys=None, separator=DEFAULT_SEPARATOR):
"""Formats an object's attributes. Useful for object representation
implementation. Will skip methods or private attributes.
For more details see :func:`kv_format`.
:param o:
Object to format.
:param collections.Sequence ke... | [
"def",
"kv_format_object",
"(",
"o",
",",
"keys",
"=",
"None",
",",
"separator",
"=",
"DEFAULT_SEPARATOR",
")",
":",
"if",
"keys",
"is",
"None",
":",
"key_values",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"(",
"(",
"x",
",",
"getattr",
"(",
"o",
... | Formats an object's attributes. Useful for object representation
implementation. Will skip methods or private attributes.
For more details see :func:`kv_format`.
:param o:
Object to format.
:param collections.Sequence keys:
Explicit list of attributes to format. ``None`` means all p... | [
"Formats",
"an",
"object",
"s",
"attributes",
".",
"Useful",
"for",
"object",
"representation",
"implementation",
".",
"Will",
"skip",
"methods",
"or",
"private",
"attributes",
"."
] | 77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f | https://github.com/eisensheng/kaviar/blob/77ab934a3dd7b1cfabc0ec96acc0b8ed26edcb3f/kaviar/api.py#L54-L81 |
250,065 | praekeltfoundation/seed-service-rating | ratings/views.py | InviteSend.post | def post(self, request, *args, **kwargs):
""" Triggers the task that sends invitation messages
"""
status = 201
accepted = {"accepted": True}
send_invite_messages.apply_async()
return Response(accepted, status=status) | python | def post(self, request, *args, **kwargs):
""" Triggers the task that sends invitation messages
"""
status = 201
accepted = {"accepted": True}
send_invite_messages.apply_async()
return Response(accepted, status=status) | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"status",
"=",
"201",
"accepted",
"=",
"{",
"\"accepted\"",
":",
"True",
"}",
"send_invite_messages",
".",
"apply_async",
"(",
")",
"return",
"Response",
"... | Triggers the task that sends invitation messages | [
"Triggers",
"the",
"task",
"that",
"sends",
"invitation",
"messages"
] | 73f7974a5bcb6e1f32a756be5274b200084c2670 | https://github.com/praekeltfoundation/seed-service-rating/blob/73f7974a5bcb6e1f32a756be5274b200084c2670/ratings/views.py#L59-L65 |
250,066 | praekeltfoundation/seed-service-rating | ratings/views.py | UserView.post | def post(self, request):
'''Create a user and token, given an email. If user exists just
provide the token.'''
serializer = CreateUserSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
email = serializer.validated_data.get('email')
try:
u... | python | def post(self, request):
'''Create a user and token, given an email. If user exists just
provide the token.'''
serializer = CreateUserSerializer(data=request.data)
serializer.is_valid(raise_exception=True)
email = serializer.validated_data.get('email')
try:
u... | [
"def",
"post",
"(",
"self",
",",
"request",
")",
":",
"serializer",
"=",
"CreateUserSerializer",
"(",
"data",
"=",
"request",
".",
"data",
")",
"serializer",
".",
"is_valid",
"(",
"raise_exception",
"=",
"True",
")",
"email",
"=",
"serializer",
".",
"valid... | Create a user and token, given an email. If user exists just
provide the token. | [
"Create",
"a",
"user",
"and",
"token",
"given",
"an",
"email",
".",
"If",
"user",
"exists",
"just",
"provide",
"the",
"token",
"."
] | 73f7974a5bcb6e1f32a756be5274b200084c2670 | https://github.com/praekeltfoundation/seed-service-rating/blob/73f7974a5bcb6e1f32a756be5274b200084c2670/ratings/views.py#L94-L108 |
250,067 | djangomini/djangomini | djangomini/controllers.py | Controller.dispatch | def dispatch(self, request, *args, **kwargs):
"""
Redefine parent's method.
Called on each new request from user.
Main difference between Django's approach and ours - we don't push
a 'request' to a method call. We use 'self.request' instead.
"""
# this part copi... | python | def dispatch(self, request, *args, **kwargs):
"""
Redefine parent's method.
Called on each new request from user.
Main difference between Django's approach and ours - we don't push
a 'request' to a method call. We use 'self.request' instead.
"""
# this part copi... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# this part copied from django source code",
"if",
"request",
".",
"method",
".",
"lower",
"(",
")",
"in",
"self",
".",
"http_method_names",
":",
"handler",... | Redefine parent's method.
Called on each new request from user.
Main difference between Django's approach and ours - we don't push
a 'request' to a method call. We use 'self.request' instead. | [
"Redefine",
"parent",
"s",
"method",
"."
] | cfbe2d59acf0e89e5fd442df8952f9a117a63875 | https://github.com/djangomini/djangomini/blob/cfbe2d59acf0e89e5fd442df8952f9a117a63875/djangomini/controllers.py#L21-L37 |
250,068 | djangomini/djangomini | djangomini/controllers.py | Controller.html | def html(self, data=None, template=None):
"""
Send html document to user.
Args:
- data: Dict to render template, or string with rendered HTML.
- template: Name of template to render HTML document with passed data.
"""
if data is None:
data = {}
... | python | def html(self, data=None, template=None):
"""
Send html document to user.
Args:
- data: Dict to render template, or string with rendered HTML.
- template: Name of template to render HTML document with passed data.
"""
if data is None:
data = {}
... | [
"def",
"html",
"(",
"self",
",",
"data",
"=",
"None",
",",
"template",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"{",
"}",
"if",
"template",
":",
"return",
"render",
"(",
"self",
".",
"request",
",",
"template",
",",
"d... | Send html document to user.
Args:
- data: Dict to render template, or string with rendered HTML.
- template: Name of template to render HTML document with passed data. | [
"Send",
"html",
"document",
"to",
"user",
"."
] | cfbe2d59acf0e89e5fd442df8952f9a117a63875 | https://github.com/djangomini/djangomini/blob/cfbe2d59acf0e89e5fd442df8952f9a117a63875/djangomini/controllers.py#L39-L51 |
250,069 | OpenVolunteeringPlatform/django-ovp-search | ovp_search/filters.py | by_skills | def by_skills(queryset, skill_string=None):
""" Filter queryset by a comma delimeted skill list """
if skill_string:
operator, items = get_operator_and_items(skill_string)
q_obj = SQ()
for s in items:
if len(s) > 0:
q_obj.add(SQ(skills=s), operator)
queryset = queryset.filter(q_obj)
... | python | def by_skills(queryset, skill_string=None):
""" Filter queryset by a comma delimeted skill list """
if skill_string:
operator, items = get_operator_and_items(skill_string)
q_obj = SQ()
for s in items:
if len(s) > 0:
q_obj.add(SQ(skills=s), operator)
queryset = queryset.filter(q_obj)
... | [
"def",
"by_skills",
"(",
"queryset",
",",
"skill_string",
"=",
"None",
")",
":",
"if",
"skill_string",
":",
"operator",
",",
"items",
"=",
"get_operator_and_items",
"(",
"skill_string",
")",
"q_obj",
"=",
"SQ",
"(",
")",
"for",
"s",
"in",
"items",
":",
"... | Filter queryset by a comma delimeted skill list | [
"Filter",
"queryset",
"by",
"a",
"comma",
"delimeted",
"skill",
"list"
] | 003ceecc0a87be31fe8195f65367c52631f72b57 | https://github.com/OpenVolunteeringPlatform/django-ovp-search/blob/003ceecc0a87be31fe8195f65367c52631f72b57/ovp_search/filters.py#L78-L87 |
250,070 | OpenVolunteeringPlatform/django-ovp-search | ovp_search/filters.py | by_causes | def by_causes(queryset, cause_string=None):
""" Filter queryset by a comma delimeted cause list """
if cause_string:
operator, items = get_operator_and_items(cause_string)
q_obj = SQ()
for c in items:
if len(c) > 0:
q_obj.add(SQ(causes=c), operator)
queryset = queryset.filter(q_obj)
... | python | def by_causes(queryset, cause_string=None):
""" Filter queryset by a comma delimeted cause list """
if cause_string:
operator, items = get_operator_and_items(cause_string)
q_obj = SQ()
for c in items:
if len(c) > 0:
q_obj.add(SQ(causes=c), operator)
queryset = queryset.filter(q_obj)
... | [
"def",
"by_causes",
"(",
"queryset",
",",
"cause_string",
"=",
"None",
")",
":",
"if",
"cause_string",
":",
"operator",
",",
"items",
"=",
"get_operator_and_items",
"(",
"cause_string",
")",
"q_obj",
"=",
"SQ",
"(",
")",
"for",
"c",
"in",
"items",
":",
"... | Filter queryset by a comma delimeted cause list | [
"Filter",
"queryset",
"by",
"a",
"comma",
"delimeted",
"cause",
"list"
] | 003ceecc0a87be31fe8195f65367c52631f72b57 | https://github.com/OpenVolunteeringPlatform/django-ovp-search/blob/003ceecc0a87be31fe8195f65367c52631f72b57/ovp_search/filters.py#L90-L99 |
250,071 | OpenVolunteeringPlatform/django-ovp-search | ovp_search/filters.py | by_published | def by_published(queryset, published_string='true'):
""" Filter queryset by publish status """
if published_string == 'true':
queryset = queryset.filter(published=1)
elif published_string == 'false':
queryset = queryset.filter(published=0)
# Any other value will return both published and unpublished
r... | python | def by_published(queryset, published_string='true'):
""" Filter queryset by publish status """
if published_string == 'true':
queryset = queryset.filter(published=1)
elif published_string == 'false':
queryset = queryset.filter(published=0)
# Any other value will return both published and unpublished
r... | [
"def",
"by_published",
"(",
"queryset",
",",
"published_string",
"=",
"'true'",
")",
":",
"if",
"published_string",
"==",
"'true'",
":",
"queryset",
"=",
"queryset",
".",
"filter",
"(",
"published",
"=",
"1",
")",
"elif",
"published_string",
"==",
"'false'",
... | Filter queryset by publish status | [
"Filter",
"queryset",
"by",
"publish",
"status"
] | 003ceecc0a87be31fe8195f65367c52631f72b57 | https://github.com/OpenVolunteeringPlatform/django-ovp-search/blob/003ceecc0a87be31fe8195f65367c52631f72b57/ovp_search/filters.py#L102-L109 |
250,072 | OpenVolunteeringPlatform/django-ovp-search | ovp_search/filters.py | by_name | def by_name(queryset, name=None):
""" Filter queryset by name, with word wide auto-completion """
if name:
queryset = queryset.filter(name=name)
return queryset | python | def by_name(queryset, name=None):
""" Filter queryset by name, with word wide auto-completion """
if name:
queryset = queryset.filter(name=name)
return queryset | [
"def",
"by_name",
"(",
"queryset",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
":",
"queryset",
"=",
"queryset",
".",
"filter",
"(",
"name",
"=",
"name",
")",
"return",
"queryset"
] | Filter queryset by name, with word wide auto-completion | [
"Filter",
"queryset",
"by",
"name",
"with",
"word",
"wide",
"auto",
"-",
"completion"
] | 003ceecc0a87be31fe8195f65367c52631f72b57 | https://github.com/OpenVolunteeringPlatform/django-ovp-search/blob/003ceecc0a87be31fe8195f65367c52631f72b57/ovp_search/filters.py#L112-L116 |
250,073 | OpenVolunteeringPlatform/django-ovp-search | ovp_search/filters.py | by_address | def by_address(queryset, address='', project=False):
"""
Filter queryset by publish status.
If project=True, we also apply a project exclusive filter
"""
if address:
address = json.loads(address)
if u'address_components' in address:
q_objs = []
"""
Caribbean filter
"""
... | python | def by_address(queryset, address='', project=False):
"""
Filter queryset by publish status.
If project=True, we also apply a project exclusive filter
"""
if address:
address = json.loads(address)
if u'address_components' in address:
q_objs = []
"""
Caribbean filter
"""
... | [
"def",
"by_address",
"(",
"queryset",
",",
"address",
"=",
"''",
",",
"project",
"=",
"False",
")",
":",
"if",
"address",
":",
"address",
"=",
"json",
".",
"loads",
"(",
"address",
")",
"if",
"u'address_components'",
"in",
"address",
":",
"q_objs",
"=",
... | Filter queryset by publish status.
If project=True, we also apply a project exclusive filter | [
"Filter",
"queryset",
"by",
"publish",
"status",
"."
] | 003ceecc0a87be31fe8195f65367c52631f72b57 | https://github.com/OpenVolunteeringPlatform/django-ovp-search/blob/003ceecc0a87be31fe8195f65367c52631f72b57/ovp_search/filters.py#L119-L161 |
250,074 | OpenVolunteeringPlatform/django-ovp-search | ovp_search/filters.py | filter_out | def filter_out(queryset, setting_name):
"""
Remove unwanted results from queryset
"""
kwargs = helpers.get_settings().get(setting_name, {}).get('FILTER_OUT', {})
queryset = queryset.exclude(**kwargs)
return queryset | python | def filter_out(queryset, setting_name):
"""
Remove unwanted results from queryset
"""
kwargs = helpers.get_settings().get(setting_name, {}).get('FILTER_OUT', {})
queryset = queryset.exclude(**kwargs)
return queryset | [
"def",
"filter_out",
"(",
"queryset",
",",
"setting_name",
")",
":",
"kwargs",
"=",
"helpers",
".",
"get_settings",
"(",
")",
".",
"get",
"(",
"setting_name",
",",
"{",
"}",
")",
".",
"get",
"(",
"'FILTER_OUT'",
",",
"{",
"}",
")",
"queryset",
"=",
"... | Remove unwanted results from queryset | [
"Remove",
"unwanted",
"results",
"from",
"queryset"
] | 003ceecc0a87be31fe8195f65367c52631f72b57 | https://github.com/OpenVolunteeringPlatform/django-ovp-search/blob/003ceecc0a87be31fe8195f65367c52631f72b57/ovp_search/filters.py#L163-L169 |
250,075 | 20tab/twentytab-tree | tree/models.py | list_apps | def list_apps():
"""
It returns a list of application contained in PROJECT_APPS
"""
return [(d.split('.')[-1], d.split('.')[-1]) for d in os.listdir(
os.getcwd()) if is_app(u"{}/{}".format(os.getcwd(), d))] | python | def list_apps():
"""
It returns a list of application contained in PROJECT_APPS
"""
return [(d.split('.')[-1], d.split('.')[-1]) for d in os.listdir(
os.getcwd()) if is_app(u"{}/{}".format(os.getcwd(), d))] | [
"def",
"list_apps",
"(",
")",
":",
"return",
"[",
"(",
"d",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
",",
"d",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"1",
"]",
")",
"for",
"d",
"in",
"os",
".",
"listdir",
"(",
"os",
".",
"getc... | It returns a list of application contained in PROJECT_APPS | [
"It",
"returns",
"a",
"list",
"of",
"application",
"contained",
"in",
"PROJECT_APPS"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/models.py#L291-L296 |
250,076 | 20tab/twentytab-tree | tree/models.py | Node.slug | def slug(self):
"""
It returns node's slug
"""
if self.is_root_node():
return ""
if self.slugable and self.parent.parent:
if not self.page.regex or (self.page.regex and not self.page.show_regex) or self.is_leaf_node():
return u"{0}/{1}".for... | python | def slug(self):
"""
It returns node's slug
"""
if self.is_root_node():
return ""
if self.slugable and self.parent.parent:
if not self.page.regex or (self.page.regex and not self.page.show_regex) or self.is_leaf_node():
return u"{0}/{1}".for... | [
"def",
"slug",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_root_node",
"(",
")",
":",
"return",
"\"\"",
"if",
"self",
".",
"slugable",
"and",
"self",
".",
"parent",
".",
"parent",
":",
"if",
"not",
"self",
".",
"page",
".",
"regex",
"or",
"(",
... | It returns node's slug | [
"It",
"returns",
"node",
"s",
"slug"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/models.py#L97-L117 |
250,077 | 20tab/twentytab-tree | tree/models.py | Node.get_pattern | def get_pattern(self):
"""
It returns its url pattern
"""
if self.is_root_node():
return ""
else:
parent_pattern = self.parent.get_pattern()
if parent_pattern != "":
parent_pattern = u"{}".format(parent_pattern)
if n... | python | def get_pattern(self):
"""
It returns its url pattern
"""
if self.is_root_node():
return ""
else:
parent_pattern = self.parent.get_pattern()
if parent_pattern != "":
parent_pattern = u"{}".format(parent_pattern)
if n... | [
"def",
"get_pattern",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_root_node",
"(",
")",
":",
"return",
"\"\"",
"else",
":",
"parent_pattern",
"=",
"self",
".",
"parent",
".",
"get_pattern",
"(",
")",
"if",
"parent_pattern",
"!=",
"\"\"",
":",
"parent_p... | It returns its url pattern | [
"It",
"returns",
"its",
"url",
"pattern"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/models.py#L142-L165 |
250,078 | 20tab/twentytab-tree | tree/models.py | Node.presentation_type | def presentation_type(self):
"""
It returns page's presentation_type
"""
if self.page and self.page.presentation_type:
return self.page.presentation_type
return "" | python | def presentation_type(self):
"""
It returns page's presentation_type
"""
if self.page and self.page.presentation_type:
return self.page.presentation_type
return "" | [
"def",
"presentation_type",
"(",
"self",
")",
":",
"if",
"self",
".",
"page",
"and",
"self",
".",
"page",
".",
"presentation_type",
":",
"return",
"self",
".",
"page",
".",
"presentation_type",
"return",
"\"\""
] | It returns page's presentation_type | [
"It",
"returns",
"page",
"s",
"presentation_type"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/models.py#L174-L180 |
250,079 | 20tab/twentytab-tree | tree/models.py | Page.view_path | def view_path(self):
"""
It returns view's view path
"""
if self.scheme_name is None or self.scheme_name == "":
return self.view.view_path
else:
return self.scheme_name | python | def view_path(self):
"""
It returns view's view path
"""
if self.scheme_name is None or self.scheme_name == "":
return self.view.view_path
else:
return self.scheme_name | [
"def",
"view_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"scheme_name",
"is",
"None",
"or",
"self",
".",
"scheme_name",
"==",
"\"\"",
":",
"return",
"self",
".",
"view",
".",
"view_path",
"else",
":",
"return",
"self",
".",
"scheme_name"
] | It returns view's view path | [
"It",
"returns",
"view",
"s",
"view",
"path"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/models.py#L238-L245 |
250,080 | 20tab/twentytab-tree | tree/models.py | Page.get_absolute_url | def get_absolute_url(self):
"""
It returns absolute url defined by node related to this page
"""
try:
node = Node.objects.select_related().filter(page=self)[0]
return node.get_absolute_url()
except Exception, e:
raise ValueError(u"Error in {0}.... | python | def get_absolute_url(self):
"""
It returns absolute url defined by node related to this page
"""
try:
node = Node.objects.select_related().filter(page=self)[0]
return node.get_absolute_url()
except Exception, e:
raise ValueError(u"Error in {0}.... | [
"def",
"get_absolute_url",
"(",
"self",
")",
":",
"try",
":",
"node",
"=",
"Node",
".",
"objects",
".",
"select_related",
"(",
")",
".",
"filter",
"(",
"page",
"=",
"self",
")",
"[",
"0",
"]",
"return",
"node",
".",
"get_absolute_url",
"(",
")",
"exc... | It returns absolute url defined by node related to this page | [
"It",
"returns",
"absolute",
"url",
"defined",
"by",
"node",
"related",
"to",
"this",
"page"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/models.py#L247-L256 |
250,081 | 20tab/twentytab-tree | tree/models.py | Page.check_static_vars | def check_static_vars(self, node):
"""
This function check if a Page has static vars
"""
if self.static_vars == "" and hasattr(self, "template"):
self.static_vars = {
'upy_context': {
'template_name': u"{}/{}".format(self.template.app_name,... | python | def check_static_vars(self, node):
"""
This function check if a Page has static vars
"""
if self.static_vars == "" and hasattr(self, "template"):
self.static_vars = {
'upy_context': {
'template_name': u"{}/{}".format(self.template.app_name,... | [
"def",
"check_static_vars",
"(",
"self",
",",
"node",
")",
":",
"if",
"self",
".",
"static_vars",
"==",
"\"\"",
"and",
"hasattr",
"(",
"self",
",",
"\"template\"",
")",
":",
"self",
".",
"static_vars",
"=",
"{",
"'upy_context'",
":",
"{",
"'template_name'"... | This function check if a Page has static vars | [
"This",
"function",
"check",
"if",
"a",
"Page",
"has",
"static",
"vars"
] | f2c1ced33e6c211bb52a25a7d48155e39fbdc088 | https://github.com/20tab/twentytab-tree/blob/f2c1ced33e6c211bb52a25a7d48155e39fbdc088/tree/models.py#L258-L274 |
250,082 | jamieleshaw/lurklib | lurklib/optional.py | _Optional.rehash | def rehash(self):
"""
Rehashes the IRCd's configuration file.
"""
with self.lock:
self.send('REHASH')
if self.readable():
msg = self._recv(expected_replies=('382',))
if msg[0] == '382':
pass | python | def rehash(self):
"""
Rehashes the IRCd's configuration file.
"""
with self.lock:
self.send('REHASH')
if self.readable():
msg = self._recv(expected_replies=('382',))
if msg[0] == '382':
pass | [
"def",
"rehash",
"(",
"self",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"send",
"(",
"'REHASH'",
")",
"if",
"self",
".",
"readable",
"(",
")",
":",
"msg",
"=",
"self",
".",
"_recv",
"(",
"expected_replies",
"=",
"(",
"'382'",
",",
... | Rehashes the IRCd's configuration file. | [
"Rehashes",
"the",
"IRCd",
"s",
"configuration",
"file",
"."
] | a861f35d880140422103dd78ec3239814e85fd7e | https://github.com/jamieleshaw/lurklib/blob/a861f35d880140422103dd78ec3239814e85fd7e/lurklib/optional.py#L39-L48 |
250,083 | globocom/globomap-loader-api-client | globomap_loader_api_client/auth.py | Auth.generate_token | def generate_token(self):
"""Make request in API to generate a token."""
response = self._make_request()
self.auth = response
self.token = response['token'] | python | def generate_token(self):
"""Make request in API to generate a token."""
response = self._make_request()
self.auth = response
self.token = response['token'] | [
"def",
"generate_token",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_make_request",
"(",
")",
"self",
".",
"auth",
"=",
"response",
"self",
".",
"token",
"=",
"response",
"[",
"'token'",
"]"
] | Make request in API to generate a token. | [
"Make",
"request",
"in",
"API",
"to",
"generate",
"a",
"token",
"."
] | b12347ca77d245de1abd604d1b694162156570e6 | https://github.com/globocom/globomap-loader-api-client/blob/b12347ca77d245de1abd604d1b694162156570e6/globomap_loader_api_client/auth.py#L45-L50 |
250,084 | ulf1/oxyba | oxyba/linreg_ols_svd.py | linreg_ols_svd | def linreg_ols_svd(y, X, rcond=1e-15):
"""Linear Regression, OLS, inv by SVD
Properties
----------
* Numpy's lstsq is based on LAPACK's _gelsd what applies SVD
* SVD inverse might be slow (complex Landau O)
* speed might decline during forward selection
* no overhead or other computations
... | python | def linreg_ols_svd(y, X, rcond=1e-15):
"""Linear Regression, OLS, inv by SVD
Properties
----------
* Numpy's lstsq is based on LAPACK's _gelsd what applies SVD
* SVD inverse might be slow (complex Landau O)
* speed might decline during forward selection
* no overhead or other computations
... | [
"def",
"linreg_ols_svd",
"(",
"y",
",",
"X",
",",
"rcond",
"=",
"1e-15",
")",
":",
"import",
"numpy",
"as",
"np",
"try",
":",
"# solve OLS formula",
"beta",
",",
"_",
",",
"_",
",",
"singu",
"=",
"np",
".",
"linalg",
".",
"lstsq",
"(",
"b",
"=",
... | Linear Regression, OLS, inv by SVD
Properties
----------
* Numpy's lstsq is based on LAPACK's _gelsd what applies SVD
* SVD inverse might be slow (complex Landau O)
* speed might decline during forward selection
* no overhead or other computations
Example:
--------
beta = lin_o... | [
"Linear",
"Regression",
"OLS",
"inv",
"by",
"SVD"
] | b3043116050de275124365cb11e7df91fb40169d | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/linreg_ols_svd.py#L2-L29 |
250,085 | b3j0f/conf | b3j0f/conf/parser/resolver/lang/py.py | genrepl | def genrepl(scope):
"""Replacement function with specific scope."""
def repl(match):
"""Internal replacement function."""
name = match.group('name')
value = lookup(name, scope=scope)
result = name.replace('.', '_')
scope[result] = value
return result
ret... | python | def genrepl(scope):
"""Replacement function with specific scope."""
def repl(match):
"""Internal replacement function."""
name = match.group('name')
value = lookup(name, scope=scope)
result = name.replace('.', '_')
scope[result] = value
return result
ret... | [
"def",
"genrepl",
"(",
"scope",
")",
":",
"def",
"repl",
"(",
"match",
")",
":",
"\"\"\"Internal replacement function.\"\"\"",
"name",
"=",
"match",
".",
"group",
"(",
"'name'",
")",
"value",
"=",
"lookup",
"(",
"name",
",",
"scope",
"=",
"scope",
")",
"... | Replacement function with specific scope. | [
"Replacement",
"function",
"with",
"specific",
"scope",
"."
] | 18dd6d5d6560f9b202793739e2330a2181163511 | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/lang/py.py#L48-L63 |
250,086 | bcho/yufou | yufou/radar.py | image | def image(radar, at=None):
'''Retrieve a radar image.
:param radar: radar station no.
:param at: stat datetime, defaults to now.
'''
at = round_to_5_minutes(at or datetime.utcnow())
return ''.join([
'http://image.nmc.cn/product',
'/{0}'.format(at.year),
'/{0}'.format(at... | python | def image(radar, at=None):
'''Retrieve a radar image.
:param radar: radar station no.
:param at: stat datetime, defaults to now.
'''
at = round_to_5_minutes(at or datetime.utcnow())
return ''.join([
'http://image.nmc.cn/product',
'/{0}'.format(at.year),
'/{0}'.format(at... | [
"def",
"image",
"(",
"radar",
",",
"at",
"=",
"None",
")",
":",
"at",
"=",
"round_to_5_minutes",
"(",
"at",
"or",
"datetime",
".",
"utcnow",
"(",
")",
")",
"return",
"''",
".",
"join",
"(",
"[",
"'http://image.nmc.cn/product'",
",",
"'/{0}'",
".",
"for... | Retrieve a radar image.
:param radar: radar station no.
:param at: stat datetime, defaults to now. | [
"Retrieve",
"a",
"radar",
"image",
"."
] | 008e38468f17cf6bc616b30b944bb9395dbaface | https://github.com/bcho/yufou/blob/008e38468f17cf6bc616b30b944bb9395dbaface/yufou/radar.py#L26-L42 |
250,087 | nickmilon/Hellas | Hellas/Olympia.py | pickle_compress | def pickle_compress(obj, print_compression_info=False):
"""pickle and compress an object"""
p = pickle.dumps(obj)
c = zlib.compress(p)
if print_compression_info:
print ("len = {:,d} compr={:,d} ratio:{:.6f}".format(len(p), len(c), float(len(c))/len(p)))
return c | python | def pickle_compress(obj, print_compression_info=False):
"""pickle and compress an object"""
p = pickle.dumps(obj)
c = zlib.compress(p)
if print_compression_info:
print ("len = {:,d} compr={:,d} ratio:{:.6f}".format(len(p), len(c), float(len(c))/len(p)))
return c | [
"def",
"pickle_compress",
"(",
"obj",
",",
"print_compression_info",
"=",
"False",
")",
":",
"p",
"=",
"pickle",
".",
"dumps",
"(",
"obj",
")",
"c",
"=",
"zlib",
".",
"compress",
"(",
"p",
")",
"if",
"print_compression_info",
":",
"print",
"(",
"\"len = ... | pickle and compress an object | [
"pickle",
"and",
"compress",
"an",
"object"
] | 542e4778692fbec90753942946f20100412ec9ee | https://github.com/nickmilon/Hellas/blob/542e4778692fbec90753942946f20100412ec9ee/Hellas/Olympia.py#L9-L15 |
250,088 | ahobsonsayers/bthomehub5-devicelist | bthomehub5_devicelist/bthomehub5_devicelist.py | get_devicelist | def get_devicelist(home_hub_ip='192.168.1.254'):
"""Retrieve data from BT Home Hub 5 and return parsed result.
"""
url = 'http://{}/'.format(home_hub_ip)
try:
response = requests.get(url, timeout=5)
except requests.exceptions.Timeout:
_LOGGER.exception("Connection to the router tim... | python | def get_devicelist(home_hub_ip='192.168.1.254'):
"""Retrieve data from BT Home Hub 5 and return parsed result.
"""
url = 'http://{}/'.format(home_hub_ip)
try:
response = requests.get(url, timeout=5)
except requests.exceptions.Timeout:
_LOGGER.exception("Connection to the router tim... | [
"def",
"get_devicelist",
"(",
"home_hub_ip",
"=",
"'192.168.1.254'",
")",
":",
"url",
"=",
"'http://{}/'",
".",
"format",
"(",
"home_hub_ip",
")",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"timeout",
"=",
"5",
")",
"except",
"... | Retrieve data from BT Home Hub 5 and return parsed result. | [
"Retrieve",
"data",
"from",
"BT",
"Home",
"Hub",
"5",
"and",
"return",
"parsed",
"result",
"."
] | 941b553fab7ce49b0c7ff7f1e10023d0a212d455 | https://github.com/ahobsonsayers/bthomehub5-devicelist/blob/941b553fab7ce49b0c7ff7f1e10023d0a212d455/bthomehub5_devicelist/bthomehub5_devicelist.py#L8-L22 |
250,089 | ahobsonsayers/bthomehub5-devicelist | bthomehub5_devicelist/bthomehub5_devicelist.py | parse_devicelist | def parse_devicelist(data_str):
"""Parse the BT Home Hub 5 data format."""
p = HTMLTableParser()
p.feed(data_str)
known_devices = p.tables[9]
devices = {}
for device in known_devices:
if len(device) == 5 and device[2] != '':
devices[device[2]] = device[1]
return devi... | python | def parse_devicelist(data_str):
"""Parse the BT Home Hub 5 data format."""
p = HTMLTableParser()
p.feed(data_str)
known_devices = p.tables[9]
devices = {}
for device in known_devices:
if len(device) == 5 and device[2] != '':
devices[device[2]] = device[1]
return devi... | [
"def",
"parse_devicelist",
"(",
"data_str",
")",
":",
"p",
"=",
"HTMLTableParser",
"(",
")",
"p",
".",
"feed",
"(",
"data_str",
")",
"known_devices",
"=",
"p",
".",
"tables",
"[",
"9",
"]",
"devices",
"=",
"{",
"}",
"for",
"device",
"in",
"known_device... | Parse the BT Home Hub 5 data format. | [
"Parse",
"the",
"BT",
"Home",
"Hub",
"5",
"data",
"format",
"."
] | 941b553fab7ce49b0c7ff7f1e10023d0a212d455 | https://github.com/ahobsonsayers/bthomehub5-devicelist/blob/941b553fab7ce49b0c7ff7f1e10023d0a212d455/bthomehub5_devicelist/bthomehub5_devicelist.py#L25-L39 |
250,090 | minhhoit/yacms | yacms/generic/templatetags/comment_tags.py | comments_for | def comments_for(context, obj):
"""
Provides a generic context variable name for the object that
comments are being rendered for.
"""
form_class = import_dotted_path(settings.COMMENT_FORM_CLASS)
form = form_class(context["request"], obj)
context_form = context.get("posted_comment_form", form... | python | def comments_for(context, obj):
"""
Provides a generic context variable name for the object that
comments are being rendered for.
"""
form_class = import_dotted_path(settings.COMMENT_FORM_CLASS)
form = form_class(context["request"], obj)
context_form = context.get("posted_comment_form", form... | [
"def",
"comments_for",
"(",
"context",
",",
"obj",
")",
":",
"form_class",
"=",
"import_dotted_path",
"(",
"settings",
".",
"COMMENT_FORM_CLASS",
")",
"form",
"=",
"form_class",
"(",
"context",
"[",
"\"request\"",
"]",
",",
"obj",
")",
"context_form",
"=",
"... | Provides a generic context variable name for the object that
comments are being rendered for. | [
"Provides",
"a",
"generic",
"context",
"variable",
"name",
"for",
"the",
"object",
"that",
"comments",
"are",
"being",
"rendered",
"for",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/templatetags/comment_tags.py#L19-L34 |
250,091 | minhhoit/yacms | yacms/generic/templatetags/comment_tags.py | comment_thread | def comment_thread(context, parent):
"""
Return a list of child comments for the given parent, storing all
comments in a dict in the context when first called, using parents
as keys for retrieval on subsequent recursive calls from the
comments template.
"""
if "all_comments" not in context:
... | python | def comment_thread(context, parent):
"""
Return a list of child comments for the given parent, storing all
comments in a dict in the context when first called, using parents
as keys for retrieval on subsequent recursive calls from the
comments template.
"""
if "all_comments" not in context:
... | [
"def",
"comment_thread",
"(",
"context",
",",
"parent",
")",
":",
"if",
"\"all_comments\"",
"not",
"in",
"context",
":",
"comments",
"=",
"defaultdict",
"(",
"list",
")",
"if",
"\"request\"",
"in",
"context",
"and",
"context",
"[",
"\"request\"",
"]",
".",
... | Return a list of child comments for the given parent, storing all
comments in a dict in the context when first called, using parents
as keys for retrieval on subsequent recursive calls from the
comments template. | [
"Return",
"a",
"list",
"of",
"child",
"comments",
"for",
"the",
"given",
"parent",
"storing",
"all",
"comments",
"in",
"a",
"dict",
"in",
"the",
"context",
"when",
"first",
"called",
"using",
"parents",
"as",
"keys",
"for",
"retrieval",
"on",
"subsequent",
... | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/templatetags/comment_tags.py#L38-L64 |
250,092 | minhhoit/yacms | yacms/generic/templatetags/comment_tags.py | recent_comments | def recent_comments(context):
"""
Dashboard widget for displaying recent comments.
"""
latest = context["settings"].COMMENTS_NUM_LATEST
comments = ThreadedComment.objects.all().select_related("user")
context["comments"] = comments.order_by("-id")[:latest]
return context | python | def recent_comments(context):
"""
Dashboard widget for displaying recent comments.
"""
latest = context["settings"].COMMENTS_NUM_LATEST
comments = ThreadedComment.objects.all().select_related("user")
context["comments"] = comments.order_by("-id")[:latest]
return context | [
"def",
"recent_comments",
"(",
"context",
")",
":",
"latest",
"=",
"context",
"[",
"\"settings\"",
"]",
".",
"COMMENTS_NUM_LATEST",
"comments",
"=",
"ThreadedComment",
".",
"objects",
".",
"all",
"(",
")",
".",
"select_related",
"(",
"\"user\"",
")",
"context"... | Dashboard widget for displaying recent comments. | [
"Dashboard",
"widget",
"for",
"displaying",
"recent",
"comments",
"."
] | 2921b706b7107c6e8c5f2bbf790ff11f85a2167f | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/generic/templatetags/comment_tags.py#L69-L76 |
250,093 | kalekundert/nonstdlib | nonstdlib/debug.py | log_level | def log_level(level):
"""
Attempt to convert the given argument into a log level.
Log levels are represented as integers, where higher values are more
severe. If the given level is already an integer, it is simply returned.
If the given level is a string that can be converted into an integer, i... | python | def log_level(level):
"""
Attempt to convert the given argument into a log level.
Log levels are represented as integers, where higher values are more
severe. If the given level is already an integer, it is simply returned.
If the given level is a string that can be converted into an integer, i... | [
"def",
"log_level",
"(",
"level",
")",
":",
"from",
"six",
"import",
"string_types",
"if",
"isinstance",
"(",
"level",
",",
"int",
")",
":",
"return",
"level",
"if",
"isinstance",
"(",
"level",
",",
"string_types",
")",
":",
"try",
":",
"return",
"int",
... | Attempt to convert the given argument into a log level.
Log levels are represented as integers, where higher values are more
severe. If the given level is already an integer, it is simply returned.
If the given level is a string that can be converted into an integer, it is
converted and that value... | [
"Attempt",
"to",
"convert",
"the",
"given",
"argument",
"into",
"a",
"log",
"level",
"."
] | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/debug.py#L11-L34 |
250,094 | kalekundert/nonstdlib | nonstdlib/debug.py | verbosity | def verbosity(verbosity):
"""
Convert the number of times the user specified '-v' on the command-line
into a log level.
"""
verbosity = int(verbosity)
if verbosity == 0:
return logging.WARNING
if verbosity == 1:
return logging.INFO
if verbosity == 2:
return logg... | python | def verbosity(verbosity):
"""
Convert the number of times the user specified '-v' on the command-line
into a log level.
"""
verbosity = int(verbosity)
if verbosity == 0:
return logging.WARNING
if verbosity == 1:
return logging.INFO
if verbosity == 2:
return logg... | [
"def",
"verbosity",
"(",
"verbosity",
")",
":",
"verbosity",
"=",
"int",
"(",
"verbosity",
")",
"if",
"verbosity",
"==",
"0",
":",
"return",
"logging",
".",
"WARNING",
"if",
"verbosity",
"==",
"1",
":",
"return",
"logging",
".",
"INFO",
"if",
"verbosity"... | Convert the number of times the user specified '-v' on the command-line
into a log level. | [
"Convert",
"the",
"number",
"of",
"times",
"the",
"user",
"specified",
"-",
"v",
"on",
"the",
"command",
"-",
"line",
"into",
"a",
"log",
"level",
"."
] | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/debug.py#L36-L52 |
250,095 | kalekundert/nonstdlib | nonstdlib/debug.py | config | def config(stream=sys.stderr,
level=logging.NOTSET,
format='%(levelname)s [%(name)s:%(lineno)s] %(message)s',
file=None,
file_level=None,
file_format=None):
"""
Configure logging to stream and file concurrently.
Allows setting a file and stream to log ... | python | def config(stream=sys.stderr,
level=logging.NOTSET,
format='%(levelname)s [%(name)s:%(lineno)s] %(message)s',
file=None,
file_level=None,
file_format=None):
"""
Configure logging to stream and file concurrently.
Allows setting a file and stream to log ... | [
"def",
"config",
"(",
"stream",
"=",
"sys",
".",
"stderr",
",",
"level",
"=",
"logging",
".",
"NOTSET",
",",
"format",
"=",
"'%(levelname)s [%(name)s:%(lineno)s] %(message)s'",
",",
"file",
"=",
"None",
",",
"file_level",
"=",
"None",
",",
"file_format",
"=",
... | Configure logging to stream and file concurrently.
Allows setting a file and stream to log to concurrently with differing
level if desired. Must provide either stream or file.
Parameters
----------
stream: File like:
Stream to write file to [Default: sys.stderr]. If none, will not write ... | [
"Configure",
"logging",
"to",
"stream",
"and",
"file",
"concurrently",
"."
] | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/debug.py#L54-L117 |
250,096 | kalekundert/nonstdlib | nonstdlib/debug.py | _log | def _log(level, message, frame_depth=2, **kwargs):
"""
Log the given message with the given log level using a logger named based
on the scope of the calling code. This saves you time because you will be
able to see where all your log messages are being generated from without
having to type anyth... | python | def _log(level, message, frame_depth=2, **kwargs):
"""
Log the given message with the given log level using a logger named based
on the scope of the calling code. This saves you time because you will be
able to see where all your log messages are being generated from without
having to type anyth... | [
"def",
"_log",
"(",
"level",
",",
"message",
",",
"frame_depth",
"=",
"2",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"inspect",
"try",
":",
"# Inspect variables two frames up from where we currently are (by ",
"# default). One frame up is assumed to be one of the helper... | Log the given message with the given log level using a logger named based
on the scope of the calling code. This saves you time because you will be
able to see where all your log messages are being generated from without
having to type anything. This function is meant to be called by one or
more w... | [
"Log",
"the",
"given",
"message",
"with",
"the",
"given",
"log",
"level",
"using",
"a",
"logger",
"named",
"based",
"on",
"the",
"scope",
"of",
"the",
"calling",
"code",
".",
"This",
"saves",
"you",
"time",
"because",
"you",
"will",
"be",
"able",
"to",
... | 3abf4a4680056d6d97f2a5988972eb9392756fb6 | https://github.com/kalekundert/nonstdlib/blob/3abf4a4680056d6d97f2a5988972eb9392756fb6/nonstdlib/debug.py#L145-L206 |
250,097 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.on_switch_state_changed | def on_switch_state_changed(
self, func: Callable[['BaseUnit', SwitchNumber, Optional[bool]], None]):
"""
Define the switch state changed callback implementation.
Expected signature is:
switch_state_changed_callback(base_unit, switch_number, state)
base_unit: ... | python | def on_switch_state_changed(
self, func: Callable[['BaseUnit', SwitchNumber, Optional[bool]], None]):
"""
Define the switch state changed callback implementation.
Expected signature is:
switch_state_changed_callback(base_unit, switch_number, state)
base_unit: ... | [
"def",
"on_switch_state_changed",
"(",
"self",
",",
"func",
":",
"Callable",
"[",
"[",
"'BaseUnit'",
",",
"SwitchNumber",
",",
"Optional",
"[",
"bool",
"]",
"]",
",",
"None",
"]",
")",
":",
"self",
".",
"_on_switch_state_changed",
"=",
"func"
] | Define the switch state changed callback implementation.
Expected signature is:
switch_state_changed_callback(base_unit, switch_number, state)
base_unit: the device instance for this callback
switch_number: the switch whose state has changed
state: True if sw... | [
"Define",
"the",
"switch",
"state",
"changed",
"callback",
"implementation",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L267-L279 |
250,098 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.start | def start(self) -> None:
"""
Start monitoring the base unit.
"""
self._shutdown = False
# Start listening (if server) / Open connection (if client)
if isinstance(self._protocol, Server):
self.create_task(self._async_listen)
elif isinstance(self._prot... | python | def start(self) -> None:
"""
Start monitoring the base unit.
"""
self._shutdown = False
# Start listening (if server) / Open connection (if client)
if isinstance(self._protocol, Server):
self.create_task(self._async_listen)
elif isinstance(self._prot... | [
"def",
"start",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_shutdown",
"=",
"False",
"# Start listening (if server) / Open connection (if client)",
"if",
"isinstance",
"(",
"self",
".",
"_protocol",
",",
"Server",
")",
":",
"self",
".",
"create_task",
"(... | Start monitoring the base unit. | [
"Start",
"monitoring",
"the",
"base",
"unit",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L285-L298 |
250,099 | rorr73/LifeSOSpy | lifesospy/baseunit.py | BaseUnit.stop | def stop(self) -> None:
"""
Stop monitoring the base unit.
"""
self._shutdown = True
# Close connection if needed
self._protocol.close()
# Cancel any pending tasks
self.cancel_pending_tasks() | python | def stop(self) -> None:
"""
Stop monitoring the base unit.
"""
self._shutdown = True
# Close connection if needed
self._protocol.close()
# Cancel any pending tasks
self.cancel_pending_tasks() | [
"def",
"stop",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"_shutdown",
"=",
"True",
"# Close connection if needed",
"self",
".",
"_protocol",
".",
"close",
"(",
")",
"# Cancel any pending tasks",
"self",
".",
"cancel_pending_tasks",
"(",
")"
] | Stop monitoring the base unit. | [
"Stop",
"monitoring",
"the",
"base",
"unit",
"."
] | 62360fbab2e90bf04d52b547093bdab2d4e389b4 | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/baseunit.py#L300-L311 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.