repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
rosenbrockc/acorn | acorn/ipython.py | AcornHistoryManager.store_inputs | def store_inputs(self, line_num, source, source_raw=None):
"""Store source and raw input in history and create input cache
variables ``_i*``.
Args:
line_num (int): The prompt number of this input.
source (str): Python input.
source_raw (str): If given, this i... | python | def store_inputs(self, line_num, source, source_raw=None):
"""Store source and raw input in history and create input cache
variables ``_i*``.
Args:
line_num (int): The prompt number of this input.
source (str): Python input.
source_raw (str): If given, this i... | [
"def",
"store_inputs",
"(",
"self",
",",
"line_num",
",",
"source",
",",
"source_raw",
"=",
"None",
")",
":",
"self",
".",
"old",
".",
"store_inputs",
"(",
"line_num",
",",
"source",
",",
"source_raw",
")",
"#Now that the input has been stored correctly, intercept... | Store source and raw input in history and create input cache
variables ``_i*``.
Args:
line_num (int): The prompt number of this input.
source (str): Python input.
source_raw (str): If given, this is the raw input without any
IPython transformations appl... | [
"Store",
"source",
"and",
"raw",
"input",
"in",
"history",
"and",
"create",
"input",
"cache",
"variables",
"_i",
"*",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L94-L108 |
rosenbrockc/acorn | acorn/ipython.py | InteractiveDecorator._get_decoratables | def _get_decoratables(self, atype):
"""Returns a list of the objects that need to be decorated in the
current user namespace based on their type.
Args:
atype (str): one of the values in :attr:`atypes`. Specifies the type of
object to search.
"""
result ... | python | def _get_decoratables(self, atype):
"""Returns a list of the objects that need to be decorated in the
current user namespace based on their type.
Args:
atype (str): one of the values in :attr:`atypes`. Specifies the type of
object to search.
"""
result ... | [
"def",
"_get_decoratables",
"(",
"self",
",",
"atype",
")",
":",
"result",
"=",
"[",
"]",
"defmsg",
"=",
"\"Skipping {}; not decoratable or already decorated.\"",
"for",
"varname",
"in",
"self",
".",
"shell",
".",
"run_line_magic",
"(",
"\"who_ls\"",
",",
"atype",... | Returns a list of the objects that need to be decorated in the
current user namespace based on their type.
Args:
atype (str): one of the values in :attr:`atypes`. Specifies the type of
object to search. | [
"Returns",
"a",
"list",
"of",
"the",
"objects",
"that",
"need",
"to",
"be",
"decorated",
"in",
"the",
"current",
"user",
"namespace",
"based",
"on",
"their",
"type",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L149-L199 |
rosenbrockc/acorn | acorn/ipython.py | InteractiveDecorator._logdef | def _logdef(self, n, o, otype):
"""Logs the definition of the object that was just auto-decorated inside
the `ipython` notebook.
"""
import re
try:
#The latest input cell will be the one that this got executed
#from. TODO: actually, if acorn got imported a... | python | def _logdef(self, n, o, otype):
"""Logs the definition of the object that was just auto-decorated inside
the `ipython` notebook.
"""
import re
try:
#The latest input cell will be the one that this got executed
#from. TODO: actually, if acorn got imported a... | [
"def",
"_logdef",
"(",
"self",
",",
"n",
",",
"o",
",",
"otype",
")",
":",
"import",
"re",
"try",
":",
"#The latest input cell will be the one that this got executed",
"#from. TODO: actually, if acorn got imported after the fact, then",
"#the import would have caused all the unde... | Logs the definition of the object that was just auto-decorated inside
the `ipython` notebook. | [
"Logs",
"the",
"definition",
"of",
"the",
"object",
"that",
"was",
"just",
"auto",
"-",
"decorated",
"inside",
"the",
"ipython",
"notebook",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L201-L256 |
rosenbrockc/acorn | acorn/ipython.py | InteractiveDecorator._decorate | def _decorate(self, atype, n, o):
"""Decorates the specified object for automatic logging with acorn.
Args:
atype (str): one of the types specified in :attr:`atypes`.
varobj: object instance to decorate; no additional type checking is
performed.
"""
... | python | def _decorate(self, atype, n, o):
"""Decorates the specified object for automatic logging with acorn.
Args:
atype (str): one of the types specified in :attr:`atypes`.
varobj: object instance to decorate; no additional type checking is
performed.
"""
... | [
"def",
"_decorate",
"(",
"self",
",",
"atype",
",",
"n",
",",
"o",
")",
":",
"typemap",
"=",
"{",
"\"function\"",
":",
"\"functions\"",
",",
"\"classobj\"",
":",
"\"classes\"",
",",
"\"staticmethod\"",
":",
"\"methods\"",
",",
"\"type\"",
":",
"\"classes\"",... | Decorates the specified object for automatic logging with acorn.
Args:
atype (str): one of the types specified in :attr:`atypes`.
varobj: object instance to decorate; no additional type checking is
performed. | [
"Decorates",
"the",
"specified",
"object",
"for",
"automatic",
"logging",
"with",
"acorn",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L258-L281 |
rosenbrockc/acorn | acorn/ipython.py | InteractiveDecorator._find_cellid | def _find_cellid(self, code):
"""Determines the most similar cell (if any) to the specified code. It
must have at least 50% overlap ratio and have been a loop-intercepted
cell previously.
Args:
code (str): contents of the code cell that were executed.
"""
fro... | python | def _find_cellid(self, code):
"""Determines the most similar cell (if any) to the specified code. It
must have at least 50% overlap ratio and have been a loop-intercepted
cell previously.
Args:
code (str): contents of the code cell that were executed.
"""
fro... | [
"def",
"_find_cellid",
"(",
"self",
",",
"code",
")",
":",
"from",
"difflib",
"import",
"SequenceMatcher",
"maxvalue",
"=",
"0.",
"maxid",
"=",
"None",
"for",
"cellid",
",",
"c",
"in",
"self",
".",
"cellids",
".",
"items",
"(",
")",
":",
"matcher",
"="... | Determines the most similar cell (if any) to the specified code. It
must have at least 50% overlap ratio and have been a loop-intercepted
cell previously.
Args:
code (str): contents of the code cell that were executed. | [
"Determines",
"the",
"most",
"similar",
"cell",
"(",
"if",
"any",
")",
"to",
"the",
"specified",
"code",
".",
"It",
"must",
"have",
"at",
"least",
"50%",
"overlap",
"ratio",
"and",
"have",
"been",
"a",
"loop",
"-",
"intercepted",
"cell",
"previously",
".... | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L283-L301 |
rosenbrockc/acorn | acorn/ipython.py | InteractiveDecorator._log_images | def _log_images(self):
"""Creates database logs for all the image file names in the global
variable :data:`thumb_uuid`.
"""
from time import time
from acorn.logging.database import record
entry = {
"m": "plot",
"a": None,
"s": t... | python | def _log_images(self):
"""Creates database logs for all the image file names in the global
variable :data:`thumb_uuid`.
"""
from time import time
from acorn.logging.database import record
entry = {
"m": "plot",
"a": None,
"s": t... | [
"def",
"_log_images",
"(",
"self",
")",
":",
"from",
"time",
"import",
"time",
"from",
"acorn",
".",
"logging",
".",
"database",
"import",
"record",
"entry",
"=",
"{",
"\"m\"",
":",
"\"plot\"",
",",
"\"a\"",
":",
"None",
",",
"\"s\"",
":",
"time",
"(",... | Creates database logs for all the image file names in the global
variable :data:`thumb_uuid`. | [
"Creates",
"database",
"logs",
"for",
"all",
"the",
"image",
"file",
"names",
"in",
"the",
"global",
"variable",
":",
"data",
":",
"thumb_uuid",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L303-L327 |
rosenbrockc/acorn | acorn/ipython.py | InteractiveDecorator.post_run_cell | def post_run_cell(self):
"""Runs after the user-entered code in a cell has been executed. It
detects any new, decoratable objects that haven't been decorated yet and
then decorates them.
"""
#We just want to detect any new, decoratable objects that haven't been
#decorated... | python | def post_run_cell(self):
"""Runs after the user-entered code in a cell has been executed. It
detects any new, decoratable objects that haven't been decorated yet and
then decorates them.
"""
#We just want to detect any new, decoratable objects that haven't been
#decorated... | [
"def",
"post_run_cell",
"(",
"self",
")",
":",
"#We just want to detect any new, decoratable objects that haven't been",
"#decorated yet.",
"decorlist",
"=",
"{",
"k",
":",
"[",
"]",
"for",
"k",
"in",
"self",
".",
"atypes",
"}",
"for",
"atype",
"in",
"self",
".",
... | Runs after the user-entered code in a cell has been executed. It
detects any new, decoratable objects that haven't been decorated yet and
then decorates them. | [
"Runs",
"after",
"the",
"user",
"-",
"entered",
"code",
"in",
"a",
"cell",
"has",
"been",
"executed",
".",
"It",
"detects",
"any",
"new",
"decoratable",
"objects",
"that",
"haven",
"t",
"been",
"decorated",
"yet",
"and",
"then",
"decorates",
"them",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L329-L387 |
rosenbrockc/acorn | acorn/ipython.py | InteractiveDecorator._var_changes | def _var_changes(self):
"""Determines the list of variables whose values have changed since the
last cell execution.
"""
result = []
variables = self.shell.run_line_magic("who_ls", "")
if variables is None:
return result
import inspect
... | python | def _var_changes(self):
"""Determines the list of variables whose values have changed since the
last cell execution.
"""
result = []
variables = self.shell.run_line_magic("who_ls", "")
if variables is None:
return result
import inspect
... | [
"def",
"_var_changes",
"(",
"self",
")",
":",
"result",
"=",
"[",
"]",
"variables",
"=",
"self",
".",
"shell",
".",
"run_line_magic",
"(",
"\"who_ls\"",
",",
"\"\"",
")",
"if",
"variables",
"is",
"None",
":",
"return",
"result",
"import",
"inspect",
"for... | Determines the list of variables whose values have changed since the
last cell execution. | [
"Determines",
"the",
"list",
"of",
"variables",
"whose",
"values",
"have",
"changed",
"since",
"the",
"last",
"cell",
"execution",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L389-L419 |
rosenbrockc/acorn | acorn/ipython.py | InteractiveDecorator.pre_run_cell | def pre_run_cell(self, cellno, code):
"""Executes before the user-entered code in `ipython` is run. This
intercepts loops and other problematic code that would produce lots of
database entries and streamlines it to produce only a single entry.
Args:
cellno (int): the cell nu... | python | def pre_run_cell(self, cellno, code):
"""Executes before the user-entered code in `ipython` is run. This
intercepts loops and other problematic code that would produce lots of
database entries and streamlines it to produce only a single entry.
Args:
cellno (int): the cell nu... | [
"def",
"pre_run_cell",
"(",
"self",
",",
"cellno",
",",
"code",
")",
":",
"#First, we look for loops and list/dict comprehensions in the code. Find",
"#the id of the latest cell that was executed.",
"self",
".",
"cellid",
"=",
"cellno",
"#If there is a loop somewhere in the code, i... | Executes before the user-entered code in `ipython` is run. This
intercepts loops and other problematic code that would produce lots of
database entries and streamlines it to produce only a single entry.
Args:
cellno (int): the cell number that is about to be executed.
co... | [
"Executes",
"before",
"the",
"user",
"-",
"entered",
"code",
"in",
"ipython",
"is",
"run",
".",
"This",
"intercepts",
"loops",
"and",
"other",
"problematic",
"code",
"that",
"would",
"produce",
"lots",
"of",
"database",
"entries",
"and",
"streamlines",
"it",
... | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/ipython.py#L421-L451 |
radjkarl/fancyTools | fancytools/stats/inverseHistogram.py | inverseHistogram | def inverseHistogram(hist, bin_range):
"""sample data from given histogram and min, max values within range
Returns:
np.array: data that would create the same histogram as given
"""
data = hist.astype(float) / np.min(hist[np.nonzero(hist)])
new_data = np.empty(shape=np.sum(data, dtype=int))... | python | def inverseHistogram(hist, bin_range):
"""sample data from given histogram and min, max values within range
Returns:
np.array: data that would create the same histogram as given
"""
data = hist.astype(float) / np.min(hist[np.nonzero(hist)])
new_data = np.empty(shape=np.sum(data, dtype=int))... | [
"def",
"inverseHistogram",
"(",
"hist",
",",
"bin_range",
")",
":",
"data",
"=",
"hist",
".",
"astype",
"(",
"float",
")",
"/",
"np",
".",
"min",
"(",
"hist",
"[",
"np",
".",
"nonzero",
"(",
"hist",
")",
"]",
")",
"new_data",
"=",
"np",
".",
"emp... | sample data from given histogram and min, max values within range
Returns:
np.array: data that would create the same histogram as given | [
"sample",
"data",
"from",
"given",
"histogram",
"and",
"min",
"max",
"values",
"within",
"range"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/stats/inverseHistogram.py#L7-L20 |
Aperture-py/aperture-lib | aperturelib/watermark.py | watermark_image | def watermark_image(image, wtrmrk_path, corner=2):
'''Adds a watermark image to an instance of a PIL Image.
If the provided watermark image (wtrmrk_path) is
larger than the provided base image (image), then
the watermark image will be automatically resized to
roughly 1/8 the size of the base image... | python | def watermark_image(image, wtrmrk_path, corner=2):
'''Adds a watermark image to an instance of a PIL Image.
If the provided watermark image (wtrmrk_path) is
larger than the provided base image (image), then
the watermark image will be automatically resized to
roughly 1/8 the size of the base image... | [
"def",
"watermark_image",
"(",
"image",
",",
"wtrmrk_path",
",",
"corner",
"=",
"2",
")",
":",
"padding",
"=",
"2",
"wtrmrk_img",
"=",
"Image",
".",
"open",
"(",
"wtrmrk_path",
")",
"#Need to perform size check in here rather than in options.py because this is",
"# th... | Adds a watermark image to an instance of a PIL Image.
If the provided watermark image (wtrmrk_path) is
larger than the provided base image (image), then
the watermark image will be automatically resized to
roughly 1/8 the size of the base image.
Args:
image: An instance of a PIL Image. Th... | [
"Adds",
"a",
"watermark",
"image",
"to",
"an",
"instance",
"of",
"a",
"PIL",
"Image",
"."
] | train | https://github.com/Aperture-py/aperture-lib/blob/5c54af216319f297ddf96181a16f088cf1ba23f3/aperturelib/watermark.py#L5-L56 |
Aperture-py/aperture-lib | aperturelib/watermark.py | watermark_text | def watermark_text(image, text, corner=2):
'''Adds a text watermark to an instance of a PIL Image.
The text will be sized so that the height of the text is
roughly 1/20th the height of the base image. The text will
be white with a thin black outline.
Args:
image: An instance of a PIL Imag... | python | def watermark_text(image, text, corner=2):
'''Adds a text watermark to an instance of a PIL Image.
The text will be sized so that the height of the text is
roughly 1/20th the height of the base image. The text will
be white with a thin black outline.
Args:
image: An instance of a PIL Imag... | [
"def",
"watermark_text",
"(",
"image",
",",
"text",
",",
"corner",
"=",
"2",
")",
":",
"# Load Font",
"FONT_PATH",
"=",
"''",
"if",
"resource_exists",
"(",
"__name__",
",",
"'resources/fonts/SourceSansPro-Regular.ttf'",
")",
":",
"FONT_PATH",
"=",
"resource_filena... | Adds a text watermark to an instance of a PIL Image.
The text will be sized so that the height of the text is
roughly 1/20th the height of the base image. The text will
be white with a thin black outline.
Args:
image: An instance of a PIL Image. This is the base image.
text: Text to u... | [
"Adds",
"a",
"text",
"watermark",
"to",
"an",
"instance",
"of",
"a",
"PIL",
"Image",
"."
] | train | https://github.com/Aperture-py/aperture-lib/blob/5c54af216319f297ddf96181a16f088cf1ba23f3/aperturelib/watermark.py#L59-L152 |
bazzisoft/webmake | webmake/modules/utils.py | log | def log(msg, *args, **kwargs):
"""
Print out a log message.
"""
if len(args) == 0 and len(kwargs) == 0:
print(msg)
else:
print(msg.format(*args, **kwargs)) | python | def log(msg, *args, **kwargs):
"""
Print out a log message.
"""
if len(args) == 0 and len(kwargs) == 0:
print(msg)
else:
print(msg.format(*args, **kwargs)) | [
"def",
"log",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"0",
"and",
"len",
"(",
"kwargs",
")",
"==",
"0",
":",
"print",
"(",
"msg",
")",
"else",
":",
"print",
"(",
"msg",
".",
"for... | Print out a log message. | [
"Print",
"out",
"a",
"log",
"message",
"."
] | train | https://github.com/bazzisoft/webmake/blob/c11918900529c801f1675647760ededc0ea5d0cd/webmake/modules/utils.py#L8-L15 |
bazzisoft/webmake | webmake/modules/utils.py | logv | def logv(msg, *args, **kwargs):
"""
Print out a log message, only if verbose mode.
"""
if settings.VERBOSE:
log(msg, *args, **kwargs) | python | def logv(msg, *args, **kwargs):
"""
Print out a log message, only if verbose mode.
"""
if settings.VERBOSE:
log(msg, *args, **kwargs) | [
"def",
"logv",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"settings",
".",
"VERBOSE",
":",
"log",
"(",
"msg",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Print out a log message, only if verbose mode. | [
"Print",
"out",
"a",
"log",
"message",
"only",
"if",
"verbose",
"mode",
"."
] | train | https://github.com/bazzisoft/webmake/blob/c11918900529c801f1675647760ededc0ea5d0cd/webmake/modules/utils.py#L18-L23 |
bazzisoft/webmake | webmake/modules/utils.py | resolve_possible_paths | def resolve_possible_paths(path, relative_prefix, possible_extensions=None, leading_underscore=False):
"""
Attempts to resolve the given absolute or relative ``path``. If it
doesn't exist as is, tries to create an absolute path using the
``relative_prefix``. If that fails, tries relative/absolute versio... | python | def resolve_possible_paths(path, relative_prefix, possible_extensions=None, leading_underscore=False):
"""
Attempts to resolve the given absolute or relative ``path``. If it
doesn't exist as is, tries to create an absolute path using the
``relative_prefix``. If that fails, tries relative/absolute versio... | [
"def",
"resolve_possible_paths",
"(",
"path",
",",
"relative_prefix",
",",
"possible_extensions",
"=",
"None",
",",
"leading_underscore",
"=",
"False",
")",
":",
"possible_extensions",
"=",
"[",
"''",
"]",
"+",
"list",
"(",
"possible_extensions",
")",
"if",
"pos... | Attempts to resolve the given absolute or relative ``path``. If it
doesn't exist as is, tries to create an absolute path using the
``relative_prefix``. If that fails, tries relative/absolute versions
with each of ``possible_extensions``.
:returns: The absolute path, or ``None`` if no such file can be f... | [
"Attempts",
"to",
"resolve",
"the",
"given",
"absolute",
"or",
"relative",
"path",
".",
"If",
"it",
"doesn",
"t",
"exist",
"as",
"is",
"tries",
"to",
"create",
"an",
"absolute",
"path",
"using",
"the",
"relative_prefix",
".",
"If",
"that",
"fails",
"tries"... | train | https://github.com/bazzisoft/webmake/blob/c11918900529c801f1675647760ededc0ea5d0cd/webmake/modules/utils.py#L108-L131 |
ckcollab/existence | existence.py | parse_html_urls | def parse_html_urls(file_name, html_data):
'''
Returns a list of tuples in the form (url, file_name, line_number)
'''
try:
html = lxml.html.fromstring(html_data)
anchor_tags = html.cssselect('a')
for a in anchor_tags:
# A link was started but not finished, href with ... | python | def parse_html_urls(file_name, html_data):
'''
Returns a list of tuples in the form (url, file_name, line_number)
'''
try:
html = lxml.html.fromstring(html_data)
anchor_tags = html.cssselect('a')
for a in anchor_tags:
# A link was started but not finished, href with ... | [
"def",
"parse_html_urls",
"(",
"file_name",
",",
"html_data",
")",
":",
"try",
":",
"html",
"=",
"lxml",
".",
"html",
".",
"fromstring",
"(",
"html_data",
")",
"anchor_tags",
"=",
"html",
".",
"cssselect",
"(",
"'a'",
")",
"for",
"a",
"in",
"anchor_tags"... | Returns a list of tuples in the form (url, file_name, line_number) | [
"Returns",
"a",
"list",
"of",
"tuples",
"in",
"the",
"form",
"(",
"url",
"file_name",
"line_number",
")"
] | train | https://github.com/ckcollab/existence/blob/09a9ceae28db6fa3a9c3d1e2af3faf76b4f3d11e/existence.py#L38-L60 |
ckcollab/existence | existence.py | check_urls | def check_urls(urls):
'''
expected format of urls is list of tuples (url, file name, source line) i.e. ("google.com", "index.html", 32)
'''
threads = list()
progress_bar = None
progress_counter = 0
if SHOW_PROGRESS_BAR and len(urls) > 0:
widgets = [SimpleProgress()]
progres... | python | def check_urls(urls):
'''
expected format of urls is list of tuples (url, file name, source line) i.e. ("google.com", "index.html", 32)
'''
threads = list()
progress_bar = None
progress_counter = 0
if SHOW_PROGRESS_BAR and len(urls) > 0:
widgets = [SimpleProgress()]
progres... | [
"def",
"check_urls",
"(",
"urls",
")",
":",
"threads",
"=",
"list",
"(",
")",
"progress_bar",
"=",
"None",
"progress_counter",
"=",
"0",
"if",
"SHOW_PROGRESS_BAR",
"and",
"len",
"(",
"urls",
")",
">",
"0",
":",
"widgets",
"=",
"[",
"SimpleProgress",
"(",... | expected format of urls is list of tuples (url, file name, source line) i.e. ("google.com", "index.html", 32) | [
"expected",
"format",
"of",
"urls",
"is",
"list",
"of",
"tuples",
"(",
"url",
"file",
"name",
"source",
"line",
")",
"i",
".",
"e",
".",
"(",
"google",
".",
"com",
"index",
".",
"html",
"32",
")"
] | train | https://github.com/ckcollab/existence/blob/09a9ceae28db6fa3a9c3d1e2af3faf76b4f3d11e/existence.py#L88-L114 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/v1/baremetal.py | _csv_to_nodes_dict | def _csv_to_nodes_dict(nodes_csv):
"""Convert CSV to a list of dicts formatted for os_cloud_config
Given a CSV file in the format below, convert it into the
structure expected by os_could_config JSON files.
pm_type, pm_addr, pm_user, pm_password, mac
"""
data = []
for row in csv.reader(n... | python | def _csv_to_nodes_dict(nodes_csv):
"""Convert CSV to a list of dicts formatted for os_cloud_config
Given a CSV file in the format below, convert it into the
structure expected by os_could_config JSON files.
pm_type, pm_addr, pm_user, pm_password, mac
"""
data = []
for row in csv.reader(n... | [
"def",
"_csv_to_nodes_dict",
"(",
"nodes_csv",
")",
":",
"data",
"=",
"[",
"]",
"for",
"row",
"in",
"csv",
".",
"reader",
"(",
"nodes_csv",
")",
":",
"node",
"=",
"{",
"\"pm_user\"",
":",
"row",
"[",
"2",
"]",
",",
"\"pm_addr\"",
":",
"row",
"[",
"... | Convert CSV to a list of dicts formatted for os_cloud_config
Given a CSV file in the format below, convert it into the
structure expected by os_could_config JSON files.
pm_type, pm_addr, pm_user, pm_password, mac | [
"Convert",
"CSV",
"to",
"a",
"list",
"of",
"dicts",
"formatted",
"for",
"os_cloud_config"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/v1/baremetal.py#L35-L58 |
mbodenhamer/syn | syn/base_utils/context.py | assign | def assign(A, attr, B, lock=False):
'''Assigns B to A.attr, yields, and then assigns A.attr back to its
original value.
'''
class NoAttr(object): pass
context = threading.Lock if lock else null_context
with context():
if not hasattr(A, attr):
tmp = NoAttr
else:
... | python | def assign(A, attr, B, lock=False):
'''Assigns B to A.attr, yields, and then assigns A.attr back to its
original value.
'''
class NoAttr(object): pass
context = threading.Lock if lock else null_context
with context():
if not hasattr(A, attr):
tmp = NoAttr
else:
... | [
"def",
"assign",
"(",
"A",
",",
"attr",
",",
"B",
",",
"lock",
"=",
"False",
")",
":",
"class",
"NoAttr",
"(",
"object",
")",
":",
"pass",
"context",
"=",
"threading",
".",
"Lock",
"if",
"lock",
"else",
"null_context",
"with",
"context",
"(",
")",
... | Assigns B to A.attr, yields, and then assigns A.attr back to its
original value. | [
"Assigns",
"B",
"to",
"A",
".",
"attr",
"yields",
"and",
"then",
"assigns",
"A",
".",
"attr",
"back",
"to",
"its",
"original",
"value",
"."
] | train | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/context.py#L23-L45 |
mbodenhamer/syn | syn/base_utils/context.py | delete | def delete(*args):
'''For using then deleting objects.'''
from syn.base_utils import this_module
mod = this_module(npop=3)
yield
for arg in args:
name = arg
if not isinstance(name, STR):
name = arg.__name__
delattr(mod, name) | python | def delete(*args):
'''For using then deleting objects.'''
from syn.base_utils import this_module
mod = this_module(npop=3)
yield
for arg in args:
name = arg
if not isinstance(name, STR):
name = arg.__name__
delattr(mod, name) | [
"def",
"delete",
"(",
"*",
"args",
")",
":",
"from",
"syn",
".",
"base_utils",
"import",
"this_module",
"mod",
"=",
"this_module",
"(",
"npop",
"=",
"3",
")",
"yield",
"for",
"arg",
"in",
"args",
":",
"name",
"=",
"arg",
"if",
"not",
"isinstance",
"(... | For using then deleting objects. | [
"For",
"using",
"then",
"deleting",
"objects",
"."
] | train | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/context.py#L90-L99 |
alexpearce/jobmonitor | jobmonitor/jobs.py | serialize_job | def serialize_job(job):
"""Return a dictionary representing the job."""
d = dict(
id=job.get_id(),
uri=url_for('jobs.get_job', job_id=job.get_id(), _external=True),
status=job.get_status(),
result=job.result
)
return d | python | def serialize_job(job):
"""Return a dictionary representing the job."""
d = dict(
id=job.get_id(),
uri=url_for('jobs.get_job', job_id=job.get_id(), _external=True),
status=job.get_status(),
result=job.result
)
return d | [
"def",
"serialize_job",
"(",
"job",
")",
":",
"d",
"=",
"dict",
"(",
"id",
"=",
"job",
".",
"get_id",
"(",
")",
",",
"uri",
"=",
"url_for",
"(",
"'jobs.get_job'",
",",
"job_id",
"=",
"job",
".",
"get_id",
"(",
")",
",",
"_external",
"=",
"True",
... | Return a dictionary representing the job. | [
"Return",
"a",
"dictionary",
"representing",
"the",
"job",
"."
] | train | https://github.com/alexpearce/jobmonitor/blob/c08955ed3c357b2b3518aa0853b43bc237bc0814/jobmonitor/jobs.py#L26-L34 |
noirbizarre/minibench | minibench/cli.py | resolve_pattern | def resolve_pattern(pattern):
'''Resolve a glob pattern into a filelist'''
if os.path.exists(pattern) and os.path.isdir(pattern):
pattern = os.path.join(pattern, '**/*.bench.py')
return recursive_glob(pattern) | python | def resolve_pattern(pattern):
'''Resolve a glob pattern into a filelist'''
if os.path.exists(pattern) and os.path.isdir(pattern):
pattern = os.path.join(pattern, '**/*.bench.py')
return recursive_glob(pattern) | [
"def",
"resolve_pattern",
"(",
"pattern",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"pattern",
")",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"pattern",
")",
":",
"pattern",
"=",
"os",
".",
"path",
".",
"join",
"(",
"pattern",
",",
... | Resolve a glob pattern into a filelist | [
"Resolve",
"a",
"glob",
"pattern",
"into",
"a",
"filelist"
] | train | https://github.com/noirbizarre/minibench/blob/a1ac66dc075181c62bb3c0d3a26beb5c46d5f4ab/minibench/cli.py#L144-L148 |
noirbizarre/minibench | minibench/cli.py | cli | def cli(patterns, times, json, csv, rst, md, ref, unit, precision, debug):
'''Execute minibench benchmarks'''
if ref:
ref = JSON.load(ref)
filenames = []
reporters = [CliReporter(ref=ref, debug=debug, unit=unit, precision=precision)]
kwargs = {}
for pattern in patterns or ['**/*.bench.p... | python | def cli(patterns, times, json, csv, rst, md, ref, unit, precision, debug):
'''Execute minibench benchmarks'''
if ref:
ref = JSON.load(ref)
filenames = []
reporters = [CliReporter(ref=ref, debug=debug, unit=unit, precision=precision)]
kwargs = {}
for pattern in patterns or ['**/*.bench.p... | [
"def",
"cli",
"(",
"patterns",
",",
"times",
",",
"json",
",",
"csv",
",",
"rst",
",",
"md",
",",
"ref",
",",
"unit",
",",
"precision",
",",
"debug",
")",
":",
"if",
"ref",
":",
"ref",
"=",
"JSON",
".",
"load",
"(",
"ref",
")",
"filenames",
"="... | Execute minibench benchmarks | [
"Execute",
"minibench",
"benchmarks"
] | train | https://github.com/noirbizarre/minibench/blob/a1ac66dc075181c62bb3c0d3a26beb5c46d5f4ab/minibench/cli.py#L165-L186 |
urbn/Caesium | caesium/handler.py | BaseHandler.load_json | def load_json(self):
"""Load JSON from the request body and store them in
self.request.arguments, like Tornado does by default for POSTed form
parameters.
If JSON cannot be decoded
:raises ValueError: JSON Could not be decoded
"""
try:
self.request.a... | python | def load_json(self):
"""Load JSON from the request body and store them in
self.request.arguments, like Tornado does by default for POSTed form
parameters.
If JSON cannot be decoded
:raises ValueError: JSON Could not be decoded
"""
try:
self.request.a... | [
"def",
"load_json",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"request",
".",
"arguments",
"=",
"json",
".",
"loads",
"(",
"self",
".",
"request",
".",
"body",
")",
"except",
"ValueError",
":",
"msg",
"=",
"\"Could not decode JSON: %s\"",
"%",
"sel... | Load JSON from the request body and store them in
self.request.arguments, like Tornado does by default for POSTed form
parameters.
If JSON cannot be decoded
:raises ValueError: JSON Could not be decoded | [
"Load",
"JSON",
"from",
"the",
"request",
"body",
"and",
"store",
"them",
"in",
"self",
".",
"request",
".",
"arguments",
"like",
"Tornado",
"does",
"by",
"default",
"for",
"POSTed",
"form",
"parameters",
"."
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L33-L47 |
urbn/Caesium | caesium/handler.py | BaseHandler.get_json_argument | def get_json_argument(self, name, default=None):
"""Find and return the argument with key 'name'
from JSON request data. Similar to Tornado's get_argument() method.
:param str name: The name of the json key you want to get the value for
:param bool default: The default value if nothing ... | python | def get_json_argument(self, name, default=None):
"""Find and return the argument with key 'name'
from JSON request data. Similar to Tornado's get_argument() method.
:param str name: The name of the json key you want to get the value for
:param bool default: The default value if nothing ... | [
"def",
"get_json_argument",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"if",
"default",
"is",
"None",
":",
"default",
"=",
"self",
".",
"_ARG_DEFAULT",
"if",
"not",
"self",
".",
"request",
".",
"arguments",
":",
"self",
".",
"load... | Find and return the argument with key 'name'
from JSON request data. Similar to Tornado's get_argument() method.
:param str name: The name of the json key you want to get the value for
:param bool default: The default value if nothing is found
:returns: value of the argument name reques... | [
"Find",
"and",
"return",
"the",
"argument",
"with",
"key",
"name",
"from",
"JSON",
"request",
"data",
".",
"Similar",
"to",
"Tornado",
"s",
"get_argument",
"()",
"method",
"."
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L49-L72 |
urbn/Caesium | caesium/handler.py | BaseHandler.get_dict_of_all_args | def get_dict_of_all_args(self):
"""Generates a dictionary from a handler paths query string and returns it
:returns: Dictionary of all key/values in arguments list
:rtype: dict
"""
dictionary = {}
for arg in [arg for arg in self.request.arguments if arg not in self.setti... | python | def get_dict_of_all_args(self):
"""Generates a dictionary from a handler paths query string and returns it
:returns: Dictionary of all key/values in arguments list
:rtype: dict
"""
dictionary = {}
for arg in [arg for arg in self.request.arguments if arg not in self.setti... | [
"def",
"get_dict_of_all_args",
"(",
"self",
")",
":",
"dictionary",
"=",
"{",
"}",
"for",
"arg",
"in",
"[",
"arg",
"for",
"arg",
"in",
"self",
".",
"request",
".",
"arguments",
"if",
"arg",
"not",
"in",
"self",
".",
"settings",
".",
"get",
"(",
"\"re... | Generates a dictionary from a handler paths query string and returns it
:returns: Dictionary of all key/values in arguments list
:rtype: dict | [
"Generates",
"a",
"dictionary",
"from",
"a",
"handler",
"paths",
"query",
"string",
"and",
"returns",
"it"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L74-L85 |
urbn/Caesium | caesium/handler.py | BaseHandler.get_arg_value_as_type | def get_arg_value_as_type(self, key, default=None, convert_int=False):
"""Allow users to pass through truthy type values like true, yes, no and get to a typed variable in your code
:param str val: The string reprensentation of the value you want to convert
:returns: adapted value
:rtype... | python | def get_arg_value_as_type(self, key, default=None, convert_int=False):
"""Allow users to pass through truthy type values like true, yes, no and get to a typed variable in your code
:param str val: The string reprensentation of the value you want to convert
:returns: adapted value
:rtype... | [
"def",
"get_arg_value_as_type",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
",",
"convert_int",
"=",
"False",
")",
":",
"val",
"=",
"self",
".",
"get_query_argument",
"(",
"key",
",",
"default",
")",
"if",
"isinstance",
"(",
"val",
",",
"int",
... | Allow users to pass through truthy type values like true, yes, no and get to a typed variable in your code
:param str val: The string reprensentation of the value you want to convert
:returns: adapted value
:rtype: dynamic | [
"Allow",
"users",
"to",
"pass",
"through",
"truthy",
"type",
"values",
"like",
"true",
"yes",
"no",
"and",
"get",
"to",
"a",
"typed",
"variable",
"in",
"your",
"code"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L87-L106 |
urbn/Caesium | caesium/handler.py | BaseHandler.get_mongo_query_from_arguments | def get_mongo_query_from_arguments(self, reserved_attributes=[]):
"""Generate a mongo query from the given URL query parameters, handles OR query via multiples
:param list reserved_attributes: A list of attributes you want to exclude from this particular query
:return: dict
"""
... | python | def get_mongo_query_from_arguments(self, reserved_attributes=[]):
"""Generate a mongo query from the given URL query parameters, handles OR query via multiples
:param list reserved_attributes: A list of attributes you want to exclude from this particular query
:return: dict
"""
... | [
"def",
"get_mongo_query_from_arguments",
"(",
"self",
",",
"reserved_attributes",
"=",
"[",
"]",
")",
":",
"query",
"=",
"{",
"}",
"for",
"arg",
"in",
"self",
".",
"request",
".",
"arguments",
":",
"if",
"arg",
"not",
"in",
"reserved_attributes",
":",
"if"... | Generate a mongo query from the given URL query parameters, handles OR query via multiples
:param list reserved_attributes: A list of attributes you want to exclude from this particular query
:return: dict | [
"Generate",
"a",
"mongo",
"query",
"from",
"the",
"given",
"URL",
"query",
"parameters",
"handles",
"OR",
"query",
"via",
"multiples"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L108-L125 |
urbn/Caesium | caesium/handler.py | BaseHandler.obj_cursor_to_json | def obj_cursor_to_json(self, cursor):
"""Handle conversion of pymongo cursor into a JSON object formatted for UI consumption
:param Cursor cursor: A motor client database cursor
"""
json_object = json.loads(json_util.dumps(cursor))
if "_id" in json_object:
json_obje... | python | def obj_cursor_to_json(self, cursor):
"""Handle conversion of pymongo cursor into a JSON object formatted for UI consumption
:param Cursor cursor: A motor client database cursor
"""
json_object = json.loads(json_util.dumps(cursor))
if "_id" in json_object:
json_obje... | [
"def",
"obj_cursor_to_json",
"(",
"self",
",",
"cursor",
")",
":",
"json_object",
"=",
"json",
".",
"loads",
"(",
"json_util",
".",
"dumps",
"(",
"cursor",
")",
")",
"if",
"\"_id\"",
"in",
"json_object",
":",
"json_object",
"[",
"'id'",
"]",
"=",
"str",
... | Handle conversion of pymongo cursor into a JSON object formatted for UI consumption
:param Cursor cursor: A motor client database cursor | [
"Handle",
"conversion",
"of",
"pymongo",
"cursor",
"into",
"a",
"JSON",
"object",
"formatted",
"for",
"UI",
"consumption"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L133-L144 |
urbn/Caesium | caesium/handler.py | BaseHandler._get_meta_data | def _get_meta_data(self):
"""Creates the meta data dictionary for a revision"""
return {
"comment": self.request.headers.get("comment", ""),
"author": self.get_current_user() or self.settings.get('annonymous_user')
} | python | def _get_meta_data(self):
"""Creates the meta data dictionary for a revision"""
return {
"comment": self.request.headers.get("comment", ""),
"author": self.get_current_user() or self.settings.get('annonymous_user')
} | [
"def",
"_get_meta_data",
"(",
"self",
")",
":",
"return",
"{",
"\"comment\"",
":",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"comment\"",
",",
"\"\"",
")",
",",
"\"author\"",
":",
"self",
".",
"get_current_user",
"(",
")",
"or",
"self",
... | Creates the meta data dictionary for a revision | [
"Creates",
"the",
"meta",
"data",
"dictionary",
"for",
"a",
"revision"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L146-L151 |
urbn/Caesium | caesium/handler.py | BaseHandler.json_obj_to_cursor | def json_obj_to_cursor(self, json):
"""(Deprecated) Converts a JSON object to a mongo db cursor
:param str json: A json string
:returns: dictionary with ObjectId type
:rtype: dict
"""
cursor = json_util.loads(json)
if "id" in json:
cursor["_id"] = Obj... | python | def json_obj_to_cursor(self, json):
"""(Deprecated) Converts a JSON object to a mongo db cursor
:param str json: A json string
:returns: dictionary with ObjectId type
:rtype: dict
"""
cursor = json_util.loads(json)
if "id" in json:
cursor["_id"] = Obj... | [
"def",
"json_obj_to_cursor",
"(",
"self",
",",
"json",
")",
":",
"cursor",
"=",
"json_util",
".",
"loads",
"(",
"json",
")",
"if",
"\"id\"",
"in",
"json",
":",
"cursor",
"[",
"\"_id\"",
"]",
"=",
"ObjectId",
"(",
"cursor",
"[",
"\"id\"",
"]",
")",
"d... | (Deprecated) Converts a JSON object to a mongo db cursor
:param str json: A json string
:returns: dictionary with ObjectId type
:rtype: dict | [
"(",
"Deprecated",
")",
"Converts",
"a",
"JSON",
"object",
"to",
"a",
"mongo",
"db",
"cursor"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L153-L165 |
urbn/Caesium | caesium/handler.py | BaseHandler.arg_as_array | def arg_as_array(self, arg, split_char="|"):
"""Turns an argument into an array, split by the splitChar
:param str arg: The name of the query param you want to turn into an array based on the value
:param str split_char: The character the value should be split on.
:returns: A list of va... | python | def arg_as_array(self, arg, split_char="|"):
"""Turns an argument into an array, split by the splitChar
:param str arg: The name of the query param you want to turn into an array based on the value
:param str split_char: The character the value should be split on.
:returns: A list of va... | [
"def",
"arg_as_array",
"(",
"self",
",",
"arg",
",",
"split_char",
"=",
"\"|\"",
")",
":",
"valuesString",
"=",
"self",
".",
"get_argument",
"(",
"arg",
",",
"default",
"=",
"None",
")",
"if",
"valuesString",
":",
"valuesArray",
"=",
"valuesString",
".",
... | Turns an argument into an array, split by the splitChar
:param str arg: The name of the query param you want to turn into an array based on the value
:param str split_char: The character the value should be split on.
:returns: A list of values
:rtype: list | [
"Turns",
"an",
"argument",
"into",
"an",
"array",
"split",
"by",
"the",
"splitChar"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L167-L180 |
urbn/Caesium | caesium/handler.py | BaseHandler.raise_error | def raise_error(self, status=500, message="Generic server error. Out of luck..."):
"""
Sets an error status and returns a message to the user in JSON format
:param int status: The status code to use
:param str message: The message to return in the JSON response
"""
self... | python | def raise_error(self, status=500, message="Generic server error. Out of luck..."):
"""
Sets an error status and returns a message to the user in JSON format
:param int status: The status code to use
:param str message: The message to return in the JSON response
"""
self... | [
"def",
"raise_error",
"(",
"self",
",",
"status",
"=",
"500",
",",
"message",
"=",
"\"Generic server error. Out of luck...\"",
")",
":",
"self",
".",
"set_status",
"(",
"status",
")",
"self",
".",
"write",
"(",
"{",
"\"message\"",
":",
"message",
",",
"\"st... | Sets an error status and returns a message to the user in JSON format
:param int status: The status code to use
:param str message: The message to return in the JSON response | [
"Sets",
"an",
"error",
"status",
"and",
"returns",
"a",
"message",
"to",
"the",
"user",
"in",
"JSON",
"format"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L182-L191 |
urbn/Caesium | caesium/handler.py | BaseHandler.return_resource | def return_resource(self, resource, status=200, statusMessage="OK"):
"""Return a resource response
:param str resource: The JSON String representation of a resource response
:param int status: Status code to use
:param str statusMessage: The message to use in the error response
... | python | def return_resource(self, resource, status=200, statusMessage="OK"):
"""Return a resource response
:param str resource: The JSON String representation of a resource response
:param int status: Status code to use
:param str statusMessage: The message to use in the error response
... | [
"def",
"return_resource",
"(",
"self",
",",
"resource",
",",
"status",
"=",
"200",
",",
"statusMessage",
"=",
"\"OK\"",
")",
":",
"self",
".",
"set_status",
"(",
"status",
",",
"statusMessage",
")",
"self",
".",
"write",
"(",
"json",
".",
"loads",
"(",
... | Return a resource response
:param str resource: The JSON String representation of a resource response
:param int status: Status code to use
:param str statusMessage: The message to use in the error response | [
"Return",
"a",
"resource",
"response"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L200-L208 |
urbn/Caesium | caesium/handler.py | BaseHandler.group_objects_by | def group_objects_by(self, list, attr, valueLabel="value", childrenLabel="children"):
"""
Generates a group object based on the attribute value on of the given attr value that is passed in.
:param list list: A list of dictionary objects
:param str attr: The attribute that the dictionari... | python | def group_objects_by(self, list, attr, valueLabel="value", childrenLabel="children"):
"""
Generates a group object based on the attribute value on of the given attr value that is passed in.
:param list list: A list of dictionary objects
:param str attr: The attribute that the dictionari... | [
"def",
"group_objects_by",
"(",
"self",
",",
"list",
",",
"attr",
",",
"valueLabel",
"=",
"\"value\"",
",",
"childrenLabel",
"=",
"\"children\"",
")",
":",
"groups",
"=",
"[",
"]",
"for",
"obj",
"in",
"list",
":",
"val",
"=",
"obj",
".",
"get",
"(",
... | Generates a group object based on the attribute value on of the given attr value that is passed in.
:param list list: A list of dictionary objects
:param str attr: The attribute that the dictionaries should be sorted upon
:param str valueLabel: What to call the key of the field we're sorting up... | [
"Generates",
"a",
"group",
"object",
"based",
"on",
"the",
"attribute",
"value",
"on",
"of",
"the",
"given",
"attr",
"value",
"that",
"is",
"passed",
"in",
"."
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L211-L242 |
urbn/Caesium | caesium/handler.py | BaseHandler.write_hyper_response | def write_hyper_response(self, links=[], meta={}, entity_name=None, entity=None, notifications=[], actions=[]):
"""Writes a hyper media response object
:param list links: A list of links to the resources
:param dict meta: The meta data for this response
:param str entity_name: The entit... | python | def write_hyper_response(self, links=[], meta={}, entity_name=None, entity=None, notifications=[], actions=[]):
"""Writes a hyper media response object
:param list links: A list of links to the resources
:param dict meta: The meta data for this response
:param str entity_name: The entit... | [
"def",
"write_hyper_response",
"(",
"self",
",",
"links",
"=",
"[",
"]",
",",
"meta",
"=",
"{",
"}",
",",
"entity_name",
"=",
"None",
",",
"entity",
"=",
"None",
",",
"notifications",
"=",
"[",
"]",
",",
"actions",
"=",
"[",
"]",
")",
":",
"assert"... | Writes a hyper media response object
:param list links: A list of links to the resources
:param dict meta: The meta data for this response
:param str entity_name: The entity name
:param object entity: The Entity itself
:param list notifications: List of notifications
:pa... | [
"Writes",
"a",
"hyper",
"media",
"response",
"object"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L252-L275 |
urbn/Caesium | caesium/handler.py | BaseRestfulMotorHandler.get | def get(self, id):
"""
Get an by object by unique identifier
:id string id: the bson id of an object
:rtype: JSON
"""
try:
if self.request.headers.get("Id"):
object_ = yield self.client.find_one({self.request.headers.get("Id"): id})
... | python | def get(self, id):
"""
Get an by object by unique identifier
:id string id: the bson id of an object
:rtype: JSON
"""
try:
if self.request.headers.get("Id"):
object_ = yield self.client.find_one({self.request.headers.get("Id"): id})
... | [
"def",
"get",
"(",
"self",
",",
"id",
")",
":",
"try",
":",
"if",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"Id\"",
")",
":",
"object_",
"=",
"yield",
"self",
".",
"client",
".",
"find_one",
"(",
"{",
"self",
".",
"request",
".",... | Get an by object by unique identifier
:id string id: the bson id of an object
:rtype: JSON | [
"Get",
"an",
"by",
"object",
"by",
"unique",
"identifier"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L294-L317 |
urbn/Caesium | caesium/handler.py | BaseRestfulMotorHandler.put | def put(self, id):
"""
Update a resource by bson ObjectId
:returns: json string representation
:rtype: JSON
"""
try:
#Async update flow
object_ = json_util.loads(self.request.body)
toa = self.request.headers.get("Caesium-TOA", None)
... | python | def put(self, id):
"""
Update a resource by bson ObjectId
:returns: json string representation
:rtype: JSON
"""
try:
#Async update flow
object_ = json_util.loads(self.request.body)
toa = self.request.headers.get("Caesium-TOA", None)
... | [
"def",
"put",
"(",
"self",
",",
"id",
")",
":",
"try",
":",
"#Async update flow",
"object_",
"=",
"json_util",
".",
"loads",
"(",
"self",
".",
"request",
".",
"body",
")",
"toa",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"Caesiu... | Update a resource by bson ObjectId
:returns: json string representation
:rtype: JSON | [
"Update",
"a",
"resource",
"by",
"bson",
"ObjectId"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L321-L377 |
urbn/Caesium | caesium/handler.py | BaseRestfulMotorHandler.post | def post(self, id=None):
"""
Create a new object resource
:json: Object to create
:returns: json string representation
:rtype: JSON
"""
try:
try:
base_object = json_util.loads(self.request.body)
except TypeError:
... | python | def post(self, id=None):
"""
Create a new object resource
:json: Object to create
:returns: json string representation
:rtype: JSON
"""
try:
try:
base_object = json_util.loads(self.request.body)
except TypeError:
... | [
"def",
"post",
"(",
"self",
",",
"id",
"=",
"None",
")",
":",
"try",
":",
"try",
":",
"base_object",
"=",
"json_util",
".",
"loads",
"(",
"self",
".",
"request",
".",
"body",
")",
"except",
"TypeError",
":",
"base_object",
"=",
"json_util",
".",
"loa... | Create a new object resource
:json: Object to create
:returns: json string representation
:rtype: JSON | [
"Create",
"a",
"new",
"object",
"resource"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L381-L428 |
urbn/Caesium | caesium/handler.py | BaseRestfulMotorHandler.delete | def delete(self, id):
"""
Delete a resource by bson id
:raises: 404 Not Found
:raises: 400 Bad request
:raises: 500 Server Error
"""
try:
response = yield self.client.delete(id)
if response.get("n") > 0:
self.write({"messag... | python | def delete(self, id):
"""
Delete a resource by bson id
:raises: 404 Not Found
:raises: 400 Bad request
:raises: 500 Server Error
"""
try:
response = yield self.client.delete(id)
if response.get("n") > 0:
self.write({"messag... | [
"def",
"delete",
"(",
"self",
",",
"id",
")",
":",
"try",
":",
"response",
"=",
"yield",
"self",
".",
"client",
".",
"delete",
"(",
"id",
")",
"if",
"response",
".",
"get",
"(",
"\"n\"",
")",
">",
"0",
":",
"self",
".",
"write",
"(",
"{",
"\"me... | Delete a resource by bson id
:raises: 404 Not Found
:raises: 400 Bad request
:raises: 500 Server Error | [
"Delete",
"a",
"resource",
"by",
"bson",
"id",
":",
"raises",
":",
"404",
"Not",
"Found",
":",
"raises",
":",
"400",
"Bad",
"request",
":",
"raises",
":",
"500",
"Server",
"Error"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L431-L452 |
urbn/Caesium | caesium/handler.py | BaseRevisionList.initialize | def initialize(self):
"""Initializer for the Search Handler"""
self.logger = logging.getLogger(self.__class__.__name__)
self.client = None | python | def initialize(self):
"""Initializer for the Search Handler"""
self.logger = logging.getLogger(self.__class__.__name__)
self.client = None | [
"def",
"initialize",
"(",
"self",
")",
":",
"self",
".",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"__class__",
".",
"__name__",
")",
"self",
".",
"client",
"=",
"None"
] | Initializer for the Search Handler | [
"Initializer",
"for",
"the",
"Search",
"Handler"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L456-L460 |
urbn/Caesium | caesium/handler.py | BaseRevisionList.__lazy_migration | def __lazy_migration(self, master_id):
"""
Creates a revision for a master id that didn't previously have a
revision, this allows you to easily turn on revisioning for a
collection that didn't previously allow for it.
:param master_id:
:returns: list of objects
"... | python | def __lazy_migration(self, master_id):
"""
Creates a revision for a master id that didn't previously have a
revision, this allows you to easily turn on revisioning for a
collection that didn't previously allow for it.
:param master_id:
:returns: list of objects
"... | [
"def",
"__lazy_migration",
"(",
"self",
",",
"master_id",
")",
":",
"collection_name",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"collection\"",
")",
"if",
"collection_name",
":",
"stack",
"=",
"AsyncSchedulableDocumentRevisionStack",
"(",
... | Creates a revision for a master id that didn't previously have a
revision, this allows you to easily turn on revisioning for a
collection that didn't previously allow for it.
:param master_id:
:returns: list of objects | [
"Creates",
"a",
"revision",
"for",
"a",
"master",
"id",
"that",
"didn",
"t",
"previously",
"have",
"a",
"revision",
"this",
"allows",
"you",
"to",
"easily",
"turn",
"on",
"revisioning",
"for",
"a",
"collection",
"that",
"didn",
"t",
"previously",
"allow",
... | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L463-L486 |
urbn/Caesium | caesium/handler.py | BaseRevisionList.get | def get(self, master_id):
"""
Get a list of revisions by master ID
:param master_id:
:return:
"""
collection_name = self.request.headers.get("collection")
self.client = BaseAsyncMotorDocument("%s_revisions" % collection_name)
limit = self.get_query_argum... | python | def get(self, master_id):
"""
Get a list of revisions by master ID
:param master_id:
:return:
"""
collection_name = self.request.headers.get("collection")
self.client = BaseAsyncMotorDocument("%s_revisions" % collection_name)
limit = self.get_query_argum... | [
"def",
"get",
"(",
"self",
",",
"master_id",
")",
":",
"collection_name",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"collection\"",
")",
"self",
".",
"client",
"=",
"BaseAsyncMotorDocument",
"(",
"\"%s_revisions\"",
"%",
"collection_name"... | Get a list of revisions by master ID
:param master_id:
:return: | [
"Get",
"a",
"list",
"of",
"revisions",
"by",
"master",
"ID"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L489-L548 |
urbn/Caesium | caesium/handler.py | RevisionHandler.put | def put(self, id):
"""
Update a revision by ID
:param id: BSON id
:return:
"""
collection_name = self.request.headers.get("collection")
if not collection_name:
self.raise_error(400, "Missing a collection name header")
self.client = BaseAsyn... | python | def put(self, id):
"""
Update a revision by ID
:param id: BSON id
:return:
"""
collection_name = self.request.headers.get("collection")
if not collection_name:
self.raise_error(400, "Missing a collection name header")
self.client = BaseAsyn... | [
"def",
"put",
"(",
"self",
",",
"id",
")",
":",
"collection_name",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"collection\"",
")",
"if",
"not",
"collection_name",
":",
"self",
".",
"raise_error",
"(",
"400",
",",
"\"Missing a collectio... | Update a revision by ID
:param id: BSON id
:return: | [
"Update",
"a",
"revision",
"by",
"ID"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L559-L574 |
urbn/Caesium | caesium/handler.py | RevisionHandler.get | def get(self, id):
"""
Get revision based on the stack preview algorithm
:param id: BSON id
:return: JSON
"""
collection_name = self.request.headers.get("collection")
if not collection_name:
self.raise_error(400, "Missing a collection name for stack"... | python | def get(self, id):
"""
Get revision based on the stack preview algorithm
:param id: BSON id
:return: JSON
"""
collection_name = self.request.headers.get("collection")
if not collection_name:
self.raise_error(400, "Missing a collection name for stack"... | [
"def",
"get",
"(",
"self",
",",
"id",
")",
":",
"collection_name",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"collection\"",
")",
"if",
"not",
"collection_name",
":",
"self",
".",
"raise_error",
"(",
"400",
",",
"\"Missing a collectio... | Get revision based on the stack preview algorithm
:param id: BSON id
:return: JSON | [
"Get",
"revision",
"based",
"on",
"the",
"stack",
"preview",
"algorithm"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L613-L628 |
urbn/Caesium | caesium/handler.py | BaseMotorSearch.get | def get(self):
"""
Standard search end point for a resource of any type, override this get method as necessary
in any specifc sub class. This is mostly here as a convenience for basic querying functionality
on attribute
example URL::
foo?attr1=foo&attr2=true
... | python | def get(self):
"""
Standard search end point for a resource of any type, override this get method as necessary
in any specifc sub class. This is mostly here as a convenience for basic querying functionality
on attribute
example URL::
foo?attr1=foo&attr2=true
... | [
"def",
"get",
"(",
"self",
")",
":",
"objects",
"=",
"yield",
"self",
".",
"client",
".",
"find",
"(",
"self",
".",
"get_mongo_query_from_arguments",
"(",
")",
")",
"self",
".",
"write",
"(",
"{",
"\"count\"",
":",
"len",
"(",
"objects",
")",
",",
"\... | Standard search end point for a resource of any type, override this get method as necessary
in any specifc sub class. This is mostly here as a convenience for basic querying functionality
on attribute
example URL::
foo?attr1=foo&attr2=true
will create a query of::
... | [
"Standard",
"search",
"end",
"point",
"for",
"a",
"resource",
"of",
"any",
"type",
"override",
"this",
"get",
"method",
"as",
"necessary",
"in",
"any",
"specifc",
"sub",
"class",
".",
"This",
"is",
"mostly",
"here",
"as",
"a",
"convenience",
"for",
"basic"... | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L640-L666 |
urbn/Caesium | caesium/handler.py | BaseBulkScheduleableUpdateHandler.put | def put(self, id=None):
"""Update many objects with a single PUT.
Example Request::
{
"ids": ["52b0ede98ac752b358b1bd69", "52b0ede98ac752b358b1bd70"],
"patch": {
"foo": "bar"
}
}
"""
toa = sel... | python | def put(self, id=None):
"""Update many objects with a single PUT.
Example Request::
{
"ids": ["52b0ede98ac752b358b1bd69", "52b0ede98ac752b358b1bd70"],
"patch": {
"foo": "bar"
}
}
"""
toa = sel... | [
"def",
"put",
"(",
"self",
",",
"id",
"=",
"None",
")",
":",
"toa",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"Caesium-TOA\"",
")",
"if",
"not",
"toa",
":",
"self",
".",
"raise_error",
"(",
"400",
",",
"\"Caesium-TOA header is req... | Update many objects with a single PUT.
Example Request::
{
"ids": ["52b0ede98ac752b358b1bd69", "52b0ede98ac752b358b1bd70"],
"patch": {
"foo": "bar"
}
} | [
"Update",
"many",
"objects",
"with",
"a",
"single",
"PUT",
"."
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L675-L713 |
urbn/Caesium | caesium/handler.py | BaseBulkScheduleableUpdateHandler.delete | def delete(self, bulk_id):
"""Update many objects with a single toa
:param str bulk_id: The bulk id for the job you want to delete
"""
collection_name = self.request.headers.get("collection")
if not collection_name:
self.raise_error(400, "Missing a collection name ... | python | def delete(self, bulk_id):
"""Update many objects with a single toa
:param str bulk_id: The bulk id for the job you want to delete
"""
collection_name = self.request.headers.get("collection")
if not collection_name:
self.raise_error(400, "Missing a collection name ... | [
"def",
"delete",
"(",
"self",
",",
"bulk_id",
")",
":",
"collection_name",
"=",
"self",
".",
"request",
".",
"headers",
".",
"get",
"(",
"\"collection\"",
")",
"if",
"not",
"collection_name",
":",
"self",
".",
"raise_error",
"(",
"400",
",",
"\"Missing a c... | Update many objects with a single toa
:param str bulk_id: The bulk id for the job you want to delete | [
"Update",
"many",
"objects",
"with",
"a",
"single",
"toa"
] | train | https://github.com/urbn/Caesium/blob/2a14fe79724c38fe9a1b20f7b8f518f8c6d50df1/caesium/handler.py#L716-L733 |
stephanepechard/projy | projy/collectors/AuthorCollector.py | AuthorCollector.author_from_git | def author_from_git(self):
""" Get the author name from git information. """
self.author = None
try:
encoding = locale.getdefaultlocale()[1]
# launch git command and get answer
cmd = Popen(["git", "config", "--get", "user.name"], stdout=PIPE)
stdou... | python | def author_from_git(self):
""" Get the author name from git information. """
self.author = None
try:
encoding = locale.getdefaultlocale()[1]
# launch git command and get answer
cmd = Popen(["git", "config", "--get", "user.name"], stdout=PIPE)
stdou... | [
"def",
"author_from_git",
"(",
"self",
")",
":",
"self",
".",
"author",
"=",
"None",
"try",
":",
"encoding",
"=",
"locale",
".",
"getdefaultlocale",
"(",
")",
"[",
"1",
"]",
"# launch git command and get answer",
"cmd",
"=",
"Popen",
"(",
"[",
"\"git\"",
"... | Get the author name from git information. | [
"Get",
"the",
"author",
"name",
"from",
"git",
"information",
"."
] | train | https://github.com/stephanepechard/projy/blob/3146b0e3c207b977e1b51fcb33138746dae83c23/projy/collectors/AuthorCollector.py#L26-L45 |
metagriffin/secpass | secpass/util.py | zulu | def zulu(ts=None, ms=True):
'''
Returns the specified epoch time (or current time if None or not
provided) as an ISO 8601 string in zulu time (with millisecond
precision), e.g. zulu(1362187446.553) => '2013-03-02T01:24:06.553Z'.
If `ms` is True (the default), milliseconds will be included, otherwise
truncat... | python | def zulu(ts=None, ms=True):
'''
Returns the specified epoch time (or current time if None or not
provided) as an ISO 8601 string in zulu time (with millisecond
precision), e.g. zulu(1362187446.553) => '2013-03-02T01:24:06.553Z'.
If `ms` is True (the default), milliseconds will be included, otherwise
truncat... | [
"def",
"zulu",
"(",
"ts",
"=",
"None",
",",
"ms",
"=",
"True",
")",
":",
"if",
"ts",
"is",
"None",
":",
"ts",
"=",
"time",
".",
"time",
"(",
")",
"ms",
"=",
"'.%03dZ'",
"%",
"(",
"ts",
"*",
"1000",
"%",
"1000",
",",
")",
"if",
"ms",
"else",... | Returns the specified epoch time (or current time if None or not
provided) as an ISO 8601 string in zulu time (with millisecond
precision), e.g. zulu(1362187446.553) => '2013-03-02T01:24:06.553Z'.
If `ms` is True (the default), milliseconds will be included, otherwise
truncated. | [
"Returns",
"the",
"specified",
"epoch",
"time",
"(",
"or",
"current",
"time",
"if",
"None",
"or",
"not",
"provided",
")",
"as",
"an",
"ISO",
"8601",
"string",
"in",
"zulu",
"time",
"(",
"with",
"millisecond",
"precision",
")",
"e",
".",
"g",
".",
"zulu... | train | https://github.com/metagriffin/secpass/blob/7ec29666e82cb8900e5c36552ab2ee3403021a6a/secpass/util.py#L58-L69 |
jaraco/jaraco.compat | py31compat/cache.py | lru_cache | def lru_cache(maxsize=100, typed=False):
"""Least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.
If *typed* is True, arguments of different types will be cached separately.
For example, f(3.0) and f(3) will be treated as distinct ca... | python | def lru_cache(maxsize=100, typed=False):
"""Least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.
If *typed* is True, arguments of different types will be cached separately.
For example, f(3.0) and f(3) will be treated as distinct ca... | [
"def",
"lru_cache",
"(",
"maxsize",
"=",
"100",
",",
"typed",
"=",
"False",
")",
":",
"# Users should only access the lru_cache through its public API:",
"# cache_info, cache_clear, and f.__wrapped__",
"# The internals of the lru_cache are encapsulated for thread safety and",
"# to... | Least-recently-used cache decorator.
If *maxsize* is set to None, the LRU features are disabled and the cache
can grow without bound.
If *typed* is True, arguments of different types will be cached separately.
For example, f(3.0) and f(3) will be treated as distinct calls with
distinct results.
Arguments to th... | [
"Least",
"-",
"recently",
"-",
"used",
"cache",
"decorator",
"."
] | train | https://github.com/jaraco/jaraco.compat/blob/e61efd45d92e3c7db6d8fb28d47f38f43193a6f5/py31compat/cache.py#L35-L148 |
akatrevorjay/mainline | mainline/catalog.py | ProviderMapping.update | def update(self, arg, allow_overwrite=False):
"""
Update our providers from either an ICatalog subclass/instance or a mapping.
If arg is an ICatalog, we update from it's ._providers attribute.
:param arg: Di/Catalog/Mapping to update from.
:type arg: ICatalog or collections.Map... | python | def update(self, arg, allow_overwrite=False):
"""
Update our providers from either an ICatalog subclass/instance or a mapping.
If arg is an ICatalog, we update from it's ._providers attribute.
:param arg: Di/Catalog/Mapping to update from.
:type arg: ICatalog or collections.Map... | [
"def",
"update",
"(",
"self",
",",
"arg",
",",
"allow_overwrite",
"=",
"False",
")",
":",
"# If arg happens to be an ICatalog subclass",
"if",
"inspect",
".",
"isclass",
"(",
"arg",
")",
"and",
"issubclass",
"(",
"arg",
",",
"ICatalog",
")",
"or",
"isinstance"... | Update our providers from either an ICatalog subclass/instance or a mapping.
If arg is an ICatalog, we update from it's ._providers attribute.
:param arg: Di/Catalog/Mapping to update from.
:type arg: ICatalog or collections.Mapping
:param allow_overwrite: If True, allow overwriting ex... | [
"Update",
"our",
"providers",
"from",
"either",
"an",
"ICatalog",
"subclass",
"/",
"instance",
"or",
"a",
"mapping",
"."
] | train | https://github.com/akatrevorjay/mainline/blob/8aa7f6ef6cad4051fcd5f8d43d2ba8cdad681986/mainline/catalog.py#L27-L45 |
gsamokovarov/frames.py | frames/compat.py | _getframe | def _getframe(level=0):
'''
A reimplementation of `sys._getframe`.
`sys._getframe` is a private function, and isn't guaranteed to exist in all
versions and implementations of Python.
This function is about 2 times slower than the native implementation. It
relies on the asumption that the trace... | python | def _getframe(level=0):
'''
A reimplementation of `sys._getframe`.
`sys._getframe` is a private function, and isn't guaranteed to exist in all
versions and implementations of Python.
This function is about 2 times slower than the native implementation. It
relies on the asumption that the trace... | [
"def",
"_getframe",
"(",
"level",
"=",
"0",
")",
":",
"if",
"level",
"<",
"0",
":",
"level",
"=",
"0",
"try",
":",
"raise",
"except",
":",
"# `sys.exc_info` returns `(type, value, traceback)`.",
"_",
",",
"_",
",",
"traceback",
"=",
"sys",
".",
"exc_info",... | A reimplementation of `sys._getframe`.
`sys._getframe` is a private function, and isn't guaranteed to exist in all
versions and implementations of Python.
This function is about 2 times slower than the native implementation. It
relies on the asumption that the traceback objects have `tb_frame`
att... | [
"A",
"reimplementation",
"of",
"sys",
".",
"_getframe",
"."
] | train | https://github.com/gsamokovarov/frames.py/blob/ba43782d043691fb5a388a1e749e0f0edb68a3d7/frames/compat.py#L4-L47 |
johnnoone/facts | facts/grafts/__init__.py | graft | def graft(func=None, *, namespace=None):
"""Decorator for marking a function as a graft.
Parameters:
namespace (str): namespace of data, same format as targeting.
Returns:
Graft
For example, these grafts::
@graft
def foo_data:
return {'foo', True}
... | python | def graft(func=None, *, namespace=None):
"""Decorator for marking a function as a graft.
Parameters:
namespace (str): namespace of data, same format as targeting.
Returns:
Graft
For example, these grafts::
@graft
def foo_data:
return {'foo', True}
... | [
"def",
"graft",
"(",
"func",
"=",
"None",
",",
"*",
",",
"namespace",
"=",
"None",
")",
":",
"if",
"not",
"func",
":",
"return",
"functools",
".",
"partial",
"(",
"graft",
",",
"namespace",
"=",
"namespace",
")",
"if",
"isinstance",
"(",
"func",
",",... | Decorator for marking a function as a graft.
Parameters:
namespace (str): namespace of data, same format as targeting.
Returns:
Graft
For example, these grafts::
@graft
def foo_data:
return {'foo', True}
@graft(namespace='bar')
def bar_data:
... | [
"Decorator",
"for",
"marking",
"a",
"function",
"as",
"a",
"graft",
"."
] | train | https://github.com/johnnoone/facts/blob/82d38a46c15d9c01200445526f4c0d1825fc1e51/facts/grafts/__init__.py#L29-L61 |
johnnoone/facts | facts/grafts/__init__.py | load | def load(force=False):
"""Magical loading of all grafted functions.
Parameters:
force (bool): force reload
"""
if GRAFTS and not force:
return GRAFTS
# insert missing paths
# this could be a configurated item
userpath = settings.userpath
if os.path.isdir(userpath) and ... | python | def load(force=False):
"""Magical loading of all grafted functions.
Parameters:
force (bool): force reload
"""
if GRAFTS and not force:
return GRAFTS
# insert missing paths
# this could be a configurated item
userpath = settings.userpath
if os.path.isdir(userpath) and ... | [
"def",
"load",
"(",
"force",
"=",
"False",
")",
":",
"if",
"GRAFTS",
"and",
"not",
"force",
":",
"return",
"GRAFTS",
"# insert missing paths",
"# this could be a configurated item",
"userpath",
"=",
"settings",
".",
"userpath",
"if",
"os",
".",
"path",
".",
"i... | Magical loading of all grafted functions.
Parameters:
force (bool): force reload | [
"Magical",
"loading",
"of",
"all",
"grafted",
"functions",
"."
] | train | https://github.com/johnnoone/facts/blob/82d38a46c15d9c01200445526f4c0d1825fc1e51/facts/grafts/__init__.py#L70-L110 |
yougov/vr.builder | vr/builder/build.py | _write_buildproc_yaml | def _write_buildproc_yaml(build_data, env, user, cmd, volumes, app_folder):
"""
Write a proc.yaml for the container and return the container path
"""
buildproc = ProcData({
'app_folder': str(app_folder),
'app_name': build_data.app_name,
'app_repo_url': '',
'app_repo_type... | python | def _write_buildproc_yaml(build_data, env, user, cmd, volumes, app_folder):
"""
Write a proc.yaml for the container and return the container path
"""
buildproc = ProcData({
'app_folder': str(app_folder),
'app_name': build_data.app_name,
'app_repo_url': '',
'app_repo_type... | [
"def",
"_write_buildproc_yaml",
"(",
"build_data",
",",
"env",
",",
"user",
",",
"cmd",
",",
"volumes",
",",
"app_folder",
")",
":",
"buildproc",
"=",
"ProcData",
"(",
"{",
"'app_folder'",
":",
"str",
"(",
"app_folder",
")",
",",
"'app_name'",
":",
"build_... | Write a proc.yaml for the container and return the container path | [
"Write",
"a",
"proc",
".",
"yaml",
"for",
"the",
"container",
"and",
"return",
"the",
"container",
"path"
] | train | https://github.com/yougov/vr.builder/blob/666b28f997d0cff52e82eed4ace1c73fee4b2136/vr/builder/build.py#L207-L238 |
yougov/vr.builder | vr/builder/build.py | assert_compile_finished | def assert_compile_finished(app_folder):
"""
Once builder.sh has invoked the compile script, it should return and we
should set a flag to the script returned. If that flag is missing, then
it is an indication that the container crashed, and we generate an error.
This function will clean up the flag... | python | def assert_compile_finished(app_folder):
"""
Once builder.sh has invoked the compile script, it should return and we
should set a flag to the script returned. If that flag is missing, then
it is an indication that the container crashed, and we generate an error.
This function will clean up the flag... | [
"def",
"assert_compile_finished",
"(",
"app_folder",
")",
":",
"fpath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_folder",
",",
"'.postbuild.flag'",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"fpath",
")",
":",
"msg",
"=",
"(",
"'No ... | Once builder.sh has invoked the compile script, it should return and we
should set a flag to the script returned. If that flag is missing, then
it is an indication that the container crashed, and we generate an error.
This function will clean up the flag after the check is performed, so only
call this ... | [
"Once",
"builder",
".",
"sh",
"has",
"invoked",
"the",
"compile",
"script",
"it",
"should",
"return",
"and",
"we",
"should",
"set",
"a",
"flag",
"to",
"the",
"script",
"returned",
".",
"If",
"that",
"flag",
"is",
"missing",
"then",
"it",
"is",
"an",
"i... | train | https://github.com/yougov/vr.builder/blob/666b28f997d0cff52e82eed4ace1c73fee4b2136/vr/builder/build.py#L241-L259 |
yougov/vr.builder | vr/builder/build.py | recover_release_data | def recover_release_data(app_folder):
"""
Given the path to an app folder where an app was just built, return a
dictionary containing the data emitted from running the buildpack's release
script.
Relies on the builder.sh script storing the release data in ./.release.yaml
inside the app folder.
... | python | def recover_release_data(app_folder):
"""
Given the path to an app folder where an app was just built, return a
dictionary containing the data emitted from running the buildpack's release
script.
Relies on the builder.sh script storing the release data in ./.release.yaml
inside the app folder.
... | [
"def",
"recover_release_data",
"(",
"app_folder",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"app_folder",
",",
"'.release.yaml'",
")",
",",
"'rb'",
")",
"as",
"f",
":",
"return",
"yaml",
".",
"safe_load",
"(",
"f",
")"
] | Given the path to an app folder where an app was just built, return a
dictionary containing the data emitted from running the buildpack's release
script.
Relies on the builder.sh script storing the release data in ./.release.yaml
inside the app folder. | [
"Given",
"the",
"path",
"to",
"an",
"app",
"folder",
"where",
"an",
"app",
"was",
"just",
"built",
"return",
"a",
"dictionary",
"containing",
"the",
"data",
"emitted",
"from",
"running",
"the",
"buildpack",
"s",
"release",
"script",
"."
] | train | https://github.com/yougov/vr.builder/blob/666b28f997d0cff52e82eed4ace1c73fee4b2136/vr/builder/build.py#L262-L272 |
yougov/vr.builder | vr/builder/build.py | recover_buildpack | def recover_buildpack(app_folder):
"""
Given the path to an app folder where an app was just built, return a
BuildPack object pointing to the dir for the buildpack used during the
build.
Relies on the builder.sh script storing the buildpack location in
/.buildpack inside the container.
"""
... | python | def recover_buildpack(app_folder):
"""
Given the path to an app folder where an app was just built, return a
BuildPack object pointing to the dir for the buildpack used during the
build.
Relies on the builder.sh script storing the buildpack location in
/.buildpack inside the container.
"""
... | [
"def",
"recover_buildpack",
"(",
"app_folder",
")",
":",
"filepath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_folder",
",",
"'.buildpack'",
")",
"with",
"open",
"(",
"filepath",
")",
"as",
"f",
":",
"buildpack_picked",
"=",
"f",
".",
"read",
"(",
... | Given the path to an app folder where an app was just built, return a
BuildPack object pointing to the dir for the buildpack used during the
build.
Relies on the builder.sh script storing the buildpack location in
/.buildpack inside the container. | [
"Given",
"the",
"path",
"to",
"an",
"app",
"folder",
"where",
"an",
"app",
"was",
"just",
"built",
"return",
"a",
"BuildPack",
"object",
"pointing",
"to",
"the",
"dir",
"for",
"the",
"buildpack",
"used",
"during",
"the",
"build",
"."
] | train | https://github.com/yougov/vr.builder/blob/666b28f997d0cff52e82eed4ace1c73fee4b2136/vr/builder/build.py#L275-L290 |
yougov/vr.builder | vr/builder/build.py | pull_buildpack | def pull_buildpack(url):
"""
Update a buildpack in its shared location, then make a copy into the
current directory, using an md5 of the url.
"""
defrag = _defrag(urllib.parse.urldefrag(url))
with lock_or_wait(defrag.url):
bp = update_buildpack(url)
dest = bp.basename + '-' + has... | python | def pull_buildpack(url):
"""
Update a buildpack in its shared location, then make a copy into the
current directory, using an md5 of the url.
"""
defrag = _defrag(urllib.parse.urldefrag(url))
with lock_or_wait(defrag.url):
bp = update_buildpack(url)
dest = bp.basename + '-' + has... | [
"def",
"pull_buildpack",
"(",
"url",
")",
":",
"defrag",
"=",
"_defrag",
"(",
"urllib",
".",
"parse",
".",
"urldefrag",
"(",
"url",
")",
")",
"with",
"lock_or_wait",
"(",
"defrag",
".",
"url",
")",
":",
"bp",
"=",
"update_buildpack",
"(",
"url",
")",
... | Update a buildpack in its shared location, then make a copy into the
current directory, using an md5 of the url. | [
"Update",
"a",
"buildpack",
"in",
"its",
"shared",
"location",
"then",
"make",
"a",
"copy",
"into",
"the",
"current",
"directory",
"using",
"an",
"md5",
"of",
"the",
"url",
"."
] | train | https://github.com/yougov/vr.builder/blob/666b28f997d0cff52e82eed4ace1c73fee4b2136/vr/builder/build.py#L304-L317 |
yougov/vr.builder | vr/builder/build.py | OutputSaver.make_tarball | def make_tarball(self, app_folder, build_data):
"""
Following a successful build, create a tarball and build result.
"""
# slugignore
clean_slug_dir(app_folder)
# tar up the result
with tarfile.open('build.tar.gz', 'w:gz') as tar:
tar.add(app_folder, ... | python | def make_tarball(self, app_folder, build_data):
"""
Following a successful build, create a tarball and build result.
"""
# slugignore
clean_slug_dir(app_folder)
# tar up the result
with tarfile.open('build.tar.gz', 'w:gz') as tar:
tar.add(app_folder, ... | [
"def",
"make_tarball",
"(",
"self",
",",
"app_folder",
",",
"build_data",
")",
":",
"# slugignore",
"clean_slug_dir",
"(",
"app_folder",
")",
"# tar up the result",
"with",
"tarfile",
".",
"open",
"(",
"'build.tar.gz'",
",",
"'w:gz'",
")",
"as",
"tar",
":",
"t... | Following a successful build, create a tarball and build result. | [
"Following",
"a",
"successful",
"build",
"create",
"a",
"tarball",
"and",
"build",
"result",
"."
] | train | https://github.com/yougov/vr.builder/blob/666b28f997d0cff52e82eed4ace1c73fee4b2136/vr/builder/build.py#L63-L81 |
goldhand/django-nupages | nupages/middleware.py | MultiTenantMiddleware.process_request | def process_request(self, request):
'''
checks if the host domain is one of the site objects
and sets request.site_id
'''
site_id = 0
domain = request.get_host().lower()
if hasattr(settings, 'SITE_ID'):
site_id = settings.SITE_ID
try:
... | python | def process_request(self, request):
'''
checks if the host domain is one of the site objects
and sets request.site_id
'''
site_id = 0
domain = request.get_host().lower()
if hasattr(settings, 'SITE_ID'):
site_id = settings.SITE_ID
try:
... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"site_id",
"=",
"0",
"domain",
"=",
"request",
".",
"get_host",
"(",
")",
".",
"lower",
"(",
")",
"if",
"hasattr",
"(",
"settings",
",",
"'SITE_ID'",
")",
":",
"site_id",
"=",
"settings",... | checks if the host domain is one of the site objects
and sets request.site_id | [
"checks",
"if",
"the",
"host",
"domain",
"is",
"one",
"of",
"the",
"site",
"objects",
"and",
"sets",
"request",
".",
"site_id"
] | train | https://github.com/goldhand/django-nupages/blob/4e54fae7e057f9530c22dc30c03812fd660cb7f4/nupages/middleware.py#L9-L23 |
baliame/http-hmac-python | httphmac/v2.py | V2Signer.signable | def signable(self, request, authheaders, bodyhash=None):
"""Creates the signable string for a request and returns it.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropriate for thi... | python | def signable(self, request, authheaders, bodyhash=None):
"""Creates the signable string for a request and returns it.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropriate for thi... | [
"def",
"signable",
"(",
"self",
",",
"request",
",",
"authheaders",
",",
"bodyhash",
"=",
"None",
")",
":",
"method",
"=",
"request",
".",
"method",
".",
"upper",
"(",
")",
"host",
"=",
"request",
".",
"get_header",
"(",
"\"host\"",
")",
"path",
"=",
... | Creates the signable string for a request and returns it.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropriate for this signature version.
bodyhash -- The hash for the body of th... | [
"Creates",
"the",
"signable",
"string",
"for",
"a",
"request",
"and",
"returns",
"it",
"."
] | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L34-L65 |
baliame/http-hmac-python | httphmac/v2.py | V2Signer.parse_auth_headers | def parse_auth_headers(self, authorization):
"""Parses the authorization headers from the authorization header taken from a request.
Returns a dict that is accepted by all other API functions which expect authorization headers in a dict format.
parse_auth_headers(unroll_auth_headers(A)) should r... | python | def parse_auth_headers(self, authorization):
"""Parses the authorization headers from the authorization header taken from a request.
Returns a dict that is accepted by all other API functions which expect authorization headers in a dict format.
parse_auth_headers(unroll_auth_headers(A)) should r... | [
"def",
"parse_auth_headers",
"(",
"self",
",",
"authorization",
")",
":",
"matches",
"=",
"re",
".",
"findall",
"(",
"r'(\\w+)=\"(.*?)\"'",
",",
"authorization",
")",
"return",
"dict",
"(",
"matches",
")"
] | Parses the authorization headers from the authorization header taken from a request.
Returns a dict that is accepted by all other API functions which expect authorization headers in a dict format.
parse_auth_headers(unroll_auth_headers(A)) should return a dict that is equal to A.
Keyword argume... | [
"Parses",
"the",
"authorization",
"headers",
"from",
"the",
"authorization",
"header",
"taken",
"from",
"a",
"request",
".",
"Returns",
"a",
"dict",
"that",
"is",
"accepted",
"by",
"all",
"other",
"API",
"functions",
"which",
"expect",
"authorization",
"headers"... | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L67-L76 |
baliame/http-hmac-python | httphmac/v2.py | V2Signer.sign | def sign(self, request, authheaders, secret):
"""Returns the v2 signature appropriate for the request. The request is not changed by this function.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains t... | python | def sign(self, request, authheaders, secret):
"""Returns the v2 signature appropriate for the request. The request is not changed by this function.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains t... | [
"def",
"sign",
"(",
"self",
",",
"request",
",",
"authheaders",
",",
"secret",
")",
":",
"if",
"\"id\"",
"not",
"in",
"authheaders",
"or",
"authheaders",
"[",
"\"id\"",
"]",
"==",
"''",
":",
"raise",
"KeyError",
"(",
"\"id required in authorization headers.\""... | Returns the v2 signature appropriate for the request. The request is not changed by this function.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropriate for this signature version.
... | [
"Returns",
"the",
"v2",
"signature",
"appropriate",
"for",
"the",
"request",
".",
"The",
"request",
"is",
"not",
"changed",
"by",
"this",
"function",
"."
] | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L78-L109 |
baliame/http-hmac-python | httphmac/v2.py | V2Signer.get_response_signer | def get_response_signer(self):
"""Returns the response signer for this version of the signature.
"""
if not hasattr(self, "response_signer"):
self.response_signer = V2ResponseSigner(self.digest, orig=self)
return self.response_signer | python | def get_response_signer(self):
"""Returns the response signer for this version of the signature.
"""
if not hasattr(self, "response_signer"):
self.response_signer = V2ResponseSigner(self.digest, orig=self)
return self.response_signer | [
"def",
"get_response_signer",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"response_signer\"",
")",
":",
"self",
".",
"response_signer",
"=",
"V2ResponseSigner",
"(",
"self",
".",
"digest",
",",
"orig",
"=",
"self",
")",
"return",
"s... | Returns the response signer for this version of the signature. | [
"Returns",
"the",
"response",
"signer",
"for",
"this",
"version",
"of",
"the",
"signature",
"."
] | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L111-L116 |
baliame/http-hmac-python | httphmac/v2.py | V2Signer.check | def check(self, request, secret):
"""Verifies whether or not the request bears an authorization appropriate and valid for this version of the signature.
This verifies every element of the signature, including the timestamp's value.
Does not alter the request.
Keyword arguments:
... | python | def check(self, request, secret):
"""Verifies whether or not the request bears an authorization appropriate and valid for this version of the signature.
This verifies every element of the signature, including the timestamp's value.
Does not alter the request.
Keyword arguments:
... | [
"def",
"check",
"(",
"self",
",",
"request",
",",
"secret",
")",
":",
"if",
"request",
".",
"get_header",
"(",
"\"Authorization\"",
")",
"==",
"\"\"",
":",
"return",
"False",
"ah",
"=",
"self",
".",
"parse_auth_headers",
"(",
"request",
".",
"get_header",
... | Verifies whether or not the request bears an authorization appropriate and valid for this version of the signature.
This verifies every element of the signature, including the timestamp's value.
Does not alter the request.
Keyword arguments:
request -- A request object which can be cons... | [
"Verifies",
"whether",
"or",
"not",
"the",
"request",
"bears",
"an",
"authorization",
"appropriate",
"and",
"valid",
"for",
"this",
"version",
"of",
"the",
"signature",
".",
"This",
"verifies",
"every",
"element",
"of",
"the",
"signature",
"including",
"the",
... | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L128-L163 |
baliame/http-hmac-python | httphmac/v2.py | V2Signer.unroll_auth_headers | def unroll_auth_headers(self, authheaders, exclude_signature=False, sep=",", quote=True):
"""Converts an authorization header dict-like object into a string representing the authorization.
Keyword arguments:
authheaders -- A string-indexable object which contains the headers appropriate for thi... | python | def unroll_auth_headers(self, authheaders, exclude_signature=False, sep=",", quote=True):
"""Converts an authorization header dict-like object into a string representing the authorization.
Keyword arguments:
authheaders -- A string-indexable object which contains the headers appropriate for thi... | [
"def",
"unroll_auth_headers",
"(",
"self",
",",
"authheaders",
",",
"exclude_signature",
"=",
"False",
",",
"sep",
"=",
"\",\"",
",",
"quote",
"=",
"True",
")",
":",
"res",
"=",
"\"\"",
"ordered",
"=",
"collections",
".",
"OrderedDict",
"(",
"sorted",
"(",... | Converts an authorization header dict-like object into a string representing the authorization.
Keyword arguments:
authheaders -- A string-indexable object which contains the headers appropriate for this signature version. | [
"Converts",
"an",
"authorization",
"header",
"dict",
"-",
"like",
"object",
"into",
"a",
"string",
"representing",
"the",
"authorization",
"."
] | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L165-L177 |
baliame/http-hmac-python | httphmac/v2.py | V2Signer.sign_direct | def sign_direct(self, request, authheaders, secret):
"""Signs a request directly with a v2 signature. The request's Authorization header will change.
This function may also add the required X-Authorization-Timestamp and X-Authorization-Content-SHA256 headers.
Keyword arguments:
request ... | python | def sign_direct(self, request, authheaders, secret):
"""Signs a request directly with a v2 signature. The request's Authorization header will change.
This function may also add the required X-Authorization-Timestamp and X-Authorization-Content-SHA256 headers.
Keyword arguments:
request ... | [
"def",
"sign_direct",
"(",
"self",
",",
"request",
",",
"authheaders",
",",
"secret",
")",
":",
"if",
"request",
".",
"get_header",
"(",
"'x-authorization-timestamp'",
")",
"==",
"''",
":",
"request",
".",
"with_header",
"(",
"\"X-Authorization-Timestamp\"",
","... | Signs a request directly with a v2 signature. The request's Authorization header will change.
This function may also add the required X-Authorization-Timestamp and X-Authorization-Content-SHA256 headers.
Keyword arguments:
request -- A request object which can be consumed by this API.
a... | [
"Signs",
"a",
"request",
"directly",
"with",
"a",
"v2",
"signature",
".",
"The",
"request",
"s",
"Authorization",
"header",
"will",
"change",
".",
"This",
"function",
"may",
"also",
"add",
"the",
"required",
"X",
"-",
"Authorization",
"-",
"Timestamp",
"and"... | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L188-L206 |
baliame/http-hmac-python | httphmac/v2.py | V2ResponseSigner.check | def check(self, request, response, secret):
"""Checks the response for the appropriate signature. Returns True if the signature matches the expected value.
Keyword arguments:
request -- A request object which can be consumed by this API.
response -- A requests response object or compati... | python | def check(self, request, response, secret):
"""Checks the response for the appropriate signature. Returns True if the signature matches the expected value.
Keyword arguments:
request -- A request object which can be consumed by this API.
response -- A requests response object or compati... | [
"def",
"check",
"(",
"self",
",",
"request",
",",
"response",
",",
"secret",
")",
":",
"auth",
"=",
"request",
".",
"get_header",
"(",
"'Authorization'",
")",
"if",
"auth",
"==",
"''",
":",
"raise",
"KeyError",
"(",
"'Authorization header is required for the r... | Checks the response for the appropriate signature. Returns True if the signature matches the expected value.
Keyword arguments:
request -- A request object which can be consumed by this API.
response -- A requests response object or compatible signed response object.
secret -- The base6... | [
"Checks",
"the",
"response",
"for",
"the",
"appropriate",
"signature",
".",
"Returns",
"True",
"if",
"the",
"signature",
"matches",
"the",
"expected",
"value",
"."
] | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L226-L242 |
baliame/http-hmac-python | httphmac/v2.py | V2ResponseSigner.signable | def signable(self, request, authheaders, response_body):
"""Creates the signable string for a response and returns it.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropriate for th... | python | def signable(self, request, authheaders, response_body):
"""Creates the signable string for a response and returns it.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropriate for th... | [
"def",
"signable",
"(",
"self",
",",
"request",
",",
"authheaders",
",",
"response_body",
")",
":",
"nonce",
"=",
"authheaders",
"[",
"\"nonce\"",
"]",
"timestamp",
"=",
"request",
".",
"get_header",
"(",
"\"x-authorization-timestamp\"",
")",
"try",
":",
"body... | Creates the signable string for a response and returns it.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropriate for this signature version.
response_body -- A string or bytes-lik... | [
"Creates",
"the",
"signable",
"string",
"for",
"a",
"response",
"and",
"returns",
"it",
"."
] | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L244-L258 |
baliame/http-hmac-python | httphmac/v2.py | V2ResponseSigner.sign | def sign(self, request, authheaders, response_body, secret):
"""Returns the response signature for the response to the request.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropria... | python | def sign(self, request, authheaders, response_body, secret):
"""Returns the response signature for the response to the request.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropria... | [
"def",
"sign",
"(",
"self",
",",
"request",
",",
"authheaders",
",",
"response_body",
",",
"secret",
")",
":",
"if",
"\"nonce\"",
"not",
"in",
"authheaders",
"or",
"authheaders",
"[",
"\"nonce\"",
"]",
"==",
"''",
":",
"raise",
"KeyError",
"(",
"\"nonce re... | Returns the response signature for the response to the request.
Keyword arguments:
request -- A request object which can be consumed by this API.
authheaders -- A string-indexable object which contains the headers appropriate for this signature version.
response_body -- A string or byte... | [
"Returns",
"the",
"response",
"signature",
"for",
"the",
"response",
"to",
"the",
"request",
"."
] | train | https://github.com/baliame/http-hmac-python/blob/9884c0cbfdb712f9f37080a8efbfdce82850785f/httphmac/v2.py#L260-L283 |
basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/taskqueue.py | _TaskIterator.get_items_from_response | def get_items_from_response(self, response):
"""Yield :class:`.taskqueue.task.Task` items from response.
:type response: dict
:param response: The JSON API response for a page of tasks.
"""
for item in response.get('items', []):
id = item.get('id')
task =... | python | def get_items_from_response(self, response):
"""Yield :class:`.taskqueue.task.Task` items from response.
:type response: dict
:param response: The JSON API response for a page of tasks.
"""
for item in response.get('items', []):
id = item.get('id')
task =... | [
"def",
"get_items_from_response",
"(",
"self",
",",
"response",
")",
":",
"for",
"item",
"in",
"response",
".",
"get",
"(",
"'items'",
",",
"[",
"]",
")",
":",
"id",
"=",
"item",
".",
"get",
"(",
"'id'",
")",
"task",
"=",
"Task",
"(",
"id",
",",
... | Yield :class:`.taskqueue.task.Task` items from response.
:type response: dict
:param response: The JSON API response for a page of tasks. | [
"Yield",
":",
"class",
":",
".",
"taskqueue",
".",
"task",
".",
"Task",
"items",
"from",
"response",
"."
] | train | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/taskqueue.py#L51-L61 |
basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/taskqueue.py | Taskqueue.full_name | def full_name(self):
"""Fully-qualified name used in taskqueues / tasks APIs"""
if self._full_name is None:
self._full_name = 'projects/{project}/taskqueues/{taskqueue}'.format(project=self.project,
taskqueue=se... | python | def full_name(self):
"""Fully-qualified name used in taskqueues / tasks APIs"""
if self._full_name is None:
self._full_name = 'projects/{project}/taskqueues/{taskqueue}'.format(project=self.project,
taskqueue=se... | [
"def",
"full_name",
"(",
"self",
")",
":",
"if",
"self",
".",
"_full_name",
"is",
"None",
":",
"self",
".",
"_full_name",
"=",
"'projects/{project}/taskqueues/{taskqueue}'",
".",
"format",
"(",
"project",
"=",
"self",
".",
"project",
",",
"taskqueue",
"=",
"... | Fully-qualified name used in taskqueues / tasks APIs | [
"Fully",
"-",
"qualified",
"name",
"used",
"in",
"taskqueues",
"/",
"tasks",
"APIs"
] | train | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/taskqueue.py#L98-L103 |
basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/taskqueue.py | Taskqueue.exists | def exists(self, client=None):
"""API call: test for the existence of the taskqueue via a GET request
See
https://cloud.google.com/appengine/docs/python/taskqueue/rest/taskqueues/get
:type client: :class:`taskqueue.client.Client` or ``NoneType``
:param client: the client to us... | python | def exists(self, client=None):
"""API call: test for the existence of the taskqueue via a GET request
See
https://cloud.google.com/appengine/docs/python/taskqueue/rest/taskqueues/get
:type client: :class:`taskqueue.client.Client` or ``NoneType``
:param client: the client to us... | [
"def",
"exists",
"(",
"self",
",",
"client",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_require_client",
"(",
"client",
")",
"try",
":",
"response",
"=",
"client",
".",
"connection",
".",
"api_request",
"(",
"method",
"=",
"'GET'",
",",
"path... | API call: test for the existence of the taskqueue via a GET request
See
https://cloud.google.com/appengine/docs/python/taskqueue/rest/taskqueues/get
:type client: :class:`taskqueue.client.Client` or ``NoneType``
:param client: the client to use. If not passed, falls back to the
... | [
"API",
"call",
":",
"test",
"for",
"the",
"existence",
"of",
"the",
"taskqueue",
"via",
"a",
"GET",
"request"
] | train | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/taskqueue.py#L129-L151 |
basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/taskqueue.py | Taskqueue.delete_task | def delete_task(self, id, client=None):
"""Deletes a task from the current task queue.
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to delete.
:type client: :class:`gcloud.taskqueue.client.... | python | def delete_task(self, id, client=None):
"""Deletes a task from the current task queue.
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to delete.
:type client: :class:`gcloud.taskqueue.client.... | [
"def",
"delete_task",
"(",
"self",
",",
"id",
",",
"client",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_require_client",
"(",
"client",
")",
"task",
"=",
"Task",
"(",
"taskqueue",
"=",
"self",
",",
"id",
"=",
"id",
")",
"# We intentionally pa... | Deletes a task from the current task queue.
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to delete.
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
:param client: Opti... | [
"Deletes",
"a",
"task",
"from",
"the",
"current",
"task",
"queue",
"."
] | train | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/taskqueue.py#L153-L174 |
basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/taskqueue.py | Taskqueue.get_task | def get_task(self, id, client=None):
"""Gets a named task from taskqueue
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to get
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneTy... | python | def get_task(self, id, client=None):
"""Gets a named task from taskqueue
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to get
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneTy... | [
"def",
"get_task",
"(",
"self",
",",
"id",
",",
"client",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_require_client",
"(",
"client",
")",
"task",
"=",
"Task",
"(",
"taskqueue",
"=",
"self",
",",
"id",
"=",
"id",
")",
"try",
":",
"response... | Gets a named task from taskqueue
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to get
:type client: :class:`gcloud.taskqueue.client.Client` or ``NoneType``
:param client: Optional. The client... | [
"Gets",
"a",
"named",
"task",
"from",
"taskqueue"
] | train | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/taskqueue.py#L176-L199 |
basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/taskqueue.py | Taskqueue.lease | def lease(self, lease_time, num_tasks, group_by_tag=False, tag=None, client=None):
""" Acquires a lease on the topmost N unowned tasks in the specified queue.
:type lease_time: int
:param lease_time: How long to lease this task, in seconds.
:type num_tasks: int
:param num_tasks... | python | def lease(self, lease_time, num_tasks, group_by_tag=False, tag=None, client=None):
""" Acquires a lease on the topmost N unowned tasks in the specified queue.
:type lease_time: int
:param lease_time: How long to lease this task, in seconds.
:type num_tasks: int
:param num_tasks... | [
"def",
"lease",
"(",
"self",
",",
"lease_time",
",",
"num_tasks",
",",
"group_by_tag",
"=",
"False",
",",
"tag",
"=",
"None",
",",
"client",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_require_client",
"(",
"client",
")",
"if",
"group_by_tag",
... | Acquires a lease on the topmost N unowned tasks in the specified queue.
:type lease_time: int
:param lease_time: How long to lease this task, in seconds.
:type num_tasks: int
:param num_tasks: The number of tasks to lease.
:type group_by_tag: bool
:param group_by_tag: ... | [
"Acquires",
"a",
"lease",
"on",
"the",
"topmost",
"N",
"unowned",
"tasks",
"in",
"the",
"specified",
"queue",
"."
] | train | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/taskqueue.py#L209-L246 |
basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/taskqueue.py | Taskqueue.update_task | def update_task(self, id, new_lease_time, client=None):
""" Updates the duration of a task lease
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to update
:type new_lease_time: int
:pa... | python | def update_task(self, id, new_lease_time, client=None):
""" Updates the duration of a task lease
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to update
:type new_lease_time: int
:pa... | [
"def",
"update_task",
"(",
"self",
",",
"id",
",",
"new_lease_time",
",",
"client",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_require_client",
"(",
"client",
")",
"task",
"=",
"Task",
"(",
"taskqueue",
"=",
"self",
",",
"id",
"=",
"id",
")... | Updates the duration of a task lease
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type id: string
:param id: A task name to update
:type new_lease_time: int
:param new_lease_time: New lease time, in seconds.
:type clien... | [
"Updates",
"the",
"duration",
"of",
"a",
"task",
"lease"
] | train | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/taskqueue.py#L248-L277 |
basvandenbroek/gcloud_taskqueue | gcloud_taskqueue/taskqueue.py | Taskqueue.insert_task | def insert_task(self, description, tag=None, client=None):
""" Insert task in task queue.
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type description: string
:param description: Description of task to perform
:type tag: string... | python | def insert_task(self, description, tag=None, client=None):
""" Insert task in task queue.
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type description: string
:param description: Description of task to perform
:type tag: string... | [
"def",
"insert_task",
"(",
"self",
",",
"description",
",",
"tag",
"=",
"None",
",",
"client",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_require_client",
"(",
"client",
")",
"new_task",
"=",
"{",
"\"queueName\"",
":",
"self",
".",
"full_name",... | Insert task in task queue.
If the task isn't found (backend 404), raises a
:class:`gcloud.exceptions.NotFound`.
:type description: string
:param description: Description of task to perform
:type tag: string
:param tag: Optional. The tag for this task, allows leasing ta... | [
"Insert",
"task",
"in",
"task",
"queue",
"."
] | train | https://github.com/basvandenbroek/gcloud_taskqueue/blob/b147b57f7c0ad9e8030ee9797d6526a448aa5007/gcloud_taskqueue/taskqueue.py#L279-L310 |
pydsigner/pygu | pygu/pygw.py | Base.add_to | def add_to(self, container):
'''
Add the class to @container.
'''
if self.container:
self.remove_from(self.container)
container.add(self) | python | def add_to(self, container):
'''
Add the class to @container.
'''
if self.container:
self.remove_from(self.container)
container.add(self) | [
"def",
"add_to",
"(",
"self",
",",
"container",
")",
":",
"if",
"self",
".",
"container",
":",
"self",
".",
"remove_from",
"(",
"self",
".",
"container",
")",
"container",
".",
"add",
"(",
"self",
")"
] | Add the class to @container. | [
"Add",
"the",
"class",
"to"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L78-L84 |
pydsigner/pygu | pygu/pygw.py | Container.draw | def draw(self, surf):
'''
Draw all widgets and sub-containers to @surf.
'''
if self.shown:
for w in self.widgets:
surf.blit(w.image, self.convert_rect(w.rect))
for c in self.containers:
c.draw(surf) | python | def draw(self, surf):
'''
Draw all widgets and sub-containers to @surf.
'''
if self.shown:
for w in self.widgets:
surf.blit(w.image, self.convert_rect(w.rect))
for c in self.containers:
c.draw(surf) | [
"def",
"draw",
"(",
"self",
",",
"surf",
")",
":",
"if",
"self",
".",
"shown",
":",
"for",
"w",
"in",
"self",
".",
"widgets",
":",
"surf",
".",
"blit",
"(",
"w",
".",
"image",
",",
"self",
".",
"convert_rect",
"(",
"w",
".",
"rect",
")",
")",
... | Draw all widgets and sub-containers to @surf. | [
"Draw",
"all",
"widgets",
"and",
"sub",
"-",
"containers",
"to"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L153-L161 |
pydsigner/pygu | pygu/pygw.py | Container.kill | def kill(self):
'''
Remove the class from its container, contained items and sub-widgets.
Runs automatically when the class is garbage collected.
'''
Base.kill(self)
for c in self.containers:
c.remove_internal(self)
for w in self.widgets:
... | python | def kill(self):
'''
Remove the class from its container, contained items and sub-widgets.
Runs automatically when the class is garbage collected.
'''
Base.kill(self)
for c in self.containers:
c.remove_internal(self)
for w in self.widgets:
... | [
"def",
"kill",
"(",
"self",
")",
":",
"Base",
".",
"kill",
"(",
"self",
")",
"for",
"c",
"in",
"self",
".",
"containers",
":",
"c",
".",
"remove_internal",
"(",
"self",
")",
"for",
"w",
"in",
"self",
".",
"widgets",
":",
"w",
".",
"remove_internal"... | Remove the class from its container, contained items and sub-widgets.
Runs automatically when the class is garbage collected. | [
"Remove",
"the",
"class",
"from",
"its",
"container",
"contained",
"items",
"and",
"sub",
"-",
"widgets",
".",
"Runs",
"automatically",
"when",
"the",
"class",
"is",
"garbage",
"collected",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L163-L173 |
pydsigner/pygu | pygu/pygw.py | Container.add | def add(self, *widgets):
'''
Place @widgets under the blitting hand of the Container(). Each arg
must be a Widget(), a fellow Container(), or an iterable. Else, things
get ugly...
'''
for w in widgets:
if is_widget(w):
if w not in self.widget... | python | def add(self, *widgets):
'''
Place @widgets under the blitting hand of the Container(). Each arg
must be a Widget(), a fellow Container(), or an iterable. Else, things
get ugly...
'''
for w in widgets:
if is_widget(w):
if w not in self.widget... | [
"def",
"add",
"(",
"self",
",",
"*",
"widgets",
")",
":",
"for",
"w",
"in",
"widgets",
":",
"if",
"is_widget",
"(",
"w",
")",
":",
"if",
"w",
"not",
"in",
"self",
".",
"widgets",
":",
"self",
".",
"widgets",
".",
"add",
"(",
"w",
")",
"w",
".... | Place @widgets under the blitting hand of the Container(). Each arg
must be a Widget(), a fellow Container(), or an iterable. Else, things
get ugly... | [
"Place"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L177-L195 |
pydsigner/pygu | pygu/pygw.py | Container.remove | def remove(self, *widgets):
'''
Remove @widgets from the blitting hand of the Container(). Each arg
must be a Widget(), a fellow Container(), or an iterable. Else, things
get ugly...
'''
for w in widgets:
if w in self.widgets:
self.widgets.re... | python | def remove(self, *widgets):
'''
Remove @widgets from the blitting hand of the Container(). Each arg
must be a Widget(), a fellow Container(), or an iterable. Else, things
get ugly...
'''
for w in widgets:
if w in self.widgets:
self.widgets.re... | [
"def",
"remove",
"(",
"self",
",",
"*",
"widgets",
")",
":",
"for",
"w",
"in",
"widgets",
":",
"if",
"w",
"in",
"self",
".",
"widgets",
":",
"self",
".",
"widgets",
".",
"remove",
"(",
"w",
")",
"w",
".",
"remove_internal",
"(",
"self",
")",
"eli... | Remove @widgets from the blitting hand of the Container(). Each arg
must be a Widget(), a fellow Container(), or an iterable. Else, things
get ugly... | [
"Remove"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L197-L213 |
pydsigner/pygu | pygu/pygw.py | Container.convert_point | def convert_point(self, point):
'''
Converts the relative position of @point into an absolute position. To
be used for event considerations, blitting is handled directly by the
Container().
'''
return self.container.convert_point(Vector(point) + self.pos) | python | def convert_point(self, point):
'''
Converts the relative position of @point into an absolute position. To
be used for event considerations, blitting is handled directly by the
Container().
'''
return self.container.convert_point(Vector(point) + self.pos) | [
"def",
"convert_point",
"(",
"self",
",",
"point",
")",
":",
"return",
"self",
".",
"container",
".",
"convert_point",
"(",
"Vector",
"(",
"point",
")",
"+",
"self",
".",
"pos",
")"
] | Converts the relative position of @point into an absolute position. To
be used for event considerations, blitting is handled directly by the
Container(). | [
"Converts",
"the",
"relative",
"position",
"of"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L217-L223 |
pydsigner/pygu | pygu/pygw.py | Container.convert_rect | def convert_rect(self, rect):
'''
Converts the relative position of @rect into an absolute position.To be
used for event considerations, blitting is handled directly by the
Container().
'''
return self.container.convert_rect(rect.move(self.pos)) | python | def convert_rect(self, rect):
'''
Converts the relative position of @rect into an absolute position.To be
used for event considerations, blitting is handled directly by the
Container().
'''
return self.container.convert_rect(rect.move(self.pos)) | [
"def",
"convert_rect",
"(",
"self",
",",
"rect",
")",
":",
"return",
"self",
".",
"container",
".",
"convert_rect",
"(",
"rect",
".",
"move",
"(",
"self",
".",
"pos",
")",
")"
] | Converts the relative position of @rect into an absolute position.To be
used for event considerations, blitting is handled directly by the
Container(). | [
"Converts",
"the",
"relative",
"position",
"of"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L225-L231 |
pydsigner/pygu | pygu/pygw.py | Container.bind | def bind(self, func, etype):
'''
Wraps around container.bind().
'''
if func not in self._event_cbs:
wrapped = self._WrapCB(self, func)
self._event_cbs[func] = wrapped
else:
wrapped = self._event_cbs[func]
self.container.bind(wrapped, et... | python | def bind(self, func, etype):
'''
Wraps around container.bind().
'''
if func not in self._event_cbs:
wrapped = self._WrapCB(self, func)
self._event_cbs[func] = wrapped
else:
wrapped = self._event_cbs[func]
self.container.bind(wrapped, et... | [
"def",
"bind",
"(",
"self",
",",
"func",
",",
"etype",
")",
":",
"if",
"func",
"not",
"in",
"self",
".",
"_event_cbs",
":",
"wrapped",
"=",
"self",
".",
"_WrapCB",
"(",
"self",
",",
"func",
")",
"self",
".",
"_event_cbs",
"[",
"func",
"]",
"=",
"... | Wraps around container.bind(). | [
"Wraps",
"around",
"container",
".",
"bind",
"()",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L241-L250 |
pydsigner/pygu | pygu/pygw.py | Container.unbind | def unbind(self, func, etype):
'''
Wraps around container.unbind().
'''
wrapped = self.event_cbs[func]
self.container.unbind(self, wrapped, etype) | python | def unbind(self, func, etype):
'''
Wraps around container.unbind().
'''
wrapped = self.event_cbs[func]
self.container.unbind(self, wrapped, etype) | [
"def",
"unbind",
"(",
"self",
",",
"func",
",",
"etype",
")",
":",
"wrapped",
"=",
"self",
".",
"event_cbs",
"[",
"func",
"]",
"self",
".",
"container",
".",
"unbind",
"(",
"self",
",",
"wrapped",
",",
"etype",
")"
] | Wraps around container.unbind(). | [
"Wraps",
"around",
"container",
".",
"unbind",
"()",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L252-L257 |
pydsigner/pygu | pygu/pygw.py | Scrollable.scroll_x | def scroll_x(self, pixels, relative=True):
'''
Negative values for @pixels scroll left, positive values scroll right;
@relative determines whether to set the scroll-x value or change as
above.
'''
if relative:
self.offset.x += int(pixels)
else:
... | python | def scroll_x(self, pixels, relative=True):
'''
Negative values for @pixels scroll left, positive values scroll right;
@relative determines whether to set the scroll-x value or change as
above.
'''
if relative:
self.offset.x += int(pixels)
else:
... | [
"def",
"scroll_x",
"(",
"self",
",",
"pixels",
",",
"relative",
"=",
"True",
")",
":",
"if",
"relative",
":",
"self",
".",
"offset",
".",
"x",
"+=",
"int",
"(",
"pixels",
")",
"else",
":",
"self",
".",
"offset",
".",
"x",
"=",
"int",
"(",
"pixels... | Negative values for @pixels scroll left, positive values scroll right;
@relative determines whether to set the scroll-x value or change as
above. | [
"Negative",
"values",
"for"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L292-L302 |
pydsigner/pygu | pygu/pygw.py | Scrollable.scroll_y | def scroll_y(self, pixels, relative=True):
'''
Negative values for @pixels scroll up, positive values scroll down;
@relative determines whether to set the scroll-y value or change as
above.
'''
if relative:
self.offset.y += int(pixels)
else:
... | python | def scroll_y(self, pixels, relative=True):
'''
Negative values for @pixels scroll up, positive values scroll down;
@relative determines whether to set the scroll-y value or change as
above.
'''
if relative:
self.offset.y += int(pixels)
else:
... | [
"def",
"scroll_y",
"(",
"self",
",",
"pixels",
",",
"relative",
"=",
"True",
")",
":",
"if",
"relative",
":",
"self",
".",
"offset",
".",
"y",
"+=",
"int",
"(",
"pixels",
")",
"else",
":",
"self",
".",
"offset",
".",
"y",
"=",
"int",
"(",
"pixels... | Negative values for @pixels scroll up, positive values scroll down;
@relative determines whether to set the scroll-y value or change as
above. | [
"Negative",
"values",
"for"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L304-L314 |
pydsigner/pygu | pygu/pygw.py | Scrollable.convert_rect | def convert_rect(self, rect):
'''
Same as Container().convert_rect(), but adds scrolling.
'''
return Container.convert_rect(self, rect).move(-self.offset) | python | def convert_rect(self, rect):
'''
Same as Container().convert_rect(), but adds scrolling.
'''
return Container.convert_rect(self, rect).move(-self.offset) | [
"def",
"convert_rect",
"(",
"self",
",",
"rect",
")",
":",
"return",
"Container",
".",
"convert_rect",
"(",
"self",
",",
"rect",
")",
".",
"move",
"(",
"-",
"self",
".",
"offset",
")"
] | Same as Container().convert_rect(), but adds scrolling. | [
"Same",
"as",
"Container",
"()",
".",
"convert_rect",
"()",
"but",
"adds",
"scrolling",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L324-L328 |
pydsigner/pygu | pygu/pygw.py | Typable.bspace | def bspace(self):
'''
Remove the character before the cursor.
'''
try:
self.text.pop(self.cursor_loc - 1)
self.cursor_loc -= 1
except IndexError:
pass | python | def bspace(self):
'''
Remove the character before the cursor.
'''
try:
self.text.pop(self.cursor_loc - 1)
self.cursor_loc -= 1
except IndexError:
pass | [
"def",
"bspace",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"text",
".",
"pop",
"(",
"self",
".",
"cursor_loc",
"-",
"1",
")",
"self",
".",
"cursor_loc",
"-=",
"1",
"except",
"IndexError",
":",
"pass"
] | Remove the character before the cursor. | [
"Remove",
"the",
"character",
"before",
"the",
"cursor",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L446-L454 |
pydsigner/pygu | pygu/pygw.py | Typable.insert | def insert(self, s):
'''
Insert string @s at the current cursor location.
'''
for c in s:
self.text.insert(self.cursor_loc, c)
self.cursor_loc += 1 | python | def insert(self, s):
'''
Insert string @s at the current cursor location.
'''
for c in s:
self.text.insert(self.cursor_loc, c)
self.cursor_loc += 1 | [
"def",
"insert",
"(",
"self",
",",
"s",
")",
":",
"for",
"c",
"in",
"s",
":",
"self",
".",
"text",
".",
"insert",
"(",
"self",
".",
"cursor_loc",
",",
"c",
")",
"self",
".",
"cursor_loc",
"+=",
"1"
] | Insert string @s at the current cursor location. | [
"Insert",
"string"
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L490-L496 |
pydsigner/pygu | pygu/pygw.py | Typable.update | def update(self):
'''
Update the image before drawing.
'''
self.image = self.blank.copy()
vcenter_blit(self.image,
self.font.render(self.get(), True, self.color),
self.margin) | python | def update(self):
'''
Update the image before drawing.
'''
self.image = self.blank.copy()
vcenter_blit(self.image,
self.font.render(self.get(), True, self.color),
self.margin) | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"image",
"=",
"self",
".",
"blank",
".",
"copy",
"(",
")",
"vcenter_blit",
"(",
"self",
".",
"image",
",",
"self",
".",
"font",
".",
"render",
"(",
"self",
".",
"get",
"(",
")",
",",
"True",
... | Update the image before drawing. | [
"Update",
"the",
"image",
"before",
"drawing",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L500-L507 |
pydsigner/pygu | pygu/pygw.py | Entry.copy | def copy(self):
'''
Copy the text in the Entry() and place it on the clipboard.
'''
try:
pygame.scrap.put(SCRAP_TEXT, self.get())
return True
except:
# pygame.scrap is experimental, allow for changes
return False | python | def copy(self):
'''
Copy the text in the Entry() and place it on the clipboard.
'''
try:
pygame.scrap.put(SCRAP_TEXT, self.get())
return True
except:
# pygame.scrap is experimental, allow for changes
return False | [
"def",
"copy",
"(",
"self",
")",
":",
"try",
":",
"pygame",
".",
"scrap",
".",
"put",
"(",
"SCRAP_TEXT",
",",
"self",
".",
"get",
"(",
")",
")",
"return",
"True",
"except",
":",
"# pygame.scrap is experimental, allow for changes",
"return",
"False"
] | Copy the text in the Entry() and place it on the clipboard. | [
"Copy",
"the",
"text",
"in",
"the",
"Entry",
"()",
"and",
"place",
"it",
"on",
"the",
"clipboard",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L550-L559 |
pydsigner/pygu | pygu/pygw.py | Entry.paste | def paste(self):
'''
Insert text from the clipboard at the cursor.
'''
try:
t = pygame.scrap.get(SCRAP_TEXT)
if t:
self.insert(t)
return True
except:
# pygame.scrap is experimental, allow for changes
... | python | def paste(self):
'''
Insert text from the clipboard at the cursor.
'''
try:
t = pygame.scrap.get(SCRAP_TEXT)
if t:
self.insert(t)
return True
except:
# pygame.scrap is experimental, allow for changes
... | [
"def",
"paste",
"(",
"self",
")",
":",
"try",
":",
"t",
"=",
"pygame",
".",
"scrap",
".",
"get",
"(",
"SCRAP_TEXT",
")",
"if",
"t",
":",
"self",
".",
"insert",
"(",
"t",
")",
"return",
"True",
"except",
":",
"# pygame.scrap is experimental, allow for cha... | Insert text from the clipboard at the cursor. | [
"Insert",
"text",
"from",
"the",
"clipboard",
"at",
"the",
"cursor",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L568-L579 |
pydsigner/pygu | pygu/pygw.py | Entry.update | def update(self):
'''
Update the image before drawing.
'''
self.image = self.blank.copy()
bf = self.font.render(''.join(self.text[:self.cursor_loc]),
True, self.color)
br = bf.get_rect().move(self.margin)
af = self.font.render(''... | python | def update(self):
'''
Update the image before drawing.
'''
self.image = self.blank.copy()
bf = self.font.render(''.join(self.text[:self.cursor_loc]),
True, self.color)
br = bf.get_rect().move(self.margin)
af = self.font.render(''... | [
"def",
"update",
"(",
"self",
")",
":",
"self",
".",
"image",
"=",
"self",
".",
"blank",
".",
"copy",
"(",
")",
"bf",
"=",
"self",
".",
"font",
".",
"render",
"(",
"''",
".",
"join",
"(",
"self",
".",
"text",
"[",
":",
"self",
".",
"cursor_loc"... | Update the image before drawing. | [
"Update",
"the",
"image",
"before",
"drawing",
"."
] | train | https://github.com/pydsigner/pygu/blob/09fe71534900933908ab83db12f5659b7827e31c/pygu/pygw.py#L605-L636 |
pip-services3-python/pip-services3-components-python | pip_services3_components/info/ContextInfo.py | ContextInfo.configure | def configure(self, config):
"""
Configures component by passing configuration parameters.
:param config: configuration parameters to be set.
"""
self._name = config.get_as_string_with_default("name", self._name)
self._name = config.get_as_string_with_default("info.name"... | python | def configure(self, config):
"""
Configures component by passing configuration parameters.
:param config: configuration parameters to be set.
"""
self._name = config.get_as_string_with_default("name", self._name)
self._name = config.get_as_string_with_default("info.name"... | [
"def",
"configure",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_name",
"=",
"config",
".",
"get_as_string_with_default",
"(",
"\"name\"",
",",
"self",
".",
"_name",
")",
"self",
".",
"_name",
"=",
"config",
".",
"get_as_string_with_default",
"(",
... | Configures component by passing configuration parameters.
:param config: configuration parameters to be set. | [
"Configures",
"component",
"by",
"passing",
"configuration",
"parameters",
"."
] | train | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/info/ContextInfo.py#L61-L73 |
callowayproject/Transmogrify | transmogrify/settings.py | list_from_env | def list_from_env(key, default=""):
"""
Splits a string in the format "a,b,c,d,e,f" into
['a', 'b', 'c', 'd', 'e', 'f', ]
"""
try:
val = os.environ.get(key, default)
return val.split(',')
except (KeyError, ValueError):
return [] | python | def list_from_env(key, default=""):
"""
Splits a string in the format "a,b,c,d,e,f" into
['a', 'b', 'c', 'd', 'e', 'f', ]
"""
try:
val = os.environ.get(key, default)
return val.split(',')
except (KeyError, ValueError):
return [] | [
"def",
"list_from_env",
"(",
"key",
",",
"default",
"=",
"\"\"",
")",
":",
"try",
":",
"val",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"key",
",",
"default",
")",
"return",
"val",
".",
"split",
"(",
"','",
")",
"except",
"(",
"KeyError",
",",
... | Splits a string in the format "a,b,c,d,e,f" into
['a', 'b', 'c', 'd', 'e', 'f', ] | [
"Splits",
"a",
"string",
"in",
"the",
"format",
"a",
"b",
"c",
"d",
"e",
"f",
"into",
"[",
"a",
"b",
"c",
"d",
"e",
"f",
"]"
] | train | https://github.com/callowayproject/Transmogrify/blob/f1f891b8b923b3a1ede5eac7f60531c1c472379e/transmogrify/settings.py#L45-L54 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.