repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
sernst/cauldron | cauldron/cli/server/routes/synchronize/__init__.py | touch_project | def touch_project():
"""
Touches the project to trigger refreshing its cauldron.json state.
"""
r = Response()
project = cd.project.get_internal_project()
if project:
project.refresh()
else:
r.fail(
code='NO_PROJECT',
message='No open project to refre... | python | def touch_project():
"""
Touches the project to trigger refreshing its cauldron.json state.
"""
r = Response()
project = cd.project.get_internal_project()
if project:
project.refresh()
else:
r.fail(
code='NO_PROJECT',
message='No open project to refre... | [
"def",
"touch_project",
"(",
")",
":",
"r",
"=",
"Response",
"(",
")",
"project",
"=",
"cd",
".",
"project",
".",
"get_internal_project",
"(",
")",
"if",
"project",
":",
"project",
".",
"refresh",
"(",
")",
"else",
":",
"r",
".",
"fail",
"(",
"code",... | Touches the project to trigger refreshing its cauldron.json state. | [
"Touches",
"the",
"project",
"to",
"trigger",
"refreshing",
"its",
"cauldron",
".",
"json",
"state",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/synchronize/__init__.py#L28-L45 |
sernst/cauldron | cauldron/cli/server/routes/synchronize/__init__.py | fetch_synchronize_status | def fetch_synchronize_status():
"""
Returns the synchronization status information for the currently opened
project
"""
r = Response()
project = cd.project.get_internal_project()
if not project:
r.fail(
code='NO_PROJECT',
message='No open project on which to ... | python | def fetch_synchronize_status():
"""
Returns the synchronization status information for the currently opened
project
"""
r = Response()
project = cd.project.get_internal_project()
if not project:
r.fail(
code='NO_PROJECT',
message='No open project on which to ... | [
"def",
"fetch_synchronize_status",
"(",
")",
":",
"r",
"=",
"Response",
"(",
")",
"project",
"=",
"cd",
".",
"project",
".",
"get_internal_project",
"(",
")",
"if",
"not",
"project",
":",
"r",
".",
"fail",
"(",
"code",
"=",
"'NO_PROJECT'",
",",
"message"... | Returns the synchronization status information for the currently opened
project | [
"Returns",
"the",
"synchronization",
"status",
"information",
"for",
"the",
"currently",
"opened",
"project"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/synchronize/__init__.py#L50-L76 |
sernst/cauldron | cauldron/cli/server/routes/synchronize/__init__.py | download_file | def download_file(filename: str):
""" downloads the specified project file if it exists """
project = cd.project.get_internal_project()
source_directory = project.source_directory if project else None
if not filename or not project or not source_directory:
return '', 204
path = os.path.re... | python | def download_file(filename: str):
""" downloads the specified project file if it exists """
project = cd.project.get_internal_project()
source_directory = project.source_directory if project else None
if not filename or not project or not source_directory:
return '', 204
path = os.path.re... | [
"def",
"download_file",
"(",
"filename",
":",
"str",
")",
":",
"project",
"=",
"cd",
".",
"project",
".",
"get_internal_project",
"(",
")",
"source_directory",
"=",
"project",
".",
"source_directory",
"if",
"project",
"else",
"None",
"if",
"not",
"filename",
... | downloads the specified project file if it exists | [
"downloads",
"the",
"specified",
"project",
"file",
"if",
"it",
"exists"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/synchronize/__init__.py#L198-L217 |
sernst/cauldron | cauldron/session/projects/definitions.py | get_project_source_path | def get_project_source_path(path: str) -> str:
"""
Converts the given path into a project source path, to the cauldron.json
file. If the path already points to a cauldron.json file, the path is
returned without modification.
:param path:
The path to convert into a project source path
""... | python | def get_project_source_path(path: str) -> str:
"""
Converts the given path into a project source path, to the cauldron.json
file. If the path already points to a cauldron.json file, the path is
returned without modification.
:param path:
The path to convert into a project source path
""... | [
"def",
"get_project_source_path",
"(",
"path",
":",
"str",
")",
"->",
"str",
":",
"path",
"=",
"environ",
".",
"paths",
".",
"clean",
"(",
"path",
")",
"if",
"not",
"path",
".",
"endswith",
"(",
"'cauldron.json'",
")",
":",
"return",
"os",
".",
"path",... | Converts the given path into a project source path, to the cauldron.json
file. If the path already points to a cauldron.json file, the path is
returned without modification.
:param path:
The path to convert into a project source path | [
"Converts",
"the",
"given",
"path",
"into",
"a",
"project",
"source",
"path",
"to",
"the",
"cauldron",
".",
"json",
"file",
".",
"If",
"the",
"path",
"already",
"points",
"to",
"a",
"cauldron",
".",
"json",
"file",
"the",
"path",
"is",
"returned",
"witho... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/definitions.py#L7-L22 |
sernst/cauldron | cauldron/session/projects/definitions.py | load_project_definition | def load_project_definition(path: str) -> dict:
"""
Load the cauldron.json project definition file for the given path. The
path can be either a source path to the cauldron.json file or the source
directory where a cauldron.json file resides.
:param path:
The source path or directory where t... | python | def load_project_definition(path: str) -> dict:
"""
Load the cauldron.json project definition file for the given path. The
path can be either a source path to the cauldron.json file or the source
directory where a cauldron.json file resides.
:param path:
The source path or directory where t... | [
"def",
"load_project_definition",
"(",
"path",
":",
"str",
")",
"->",
"dict",
":",
"source_path",
"=",
"get_project_source_path",
"(",
"path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"source_path",
")",
":",
"raise",
"FileNotFoundError",
"("... | Load the cauldron.json project definition file for the given path. The
path can be either a source path to the cauldron.json file or the source
directory where a cauldron.json file resides.
:param path:
The source path or directory where the definition file will be loaded | [
"Load",
"the",
"cauldron",
".",
"json",
"project",
"definition",
"file",
"for",
"the",
"given",
"path",
".",
"The",
"path",
"can",
"be",
"either",
"a",
"source",
"path",
"to",
"the",
"cauldron",
".",
"json",
"file",
"or",
"the",
"source",
"directory",
"w... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/definitions.py#L25-L46 |
sernst/cauldron | cauldron/environ/systems.py | simplify_path | def simplify_path(path: str, path_prefixes: list = None) -> str:
"""
Simplifies package paths by replacing path prefixes with values specified
in the replacements list
:param path:
:param path_prefixes:
:return:
"""
test_path = '{}'.format(path if path else '')
replacements = (path... | python | def simplify_path(path: str, path_prefixes: list = None) -> str:
"""
Simplifies package paths by replacing path prefixes with values specified
in the replacements list
:param path:
:param path_prefixes:
:return:
"""
test_path = '{}'.format(path if path else '')
replacements = (path... | [
"def",
"simplify_path",
"(",
"path",
":",
"str",
",",
"path_prefixes",
":",
"list",
"=",
"None",
")",
"->",
"str",
":",
"test_path",
"=",
"'{}'",
".",
"format",
"(",
"path",
"if",
"path",
"else",
"''",
")",
"replacements",
"=",
"(",
"path_prefixes",
"i... | Simplifies package paths by replacing path prefixes with values specified
in the replacements list
:param path:
:param path_prefixes:
:return: | [
"Simplifies",
"package",
"paths",
"by",
"replacing",
"path",
"prefixes",
"with",
"values",
"specified",
"in",
"the",
"replacements",
"list"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/systems.py#L20-L38 |
sernst/cauldron | cauldron/environ/systems.py | module_to_package_data | def module_to_package_data(
name: str,
entry,
path_prefixes: list = None
) -> typing.Union[dict, None]:
"""
Converts a module entry into a package data dictionary with information
about the module. including version and location on disk
:param name:
:param entry:
:param ... | python | def module_to_package_data(
name: str,
entry,
path_prefixes: list = None
) -> typing.Union[dict, None]:
"""
Converts a module entry into a package data dictionary with information
about the module. including version and location on disk
:param name:
:param entry:
:param ... | [
"def",
"module_to_package_data",
"(",
"name",
":",
"str",
",",
"entry",
",",
"path_prefixes",
":",
"list",
"=",
"None",
")",
"->",
"typing",
".",
"Union",
"[",
"dict",
",",
"None",
"]",
":",
"if",
"name",
".",
"find",
"(",
"'.'",
")",
">",
"-",
"1"... | Converts a module entry into a package data dictionary with information
about the module. including version and location on disk
:param name:
:param entry:
:param path_prefixes:
:return: | [
"Converts",
"a",
"module",
"entry",
"into",
"a",
"package",
"data",
"dictionary",
"with",
"information",
"about",
"the",
"module",
".",
"including",
"version",
"and",
"location",
"on",
"disk"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/systems.py#L41-L73 |
sernst/cauldron | cauldron/environ/systems.py | get_system_data | def get_system_data() -> typing.Union[None, dict]:
"""
Returns information about the system in which Cauldron is running.
If the information cannot be found, None is returned instead.
:return:
Dictionary containing information about the Cauldron system, whic
includes:
* name
... | python | def get_system_data() -> typing.Union[None, dict]:
"""
Returns information about the system in which Cauldron is running.
If the information cannot be found, None is returned instead.
:return:
Dictionary containing information about the Cauldron system, whic
includes:
* name
... | [
"def",
"get_system_data",
"(",
")",
"->",
"typing",
".",
"Union",
"[",
"None",
",",
"dict",
"]",
":",
"site_packages",
"=",
"get_site_packages",
"(",
")",
"path_prefixes",
"=",
"[",
"(",
"'[SP]'",
",",
"p",
")",
"for",
"p",
"in",
"site_packages",
"]",
... | Returns information about the system in which Cauldron is running.
If the information cannot be found, None is returned instead.
:return:
Dictionary containing information about the Cauldron system, whic
includes:
* name
* location
* version | [
"Returns",
"information",
"about",
"the",
"system",
"in",
"which",
"Cauldron",
"is",
"running",
".",
"If",
"the",
"information",
"cannot",
"be",
"found",
"None",
"is",
"returned",
"instead",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/systems.py#L76-L108 |
sernst/cauldron | cauldron/environ/systems.py | remove | def remove(path: str, max_retries: int = 3) -> bool:
"""
Removes the specified path from the local filesystem if it exists.
Directories will be removed along with all files and folders within
them as well as files.
:param path:
The location of the file or folder to remove.
:param max_re... | python | def remove(path: str, max_retries: int = 3) -> bool:
"""
Removes the specified path from the local filesystem if it exists.
Directories will be removed along with all files and folders within
them as well as files.
:param path:
The location of the file or folder to remove.
:param max_re... | [
"def",
"remove",
"(",
"path",
":",
"str",
",",
"max_retries",
":",
"int",
"=",
"3",
")",
"->",
"bool",
":",
"if",
"not",
"path",
":",
"return",
"False",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"True",
"remo... | Removes the specified path from the local filesystem if it exists.
Directories will be removed along with all files and folders within
them as well as files.
:param path:
The location of the file or folder to remove.
:param max_retries:
The number of times to retry before giving up.
... | [
"Removes",
"the",
"specified",
"path",
"from",
"the",
"local",
"filesystem",
"if",
"it",
"exists",
".",
"Directories",
"will",
"be",
"removed",
"along",
"with",
"all",
"files",
"and",
"folders",
"within",
"them",
"as",
"well",
"as",
"files",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/systems.py#L123-L153 |
sernst/cauldron | cauldron/environ/systems.py | end | def end(code: int):
"""
Ends the application with the specified error code, adding whitespace to
the end of the console log output for clarity
:param code:
The integer status code to apply on exit. If the value is non-zero,
indicating an error, a message will be printed to the console t... | python | def end(code: int):
"""
Ends the application with the specified error code, adding whitespace to
the end of the console log output for clarity
:param code:
The integer status code to apply on exit. If the value is non-zero,
indicating an error, a message will be printed to the console t... | [
"def",
"end",
"(",
"code",
":",
"int",
")",
":",
"print",
"(",
"'\\n'",
")",
"if",
"code",
"!=",
"0",
":",
"log",
"(",
"'Failed with status code: {}'",
".",
"format",
"(",
"code",
")",
",",
"whitespace",
"=",
"1",
")",
"sys",
".",
"exit",
"(",
"cod... | Ends the application with the specified error code, adding whitespace to
the end of the console log output for clarity
:param code:
The integer status code to apply on exit. If the value is non-zero,
indicating an error, a message will be printed to the console to
inform the user that t... | [
"Ends",
"the",
"application",
"with",
"the",
"specified",
"error",
"code",
"adding",
"whitespace",
"to",
"the",
"end",
"of",
"the",
"console",
"log",
"output",
"for",
"clarity"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/systems.py#L156-L170 |
sernst/cauldron | cauldron/session/definitions.py | FileDefinition.folder | def folder(self) -> typing.Union[str, None]:
"""
The folder, relative to the project source_directory, where the file
resides
:return:
"""
if 'folder' in self.data:
return self.data.get('folder')
elif self.project_folder:
if callable(self... | python | def folder(self) -> typing.Union[str, None]:
"""
The folder, relative to the project source_directory, where the file
resides
:return:
"""
if 'folder' in self.data:
return self.data.get('folder')
elif self.project_folder:
if callable(self... | [
"def",
"folder",
"(",
"self",
")",
"->",
"typing",
".",
"Union",
"[",
"str",
",",
"None",
"]",
":",
"if",
"'folder'",
"in",
"self",
".",
"data",
":",
"return",
"self",
".",
"data",
".",
"get",
"(",
"'folder'",
")",
"elif",
"self",
".",
"project_fol... | The folder, relative to the project source_directory, where the file
resides
:return: | [
"The",
"folder",
"relative",
"to",
"the",
"project",
"source_directory",
"where",
"the",
"file",
"resides"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/definitions.py#L91-L106 |
sernst/cauldron | cauldron/cli/commands/open/opener.py | project_exists | def project_exists(response: 'environ.Response', path: str) -> bool:
"""
Determines whether or not a project exists at the specified path
:param response:
:param path:
:return:
"""
if os.path.exists(path):
return True
response.fail(
code='PROJECT_NOT_FOUND',
me... | python | def project_exists(response: 'environ.Response', path: str) -> bool:
"""
Determines whether or not a project exists at the specified path
:param response:
:param path:
:return:
"""
if os.path.exists(path):
return True
response.fail(
code='PROJECT_NOT_FOUND',
me... | [
"def",
"project_exists",
"(",
"response",
":",
"'environ.Response'",
",",
"path",
":",
"str",
")",
"->",
"bool",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"True",
"response",
".",
"fail",
"(",
"code",
"=",
"'PROJECT_... | Determines whether or not a project exists at the specified path
:param response:
:param path:
:return: | [
"Determines",
"whether",
"or",
"not",
"a",
"project",
"exists",
"at",
"the",
"specified",
"path"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commands/open/opener.py#L10-L33 |
sernst/cauldron | cauldron/cli/commands/open/opener.py | update_recent_paths | def update_recent_paths(response, path):
"""
:param response:
:param path:
:return:
"""
try:
recent_paths = environ.configs.fetch('recent_paths', [])
if path in recent_paths:
recent_paths.remove(path)
recent_paths.insert(0, path)
environ.configs.put... | python | def update_recent_paths(response, path):
"""
:param response:
:param path:
:return:
"""
try:
recent_paths = environ.configs.fetch('recent_paths', [])
if path in recent_paths:
recent_paths.remove(path)
recent_paths.insert(0, path)
environ.configs.put... | [
"def",
"update_recent_paths",
"(",
"response",
",",
"path",
")",
":",
"try",
":",
"recent_paths",
"=",
"environ",
".",
"configs",
".",
"fetch",
"(",
"'recent_paths'",
",",
"[",
"]",
")",
"if",
"path",
"in",
"recent_paths",
":",
"recent_paths",
".",
"remove... | :param response:
:param path:
:return: | [
":",
"param",
"response",
":",
":",
"param",
"path",
":",
":",
"return",
":"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commands/open/opener.py#L55-L78 |
sernst/cauldron | cauldron/cli/parse.py | split_line | def split_line(line: str) -> typing.Tuple[str, str]:
"""
Separates the raw line string into two strings: (1) the command and (2) the
argument(s) string
:param line:
:return:
"""
index = line.find(' ')
if index == -1:
return line.lower(), ''
return line[:index].lower(), lin... | python | def split_line(line: str) -> typing.Tuple[str, str]:
"""
Separates the raw line string into two strings: (1) the command and (2) the
argument(s) string
:param line:
:return:
"""
index = line.find(' ')
if index == -1:
return line.lower(), ''
return line[:index].lower(), lin... | [
"def",
"split_line",
"(",
"line",
":",
"str",
")",
"->",
"typing",
".",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"index",
"=",
"line",
".",
"find",
"(",
"' '",
")",
"if",
"index",
"==",
"-",
"1",
":",
"return",
"line",
".",
"lower",
"(",
")",... | Separates the raw line string into two strings: (1) the command and (2) the
argument(s) string
:param line:
:return: | [
"Separates",
"the",
"raw",
"line",
"string",
"into",
"two",
"strings",
":",
"(",
"1",
")",
"the",
"command",
"and",
"(",
"2",
")",
"the",
"argument",
"(",
"s",
")",
"string"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/parse.py#L19-L32 |
sernst/cauldron | cauldron/session/exposed.py | render_stop_display | def render_stop_display(step: 'projects.ProjectStep', message: str):
"""Renders a stop action to the Cauldron display."""
stack = render_stack.get_formatted_stack_frame(
project=step.project,
error_stack=False
)
try:
names = [frame['filename'] for frame in stack]
index =... | python | def render_stop_display(step: 'projects.ProjectStep', message: str):
"""Renders a stop action to the Cauldron display."""
stack = render_stack.get_formatted_stack_frame(
project=step.project,
error_stack=False
)
try:
names = [frame['filename'] for frame in stack]
index =... | [
"def",
"render_stop_display",
"(",
"step",
":",
"'projects.ProjectStep'",
",",
"message",
":",
"str",
")",
":",
"stack",
"=",
"render_stack",
".",
"get_formatted_stack_frame",
"(",
"project",
"=",
"step",
".",
"project",
",",
"error_stack",
"=",
"False",
")",
... | Renders a stop action to the Cauldron display. | [
"Renders",
"a",
"stop",
"action",
"to",
"the",
"Cauldron",
"display",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L283-L308 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.id | def id(self) -> typing.Union[str, None]:
"""Identifier for the project."""
return self._project.id if self._project else None | python | def id(self) -> typing.Union[str, None]:
"""Identifier for the project."""
return self._project.id if self._project else None | [
"def",
"id",
"(",
"self",
")",
"->",
"typing",
".",
"Union",
"[",
"str",
",",
"None",
"]",
":",
"return",
"self",
".",
"_project",
".",
"id",
"if",
"self",
".",
"_project",
"else",
"None"
] | Identifier for the project. | [
"Identifier",
"for",
"the",
"project",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L36-L38 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.display | def display(self) -> typing.Union[None, report.Report]:
"""The display report for the current project."""
return (
self._project.current_step.report
if self._project and self._project.current_step else
None
) | python | def display(self) -> typing.Union[None, report.Report]:
"""The display report for the current project."""
return (
self._project.current_step.report
if self._project and self._project.current_step else
None
) | [
"def",
"display",
"(",
"self",
")",
"->",
"typing",
".",
"Union",
"[",
"None",
",",
"report",
".",
"Report",
"]",
":",
"return",
"(",
"self",
".",
"_project",
".",
"current_step",
".",
"report",
"if",
"self",
".",
"_project",
"and",
"self",
".",
"_pr... | The display report for the current project. | [
"The",
"display",
"report",
"for",
"the",
"current",
"project",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L41-L47 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.shared | def shared(self) -> typing.Union[None, SharedCache]:
"""The shared display object associated with this project."""
return self._project.shared if self._project else None | python | def shared(self) -> typing.Union[None, SharedCache]:
"""The shared display object associated with this project."""
return self._project.shared if self._project else None | [
"def",
"shared",
"(",
"self",
")",
"->",
"typing",
".",
"Union",
"[",
"None",
",",
"SharedCache",
"]",
":",
"return",
"self",
".",
"_project",
".",
"shared",
"if",
"self",
".",
"_project",
"else",
"None"
] | The shared display object associated with this project. | [
"The",
"shared",
"display",
"object",
"associated",
"with",
"this",
"project",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L50-L52 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.settings | def settings(self) -> typing.Union[None, SharedCache]:
"""The settings associated with this project."""
return self._project.settings if self._project else None | python | def settings(self) -> typing.Union[None, SharedCache]:
"""The settings associated with this project."""
return self._project.settings if self._project else None | [
"def",
"settings",
"(",
"self",
")",
"->",
"typing",
".",
"Union",
"[",
"None",
",",
"SharedCache",
"]",
":",
"return",
"self",
".",
"_project",
".",
"settings",
"if",
"self",
".",
"_project",
"else",
"None"
] | The settings associated with this project. | [
"The",
"settings",
"associated",
"with",
"this",
"project",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L55-L57 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.title | def title(self) -> typing.Union[None, str]:
"""The title of this project."""
return self._project.title if self._project else None | python | def title(self) -> typing.Union[None, str]:
"""The title of this project."""
return self._project.title if self._project else None | [
"def",
"title",
"(",
"self",
")",
"->",
"typing",
".",
"Union",
"[",
"None",
",",
"str",
"]",
":",
"return",
"self",
".",
"_project",
".",
"title",
"if",
"self",
".",
"_project",
"else",
"None"
] | The title of this project. | [
"The",
"title",
"of",
"this",
"project",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L60-L62 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.title | def title(self, value: typing.Union[None, str]):
"""
Modifies the title of the project, which is initially loaded from the
`cauldron.json` file.
"""
if not self._project:
raise RuntimeError('Failed to assign title to an unloaded project')
self._project.title =... | python | def title(self, value: typing.Union[None, str]):
"""
Modifies the title of the project, which is initially loaded from the
`cauldron.json` file.
"""
if not self._project:
raise RuntimeError('Failed to assign title to an unloaded project')
self._project.title =... | [
"def",
"title",
"(",
"self",
",",
"value",
":",
"typing",
".",
"Union",
"[",
"None",
",",
"str",
"]",
")",
":",
"if",
"not",
"self",
".",
"_project",
":",
"raise",
"RuntimeError",
"(",
"'Failed to assign title to an unloaded project'",
")",
"self",
".",
"_... | Modifies the title of the project, which is initially loaded from the
`cauldron.json` file. | [
"Modifies",
"the",
"title",
"of",
"the",
"project",
"which",
"is",
"initially",
"loaded",
"from",
"the",
"cauldron",
".",
"json",
"file",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L65-L72 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.load | def load(self, project: typing.Union[projects.Project, None]):
"""Connects this object to the specified source project."""
self._project = project | python | def load(self, project: typing.Union[projects.Project, None]):
"""Connects this object to the specified source project."""
self._project = project | [
"def",
"load",
"(",
"self",
",",
"project",
":",
"typing",
".",
"Union",
"[",
"projects",
".",
"Project",
",",
"None",
"]",
")",
":",
"self",
".",
"_project",
"=",
"project"
] | Connects this object to the specified source project. | [
"Connects",
"this",
"object",
"to",
"the",
"specified",
"source",
"project",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L74-L76 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.path | def path(self, *args: typing.List[str]) -> typing.Union[None, str]:
"""
Creates an absolute path in the project source directory from the
relative path components.
:param args:
Relative components for creating a path within the project source
directory
:r... | python | def path(self, *args: typing.List[str]) -> typing.Union[None, str]:
"""
Creates an absolute path in the project source directory from the
relative path components.
:param args:
Relative components for creating a path within the project source
directory
:r... | [
"def",
"path",
"(",
"self",
",",
"*",
"args",
":",
"typing",
".",
"List",
"[",
"str",
"]",
")",
"->",
"typing",
".",
"Union",
"[",
"None",
",",
"str",
"]",
":",
"if",
"not",
"self",
".",
"_project",
":",
"return",
"None",
"return",
"environ",
"."... | Creates an absolute path in the project source directory from the
relative path components.
:param args:
Relative components for creating a path within the project source
directory
:return:
An absolute path to the specified file or directory within the
... | [
"Creates",
"an",
"absolute",
"path",
"in",
"the",
"project",
"source",
"directory",
"from",
"the",
"relative",
"path",
"components",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L82-L100 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.stop | def stop(self, message: str = None, silent: bool = False):
"""
Stops the execution of the project at the current step immediately
without raising an error. Use this to abort running the project in
situations where some critical branching action should prevent the
project from con... | python | def stop(self, message: str = None, silent: bool = False):
"""
Stops the execution of the project at the current step immediately
without raising an error. Use this to abort running the project in
situations where some critical branching action should prevent the
project from con... | [
"def",
"stop",
"(",
"self",
",",
"message",
":",
"str",
"=",
"None",
",",
"silent",
":",
"bool",
"=",
"False",
")",
":",
"me",
"=",
"self",
".",
"get_internal_project",
"(",
")",
"if",
"not",
"me",
"or",
"not",
"me",
".",
"current_step",
":",
"retu... | Stops the execution of the project at the current step immediately
without raising an error. Use this to abort running the project in
situations where some critical branching action should prevent the
project from continuing to run.
:param message:
A custom display message t... | [
"Stops",
"the",
"execution",
"of",
"the",
"project",
"at",
"the",
"current",
"step",
"immediately",
"without",
"raising",
"an",
"error",
".",
"Use",
"this",
"to",
"abort",
"running",
"the",
"project",
"in",
"situations",
"where",
"some",
"critical",
"branching... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L102-L123 |
sernst/cauldron | cauldron/session/exposed.py | ExposedProject.get_internal_project | def get_internal_project(
self,
timeout: float = 1
) -> typing.Union['projects.Project', None]:
"""
Attempts to return the internally loaded project. This function
prevents race condition issues where projects are loaded via threads
because the internal loop w... | python | def get_internal_project(
self,
timeout: float = 1
) -> typing.Union['projects.Project', None]:
"""
Attempts to return the internally loaded project. This function
prevents race condition issues where projects are loaded via threads
because the internal loop w... | [
"def",
"get_internal_project",
"(",
"self",
",",
"timeout",
":",
"float",
"=",
"1",
")",
"->",
"typing",
".",
"Union",
"[",
"'projects.Project'",
",",
"None",
"]",
":",
"count",
"=",
"int",
"(",
"timeout",
"/",
"0.1",
")",
"for",
"_",
"in",
"range",
... | Attempts to return the internally loaded project. This function
prevents race condition issues where projects are loaded via threads
because the internal loop will try to continuously load the internal
project until it is available or until the timeout is reached.
:param timeout:
... | [
"Attempts",
"to",
"return",
"the",
"internally",
"loaded",
"project",
".",
"This",
"function",
"prevents",
"race",
"condition",
"issues",
"where",
"projects",
"are",
"loaded",
"via",
"threads",
"because",
"the",
"internal",
"loop",
"will",
"try",
"to",
"continuo... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L125-L146 |
sernst/cauldron | cauldron/session/exposed.py | ExposedStep._step | def _step(self) -> typing.Union[None, 'projects.ProjectStep']:
"""
Internal access to the source step. Should not be used outside
of Cauldron development.
:return:
The ProjectStep instance that this ExposedStep represents
"""
import cauldron
try:
... | python | def _step(self) -> typing.Union[None, 'projects.ProjectStep']:
"""
Internal access to the source step. Should not be used outside
of Cauldron development.
:return:
The ProjectStep instance that this ExposedStep represents
"""
import cauldron
try:
... | [
"def",
"_step",
"(",
"self",
")",
"->",
"typing",
".",
"Union",
"[",
"None",
",",
"'projects.ProjectStep'",
"]",
":",
"import",
"cauldron",
"try",
":",
"return",
"cauldron",
".",
"project",
".",
"get_internal_project",
"(",
")",
".",
"current_step",
"except"... | Internal access to the source step. Should not be used outside
of Cauldron development.
:return:
The ProjectStep instance that this ExposedStep represents | [
"Internal",
"access",
"to",
"the",
"source",
"step",
".",
"Should",
"not",
"be",
"used",
"outside",
"of",
"Cauldron",
"development",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L156-L168 |
sernst/cauldron | cauldron/session/exposed.py | ExposedStep.stop | def stop(
self,
message: str = None,
silent: bool = False,
halt: bool = False
):
"""
Stops the execution of the current step immediately without raising
an error. Use this to abort the step running process if you want
to return early.
... | python | def stop(
self,
message: str = None,
silent: bool = False,
halt: bool = False
):
"""
Stops the execution of the current step immediately without raising
an error. Use this to abort the step running process if you want
to return early.
... | [
"def",
"stop",
"(",
"self",
",",
"message",
":",
"str",
"=",
"None",
",",
"silent",
":",
"bool",
"=",
"False",
",",
"halt",
":",
"bool",
"=",
"False",
")",
":",
"step",
"=",
"self",
".",
"_step",
"if",
"not",
"step",
":",
"return",
"if",
"not",
... | Stops the execution of the current step immediately without raising
an error. Use this to abort the step running process if you want
to return early.
:param message:
A custom display message to include in the display for the stop
action. This message is ignored if silent... | [
"Stops",
"the",
"execution",
"of",
"the",
"current",
"step",
"immediately",
"without",
"raising",
"an",
"error",
".",
"Use",
"this",
"to",
"abort",
"the",
"step",
"running",
"process",
"if",
"you",
"want",
"to",
"return",
"early",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L212-L244 |
sernst/cauldron | cauldron/session/exposed.py | ExposedStep.write_to_console | def write_to_console(self, message: str):
"""
Writes the specified message to the console stdout without including
it in the notebook display.
"""
if not self._step:
raise ValueError(
'Cannot write to the console stdout on an uninitialized step'
... | python | def write_to_console(self, message: str):
"""
Writes the specified message to the console stdout without including
it in the notebook display.
"""
if not self._step:
raise ValueError(
'Cannot write to the console stdout on an uninitialized step'
... | [
"def",
"write_to_console",
"(",
"self",
",",
"message",
":",
"str",
")",
":",
"if",
"not",
"self",
".",
"_step",
":",
"raise",
"ValueError",
"(",
"'Cannot write to the console stdout on an uninitialized step'",
")",
"interceptor",
"=",
"self",
".",
"_step",
".",
... | Writes the specified message to the console stdout without including
it in the notebook display. | [
"Writes",
"the",
"specified",
"message",
"to",
"the",
"console",
"stdout",
"without",
"including",
"it",
"in",
"the",
"notebook",
"display",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L255-L265 |
sernst/cauldron | cauldron/session/exposed.py | ExposedStep.render_to_console | def render_to_console(self, message: str, **kwargs):
"""
Renders the specified message to the console using Jinja2 template
rendering with the kwargs as render variables. The message will also
be dedented prior to rendering in the same fashion as other Cauldron
template rendering... | python | def render_to_console(self, message: str, **kwargs):
"""
Renders the specified message to the console using Jinja2 template
rendering with the kwargs as render variables. The message will also
be dedented prior to rendering in the same fashion as other Cauldron
template rendering... | [
"def",
"render_to_console",
"(",
"self",
",",
"message",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
":",
"rendered",
"=",
"templating",
".",
"render",
"(",
"message",
",",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"write_to_console",
"(",
"rendered"... | Renders the specified message to the console using Jinja2 template
rendering with the kwargs as render variables. The message will also
be dedented prior to rendering in the same fashion as other Cauldron
template rendering actions.
:param message:
Template string to be rend... | [
"Renders",
"the",
"specified",
"message",
"to",
"the",
"console",
"using",
"Jinja2",
"template",
"rendering",
"with",
"the",
"kwargs",
"as",
"render",
"variables",
".",
"The",
"message",
"will",
"also",
"be",
"dedented",
"prior",
"to",
"rendering",
"in",
"the"... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/exposed.py#L267-L280 |
WimpyAnalytics/django-andablog | demo/common/migrations/0002_auto_20150507_1708.py | get_operations | def get_operations():
"""
This will break things if you upgrade Django to 1.8 having already applied this migration in 1.7.
Since this is for a demo site it doesn't really matter (simply blow away the DB if you want to go to 1.8)
Our demo site is a unusual in that we want to run it's tests (for integra... | python | def get_operations():
"""
This will break things if you upgrade Django to 1.8 having already applied this migration in 1.7.
Since this is for a demo site it doesn't really matter (simply blow away the DB if you want to go to 1.8)
Our demo site is a unusual in that we want to run it's tests (for integra... | [
"def",
"get_operations",
"(",
")",
":",
"compatible",
"=",
"(",
"1",
",",
"8",
")",
"<=",
"DJANGO_VERSION",
"<",
"(",
"1",
",",
"10",
")",
"if",
"not",
"compatible",
":",
"return",
"[",
"]",
"return",
"[",
"migrations",
".",
"AlterField",
"(",
"model... | This will break things if you upgrade Django to 1.8 having already applied this migration in 1.7.
Since this is for a demo site it doesn't really matter (simply blow away the DB if you want to go to 1.8)
Our demo site is a unusual in that we want to run it's tests (for integration testing) in multiple Django v... | [
"This",
"will",
"break",
"things",
"if",
"you",
"upgrade",
"Django",
"to",
"1",
".",
"8",
"having",
"already",
"applied",
"this",
"migration",
"in",
"1",
".",
"7",
".",
"Since",
"this",
"is",
"for",
"a",
"demo",
"site",
"it",
"doesn",
"t",
"really",
... | train | https://github.com/WimpyAnalytics/django-andablog/blob/9175144140d220e4ce8212d0da6abc8c9ba9816a/demo/common/migrations/0002_auto_20150507_1708.py#L8-L31 |
sernst/cauldron | cauldron/session/writing/components/bokeh_component.py | create | def create(project: 'projects.Project') -> COMPONENT:
"""
:return:
"""
try:
from bokeh.resources import Resources as BokehResources
bokeh_resources = BokehResources(mode='absolute')
except Exception:
bokeh_resources = None
if bokeh_resources is None:
environ.log... | python | def create(project: 'projects.Project') -> COMPONENT:
"""
:return:
"""
try:
from bokeh.resources import Resources as BokehResources
bokeh_resources = BokehResources(mode='absolute')
except Exception:
bokeh_resources = None
if bokeh_resources is None:
environ.log... | [
"def",
"create",
"(",
"project",
":",
"'projects.Project'",
")",
"->",
"COMPONENT",
":",
"try",
":",
"from",
"bokeh",
".",
"resources",
"import",
"Resources",
"as",
"BokehResources",
"bokeh_resources",
"=",
"BokehResources",
"(",
"mode",
"=",
"'absolute'",
")",
... | :return: | [
":",
"return",
":"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/components/bokeh_component.py#L22-L50 |
sernst/cauldron | cauldron/session/report.py | Report.last_update_time | def last_update_time(self) -> float:
"""The last time at which the report was modified."""
stdout = self.stdout_interceptor
stderr = self.stderr_interceptor
return max([
self._last_update_time,
stdout.last_write_time if stdout else 0,
stderr.last_writ... | python | def last_update_time(self) -> float:
"""The last time at which the report was modified."""
stdout = self.stdout_interceptor
stderr = self.stderr_interceptor
return max([
self._last_update_time,
stdout.last_write_time if stdout else 0,
stderr.last_writ... | [
"def",
"last_update_time",
"(",
"self",
")",
"->",
"float",
":",
"stdout",
"=",
"self",
".",
"stdout_interceptor",
"stderr",
"=",
"self",
".",
"stderr_interceptor",
"return",
"max",
"(",
"[",
"self",
".",
"_last_update_time",
",",
"stdout",
".",
"last_write_ti... | The last time at which the report was modified. | [
"The",
"last",
"time",
"at",
"which",
"the",
"report",
"was",
"modified",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/report.py#L38-L47 |
sernst/cauldron | cauldron/session/report.py | Report.results_cache_path | def results_cache_path(self) -> str:
"""
Location where step report is cached between sessions to
prevent loss of display data between runs.
"""
if not self.project:
return ''
return os.path.join(
self.project.results_path,
'.cache',
... | python | def results_cache_path(self) -> str:
"""
Location where step report is cached between sessions to
prevent loss of display data between runs.
"""
if not self.project:
return ''
return os.path.join(
self.project.results_path,
'.cache',
... | [
"def",
"results_cache_path",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"project",
":",
"return",
"''",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"project",
".",
"results_path",
",",
"'.cache'",
",",
"'steps'",
",",... | Location where step report is cached between sessions to
prevent loss of display data between runs. | [
"Location",
"where",
"step",
"report",
"is",
"cached",
"between",
"sessions",
"to",
"prevent",
"loss",
"of",
"display",
"data",
"between",
"runs",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/report.py#L58-L70 |
sernst/cauldron | cauldron/session/report.py | Report.clear | def clear(self) -> 'Report':
"""
Clear all user-data stored in this instance and reset it to its
originally loaded state
:return:
The instance that was called for method chaining
"""
self.body = []
self.data = SharedCache()
self.files = Shared... | python | def clear(self) -> 'Report':
"""
Clear all user-data stored in this instance and reset it to its
originally loaded state
:return:
The instance that was called for method chaining
"""
self.body = []
self.data = SharedCache()
self.files = Shared... | [
"def",
"clear",
"(",
"self",
")",
"->",
"'Report'",
":",
"self",
".",
"body",
"=",
"[",
"]",
"self",
".",
"data",
"=",
"SharedCache",
"(",
")",
"self",
".",
"files",
"=",
"SharedCache",
"(",
")",
"self",
".",
"_last_update_time",
"=",
"time",
".",
... | Clear all user-data stored in this instance and reset it to its
originally loaded state
:return:
The instance that was called for method chaining | [
"Clear",
"all",
"user",
"-",
"data",
"stored",
"in",
"this",
"instance",
"and",
"reset",
"it",
"to",
"its",
"originally",
"loaded",
"state"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/report.py#L82-L94 |
sernst/cauldron | cauldron/session/report.py | Report.append_body | def append_body(self, dom: str):
"""
Appends the specified HTML-formatted DOM string to the
currently stored report body for the step.
"""
self.flush_stdout()
self.body.append(dom)
self._last_update_time = time.time() | python | def append_body(self, dom: str):
"""
Appends the specified HTML-formatted DOM string to the
currently stored report body for the step.
"""
self.flush_stdout()
self.body.append(dom)
self._last_update_time = time.time() | [
"def",
"append_body",
"(",
"self",
",",
"dom",
":",
"str",
")",
":",
"self",
".",
"flush_stdout",
"(",
")",
"self",
".",
"body",
".",
"append",
"(",
"dom",
")",
"self",
".",
"_last_update_time",
"=",
"time",
".",
"time",
"(",
")"
] | Appends the specified HTML-formatted DOM string to the
currently stored report body for the step. | [
"Appends",
"the",
"specified",
"HTML",
"-",
"formatted",
"DOM",
"string",
"to",
"the",
"currently",
"stored",
"report",
"body",
"for",
"the",
"step",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/report.py#L96-L103 |
sernst/cauldron | cauldron/session/report.py | Report.read_stdout | def read_stdout(self):
"""
Reads the current state of the print buffer (if it exists) and returns
a body-ready dom object of those contents without adding them to the
actual report body. This is useful for creating intermediate body
values for display while the method is still ex... | python | def read_stdout(self):
"""
Reads the current state of the print buffer (if it exists) and returns
a body-ready dom object of those contents without adding them to the
actual report body. This is useful for creating intermediate body
values for display while the method is still ex... | [
"def",
"read_stdout",
"(",
"self",
")",
":",
"try",
":",
"contents",
"=",
"self",
".",
"stdout_interceptor",
".",
"read_all",
"(",
")",
"except",
"Exception",
"as",
"err",
":",
"contents",
"=",
"''",
"return",
"render_texts",
".",
"preformatted_text",
"(",
... | Reads the current state of the print buffer (if it exists) and returns
a body-ready dom object of those contents without adding them to the
actual report body. This is useful for creating intermediate body
values for display while the method is still executing.
:return:
A do... | [
"Reads",
"the",
"current",
"state",
"of",
"the",
"print",
"buffer",
"(",
"if",
"it",
"exists",
")",
"and",
"returns",
"a",
"body",
"-",
"ready",
"dom",
"object",
"of",
"those",
"contents",
"without",
"adding",
"them",
"to",
"the",
"actual",
"report",
"bo... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/report.py#L105-L120 |
sernst/cauldron | cauldron/session/report.py | Report.flush_stdout | def flush_stdout(self):
"""
Empties the standard out redirect buffer and renders the
contents to the body as a preformatted text box.
"""
try:
contents = self.stdout_interceptor.flush_all()
except Exception:
return
if len(contents) > 0:
... | python | def flush_stdout(self):
"""
Empties the standard out redirect buffer and renders the
contents to the body as a preformatted text box.
"""
try:
contents = self.stdout_interceptor.flush_all()
except Exception:
return
if len(contents) > 0:
... | [
"def",
"flush_stdout",
"(",
"self",
")",
":",
"try",
":",
"contents",
"=",
"self",
".",
"stdout_interceptor",
".",
"flush_all",
"(",
")",
"except",
"Exception",
":",
"return",
"if",
"len",
"(",
"contents",
")",
">",
"0",
":",
"self",
".",
"body",
".",
... | Empties the standard out redirect buffer and renders the
contents to the body as a preformatted text box. | [
"Empties",
"the",
"standard",
"out",
"redirect",
"buffer",
"and",
"renders",
"the",
"contents",
"to",
"the",
"body",
"as",
"a",
"preformatted",
"text",
"box",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/report.py#L122-L136 |
seomoz/qless-py | qless/util.py | import_class | def import_class(klass):
'''Import the named class and return that class'''
mod = __import__(klass.rpartition('.')[0])
for segment in klass.split('.')[1:-1]:
mod = getattr(mod, segment)
return getattr(mod, klass.rpartition('.')[2]) | python | def import_class(klass):
'''Import the named class and return that class'''
mod = __import__(klass.rpartition('.')[0])
for segment in klass.split('.')[1:-1]:
mod = getattr(mod, segment)
return getattr(mod, klass.rpartition('.')[2]) | [
"def",
"import_class",
"(",
"klass",
")",
":",
"mod",
"=",
"__import__",
"(",
"klass",
".",
"rpartition",
"(",
"'.'",
")",
"[",
"0",
"]",
")",
"for",
"segment",
"in",
"klass",
".",
"split",
"(",
"'.'",
")",
"[",
"1",
":",
"-",
"1",
"]",
":",
"m... | Import the named class and return that class | [
"Import",
"the",
"named",
"class",
"and",
"return",
"that",
"class"
] | train | https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/util.py#L4-L9 |
sernst/cauldron | cauldron/session/writing/components/project_component.py | create | def create(
project: 'projects.Project',
include_path: str
) -> COMPONENT:
"""
Creates a COMPONENT instance for the project component specified by the
include path
:param project:
The project in which the component resides
:param include_path:
The relative path withi... | python | def create(
project: 'projects.Project',
include_path: str
) -> COMPONENT:
"""
Creates a COMPONENT instance for the project component specified by the
include path
:param project:
The project in which the component resides
:param include_path:
The relative path withi... | [
"def",
"create",
"(",
"project",
":",
"'projects.Project'",
",",
"include_path",
":",
"str",
")",
"->",
"COMPONENT",
":",
"source_path",
"=",
"environ",
".",
"paths",
".",
"clean",
"(",
"os",
".",
"path",
".",
"join",
"(",
"project",
".",
"source_directory... | Creates a COMPONENT instance for the project component specified by the
include path
:param project:
The project in which the component resides
:param include_path:
The relative path within the project where the component resides
:return:
The created COMPONENT instance | [
"Creates",
"a",
"COMPONENT",
"instance",
"for",
"the",
"project",
"component",
"specified",
"by",
"the",
"include",
"path"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/components/project_component.py#L14-L53 |
sernst/cauldron | cauldron/session/writing/components/project_component.py | create_many | def create_many(
project: 'projects.Project',
include_paths: typing.List[str]
) -> COMPONENT:
"""
Creates a single COMPONENT instance for all of the specified project
include paths
:param project:
Project where the components reside
:param include_paths:
A list of re... | python | def create_many(
project: 'projects.Project',
include_paths: typing.List[str]
) -> COMPONENT:
"""
Creates a single COMPONENT instance for all of the specified project
include paths
:param project:
Project where the components reside
:param include_paths:
A list of re... | [
"def",
"create_many",
"(",
"project",
":",
"'projects.Project'",
",",
"include_paths",
":",
"typing",
".",
"List",
"[",
"str",
"]",
")",
"->",
"COMPONENT",
":",
"return",
"definitions",
".",
"merge_components",
"(",
"*",
"map",
"(",
"functools",
".",
"partia... | Creates a single COMPONENT instance for all of the specified project
include paths
:param project:
Project where the components reside
:param include_paths:
A list of relative paths within the project directory to files or
directories that should be included in the project
:retu... | [
"Creates",
"a",
"single",
"COMPONENT",
"instance",
"for",
"all",
"of",
"the",
"specified",
"project",
"include",
"paths"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/components/project_component.py#L56-L76 |
sernst/cauldron | cauldron/session/writing/components/project_component.py | to_web_include | def to_web_include(
project: 'projects.Project',
file_path: str
) -> WEB_INCLUDE:
"""
Converts the given file_path into a WEB_INCLUDE instance that represents
the deployed version of this file to be loaded into the results project
page
:param project:
Project in which the fi... | python | def to_web_include(
project: 'projects.Project',
file_path: str
) -> WEB_INCLUDE:
"""
Converts the given file_path into a WEB_INCLUDE instance that represents
the deployed version of this file to be loaded into the results project
page
:param project:
Project in which the fi... | [
"def",
"to_web_include",
"(",
"project",
":",
"'projects.Project'",
",",
"file_path",
":",
"str",
")",
"->",
"WEB_INCLUDE",
":",
"if",
"not",
"file_path",
".",
"endswith",
"(",
"'.css'",
")",
"and",
"not",
"file_path",
".",
"endswith",
"(",
"'.js'",
")",
"... | Converts the given file_path into a WEB_INCLUDE instance that represents
the deployed version of this file to be loaded into the results project
page
:param project:
Project in which the file_path resides
:param file_path:
Absolute path to the source file for which the WEB_INCLUDE insta... | [
"Converts",
"the",
"given",
"file_path",
"into",
"a",
"WEB_INCLUDE",
"instance",
"that",
"represents",
"the",
"deployed",
"version",
"of",
"this",
"file",
"to",
"be",
"loaded",
"into",
"the",
"results",
"project",
"page"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/components/project_component.py#L79-L106 |
sernst/cauldron | cauldron/writer.py | attempt_file_write | def attempt_file_write(
path: str,
contents: typing.Union[str, bytes],
mode: str = 'w',
offset: int = 0
) -> typing.Union[None, Exception]:
"""
Attempts to write the specified contents to a file and returns None if
successful, or the raised exception if writing failed.
... | python | def attempt_file_write(
path: str,
contents: typing.Union[str, bytes],
mode: str = 'w',
offset: int = 0
) -> typing.Union[None, Exception]:
"""
Attempts to write the specified contents to a file and returns None if
successful, or the raised exception if writing failed.
... | [
"def",
"attempt_file_write",
"(",
"path",
":",
"str",
",",
"contents",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"bytes",
"]",
",",
"mode",
":",
"str",
"=",
"'w'",
",",
"offset",
":",
"int",
"=",
"0",
")",
"->",
"typing",
".",
"Union",
"[",
"... | Attempts to write the specified contents to a file and returns None if
successful, or the raised exception if writing failed.
:param path:
The path to the file that will be written
:param contents:
The contents of the file to write
:param mode:
The mode in which the file wil... | [
"Attempts",
"to",
"write",
"the",
"specified",
"contents",
"to",
"a",
"file",
"and",
"returns",
"None",
"if",
"successful",
"or",
"the",
"raised",
"exception",
"if",
"writing",
"failed",
".",
":",
"param",
"path",
":",
"The",
"path",
"to",
"the",
"file",
... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/writer.py#L6-L52 |
sernst/cauldron | cauldron/writer.py | write_file | def write_file(
path: str,
contents,
mode: str = 'w',
retry_count: int = 3,
offset: int = 0
) -> typing.Tuple[bool, typing.Union[None, Exception]]:
"""
Writes the specified contents to a file, with retry attempts if the write
operation fails. This is useful to prevent... | python | def write_file(
path: str,
contents,
mode: str = 'w',
retry_count: int = 3,
offset: int = 0
) -> typing.Tuple[bool, typing.Union[None, Exception]]:
"""
Writes the specified contents to a file, with retry attempts if the write
operation fails. This is useful to prevent... | [
"def",
"write_file",
"(",
"path",
":",
"str",
",",
"contents",
",",
"mode",
":",
"str",
"=",
"'w'",
",",
"retry_count",
":",
"int",
"=",
"3",
",",
"offset",
":",
"int",
"=",
"0",
")",
"->",
"typing",
".",
"Tuple",
"[",
"bool",
",",
"typing",
".",... | Writes the specified contents to a file, with retry attempts if the write
operation fails. This is useful to prevent OS related write collisions with
files that are regularly written to and read from quickly.
:param path:
The path to the file that will be written
:param contents:
Th... | [
"Writes",
"the",
"specified",
"contents",
"to",
"a",
"file",
"with",
"retry",
"attempts",
"if",
"the",
"write",
"operation",
"fails",
".",
"This",
"is",
"useful",
"to",
"prevent",
"OS",
"related",
"write",
"collisions",
"with",
"files",
"that",
"are",
"regul... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/writer.py#L55-L95 |
sernst/cauldron | cauldron/writer.py | attempt_json_write | def attempt_json_write(
path: str,
contents: dict,
mode: str = 'w'
) -> typing.Union[None, Exception]:
"""
Attempts to write the specified JSON content to file.
:param path:
The path to the file where the JSON serialized content will be written.
:param contents:
... | python | def attempt_json_write(
path: str,
contents: dict,
mode: str = 'w'
) -> typing.Union[None, Exception]:
"""
Attempts to write the specified JSON content to file.
:param path:
The path to the file where the JSON serialized content will be written.
:param contents:
... | [
"def",
"attempt_json_write",
"(",
"path",
":",
"str",
",",
"contents",
":",
"dict",
",",
"mode",
":",
"str",
"=",
"'w'",
")",
"->",
"typing",
".",
"Union",
"[",
"None",
",",
"Exception",
"]",
":",
"try",
":",
"with",
"open",
"(",
"path",
",",
"mode... | Attempts to write the specified JSON content to file.
:param path:
The path to the file where the JSON serialized content will be written.
:param contents:
The JSON data to write to the file
:param mode:
The mode used to open the file where the content will be written.
:r... | [
"Attempts",
"to",
"write",
"the",
"specified",
"JSON",
"content",
"to",
"file",
".",
":",
"param",
"path",
":",
"The",
"path",
"to",
"the",
"file",
"where",
"the",
"JSON",
"serialized",
"content",
"will",
"be",
"written",
".",
":",
"param",
"contents",
"... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/writer.py#L98-L121 |
sernst/cauldron | cauldron/writer.py | write_json_file | def write_json_file(
path: str,
contents: dict,
mode: str = 'w',
retry_count: int = 3
) -> typing.Tuple[bool, typing.Union[None, Exception]]:
"""
Writes the specified dictionary to a file as a JSON-serialized string,
with retry attempts if the write operation fails. This is ... | python | def write_json_file(
path: str,
contents: dict,
mode: str = 'w',
retry_count: int = 3
) -> typing.Tuple[bool, typing.Union[None, Exception]]:
"""
Writes the specified dictionary to a file as a JSON-serialized string,
with retry attempts if the write operation fails. This is ... | [
"def",
"write_json_file",
"(",
"path",
":",
"str",
",",
"contents",
":",
"dict",
",",
"mode",
":",
"str",
"=",
"'w'",
",",
"retry_count",
":",
"int",
"=",
"3",
")",
"->",
"typing",
".",
"Tuple",
"[",
"bool",
",",
"typing",
".",
"Union",
"[",
"None"... | Writes the specified dictionary to a file as a JSON-serialized string,
with retry attempts if the write operation fails. This is useful to prevent
OS related write collisions with files that are regularly written to and
read from quickly.
:param path:
The path to the file that will be wr... | [
"Writes",
"the",
"specified",
"dictionary",
"to",
"a",
"file",
"as",
"a",
"JSON",
"-",
"serialized",
"string",
"with",
"retry",
"attempts",
"if",
"the",
"write",
"operation",
"fails",
".",
"This",
"is",
"useful",
"to",
"prevent",
"OS",
"related",
"write",
... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/writer.py#L124-L158 |
sernst/cauldron | cauldron/cli/__init__.py | reformat | def reformat(source: str) -> str:
"""
Formats the source string to strip newlines on both ends and dedents the
the entire string
:param source:
The string to reformat
"""
value = source if source else ''
return dedent(value.strip('\n')).strip() | python | def reformat(source: str) -> str:
"""
Formats the source string to strip newlines on both ends and dedents the
the entire string
:param source:
The string to reformat
"""
value = source if source else ''
return dedent(value.strip('\n')).strip() | [
"def",
"reformat",
"(",
"source",
":",
"str",
")",
"->",
"str",
":",
"value",
"=",
"source",
"if",
"source",
"else",
"''",
"return",
"dedent",
"(",
"value",
".",
"strip",
"(",
"'\\n'",
")",
")",
".",
"strip",
"(",
")"
] | Formats the source string to strip newlines on both ends and dedents the
the entire string
:param source:
The string to reformat | [
"Formats",
"the",
"source",
"string",
"to",
"strip",
"newlines",
"on",
"both",
"ends",
"and",
"dedents",
"the",
"the",
"entire",
"string"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/__init__.py#L53-L63 |
sernst/cauldron | cauldron/templating.py | get_environment | def get_environment() -> Environment:
"""
Returns the jinja2 templating environment updated with the most recent
cauldron environment configurations
:return:
"""
env = JINJA_ENVIRONMENT
loader = env.loader
resource_path = environ.configs.make_path(
'resources', 'templates',
... | python | def get_environment() -> Environment:
"""
Returns the jinja2 templating environment updated with the most recent
cauldron environment configurations
:return:
"""
env = JINJA_ENVIRONMENT
loader = env.loader
resource_path = environ.configs.make_path(
'resources', 'templates',
... | [
"def",
"get_environment",
"(",
")",
"->",
"Environment",
":",
"env",
"=",
"JINJA_ENVIRONMENT",
"loader",
"=",
"env",
".",
"loader",
"resource_path",
"=",
"environ",
".",
"configs",
".",
"make_path",
"(",
"'resources'",
",",
"'templates'",
",",
"override_key",
... | Returns the jinja2 templating environment updated with the most recent
cauldron environment configurations
:return: | [
"Returns",
"the",
"jinja2",
"templating",
"environment",
"updated",
"with",
"the",
"most",
"recent",
"cauldron",
"environment",
"configurations"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/templating.py#L77-L100 |
sernst/cauldron | cauldron/templating.py | render | def render(template: typing.Union[str, Template], **kwargs):
"""
Renders a template string using Jinja2 and the Cauldron templating
environment.
:param template:
The string containing the template to be rendered
:param kwargs:
Any named arguments to pass to Jinja2 for use in renderi... | python | def render(template: typing.Union[str, Template], **kwargs):
"""
Renders a template string using Jinja2 and the Cauldron templating
environment.
:param template:
The string containing the template to be rendered
:param kwargs:
Any named arguments to pass to Jinja2 for use in renderi... | [
"def",
"render",
"(",
"template",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"Template",
"]",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"hasattr",
"(",
"template",
",",
"'render'",
")",
":",
"template",
"=",
"get_environment",
"(",
")",
".",... | Renders a template string using Jinja2 and the Cauldron templating
environment.
:param template:
The string containing the template to be rendered
:param kwargs:
Any named arguments to pass to Jinja2 for use in rendering
:return:
The rendered template string | [
"Renders",
"a",
"template",
"string",
"using",
"Jinja2",
"and",
"the",
"Cauldron",
"templating",
"environment",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/templating.py#L103-L122 |
sernst/cauldron | cauldron/templating.py | render_file | def render_file(path: str, **kwargs):
"""
Renders a file at the specified absolute path. The file can reside
anywhere on the local disk as Cauldron's template environment path
searching is ignored.
:param path:
Absolute path to a template file to render
:param kwargs:
Named argu... | python | def render_file(path: str, **kwargs):
"""
Renders a file at the specified absolute path. The file can reside
anywhere on the local disk as Cauldron's template environment path
searching is ignored.
:param path:
Absolute path to a template file to render
:param kwargs:
Named argu... | [
"def",
"render_file",
"(",
"path",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"open",
"(",
"path",
",",
"'r'",
")",
"as",
"f",
":",
"contents",
"=",
"f",
".",
"read",
"(",
")",
"return",
"get_environment",
"(",
")",
".",
"from_string",
... | Renders a file at the specified absolute path. The file can reside
anywhere on the local disk as Cauldron's template environment path
searching is ignored.
:param path:
Absolute path to a template file to render
:param kwargs:
Named arguments that should be passed to Jinja2 for renderin... | [
"Renders",
"a",
"file",
"at",
"the",
"specified",
"absolute",
"path",
".",
"The",
"file",
"can",
"reside",
"anywhere",
"on",
"the",
"local",
"disk",
"as",
"Cauldron",
"s",
"template",
"environment",
"path",
"searching",
"is",
"ignored",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/templating.py#L125-L145 |
sernst/cauldron | cauldron/templating.py | render_template | def render_template(template_name: str, **kwargs):
"""
Renders the template file with the given filename from within Cauldron's
template environment folder.
:param template_name:
The filename of the template to render. Any path elements should be
relative to Cauldron's root template fol... | python | def render_template(template_name: str, **kwargs):
"""
Renders the template file with the given filename from within Cauldron's
template environment folder.
:param template_name:
The filename of the template to render. Any path elements should be
relative to Cauldron's root template fol... | [
"def",
"render_template",
"(",
"template_name",
":",
"str",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"get_environment",
"(",
")",
".",
"get_template",
"(",
"template_name",
")",
".",
"render",
"(",
"cauldron_template_uid",
"=",
"make_template_uid",
"(",
")... | Renders the template file with the given filename from within Cauldron's
template environment folder.
:param template_name:
The filename of the template to render. Any path elements should be
relative to Cauldron's root template folder.
:param kwargs:
Any elements passed to Jinja2 f... | [
"Renders",
"the",
"template",
"file",
"with",
"the",
"given",
"filename",
"from",
"within",
"Cauldron",
"s",
"template",
"environment",
"folder",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/templating.py#L148-L165 |
sernst/cauldron | cauldron/environ/paths.py | clean | def clean(path: str) -> str:
"""
Cleans the specified path by expanding shorthand elements, redirecting to
the real path for symbolic links, and removing any relative components to
return a complete, absolute path to the specified location.
:param path:
The source path to be cleaned
"""... | python | def clean(path: str) -> str:
"""
Cleans the specified path by expanding shorthand elements, redirecting to
the real path for symbolic links, and removing any relative components to
return a complete, absolute path to the specified location.
:param path:
The source path to be cleaned
"""... | [
"def",
"clean",
"(",
"path",
":",
"str",
")",
"->",
"str",
":",
"if",
"not",
"path",
"or",
"path",
"==",
"'.'",
":",
"path",
"=",
"os",
".",
"curdir",
"if",
"path",
".",
"startswith",
"(",
"'~'",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
... | Cleans the specified path by expanding shorthand elements, redirecting to
the real path for symbolic links, and removing any relative components to
return a complete, absolute path to the specified location.
:param path:
The source path to be cleaned | [
"Cleans",
"the",
"specified",
"path",
"by",
"expanding",
"shorthand",
"elements",
"redirecting",
"to",
"the",
"real",
"path",
"for",
"symbolic",
"links",
"and",
"removing",
"any",
"relative",
"components",
"to",
"return",
"a",
"complete",
"absolute",
"path",
"to... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/paths.py#L10-L26 |
sernst/cauldron | cauldron/environ/paths.py | package | def package(*args: str) -> str:
"""
Creates an absolute path to a file or folder within the cauldron package
using the relative path elements specified by the args.
:param args:
Zero or more relative path elements that describe a file or folder
within the reporting
"""
return c... | python | def package(*args: str) -> str:
"""
Creates an absolute path to a file or folder within the cauldron package
using the relative path elements specified by the args.
:param args:
Zero or more relative path elements that describe a file or folder
within the reporting
"""
return c... | [
"def",
"package",
"(",
"*",
"args",
":",
"str",
")",
"->",
"str",
":",
"return",
"clean",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'..'",
",",
"*",
"args",
")",
")"
] | Creates an absolute path to a file or folder within the cauldron package
using the relative path elements specified by the args.
:param args:
Zero or more relative path elements that describe a file or folder
within the reporting | [
"Creates",
"an",
"absolute",
"path",
"to",
"a",
"file",
"or",
"folder",
"within",
"the",
"cauldron",
"package",
"using",
"the",
"relative",
"path",
"elements",
"specified",
"by",
"the",
"args",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/environ/paths.py#L29-L39 |
sernst/cauldron | cauldron/cli/interaction/query.py | confirm | def confirm(question: str, default: bool = True) -> bool:
"""
Requests confirmation of the specified question and returns that result
:param question:
The question to print to the console for the confirmation
:param default:
The default value if the user hits enter without entering a va... | python | def confirm(question: str, default: bool = True) -> bool:
"""
Requests confirmation of the specified question and returns that result
:param question:
The question to print to the console for the confirmation
:param default:
The default value if the user hits enter without entering a va... | [
"def",
"confirm",
"(",
"question",
":",
"str",
",",
"default",
":",
"bool",
"=",
"True",
")",
"->",
"bool",
":",
"result",
"=",
"input",
"(",
"'{question} [{yes}/{no}]:'",
".",
"format",
"(",
"question",
"=",
"question",
",",
"yes",
"=",
"'(Y)'",
"if",
... | Requests confirmation of the specified question and returns that result
:param question:
The question to print to the console for the confirmation
:param default:
The default value if the user hits enter without entering a value | [
"Requests",
"confirmation",
"of",
"the",
"specified",
"question",
"and",
"returns",
"that",
"result"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/interaction/query.py#L7-L28 |
sernst/cauldron | cauldron/cli/commands/open/actions.py | fetch_last | def fetch_last(response: Response) -> typing.Union[str, None]:
""" Returns the last opened project path if such a path exists """
recent_paths = environ.configs.fetch('recent_paths', [])
if len(recent_paths) < 1:
response.fail(
code='NO_RECENT_PROJECTS',
message='No project... | python | def fetch_last(response: Response) -> typing.Union[str, None]:
""" Returns the last opened project path if such a path exists """
recent_paths = environ.configs.fetch('recent_paths', [])
if len(recent_paths) < 1:
response.fail(
code='NO_RECENT_PROJECTS',
message='No project... | [
"def",
"fetch_last",
"(",
"response",
":",
"Response",
")",
"->",
"typing",
".",
"Union",
"[",
"str",
",",
"None",
"]",
":",
"recent_paths",
"=",
"environ",
".",
"configs",
".",
"fetch",
"(",
"'recent_paths'",
",",
"[",
"]",
")",
"if",
"len",
"(",
"r... | Returns the last opened project path if such a path exists | [
"Returns",
"the",
"last",
"opened",
"project",
"path",
"if",
"such",
"a",
"path",
"exists"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commands/open/actions.py#L129-L141 |
myaooo/pysbrl | pysbrl/utils.py | before_save | def before_save(file_or_dir):
"""
make sure that the dedicated path exists (create if not exist)
:param file_or_dir:
:return: None
"""
dir_name = os.path.dirname(os.path.abspath(file_or_dir))
if not os.path.exists(dir_name):
os.makedirs(dir_name) | python | def before_save(file_or_dir):
"""
make sure that the dedicated path exists (create if not exist)
:param file_or_dir:
:return: None
"""
dir_name = os.path.dirname(os.path.abspath(file_or_dir))
if not os.path.exists(dir_name):
os.makedirs(dir_name) | [
"def",
"before_save",
"(",
"file_or_dir",
")",
":",
"dir_name",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"file_or_dir",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dir_name",
")",
":",
... | make sure that the dedicated path exists (create if not exist)
:param file_or_dir:
:return: None | [
"make",
"sure",
"that",
"the",
"dedicated",
"path",
"exists",
"(",
"create",
"if",
"not",
"exist",
")",
":",
"param",
"file_or_dir",
":",
":",
"return",
":",
"None"
] | train | https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/utils.py#L12-L20 |
myaooo/pysbrl | pysbrl/utils.py | categorical2pysbrl_data | def categorical2pysbrl_data(
x,
y,
data_filename,
label_filename,
method='eclat',
supp=0.05,
zmin=1,
zmax=3):
"""
Run a frequent item mining algorithm to extract candidate rules.
:param x: 2D np.ndarray, categorical data of shape [n_instances, ... | python | def categorical2pysbrl_data(
x,
y,
data_filename,
label_filename,
method='eclat',
supp=0.05,
zmin=1,
zmax=3):
"""
Run a frequent item mining algorithm to extract candidate rules.
:param x: 2D np.ndarray, categorical data of shape [n_instances, ... | [
"def",
"categorical2pysbrl_data",
"(",
"x",
",",
"y",
",",
"data_filename",
",",
"label_filename",
",",
"method",
"=",
"'eclat'",
",",
"supp",
"=",
"0.05",
",",
"zmin",
"=",
"1",
",",
"zmax",
"=",
"3",
")",
":",
"# Safely cast data types",
"x",
"=",
"x",... | Run a frequent item mining algorithm to extract candidate rules.
:param x: 2D np.ndarray, categorical data of shape [n_instances, n_features]
:param y: 1D np.ndarray, label array of shape [n_instances, ]
:param data_filename: the path to store data file
:param label_filename: the path to store label fil... | [
"Run",
"a",
"frequent",
"item",
"mining",
"algorithm",
"to",
"extract",
"candidate",
"rules",
".",
":",
"param",
"x",
":",
"2D",
"np",
".",
"ndarray",
"categorical",
"data",
"of",
"shape",
"[",
"n_instances",
"n_features",
"]",
":",
"param",
"y",
":",
"1... | train | https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/utils.py#L29-L97 |
myaooo/pysbrl | pysbrl/utils.py | categorical2transactions | def categorical2transactions(x):
# type: (np.ndarray) -> List
"""
Convert a 2D int array into a transaction list:
[
['x0=1', 'x1=0', ...],
...
]
:param x:
:return:
"""
assert len(x.shape) == 2
transactions = []
for entry in x:
transact... | python | def categorical2transactions(x):
# type: (np.ndarray) -> List
"""
Convert a 2D int array into a transaction list:
[
['x0=1', 'x1=0', ...],
...
]
:param x:
:return:
"""
assert len(x.shape) == 2
transactions = []
for entry in x:
transact... | [
"def",
"categorical2transactions",
"(",
"x",
")",
":",
"# type: (np.ndarray) -> List",
"assert",
"len",
"(",
"x",
".",
"shape",
")",
"==",
"2",
"transactions",
"=",
"[",
"]",
"for",
"entry",
"in",
"x",
":",
"transactions",
".",
"append",
"(",
"[",
"'x%d=%d... | Convert a 2D int array into a transaction list:
[
['x0=1', 'x1=0', ...],
...
]
:param x:
:return: | [
"Convert",
"a",
"2D",
"int",
"array",
"into",
"a",
"transaction",
"list",
":",
"[",
"[",
"x0",
"=",
"1",
"x1",
"=",
"0",
"...",
"]",
"...",
"]",
":",
"param",
"x",
":",
":",
"return",
":"
] | train | https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/utils.py#L100-L117 |
myaooo/pysbrl | pysbrl/utils.py | rule_satisfied | def rule_satisfied(x, features, categories):
"""
return a logical array representing whether entries in x satisfied the rules denoted by features and categories
:param x: a categorical 2D array
:param features: a list of feature indices
:param categories: a list of categories
:return:
"""
... | python | def rule_satisfied(x, features, categories):
"""
return a logical array representing whether entries in x satisfied the rules denoted by features and categories
:param x: a categorical 2D array
:param features: a list of feature indices
:param categories: a list of categories
:return:
"""
... | [
"def",
"rule_satisfied",
"(",
"x",
",",
"features",
",",
"categories",
")",
":",
"satisfied",
"=",
"[",
"]",
"if",
"features",
"[",
"0",
"]",
"==",
"-",
"1",
"and",
"len",
"(",
"features",
")",
"==",
"1",
":",
"# Default rule, all satisfied",
"return",
... | return a logical array representing whether entries in x satisfied the rules denoted by features and categories
:param x: a categorical 2D array
:param features: a list of feature indices
:param categories: a list of categories
:return: | [
"return",
"a",
"logical",
"array",
"representing",
"whether",
"entries",
"in",
"x",
"satisfied",
"the",
"rules",
"denoted",
"by",
"features",
"and",
"categories",
":",
"param",
"x",
":",
"a",
"categorical",
"2D",
"array",
":",
"param",
"features",
":",
"a",
... | train | https://github.com/myaooo/pysbrl/blob/74bba8c6913a7f82e32313108f8c3e025b89d9c7/pysbrl/utils.py#L146-L161 |
sernst/cauldron | cauldron/cli/server/routes/synchronize/status.py | of_project | def of_project(project: 'projects.Project') -> dict:
"""
Returns the file status information for every file within the project
source directory and its shared library folders.
:param project:
The project for which the status information should be generated
:return:
A dictionary cont... | python | def of_project(project: 'projects.Project') -> dict:
"""
Returns the file status information for every file within the project
source directory and its shared library folders.
:param project:
The project for which the status information should be generated
:return:
A dictionary cont... | [
"def",
"of_project",
"(",
"project",
":",
"'projects.Project'",
")",
"->",
"dict",
":",
"source_directory",
"=",
"project",
".",
"source_directory",
"libraries_status",
"=",
"[",
"{",
"}",
"if",
"d",
".",
"startswith",
"(",
"source_directory",
")",
"else",
"of... | Returns the file status information for every file within the project
source directory and its shared library folders.
:param project:
The project for which the status information should be generated
:return:
A dictionary containing:
- project: the status information for all fil... | [
"Returns",
"the",
"file",
"status",
"information",
"for",
"every",
"file",
"within",
"the",
"project",
"source",
"directory",
"and",
"its",
"shared",
"library",
"folders",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/synchronize/status.py#L7-L33 |
sernst/cauldron | cauldron/cli/server/routes/synchronize/status.py | of_file | def of_file(path: str, root_directory: str = None) -> dict:
"""
Returns a dictionary containing status information for the specified file
including when its name relative to the root directory, when it was last
modified and its size.
:param path:
The absolute path to the file for which the ... | python | def of_file(path: str, root_directory: str = None) -> dict:
"""
Returns a dictionary containing status information for the specified file
including when its name relative to the root directory, when it was last
modified and its size.
:param path:
The absolute path to the file for which the ... | [
"def",
"of_file",
"(",
"path",
":",
"str",
",",
"root_directory",
":",
"str",
"=",
"None",
")",
"->",
"dict",
":",
"slug",
"=",
"(",
"path",
"if",
"root_directory",
"is",
"None",
"else",
"path",
"[",
"len",
"(",
"root_directory",
")",
":",
"]",
".",
... | Returns a dictionary containing status information for the specified file
including when its name relative to the root directory, when it was last
modified and its size.
:param path:
The absolute path to the file for which the status information should
be generated
:param root_directory... | [
"Returns",
"a",
"dictionary",
"containing",
"status",
"information",
"for",
"the",
"specified",
"file",
"including",
"when",
"its",
"name",
"relative",
"to",
"the",
"root",
"directory",
"when",
"it",
"was",
"last",
"modified",
"and",
"its",
"size",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/synchronize/status.py#L36-L75 |
sernst/cauldron | cauldron/cli/server/routes/synchronize/status.py | of_directory | def of_directory(directory: str, root_directory: str = None) -> dict:
"""
Returns a dictionary containing status entries recursively for all files
within the specified directory and its descendant directories.
:param directory:
The directory in which to retrieve status information
:param ro... | python | def of_directory(directory: str, root_directory: str = None) -> dict:
"""
Returns a dictionary containing status entries recursively for all files
within the specified directory and its descendant directories.
:param directory:
The directory in which to retrieve status information
:param ro... | [
"def",
"of_directory",
"(",
"directory",
":",
"str",
",",
"root_directory",
":",
"str",
"=",
"None",
")",
"->",
"dict",
":",
"glob_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"'**/*'",
")",
"root",
"=",
"root_directory",
"if",
"r... | Returns a dictionary containing status entries recursively for all files
within the specified directory and its descendant directories.
:param directory:
The directory in which to retrieve status information
:param root_directory:
Directory relative to which all file status paths are relate... | [
"Returns",
"a",
"dictionary",
"containing",
"status",
"entries",
"recursively",
"for",
"all",
"files",
"within",
"the",
"specified",
"directory",
"and",
"its",
"descendant",
"directories",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/synchronize/status.py#L78-L100 |
sernst/cauldron | cauldron/cli/commands/run/__init__.py | run_local | def run_local(
context: cli.CommandContext,
project: projects.Project,
project_steps: typing.List[projects.ProjectStep],
force: bool,
continue_after: bool,
single_step: bool,
limit: int,
print_status: bool,
skip_library_reload: bool = False
) -> en... | python | def run_local(
context: cli.CommandContext,
project: projects.Project,
project_steps: typing.List[projects.ProjectStep],
force: bool,
continue_after: bool,
single_step: bool,
limit: int,
print_status: bool,
skip_library_reload: bool = False
) -> en... | [
"def",
"run_local",
"(",
"context",
":",
"cli",
".",
"CommandContext",
",",
"project",
":",
"projects",
".",
"Project",
",",
"project_steps",
":",
"typing",
".",
"List",
"[",
"projects",
".",
"ProjectStep",
"]",
",",
"force",
":",
"bool",
",",
"continue_af... | Execute the run command locally within this cauldron environment
:param context:
:param project:
:param project_steps:
:param force:
:param continue_after:
:param single_step:
:param limit:
:param print_status:
:param skip_library_reload:
Whether or not to skip reloading all... | [
"Execute",
"the",
"run",
"command",
"locally",
"within",
"this",
"cauldron",
"environment"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commands/run/__init__.py#L229-L322 |
WimpyAnalytics/django-andablog | build.py | loadalldatas | def loadalldatas():
"""Loads all demo fixtures."""
dependency_order = ['common', 'profiles', 'blog', 'democomments']
for app in dependency_order:
project.recursive_load(os.path.join(paths.project_paths.manage_root, app)) | python | def loadalldatas():
"""Loads all demo fixtures."""
dependency_order = ['common', 'profiles', 'blog', 'democomments']
for app in dependency_order:
project.recursive_load(os.path.join(paths.project_paths.manage_root, app)) | [
"def",
"loadalldatas",
"(",
")",
":",
"dependency_order",
"=",
"[",
"'common'",
",",
"'profiles'",
",",
"'blog'",
",",
"'democomments'",
"]",
"for",
"app",
"in",
"dependency_order",
":",
"project",
".",
"recursive_load",
"(",
"os",
".",
"path",
".",
"join",
... | Loads all demo fixtures. | [
"Loads",
"all",
"demo",
"fixtures",
"."
] | train | https://github.com/WimpyAnalytics/django-andablog/blob/9175144140d220e4ce8212d0da6abc8c9ba9816a/build.py#L23-L27 |
sernst/cauldron | cauldron/cli/server/routes/status.py | project_status | def project_status():
"""..."""
r = Response()
try:
project = cauldron.project.get_internal_project()
if project:
r.update(project=project.status())
else:
r.update(project=None)
except Exception as err:
r.fail(
code='PROJECT_STATUS_ERR... | python | def project_status():
"""..."""
r = Response()
try:
project = cauldron.project.get_internal_project()
if project:
r.update(project=project.status())
else:
r.update(project=None)
except Exception as err:
r.fail(
code='PROJECT_STATUS_ERR... | [
"def",
"project_status",
"(",
")",
":",
"r",
"=",
"Response",
"(",
")",
"try",
":",
"project",
"=",
"cauldron",
".",
"project",
".",
"get_internal_project",
"(",
")",
"if",
"project",
":",
"r",
".",
"update",
"(",
"project",
"=",
"project",
".",
"statu... | ... | [
"..."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/status.py#L32-L50 |
sernst/cauldron | cauldron/cli/server/routes/status.py | clean_step | def clean_step(step_name: str):
"""..."""
r = Response()
project = cauldron.project.get_internal_project()
if not project:
return flask.jsonify(r.fail(
code='PROJECT_FETCH_ERROR',
message='No project is currently open'
).response.serialize())
step = project.... | python | def clean_step(step_name: str):
"""..."""
r = Response()
project = cauldron.project.get_internal_project()
if not project:
return flask.jsonify(r.fail(
code='PROJECT_FETCH_ERROR',
message='No project is currently open'
).response.serialize())
step = project.... | [
"def",
"clean_step",
"(",
"step_name",
":",
"str",
")",
":",
"r",
"=",
"Response",
"(",
")",
"project",
"=",
"cauldron",
".",
"project",
".",
"get_internal_project",
"(",
")",
"if",
"not",
"project",
":",
"return",
"flask",
".",
"jsonify",
"(",
"r",
".... | ... | [
"..."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/routes/status.py#L58-L81 |
WimpyAnalytics/django-andablog | andablog/models.py | Entry._insert_timestamp | def _insert_timestamp(self, slug, max_length=255):
"""Appends a timestamp integer to the given slug, yet ensuring the
result is less than the specified max_length.
"""
timestamp = str(int(time.time()))
ts_len = len(timestamp) + 1
while len(slug) + ts_len > max_length:
... | python | def _insert_timestamp(self, slug, max_length=255):
"""Appends a timestamp integer to the given slug, yet ensuring the
result is less than the specified max_length.
"""
timestamp = str(int(time.time()))
ts_len = len(timestamp) + 1
while len(slug) + ts_len > max_length:
... | [
"def",
"_insert_timestamp",
"(",
"self",
",",
"slug",
",",
"max_length",
"=",
"255",
")",
":",
"timestamp",
"=",
"str",
"(",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"ts_len",
"=",
"len",
"(",
"timestamp",
")",
"+",
"1",
"while",
"len",... | Appends a timestamp integer to the given slug, yet ensuring the
result is less than the specified max_length. | [
"Appends",
"a",
"timestamp",
"integer",
"to",
"the",
"given",
"slug",
"yet",
"ensuring",
"the",
"result",
"is",
"less",
"than",
"the",
"specified",
"max_length",
"."
] | train | https://github.com/WimpyAnalytics/django-andablog/blob/9175144140d220e4ce8212d0da6abc8c9ba9816a/andablog/models.py#L40-L49 |
WimpyAnalytics/django-andablog | andablog/models.py | Entry._slugify_title | def _slugify_title(self):
"""Slugify the Entry title, but ensure it's less than the maximum
number of characters. This method also ensures that a slug is unique by
appending a timestamp to any duplicate slugs.
"""
# Restrict slugs to their maximum number of chars, but don't split... | python | def _slugify_title(self):
"""Slugify the Entry title, but ensure it's less than the maximum
number of characters. This method also ensures that a slug is unique by
appending a timestamp to any duplicate slugs.
"""
# Restrict slugs to their maximum number of chars, but don't split... | [
"def",
"_slugify_title",
"(",
"self",
")",
":",
"# Restrict slugs to their maximum number of chars, but don't split mid-word",
"self",
".",
"slug",
"=",
"slugify",
"(",
"self",
".",
"title",
")",
"while",
"len",
"(",
"self",
".",
"slug",
")",
">",
"255",
":",
"s... | Slugify the Entry title, but ensure it's less than the maximum
number of characters. This method also ensures that a slug is unique by
appending a timestamp to any duplicate slugs. | [
"Slugify",
"the",
"Entry",
"title",
"but",
"ensure",
"it",
"s",
"less",
"than",
"the",
"maximum",
"number",
"of",
"characters",
".",
"This",
"method",
"also",
"ensures",
"that",
"a",
"slug",
"is",
"unique",
"by",
"appending",
"a",
"timestamp",
"to",
"any",... | train | https://github.com/WimpyAnalytics/django-andablog/blob/9175144140d220e4ce8212d0da6abc8c9ba9816a/andablog/models.py#L51-L64 |
seomoz/qless-py | qless/workers/serial.py | SerialWorker.run | def run(self):
'''Run jobs, popping one after another'''
# Register our signal handlers
self.signals()
with self.listener():
for job in self.jobs():
# If there was no job to be had, we should sleep a little bit
if not job:
... | python | def run(self):
'''Run jobs, popping one after another'''
# Register our signal handlers
self.signals()
with self.listener():
for job in self.jobs():
# If there was no job to be had, we should sleep a little bit
if not job:
... | [
"def",
"run",
"(",
"self",
")",
":",
"# Register our signal handlers",
"self",
".",
"signals",
"(",
")",
"with",
"self",
".",
"listener",
"(",
")",
":",
"for",
"job",
"in",
"self",
".",
"jobs",
"(",
")",
":",
"# If there was no job to be had, we should sleep a... | Run jobs, popping one after another | [
"Run",
"jobs",
"popping",
"one",
"after",
"another"
] | train | https://github.com/seomoz/qless-py/blob/3eda4ffcd4c0016c9a7e44f780d6155e1a354dda/qless/workers/serial.py#L24-L43 |
sernst/cauldron | cauldron/invoke/__init__.py | initialize | def initialize():
"""
Initializes the cauldron library by confirming that it can be imported
by the importlib library. If the attempt to import it fails, the system
path will be modified and the attempt retried. If both attempts fail, an
import error will be raised.
"""
cauldron_module = ge... | python | def initialize():
"""
Initializes the cauldron library by confirming that it can be imported
by the importlib library. If the attempt to import it fails, the system
path will be modified and the attempt retried. If both attempts fail, an
import error will be raised.
"""
cauldron_module = ge... | [
"def",
"initialize",
"(",
")",
":",
"cauldron_module",
"=",
"get_cauldron_module",
"(",
")",
"if",
"cauldron_module",
"is",
"not",
"None",
":",
"return",
"cauldron_module",
"sys",
".",
"path",
".",
"append",
"(",
"ROOT_DIRECTORY",
")",
"cauldron_module",
"=",
... | Initializes the cauldron library by confirming that it can be imported
by the importlib library. If the attempt to import it fails, the system
path will be modified and the attempt retried. If both attempts fail, an
import error will be raised. | [
"Initializes",
"the",
"cauldron",
"library",
"by",
"confirming",
"that",
"it",
"can",
"be",
"imported",
"by",
"the",
"importlib",
"library",
".",
"If",
"the",
"attempt",
"to",
"import",
"it",
"fails",
"the",
"system",
"path",
"will",
"be",
"modified",
"and",... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/__init__.py#L22-L43 |
sernst/cauldron | cauldron/invoke/__init__.py | run | def run(arguments: typing.List[str] = None):
"""Executes the cauldron command"""
initialize()
from cauldron.invoke import parser
from cauldron.invoke import invoker
args = parser.parse(arguments)
exit_code = invoker.run(args.get('command'), args)
sys.exit(exit_code) | python | def run(arguments: typing.List[str] = None):
"""Executes the cauldron command"""
initialize()
from cauldron.invoke import parser
from cauldron.invoke import invoker
args = parser.parse(arguments)
exit_code = invoker.run(args.get('command'), args)
sys.exit(exit_code) | [
"def",
"run",
"(",
"arguments",
":",
"typing",
".",
"List",
"[",
"str",
"]",
"=",
"None",
")",
":",
"initialize",
"(",
")",
"from",
"cauldron",
".",
"invoke",
"import",
"parser",
"from",
"cauldron",
".",
"invoke",
"import",
"invoker",
"args",
"=",
"par... | Executes the cauldron command | [
"Executes",
"the",
"cauldron",
"command"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/__init__.py#L46-L55 |
WimpyAnalytics/django-andablog | andablog/templatetags/andablog_tags.py | author_display | def author_display(author, *args):
"""Returns either the linked or not-linked profile name."""
# Call get_absolute_url or a function returning none if not defined
url = getattr(author, 'get_absolute_url', lambda: None)()
# get_short_name or unicode representation
short_name = getattr(author, 'get_s... | python | def author_display(author, *args):
"""Returns either the linked or not-linked profile name."""
# Call get_absolute_url or a function returning none if not defined
url = getattr(author, 'get_absolute_url', lambda: None)()
# get_short_name or unicode representation
short_name = getattr(author, 'get_s... | [
"def",
"author_display",
"(",
"author",
",",
"*",
"args",
")",
":",
"# Call get_absolute_url or a function returning none if not defined",
"url",
"=",
"getattr",
"(",
"author",
",",
"'get_absolute_url'",
",",
"lambda",
":",
"None",
")",
"(",
")",
"# get_short_name or ... | Returns either the linked or not-linked profile name. | [
"Returns",
"either",
"the",
"linked",
"or",
"not",
"-",
"linked",
"profile",
"name",
"."
] | train | https://github.com/WimpyAnalytics/django-andablog/blob/9175144140d220e4ce8212d0da6abc8c9ba9816a/andablog/templatetags/andablog_tags.py#L9-L19 |
sernst/cauldron | cauldron/cli/commands/steps/actions.py | echo_steps | def echo_steps(response: Response, project: Project):
"""
:param response:
:param project:
:return:
"""
if len(project.steps) < 1:
response.update(
steps=[]
).notify(
kind='SUCCESS',
code='ECHO_STEPS',
message='No steps in project'... | python | def echo_steps(response: Response, project: Project):
"""
:param response:
:param project:
:return:
"""
if len(project.steps) < 1:
response.update(
steps=[]
).notify(
kind='SUCCESS',
code='ECHO_STEPS',
message='No steps in project'... | [
"def",
"echo_steps",
"(",
"response",
":",
"Response",
",",
"project",
":",
"Project",
")",
":",
"if",
"len",
"(",
"project",
".",
"steps",
")",
"<",
"1",
":",
"response",
".",
"update",
"(",
"steps",
"=",
"[",
"]",
")",
".",
"notify",
"(",
"kind",... | :param response:
:param project:
:return: | [
":",
"param",
"response",
":",
":",
"param",
"project",
":",
":",
"return",
":"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/commands/steps/actions.py#L46-L85 |
sernst/cauldron | cauldron/session/naming.py | explode_filename | def explode_filename(name: str, scheme: str) -> dict:
"""
Removes any path components from the input filename and returns a
dictionary containing the name of the file without extension and the
extension (if an extension exists)
:param name:
:param scheme:
:return:
"""
if not scheme... | python | def explode_filename(name: str, scheme: str) -> dict:
"""
Removes any path components from the input filename and returns a
dictionary containing the name of the file without extension and the
extension (if an extension exists)
:param name:
:param scheme:
:return:
"""
if not scheme... | [
"def",
"explode_filename",
"(",
"name",
":",
"str",
",",
"scheme",
":",
"str",
")",
"->",
"dict",
":",
"if",
"not",
"scheme",
":",
"return",
"split_filename",
"(",
"name",
")",
"replacements",
"=",
"{",
"'name'",
":",
"'(?P<name>.*)'",
",",
"'ext'",
":",... | Removes any path components from the input filename and returns a
dictionary containing the name of the file without extension and the
extension (if an extension exists)
:param name:
:param scheme:
:return: | [
"Removes",
"any",
"path",
"components",
"from",
"the",
"input",
"filename",
"and",
"returns",
"a",
"dictionary",
"containing",
"the",
"name",
"of",
"the",
"file",
"without",
"extension",
"and",
"the",
"extension",
"(",
"if",
"an",
"extension",
"exists",
")"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/naming.py#L36-L117 |
sernst/cauldron | cauldron/session/writing/components/plotly_component.py | create | def create(project: 'projects.Project') -> COMPONENT:
"""
:param project:
:return:
"""
source_path = get_source_path()
if not source_path:
return COMPONENT([], [])
output_slug = 'components/plotly/plotly.min.js'
output_path = os.path.join(project.output_directory, output_slug)
... | python | def create(project: 'projects.Project') -> COMPONENT:
"""
:param project:
:return:
"""
source_path = get_source_path()
if not source_path:
return COMPONENT([], [])
output_slug = 'components/plotly/plotly.min.js'
output_path = os.path.join(project.output_directory, output_slug)
... | [
"def",
"create",
"(",
"project",
":",
"'projects.Project'",
")",
"->",
"COMPONENT",
":",
"source_path",
"=",
"get_source_path",
"(",
")",
"if",
"not",
"source_path",
":",
"return",
"COMPONENT",
"(",
"[",
"]",
",",
"[",
"]",
")",
"output_slug",
"=",
"'compo... | :param project:
:return: | [
":",
"param",
"project",
":",
":",
"return",
":"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/writing/components/plotly_component.py#L58-L80 |
sernst/cauldron | cauldron/invoke/invoker.py | in_project_directory | def in_project_directory() -> bool:
"""
Returns whether or not the current working directory is a Cauldron project
directory, which contains a cauldron.json file.
"""
current_directory = os.path.realpath(os.curdir)
project_path = os.path.join(current_directory, 'cauldron.json')
return os.pat... | python | def in_project_directory() -> bool:
"""
Returns whether or not the current working directory is a Cauldron project
directory, which contains a cauldron.json file.
"""
current_directory = os.path.realpath(os.curdir)
project_path = os.path.join(current_directory, 'cauldron.json')
return os.pat... | [
"def",
"in_project_directory",
"(",
")",
"->",
"bool",
":",
"current_directory",
"=",
"os",
".",
"path",
".",
"realpath",
"(",
"os",
".",
"curdir",
")",
"project_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"current_directory",
",",
"'cauldron.json'",
... | Returns whether or not the current working directory is a Cauldron project
directory, which contains a cauldron.json file. | [
"Returns",
"whether",
"or",
"not",
"the",
"current",
"working",
"directory",
"is",
"a",
"Cauldron",
"project",
"directory",
"which",
"contains",
"a",
"cauldron",
".",
"json",
"file",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/invoker.py#L12-L19 |
sernst/cauldron | cauldron/invoke/invoker.py | load_shared_data | def load_shared_data(path: typing.Union[str, None]) -> dict:
"""Load shared data from a JSON file stored on disk"""
if path is None:
return dict()
if not os.path.exists(path):
raise FileNotFoundError('No such shared data file "{}"'.format(path))
try:
with open(path, 'r') as fp... | python | def load_shared_data(path: typing.Union[str, None]) -> dict:
"""Load shared data from a JSON file stored on disk"""
if path is None:
return dict()
if not os.path.exists(path):
raise FileNotFoundError('No such shared data file "{}"'.format(path))
try:
with open(path, 'r') as fp... | [
"def",
"load_shared_data",
"(",
"path",
":",
"typing",
".",
"Union",
"[",
"str",
",",
"None",
"]",
")",
"->",
"dict",
":",
"if",
"path",
"is",
"None",
":",
"return",
"dict",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")... | Load shared data from a JSON file stored on disk | [
"Load",
"shared",
"data",
"from",
"a",
"JSON",
"file",
"stored",
"on",
"disk"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/invoker.py#L22-L40 |
sernst/cauldron | cauldron/invoke/invoker.py | run_version | def run_version(args: dict) -> int:
"""Displays the current version"""
version = environ.package_settings.get('version', 'unknown')
print('VERSION: {}'.format(version))
return 0 | python | def run_version(args: dict) -> int:
"""Displays the current version"""
version = environ.package_settings.get('version', 'unknown')
print('VERSION: {}'.format(version))
return 0 | [
"def",
"run_version",
"(",
"args",
":",
"dict",
")",
"->",
"int",
":",
"version",
"=",
"environ",
".",
"package_settings",
".",
"get",
"(",
"'version'",
",",
"'unknown'",
")",
"print",
"(",
"'VERSION: {}'",
".",
"format",
"(",
"version",
")",
")",
"retur... | Displays the current version | [
"Displays",
"the",
"current",
"version"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/invoker.py#L43-L47 |
sernst/cauldron | cauldron/invoke/invoker.py | run_batch | def run_batch(args: dict) -> int:
"""Runs a batch operation for the given arguments"""
batcher.run_project(
project_directory=args.get('project_directory'),
log_path=args.get('logging_path'),
output_directory=args.get('output_directory'),
shared_data=load_shared_data(args.get('s... | python | def run_batch(args: dict) -> int:
"""Runs a batch operation for the given arguments"""
batcher.run_project(
project_directory=args.get('project_directory'),
log_path=args.get('logging_path'),
output_directory=args.get('output_directory'),
shared_data=load_shared_data(args.get('s... | [
"def",
"run_batch",
"(",
"args",
":",
"dict",
")",
"->",
"int",
":",
"batcher",
".",
"run_project",
"(",
"project_directory",
"=",
"args",
".",
"get",
"(",
"'project_directory'",
")",
",",
"log_path",
"=",
"args",
".",
"get",
"(",
"'logging_path'",
")",
... | Runs a batch operation for the given arguments | [
"Runs",
"a",
"batch",
"operation",
"for",
"the",
"given",
"arguments"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/invoker.py#L50-L59 |
sernst/cauldron | cauldron/invoke/invoker.py | run_shell | def run_shell(args: dict) -> int:
"""Run the shell sub command"""
if args.get('project_directory'):
return run_batch(args)
shell = CauldronShell()
if in_project_directory():
shell.cmdqueue.append('open "{}"'.format(os.path.realpath(os.curdir)))
shell.cmdloop()
return 0 | python | def run_shell(args: dict) -> int:
"""Run the shell sub command"""
if args.get('project_directory'):
return run_batch(args)
shell = CauldronShell()
if in_project_directory():
shell.cmdqueue.append('open "{}"'.format(os.path.realpath(os.curdir)))
shell.cmdloop()
return 0 | [
"def",
"run_shell",
"(",
"args",
":",
"dict",
")",
"->",
"int",
":",
"if",
"args",
".",
"get",
"(",
"'project_directory'",
")",
":",
"return",
"run_batch",
"(",
"args",
")",
"shell",
"=",
"CauldronShell",
"(",
")",
"if",
"in_project_directory",
"(",
")",... | Run the shell sub command | [
"Run",
"the",
"shell",
"sub",
"command"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/invoker.py#L62-L74 |
sernst/cauldron | cauldron/invoke/invoker.py | run | def run(action: str, args: dict) -> int:
"""
Runs the specified command action and returns the return status code
for exit.
:param action:
The action to run
:param args:
The arguments parsed for the specified action
"""
if args.get('show_version_info'):
return ru... | python | def run(action: str, args: dict) -> int:
"""
Runs the specified command action and returns the return status code
for exit.
:param action:
The action to run
:param args:
The arguments parsed for the specified action
"""
if args.get('show_version_info'):
return ru... | [
"def",
"run",
"(",
"action",
":",
"str",
",",
"args",
":",
"dict",
")",
"->",
"int",
":",
"if",
"args",
".",
"get",
"(",
"'show_version_info'",
")",
":",
"return",
"run_version",
"(",
"args",
")",
"actions",
"=",
"dict",
"(",
"shell",
"=",
"run_shell... | Runs the specified command action and returns the return status code
for exit.
:param action:
The action to run
:param args:
The arguments parsed for the specified action | [
"Runs",
"the",
"specified",
"command",
"action",
"and",
"returns",
"the",
"return",
"status",
"code",
"for",
"exit",
".",
":",
"param",
"action",
":",
"The",
"action",
"to",
"run",
":",
"param",
"args",
":",
"The",
"arguments",
"parsed",
"for",
"the",
"s... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/invoke/invoker.py#L83-L109 |
sernst/cauldron | cauldron/cli/server/run.py | get_running_step_changes | def get_running_step_changes(write: bool = False) -> list:
"""..."""
project = cd.project.get_internal_project()
running_steps = list(filter(
lambda step: step.is_running,
project.steps
))
def get_changes(step):
step_data = writing.step_writer.serialize(step)
if wr... | python | def get_running_step_changes(write: bool = False) -> list:
"""..."""
project = cd.project.get_internal_project()
running_steps = list(filter(
lambda step: step.is_running,
project.steps
))
def get_changes(step):
step_data = writing.step_writer.serialize(step)
if wr... | [
"def",
"get_running_step_changes",
"(",
"write",
":",
"bool",
"=",
"False",
")",
"->",
"list",
":",
"project",
"=",
"cd",
".",
"project",
".",
"get_internal_project",
"(",
")",
"running_steps",
"=",
"list",
"(",
"filter",
"(",
"lambda",
"step",
":",
"step"... | ... | [
"..."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/run.py#L53-L75 |
sernst/cauldron | cauldron/cli/server/run.py | parse | def parse(
args: typing.List[str] = None,
arg_parser: ArgumentParser = None
) -> dict:
"""Parses the arguments for the cauldron server"""
parser = arg_parser or create_parser()
return vars(parser.parse_args(args)) | python | def parse(
args: typing.List[str] = None,
arg_parser: ArgumentParser = None
) -> dict:
"""Parses the arguments for the cauldron server"""
parser = arg_parser or create_parser()
return vars(parser.parse_args(args)) | [
"def",
"parse",
"(",
"args",
":",
"typing",
".",
"List",
"[",
"str",
"]",
"=",
"None",
",",
"arg_parser",
":",
"ArgumentParser",
"=",
"None",
")",
"->",
"dict",
":",
"parser",
"=",
"arg_parser",
"or",
"create_parser",
"(",
")",
"return",
"vars",
"(",
... | Parses the arguments for the cauldron server | [
"Parses",
"the",
"arguments",
"for",
"the",
"cauldron",
"server"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/run.py#L78-L85 |
sernst/cauldron | cauldron/cli/server/run.py | create_parser | def create_parser(arg_parser: ArgumentParser = None) -> ArgumentParser:
"""
Creates an argument parser populated with the arg formats for the server
command.
"""
parser = arg_parser or ArgumentParser()
parser.description = 'Cauldron kernel server'
parser.add_argument(
'-p', '--port... | python | def create_parser(arg_parser: ArgumentParser = None) -> ArgumentParser:
"""
Creates an argument parser populated with the arg formats for the server
command.
"""
parser = arg_parser or ArgumentParser()
parser.description = 'Cauldron kernel server'
parser.add_argument(
'-p', '--port... | [
"def",
"create_parser",
"(",
"arg_parser",
":",
"ArgumentParser",
"=",
"None",
")",
"->",
"ArgumentParser",
":",
"parser",
"=",
"arg_parser",
"or",
"ArgumentParser",
"(",
")",
"parser",
".",
"description",
"=",
"'Cauldron kernel server'",
"parser",
".",
"add_argum... | Creates an argument parser populated with the arg formats for the server
command. | [
"Creates",
"an",
"argument",
"parser",
"populated",
"with",
"the",
"arg",
"formats",
"for",
"the",
"server",
"command",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/cli/server/run.py#L88-L132 |
ayoungprogrammer/Lango | lango/matcher.py | match_rules | def match_rules(tree, rules, fun=None, multi=False):
"""Matches a Tree structure with the given query rules.
Query rules are represented as a dictionary of template to action.
Action is either a function, or a dictionary of subtemplate parameter to rules::
rules = { 'template' : { 'key': rules } }... | python | def match_rules(tree, rules, fun=None, multi=False):
"""Matches a Tree structure with the given query rules.
Query rules are represented as a dictionary of template to action.
Action is either a function, or a dictionary of subtemplate parameter to rules::
rules = { 'template' : { 'key': rules } }... | [
"def",
"match_rules",
"(",
"tree",
",",
"rules",
",",
"fun",
"=",
"None",
",",
"multi",
"=",
"False",
")",
":",
"if",
"multi",
":",
"context",
"=",
"match_rules_context_multi",
"(",
"tree",
",",
"rules",
")",
"else",
":",
"context",
"=",
"match_rules_con... | Matches a Tree structure with the given query rules.
Query rules are represented as a dictionary of template to action.
Action is either a function, or a dictionary of subtemplate parameter to rules::
rules = { 'template' : { 'key': rules } }
| { 'template' : {} }
Args:
tree... | [
"Matches",
"a",
"Tree",
"structure",
"with",
"the",
"given",
"query",
"rules",
"."
] | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L6-L48 |
ayoungprogrammer/Lango | lango/matcher.py | match_rules_context | def match_rules_context(tree, rules, parent_context={}):
"""Recursively matches a Tree structure with rules and returns context
Args:
tree (Tree): Parsed tree structure
rules (dict): See match_rules
parent_context (dict): Context of parent call
Returns:
dict: Context matched... | python | def match_rules_context(tree, rules, parent_context={}):
"""Recursively matches a Tree structure with rules and returns context
Args:
tree (Tree): Parsed tree structure
rules (dict): See match_rules
parent_context (dict): Context of parent call
Returns:
dict: Context matched... | [
"def",
"match_rules_context",
"(",
"tree",
",",
"rules",
",",
"parent_context",
"=",
"{",
"}",
")",
":",
"for",
"template",
",",
"match_rules",
"in",
"rules",
".",
"items",
"(",
")",
":",
"context",
"=",
"parent_context",
".",
"copy",
"(",
")",
"if",
"... | Recursively matches a Tree structure with rules and returns context
Args:
tree (Tree): Parsed tree structure
rules (dict): See match_rules
parent_context (dict): Context of parent call
Returns:
dict: Context matched dictionary of matched rules or
None if no match | [
"Recursively",
"matches",
"a",
"Tree",
"structure",
"with",
"rules",
"and",
"returns",
"context"
] | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L50-L72 |
ayoungprogrammer/Lango | lango/matcher.py | cross_context | def cross_context(contextss):
"""
Cross product of all contexts
[[a], [b], [c]] -> [[a] x [b] x [c]]
"""
if not contextss:
return []
product = [{}]
for contexts in contextss:
tmp_product = []
for c in contexts:
for ce in product:
c_copy ... | python | def cross_context(contextss):
"""
Cross product of all contexts
[[a], [b], [c]] -> [[a] x [b] x [c]]
"""
if not contextss:
return []
product = [{}]
for contexts in contextss:
tmp_product = []
for c in contexts:
for ce in product:
c_copy ... | [
"def",
"cross_context",
"(",
"contextss",
")",
":",
"if",
"not",
"contextss",
":",
"return",
"[",
"]",
"product",
"=",
"[",
"{",
"}",
"]",
"for",
"contexts",
"in",
"contextss",
":",
"tmp_product",
"=",
"[",
"]",
"for",
"c",
"in",
"contexts",
":",
"fo... | Cross product of all contexts
[[a], [b], [c]] -> [[a] x [b] x [c]] | [
"Cross",
"product",
"of",
"all",
"contexts",
"[[",
"a",
"]",
"[",
"b",
"]",
"[",
"c",
"]]",
"-",
">",
"[[",
"a",
"]",
"x",
"[",
"b",
"]",
"x",
"[",
"c",
"]]"
] | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L74-L93 |
ayoungprogrammer/Lango | lango/matcher.py | match_rules_context_multi | def match_rules_context_multi(tree, rules, parent_context={}):
"""Recursively matches a Tree structure with rules and returns context
Args:
tree (Tree): Parsed tree structure
rules (dict): See match_rules
parent_context (dict): Context of parent call
Returns:
dict: Context m... | python | def match_rules_context_multi(tree, rules, parent_context={}):
"""Recursively matches a Tree structure with rules and returns context
Args:
tree (Tree): Parsed tree structure
rules (dict): See match_rules
parent_context (dict): Context of parent call
Returns:
dict: Context m... | [
"def",
"match_rules_context_multi",
"(",
"tree",
",",
"rules",
",",
"parent_context",
"=",
"{",
"}",
")",
":",
"all_contexts",
"=",
"[",
"]",
"for",
"template",
",",
"match_rules",
"in",
"rules",
".",
"items",
"(",
")",
":",
"context",
"=",
"parent_context... | Recursively matches a Tree structure with rules and returns context
Args:
tree (Tree): Parsed tree structure
rules (dict): See match_rules
parent_context (dict): Context of parent call
Returns:
dict: Context matched dictionary of matched rules or
None if no match | [
"Recursively",
"matches",
"a",
"Tree",
"structure",
"with",
"rules",
"and",
"returns",
"context"
] | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L95-L117 |
ayoungprogrammer/Lango | lango/matcher.py | match_template | def match_template(tree, template, args=None):
"""Check if match string matches Tree structure
Args:
tree (Tree): Parsed Tree structure of a sentence
template (str): String template to match. Example: "( S ( NP ) )"
Returns:
bool: If they match or not
"""
tokens = get_to... | python | def match_template(tree, template, args=None):
"""Check if match string matches Tree structure
Args:
tree (Tree): Parsed Tree structure of a sentence
template (str): String template to match. Example: "( S ( NP ) )"
Returns:
bool: If they match or not
"""
tokens = get_to... | [
"def",
"match_template",
"(",
"tree",
",",
"template",
",",
"args",
"=",
"None",
")",
":",
"tokens",
"=",
"get_tokens",
"(",
"template",
".",
"split",
"(",
")",
")",
"cur_args",
"=",
"{",
"}",
"if",
"match_tokens",
"(",
"tree",
",",
"tokens",
",",
"c... | Check if match string matches Tree structure
Args:
tree (Tree): Parsed Tree structure of a sentence
template (str): String template to match. Example: "( S ( NP ) )"
Returns:
bool: If they match or not | [
"Check",
"if",
"match",
"string",
"matches",
"Tree",
"structure",
"Args",
":",
"tree",
"(",
"Tree",
")",
":",
"Parsed",
"Tree",
"structure",
"of",
"a",
"sentence",
"template",
"(",
"str",
")",
":",
"String",
"template",
"to",
"match",
".",
"Example",
":"... | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L119-L137 |
ayoungprogrammer/Lango | lango/matcher.py | match_tokens | def match_tokens(tree, tokens, args):
"""Check if stack of tokens matches the Tree structure
Special matching rules that can be specified in the template::
':label': Label a token, the token will be returned as part of the context with key 'label'.
'-@': Additional single letter argument d... | python | def match_tokens(tree, tokens, args):
"""Check if stack of tokens matches the Tree structure
Special matching rules that can be specified in the template::
':label': Label a token, the token will be returned as part of the context with key 'label'.
'-@': Additional single letter argument d... | [
"def",
"match_tokens",
"(",
"tree",
",",
"tokens",
",",
"args",
")",
":",
"arg_type_to_func",
"=",
"{",
"'r'",
":",
"get_raw_lower",
",",
"'R'",
":",
"get_raw",
",",
"'o'",
":",
"get_object_lower",
",",
"'O'",
":",
"get_object",
",",
"}",
"if",
"len",
... | Check if stack of tokens matches the Tree structure
Special matching rules that can be specified in the template::
':label': Label a token, the token will be returned as part of the context with key 'label'.
'-@': Additional single letter argument determining return format of labeled token. Va... | [
"Check",
"if",
"stack",
"of",
"tokens",
"matches",
"the",
"Tree",
"structure",
"Special",
"matching",
"rules",
"that",
"can",
"be",
"specified",
"in",
"the",
"template",
"::"
] | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L140-L211 |
ayoungprogrammer/Lango | lango/matcher.py | get_tokens | def get_tokens(tokens):
"""Recursively gets tokens from a match list
Args:
tokens : List of tokens ['(', 'S', '(', 'NP', ')', ')']
Returns:
Stack of tokens
"""
tokens = tokens[1:-1]
ret = []
start = 0
stack = 0
for i in range(len(tokens)):
if tokens[i] ==... | python | def get_tokens(tokens):
"""Recursively gets tokens from a match list
Args:
tokens : List of tokens ['(', 'S', '(', 'NP', ')', ')']
Returns:
Stack of tokens
"""
tokens = tokens[1:-1]
ret = []
start = 0
stack = 0
for i in range(len(tokens)):
if tokens[i] ==... | [
"def",
"get_tokens",
"(",
"tokens",
")",
":",
"tokens",
"=",
"tokens",
"[",
"1",
":",
"-",
"1",
"]",
"ret",
"=",
"[",
"]",
"start",
"=",
"0",
"stack",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"tokens",
")",
")",
":",
"if",
"token... | Recursively gets tokens from a match list
Args:
tokens : List of tokens ['(', 'S', '(', 'NP', ')', ')']
Returns:
Stack of tokens | [
"Recursively",
"gets",
"tokens",
"from",
"a",
"match",
"list",
"Args",
":",
"tokens",
":",
"List",
"of",
"tokens",
"[",
"(",
"S",
"(",
"NP",
")",
")",
"]",
"Returns",
":",
"Stack",
"of",
"tokens"
] | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L214-L242 |
ayoungprogrammer/Lango | lango/matcher.py | get_object | def get_object(tree):
"""Get the object in the tree object.
Method should remove unnecessary letters and words::
the
a/an
's
Args:
tree (Tree): Parsed tree structure
Returns:
Resulting string of tree ``(Ex: "red car")``
"""
if isinstance(tree, Tree)... | python | def get_object(tree):
"""Get the object in the tree object.
Method should remove unnecessary letters and words::
the
a/an
's
Args:
tree (Tree): Parsed tree structure
Returns:
Resulting string of tree ``(Ex: "red car")``
"""
if isinstance(tree, Tree)... | [
"def",
"get_object",
"(",
"tree",
")",
":",
"if",
"isinstance",
"(",
"tree",
",",
"Tree",
")",
":",
"if",
"tree",
".",
"label",
"(",
")",
"==",
"'DT'",
"or",
"tree",
".",
"label",
"(",
")",
"==",
"'POS'",
":",
"return",
"''",
"words",
"=",
"[",
... | Get the object in the tree object.
Method should remove unnecessary letters and words::
the
a/an
's
Args:
tree (Tree): Parsed tree structure
Returns:
Resulting string of tree ``(Ex: "red car")`` | [
"Get",
"the",
"object",
"in",
"the",
"tree",
"object",
".",
"Method",
"should",
"remove",
"unnecessary",
"letters",
"and",
"words",
"::"
] | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L245-L267 |
ayoungprogrammer/Lango | lango/matcher.py | get_raw | def get_raw(tree):
"""Get the exact words in lowercase in the tree object.
Args:
tree (Tree): Parsed tree structure
Returns:
Resulting string of tree ``(Ex: "The red car")``
"""
if isinstance(tree, Tree):
words = []
for child in tree:
words.append(get... | python | def get_raw(tree):
"""Get the exact words in lowercase in the tree object.
Args:
tree (Tree): Parsed tree structure
Returns:
Resulting string of tree ``(Ex: "The red car")``
"""
if isinstance(tree, Tree):
words = []
for child in tree:
words.append(get... | [
"def",
"get_raw",
"(",
"tree",
")",
":",
"if",
"isinstance",
"(",
"tree",
",",
"Tree",
")",
":",
"words",
"=",
"[",
"]",
"for",
"child",
"in",
"tree",
":",
"words",
".",
"append",
"(",
"get_raw",
"(",
"child",
")",
")",
"return",
"' '",
".",
"joi... | Get the exact words in lowercase in the tree object.
Args:
tree (Tree): Parsed tree structure
Returns:
Resulting string of tree ``(Ex: "The red car")`` | [
"Get",
"the",
"exact",
"words",
"in",
"lowercase",
"in",
"the",
"tree",
"object",
".",
"Args",
":",
"tree",
"(",
"Tree",
")",
":",
"Parsed",
"tree",
"structure",
"Returns",
":",
"Resulting",
"string",
"of",
"tree",
"(",
"Ex",
":",
"The",
"red",
"car",
... | train | https://github.com/ayoungprogrammer/Lango/blob/0c4284c153abc2d8de4b03a86731bd84385e6afa/lango/matcher.py#L274-L288 |
sernst/cauldron | cauldron/session/spark/__init__.py | initialize | def initialize(spark_home_path: str = None):
"""
Registers and initializes the PySpark library dependencies so that the
pyspark package can be imported and used within the notebook.
If you specify the path to the spark home folder, the PySpark libraries
from that location will be loaded. If a value... | python | def initialize(spark_home_path: str = None):
"""
Registers and initializes the PySpark library dependencies so that the
pyspark package can be imported and used within the notebook.
If you specify the path to the spark home folder, the PySpark libraries
from that location will be loaded. If a value... | [
"def",
"initialize",
"(",
"spark_home_path",
":",
"str",
"=",
"None",
")",
":",
"if",
"not",
"spark_home_path",
":",
"spark_home_path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'SPARK_HOME'",
")",
"spark_home_path",
"=",
"environ",
".",
"paths",
".",
"... | Registers and initializes the PySpark library dependencies so that the
pyspark package can be imported and used within the notebook.
If you specify the path to the spark home folder, the PySpark libraries
from that location will be loaded. If a value is omitted, the $SPARK_HOME
environmental variable w... | [
"Registers",
"and",
"initializes",
"the",
"PySpark",
"library",
"dependencies",
"so",
"that",
"the",
"pyspark",
"package",
"can",
"be",
"imported",
"and",
"used",
"within",
"the",
"notebook",
"."
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/spark/__init__.py#L26-L86 |
sernst/cauldron | cauldron/session/projects/project.py | Project.is_remote_project | def is_remote_project(self) -> bool:
"""Whether or not this project is remote"""
project_path = environ.paths.clean(self.source_directory)
return project_path.find('cd-remote-project') != -1 | python | def is_remote_project(self) -> bool:
"""Whether or not this project is remote"""
project_path = environ.paths.clean(self.source_directory)
return project_path.find('cd-remote-project') != -1 | [
"def",
"is_remote_project",
"(",
"self",
")",
"->",
"bool",
":",
"project_path",
"=",
"environ",
".",
"paths",
".",
"clean",
"(",
"self",
".",
"source_directory",
")",
"return",
"project_path",
".",
"find",
"(",
"'cd-remote-project'",
")",
"!=",
"-",
"1"
] | Whether or not this project is remote | [
"Whether",
"or",
"not",
"this",
"project",
"is",
"remote"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/project.py#L75-L78 |
sernst/cauldron | cauldron/session/projects/project.py | Project.library_directories | def library_directories(self) -> typing.List[str]:
"""
The list of directories to all of the library locations
"""
def listify(value):
return [value] if isinstance(value, str) else list(value)
# If this is a project running remotely remove external library
# ... | python | def library_directories(self) -> typing.List[str]:
"""
The list of directories to all of the library locations
"""
def listify(value):
return [value] if isinstance(value, str) else list(value)
# If this is a project running remotely remove external library
# ... | [
"def",
"library_directories",
"(",
"self",
")",
"->",
"typing",
".",
"List",
"[",
"str",
"]",
":",
"def",
"listify",
"(",
"value",
")",
":",
"return",
"[",
"value",
"]",
"if",
"isinstance",
"(",
"value",
",",
"str",
")",
"else",
"list",
"(",
"value",... | The list of directories to all of the library locations | [
"The",
"list",
"of",
"directories",
"to",
"all",
"of",
"the",
"library",
"locations"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/project.py#L81-L107 |
sernst/cauldron | cauldron/session/projects/project.py | Project.results_path | def results_path(self) -> str:
"""The path where the project results will be written"""
def possible_paths():
yield self._results_path
yield self.settings.fetch('path_results')
yield environ.configs.fetch('results_directory')
yield environ.paths.results(s... | python | def results_path(self) -> str:
"""The path where the project results will be written"""
def possible_paths():
yield self._results_path
yield self.settings.fetch('path_results')
yield environ.configs.fetch('results_directory')
yield environ.paths.results(s... | [
"def",
"results_path",
"(",
"self",
")",
"->",
"str",
":",
"def",
"possible_paths",
"(",
")",
":",
"yield",
"self",
".",
"_results_path",
"yield",
"self",
".",
"settings",
".",
"fetch",
"(",
"'path_results'",
")",
"yield",
"environ",
".",
"configs",
".",
... | The path where the project results will be written | [
"The",
"path",
"where",
"the",
"project",
"results",
"will",
"be",
"written"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/project.py#L175-L184 |
sernst/cauldron | cauldron/session/projects/project.py | Project.url | def url(self) -> str:
"""
Returns the URL that will open this project results file in the browser
:return:
"""
return 'file://{path}?id={id}'.format(
path=os.path.join(self.results_path, 'project.html'),
id=self.uuid
) | python | def url(self) -> str:
"""
Returns the URL that will open this project results file in the browser
:return:
"""
return 'file://{path}?id={id}'.format(
path=os.path.join(self.results_path, 'project.html'),
id=self.uuid
) | [
"def",
"url",
"(",
"self",
")",
"->",
"str",
":",
"return",
"'file://{path}?id={id}'",
".",
"format",
"(",
"path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"results_path",
",",
"'project.html'",
")",
",",
"id",
"=",
"self",
".",
"uuid",
... | Returns the URL that will open this project results file in the browser
:return: | [
"Returns",
"the",
"URL",
"that",
"will",
"open",
"this",
"project",
"results",
"file",
"in",
"the",
"browser",
":",
"return",
":"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/project.py#L191-L200 |
sernst/cauldron | cauldron/session/projects/project.py | Project.output_directory | def output_directory(self) -> str:
"""
Returns the directory where the project results files will be written
"""
return os.path.join(self.results_path, 'reports', self.uuid, 'latest') | python | def output_directory(self) -> str:
"""
Returns the directory where the project results files will be written
"""
return os.path.join(self.results_path, 'reports', self.uuid, 'latest') | [
"def",
"output_directory",
"(",
"self",
")",
"->",
"str",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"results_path",
",",
"'reports'",
",",
"self",
".",
"uuid",
",",
"'latest'",
")"
] | Returns the directory where the project results files will be written | [
"Returns",
"the",
"directory",
"where",
"the",
"project",
"results",
"files",
"will",
"be",
"written"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/project.py#L217-L222 |
sernst/cauldron | cauldron/session/projects/project.py | Project.refresh | def refresh(self, force: bool = False) -> bool:
"""
Loads the cauldron.json definition file for the project and populates
the project with the loaded data. Any existing data will be overwritten,
if the new definition file differs from the previous one.
If the project has already... | python | def refresh(self, force: bool = False) -> bool:
"""
Loads the cauldron.json definition file for the project and populates
the project with the loaded data. Any existing data will be overwritten,
if the new definition file differs from the previous one.
If the project has already... | [
"def",
"refresh",
"(",
"self",
",",
"force",
":",
"bool",
"=",
"False",
")",
"->",
"bool",
":",
"lm",
"=",
"self",
".",
"last_modified",
"is_newer",
"=",
"lm",
"is",
"not",
"None",
"and",
"lm",
">=",
"os",
".",
"path",
".",
"getmtime",
"(",
"self",... | Loads the cauldron.json definition file for the project and populates
the project with the loaded data. Any existing data will be overwritten,
if the new definition file differs from the previous one.
If the project has already loaded with the most recent version of the
cauldron.json fi... | [
"Loads",
"the",
"cauldron",
".",
"json",
"definition",
"file",
"for",
"the",
"project",
"and",
"populates",
"the",
"project",
"with",
"the",
"loaded",
"data",
".",
"Any",
"existing",
"data",
"will",
"be",
"overwritten",
"if",
"the",
"new",
"definition",
"fil... | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/session/projects/project.py#L267-L317 |
sernst/cauldron | cauldron/render/texts.py | preformatted_text | def preformatted_text(source: str) -> str:
"""Renders preformatted text box"""
environ.abort_thread()
if not source:
return ''
source = render_utils.html_escape(source)
return '<pre class="preformatted-textbox">{text}</pre>'.format(
text=str(textwrap.dedent(source))
) | python | def preformatted_text(source: str) -> str:
"""Renders preformatted text box"""
environ.abort_thread()
if not source:
return ''
source = render_utils.html_escape(source)
return '<pre class="preformatted-textbox">{text}</pre>'.format(
text=str(textwrap.dedent(source))
) | [
"def",
"preformatted_text",
"(",
"source",
":",
"str",
")",
"->",
"str",
":",
"environ",
".",
"abort_thread",
"(",
")",
"if",
"not",
"source",
":",
"return",
"''",
"source",
"=",
"render_utils",
".",
"html_escape",
"(",
"source",
")",
"return",
"'<pre clas... | Renders preformatted text box | [
"Renders",
"preformatted",
"text",
"box"
] | train | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/render/texts.py#L142-L153 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.