repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
bionikspoon/pureyaml | pureyaml/_compat/singledispatch.py | _compose_mro | def _compose_mro(cls, types): # noqa
"""Calculates the method resolution order for a given class *cls*.
Includes relevant abstract base classes (with their respective bases) from
the *types* iterable. Uses a modified C3 linearization algorithm.
"""
bases = set(cls.__mro__)
# Remove entries w... | python | def _compose_mro(cls, types): # noqa
"""Calculates the method resolution order for a given class *cls*.
Includes relevant abstract base classes (with their respective bases) from
the *types* iterable. Uses a modified C3 linearization algorithm.
"""
bases = set(cls.__mro__)
# Remove entries w... | [
"def",
"_compose_mro",
"(",
"cls",
",",
"types",
")",
":",
"# noqa",
"bases",
"=",
"set",
"(",
"cls",
".",
"__mro__",
")",
"# Remove entries which are already present in the __mro__ or unrelated.",
"def",
"is_related",
"(",
"_type",
")",
":",
"return",
"(",
"# :of... | Calculates the method resolution order for a given class *cls*.
Includes relevant abstract base classes (with their respective bases) from
the *types* iterable. Uses a modified C3 linearization algorithm. | [
"Calculates",
"the",
"method",
"resolution",
"order",
"for",
"a",
"given",
"class",
"*",
"cls",
"*",
"."
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/_compat/singledispatch.py#L91-L137 | train | Calculates the method resolution order for a given class cls. |
bionikspoon/pureyaml | pureyaml/_compat/singledispatch.py | _find_impl | def _find_impl(cls, registry):
"""Returns the best matching implementation from *registry* for type *cls*.
Where there is no registered implementation for a specific type, its method
resolution order is used to find a more generic implementation.
Note: if *registry* does not contain an implementation ... | python | def _find_impl(cls, registry):
"""Returns the best matching implementation from *registry* for type *cls*.
Where there is no registered implementation for a specific type, its method
resolution order is used to find a more generic implementation.
Note: if *registry* does not contain an implementation ... | [
"def",
"_find_impl",
"(",
"cls",
",",
"registry",
")",
":",
"mro",
"=",
"_compose_mro",
"(",
"cls",
",",
"registry",
".",
"keys",
"(",
")",
")",
"match",
"=",
"None",
"for",
"t",
"in",
"mro",
":",
"if",
"match",
"is",
"not",
"None",
":",
"# If *mat... | Returns the best matching implementation from *registry* for type *cls*.
Where there is no registered implementation for a specific type, its method
resolution order is used to find a more generic implementation.
Note: if *registry* does not contain an implementation for the base
*object* type, this f... | [
"Returns",
"the",
"best",
"matching",
"implementation",
"from",
"*",
"registry",
"*",
"for",
"type",
"*",
"cls",
"*",
"."
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/_compat/singledispatch.py#L140-L166 | train | Returns the best matching implementation for the given base class. |
bionikspoon/pureyaml | pureyaml/_compat/singledispatch.py | singledispatch | def singledispatch(function): # noqa
"""Single-dispatch generic function decorator.
Transforms a function into a generic function, which can have different
behaviours depending upon the type of its first argument. The decorated
function acts as the default implementation, and additional
implementa... | python | def singledispatch(function): # noqa
"""Single-dispatch generic function decorator.
Transforms a function into a generic function, which can have different
behaviours depending upon the type of its first argument. The decorated
function acts as the default implementation, and additional
implementa... | [
"def",
"singledispatch",
"(",
"function",
")",
":",
"# noqa",
"registry",
"=",
"{",
"}",
"dispatch_cache",
"=",
"WeakKeyDictionary",
"(",
")",
"def",
"ns",
"(",
")",
":",
"pass",
"ns",
".",
"cache_token",
"=",
"None",
"# noinspection PyIncorrectDocstring",
"de... | Single-dispatch generic function decorator.
Transforms a function into a generic function, which can have different
behaviours depending upon the type of its first argument. The decorated
function acts as the default implementation, and additional
implementations can be registered using the register() ... | [
"Single",
"-",
"dispatch",
"generic",
"function",
"decorator",
"."
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/_compat/singledispatch.py#L170-L235 | train | Single - dispatch generic function decorator. |
jaraco/jaraco.windows | jaraco/windows/clipboard.py | SetClipboardData | def SetClipboardData(type, content):
"""
Modeled after http://msdn.microsoft.com
/en-us/library/ms649016%28VS.85%29.aspx
#_win32_Copying_Information_to_the_Clipboard
"""
allocators = {
clipboard.CF_TEXT: ctypes.create_string_buffer,
clipboard.CF_UNICODETEXT: ctypes.create_unicode_buffer,
clipboard.CF_HTML: ... | python | def SetClipboardData(type, content):
"""
Modeled after http://msdn.microsoft.com
/en-us/library/ms649016%28VS.85%29.aspx
#_win32_Copying_Information_to_the_Clipboard
"""
allocators = {
clipboard.CF_TEXT: ctypes.create_string_buffer,
clipboard.CF_UNICODETEXT: ctypes.create_unicode_buffer,
clipboard.CF_HTML: ... | [
"def",
"SetClipboardData",
"(",
"type",
",",
"content",
")",
":",
"allocators",
"=",
"{",
"clipboard",
".",
"CF_TEXT",
":",
"ctypes",
".",
"create_string_buffer",
",",
"clipboard",
".",
"CF_UNICODETEXT",
":",
"ctypes",
".",
"create_unicode_buffer",
",",
"clipboa... | Modeled after http://msdn.microsoft.com
/en-us/library/ms649016%28VS.85%29.aspx
#_win32_Copying_Information_to_the_Clipboard | [
"Modeled",
"after",
"http",
":",
"//",
"msdn",
".",
"microsoft",
".",
"com",
"/",
"en",
"-",
"us",
"/",
"library",
"/",
"ms649016%28VS",
".",
"85%29",
".",
"aspx",
"#_win32_Copying_Information_to_the_Clipboard"
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/clipboard.py#L134-L157 | train | Set the clipboard data. |
MasterOdin/pylint_runner | pylint_runner/main.py | main | def main(output=None, error=None, verbose=False):
""" The main (cli) interface for the pylint runner. """
runner = Runner(args=["--verbose"] if verbose is not False else None)
runner.run(output, error) | python | def main(output=None, error=None, verbose=False):
""" The main (cli) interface for the pylint runner. """
runner = Runner(args=["--verbose"] if verbose is not False else None)
runner.run(output, error) | [
"def",
"main",
"(",
"output",
"=",
"None",
",",
"error",
"=",
"None",
",",
"verbose",
"=",
"False",
")",
":",
"runner",
"=",
"Runner",
"(",
"args",
"=",
"[",
"\"--verbose\"",
"]",
"if",
"verbose",
"is",
"not",
"False",
"else",
"None",
")",
"runner",
... | The main (cli) interface for the pylint runner. | [
"The",
"main",
"(",
"cli",
")",
"interface",
"for",
"the",
"pylint",
"runner",
"."
] | b8ec3324e568e172d38fc0b6fa6f5551b229de07 | https://github.com/MasterOdin/pylint_runner/blob/b8ec3324e568e172d38fc0b6fa6f5551b229de07/pylint_runner/main.py#L187-L190 | train | The main function for the pylint runner. |
MasterOdin/pylint_runner | pylint_runner/main.py | Runner._parse_args | def _parse_args(self, args):
"""Parses any supplied command-line args and provides help text. """
parser = ArgumentParser(description="Runs pylint recursively on a directory")
parser.add_argument(
"-v",
"--verbose",
dest="verbose",
action="store_... | python | def _parse_args(self, args):
"""Parses any supplied command-line args and provides help text. """
parser = ArgumentParser(description="Runs pylint recursively on a directory")
parser.add_argument(
"-v",
"--verbose",
dest="verbose",
action="store_... | [
"def",
"_parse_args",
"(",
"self",
",",
"args",
")",
":",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"\"Runs pylint recursively on a directory\"",
")",
"parser",
".",
"add_argument",
"(",
"\"-v\"",
",",
"\"--verbose\"",
",",
"dest",
"=",
"\"verbose\... | Parses any supplied command-line args and provides help text. | [
"Parses",
"any",
"supplied",
"command",
"-",
"line",
"args",
"and",
"provides",
"help",
"text",
"."
] | b8ec3324e568e172d38fc0b6fa6f5551b229de07 | https://github.com/MasterOdin/pylint_runner/blob/b8ec3324e568e172d38fc0b6fa6f5551b229de07/pylint_runner/main.py#L39-L78 | train | Parses any supplied command - line args and provides help text. |
MasterOdin/pylint_runner | pylint_runner/main.py | Runner._parse_ignores | def _parse_ignores(self):
""" Parse the ignores setting from the pylintrc file if available. """
error_message = (
colorama.Fore.RED
+ "{} does not appear to be a valid pylintrc file".format(self.rcfile)
+ colorama.Fore.RESET
)
if not os.path.isfile(... | python | def _parse_ignores(self):
""" Parse the ignores setting from the pylintrc file if available. """
error_message = (
colorama.Fore.RED
+ "{} does not appear to be a valid pylintrc file".format(self.rcfile)
+ colorama.Fore.RESET
)
if not os.path.isfile(... | [
"def",
"_parse_ignores",
"(",
"self",
")",
":",
"error_message",
"=",
"(",
"colorama",
".",
"Fore",
".",
"RED",
"+",
"\"{} does not appear to be a valid pylintrc file\"",
".",
"format",
"(",
"self",
".",
"rcfile",
")",
"+",
"colorama",
".",
"Fore",
".",
"RESET... | Parse the ignores setting from the pylintrc file if available. | [
"Parse",
"the",
"ignores",
"setting",
"from",
"the",
"pylintrc",
"file",
"if",
"available",
"."
] | b8ec3324e568e172d38fc0b6fa6f5551b229de07 | https://github.com/MasterOdin/pylint_runner/blob/b8ec3324e568e172d38fc0b6fa6f5551b229de07/pylint_runner/main.py#L80-L104 | train | Parse the ignores setting from the pylintrc file if available. |
MasterOdin/pylint_runner | pylint_runner/main.py | Runner.get_files_from_dir | def get_files_from_dir(self, current_dir):
"""
Recursively walk through a directory and get all python files and then walk
through any potential directories that are found off current directory,
so long as not within self.IGNORE_FOLDERS
:return: all python files that were found o... | python | def get_files_from_dir(self, current_dir):
"""
Recursively walk through a directory and get all python files and then walk
through any potential directories that are found off current directory,
so long as not within self.IGNORE_FOLDERS
:return: all python files that were found o... | [
"def",
"get_files_from_dir",
"(",
"self",
",",
"current_dir",
")",
":",
"if",
"current_dir",
"[",
"-",
"1",
"]",
"!=",
"\"/\"",
"and",
"current_dir",
"!=",
"\".\"",
":",
"current_dir",
"+=",
"\"/\"",
"files",
"=",
"[",
"]",
"for",
"dir_file",
"in",
"os",... | Recursively walk through a directory and get all python files and then walk
through any potential directories that are found off current directory,
so long as not within self.IGNORE_FOLDERS
:return: all python files that were found off current_dir | [
"Recursively",
"walk",
"through",
"a",
"directory",
"and",
"get",
"all",
"python",
"files",
"and",
"then",
"walk",
"through",
"any",
"potential",
"directories",
"that",
"are",
"found",
"off",
"current",
"directory",
"so",
"long",
"as",
"not",
"within",
"self",... | b8ec3324e568e172d38fc0b6fa6f5551b229de07 | https://github.com/MasterOdin/pylint_runner/blob/b8ec3324e568e172d38fc0b6fa6f5551b229de07/pylint_runner/main.py#L114-L143 | train | Recursively walk through a directory and get all python files and return a list of all python files that were found off current_dir |
MasterOdin/pylint_runner | pylint_runner/main.py | Runner.run | def run(self, output=None, error=None):
""" Runs pylint on all python files in the current directory """
pylint_output = output if output is not None else sys.stdout
pylint_error = error if error is not None else sys.stderr
savedout, savederr = sys.__stdout__, sys.__stderr__
sys... | python | def run(self, output=None, error=None):
""" Runs pylint on all python files in the current directory """
pylint_output = output if output is not None else sys.stdout
pylint_error = error if error is not None else sys.stderr
savedout, savederr = sys.__stdout__, sys.__stderr__
sys... | [
"def",
"run",
"(",
"self",
",",
"output",
"=",
"None",
",",
"error",
"=",
"None",
")",
":",
"pylint_output",
"=",
"output",
"if",
"output",
"is",
"not",
"None",
"else",
"sys",
".",
"stdout",
"pylint_error",
"=",
"error",
"if",
"error",
"is",
"not",
"... | Runs pylint on all python files in the current directory | [
"Runs",
"pylint",
"on",
"all",
"python",
"files",
"in",
"the",
"current",
"directory"
] | b8ec3324e568e172d38fc0b6fa6f5551b229de07 | https://github.com/MasterOdin/pylint_runner/blob/b8ec3324e568e172d38fc0b6fa6f5551b229de07/pylint_runner/main.py#L145-L184 | train | Runs pylint on all python files in the current directory. |
bionikspoon/pureyaml | pureyaml/grammar/utils.py | strict | def strict(*types):
"""Decorator, type check production rule output"""
def decorate(func):
@wraps(func)
def wrapper(self, p):
func(self, p)
if not isinstance(p[0], types):
raise YAMLStrictTypeError(p[0], types, func)
wrapper.co_firstlineno = func... | python | def strict(*types):
"""Decorator, type check production rule output"""
def decorate(func):
@wraps(func)
def wrapper(self, p):
func(self, p)
if not isinstance(p[0], types):
raise YAMLStrictTypeError(p[0], types, func)
wrapper.co_firstlineno = func... | [
"def",
"strict",
"(",
"*",
"types",
")",
":",
"def",
"decorate",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"self",
",",
"p",
")",
":",
"func",
"(",
"self",
",",
"p",
")",
"if",
"not",
"isinstance",
"(",
"p",
... | Decorator, type check production rule output | [
"Decorator",
"type",
"check",
"production",
"rule",
"output"
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/grammar/utils.py#L11-L24 | train | Decorator to check that a function is a type check production rule output. |
bionikspoon/pureyaml | pureyaml/grammar/utils.py | find_column | def find_column(t):
"""Get cursor position, based on previous newline"""
pos = t.lexer.lexpos
data = t.lexer.lexdata
last_cr = data.rfind('\n', 0, pos)
if last_cr < 0:
last_cr = -1
column = pos - last_cr
return column | python | def find_column(t):
"""Get cursor position, based on previous newline"""
pos = t.lexer.lexpos
data = t.lexer.lexdata
last_cr = data.rfind('\n', 0, pos)
if last_cr < 0:
last_cr = -1
column = pos - last_cr
return column | [
"def",
"find_column",
"(",
"t",
")",
":",
"pos",
"=",
"t",
".",
"lexer",
".",
"lexpos",
"data",
"=",
"t",
".",
"lexer",
".",
"lexdata",
"last_cr",
"=",
"data",
".",
"rfind",
"(",
"'\\n'",
",",
"0",
",",
"pos",
")",
"if",
"last_cr",
"<",
"0",
":... | Get cursor position, based on previous newline | [
"Get",
"cursor",
"position",
"based",
"on",
"previous",
"newline"
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/grammar/utils.py#L27-L35 | train | Get cursor position based on previous newline |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | ScimetaSubEndpoint.custom | def custom(self, payload):
"""
:param payload:
a key/value object containing the scimeta you want to store
e.g. {"weather": "sunny", "temperature": "80C" }
:return:
empty (200 status code)
"""
url = "{url_base}/resource/{pid}/scimeta/... | python | def custom(self, payload):
"""
:param payload:
a key/value object containing the scimeta you want to store
e.g. {"weather": "sunny", "temperature": "80C" }
:return:
empty (200 status code)
"""
url = "{url_base}/resource/{pid}/scimeta/... | [
"def",
"custom",
"(",
"self",
",",
"payload",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/scimeta/custom/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"hs",
".",
"url_base",
",",
"pid",
"=",
"self",
".",
"pid",
")",
"r",
"=",
"self",
".",... | :param payload:
a key/value object containing the scimeta you want to store
e.g. {"weather": "sunny", "temperature": "80C" }
:return:
empty (200 status code) | [
":",
"param",
"payload",
":",
"a",
"key",
"/",
"value",
"object",
"containing",
"the",
"scimeta",
"you",
"want",
"to",
"store",
"e",
".",
"g",
".",
"{",
"weather",
":",
"sunny",
"temperature",
":",
"80C",
"}",
":",
"return",
":",
"empty",
"(",
"200",... | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L23-L35 | train | Send a custom request to the HS |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | ScimetaSubEndpoint.get | def get(self):
"""
:param payload:
a key/value object containing the scimeta you want to store
e.g. {"weather": "sunny", "temperature": "80C" }
:return:
empty (200 status code)
"""
url = "{url_base}/resource/{pid}/scimeta/custom/".for... | python | def get(self):
"""
:param payload:
a key/value object containing the scimeta you want to store
e.g. {"weather": "sunny", "temperature": "80C" }
:return:
empty (200 status code)
"""
url = "{url_base}/resource/{pid}/scimeta/custom/".for... | [
"def",
"get",
"(",
"self",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/scimeta/custom/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"hs",
".",
"url_base",
",",
"pid",
"=",
"self",
".",
"pid",
")",
"r",
"=",
"self",
".",
"hs",
".",
"_req... | :param payload:
a key/value object containing the scimeta you want to store
e.g. {"weather": "sunny", "temperature": "80C" }
:return:
empty (200 status code) | [
":",
"param",
"payload",
":",
"a",
"key",
"/",
"value",
"object",
"containing",
"the",
"scimeta",
"you",
"want",
"to",
"store",
"e",
".",
"g",
".",
"{",
"weather",
":",
"sunny",
"temperature",
":",
"80C",
"}",
":",
"return",
":",
"empty",
"(",
"200",... | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L37-L49 | train | Returns a list of all the keys in the scimeta resource that are in the same order as the original. |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | FilesSubEndpoint.all | def all(self):
"""
:return:
array of file objects (200 status code)
"""
url = "{url_base}/resource/{pid}/files/".format(url_base=self.hs.url_base,
pid=self.pid)
r = self.hs._request('GET', url)
... | python | def all(self):
"""
:return:
array of file objects (200 status code)
"""
url = "{url_base}/resource/{pid}/files/".format(url_base=self.hs.url_base,
pid=self.pid)
r = self.hs._request('GET', url)
... | [
"def",
"all",
"(",
"self",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/files/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"hs",
".",
"url_base",
",",
"pid",
"=",
"self",
".",
"pid",
")",
"r",
"=",
"self",
".",
"hs",
".",
"_request",
... | :return:
array of file objects (200 status code) | [
":",
"return",
":",
"array",
"of",
"file",
"objects",
"(",
"200",
"status",
"code",
")"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L56-L64 | train | Returns a list of all the file objects in the resource. |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | FilesSubEndpoint.metadata | def metadata(self, file_path, params=None):
"""
:params:
title: string
keywords: array
extra_metadata: array
temporal_coverage: coverage object
spatial_coverage: coverage object
:return:
file metadata object (200 ... | python | def metadata(self, file_path, params=None):
"""
:params:
title: string
keywords: array
extra_metadata: array
temporal_coverage: coverage object
spatial_coverage: coverage object
:return:
file metadata object (200 ... | [
"def",
"metadata",
"(",
"self",
",",
"file_path",
",",
"params",
"=",
"None",
")",
":",
"url_base",
"=",
"self",
".",
"hs",
".",
"url_base",
"url",
"=",
"\"{url_base}/resource/{pid}/files/metadata/{file_path}/\"",
".",
"format",
"(",
"url_base",
"=",
"url_base",... | :params:
title: string
keywords: array
extra_metadata: array
temporal_coverage: coverage object
spatial_coverage: coverage object
:return:
file metadata object (200 status code) | [
":",
"params",
":",
"title",
":",
"string",
"keywords",
":",
"array",
"extra_metadata",
":",
"array",
"temporal_coverage",
":",
"coverage",
"object",
"spatial_coverage",
":",
"coverage",
"object",
":",
"return",
":",
"file",
"metadata",
"object",
"(",
"200",
"... | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L66-L91 | train | Returns the metadata for a single file. |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | FunctionsSubEndpoint.unzip | def unzip(self, payload):
"""
Unzips a file
:param payload:
zip_with_rel_path: string
remove_original_zip: boolean
:return: (object)
unzipped_path: string
"""
zip_with_rel_path = payload.pop('zip_with_rel_path')
ur... | python | def unzip(self, payload):
"""
Unzips a file
:param payload:
zip_with_rel_path: string
remove_original_zip: boolean
:return: (object)
unzipped_path: string
"""
zip_with_rel_path = payload.pop('zip_with_rel_path')
ur... | [
"def",
"unzip",
"(",
"self",
",",
"payload",
")",
":",
"zip_with_rel_path",
"=",
"payload",
".",
"pop",
"(",
"'zip_with_rel_path'",
")",
"url",
"=",
"\"{url_base}/resource/{pid}/functions/unzip/{path}/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"hs",
... | Unzips a file
:param payload:
zip_with_rel_path: string
remove_original_zip: boolean
:return: (object)
unzipped_path: string | [
"Unzips",
"a",
"file",
":",
"param",
"payload",
":",
"zip_with_rel_path",
":",
"string",
"remove_original_zip",
":",
"boolean",
":",
"return",
":",
"(",
"object",
")",
"unzipped_path",
":",
"string"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L133-L150 | train | Unzips a file
|
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | FunctionsSubEndpoint.set_file_type | def set_file_type(self, payload):
"""
Sets a file to a specific HydroShare file type (e.g. NetCDF, GeoRaster, GeoFeature etc)
:param payload:
file_path: string (relative path of the file to be set to a specific file type)
hs_file_type: string (one of the supported ... | python | def set_file_type(self, payload):
"""
Sets a file to a specific HydroShare file type (e.g. NetCDF, GeoRaster, GeoFeature etc)
:param payload:
file_path: string (relative path of the file to be set to a specific file type)
hs_file_type: string (one of the supported ... | [
"def",
"set_file_type",
"(",
"self",
",",
"payload",
")",
":",
"file_path",
"=",
"payload",
".",
"pop",
"(",
"'file_path'",
")",
"hs_file_type",
"=",
"payload",
".",
"pop",
"(",
"'hs_file_type'",
")",
"url",
"=",
"\"{url_base}/resource/{pid}/functions/set-file-typ... | Sets a file to a specific HydroShare file type (e.g. NetCDF, GeoRaster, GeoFeature etc)
:param payload:
file_path: string (relative path of the file to be set to a specific file type)
hs_file_type: string (one of the supported files types: SingleFile, NetCDF, GeoRaster,
... | [
"Sets",
"a",
"file",
"to",
"a",
"specific",
"HydroShare",
"file",
"type",
"(",
"e",
".",
"g",
".",
"NetCDF",
"GeoRaster",
"GeoFeature",
"etc",
")",
":",
"param",
"payload",
":",
"file_path",
":",
"string",
"(",
"relative",
"path",
"of",
"the",
"file",
... | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L167-L187 | train | Set a file to a specific HydroShare file type |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | ResourceEndpoint.flag | def flag(self, payload):
"""Set a single flag on a resource.
:param payload:
t: can be one of make_public, make_private, make_shareable,
make_not_shareable, make_discoverable, make_not_discoverable
:return:
empty but with 202 status_code
"""
... | python | def flag(self, payload):
"""Set a single flag on a resource.
:param payload:
t: can be one of make_public, make_private, make_shareable,
make_not_shareable, make_discoverable, make_not_discoverable
:return:
empty but with 202 status_code
"""
... | [
"def",
"flag",
"(",
"self",
",",
"payload",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/flag/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"hs",
".",
"url_base",
",",
"pid",
"=",
"self",
".",
"pid",
")",
"r",
"=",
"self",
".",
"hs",
"... | Set a single flag on a resource.
:param payload:
t: can be one of make_public, make_private, make_shareable,
make_not_shareable, make_discoverable, make_not_discoverable
:return:
empty but with 202 status_code | [
"Set",
"a",
"single",
"flag",
"on",
"a",
"resource",
".",
":",
"param",
"payload",
":",
"t",
":",
"can",
"be",
"one",
"of",
"make_public",
"make_private",
"make_shareable",
"make_not_shareable",
"make_discoverable",
"make_not_discoverable",
":",
"return",
":",
"... | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L208-L221 | train | Set a single flag on a resource. |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | ResourceEndpoint.files | def files(self, payload):
"""Upload a file to a hydroshare resource.
:param payload:
file: File object to upload to server
folder: folder path to upload the file to
:return: json object
resource_id: string resource id,
file_name: string na... | python | def files(self, payload):
"""Upload a file to a hydroshare resource.
:param payload:
file: File object to upload to server
folder: folder path to upload the file to
:return: json object
resource_id: string resource id,
file_name: string na... | [
"def",
"files",
"(",
"self",
",",
"payload",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/files/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"hs",
".",
"url_base",
",",
"pid",
"=",
"self",
".",
"pid",
")",
"encoder",
"=",
"MultipartEncoder"... | Upload a file to a hydroshare resource.
:param payload:
file: File object to upload to server
folder: folder path to upload the file to
:return: json object
resource_id: string resource id,
file_name: string name of file | [
"Upload",
"a",
"file",
"to",
"a",
"hydroshare",
"resource",
".",
":",
"param",
"payload",
":",
"file",
":",
"File",
"object",
"to",
"upload",
"to",
"server",
"folder",
":",
"folder",
"path",
"to",
"upload",
"the",
"file",
"to",
":",
"return",
":",
"jso... | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L223-L243 | train | Uploads a file to a hydroshare resource. |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | ResourceEndpoint.public | def public(self, boolean):
"""Pass through helper function for flag function."""
if(boolean):
r = self.flag({
"flag": "make_public"
})
else:
r = self.flag({
"flag": "make_private"
})
return r | python | def public(self, boolean):
"""Pass through helper function for flag function."""
if(boolean):
r = self.flag({
"flag": "make_public"
})
else:
r = self.flag({
"flag": "make_private"
})
return r | [
"def",
"public",
"(",
"self",
",",
"boolean",
")",
":",
"if",
"(",
"boolean",
")",
":",
"r",
"=",
"self",
".",
"flag",
"(",
"{",
"\"flag\"",
":",
"\"make_public\"",
"}",
")",
"else",
":",
"r",
"=",
"self",
".",
"flag",
"(",
"{",
"\"flag\"",
":",
... | Pass through helper function for flag function. | [
"Pass",
"through",
"helper",
"function",
"for",
"flag",
"function",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L255-L266 | train | Pass through helper function for flag function. |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | ResourceEndpoint.discoverable | def discoverable(self, boolean):
"""Pass through helper function for flag function."""
if(boolean):
r = self.flag({
"flag": "make_discoverable"
})
else:
r = self.flag({
"flag": "make_not_discoverable"
})
... | python | def discoverable(self, boolean):
"""Pass through helper function for flag function."""
if(boolean):
r = self.flag({
"flag": "make_discoverable"
})
else:
r = self.flag({
"flag": "make_not_discoverable"
})
... | [
"def",
"discoverable",
"(",
"self",
",",
"boolean",
")",
":",
"if",
"(",
"boolean",
")",
":",
"r",
"=",
"self",
".",
"flag",
"(",
"{",
"\"flag\"",
":",
"\"make_discoverable\"",
"}",
")",
"else",
":",
"r",
"=",
"self",
".",
"flag",
"(",
"{",
"\"flag... | Pass through helper function for flag function. | [
"Pass",
"through",
"helper",
"function",
"for",
"flag",
"function",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L268-L279 | train | Pass through helper function for flag function. |
hydroshare/hs_restclient | hs_restclient/endpoints/resources.py | ResourceEndpoint.shareable | def shareable(self, boolean):
"""Pass through helper function for flag function."""
if(boolean):
r = self.flag({
"flag": "make_shareable"
})
else:
r = self.flag({
"flag": "make_not_shareable"
})
r... | python | def shareable(self, boolean):
"""Pass through helper function for flag function."""
if(boolean):
r = self.flag({
"flag": "make_shareable"
})
else:
r = self.flag({
"flag": "make_not_shareable"
})
r... | [
"def",
"shareable",
"(",
"self",
",",
"boolean",
")",
":",
"if",
"(",
"boolean",
")",
":",
"r",
"=",
"self",
".",
"flag",
"(",
"{",
"\"flag\"",
":",
"\"make_shareable\"",
"}",
")",
"else",
":",
"r",
"=",
"self",
".",
"flag",
"(",
"{",
"\"flag\"",
... | Pass through helper function for flag function. | [
"Pass",
"through",
"helper",
"function",
"for",
"flag",
"function",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/endpoints/resources.py#L281-L292 | train | Pass through helper function for flag function. |
jaraco/jaraco.windows | jaraco/windows/power.py | no_sleep | def no_sleep():
"""
Context that prevents the computer from going to sleep.
"""
mode = power.ES.continuous | power.ES.system_required
handle_nonzero_success(power.SetThreadExecutionState(mode))
try:
yield
finally:
handle_nonzero_success(power.SetThreadExecutionState(power.ES.continuous)) | python | def no_sleep():
"""
Context that prevents the computer from going to sleep.
"""
mode = power.ES.continuous | power.ES.system_required
handle_nonzero_success(power.SetThreadExecutionState(mode))
try:
yield
finally:
handle_nonzero_success(power.SetThreadExecutionState(power.ES.continuous)) | [
"def",
"no_sleep",
"(",
")",
":",
"mode",
"=",
"power",
".",
"ES",
".",
"continuous",
"|",
"power",
".",
"ES",
".",
"system_required",
"handle_nonzero_success",
"(",
"power",
".",
"SetThreadExecutionState",
"(",
"mode",
")",
")",
"try",
":",
"yield",
"fina... | Context that prevents the computer from going to sleep. | [
"Context",
"that",
"prevents",
"the",
"computer",
"from",
"going",
"to",
"sleep",
"."
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/power.py#L68-L77 | train | This function is used to prevent the computer from going to sleep. |
theno/fabsetup | fabsetup/fabfile/setup/service/selfoss.py | selfoss | def selfoss(reset_password=False):
'''Install, update and set up selfoss.
This selfoss installation uses sqlite (selfoss-default), php5-fpm and nginx.
The connection is https-only and secured by a letsencrypt certificate. This
certificate must be created separately with task setup.server_letsencrypt.... | python | def selfoss(reset_password=False):
'''Install, update and set up selfoss.
This selfoss installation uses sqlite (selfoss-default), php5-fpm and nginx.
The connection is https-only and secured by a letsencrypt certificate. This
certificate must be created separately with task setup.server_letsencrypt.... | [
"def",
"selfoss",
"(",
"reset_password",
"=",
"False",
")",
":",
"hostname",
"=",
"re",
".",
"sub",
"(",
"r'^[^@]+@'",
",",
"''",
",",
"env",
".",
"host",
")",
"# without username if any",
"sitename",
"=",
"query_input",
"(",
"question",
"=",
"'\\nEnter site... | Install, update and set up selfoss.
This selfoss installation uses sqlite (selfoss-default), php5-fpm and nginx.
The connection is https-only and secured by a letsencrypt certificate. This
certificate must be created separately with task setup.server_letsencrypt.
More infos:
https://selfoss.ad... | [
"Install",
"update",
"and",
"set",
"up",
"selfoss",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/service/selfoss.py#L19-L54 | train | Install update and set up selfoss. |
NearHuscarl/py-currency | currency/cache.py | get_cache_path | def get_cache_path(filename):
""" get file path """
cwd = os.path.dirname(os.path.realpath(__file__))
return os.path.join(cwd, filename) | python | def get_cache_path(filename):
""" get file path """
cwd = os.path.dirname(os.path.realpath(__file__))
return os.path.join(cwd, filename) | [
"def",
"get_cache_path",
"(",
"filename",
")",
":",
"cwd",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",
"cwd",
",",
"filename",
")"
] | get file path | [
"get",
"file",
"path"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/cache.py#L8-L11 | train | get file path |
NearHuscarl/py-currency | currency/cache.py | read | def read(filename='cache'):
"""
parameter: file_path - path to cache file
return: data after parsing json file"""
cache_path = get_cache_path(filename)
if not os.path.exists(cache_path) or os.stat(cache_path).st_size == 0:
return None
with open(cache_path, 'r') as file:
return json.load(file) | python | def read(filename='cache'):
"""
parameter: file_path - path to cache file
return: data after parsing json file"""
cache_path = get_cache_path(filename)
if not os.path.exists(cache_path) or os.stat(cache_path).st_size == 0:
return None
with open(cache_path, 'r') as file:
return json.load(file) | [
"def",
"read",
"(",
"filename",
"=",
"'cache'",
")",
":",
"cache_path",
"=",
"get_cache_path",
"(",
"filename",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"cache_path",
")",
"or",
"os",
".",
"stat",
"(",
"cache_path",
")",
".",
"st_size",... | parameter: file_path - path to cache file
return: data after parsing json file | [
"parameter",
":",
"file_path",
"-",
"path",
"to",
"cache",
"file",
"return",
":",
"data",
"after",
"parsing",
"json",
"file"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/cache.py#L13-L21 | train | read a json file from the cache |
NearHuscarl/py-currency | currency/cache.py | write | def write(content, filename='cache'):
""" write data to cache file
parameters:
cache_path - path to cache file
content - a data structure to save into cache file"""
cache_path = get_cache_path(filename)
with open(cache_path, 'w') as file:
if content is not None:
json.dump(content, file, indent=3, sort_keys... | python | def write(content, filename='cache'):
""" write data to cache file
parameters:
cache_path - path to cache file
content - a data structure to save into cache file"""
cache_path = get_cache_path(filename)
with open(cache_path, 'w') as file:
if content is not None:
json.dump(content, file, indent=3, sort_keys... | [
"def",
"write",
"(",
"content",
",",
"filename",
"=",
"'cache'",
")",
":",
"cache_path",
"=",
"get_cache_path",
"(",
"filename",
")",
"with",
"open",
"(",
"cache_path",
",",
"'w'",
")",
"as",
"file",
":",
"if",
"content",
"is",
"not",
"None",
":",
"jso... | write data to cache file
parameters:
cache_path - path to cache file
content - a data structure to save into cache file | [
"write",
"data",
"to",
"cache",
"file",
"parameters",
":",
"cache_path",
"-",
"path",
"to",
"cache",
"file",
"content",
"-",
"a",
"data",
"structure",
"to",
"save",
"into",
"cache",
"file"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/cache.py#L23-L31 | train | write data to cache file |
jaraco/jaraco.windows | jaraco/windows/security.py | get_security_attributes_for_user | def get_security_attributes_for_user(user=None):
"""
Return a SECURITY_ATTRIBUTES structure with the SID set to the
specified user (uses current user if none is specified).
"""
if user is None:
user = get_current_user()
assert isinstance(user, security.TOKEN_USER), (
"user must be TOKEN_USER instance")
SD ... | python | def get_security_attributes_for_user(user=None):
"""
Return a SECURITY_ATTRIBUTES structure with the SID set to the
specified user (uses current user if none is specified).
"""
if user is None:
user = get_current_user()
assert isinstance(user, security.TOKEN_USER), (
"user must be TOKEN_USER instance")
SD ... | [
"def",
"get_security_attributes_for_user",
"(",
"user",
"=",
"None",
")",
":",
"if",
"user",
"is",
"None",
":",
"user",
"=",
"get_current_user",
"(",
")",
"assert",
"isinstance",
"(",
"user",
",",
"security",
".",
"TOKEN_USER",
")",
",",
"(",
"\"user must be... | Return a SECURITY_ATTRIBUTES structure with the SID set to the
specified user (uses current user if none is specified). | [
"Return",
"a",
"SECURITY_ATTRIBUTES",
"structure",
"with",
"the",
"SID",
"set",
"to",
"the",
"specified",
"user",
"(",
"uses",
"current",
"user",
"if",
"none",
"is",
"specified",
")",
"."
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/security.py#L43-L67 | train | Returns a SECURITY_ATTRIBUTES structure with the SID set to the
specified user. |
jaraco/jaraco.windows | jaraco/windows/privilege.py | get_process_token | def get_process_token():
"""
Get the current process token
"""
token = wintypes.HANDLE()
res = process.OpenProcessToken(
process.GetCurrentProcess(), process.TOKEN_ALL_ACCESS, token)
if not res > 0:
raise RuntimeError("Couldn't get process token")
return token | python | def get_process_token():
"""
Get the current process token
"""
token = wintypes.HANDLE()
res = process.OpenProcessToken(
process.GetCurrentProcess(), process.TOKEN_ALL_ACCESS, token)
if not res > 0:
raise RuntimeError("Couldn't get process token")
return token | [
"def",
"get_process_token",
"(",
")",
":",
"token",
"=",
"wintypes",
".",
"HANDLE",
"(",
")",
"res",
"=",
"process",
".",
"OpenProcessToken",
"(",
"process",
".",
"GetCurrentProcess",
"(",
")",
",",
"process",
".",
"TOKEN_ALL_ACCESS",
",",
"token",
")",
"i... | Get the current process token | [
"Get",
"the",
"current",
"process",
"token"
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/privilege.py#L11-L20 | train | Get the current process token |
jaraco/jaraco.windows | jaraco/windows/privilege.py | get_symlink_luid | def get_symlink_luid():
"""
Get the LUID for the SeCreateSymbolicLinkPrivilege
"""
symlink_luid = privilege.LUID()
res = privilege.LookupPrivilegeValue(
None, "SeCreateSymbolicLinkPrivilege", symlink_luid)
if not res > 0:
raise RuntimeError("Couldn't lookup privilege value")
return symlink_luid | python | def get_symlink_luid():
"""
Get the LUID for the SeCreateSymbolicLinkPrivilege
"""
symlink_luid = privilege.LUID()
res = privilege.LookupPrivilegeValue(
None, "SeCreateSymbolicLinkPrivilege", symlink_luid)
if not res > 0:
raise RuntimeError("Couldn't lookup privilege value")
return symlink_luid | [
"def",
"get_symlink_luid",
"(",
")",
":",
"symlink_luid",
"=",
"privilege",
".",
"LUID",
"(",
")",
"res",
"=",
"privilege",
".",
"LookupPrivilegeValue",
"(",
"None",
",",
"\"SeCreateSymbolicLinkPrivilege\"",
",",
"symlink_luid",
")",
"if",
"not",
"res",
">",
"... | Get the LUID for the SeCreateSymbolicLinkPrivilege | [
"Get",
"the",
"LUID",
"for",
"the",
"SeCreateSymbolicLinkPrivilege"
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/privilege.py#L23-L32 | train | Get the LUID for the SeCreateSymbolicLinkPrivilege and raise a RuntimeError if the privilege value is not found |
jaraco/jaraco.windows | jaraco/windows/privilege.py | get_privilege_information | def get_privilege_information():
"""
Get all privileges associated with the current process.
"""
# first call with zero length to determine what size buffer we need
return_length = wintypes.DWORD()
params = [
get_process_token(),
privilege.TOKEN_INFORMATION_CLASS.TokenPrivileges,
None,
0,
return_length... | python | def get_privilege_information():
"""
Get all privileges associated with the current process.
"""
# first call with zero length to determine what size buffer we need
return_length = wintypes.DWORD()
params = [
get_process_token(),
privilege.TOKEN_INFORMATION_CLASS.TokenPrivileges,
None,
0,
return_length... | [
"def",
"get_privilege_information",
"(",
")",
":",
"# first call with zero length to determine what size buffer we need",
"return_length",
"=",
"wintypes",
".",
"DWORD",
"(",
")",
"params",
"=",
"[",
"get_process_token",
"(",
")",
",",
"privilege",
".",
"TOKEN_INFORMATION... | Get all privileges associated with the current process. | [
"Get",
"all",
"privileges",
"associated",
"with",
"the",
"current",
"process",
"."
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/privilege.py#L35-L63 | train | Get all privileges associated with the current process. |
jaraco/jaraco.windows | jaraco/windows/privilege.py | enable_symlink_privilege | def enable_symlink_privilege():
"""
Try to assign the symlink privilege to the current process token.
Return True if the assignment is successful.
"""
# create a space in memory for a TOKEN_PRIVILEGES structure
# with one element
size = ctypes.sizeof(privilege.TOKEN_PRIVILEGES)
size += ctypes.sizeof(privilege.... | python | def enable_symlink_privilege():
"""
Try to assign the symlink privilege to the current process token.
Return True if the assignment is successful.
"""
# create a space in memory for a TOKEN_PRIVILEGES structure
# with one element
size = ctypes.sizeof(privilege.TOKEN_PRIVILEGES)
size += ctypes.sizeof(privilege.... | [
"def",
"enable_symlink_privilege",
"(",
")",
":",
"# create a space in memory for a TOKEN_PRIVILEGES structure",
"# with one element",
"size",
"=",
"ctypes",
".",
"sizeof",
"(",
"privilege",
".",
"TOKEN_PRIVILEGES",
")",
"size",
"+=",
"ctypes",
".",
"sizeof",
"(",
"pri... | Try to assign the symlink privilege to the current process token.
Return True if the assignment is successful. | [
"Try",
"to",
"assign",
"the",
"symlink",
"privilege",
"to",
"the",
"current",
"process",
"token",
".",
"Return",
"True",
"if",
"the",
"assignment",
"is",
"successful",
"."
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/privilege.py#L75-L95 | train | Enable symlink privilege. |
jaraco/jaraco.windows | jaraco/windows/privilege.py | grant_symlink_privilege | def grant_symlink_privilege(who, machine=''):
"""
Grant the 'create symlink' privilege to who.
Based on http://support.microsoft.com/kb/132958
"""
flags = security.POLICY_CREATE_ACCOUNT | security.POLICY_LOOKUP_NAMES
policy = OpenPolicy(machine, flags)
return policy | python | def grant_symlink_privilege(who, machine=''):
"""
Grant the 'create symlink' privilege to who.
Based on http://support.microsoft.com/kb/132958
"""
flags = security.POLICY_CREATE_ACCOUNT | security.POLICY_LOOKUP_NAMES
policy = OpenPolicy(machine, flags)
return policy | [
"def",
"grant_symlink_privilege",
"(",
"who",
",",
"machine",
"=",
"''",
")",
":",
"flags",
"=",
"security",
".",
"POLICY_CREATE_ACCOUNT",
"|",
"security",
".",
"POLICY_LOOKUP_NAMES",
"policy",
"=",
"OpenPolicy",
"(",
"machine",
",",
"flags",
")",
"return",
"p... | Grant the 'create symlink' privilege to who.
Based on http://support.microsoft.com/kb/132958 | [
"Grant",
"the",
"create",
"symlink",
"privilege",
"to",
"who",
"."
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/privilege.py#L123-L131 | train | Grant the create symlink privilege to who. |
theno/fabsetup | fabsetup/addons.py | get_or_create_module_r | def get_or_create_module_r(module_name, base_module=None):
'''Return a base-module (e.g. 'theno') or a sub-module (e.g.
'theno.service.raccoon') from the dict addon_modules given by param
'module_name'.
If the highest module (e.g. 'theno') not exists, an empty module will be
created. This will be ... | python | def get_or_create_module_r(module_name, base_module=None):
'''Return a base-module (e.g. 'theno') or a sub-module (e.g.
'theno.service.raccoon') from the dict addon_modules given by param
'module_name'.
If the highest module (e.g. 'theno') not exists, an empty module will be
created. This will be ... | [
"def",
"get_or_create_module_r",
"(",
"module_name",
",",
"base_module",
"=",
"None",
")",
":",
"module_names",
"=",
"module_name",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"if",
"len",
"(",
"module_names",
")",
">",
"1",
":",
"# e.g. ['theno', 'service.wallab... | Return a base-module (e.g. 'theno') or a sub-module (e.g.
'theno.service.raccoon') from the dict addon_modules given by param
'module_name'.
If the highest module (e.g. 'theno') not exists, an empty module will be
created. This will be continued recursively until the lowest sub-module
exists which... | [
"Return",
"a",
"base",
"-",
"module",
"(",
"e",
".",
"g",
".",
"theno",
")",
"or",
"a",
"sub",
"-",
"module",
"(",
"e",
".",
"g",
".",
"theno",
".",
"service",
".",
"raccoon",
")",
"from",
"the",
"dict",
"addon_modules",
"given",
"by",
"param",
"... | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/addons.py#L18-L47 | train | Return a base - module or a sub - module from the dict addon_modules given by module_name. |
theno/fabsetup | fabsetup/addons.py | add_tasks_r | def add_tasks_r(addon_module, package_module, package_name):
'''Recursively iterate through 'package_module' and add every fabric task
to the 'addon_module' keeping the task hierarchy.
Args:
addon_module(types.ModuleType)
package_module(types.ModuleType)
package_name(str): Required,... | python | def add_tasks_r(addon_module, package_module, package_name):
'''Recursively iterate through 'package_module' and add every fabric task
to the 'addon_module' keeping the task hierarchy.
Args:
addon_module(types.ModuleType)
package_module(types.ModuleType)
package_name(str): Required,... | [
"def",
"add_tasks_r",
"(",
"addon_module",
",",
"package_module",
",",
"package_name",
")",
":",
"module_dict",
"=",
"package_module",
".",
"__dict__",
"for",
"attr_name",
",",
"attr_val",
"in",
"module_dict",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"... | Recursively iterate through 'package_module' and add every fabric task
to the 'addon_module' keeping the task hierarchy.
Args:
addon_module(types.ModuleType)
package_module(types.ModuleType)
package_name(str): Required, to avoid redundant addition of tasks
Return: None | [
"Recursively",
"iterate",
"through",
"package_module",
"and",
"add",
"every",
"fabric",
"task",
"to",
"the",
"addon_module",
"keeping",
"the",
"task",
"hierarchy",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/addons.py#L50-L77 | train | Recursively add every fabric task
to the addon_module and all its submodules keeping the task hierarchy. |
theno/fabsetup | fabsetup/addons.py | load_addon | def load_addon(username, package_name, _globals):
'''Load an fabsetup addon given by 'package_name' and hook it in the
base task namespace 'username'.
Args:
username(str)
package_name(str)
_globals(dict): the globals() namespace of the fabric script.
Return: None
'''
ad... | python | def load_addon(username, package_name, _globals):
'''Load an fabsetup addon given by 'package_name' and hook it in the
base task namespace 'username'.
Args:
username(str)
package_name(str)
_globals(dict): the globals() namespace of the fabric script.
Return: None
'''
ad... | [
"def",
"load_addon",
"(",
"username",
",",
"package_name",
",",
"_globals",
")",
":",
"addon_module",
"=",
"get_or_create_module_r",
"(",
"username",
")",
"package_module",
"=",
"__import__",
"(",
"package_name",
")",
"add_tasks_r",
"(",
"addon_module",
",",
"pack... | Load an fabsetup addon given by 'package_name' and hook it in the
base task namespace 'username'.
Args:
username(str)
package_name(str)
_globals(dict): the globals() namespace of the fabric script.
Return: None | [
"Load",
"an",
"fabsetup",
"addon",
"given",
"by",
"package_name",
"and",
"hook",
"it",
"in",
"the",
"base",
"task",
"namespace",
"username",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/addons.py#L80-L96 | train | Load an addon given by package_name and hook it in the base task namespace username. |
theno/fabsetup | fabsetup/addons.py | load_pip_addons | def load_pip_addons(_globals):
'''Load all known fabsetup addons which are installed as pypi pip-packages.
Args:
_globals(dict): the globals() namespace of the fabric script.
Return: None
'''
for package_name in known_pip_addons:
_, username = package_username(package_name)
... | python | def load_pip_addons(_globals):
'''Load all known fabsetup addons which are installed as pypi pip-packages.
Args:
_globals(dict): the globals() namespace of the fabric script.
Return: None
'''
for package_name in known_pip_addons:
_, username = package_username(package_name)
... | [
"def",
"load_pip_addons",
"(",
"_globals",
")",
":",
"for",
"package_name",
"in",
"known_pip_addons",
":",
"_",
",",
"username",
"=",
"package_username",
"(",
"package_name",
")",
"try",
":",
"load_addon",
"(",
"username",
",",
"package_name",
".",
"replace",
... | Load all known fabsetup addons which are installed as pypi pip-packages.
Args:
_globals(dict): the globals() namespace of the fabric script.
Return: None | [
"Load",
"all",
"known",
"fabsetup",
"addons",
"which",
"are",
"installed",
"as",
"pypi",
"pip",
"-",
"packages",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/addons.py#L99-L112 | train | Load all known fabsetup addons which are installed as pypi pip - packages. |
theno/fabsetup | fabsetup/addons.py | package_username | def package_username(repo):
'''
>>> package_user('fabsetup-theno-termdown')
(termdown, theno)
'''
package = repo.replace('-', '_')
username = repo.split('-')[1]
return package, username | python | def package_username(repo):
'''
>>> package_user('fabsetup-theno-termdown')
(termdown, theno)
'''
package = repo.replace('-', '_')
username = repo.split('-')[1]
return package, username | [
"def",
"package_username",
"(",
"repo",
")",
":",
"package",
"=",
"repo",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
"username",
"=",
"repo",
".",
"split",
"(",
"'-'",
")",
"[",
"1",
"]",
"return",
"package",
",",
"username"
] | >>> package_user('fabsetup-theno-termdown')
(termdown, theno) | [
">>>",
"package_user",
"(",
"fabsetup",
"-",
"theno",
"-",
"termdown",
")",
"(",
"termdown",
"theno",
")"
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/addons.py#L115-L123 | train | Return package and username for a given repo. |
theno/fabsetup | fabsetup/addons.py | load_repo_addons | def load_repo_addons(_globals):
'''Load all fabsetup addons which are stored under ~/.fabsetup-addon-repos
as git repositories.
Args:
_globals(dict): the globals() namespace of the fabric script.
Return: None
'''
repos_dir = os.path.expanduser('~/.fabsetup-addon-repos')
if os.path.... | python | def load_repo_addons(_globals):
'''Load all fabsetup addons which are stored under ~/.fabsetup-addon-repos
as git repositories.
Args:
_globals(dict): the globals() namespace of the fabric script.
Return: None
'''
repos_dir = os.path.expanduser('~/.fabsetup-addon-repos')
if os.path.... | [
"def",
"load_repo_addons",
"(",
"_globals",
")",
":",
"repos_dir",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/.fabsetup-addon-repos'",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"repos_dir",
")",
":",
"basedir",
",",
"repos",
",",
"_",
"="... | Load all fabsetup addons which are stored under ~/.fabsetup-addon-repos
as git repositories.
Args:
_globals(dict): the globals() namespace of the fabric script.
Return: None | [
"Load",
"all",
"fabsetup",
"addons",
"which",
"are",
"stored",
"under",
"~",
"/",
".",
"fabsetup",
"-",
"addon",
"-",
"repos",
"as",
"git",
"repositories",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/addons.py#L126-L145 | train | Load all fabsetup addons which are stored under ~/.fabsetup - addon - repos as git repositories. |
theno/fabsetup | fabsetup/fabfile-data/presetting-fabsetup-custom/fabfile_/custom/__init__.py | users_bin_dir | def users_bin_dir():
'''Put custom commands at '~/bin/'
For the conversion of diagrams into the pdf format:
* dia2pdf, ep2svg, svg2pdf
* alldia2pdf, allep2svg, alldia2pdf
'''
# circumvent circular import, cf. http://stackoverflow.com/a/18486863
from fabfile.setup import pencil2
pencil2(... | python | def users_bin_dir():
'''Put custom commands at '~/bin/'
For the conversion of diagrams into the pdf format:
* dia2pdf, ep2svg, svg2pdf
* alldia2pdf, allep2svg, alldia2pdf
'''
# circumvent circular import, cf. http://stackoverflow.com/a/18486863
from fabfile.setup import pencil2
pencil2(... | [
"def",
"users_bin_dir",
"(",
")",
":",
"# circumvent circular import, cf. http://stackoverflow.com/a/18486863",
"from",
"fabfile",
".",
"setup",
"import",
"pencil2",
"pencil2",
"(",
")",
"# used by ~/bin/ep2svg",
"install_packages",
"(",
"[",
"'dia'",
",",
"'inkscape'",
"... | Put custom commands at '~/bin/'
For the conversion of diagrams into the pdf format:
* dia2pdf, ep2svg, svg2pdf
* alldia2pdf, allep2svg, alldia2pdf | [
"Put",
"custom",
"commands",
"at",
"~",
"/",
"bin",
"/"
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile-data/presetting-fabsetup-custom/fabfile_/custom/__init__.py#L9-L36 | train | Put custom commands at ~ / bin / |
bionikspoon/pureyaml | pureyaml/grammar/tokens.py | YAMLTokens.t_ignore_INDENT | def t_ignore_INDENT(self, t):
r'\n\s*'
indent_status, curr_depth, next_depth = self.get_indent_status(t)
if indent_status == 'NODENT':
return
if indent_status == 'INDENT':
# note: also set by
# * t_B_SEQUENCE_COMPACT_START
# * t_B_MA... | python | def t_ignore_INDENT(self, t):
r'\n\s*'
indent_status, curr_depth, next_depth = self.get_indent_status(t)
if indent_status == 'NODENT':
return
if indent_status == 'INDENT':
# note: also set by
# * t_B_SEQUENCE_COMPACT_START
# * t_B_MA... | [
"def",
"t_ignore_INDENT",
"(",
"self",
",",
"t",
")",
":",
"indent_status",
",",
"curr_depth",
",",
"next_depth",
"=",
"self",
".",
"get_indent_status",
"(",
"t",
")",
"if",
"indent_status",
"==",
"'NODENT'",
":",
"return",
"if",
"indent_status",
"==",
"'IND... | r'\n\s* | [
"r",
"\\",
"n",
"\\",
"s",
"*"
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/grammar/tokens.py#L79-L104 | train | Ignore the indentation status of a token. |
bionikspoon/pureyaml | pureyaml/grammar/tokens.py | YAMLTokens.t_begin_singlequote | def t_begin_singlequote(self, t):
r"(?<!\\)'"
t.lexer.push_state('singlequote')
# t.lexer.begin('singlequote')
t.type = 'CAST_TYPE'
t.type = 'SINGLEQUOTE_START'
return t | python | def t_begin_singlequote(self, t):
r"(?<!\\)'"
t.lexer.push_state('singlequote')
# t.lexer.begin('singlequote')
t.type = 'CAST_TYPE'
t.type = 'SINGLEQUOTE_START'
return t | [
"def",
"t_begin_singlequote",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"lexer",
".",
"push_state",
"(",
"'singlequote'",
")",
"# t.lexer.begin('singlequote')",
"t",
".",
"type",
"=",
"'CAST_TYPE'",
"t",
".",
"type",
"=",
"'SINGLEQUOTE_START'",
"return",
"t"
... | r"(?<!\\) | [
"r",
"(",
"?<!",
"\\\\",
")"
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/grammar/tokens.py#L155-L161 | train | t_begin_singlequote - Starts a singlequote |
bionikspoon/pureyaml | pureyaml/grammar/tokens.py | YAMLTokens.t_fold_end | def t_fold_end(self, t):
r'\n+\ *'
column = find_column(t)
indent = self.indent_stack[-1]
if column < indent:
rollback_lexpos(t)
if column <= indent:
t.lexer.pop_state()
t.type = 'B_FOLD_END'
if column > indent:
t.type = 'SC... | python | def t_fold_end(self, t):
r'\n+\ *'
column = find_column(t)
indent = self.indent_stack[-1]
if column < indent:
rollback_lexpos(t)
if column <= indent:
t.lexer.pop_state()
t.type = 'B_FOLD_END'
if column > indent:
t.type = 'SC... | [
"def",
"t_fold_end",
"(",
"self",
",",
"t",
")",
":",
"column",
"=",
"find_column",
"(",
"t",
")",
"indent",
"=",
"self",
".",
"indent_stack",
"[",
"-",
"1",
"]",
"if",
"column",
"<",
"indent",
":",
"rollback_lexpos",
"(",
"t",
")",
"if",
"column",
... | r'\n+\ * | [
"r",
"\\",
"n",
"+",
"\\",
"*"
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/grammar/tokens.py#L203-L214 | train | r \ n \ * \ n \ * \ n \ * \ n \ * \ n \ * \ n \ * \ n \ * \ n \ * \ n \ * \ n \ * \ n \ * \ n \ * \ n \ n \ \ |
bionikspoon/pureyaml | pureyaml/grammar/tokens.py | YAMLTokens.t_B_SEQUENCE_COMPACT_START | def t_B_SEQUENCE_COMPACT_START(self, t):
r"""
\-\ + (?= -\ )
# ^ ^ sequence indicator
| \-\ + (?= [\{\[]\ | [^:\n]*:\s )
# ^ ^ ^^^ map indicator
# ^ ^ flow indicator
"""
indent_status, curr_depth, n... | python | def t_B_SEQUENCE_COMPACT_START(self, t):
r"""
\-\ + (?= -\ )
# ^ ^ sequence indicator
| \-\ + (?= [\{\[]\ | [^:\n]*:\s )
# ^ ^ ^^^ map indicator
# ^ ^ flow indicator
"""
indent_status, curr_depth, n... | [
"def",
"t_B_SEQUENCE_COMPACT_START",
"(",
"self",
",",
"t",
")",
":",
"indent_status",
",",
"curr_depth",
",",
"next_depth",
"=",
"self",
".",
"get_indent_status",
"(",
"t",
")",
"if",
"indent_status",
"==",
"'INDENT'",
":",
"self",
".",
"indent_stack",
".",
... | r"""
\-\ + (?= -\ )
# ^ ^ sequence indicator
| \-\ + (?= [\{\[]\ | [^:\n]*:\s )
# ^ ^ ^^^ map indicator
# ^ ^ flow indicator | [
"r",
"\\",
"-",
"\\",
"+",
"(",
"?",
"=",
"-",
"\\",
")",
"#",
"^",
"^",
"sequence",
"indicator",
"|",
"\\",
"-",
"\\",
"+",
"(",
"?",
"=",
"[",
"\\",
"{",
"\\",
"[]",
"\\",
"|",
"[",
"^",
":",
"\\",
"n",
"]",
"*",
":",
"\\",
"s",
")"... | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/grammar/tokens.py#L274-L296 | train | t_B_SEQUENCE_COMPACT_START token handler |
jaraco/jaraco.windows | jaraco/windows/lib.py | find_lib | def find_lib(lib):
r"""
Find the DLL for a given library.
Accepts a string or loaded module
>>> print(find_lib('kernel32').lower())
c:\windows\system32\kernel32.dll
"""
if isinstance(lib, str):
lib = getattr(ctypes.windll, lib)
size = 1024
result = ctypes.create_unicode_buffer(size)
library.GetModuleFile... | python | def find_lib(lib):
r"""
Find the DLL for a given library.
Accepts a string or loaded module
>>> print(find_lib('kernel32').lower())
c:\windows\system32\kernel32.dll
"""
if isinstance(lib, str):
lib = getattr(ctypes.windll, lib)
size = 1024
result = ctypes.create_unicode_buffer(size)
library.GetModuleFile... | [
"def",
"find_lib",
"(",
"lib",
")",
":",
"if",
"isinstance",
"(",
"lib",
",",
"str",
")",
":",
"lib",
"=",
"getattr",
"(",
"ctypes",
".",
"windll",
",",
"lib",
")",
"size",
"=",
"1024",
"result",
"=",
"ctypes",
".",
"create_unicode_buffer",
"(",
"siz... | r"""
Find the DLL for a given library.
Accepts a string or loaded module
>>> print(find_lib('kernel32').lower())
c:\windows\system32\kernel32.dll | [
"r",
"Find",
"the",
"DLL",
"for",
"a",
"given",
"library",
"."
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/lib.py#L6-L21 | train | find_lib - Find the DLL for a given library. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.getScienceMetadataRDF | def getScienceMetadataRDF(self, pid):
""" Get science metadata for a resource in XML+RDF format
:param pid: The HydroShare ID of the resource
:raises: HydroShareNotAuthorized if the user is not authorized to view the metadata.
:raises: HydroShareNotFound if the resource was not found.
... | python | def getScienceMetadataRDF(self, pid):
""" Get science metadata for a resource in XML+RDF format
:param pid: The HydroShare ID of the resource
:raises: HydroShareNotAuthorized if the user is not authorized to view the metadata.
:raises: HydroShareNotFound if the resource was not found.
... | [
"def",
"getScienceMetadataRDF",
"(",
"self",
",",
"pid",
")",
":",
"url",
"=",
"\"{url_base}/scimeta/{pid}/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
",",
"pid",
"=",
"pid",
")",
"r",
"=",
"self",
".",
"_request",
"(",
"'GET'",
",... | Get science metadata for a resource in XML+RDF format
:param pid: The HydroShare ID of the resource
:raises: HydroShareNotAuthorized if the user is not authorized to view the metadata.
:raises: HydroShareNotFound if the resource was not found.
:raises: HydroShareHTTPException to signal ... | [
"Get",
"science",
"metadata",
"for",
"a",
"resource",
"in",
"XML",
"+",
"RDF",
"format"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L245-L358 | train | Returns the science metadata for a resource in XML + RDF format. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.getResource | def getResource(self, pid, destination=None, unzip=False, wait_for_bag_creation=True):
""" Get a resource in BagIt format
:param pid: The HydroShare ID of the resource
:param destination: String representing the directory to save bag to. Bag will be saved to file named
$(PID).zip in... | python | def getResource(self, pid, destination=None, unzip=False, wait_for_bag_creation=True):
""" Get a resource in BagIt format
:param pid: The HydroShare ID of the resource
:param destination: String representing the directory to save bag to. Bag will be saved to file named
$(PID).zip in... | [
"def",
"getResource",
"(",
"self",
",",
"pid",
",",
"destination",
"=",
"None",
",",
"unzip",
"=",
"False",
",",
"wait_for_bag_creation",
"=",
"True",
")",
":",
"stream",
"=",
"self",
".",
"_getBagStream",
"(",
"pid",
",",
"wait_for_bag_creation",
")",
"if... | Get a resource in BagIt format
:param pid: The HydroShare ID of the resource
:param destination: String representing the directory to save bag to. Bag will be saved to file named
$(PID).zip in destination; existing file of the same name will be overwritten. If None, a stream to the
... | [
"Get",
"a",
"resource",
"in",
"BagIt",
"format"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L567-L594 | train | Get a resource in BagIt format and store it in a file. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.getResourceTypes | def getResourceTypes(self):
""" Get the list of resource types supported by the HydroShare server
:return: A set of strings representing the HydroShare resource types
:raises: HydroShareHTTPException to signal an HTTP error
"""
url = "{url_base}/resource/types".format(url_base=... | python | def getResourceTypes(self):
""" Get the list of resource types supported by the HydroShare server
:return: A set of strings representing the HydroShare resource types
:raises: HydroShareHTTPException to signal an HTTP error
"""
url = "{url_base}/resource/types".format(url_base=... | [
"def",
"getResourceTypes",
"(",
"self",
")",
":",
"url",
"=",
"\"{url_base}/resource/types\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
")",
"r",
"=",
"self",
".",
"_request",
"(",
"'GET'",
",",
"url",
")",
"if",
"r",
".",
"status_co... | Get the list of resource types supported by the HydroShare server
:return: A set of strings representing the HydroShare resource types
:raises: HydroShareHTTPException to signal an HTTP error | [
"Get",
"the",
"list",
"of",
"resource",
"types",
"supported",
"by",
"the",
"HydroShare",
"server"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L668-L682 | train | Get the list of resource types supported by the HydroShare server |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.createResource | def createResource(self, resource_type, title, resource_file=None, resource_filename=None,
abstract=None, keywords=None,
edit_users=None, view_users=None, edit_groups=None, view_groups=None,
metadata=None, extra_metadata=None, progress_callback=None):... | python | def createResource(self, resource_type, title, resource_file=None, resource_filename=None,
abstract=None, keywords=None,
edit_users=None, view_users=None, edit_groups=None, view_groups=None,
metadata=None, extra_metadata=None, progress_callback=None):... | [
"def",
"createResource",
"(",
"self",
",",
"resource_type",
",",
"title",
",",
"resource_file",
"=",
"None",
",",
"resource_filename",
"=",
"None",
",",
"abstract",
"=",
"None",
",",
"keywords",
"=",
"None",
",",
"edit_users",
"=",
"None",
",",
"view_users",... | Create a new resource.
:param resource_type: string representing the a HydroShare resource type recognized by this
server.
:param title: string representing the title of the new resource
:param resource_file: a read-only binary file-like object (i.e. opened with the flag 'rb') or a ... | [
"Create",
"a",
"new",
"resource",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L684-L773 | train | Creates a new resource in HydroShare. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.deleteResource | def deleteResource(self, pid):
"""
Delete a resource.
:param pid: The HydroShare ID of the resource
"""
url = "{url_base}/resource/{pid}/".format(url_base=self.url_base,
pid=pid)
r = self._request('DELETE', url)
... | python | def deleteResource(self, pid):
"""
Delete a resource.
:param pid: The HydroShare ID of the resource
"""
url = "{url_base}/resource/{pid}/".format(url_base=self.url_base,
pid=pid)
r = self._request('DELETE', url)
... | [
"def",
"deleteResource",
"(",
"self",
",",
"pid",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
",",
"pid",
"=",
"pid",
")",
"r",
"=",
"self",
".",
"_request",
"(",
"'DELETE'",
",",
... | Delete a resource.
:param pid: The HydroShare ID of the resource | [
"Delete",
"a",
"resource",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L775-L795 | train | Delete a resource. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.setAccessRules | def setAccessRules(self, pid, public=False):
"""
Set access rules for a resource. Current only allows for setting the public or private setting.
:param pid: The HydroShare ID of the resource
:param public: True if the resource should be made public.
"""
url = "{url_base... | python | def setAccessRules(self, pid, public=False):
"""
Set access rules for a resource. Current only allows for setting the public or private setting.
:param pid: The HydroShare ID of the resource
:param public: True if the resource should be made public.
"""
url = "{url_base... | [
"def",
"setAccessRules",
"(",
"self",
",",
"pid",
",",
"public",
"=",
"False",
")",
":",
"url",
"=",
"\"{url_base}/resource/accessRules/{pid}/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
",",
"pid",
"=",
"pid",
")",
"params",
"=",
"{"... | Set access rules for a resource. Current only allows for setting the public or private setting.
:param pid: The HydroShare ID of the resource
:param public: True if the resource should be made public. | [
"Set",
"access",
"rules",
"for",
"a",
"resource",
".",
"Current",
"only",
"allows",
"for",
"setting",
"the",
"public",
"or",
"private",
"setting",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L797-L819 | train | Set the access rules for a resource. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.addResourceFile | def addResourceFile(self, pid, resource_file, resource_filename=None, progress_callback=None):
""" Add a new file to an existing resource
:param pid: The HydroShare ID of the resource
:param resource_file: a read-only binary file-like object (i.e. opened with the flag 'rb') or a string
... | python | def addResourceFile(self, pid, resource_file, resource_filename=None, progress_callback=None):
""" Add a new file to an existing resource
:param pid: The HydroShare ID of the resource
:param resource_file: a read-only binary file-like object (i.e. opened with the flag 'rb') or a string
... | [
"def",
"addResourceFile",
"(",
"self",
",",
"pid",
",",
"resource_file",
",",
"resource_filename",
"=",
"None",
",",
"progress_callback",
"=",
"None",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/files/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",... | Add a new file to an existing resource
:param pid: The HydroShare ID of the resource
:param resource_file: a read-only binary file-like object (i.e. opened with the flag 'rb') or a string
representing path to file to be uploaded as part of the new resource
:param resource_filename: ... | [
"Add",
"a",
"new",
"file",
"to",
"an",
"existing",
"resource"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L821-L870 | train | Add a new file to an existing resource. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.getResourceFile | def getResourceFile(self, pid, filename, destination=None):
""" Get a file within a resource.
:param pid: The HydroShare ID of the resource
:param filename: String representing the name of the resource file to get.
:param destination: String representing the directory to save the resour... | python | def getResourceFile(self, pid, filename, destination=None):
""" Get a file within a resource.
:param pid: The HydroShare ID of the resource
:param filename: String representing the name of the resource file to get.
:param destination: String representing the directory to save the resour... | [
"def",
"getResourceFile",
"(",
"self",
",",
"pid",
",",
"filename",
",",
"destination",
"=",
"None",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/files/{filename}\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
",",
"pid",
"=",
"pid",
... | Get a file within a resource.
:param pid: The HydroShare ID of the resource
:param filename: String representing the name of the resource file to get.
:param destination: String representing the directory to save the resource file to. If None, a stream
to the resource file will be r... | [
"Get",
"a",
"file",
"within",
"a",
"resource",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L872-L913 | train | Get a file within a resource. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.deleteResourceFile | def deleteResourceFile(self, pid, filename):
"""
Delete a resource file
:param pid: The HydroShare ID of the resource
:param filename: String representing the name of the resource file to delete
:return: Dictionary containing 'resource_id' the ID of the resource from which the ... | python | def deleteResourceFile(self, pid, filename):
"""
Delete a resource file
:param pid: The HydroShare ID of the resource
:param filename: String representing the name of the resource file to delete
:return: Dictionary containing 'resource_id' the ID of the resource from which the ... | [
"def",
"deleteResourceFile",
"(",
"self",
",",
"pid",
",",
"filename",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/files/{filename}\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
",",
"pid",
"=",
"pid",
",",
"filename",
"=",
"filename... | Delete a resource file
:param pid: The HydroShare ID of the resource
:param filename: String representing the name of the resource file to delete
:return: Dictionary containing 'resource_id' the ID of the resource from which the file was deleted, and
'file_name' the filename of the... | [
"Delete",
"a",
"resource",
"file"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L915-L944 | train | Delete a resource file from HydroShare. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.getResourceFileList | def getResourceFileList(self, pid):
""" Get a listing of files within a resource.
:param pid: The HydroShare ID of the resource whose resource files are to be listed.
:raises: HydroShareArgumentException if any parameters are invalid.
:raises: HydroShareNotAuthorized if user is not aut... | python | def getResourceFileList(self, pid):
""" Get a listing of files within a resource.
:param pid: The HydroShare ID of the resource whose resource files are to be listed.
:raises: HydroShareArgumentException if any parameters are invalid.
:raises: HydroShareNotAuthorized if user is not aut... | [
"def",
"getResourceFileList",
"(",
"self",
",",
"pid",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/files/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
",",
"pid",
"=",
"pid",
")",
"return",
"resultsListGenerator",
"(",
"self",
",",
... | Get a listing of files within a resource.
:param pid: The HydroShare ID of the resource whose resource files are to be listed.
:raises: HydroShareArgumentException if any parameters are invalid.
:raises: HydroShareNotAuthorized if user is not authorized to perform action.
:raises: Hydr... | [
"Get",
"a",
"listing",
"of",
"files",
"within",
"a",
"resource",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L946-L994 | train | Returns a generator that returns a list of files within a resource. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.getResourceFolderContents | def getResourceFolderContents(self, pid, pathname):
""" Get a listing of files and folders for a resource at the specified path (*pathname*)
:param pid: The HydroShare ID of the resource whose folder contents to be listed
:param pathname: Folder path for which contents (files and folders) need ... | python | def getResourceFolderContents(self, pid, pathname):
""" Get a listing of files and folders for a resource at the specified path (*pathname*)
:param pid: The HydroShare ID of the resource whose folder contents to be listed
:param pathname: Folder path for which contents (files and folders) need ... | [
"def",
"getResourceFolderContents",
"(",
"self",
",",
"pid",
",",
"pathname",
")",
":",
"url",
"=",
"\"{url_base}/resource/{pid}/folders/{path}\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
",",
"pid",
"=",
"pid",
",",
"path",
"=",
"pathnam... | Get a listing of files and folders for a resource at the specified path (*pathname*)
:param pid: The HydroShare ID of the resource whose folder contents to be listed
:param pathname: Folder path for which contents (files and folders) need to be listed
:return: A JSON object representing the con... | [
"Get",
"a",
"listing",
"of",
"files",
"and",
"folders",
"for",
"a",
"resource",
"at",
"the",
"specified",
"path",
"(",
"*",
"pathname",
"*",
")"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L996-L1027 | train | Get a listing of files and folders for a resource at the specified path. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.createReferenceURL | def createReferenceURL(self, pid, name, ref_url, path="", validate=True):
"""Create a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be created
:param name: Filename for the referenced file
... | python | def createReferenceURL(self, pid, name, ref_url, path="", validate=True):
"""Create a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be created
:param name: Filename for the referenced file
... | [
"def",
"createReferenceURL",
"(",
"self",
",",
"pid",
",",
"name",
",",
"ref_url",
",",
"path",
"=",
"\"\"",
",",
"validate",
"=",
"True",
")",
":",
"return",
"self",
".",
"createReferencedFile",
"(",
"pid",
",",
"path",
",",
"name",
",",
"ref_url",
",... | Create a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be created
:param name: Filename for the referenced file
:param ref_url: url to be used in the referenced file
:... | [
"Create",
"a",
"Referenced",
"Content",
"File",
"(",
".",
"url",
")",
":",
"param",
"pid",
":",
"The",
"HydroShare",
"ID",
"of",
"the",
"resource",
"for",
"which",
"the",
"file",
"should",
"be",
"created",
":",
"param",
"name",
":",
"Filename",
"for",
... | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L1091-L1103 | train | Create a Referenced Content File. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.updateReferenceURL | def updateReferenceURL(self, pid, name, ref_url, path=""):
"""Update a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be updated
:param name: Filename for the referenced file
:param r... | python | def updateReferenceURL(self, pid, name, ref_url, path=""):
"""Update a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be updated
:param name: Filename for the referenced file
:param r... | [
"def",
"updateReferenceURL",
"(",
"self",
",",
"pid",
",",
"name",
",",
"ref_url",
",",
"path",
"=",
"\"\"",
")",
":",
"return",
"self",
".",
"updateReferencedFile",
"(",
"pid",
",",
"path",
",",
"name",
",",
"ref_url",
")"
] | Update a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be updated
:param name: Filename for the referenced file
:param ref_url: url to be updated in the referenced file
... | [
"Update",
"a",
"Referenced",
"Content",
"File",
"(",
".",
"url",
")"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L1135-L1148 | train | Update a Referenced Content File. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.updateReferencedFile | def updateReferencedFile(self, pid, path, name, ref_url):
"""Deprecated, use updateReferenceURL. Update a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be updated
:param path: Folder path for the file to be updated in
... | python | def updateReferencedFile(self, pid, path, name, ref_url):
"""Deprecated, use updateReferenceURL. Update a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be updated
:param path: Folder path for the file to be updated in
... | [
"def",
"updateReferencedFile",
"(",
"self",
",",
"pid",
",",
"path",
",",
"name",
",",
"ref_url",
")",
":",
"url",
"=",
"\"{url_base}/resource/data_store_edit_reference_url/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
")",
"data",
"=",
"{... | Deprecated, use updateReferenceURL. Update a Referenced Content File (.url)
:param pid: The HydroShare ID of the resource for which the file should be updated
:param path: Folder path for the file to be updated in
:param name: Filename for the referenced file
... | [
"Deprecated",
"use",
"updateReferenceURL",
".",
"Update",
"a",
"Referenced",
"Content",
"File",
"(",
".",
"url",
")"
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L1150-L1178 | train | Deprecated use updateReferenceURL. |
hydroshare/hs_restclient | hs_restclient/__init__.py | HydroShare.getUserInfo | def getUserInfo(self):
"""
Query the GET /hsapi/userInfo/ REST end point of the HydroShare server.
:raises: HydroShareHTTPException to signal an HTTP error
:return: A JSON object representing user info, for example:
{
"username": "username",
"first_name... | python | def getUserInfo(self):
"""
Query the GET /hsapi/userInfo/ REST end point of the HydroShare server.
:raises: HydroShareHTTPException to signal an HTTP error
:return: A JSON object representing user info, for example:
{
"username": "username",
"first_name... | [
"def",
"getUserInfo",
"(",
"self",
")",
":",
"url",
"=",
"\"{url_base}/userInfo/\"",
".",
"format",
"(",
"url_base",
"=",
"self",
".",
"url_base",
")",
"r",
"=",
"self",
".",
"_request",
"(",
"'GET'",
",",
"url",
")",
"if",
"r",
".",
"status_code",
"!=... | Query the GET /hsapi/userInfo/ REST end point of the HydroShare server.
:raises: HydroShareHTTPException to signal an HTTP error
:return: A JSON object representing user info, for example:
{
"username": "username",
"first_name": "First",
"last_name": "Last"... | [
"Query",
"the",
"GET",
"/",
"hsapi",
"/",
"userInfo",
"/",
"REST",
"end",
"point",
"of",
"the",
"HydroShare",
"server",
"."
] | 9cd106238b512e01ecd3e33425fe48c13b7f63d5 | https://github.com/hydroshare/hs_restclient/blob/9cd106238b512e01ecd3e33425fe48c13b7f63d5/hs_restclient/__init__.py#L1180-L1201 | train | Query the GET / hsapi / userInfo / REST end point of the HydroShare server. |
muckamuck/stackility | stackility/utility/get_ssm_parameter.py | get_ssm_parameter | def get_ssm_parameter(parameter_name):
'''
Get the decrypted value of an SSM parameter
Args:
parameter_name - the name of the stored parameter of interest
Return:
Value if allowed and present else None
'''
try:
response = boto3.client('ssm').get_parameters(
... | python | def get_ssm_parameter(parameter_name):
'''
Get the decrypted value of an SSM parameter
Args:
parameter_name - the name of the stored parameter of interest
Return:
Value if allowed and present else None
'''
try:
response = boto3.client('ssm').get_parameters(
... | [
"def",
"get_ssm_parameter",
"(",
"parameter_name",
")",
":",
"try",
":",
"response",
"=",
"boto3",
".",
"client",
"(",
"'ssm'",
")",
".",
"get_parameters",
"(",
"Names",
"=",
"[",
"parameter_name",
"]",
",",
"WithDecryption",
"=",
"True",
")",
"return",
"r... | Get the decrypted value of an SSM parameter
Args:
parameter_name - the name of the stored parameter of interest
Return:
Value if allowed and present else None | [
"Get",
"the",
"decrypted",
"value",
"of",
"an",
"SSM",
"parameter"
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/utility/get_ssm_parameter.py#L6-L26 | train | Get the decrypted value of an SSM parameter |
awickert/gFlex | ez_setup.py | use_setuptools | def use_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
download_delay=15
):
"""Automatically find/download setuptools and make it available on sys.path
`version` should be a valid setuptools version number that is available
as an egg for download under the `downlo... | python | def use_setuptools(
version=DEFAULT_VERSION, download_base=DEFAULT_URL, to_dir=os.curdir,
download_delay=15
):
"""Automatically find/download setuptools and make it available on sys.path
`version` should be a valid setuptools version number that is available
as an egg for download under the `downlo... | [
"def",
"use_setuptools",
"(",
"version",
"=",
"DEFAULT_VERSION",
",",
"download_base",
"=",
"DEFAULT_URL",
",",
"to_dir",
"=",
"os",
".",
"curdir",
",",
"download_delay",
"=",
"15",
")",
":",
"was_imported",
"=",
"'pkg_resources'",
"in",
"sys",
".",
"modules",... | Automatically find/download setuptools and make it available on sys.path
`version` should be a valid setuptools version number that is available
as an egg for download under the `download_base` URL (which should end with
a '/'). `to_dir` is the directory where setuptools will be downloaded, if
it is n... | [
"Automatically",
"find",
"/",
"download",
"setuptools",
"and",
"make",
"it",
"available",
"on",
"sys",
".",
"path"
] | 3ac32249375b0f8d342a142585d86ea4d905a5a0 | https://github.com/awickert/gFlex/blob/3ac32249375b0f8d342a142585d86ea4d905a5a0/ez_setup.py#L80-L119 | train | Automatically find and download setuptools and make it available on sys. path
. |
theno/fabsetup | fabsetup/fabfile/setup/powerline.py | powerline | def powerline():
'''Install and set up powerline for vim, bash, tmux, and i3.
It uses pip (python2) and the most up to date powerline version (trunk) from
the github repository.
More infos:
https://github.com/powerline/powerline
https://powerline.readthedocs.io/en/latest/installation.html
... | python | def powerline():
'''Install and set up powerline for vim, bash, tmux, and i3.
It uses pip (python2) and the most up to date powerline version (trunk) from
the github repository.
More infos:
https://github.com/powerline/powerline
https://powerline.readthedocs.io/en/latest/installation.html
... | [
"def",
"powerline",
"(",
")",
":",
"bindings_dir",
",",
"scripts_dir",
"=",
"install_upgrade_powerline",
"(",
")",
"set_up_powerline_fonts",
"(",
")",
"set_up_powerline_daemon",
"(",
"scripts_dir",
")",
"powerline_for_vim",
"(",
"bindings_dir",
")",
"powerline_for_bash_... | Install and set up powerline for vim, bash, tmux, and i3.
It uses pip (python2) and the most up to date powerline version (trunk) from
the github repository.
More infos:
https://github.com/powerline/powerline
https://powerline.readthedocs.io/en/latest/installation.html
https://github.com... | [
"Install",
"and",
"set",
"up",
"powerline",
"for",
"vim",
"bash",
"tmux",
"and",
"i3",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/powerline.py#L16-L36 | train | Install and set up powerline for vim bash tmux and i3. |
theno/fabsetup | fabsetup/fabfile/setup/powerline.py | install_special_glyphs | def install_special_glyphs():
'''
More infos:
https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation
https://wiki.archlinux.org/index.php/Font_configuration
$XDG_CONFIG_HOME: http://superuser.com/a/365918
'''
from_dir = '~/repos/powerline/font'
run('... | python | def install_special_glyphs():
'''
More infos:
https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation
https://wiki.archlinux.org/index.php/Font_configuration
$XDG_CONFIG_HOME: http://superuser.com/a/365918
'''
from_dir = '~/repos/powerline/font'
run('... | [
"def",
"install_special_glyphs",
"(",
")",
":",
"from_dir",
"=",
"'~/repos/powerline/font'",
"run",
"(",
"'mkdir -p ~/.local/share/fonts'",
")",
"run",
"(",
"flo",
"(",
"'cp {from_dir}/PowerlineSymbols.otf ~/.local/share/fonts'",
")",
")",
"to_dir",
"=",
"'~/.config/fontco... | More infos:
https://powerline.readthedocs.io/en/latest/installation/linux.html#fonts-installation
https://wiki.archlinux.org/index.php/Font_configuration
$XDG_CONFIG_HOME: http://superuser.com/a/365918 | [
"More",
"infos",
":",
"https",
":",
"//",
"powerline",
".",
"readthedocs",
".",
"io",
"/",
"en",
"/",
"latest",
"/",
"installation",
"/",
"linux",
".",
"html#fonts",
"-",
"installation",
"https",
":",
"//",
"wiki",
".",
"archlinux",
".",
"org",
"/",
"i... | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/powerline.py#L40-L54 | train | Installs special glyphs in the powerline font. |
theno/fabsetup | fabsetup/fabfile/setup/powerline.py | install_upgrade_powerline | def install_upgrade_powerline():
'''
More infos:
https://powerline.readthedocs.io/en/latest/installation.html#pip-installation
'''
checkup_git_repo_legacy('https://github.com/powerline/powerline.git')
path_to_powerline = os.path.expanduser('~/repos/powerline')
run(flo('pip install --user -... | python | def install_upgrade_powerline():
'''
More infos:
https://powerline.readthedocs.io/en/latest/installation.html#pip-installation
'''
checkup_git_repo_legacy('https://github.com/powerline/powerline.git')
path_to_powerline = os.path.expanduser('~/repos/powerline')
run(flo('pip install --user -... | [
"def",
"install_upgrade_powerline",
"(",
")",
":",
"checkup_git_repo_legacy",
"(",
"'https://github.com/powerline/powerline.git'",
")",
"path_to_powerline",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~/repos/powerline'",
")",
"run",
"(",
"flo",
"(",
"'pip install... | More infos:
https://powerline.readthedocs.io/en/latest/installation.html#pip-installation | [
"More",
"infos",
":",
"https",
":",
"//",
"powerline",
".",
"readthedocs",
".",
"io",
"/",
"en",
"/",
"latest",
"/",
"installation",
".",
"html#pip",
"-",
"installation"
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/powerline.py#L58-L70 | train | Install upgrade powerline. |
theno/fabsetup | fabsetup/fabfile/setup/powerline.py | powerline_for_bash_or_powerline_shell | def powerline_for_bash_or_powerline_shell(bindings_dir):
'''Set up the bash extension of powerline or powerline_shell (another task).
'''
question = '\nSet up powerline-shell instead of powerline bash extension?'
if query_yes_no(question, default='yes'):
from setup import powerline_shell
... | python | def powerline_for_bash_or_powerline_shell(bindings_dir):
'''Set up the bash extension of powerline or powerline_shell (another task).
'''
question = '\nSet up powerline-shell instead of powerline bash extension?'
if query_yes_no(question, default='yes'):
from setup import powerline_shell
... | [
"def",
"powerline_for_bash_or_powerline_shell",
"(",
"bindings_dir",
")",
":",
"question",
"=",
"'\\nSet up powerline-shell instead of powerline bash extension?'",
"if",
"query_yes_no",
"(",
"question",
",",
"default",
"=",
"'yes'",
")",
":",
"from",
"setup",
"import",
"p... | Set up the bash extension of powerline or powerline_shell (another task). | [
"Set",
"up",
"the",
"bash",
"extension",
"of",
"powerline",
"or",
"powerline_shell",
"(",
"another",
"task",
")",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/powerline.py#L102-L118 | train | Set up the bash extension of powerline or powerline_shell. |
marcuswhybrow/django-lineage | lineage/templatetags/lineage.py | ifancestor | def ifancestor(parser, token):
"""
Returns the contents of the tag if the provided path consitutes the
base of the current pages path.
There are two ways to provide arguments to this tag. Firstly one may
provide a single argument that starts with a forward slash. e.g.
{% ifancestor '/path/... | python | def ifancestor(parser, token):
"""
Returns the contents of the tag if the provided path consitutes the
base of the current pages path.
There are two ways to provide arguments to this tag. Firstly one may
provide a single argument that starts with a forward slash. e.g.
{% ifancestor '/path/... | [
"def",
"ifancestor",
"(",
"parser",
",",
"token",
")",
":",
"# Grab the contents between",
"contents",
"=",
"parser",
".",
"parse",
"(",
"(",
"'endifancestor'",
",",
")",
")",
"parser",
".",
"delete_first_token",
"(",
")",
"# If there is only one argument (2 includi... | Returns the contents of the tag if the provided path consitutes the
base of the current pages path.
There are two ways to provide arguments to this tag. Firstly one may
provide a single argument that starts with a forward slash. e.g.
{% ifancestor '/path/to/page' %}...{% endifancestor}
{% ... | [
"Returns",
"the",
"contents",
"of",
"the",
"tag",
"if",
"the",
"provided",
"path",
"consitutes",
"the",
"base",
"of",
"the",
"current",
"pages",
"path",
"."
] | 2bd18b54f721dd39bacf5fe5e7f07e7e99b75b5e | https://github.com/marcuswhybrow/django-lineage/blob/2bd18b54f721dd39bacf5fe5e7f07e7e99b75b5e/lineage/templatetags/lineage.py#L14-L54 | train | Returns the contents of the current tag if the provided path consitutes the base of the current pages path. |
yahoo/serviceping | serviceping/cli.py | exit_statistics | def exit_statistics(hostname, start_time, count_sent, count_received, min_time, avg_time, max_time, deviation):
"""
Print ping exit statistics
"""
end_time = datetime.datetime.now()
duration = end_time - start_time
duration_sec = float(duration.seconds * 1000)
duration_ms = float(duration.mi... | python | def exit_statistics(hostname, start_time, count_sent, count_received, min_time, avg_time, max_time, deviation):
"""
Print ping exit statistics
"""
end_time = datetime.datetime.now()
duration = end_time - start_time
duration_sec = float(duration.seconds * 1000)
duration_ms = float(duration.mi... | [
"def",
"exit_statistics",
"(",
"hostname",
",",
"start_time",
",",
"count_sent",
",",
"count_received",
",",
"min_time",
",",
"avg_time",
",",
"max_time",
",",
"deviation",
")",
":",
"end_time",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"durati... | Print ping exit statistics | [
"Print",
"ping",
"exit",
"statistics"
] | 1f9df5ee5b3cba466426b1164262278472ba4977 | https://github.com/yahoo/serviceping/blob/1f9df5ee5b3cba466426b1164262278472ba4977/serviceping/cli.py#L23-L45 | train | Print ping exit statistics |
jaraco/jaraco.windows | jaraco/windows/filesystem/change.py | Notifier._filtered_walk | def _filtered_walk(path, file_filter):
"""
static method that calls os.walk, but filters out
anything that doesn't match the filter
"""
for root, dirs, files in os.walk(path):
log.debug('looking in %s', root)
log.debug('files is %s', files)
file_filter.set_root(root)
files = filter(file_filter, fi... | python | def _filtered_walk(path, file_filter):
"""
static method that calls os.walk, but filters out
anything that doesn't match the filter
"""
for root, dirs, files in os.walk(path):
log.debug('looking in %s', root)
log.debug('files is %s', files)
file_filter.set_root(root)
files = filter(file_filter, fi... | [
"def",
"_filtered_walk",
"(",
"path",
",",
"file_filter",
")",
":",
"for",
"root",
",",
"dirs",
",",
"files",
"in",
"os",
".",
"walk",
"(",
"path",
")",
":",
"log",
".",
"debug",
"(",
"'looking in %s'",
",",
"root",
")",
"log",
".",
"debug",
"(",
"... | static method that calls os.walk, but filters out
anything that doesn't match the filter | [
"static",
"method",
"that",
"calls",
"os",
".",
"walk",
"but",
"filters",
"out",
"anything",
"that",
"doesn",
"t",
"match",
"the",
"filter"
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/filesystem/change.py#L171-L182 | train | A generator that yields all the files in a directory that match the filter. |
pmac/django-redirect-urls | redirect_urls/decorators.py | cache_control_expires | def cache_control_expires(num_hours):
"""
Set the appropriate Cache-Control and Expires headers for the given
number of hours.
"""
num_seconds = int(num_hours * 60 * 60)
def decorator(func):
@wraps(func)
def inner(request, *args, **kwargs):
response = func(request, *... | python | def cache_control_expires(num_hours):
"""
Set the appropriate Cache-Control and Expires headers for the given
number of hours.
"""
num_seconds = int(num_hours * 60 * 60)
def decorator(func):
@wraps(func)
def inner(request, *args, **kwargs):
response = func(request, *... | [
"def",
"cache_control_expires",
"(",
"num_hours",
")",
":",
"num_seconds",
"=",
"int",
"(",
"num_hours",
"*",
"60",
"*",
"60",
")",
"def",
"decorator",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"inner",
"(",
"request",
",",
"*",
"... | Set the appropriate Cache-Control and Expires headers for the given
number of hours. | [
"Set",
"the",
"appropriate",
"Cache",
"-",
"Control",
"and",
"Expires",
"headers",
"for",
"the",
"given",
"number",
"of",
"hours",
"."
] | 21495194b0b2a2bdd1013e13ec0d54d34dd7f750 | https://github.com/pmac/django-redirect-urls/blob/21495194b0b2a2bdd1013e13ec0d54d34dd7f750/redirect_urls/decorators.py#L10-L26 | train | Decorator for handling Cache - Control and Expires headers for the given number of hours. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility.upsert | def upsert(self):
"""
The main event of the utility. Create or update a Cloud Formation
stack. Injecting properties where needed
Args:
None
Returns:
True if the stack create/update is started successfully else
False if the start goes off in t... | python | def upsert(self):
"""
The main event of the utility. Create or update a Cloud Formation
stack. Injecting properties where needed
Args:
None
Returns:
True if the stack create/update is started successfully else
False if the start goes off in t... | [
"def",
"upsert",
"(",
"self",
")",
":",
"required_parameters",
"=",
"[",
"]",
"self",
".",
"_stackParameters",
"=",
"[",
"]",
"try",
":",
"self",
".",
"_initialize_upsert",
"(",
")",
"except",
"Exception",
":",
"return",
"False",
"try",
":",
"available_par... | The main event of the utility. Create or update a Cloud Formation
stack. Injecting properties where needed
Args:
None
Returns:
True if the stack create/update is started successfully else
False if the start goes off in the weeds.
Exits:
... | [
"The",
"main",
"event",
"of",
"the",
"utility",
".",
"Create",
"or",
"update",
"a",
"Cloud",
"Formation",
"stack",
".",
"Injecting",
"properties",
"where",
"needed"
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L89-L179 | train | This method is called by the utility to create or update a Cloud Formation System. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility.list | def list(self):
"""
List the existing stacks in the indicated region
Args:
None
Returns:
True if True
Todo:
Figure out what could go wrong and take steps
to hanlde problems.
"""
self._initialize_list()
int... | python | def list(self):
"""
List the existing stacks in the indicated region
Args:
None
Returns:
True if True
Todo:
Figure out what could go wrong and take steps
to hanlde problems.
"""
self._initialize_list()
int... | [
"def",
"list",
"(",
"self",
")",
":",
"self",
".",
"_initialize_list",
"(",
")",
"interested",
"=",
"True",
"response",
"=",
"self",
".",
"_cloudFormation",
".",
"list_stacks",
"(",
")",
"print",
"(",
"'Stack(s):'",
")",
"while",
"interested",
":",
"if",
... | List the existing stacks in the indicated region
Args:
None
Returns:
True if True
Todo:
Figure out what could go wrong and take steps
to hanlde problems. | [
"List",
"the",
"existing",
"stacks",
"in",
"the",
"indicated",
"region"
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L321-L353 | train | List the existing stacks in the specified region. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility.smash | def smash(self):
"""
Smash the given stack
Args:
None
Returns:
True if True
Todo:
Figure out what could go wrong and take steps
to hanlde problems.
"""
self._initialize_smash()
try:
stack_name ... | python | def smash(self):
"""
Smash the given stack
Args:
None
Returns:
True if True
Todo:
Figure out what could go wrong and take steps
to hanlde problems.
"""
self._initialize_smash()
try:
stack_name ... | [
"def",
"smash",
"(",
"self",
")",
":",
"self",
".",
"_initialize_smash",
"(",
")",
"try",
":",
"stack_name",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'environment'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'stack_name'",
",",
"None",
")",
"respon... | Smash the given stack
Args:
None
Returns:
True if True
Todo:
Figure out what could go wrong and take steps
to hanlde problems. | [
"Smash",
"the",
"given",
"stack"
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L355-L388 | train | Smash the given stack and return the unique ID. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility._init_boto3_clients | def _init_boto3_clients(self):
"""
The utililty requires boto3 clients to Cloud Formation and S3. Here is
where we make them.
Args:
None
Returns:
Good or Bad; True or False
"""
try:
profile = self._config.get('environment', {}... | python | def _init_boto3_clients(self):
"""
The utililty requires boto3 clients to Cloud Formation and S3. Here is
where we make them.
Args:
None
Returns:
Good or Bad; True or False
"""
try:
profile = self._config.get('environment', {}... | [
"def",
"_init_boto3_clients",
"(",
"self",
")",
":",
"try",
":",
"profile",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'environment'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'profile'",
")",
"region",
"=",
"self",
".",
"_config",
".",
"get",
"(",
... | The utililty requires boto3 clients to Cloud Formation and S3. Here is
where we make them.
Args:
None
Returns:
Good or Bad; True or False | [
"The",
"utililty",
"requires",
"boto3",
"clients",
"to",
"Cloud",
"Formation",
"and",
"S3",
".",
"Here",
"is",
"where",
"we",
"make",
"them",
"."
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L390-L417 | train | Initialize the boto3 clients for the current user. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility._get_ssm_parameter | def _get_ssm_parameter(self, p):
"""
Get parameters from Simple Systems Manager
Args:
p - a parameter name
Returns:
a value, decrypted if needed, if successful or None if things go
sideways.
"""
try:
response = self._ssm.g... | python | def _get_ssm_parameter(self, p):
"""
Get parameters from Simple Systems Manager
Args:
p - a parameter name
Returns:
a value, decrypted if needed, if successful or None if things go
sideways.
"""
try:
response = self._ssm.g... | [
"def",
"_get_ssm_parameter",
"(",
"self",
",",
"p",
")",
":",
"try",
":",
"response",
"=",
"self",
".",
"_ssm",
".",
"get_parameter",
"(",
"Name",
"=",
"p",
",",
"WithDecryption",
"=",
"True",
")",
"return",
"response",
".",
"get",
"(",
"'Parameter'",
... | Get parameters from Simple Systems Manager
Args:
p - a parameter name
Returns:
a value, decrypted if needed, if successful or None if things go
sideways. | [
"Get",
"parameters",
"from",
"Simple",
"Systems",
"Manager"
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L434-L451 | train | Get a value from Simple Systems Manager |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility._fill_parameters | def _fill_parameters(self):
"""
Fill in the _parameters dict from the properties file.
Args:
None
Returns:
True
Todo:
Figure out what could go wrong and at least acknowledge the the
fact that Murphy was an optimist.
"""
... | python | def _fill_parameters(self):
"""
Fill in the _parameters dict from the properties file.
Args:
None
Returns:
True
Todo:
Figure out what could go wrong and at least acknowledge the the
fact that Murphy was an optimist.
"""
... | [
"def",
"_fill_parameters",
"(",
"self",
")",
":",
"self",
".",
"_parameters",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'parameters'",
",",
"{",
"}",
")",
"self",
".",
"_fill_defaults",
"(",
")",
"for",
"k",
"in",
"self",
".",
"_parameters",
".",
... | Fill in the _parameters dict from the properties file.
Args:
None
Returns:
True
Todo:
Figure out what could go wrong and at least acknowledge the the
fact that Murphy was an optimist. | [
"Fill",
"in",
"the",
"_parameters",
"dict",
"from",
"the",
"properties",
"file",
"."
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L453-L498 | train | Fill in the _parameters dict from the properties file. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility._read_tags | def _read_tags(self):
"""
Fill in the _tags dict from the tags file.
Args:
None
Returns:
True
Todo:
Figure what could go wrong and at least acknowledge the
the fact that Murphy was an optimist.
"""
tags = self._co... | python | def _read_tags(self):
"""
Fill in the _tags dict from the tags file.
Args:
None
Returns:
True
Todo:
Figure what could go wrong and at least acknowledge the
the fact that Murphy was an optimist.
"""
tags = self._co... | [
"def",
"_read_tags",
"(",
"self",
")",
":",
"tags",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'tags'",
",",
"{",
"}",
")",
"logging",
".",
"info",
"(",
"'Tags:'",
")",
"for",
"tag_name",
"in",
"tags",
".",
"keys",
"(",
")",
":",
"tag",
"=",
... | Fill in the _tags dict from the tags file.
Args:
None
Returns:
True
Todo:
Figure what could go wrong and at least acknowledge the
the fact that Murphy was an optimist. | [
"Fill",
"in",
"the",
"_tags",
"dict",
"from",
"the",
"tags",
"file",
"."
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L500-L528 | train | Read the tags from the tags file and add them to the internal _tags dict. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility._set_update | def _set_update(self):
"""
Determine if we are creating a new stack or updating and existing one.
The update member is set as you would expect at the end of this query.
Args:
None
Returns:
True
"""
try:
self._updateStack = Fal... | python | def _set_update(self):
"""
Determine if we are creating a new stack or updating and existing one.
The update member is set as you would expect at the end of this query.
Args:
None
Returns:
True
"""
try:
self._updateStack = Fal... | [
"def",
"_set_update",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_updateStack",
"=",
"False",
"stack_name",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'environment'",
",",
"{",
"}",
")",
".",
"get",
"(",
"'stack_name'",
",",
"None",
")",
"r... | Determine if we are creating a new stack or updating and existing one.
The update member is set as you would expect at the end of this query.
Args:
None
Returns:
True | [
"Determine",
"if",
"we",
"are",
"creating",
"a",
"new",
"stack",
"or",
"updating",
"and",
"existing",
"one",
".",
"The",
"update",
"member",
"is",
"set",
"as",
"you",
"would",
"expect",
"at",
"the",
"end",
"of",
"this",
"query",
"."
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L530-L561 | train | Determine if we are creating a new stack or updating an existing one. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility._archive_elements | def _archive_elements(self):
"""
Cloud Formation likes to take the template from S3 so here we put the
template into S3. We also store the parameters file that was used in
this run. Note: you can pass anything as the version string but you
should at least consider a version contr... | python | def _archive_elements(self):
"""
Cloud Formation likes to take the template from S3 so here we put the
template into S3. We also store the parameters file that was used in
this run. Note: you can pass anything as the version string but you
should at least consider a version contr... | [
"def",
"_archive_elements",
"(",
"self",
")",
":",
"try",
":",
"stackfile_key",
",",
"propertyfile_key",
"=",
"self",
".",
"_craft_s3_keys",
"(",
")",
"template_file",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'environment'",
",",
"{",
"}",
")",
".",
... | Cloud Formation likes to take the template from S3 so here we put the
template into S3. We also store the parameters file that was used in
this run. Note: you can pass anything as the version string but you
should at least consider a version control tag or git commit hash as
the version.... | [
"Cloud",
"Formation",
"likes",
"to",
"take",
"the",
"template",
"from",
"S3",
"so",
"here",
"we",
"put",
"the",
"template",
"into",
"S3",
".",
"We",
"also",
"store",
"the",
"parameters",
"file",
"that",
"was",
"used",
"in",
"this",
"run",
".",
"Note",
... | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L563-L603 | train | This function copies the template file to S3 and stores the parameters file into S3. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility._craft_s3_keys | def _craft_s3_keys(self):
"""
We are putting stuff into S3, were supplied the bucket. Here we
craft the key of the elements we are putting up there in the
internet clouds.
Args:
None
Returns:
a tuple of teplate file key and property file key
... | python | def _craft_s3_keys(self):
"""
We are putting stuff into S3, were supplied the bucket. Here we
craft the key of the elements we are putting up there in the
internet clouds.
Args:
None
Returns:
a tuple of teplate file key and property file key
... | [
"def",
"_craft_s3_keys",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"gmtime",
"(",
")",
"stub",
"=",
"\"templates/{stack_name}/{version}\"",
".",
"format",
"(",
"stack_name",
"=",
"self",
".",
"_config",
".",
"get",
"(",
"'environment'",
",",
"{",
"}"... | We are putting stuff into S3, were supplied the bucket. Here we
craft the key of the elements we are putting up there in the
internet clouds.
Args:
None
Returns:
a tuple of teplate file key and property file key | [
"We",
"are",
"putting",
"stuff",
"into",
"S3",
"were",
"supplied",
"the",
"bucket",
".",
"Here",
"we",
"craft",
"the",
"key",
"of",
"the",
"elements",
"we",
"are",
"putting",
"up",
"there",
"in",
"the",
"internet",
"clouds",
"."
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L605-L636 | train | This function crafts the keys of the elements in the internet clouds that are in S3. |
muckamuck/stackility | stackility/CloudStackUtility.py | CloudStackUtility.poll_stack | def poll_stack(self):
"""
Spin in a loop while the Cloud Formation process either fails or succeeds
Args:
None
Returns:
Good or bad; True or False
"""
logging.info('polling stack status, POLL_INTERVAL={}'.format(POLL_INTERVAL))
time.sleep... | python | def poll_stack(self):
"""
Spin in a loop while the Cloud Formation process either fails or succeeds
Args:
None
Returns:
Good or bad; True or False
"""
logging.info('polling stack status, POLL_INTERVAL={}'.format(POLL_INTERVAL))
time.sleep... | [
"def",
"poll_stack",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"'polling stack status, POLL_INTERVAL={}'",
".",
"format",
"(",
"POLL_INTERVAL",
")",
")",
"time",
".",
"sleep",
"(",
"POLL_INTERVAL",
")",
"completed_states",
"=",
"[",
"'CREATE_COMPLETE'",
... | Spin in a loop while the Cloud Formation process either fails or succeeds
Args:
None
Returns:
Good or bad; True or False | [
"Spin",
"in",
"a",
"loop",
"while",
"the",
"Cloud",
"Formation",
"process",
"either",
"fails",
"or",
"succeeds"
] | b1696f02661134d31b99b4dea7c0d21d09482d33 | https://github.com/muckamuck/stackility/blob/b1696f02661134d31b99b4dea7c0d21d09482d33/stackility/CloudStackUtility.py#L638-L680 | train | Poll the Cloud Formation process for a stack and return True or False. |
theno/fabsetup | fabsetup/fabfile-data/presetting-fabsetup-custom/fabfile_/__init__.py | setup_desktop | def setup_desktop():
'''Run setup tasks to set up a nicely configured desktop pc.
This is highly biased on my personal preference.
The task is defined in file fabsetup_custom/fabfile_addtitions/__init__.py
and could be customized by Your own needs. More info: README.md
'''
run('sudo apt-get u... | python | def setup_desktop():
'''Run setup tasks to set up a nicely configured desktop pc.
This is highly biased on my personal preference.
The task is defined in file fabsetup_custom/fabfile_addtitions/__init__.py
and could be customized by Your own needs. More info: README.md
'''
run('sudo apt-get u... | [
"def",
"setup_desktop",
"(",
")",
":",
"run",
"(",
"'sudo apt-get update'",
")",
"install_packages",
"(",
"packages_desktop",
")",
"execute",
"(",
"custom",
".",
"latex",
")",
"execute",
"(",
"setup",
".",
"ripping_of_cds",
")",
"execute",
"(",
"setup",
".",
... | Run setup tasks to set up a nicely configured desktop pc.
This is highly biased on my personal preference.
The task is defined in file fabsetup_custom/fabfile_addtitions/__init__.py
and could be customized by Your own needs. More info: README.md | [
"Run",
"setup",
"tasks",
"to",
"set",
"up",
"a",
"nicely",
"configured",
"desktop",
"pc",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile-data/presetting-fabsetup-custom/fabfile_/__init__.py#L52-L73 | train | Run setup tasks to set up a nicely configured desktop pc. |
theno/fabsetup | fabsetup/fabfile-data/presetting-fabsetup-custom/fabfile_/__init__.py | setup_webserver | def setup_webserver():
'''Run setup tasks to set up a nicely configured webserver.
Features:
* owncloud service
* fdroid repository
* certificates via letsencrypt
* and more
The task is defined in file fabsetup_custom/fabfile_addtitions/__init__.py
and could be customized by Your o... | python | def setup_webserver():
'''Run setup tasks to set up a nicely configured webserver.
Features:
* owncloud service
* fdroid repository
* certificates via letsencrypt
* and more
The task is defined in file fabsetup_custom/fabfile_addtitions/__init__.py
and could be customized by Your o... | [
"def",
"setup_webserver",
"(",
")",
":",
"run",
"(",
"'sudo apt-get update'",
")",
"install_packages",
"(",
"packages_webserver",
")",
"execute",
"(",
"custom",
".",
"latex",
")",
"execute",
"(",
"setup",
".",
"solarized",
")",
"execute",
"(",
"setup",
".",
... | Run setup tasks to set up a nicely configured webserver.
Features:
* owncloud service
* fdroid repository
* certificates via letsencrypt
* and more
The task is defined in file fabsetup_custom/fabfile_addtitions/__init__.py
and could be customized by Your own needs. More info: README.m... | [
"Run",
"setup",
"tasks",
"to",
"set",
"up",
"a",
"nicely",
"configured",
"webserver",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile-data/presetting-fabsetup-custom/fabfile_/__init__.py#L77-L101 | train | Run setup tasks to set up a nicely configured webserver. |
John-Lin/snortunsock | snortunsock/snort_listener.py | start_recv | def start_recv(sockfile=None):
'''Open a server on Unix Domain Socket'''
if sockfile is not None:
SOCKFILE = sockfile
else:
# default sockfile
SOCKFILE = "/tmp/snort_alert"
if os.path.exists(SOCKFILE):
os.unlink(SOCKFILE)
unsock = socket.socket(socket.AF_UNIX, socke... | python | def start_recv(sockfile=None):
'''Open a server on Unix Domain Socket'''
if sockfile is not None:
SOCKFILE = sockfile
else:
# default sockfile
SOCKFILE = "/tmp/snort_alert"
if os.path.exists(SOCKFILE):
os.unlink(SOCKFILE)
unsock = socket.socket(socket.AF_UNIX, socke... | [
"def",
"start_recv",
"(",
"sockfile",
"=",
"None",
")",
":",
"if",
"sockfile",
"is",
"not",
"None",
":",
"SOCKFILE",
"=",
"sockfile",
"else",
":",
"# default sockfile",
"SOCKFILE",
"=",
"\"/tmp/snort_alert\"",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"... | Open a server on Unix Domain Socket | [
"Open",
"a",
"server",
"on",
"Unix",
"Domain",
"Socket"
] | f0eb540d76c02b59e3899a16acafada79754dc3e | https://github.com/John-Lin/snortunsock/blob/f0eb540d76c02b59e3899a16acafada79754dc3e/snortunsock/snort_listener.py#L11-L29 | train | Open a server on Unix Domain Socket and parse the messages. |
bionikspoon/pureyaml | pureyaml/__init__.py | dump | def dump(obj, fp=None, indent=None, sort_keys=False, **kw):
"""
Dump object to a file like object or string.
:param obj:
:param fp: Open file like object
:param int indent: Indent size, default 2
:param bool sort_keys: Optionally sort dictionary keys.
:return: Yaml serialized data.
"""
... | python | def dump(obj, fp=None, indent=None, sort_keys=False, **kw):
"""
Dump object to a file like object or string.
:param obj:
:param fp: Open file like object
:param int indent: Indent size, default 2
:param bool sort_keys: Optionally sort dictionary keys.
:return: Yaml serialized data.
"""
... | [
"def",
"dump",
"(",
"obj",
",",
"fp",
"=",
"None",
",",
"indent",
"=",
"None",
",",
"sort_keys",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"if",
"fp",
":",
"iterable",
"=",
"YAMLEncoder",
"(",
"indent",
"=",
"indent",
",",
"sort_keys",
"=",
"s... | Dump object to a file like object or string.
:param obj:
:param fp: Open file like object
:param int indent: Indent size, default 2
:param bool sort_keys: Optionally sort dictionary keys.
:return: Yaml serialized data. | [
"Dump",
"object",
"to",
"a",
"file",
"like",
"object",
"or",
"string",
"."
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/__init__.py#L28-L44 | train | Dump object to a file - like object or string. |
bionikspoon/pureyaml | pureyaml/__init__.py | dumps | def dumps(obj, indent=None, default=None, sort_keys=False, **kw):
"""Dump string."""
return YAMLEncoder(indent=indent, default=default, sort_keys=sort_keys, **kw).encode(obj) | python | def dumps(obj, indent=None, default=None, sort_keys=False, **kw):
"""Dump string."""
return YAMLEncoder(indent=indent, default=default, sort_keys=sort_keys, **kw).encode(obj) | [
"def",
"dumps",
"(",
"obj",
",",
"indent",
"=",
"None",
",",
"default",
"=",
"None",
",",
"sort_keys",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"return",
"YAMLEncoder",
"(",
"indent",
"=",
"indent",
",",
"default",
"=",
"default",
",",
"sort_keys... | Dump string. | [
"Dump",
"string",
"."
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/__init__.py#L47-L49 | train | Dump object to YAML string. |
bionikspoon/pureyaml | pureyaml/__init__.py | load | def load(s, **kwargs):
"""Load yaml file"""
try:
return loads(s, **kwargs)
except TypeError:
return loads(s.read(), **kwargs) | python | def load(s, **kwargs):
"""Load yaml file"""
try:
return loads(s, **kwargs)
except TypeError:
return loads(s.read(), **kwargs) | [
"def",
"load",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"loads",
"(",
"s",
",",
"*",
"*",
"kwargs",
")",
"except",
"TypeError",
":",
"return",
"loads",
"(",
"s",
".",
"read",
"(",
")",
",",
"*",
"*",
"kwargs",
")"
] | Load yaml file | [
"Load",
"yaml",
"file"
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/__init__.py#L52-L57 | train | Load a yaml file |
bionikspoon/pureyaml | pureyaml/__init__.py | loads | def loads(s, cls=None, **kwargs):
"""Load string"""
if not isinstance(s, string_types):
raise TypeError('the YAML object must be str, not {0!r}'.format(s.__class__.__name__))
cls = cls or YAMLDecoder
return cls(**kwargs).decode(s) | python | def loads(s, cls=None, **kwargs):
"""Load string"""
if not isinstance(s, string_types):
raise TypeError('the YAML object must be str, not {0!r}'.format(s.__class__.__name__))
cls = cls or YAMLDecoder
return cls(**kwargs).decode(s) | [
"def",
"loads",
"(",
"s",
",",
"cls",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"s",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"'the YAML object must be str, not {0!r}'",
".",
"format",
"(",
"s",
".",... | Load string | [
"Load",
"string"
] | 784830b907ca14525c4cecdb6ae35306f6f8a877 | https://github.com/bionikspoon/pureyaml/blob/784830b907ca14525c4cecdb6ae35306f6f8a877/pureyaml/__init__.py#L60-L66 | train | Load a string into a new object. |
jaraco/jaraco.windows | jaraco/windows/api/inet.py | MIB_IPADDRROW.address | def address(self):
"The address in big-endian"
_ = struct.pack('L', self.address_num)
return struct.unpack('!L', _)[0] | python | def address(self):
"The address in big-endian"
_ = struct.pack('L', self.address_num)
return struct.unpack('!L', _)[0] | [
"def",
"address",
"(",
"self",
")",
":",
"_",
"=",
"struct",
".",
"pack",
"(",
"'L'",
",",
"self",
".",
"address_num",
")",
"return",
"struct",
".",
"unpack",
"(",
"'!L'",
",",
"_",
")",
"[",
"0",
"]"
] | The address in big-endian | [
"The",
"address",
"in",
"big",
"-",
"endian"
] | 51811efed50b46ad08daa25408a1cc806bc8d519 | https://github.com/jaraco/jaraco.windows/blob/51811efed50b46ad08daa25408a1cc806bc8d519/jaraco/windows/api/inet.py#L81-L84 | train | The address in big - endian |
theno/fabsetup | fabsetup/fabfile/setup/nvm.py | enable_nvm | def enable_nvm():
'''add to ~/.bashrc: Export of $NVM env variable and load nvm command.'''
bash_snippet = '~/.bashrc_nvm'
install_file_legacy(path=bash_snippet)
prefix = flo('if [ -f {bash_snippet} ]; ')
enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi')
if env.host == '... | python | def enable_nvm():
'''add to ~/.bashrc: Export of $NVM env variable and load nvm command.'''
bash_snippet = '~/.bashrc_nvm'
install_file_legacy(path=bash_snippet)
prefix = flo('if [ -f {bash_snippet} ]; ')
enabler = flo('if [ -f {bash_snippet} ]; then source {bash_snippet}; fi')
if env.host == '... | [
"def",
"enable_nvm",
"(",
")",
":",
"bash_snippet",
"=",
"'~/.bashrc_nvm'",
"install_file_legacy",
"(",
"path",
"=",
"bash_snippet",
")",
"prefix",
"=",
"flo",
"(",
"'if [ -f {bash_snippet} ]; '",
")",
"enabler",
"=",
"flo",
"(",
"'if [ -f {bash_snippet} ]; then sourc... | add to ~/.bashrc: Export of $NVM env variable and load nvm command. | [
"add",
"to",
"~",
"/",
".",
"bashrc",
":",
"Export",
"of",
"$NVM",
"env",
"variable",
"and",
"load",
"nvm",
"command",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/nvm.py#L37-L47 | train | add to ~. bashrc |
theno/fabsetup | fabsetup/fabfile/setup/nvm.py | nvm_primer | def nvm_primer():
'''Getting started with nvm (cf. https://github.com/creationix/nvm#usage).
'''
print('\nDownload, compile and install the latest release of node:\n\n' +
cyan(' nvm install node'))
print('\nAnd then in any new shell:\n\n' +
cyan(' nvm use node') + ' # use the... | python | def nvm_primer():
'''Getting started with nvm (cf. https://github.com/creationix/nvm#usage).
'''
print('\nDownload, compile and install the latest release of node:\n\n' +
cyan(' nvm install node'))
print('\nAnd then in any new shell:\n\n' +
cyan(' nvm use node') + ' # use the... | [
"def",
"nvm_primer",
"(",
")",
":",
"print",
"(",
"'\\nDownload, compile and install the latest release of node:\\n\\n'",
"+",
"cyan",
"(",
"' nvm install node'",
")",
")",
"print",
"(",
"'\\nAnd then in any new shell:\\n\\n'",
"+",
"cyan",
"(",
"' nvm use node'",
")"... | Getting started with nvm (cf. https://github.com/creationix/nvm#usage). | [
"Getting",
"started",
"with",
"nvm",
"(",
"cf",
".",
"https",
":",
"//",
"github",
".",
"com",
"/",
"creationix",
"/",
"nvm#usage",
")",
"."
] | ced728abff93551ba5677e63bc1bdc0ef5ca5777 | https://github.com/theno/fabsetup/blob/ced728abff93551ba5677e63bc1bdc0ef5ca5777/fabsetup/fabfile/setup/nvm.py#L62-L78 | train | Print the help message for the nvm node. |
NearHuscarl/py-currency | currency/currency.py | validate_currency | def validate_currency(*currencies):
""" some validation checks before doing anything """
validated_currency = []
if not currencies:
raise CurrencyException('My function need something to run, duh')
for currency in currencies:
currency = currency.upper()
if not isinstance(currency, str):
raise TypeError('Cu... | python | def validate_currency(*currencies):
""" some validation checks before doing anything """
validated_currency = []
if not currencies:
raise CurrencyException('My function need something to run, duh')
for currency in currencies:
currency = currency.upper()
if not isinstance(currency, str):
raise TypeError('Cu... | [
"def",
"validate_currency",
"(",
"*",
"currencies",
")",
":",
"validated_currency",
"=",
"[",
"]",
"if",
"not",
"currencies",
":",
"raise",
"CurrencyException",
"(",
"'My function need something to run, duh'",
")",
"for",
"currency",
"in",
"currencies",
":",
"curren... | some validation checks before doing anything | [
"some",
"validation",
"checks",
"before",
"doing",
"anything"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L35-L47 | train | validate_currency - check the currency code |
NearHuscarl/py-currency | currency/currency.py | validate_price | def validate_price(price):
""" validation checks for price argument """
if isinstance(price, str):
try:
price = int(price)
except ValueError: # fallback if convert to int failed
price = float(price)
if not isinstance(price, (int, float)):
raise TypeError('Price should be a number: ' + repr(price))
retur... | python | def validate_price(price):
""" validation checks for price argument """
if isinstance(price, str):
try:
price = int(price)
except ValueError: # fallback if convert to int failed
price = float(price)
if not isinstance(price, (int, float)):
raise TypeError('Price should be a number: ' + repr(price))
retur... | [
"def",
"validate_price",
"(",
"price",
")",
":",
"if",
"isinstance",
"(",
"price",
",",
"str",
")",
":",
"try",
":",
"price",
"=",
"int",
"(",
"price",
")",
"except",
"ValueError",
":",
"# fallback if convert to int failed",
"price",
"=",
"float",
"(",
"pr... | validation checks for price argument | [
"validation",
"checks",
"for",
"price",
"argument"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L49-L58 | train | validate price argument |
NearHuscarl/py-currency | currency/currency.py | name | def name(currency, *, plural=False):
""" return name of currency """
currency = validate_currency(currency)
if plural:
return _currencies[currency]['name_plural']
return _currencies[currency]['name'] | python | def name(currency, *, plural=False):
""" return name of currency """
currency = validate_currency(currency)
if plural:
return _currencies[currency]['name_plural']
return _currencies[currency]['name'] | [
"def",
"name",
"(",
"currency",
",",
"*",
",",
"plural",
"=",
"False",
")",
":",
"currency",
"=",
"validate_currency",
"(",
"currency",
")",
"if",
"plural",
":",
"return",
"_currencies",
"[",
"currency",
"]",
"[",
"'name_plural'",
"]",
"return",
"_currenci... | return name of currency | [
"return",
"name",
"of",
"currency"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L70-L75 | train | return name of currency |
NearHuscarl/py-currency | currency/currency.py | symbol | def symbol(currency, *, native=True):
""" return symbol of currency """
currency = validate_currency(currency)
if native:
return _currencies[currency]['symbol_native']
return _currencies[currency]['symbol'] | python | def symbol(currency, *, native=True):
""" return symbol of currency """
currency = validate_currency(currency)
if native:
return _currencies[currency]['symbol_native']
return _currencies[currency]['symbol'] | [
"def",
"symbol",
"(",
"currency",
",",
"*",
",",
"native",
"=",
"True",
")",
":",
"currency",
"=",
"validate_currency",
"(",
"currency",
")",
"if",
"native",
":",
"return",
"_currencies",
"[",
"currency",
"]",
"[",
"'symbol_native'",
"]",
"return",
"_curre... | return symbol of currency | [
"return",
"symbol",
"of",
"currency"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L77-L82 | train | return symbol of currency |
NearHuscarl/py-currency | currency/currency.py | rounding | def rounding(price, currency):
""" rounding currency value based on its max decimal digits """
currency = validate_currency(currency)
price = validate_price(price)
if decimals(currency) == 0:
return round(int(price), decimals(currency))
return round(price, decimals(currency)) | python | def rounding(price, currency):
""" rounding currency value based on its max decimal digits """
currency = validate_currency(currency)
price = validate_price(price)
if decimals(currency) == 0:
return round(int(price), decimals(currency))
return round(price, decimals(currency)) | [
"def",
"rounding",
"(",
"price",
",",
"currency",
")",
":",
"currency",
"=",
"validate_currency",
"(",
"currency",
")",
"price",
"=",
"validate_price",
"(",
"price",
")",
"if",
"decimals",
"(",
"currency",
")",
"==",
"0",
":",
"return",
"round",
"(",
"in... | rounding currency value based on its max decimal digits | [
"rounding",
"currency",
"value",
"based",
"on",
"its",
"max",
"decimal",
"digits"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L94-L100 | train | rounding currency value based on its max decimal digits |
NearHuscarl/py-currency | currency/currency.py | pretty | def pretty(price, currency, *, abbrev=True, trim=True):
""" return format price with symbol. Example format(100, 'USD') return '$100'
pretty(price, currency, abbrev=True, trim=False)
abbrev:
True: print value + symbol. Symbol can either be placed before or after value
False: print value + currency code. currency... | python | def pretty(price, currency, *, abbrev=True, trim=True):
""" return format price with symbol. Example format(100, 'USD') return '$100'
pretty(price, currency, abbrev=True, trim=False)
abbrev:
True: print value + symbol. Symbol can either be placed before or after value
False: print value + currency code. currency... | [
"def",
"pretty",
"(",
"price",
",",
"currency",
",",
"*",
",",
"abbrev",
"=",
"True",
",",
"trim",
"=",
"True",
")",
":",
"currency",
"=",
"validate_currency",
"(",
"currency",
")",
"price",
"=",
"validate_price",
"(",
"price",
")",
"space",
"=",
"''",... | return format price with symbol. Example format(100, 'USD') return '$100'
pretty(price, currency, abbrev=True, trim=False)
abbrev:
True: print value + symbol. Symbol can either be placed before or after value
False: print value + currency code. currency code is placed behind value
trim:
True: trim float value ... | [
"return",
"format",
"price",
"with",
"symbol",
".",
"Example",
"format",
"(",
"100",
"USD",
")",
"return",
"$100",
"pretty",
"(",
"price",
"currency",
"abbrev",
"=",
"True",
"trim",
"=",
"False",
")",
"abbrev",
":",
"True",
":",
"print",
"value",
"+",
... | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L110-L131 | train | return format price with symbol |
NearHuscarl/py-currency | currency/currency.py | check_update | def check_update(from_currency, to_currency):
""" check if last update is over 30 mins ago. if so return True to update, else False """
if from_currency not in ccache: # if currency never get converted before
ccache[from_currency] = {}
if ccache[from_currency].get(to_currency) is None:
ccache[from_currency][to_c... | python | def check_update(from_currency, to_currency):
""" check if last update is over 30 mins ago. if so return True to update, else False """
if from_currency not in ccache: # if currency never get converted before
ccache[from_currency] = {}
if ccache[from_currency].get(to_currency) is None:
ccache[from_currency][to_c... | [
"def",
"check_update",
"(",
"from_currency",
",",
"to_currency",
")",
":",
"if",
"from_currency",
"not",
"in",
"ccache",
":",
"# if currency never get converted before",
"ccache",
"[",
"from_currency",
"]",
"=",
"{",
"}",
"if",
"ccache",
"[",
"from_currency",
"]",... | check if last update is over 30 mins ago. if so return True to update, else False | [
"check",
"if",
"last",
"update",
"is",
"over",
"30",
"mins",
"ago",
".",
"if",
"so",
"return",
"True",
"to",
"update",
"else",
"False"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L133-L142 | train | check if last update is over 30 mins ago. return True to update else False |
NearHuscarl/py-currency | currency/currency.py | update_cache | def update_cache(from_currency, to_currency):
""" update from_currency to_currency pair in cache if
last update for that pair is over 30 minutes ago by request API info """
if check_update(from_currency, to_currency) is True:
ccache[from_currency][to_currency]['value'] = convert_using_api(from_currency, to_currenc... | python | def update_cache(from_currency, to_currency):
""" update from_currency to_currency pair in cache if
last update for that pair is over 30 minutes ago by request API info """
if check_update(from_currency, to_currency) is True:
ccache[from_currency][to_currency]['value'] = convert_using_api(from_currency, to_currenc... | [
"def",
"update_cache",
"(",
"from_currency",
",",
"to_currency",
")",
":",
"if",
"check_update",
"(",
"from_currency",
",",
"to_currency",
")",
"is",
"True",
":",
"ccache",
"[",
"from_currency",
"]",
"[",
"to_currency",
"]",
"[",
"'value'",
"]",
"=",
"conver... | update from_currency to_currency pair in cache if
last update for that pair is over 30 minutes ago by request API info | [
"update",
"from_currency",
"to_currency",
"pair",
"in",
"cache",
"if",
"last",
"update",
"for",
"that",
"pair",
"is",
"over",
"30",
"minutes",
"ago",
"by",
"request",
"API",
"info"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L144-L150 | train | update from_currency to_currency pair in cache |
NearHuscarl/py-currency | currency/currency.py | convert_using_api | def convert_using_api(from_currency, to_currency):
""" convert from from_currency to to_currency by requesting API """
convert_str = from_currency + '_' + to_currency
options = {'compact': 'ultra', 'q': convert_str}
api_url = 'https://free.currencyconverterapi.com/api/v5/convert'
result = requests.get(api_url, par... | python | def convert_using_api(from_currency, to_currency):
""" convert from from_currency to to_currency by requesting API """
convert_str = from_currency + '_' + to_currency
options = {'compact': 'ultra', 'q': convert_str}
api_url = 'https://free.currencyconverterapi.com/api/v5/convert'
result = requests.get(api_url, par... | [
"def",
"convert_using_api",
"(",
"from_currency",
",",
"to_currency",
")",
":",
"convert_str",
"=",
"from_currency",
"+",
"'_'",
"+",
"to_currency",
"options",
"=",
"{",
"'compact'",
":",
"'ultra'",
",",
"'q'",
":",
"convert_str",
"}",
"api_url",
"=",
"'https:... | convert from from_currency to to_currency by requesting API | [
"convert",
"from",
"from_currency",
"to",
"to_currency",
"by",
"requesting",
"API"
] | 4e30426399872fd6bfaa4c752a91d67c2d7bf52c | https://github.com/NearHuscarl/py-currency/blob/4e30426399872fd6bfaa4c752a91d67c2d7bf52c/currency/currency.py#L152-L158 | train | convert from from_currency to to_currency by requesting API |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.