repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
mk-fg/graphite-metrics | graphite_metrics/collectors/__init__.py | rate_limit | def rate_limit(max_interval=20, sampling=3, f=lambda x: x):
'''x rises by 1 from 0 on each iteraton, back to 0 on triggering.
f(x) should rise up to f(max_interval) in some way (with default
"f(x)=x" probability rises lineary with 100% chance on "x=max_interval").
"sampling" affect probablility in an "c=1-(1-c0... | python | def rate_limit(max_interval=20, sampling=3, f=lambda x: x):
'''x rises by 1 from 0 on each iteraton, back to 0 on triggering.
f(x) should rise up to f(max_interval) in some way (with default
"f(x)=x" probability rises lineary with 100% chance on "x=max_interval").
"sampling" affect probablility in an "c=1-(1-c0... | [
"def",
"rate_limit",
"(",
"max_interval",
"=",
"20",
",",
"sampling",
"=",
"3",
",",
"f",
"=",
"lambda",
"x",
":",
"x",
")",
":",
"from",
"random",
"import",
"random",
"val",
"=",
"0",
"val_max",
"=",
"float",
"(",
"f",
"(",
"max_interval",
")",
")... | x rises by 1 from 0 on each iteraton, back to 0 on triggering.
f(x) should rise up to f(max_interval) in some way (with default
"f(x)=x" probability rises lineary with 100% chance on "x=max_interval").
"sampling" affect probablility in an "c=1-(1-c0)*(1-c1)*...*(1-cx)" exponential way. | [
"x",
"rises",
"by",
"1",
"from",
"0",
"on",
"each",
"iteraton",
"back",
"to",
"0",
"on",
"triggering",
".",
"f",
"(",
"x",
")",
"should",
"rise",
"up",
"to",
"f",
"(",
"max_interval",
")",
"in",
"some",
"way",
"(",
"with",
"default",
"f",
"(",
"x... | train | https://github.com/mk-fg/graphite-metrics/blob/f0ba28d1ed000b2316d3c403206eba78dd7b4c50/graphite_metrics/collectors/__init__.py#L24-L38 |
cknoll/ipydex | ipydex/displaytools.py | get_line_segments | def get_line_segments(line):
"""
Split up a line into lhs, rhs, comment, flags
lhs ist defined as the leftmost assignment
(line does not need to be an assignment)
:param line:
:return: lhs, rhs, comment
"""
line = line.strip()
tokens = tk.generate_tokens(io.StringIO(line).r... | python | def get_line_segments(line):
"""
Split up a line into lhs, rhs, comment, flags
lhs ist defined as the leftmost assignment
(line does not need to be an assignment)
:param line:
:return: lhs, rhs, comment
"""
line = line.strip()
tokens = tk.generate_tokens(io.StringIO(line).r... | [
"def",
"get_line_segments",
"(",
"line",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"tokens",
"=",
"tk",
".",
"generate_tokens",
"(",
"io",
".",
"StringIO",
"(",
"line",
")",
".",
"readline",
")",
"equality_signs",
"=",
"[",
"-",
"1",
"]"... | Split up a line into lhs, rhs, comment, flags
lhs ist defined as the leftmost assignment
(line does not need to be an assignment)
:param line:
:return: lhs, rhs, comment | [
"Split",
"up",
"a",
"line",
"into",
"lhs",
"rhs",
"comment",
"flags"
] | train | https://github.com/cknoll/ipydex/blob/ca528ce4c97ee934e48efbd5983c1b7cd88bec9d/ipydex/displaytools.py#L110-L149 |
cknoll/ipydex | ipydex/displaytools.py | custom_display | def custom_display(lhs, rhs):
"""
lhs: left hand side
rhs: right hand side
This function serves to inject the string for the left hand side
of an assignment
"""
# This code is mainly copied from IPython/display.py
# (IPython version 2.3.0)
kwargs = {}
raw = kwargs.get('raw', Fa... | python | def custom_display(lhs, rhs):
"""
lhs: left hand side
rhs: right hand side
This function serves to inject the string for the left hand side
of an assignment
"""
# This code is mainly copied from IPython/display.py
# (IPython version 2.3.0)
kwargs = {}
raw = kwargs.get('raw', Fa... | [
"def",
"custom_display",
"(",
"lhs",
",",
"rhs",
")",
":",
"# This code is mainly copied from IPython/display.py",
"# (IPython version 2.3.0)",
"kwargs",
"=",
"{",
"}",
"raw",
"=",
"kwargs",
".",
"get",
"(",
"'raw'",
",",
"False",
")",
"include",
"=",
"kwargs",
... | lhs: left hand side
rhs: right hand side
This function serves to inject the string for the left hand side
of an assignment | [
"lhs",
":",
"left",
"hand",
"side",
"rhs",
":",
"right",
"hand",
"side"
] | train | https://github.com/cknoll/ipydex/blob/ca528ce4c97ee934e48efbd5983c1b7cd88bec9d/ipydex/displaytools.py#L242-L307 |
henzk/django-productline | django_productline/features/staticfiles/tasks.py | collectstatic | def collectstatic(force=False):
"""
collect static files for production httpd
If run with ``settings.DEBUG==True``, this is a no-op
unless ``force`` is set to ``True``
"""
# noise reduction: only collectstatic if not in debug mode
from django.conf import settings
if force or not setting... | python | def collectstatic(force=False):
"""
collect static files for production httpd
If run with ``settings.DEBUG==True``, this is a no-op
unless ``force`` is set to ``True``
"""
# noise reduction: only collectstatic if not in debug mode
from django.conf import settings
if force or not setting... | [
"def",
"collectstatic",
"(",
"force",
"=",
"False",
")",
":",
"# noise reduction: only collectstatic if not in debug mode",
"from",
"django",
".",
"conf",
"import",
"settings",
"if",
"force",
"or",
"not",
"settings",
".",
"DEBUG",
":",
"tasks",
".",
"manage",
"(",... | collect static files for production httpd
If run with ``settings.DEBUG==True``, this is a no-op
unless ``force`` is set to ``True`` | [
"collect",
"static",
"files",
"for",
"production",
"httpd"
] | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/features/staticfiles/tasks.py#L8-L22 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.load_manifests | def load_manifests(self):
"""
Loads all plugin manifests on the plugin path
"""
for path in self.plugin_paths:
for item in os.listdir(path):
item_path = os.path.join(path, item)
if os.path.isdir(item_path):
self.load_manifes... | python | def load_manifests(self):
"""
Loads all plugin manifests on the plugin path
"""
for path in self.plugin_paths:
for item in os.listdir(path):
item_path = os.path.join(path, item)
if os.path.isdir(item_path):
self.load_manifes... | [
"def",
"load_manifests",
"(",
"self",
")",
":",
"for",
"path",
"in",
"self",
".",
"plugin_paths",
":",
"for",
"item",
"in",
"os",
".",
"listdir",
"(",
"path",
")",
":",
"item_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"item",
")"... | Loads all plugin manifests on the plugin path | [
"Loads",
"all",
"plugin",
"manifests",
"on",
"the",
"plugin",
"path"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L47-L55 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.load_manifest | def load_manifest(self, path):
"""
Loads a plugin manifest from a given path
:param path: The folder to load the plugin manifest from
"""
manifest_path = os.path.join(path, "plugin.json")
self._logger.debug("Attempting to load plugin manifest from {}.".format(manifest_pa... | python | def load_manifest(self, path):
"""
Loads a plugin manifest from a given path
:param path: The folder to load the plugin manifest from
"""
manifest_path = os.path.join(path, "plugin.json")
self._logger.debug("Attempting to load plugin manifest from {}.".format(manifest_pa... | [
"def",
"load_manifest",
"(",
"self",
",",
"path",
")",
":",
"manifest_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"path",
",",
"\"plugin.json\"",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Attempting to load plugin manifest from {}.\"",
".",
"form... | Loads a plugin manifest from a given path
:param path: The folder to load the plugin manifest from | [
"Loads",
"a",
"plugin",
"manifest",
"from",
"a",
"given",
"path"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L57-L74 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.load_plugin | def load_plugin(self, manifest, *args):
"""
Loads a plugin from the given manifest
:param manifest: The manifest to use to load the plugin
:param args: Arguments to pass to the plugin
"""
if self.get_plugin_loaded(manifest["name"]):
self._logger.debug("Plugin... | python | def load_plugin(self, manifest, *args):
"""
Loads a plugin from the given manifest
:param manifest: The manifest to use to load the plugin
:param args: Arguments to pass to the plugin
"""
if self.get_plugin_loaded(manifest["name"]):
self._logger.debug("Plugin... | [
"def",
"load_plugin",
"(",
"self",
",",
"manifest",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"get_plugin_loaded",
"(",
"manifest",
"[",
"\"name\"",
"]",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Plugin {} is already loaded.\"",
".",
"fo... | Loads a plugin from the given manifest
:param manifest: The manifest to use to load the plugin
:param args: Arguments to pass to the plugin | [
"Loads",
"a",
"plugin",
"from",
"the",
"given",
"manifest"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L96-L152 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.load_plugins | def load_plugins(self, *args):
"""
Loads all plugins
:param args: Arguments to pass to the plugins
"""
for manifest in self._manifests:
self.load_plugin(manifest, *args) | python | def load_plugins(self, *args):
"""
Loads all plugins
:param args: Arguments to pass to the plugins
"""
for manifest in self._manifests:
self.load_plugin(manifest, *args) | [
"def",
"load_plugins",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"manifest",
"in",
"self",
".",
"_manifests",
":",
"self",
".",
"load_plugin",
"(",
"manifest",
",",
"*",
"args",
")"
] | Loads all plugins
:param args: Arguments to pass to the plugins | [
"Loads",
"all",
"plugins"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L154-L161 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.get_all_plugins | def get_all_plugins(self):
"""
Gets all loaded plugins
:return: List of all plugins
"""
return [{
"manifest": i,
"plugin": self.get_plugin(i["name"]),
"module": self.get_module(i["name"])
} for i in self._manifests] | python | def get_all_plugins(self):
"""
Gets all loaded plugins
:return: List of all plugins
"""
return [{
"manifest": i,
"plugin": self.get_plugin(i["name"]),
"module": self.get_module(i["name"])
} for i in self._manifests] | [
"def",
"get_all_plugins",
"(",
"self",
")",
":",
"return",
"[",
"{",
"\"manifest\"",
":",
"i",
",",
"\"plugin\"",
":",
"self",
".",
"get_plugin",
"(",
"i",
"[",
"\"name\"",
"]",
")",
",",
"\"module\"",
":",
"self",
".",
"get_module",
"(",
"i",
"[",
"... | Gets all loaded plugins
:return: List of all plugins | [
"Gets",
"all",
"loaded",
"plugins"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L187-L197 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.reload_manifest | def reload_manifest(self, manifest):
"""
Reloads a manifest from the disk
:param manifest: The manifest to reload
"""
self._logger.debug("Reloading manifest for {}.".format(manifest.get("name", "Unnamed Plugin")))
self._manifests.remove(manifest)
self.load_manifes... | python | def reload_manifest(self, manifest):
"""
Reloads a manifest from the disk
:param manifest: The manifest to reload
"""
self._logger.debug("Reloading manifest for {}.".format(manifest.get("name", "Unnamed Plugin")))
self._manifests.remove(manifest)
self.load_manifes... | [
"def",
"reload_manifest",
"(",
"self",
",",
"manifest",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Reloading manifest for {}.\"",
".",
"format",
"(",
"manifest",
".",
"get",
"(",
"\"name\"",
",",
"\"Unnamed Plugin\"",
")",
")",
")",
"self",
".",... | Reloads a manifest from the disk
:param manifest: The manifest to reload | [
"Reloads",
"a",
"manifest",
"from",
"the",
"disk",
":",
"param",
"manifest",
":",
"The",
"manifest",
"to",
"reload"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L213-L221 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.reload_all_manifests | def reload_all_manifests(self):
"""
Reloads all loaded manifests, and loads any new manifests
"""
self._logger.debug("Reloading all manifests.")
self._manifests = []
self.load_manifests()
self._logger.debug("All manifests reloaded.") | python | def reload_all_manifests(self):
"""
Reloads all loaded manifests, and loads any new manifests
"""
self._logger.debug("Reloading all manifests.")
self._manifests = []
self.load_manifests()
self._logger.debug("All manifests reloaded.") | [
"def",
"reload_all_manifests",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Reloading all manifests.\"",
")",
"self",
".",
"_manifests",
"=",
"[",
"]",
"self",
".",
"load_manifests",
"(",
")",
"self",
".",
"_logger",
".",
"debug",
"... | Reloads all loaded manifests, and loads any new manifests | [
"Reloads",
"all",
"loaded",
"manifests",
"and",
"loads",
"any",
"new",
"manifests"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L223-L230 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.reload_plugin | def reload_plugin(self, name, *args):
"""
Reloads a given plugin
:param name: The name of the plugin
:param args: The args to pass to the plugin
"""
self._logger.debug("Reloading {}.".format(name))
self._logger.debug("Disabling {}.".format(name))
self.ge... | python | def reload_plugin(self, name, *args):
"""
Reloads a given plugin
:param name: The name of the plugin
:param args: The args to pass to the plugin
"""
self._logger.debug("Reloading {}.".format(name))
self._logger.debug("Disabling {}.".format(name))
self.ge... | [
"def",
"reload_plugin",
"(",
"self",
",",
"name",
",",
"*",
"args",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Reloading {}.\"",
".",
"format",
"(",
"name",
")",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Disabling {}.\"",
".",
"fo... | Reloads a given plugin
:param name: The name of the plugin
:param args: The args to pass to the plugin | [
"Reloads",
"a",
"given",
"plugin"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L232-L261 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.reload_all_plugins | def reload_all_plugins(self, *args):
"""
Reloads all initialized plugins
"""
for manifest in self._manifests[:]:
if self.get_plugin(manifest["name"]) is not None:
self.reload_plugin(manifest["name"], *args) | python | def reload_all_plugins(self, *args):
"""
Reloads all initialized plugins
"""
for manifest in self._manifests[:]:
if self.get_plugin(manifest["name"]) is not None:
self.reload_plugin(manifest["name"], *args) | [
"def",
"reload_all_plugins",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"manifest",
"in",
"self",
".",
"_manifests",
"[",
":",
"]",
":",
"if",
"self",
".",
"get_plugin",
"(",
"manifest",
"[",
"\"name\"",
"]",
")",
"is",
"not",
"None",
":",
"self... | Reloads all initialized plugins | [
"Reloads",
"all",
"initialized",
"plugins"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L263-L269 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.unload_plugin | def unload_plugin(self, name):
"""
Unloads a specified plugin
:param name: The name of the plugin
"""
self._logger.debug("Unloading {}.".format(name))
self._logger.debug("Removing plugin instance.")
del self._plugins[name]
self._logger.debug("Unloading m... | python | def unload_plugin(self, name):
"""
Unloads a specified plugin
:param name: The name of the plugin
"""
self._logger.debug("Unloading {}.".format(name))
self._logger.debug("Removing plugin instance.")
del self._plugins[name]
self._logger.debug("Unloading m... | [
"def",
"unload_plugin",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Unloading {}.\"",
".",
"format",
"(",
"name",
")",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Removing plugin instance.\"",
")",
"del",
"self"... | Unloads a specified plugin
:param name: The name of the plugin | [
"Unloads",
"a",
"specified",
"plugin",
":",
"param",
"name",
":",
"The",
"name",
"of",
"the",
"plugin"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L271-L288 |
nint8835/jigsaw | jigsaw/PluginLoader.py | PluginLoader.quickload | def quickload(self, *args):
"""
Loads all manifests, loads all plugins, and then enables all plugins
:param args: The args to pass to the plugin
"""
self.load_manifests()
self.load_plugins(args)
self.enable_all_plugins() | python | def quickload(self, *args):
"""
Loads all manifests, loads all plugins, and then enables all plugins
:param args: The args to pass to the plugin
"""
self.load_manifests()
self.load_plugins(args)
self.enable_all_plugins() | [
"def",
"quickload",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"load_manifests",
"(",
")",
"self",
".",
"load_plugins",
"(",
"args",
")",
"self",
".",
"enable_all_plugins",
"(",
")"
] | Loads all manifests, loads all plugins, and then enables all plugins
:param args: The args to pass to the plugin | [
"Loads",
"all",
"manifests",
"loads",
"all",
"plugins",
"and",
"then",
"enables",
"all",
"plugins",
":",
"param",
"args",
":",
"The",
"args",
"to",
"pass",
"to",
"the",
"plugin"
] | train | https://github.com/nint8835/jigsaw/blob/109e62801a0334652e88ea972a95a341ccc96621/jigsaw/PluginLoader.py#L290-L297 |
SetBased/py-etlt | etlt/reader/UniversalCsvReader.py | UniversalCsvReader.next | def next(self):
"""
Yields the next row from the source files.
"""
for self._filename in self._filenames:
self._open()
for row in self._csv_reader:
self._row_number += 1
if self._fields:
yield dict(zip_longest(se... | python | def next(self):
"""
Yields the next row from the source files.
"""
for self._filename in self._filenames:
self._open()
for row in self._csv_reader:
self._row_number += 1
if self._fields:
yield dict(zip_longest(se... | [
"def",
"next",
"(",
"self",
")",
":",
"for",
"self",
".",
"_filename",
"in",
"self",
".",
"_filenames",
":",
"self",
".",
"_open",
"(",
")",
"for",
"row",
"in",
"self",
".",
"_csv_reader",
":",
"self",
".",
"_row_number",
"+=",
"1",
"if",
"self",
"... | Yields the next row from the source files. | [
"Yields",
"the",
"next",
"row",
"from",
"the",
"source",
"files",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/reader/UniversalCsvReader.py#L105-L121 |
SetBased/py-etlt | etlt/reader/UniversalCsvReader.py | UniversalCsvReader._open_file | def _open_file(self, mode, encoding=None):
"""
Opens the next current file.
:param str mode: The mode for opening the file.
:param str encoding: The encoding of the file.
"""
if self._filename[-4:] == '.bz2':
self._file = bz2.open(self._filename, mode=mode, e... | python | def _open_file(self, mode, encoding=None):
"""
Opens the next current file.
:param str mode: The mode for opening the file.
:param str encoding: The encoding of the file.
"""
if self._filename[-4:] == '.bz2':
self._file = bz2.open(self._filename, mode=mode, e... | [
"def",
"_open_file",
"(",
"self",
",",
"mode",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"self",
".",
"_filename",
"[",
"-",
"4",
":",
"]",
"==",
"'.bz2'",
":",
"self",
".",
"_file",
"=",
"bz2",
".",
"open",
"(",
"self",
".",
"_filename",
","... | Opens the next current file.
:param str mode: The mode for opening the file.
:param str encoding: The encoding of the file. | [
"Opens",
"the",
"next",
"current",
"file",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/reader/UniversalCsvReader.py#L124-L134 |
SetBased/py-etlt | etlt/reader/UniversalCsvReader.py | UniversalCsvReader._get_sample | def _get_sample(self, mode, encoding):
"""
Get a sample from the next current input file.
:param str mode: The mode for opening the file.
:param str|None encoding: The encoding of the file. None for open the file in binary mode.
"""
self._open_file(mode, encoding)
... | python | def _get_sample(self, mode, encoding):
"""
Get a sample from the next current input file.
:param str mode: The mode for opening the file.
:param str|None encoding: The encoding of the file. None for open the file in binary mode.
"""
self._open_file(mode, encoding)
... | [
"def",
"_get_sample",
"(",
"self",
",",
"mode",
",",
"encoding",
")",
":",
"self",
".",
"_open_file",
"(",
"mode",
",",
"encoding",
")",
"self",
".",
"_sample",
"=",
"self",
".",
"_file",
".",
"read",
"(",
"UniversalCsvReader",
".",
"sample_size",
")",
... | Get a sample from the next current input file.
:param str mode: The mode for opening the file.
:param str|None encoding: The encoding of the file. None for open the file in binary mode. | [
"Get",
"a",
"sample",
"from",
"the",
"next",
"current",
"input",
"file",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/reader/UniversalCsvReader.py#L145-L154 |
SetBased/py-etlt | etlt/reader/UniversalCsvReader.py | UniversalCsvReader._detect_delimiter | def _detect_delimiter(self):
"""
Detects the field delimiter in the sample data.
"""
candidate_value = ','
candidate_count = 0
for delimiter in UniversalCsvReader.delimiters:
count = self._sample.count(delimiter)
if count > candidate_count:
... | python | def _detect_delimiter(self):
"""
Detects the field delimiter in the sample data.
"""
candidate_value = ','
candidate_count = 0
for delimiter in UniversalCsvReader.delimiters:
count = self._sample.count(delimiter)
if count > candidate_count:
... | [
"def",
"_detect_delimiter",
"(",
"self",
")",
":",
"candidate_value",
"=",
"','",
"candidate_count",
"=",
"0",
"for",
"delimiter",
"in",
"UniversalCsvReader",
".",
"delimiters",
":",
"count",
"=",
"self",
".",
"_sample",
".",
"count",
"(",
"delimiter",
")",
... | Detects the field delimiter in the sample data. | [
"Detects",
"the",
"field",
"delimiter",
"in",
"the",
"sample",
"data",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/reader/UniversalCsvReader.py#L165-L177 |
SetBased/py-etlt | etlt/reader/UniversalCsvReader.py | UniversalCsvReader._detect_line_ending | def _detect_line_ending(self):
"""
Detects the line ending in the sample data.
"""
candidate_value = '\n'
candidate_count = 0
for line_ending in UniversalCsvReader.line_endings:
count = self._sample.count(line_ending)
if count > candidate_count:
... | python | def _detect_line_ending(self):
"""
Detects the line ending in the sample data.
"""
candidate_value = '\n'
candidate_count = 0
for line_ending in UniversalCsvReader.line_endings:
count = self._sample.count(line_ending)
if count > candidate_count:
... | [
"def",
"_detect_line_ending",
"(",
"self",
")",
":",
"candidate_value",
"=",
"'\\n'",
"candidate_count",
"=",
"0",
"for",
"line_ending",
"in",
"UniversalCsvReader",
".",
"line_endings",
":",
"count",
"=",
"self",
".",
"_sample",
".",
"count",
"(",
"line_ending",... | Detects the line ending in the sample data. | [
"Detects",
"the",
"line",
"ending",
"in",
"the",
"sample",
"data",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/reader/UniversalCsvReader.py#L180-L192 |
SetBased/py-etlt | etlt/reader/UniversalCsvReader.py | UniversalCsvReader._open | def _open(self):
"""
Opens the next current file with proper settings for encoding and delimiter.
"""
self._sample = None
formatting_parameters0 = {'encoding': 'auto',
'delimiter': 'auto',
'line_ter... | python | def _open(self):
"""
Opens the next current file with proper settings for encoding and delimiter.
"""
self._sample = None
formatting_parameters0 = {'encoding': 'auto',
'delimiter': 'auto',
'line_ter... | [
"def",
"_open",
"(",
"self",
")",
":",
"self",
".",
"_sample",
"=",
"None",
"formatting_parameters0",
"=",
"{",
"'encoding'",
":",
"'auto'",
",",
"'delimiter'",
":",
"'auto'",
",",
"'line_terminator'",
":",
"'auto'",
",",
"'escape_char'",
":",
"'\\\\'",
",",... | Opens the next current file with proper settings for encoding and delimiter. | [
"Opens",
"the",
"next",
"current",
"file",
"with",
"proper",
"settings",
"for",
"encoding",
"and",
"delimiter",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/reader/UniversalCsvReader.py#L195-L236 |
crodjer/paster | paster/services.py | BasePaste.list_syntax | def list_syntax(self):
'''
Prints a list of available syntax for the current paste service
'''
syntax_list = ['Available syntax for %s:' %(self)]
logging.info(syntax_list[0])
for key in self.SYNTAX_DICT.keys():
syntax = '\t%-20s%-30s' %(key, self.SYNTAX_DICT[k... | python | def list_syntax(self):
'''
Prints a list of available syntax for the current paste service
'''
syntax_list = ['Available syntax for %s:' %(self)]
logging.info(syntax_list[0])
for key in self.SYNTAX_DICT.keys():
syntax = '\t%-20s%-30s' %(key, self.SYNTAX_DICT[k... | [
"def",
"list_syntax",
"(",
"self",
")",
":",
"syntax_list",
"=",
"[",
"'Available syntax for %s:'",
"%",
"(",
"self",
")",
"]",
"logging",
".",
"info",
"(",
"syntax_list",
"[",
"0",
"]",
")",
"for",
"key",
"in",
"self",
".",
"SYNTAX_DICT",
".",
"keys",
... | Prints a list of available syntax for the current paste service | [
"Prints",
"a",
"list",
"of",
"available",
"syntax",
"for",
"the",
"current",
"paste",
"service"
] | train | https://github.com/crodjer/paster/blob/0cd7230074850ba74e80c740a8bc2502645dd743/paster/services.py#L63-L74 |
crodjer/paster | paster/services.py | BasePaste.process_commmon | def process_commmon(self):
'''
Some data processing common for all services.
No need to override this.
'''
data = self.data
data_content = data['content'][0]
## Paste the output of a command
# This is deprecated after piping support
if data['comma... | python | def process_commmon(self):
'''
Some data processing common for all services.
No need to override this.
'''
data = self.data
data_content = data['content'][0]
## Paste the output of a command
# This is deprecated after piping support
if data['comma... | [
"def",
"process_commmon",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"data",
"data_content",
"=",
"data",
"[",
"'content'",
"]",
"[",
"0",
"]",
"## Paste the output of a command",
"# This is deprecated after piping support",
"if",
"data",
"[",
"'command'",
"... | Some data processing common for all services.
No need to override this. | [
"Some",
"data",
"processing",
"common",
"for",
"all",
"services",
".",
"No",
"need",
"to",
"override",
"this",
"."
] | train | https://github.com/crodjer/paster/blob/0cd7230074850ba74e80c740a8bc2502645dd743/paster/services.py#L76-L121 |
crodjer/paster | paster/services.py | BasePaste.get_response | def get_response(self):
'''
Returns response according submitted the data and method.
'''
self.process_commmon()
self.process_data()
urlencoded_data = urllib.urlencode(self.data)
if self.METHOD == POST:
req = urllib2.Request(self.URL, urlencoded_data)
... | python | def get_response(self):
'''
Returns response according submitted the data and method.
'''
self.process_commmon()
self.process_data()
urlencoded_data = urllib.urlencode(self.data)
if self.METHOD == POST:
req = urllib2.Request(self.URL, urlencoded_data)
... | [
"def",
"get_response",
"(",
"self",
")",
":",
"self",
".",
"process_commmon",
"(",
")",
"self",
".",
"process_data",
"(",
")",
"urlencoded_data",
"=",
"urllib",
".",
"urlencode",
"(",
"self",
".",
"data",
")",
"if",
"self",
".",
"METHOD",
"==",
"POST",
... | Returns response according submitted the data and method. | [
"Returns",
"response",
"according",
"submitted",
"the",
"data",
"and",
"method",
"."
] | train | https://github.com/crodjer/paster/blob/0cd7230074850ba74e80c740a8bc2502645dd743/paster/services.py#L130-L146 |
crodjer/paster | paster/services.py | BasePaste.url | def url(self):
'''
Executes the methods to send request, process the response and then
publishes the url.
'''
self.get_response()
url = self.process_response()
if url:
logging.info('Your paste has been published at %s' %(url))
return url
... | python | def url(self):
'''
Executes the methods to send request, process the response and then
publishes the url.
'''
self.get_response()
url = self.process_response()
if url:
logging.info('Your paste has been published at %s' %(url))
return url
... | [
"def",
"url",
"(",
"self",
")",
":",
"self",
".",
"get_response",
"(",
")",
"url",
"=",
"self",
".",
"process_response",
"(",
")",
"if",
"url",
":",
"logging",
".",
"info",
"(",
"'Your paste has been published at %s'",
"%",
"(",
"url",
")",
")",
"return"... | Executes the methods to send request, process the response and then
publishes the url. | [
"Executes",
"the",
"methods",
"to",
"send",
"request",
"process",
"the",
"response",
"and",
"then",
"publishes",
"the",
"url",
"."
] | train | https://github.com/crodjer/paster/blob/0cd7230074850ba74e80c740a8bc2502645dd743/paster/services.py#L155-L168 |
crodjer/paster | paster/services.py | PastebinPaste.get_api_user_key | def get_api_user_key(self, api_dev_key, username=None, password=None):
'''
Get api user key to enable posts from user accounts if username
and password available.
Not getting an api_user_key means that the posts will be "guest" posts
'''
username = username or get_config(... | python | def get_api_user_key(self, api_dev_key, username=None, password=None):
'''
Get api user key to enable posts from user accounts if username
and password available.
Not getting an api_user_key means that the posts will be "guest" posts
'''
username = username or get_config(... | [
"def",
"get_api_user_key",
"(",
"self",
",",
"api_dev_key",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"username",
"=",
"username",
"or",
"get_config",
"(",
"'pastebin'",
",",
"'api_user_name'",
")",
"password",
"=",
"password",
"o... | Get api user key to enable posts from user accounts if username
and password available.
Not getting an api_user_key means that the posts will be "guest" posts | [
"Get",
"api",
"user",
"key",
"to",
"enable",
"posts",
"from",
"user",
"accounts",
"if",
"username",
"and",
"password",
"available",
".",
"Not",
"getting",
"an",
"api_user_key",
"means",
"that",
"the",
"posts",
"will",
"be",
"guest",
"posts"
] | train | https://github.com/crodjer/paster/blob/0cd7230074850ba74e80c740a8bc2502645dd743/paster/services.py#L282-L305 |
ionelmc/python-cogen | cogen/core/proactors/__init__.py | has_any | def has_any():
"Returns the best available proactor implementation for the current platform."
return get_first(has_ctypes_iocp, has_iocp, has_stdlib_kqueue, has_kqueue,
has_stdlib_epoll, has_epoll, has_poll, has_select) | python | def has_any():
"Returns the best available proactor implementation for the current platform."
return get_first(has_ctypes_iocp, has_iocp, has_stdlib_kqueue, has_kqueue,
has_stdlib_epoll, has_epoll, has_poll, has_select) | [
"def",
"has_any",
"(",
")",
":",
"return",
"get_first",
"(",
"has_ctypes_iocp",
",",
"has_iocp",
",",
"has_stdlib_kqueue",
",",
"has_kqueue",
",",
"has_stdlib_epoll",
",",
"has_epoll",
",",
"has_poll",
",",
"has_select",
")"
] | Returns the best available proactor implementation for the current platform. | [
"Returns",
"the",
"best",
"available",
"proactor",
"implementation",
"for",
"the",
"current",
"platform",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/cogen/core/proactors/__init__.py#L89-L92 |
exa-analytics/exa | exa/core/container.py | Container.copy | def copy(self, name=None, description=None, meta=None):
"""
Create a copy of the current object (may alter the container's name,
description, and update the metadata if needed).
"""
cls = self.__class__
kwargs = self._rel(copy=True)
kwargs.update(self._data(copy=T... | python | def copy(self, name=None, description=None, meta=None):
"""
Create a copy of the current object (may alter the container's name,
description, and update the metadata if needed).
"""
cls = self.__class__
kwargs = self._rel(copy=True)
kwargs.update(self._data(copy=T... | [
"def",
"copy",
"(",
"self",
",",
"name",
"=",
"None",
",",
"description",
"=",
"None",
",",
"meta",
"=",
"None",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"kwargs",
"=",
"self",
".",
"_rel",
"(",
"copy",
"=",
"True",
")",
"kwargs",
".",
"up... | Create a copy of the current object (may alter the container's name,
description, and update the metadata if needed). | [
"Create",
"a",
"copy",
"of",
"the",
"current",
"object",
"(",
"may",
"alter",
"the",
"container",
"s",
"name",
"description",
"and",
"update",
"the",
"metadata",
"if",
"needed",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L35-L49 |
exa-analytics/exa | exa/core/container.py | Container.slice_naive | def slice_naive(self, key):
"""
Naively slice each data object in the container by the object's index.
Args:
key: Int, slice, or list by which to extra "sub"-container
Returns:
sub: Sub container of the same format with a view of the data
Warning:
... | python | def slice_naive(self, key):
"""
Naively slice each data object in the container by the object's index.
Args:
key: Int, slice, or list by which to extra "sub"-container
Returns:
sub: Sub container of the same format with a view of the data
Warning:
... | [
"def",
"slice_naive",
"(",
"self",
",",
"key",
")",
":",
"kwargs",
"=",
"{",
"'name'",
":",
"self",
".",
"name",
",",
"'description'",
":",
"self",
".",
"description",
",",
"'meta'",
":",
"self",
".",
"meta",
"}",
"for",
"name",
",",
"data",
"in",
... | Naively slice each data object in the container by the object's index.
Args:
key: Int, slice, or list by which to extra "sub"-container
Returns:
sub: Sub container of the same format with a view of the data
Warning:
To ensure that a new container is created... | [
"Naively",
"slice",
"each",
"data",
"object",
"in",
"the",
"container",
"by",
"the",
"object",
"s",
"index",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L61-L82 |
exa-analytics/exa | exa/core/container.py | Container.slice_cardinal | def slice_cardinal(self, key):
"""
Slice the container according to its (primary) cardinal axis.
The "cardinal" axis can have any name so long as the name matches a
data object attached to the container. The index name for this object
should also match the value of the cardinal ... | python | def slice_cardinal(self, key):
"""
Slice the container according to its (primary) cardinal axis.
The "cardinal" axis can have any name so long as the name matches a
data object attached to the container. The index name for this object
should also match the value of the cardinal ... | [
"def",
"slice_cardinal",
"(",
"self",
",",
"key",
")",
":",
"if",
"self",
".",
"_cardinal",
":",
"cls",
"=",
"self",
".",
"__class__",
"key",
"=",
"check_key",
"(",
"self",
"[",
"self",
".",
"_cardinal",
"]",
",",
"key",
",",
"cardinal",
"=",
"True",... | Slice the container according to its (primary) cardinal axis.
The "cardinal" axis can have any name so long as the name matches a
data object attached to the container. The index name for this object
should also match the value of the cardinal axis.
The algorithm builds a network graph... | [
"Slice",
"the",
"container",
"according",
"to",
"its",
"(",
"primary",
")",
"cardinal",
"axis",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L84-L144 |
exa-analytics/exa | exa/core/container.py | Container.cardinal_groupby | def cardinal_groupby(self):
"""
Create an instance of this class for every step in the cardinal dimension.
"""
if self._cardinal:
g = self.network(fig=False)
cardinal_indexes = self[self._cardinal].index.values
selfs = {}
cls = self.__class... | python | def cardinal_groupby(self):
"""
Create an instance of this class for every step in the cardinal dimension.
"""
if self._cardinal:
g = self.network(fig=False)
cardinal_indexes = self[self._cardinal].index.values
selfs = {}
cls = self.__class... | [
"def",
"cardinal_groupby",
"(",
"self",
")",
":",
"if",
"self",
".",
"_cardinal",
":",
"g",
"=",
"self",
".",
"network",
"(",
"fig",
"=",
"False",
")",
"cardinal_indexes",
"=",
"self",
"[",
"self",
".",
"_cardinal",
"]",
".",
"index",
".",
"values",
... | Create an instance of this class for every step in the cardinal dimension. | [
"Create",
"an",
"instance",
"of",
"this",
"class",
"for",
"every",
"step",
"in",
"the",
"cardinal",
"dimension",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L146-L181 |
exa-analytics/exa | exa/core/container.py | Container.info | def info(self):
"""
Display information about the container's data objects (note that info
on metadata and visualization objects is also provided).
Note:
Sizes are reported in bytes.
"""
names = []
types = []
sizes = []
names.append('W... | python | def info(self):
"""
Display information about the container's data objects (note that info
on metadata and visualization objects is also provided).
Note:
Sizes are reported in bytes.
"""
names = []
types = []
sizes = []
names.append('W... | [
"def",
"info",
"(",
"self",
")",
":",
"names",
"=",
"[",
"]",
"types",
"=",
"[",
"]",
"sizes",
"=",
"[",
"]",
"names",
".",
"append",
"(",
"'WIDGET'",
")",
"types",
".",
"append",
"(",
"'-'",
")",
"s",
"=",
"0",
"sizes",
".",
"append",
"(",
"... | Display information about the container's data objects (note that info
on metadata and visualization objects is also provided).
Note:
Sizes are reported in bytes. | [
"Display",
"information",
"about",
"the",
"container",
"s",
"data",
"objects",
"(",
"note",
"that",
"info",
"on",
"metadata",
"and",
"visualization",
"objects",
"is",
"also",
"provided",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L183-L213 |
exa-analytics/exa | exa/core/container.py | Container.memory_usage | def memory_usage(self, string=False):
"""
Get the memory usage estimate of the container.
Args:
string (bool): Human readable string (default false)
See Also:
:func:`~exa.core.container.Container.info`
"""
if string:
n = getsizeof(sel... | python | def memory_usage(self, string=False):
"""
Get the memory usage estimate of the container.
Args:
string (bool): Human readable string (default false)
See Also:
:func:`~exa.core.container.Container.info`
"""
if string:
n = getsizeof(sel... | [
"def",
"memory_usage",
"(",
"self",
",",
"string",
"=",
"False",
")",
":",
"if",
"string",
":",
"n",
"=",
"getsizeof",
"(",
"self",
")",
"return",
"' '",
".",
"join",
"(",
"(",
"str",
"(",
"s",
")",
"for",
"s",
"in",
"convert_bytes",
"(",
"n",
")... | Get the memory usage estimate of the container.
Args:
string (bool): Human readable string (default false)
See Also:
:func:`~exa.core.container.Container.info` | [
"Get",
"the",
"memory",
"usage",
"estimate",
"of",
"the",
"container",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L215-L228 |
exa-analytics/exa | exa/core/container.py | Container.network | def network(self, figsize=(14, 9), fig=True):
"""
Display information about the container's object relationships.
Nodes correspond to data objects. The size of the node corresponds
to the size of the table in memory. The color of the node corresponds
to its fundamental data type... | python | def network(self, figsize=(14, 9), fig=True):
"""
Display information about the container's object relationships.
Nodes correspond to data objects. The size of the node corresponds
to the size of the table in memory. The color of the node corresponds
to its fundamental data type... | [
"def",
"network",
"(",
"self",
",",
"figsize",
"=",
"(",
"14",
",",
"9",
")",
",",
"fig",
"=",
"True",
")",
":",
"conn_types",
"=",
"[",
"'index-index'",
",",
"'index-column'",
"]",
"conn_colors",
"=",
"mpl",
".",
"sns",
".",
"color_palette",
"(",
"'... | Display information about the container's object relationships.
Nodes correspond to data objects. The size of the node corresponds
to the size of the table in memory. The color of the node corresponds
to its fundamental data type. Nodes are labeled by their container
name; class informa... | [
"Display",
"information",
"about",
"the",
"container",
"s",
"object",
"relationships",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L230-L331 |
exa-analytics/exa | exa/core/container.py | Container.save | def save(self, path=None, complevel=1, complib='zlib'):
"""
Save the container as an HDF5 archive.
Args:
path (str): Path where to save the container
"""
if path is None:
path = self.hexuid + '.hdf5'
elif os.path.isdir(path):
path += o... | python | def save(self, path=None, complevel=1, complib='zlib'):
"""
Save the container as an HDF5 archive.
Args:
path (str): Path where to save the container
"""
if path is None:
path = self.hexuid + '.hdf5'
elif os.path.isdir(path):
path += o... | [
"def",
"save",
"(",
"self",
",",
"path",
"=",
"None",
",",
"complevel",
"=",
"1",
",",
"complib",
"=",
"'zlib'",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"self",
".",
"hexuid",
"+",
"'.hdf5'",
"elif",
"os",
".",
"path",
".",
"isdir... | Save the container as an HDF5 archive.
Args:
path (str): Path where to save the container | [
"Save",
"the",
"container",
"as",
"an",
"HDF5",
"archive",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L333-L387 |
exa-analytics/exa | exa/core/container.py | Container.load | def load(cls, pkid_or_path=None):
"""
Load a container object from a persistent location or file path.
Args:
pkid_or_path: Integer pkid corresponding to the container table or file path
Returns:
container: The saved container object
"""
path = pk... | python | def load(cls, pkid_or_path=None):
"""
Load a container object from a persistent location or file path.
Args:
pkid_or_path: Integer pkid corresponding to the container table or file path
Returns:
container: The saved container object
"""
path = pk... | [
"def",
"load",
"(",
"cls",
",",
"pkid_or_path",
"=",
"None",
")",
":",
"path",
"=",
"pkid_or_path",
"if",
"isinstance",
"(",
"path",
",",
"(",
"int",
",",
"np",
".",
"int32",
",",
"np",
".",
"int64",
")",
")",
":",
"raise",
"NotImplementedError",
"("... | Load a container object from a persistent location or file path.
Args:
pkid_or_path: Integer pkid corresponding to the container table or file path
Returns:
container: The saved container object | [
"Load",
"a",
"container",
"object",
"from",
"a",
"persistent",
"location",
"or",
"file",
"path",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L394-L426 |
exa-analytics/exa | exa/core/container.py | Container._rel | def _rel(self, copy=False):
"""
Get descriptive kwargs of the container (e.g. name, description, meta).
"""
rel = {}
for key, obj in vars(self).items():
if not isinstance(obj, (pd.Series, pd.DataFrame, pd.SparseSeries, pd.SparseDataFrame)) and not key.startswith('_'):... | python | def _rel(self, copy=False):
"""
Get descriptive kwargs of the container (e.g. name, description, meta).
"""
rel = {}
for key, obj in vars(self).items():
if not isinstance(obj, (pd.Series, pd.DataFrame, pd.SparseSeries, pd.SparseDataFrame)) and not key.startswith('_'):... | [
"def",
"_rel",
"(",
"self",
",",
"copy",
"=",
"False",
")",
":",
"rel",
"=",
"{",
"}",
"for",
"key",
",",
"obj",
"in",
"vars",
"(",
"self",
")",
".",
"items",
"(",
")",
":",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"(",
"pd",
".",
"Series"... | Get descriptive kwargs of the container (e.g. name, description, meta). | [
"Get",
"descriptive",
"kwargs",
"of",
"the",
"container",
"(",
"e",
".",
"g",
".",
"name",
"description",
"meta",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L433-L444 |
exa-analytics/exa | exa/core/container.py | Container._data | def _data(self, copy=False):
"""
Get data kwargs of the container (i.e. dataframe and series objects).
"""
data = {}
for key, obj in vars(self).items():
if isinstance(obj, (pd.Series, pd.DataFrame, pd.SparseSeries, pd.SparseDataFrame)):
if copy:
... | python | def _data(self, copy=False):
"""
Get data kwargs of the container (i.e. dataframe and series objects).
"""
data = {}
for key, obj in vars(self).items():
if isinstance(obj, (pd.Series, pd.DataFrame, pd.SparseSeries, pd.SparseDataFrame)):
if copy:
... | [
"def",
"_data",
"(",
"self",
",",
"copy",
"=",
"False",
")",
":",
"data",
"=",
"{",
"}",
"for",
"key",
",",
"obj",
"in",
"vars",
"(",
"self",
")",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"pd",
".",
"Series",
","... | Get data kwargs of the container (i.e. dataframe and series objects). | [
"Get",
"data",
"kwargs",
"of",
"the",
"container",
"(",
"i",
".",
"e",
".",
"dataframe",
"and",
"series",
"objects",
")",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L446-L457 |
exa-analytics/exa | exa/core/container.py | TypedMeta.create_property | def create_property(name, ptype):
"""
Creates a custom property with a getter that performs computing
functionality (if available) and raise a type error if setting
with the wrong type.
Note:
By default, the setter attempts to convert the object to the
co... | python | def create_property(name, ptype):
"""
Creates a custom property with a getter that performs computing
functionality (if available) and raise a type error if setting
with the wrong type.
Note:
By default, the setter attempts to convert the object to the
co... | [
"def",
"create_property",
"(",
"name",
",",
"ptype",
")",
":",
"pname",
"=",
"'_'",
"+",
"name",
"def",
"getter",
"(",
"self",
")",
":",
"# This will be where the data is store (e.g. self._name)",
"# This is the default property \"getter\" for container data objects.",
"# I... | Creates a custom property with a getter that performs computing
functionality (if available) and raise a type error if setting
with the wrong type.
Note:
By default, the setter attempts to convert the object to the
correct type; a type error is raised if this fails. | [
"Creates",
"a",
"custom",
"property",
"with",
"a",
"getter",
"that",
"performs",
"computing",
"functionality",
"(",
"if",
"available",
")",
"and",
"raise",
"a",
"type",
"error",
"if",
"setting",
"with",
"the",
"wrong",
"type",
"."
] | train | https://github.com/exa-analytics/exa/blob/40fb3c22b531d460dbc51e603de75b856cc28f0d/exa/core/container.py#L538-L576 |
stevelittlefish/easysvg | easysvg/svgrender.py | SvgGenerator._polar_to_cartesian | def _polar_to_cartesian(cx, cy, r, theta):
"""
:param cx: X coord of circle
:param cy: Y coord of circle
:param r: Radius of circle
:param theta: Degrees from vertical, clockwise, in radians
:return: (x, y)
"""
return cx - r * math.sin(theta), cy - r * mat... | python | def _polar_to_cartesian(cx, cy, r, theta):
"""
:param cx: X coord of circle
:param cy: Y coord of circle
:param r: Radius of circle
:param theta: Degrees from vertical, clockwise, in radians
:return: (x, y)
"""
return cx - r * math.sin(theta), cy - r * mat... | [
"def",
"_polar_to_cartesian",
"(",
"cx",
",",
"cy",
",",
"r",
",",
"theta",
")",
":",
"return",
"cx",
"-",
"r",
"*",
"math",
".",
"sin",
"(",
"theta",
")",
",",
"cy",
"-",
"r",
"*",
"math",
".",
"cos",
"(",
"theta",
")"
] | :param cx: X coord of circle
:param cy: Y coord of circle
:param r: Radius of circle
:param theta: Degrees from vertical, clockwise, in radians
:return: (x, y) | [
":",
"param",
"cx",
":",
"X",
"coord",
"of",
"circle",
":",
"param",
"cy",
":",
"Y",
"coord",
"of",
"circle",
":",
"param",
"r",
":",
"Radius",
"of",
"circle",
":",
"param",
"theta",
":",
"Degrees",
"from",
"vertical",
"clockwise",
"in",
"radians",
"... | train | https://github.com/stevelittlefish/easysvg/blob/fd21532147ef29df2dba5b3ca54ce537b44bae62/easysvg/svgrender.py#L41-L49 |
stevelittlefish/easysvg | easysvg/svgrender.py | SvgGenerator.circle | def circle(self, cx, cy, r, stroke=None, fill=None, stroke_width=1):
"""
:param cx: Center X
:param cy: Center Y
:param r: Radius
"""
self.put(' <circle cx="')
self.put(str(cx))
self.put('" cy="')
self.put(str(cy))
self.put('" r="')
... | python | def circle(self, cx, cy, r, stroke=None, fill=None, stroke_width=1):
"""
:param cx: Center X
:param cy: Center Y
:param r: Radius
"""
self.put(' <circle cx="')
self.put(str(cx))
self.put('" cy="')
self.put(str(cy))
self.put('" r="')
... | [
"def",
"circle",
"(",
"self",
",",
"cx",
",",
"cy",
",",
"r",
",",
"stroke",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"stroke_width",
"=",
"1",
")",
":",
"self",
".",
"put",
"(",
"' <circle cx=\"'",
")",
"self",
".",
"put",
"(",
"str",
"(",
... | :param cx: Center X
:param cy: Center Y
:param r: Radius | [
":",
"param",
"cx",
":",
"Center",
"X",
":",
"param",
"cy",
":",
"Center",
"Y",
":",
"param",
"r",
":",
"Radius"
] | train | https://github.com/stevelittlefish/easysvg/blob/fd21532147ef29df2dba5b3ca54ce537b44bae62/easysvg/svgrender.py#L181-L204 |
stevelittlefish/easysvg | easysvg/svgrender.py | SvgGenerator.polygon | def polygon(self, points, stroke=None, fill=None, stroke_width=1, disable_anti_aliasing=False):
"""
:param points: List of points
"""
self.put(' <polygon points="')
self.put(' '.join(['%s,%s' % p for p in points]))
self.put('" stroke-width="')
self.put(str(stroke_... | python | def polygon(self, points, stroke=None, fill=None, stroke_width=1, disable_anti_aliasing=False):
"""
:param points: List of points
"""
self.put(' <polygon points="')
self.put(' '.join(['%s,%s' % p for p in points]))
self.put('" stroke-width="')
self.put(str(stroke_... | [
"def",
"polygon",
"(",
"self",
",",
"points",
",",
"stroke",
"=",
"None",
",",
"fill",
"=",
"None",
",",
"stroke_width",
"=",
"1",
",",
"disable_anti_aliasing",
"=",
"False",
")",
":",
"self",
".",
"put",
"(",
"' <polygon points=\"'",
")",
"self",
".",
... | :param points: List of points | [
":",
"param",
"points",
":",
"List",
"of",
"points"
] | train | https://github.com/stevelittlefish/easysvg/blob/fd21532147ef29df2dba5b3ca54ce537b44bae62/easysvg/svgrender.py#L206-L225 |
stevelittlefish/easysvg | easysvg/svgrender.py | SvgGenerator.arc | def arc(self, cx, cy, r, start_radians, end_radians, fill=None):
"""
NOTE: This will leave gaps between adjacent segments. You can fix this by disabling anti-aliasing using
shape-rendering="crispEdges" on the path tag
If you want to add a stroke to this, it's advisable to cr... | python | def arc(self, cx, cy, r, start_radians, end_radians, fill=None):
"""
NOTE: This will leave gaps between adjacent segments. You can fix this by disabling anti-aliasing using
shape-rendering="crispEdges" on the path tag
If you want to add a stroke to this, it's advisable to cr... | [
"def",
"arc",
"(",
"self",
",",
"cx",
",",
"cy",
",",
"r",
",",
"start_radians",
",",
"end_radians",
",",
"fill",
"=",
"None",
")",
":",
"# This is tricky - we have to use a path, and for that we need to know the start and end points of the arc",
"# in cartesian coordinates... | NOTE: This will leave gaps between adjacent segments. You can fix this by disabling anti-aliasing using
shape-rendering="crispEdges" on the path tag
If you want to add a stroke to this, it's advisable to create a second path that just strokes the
outside of the circle
... | [
"NOTE",
":",
"This",
"will",
"leave",
"gaps",
"between",
"adjacent",
"segments",
".",
"You",
"can",
"fix",
"this",
"by",
"disabling",
"anti",
"-",
"aliasing",
"using",
"shape",
"-",
"rendering",
"=",
"crispEdges",
"on",
"the",
"path",
"tag"
] | train | https://github.com/stevelittlefish/easysvg/blob/fd21532147ef29df2dba5b3ca54ce537b44bae62/easysvg/svgrender.py#L227-L266 |
fhcrc/nestly | nestly/scons.py | name_targets | def name_targets(func):
"""
Wrap a function such that returning ``'a', 'b', 'c', [1, 2, 3]`` transforms
the value into ``dict(a=1, b=2, c=3)``.
This is useful in the case where the last parameter is an SCons command.
"""
def wrap(*a, **kw):
ret = func(*a, **kw)
return dict(zip(r... | python | def name_targets(func):
"""
Wrap a function such that returning ``'a', 'b', 'c', [1, 2, 3]`` transforms
the value into ``dict(a=1, b=2, c=3)``.
This is useful in the case where the last parameter is an SCons command.
"""
def wrap(*a, **kw):
ret = func(*a, **kw)
return dict(zip(r... | [
"def",
"name_targets",
"(",
"func",
")",
":",
"def",
"wrap",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"ret",
"=",
"func",
"(",
"*",
"a",
",",
"*",
"*",
"kw",
")",
"return",
"dict",
"(",
"zip",
"(",
"ret",
"[",
":",
"-",
"1",
"]",
","... | Wrap a function such that returning ``'a', 'b', 'c', [1, 2, 3]`` transforms
the value into ``dict(a=1, b=2, c=3)``.
This is useful in the case where the last parameter is an SCons command. | [
"Wrap",
"a",
"function",
"such",
"that",
"returning",
"a",
"b",
"c",
"[",
"1",
"2",
"3",
"]",
"transforms",
"the",
"value",
"into",
"dict",
"(",
"a",
"=",
"1",
"b",
"=",
"2",
"c",
"=",
"3",
")",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scons.py#L37-L47 |
fhcrc/nestly | nestly/scons.py | SConsWrap.add | def add(self, name, nestable, **kw):
"""
Adds a level to the nesting and creates a checkpoint that can be
reverted to later for aggregation by calling :meth:`SConsWrap.pop`.
:param name: Identifier for the nest level
:param nestable: A nestable object - see
:meth:`Ne... | python | def add(self, name, nestable, **kw):
"""
Adds a level to the nesting and creates a checkpoint that can be
reverted to later for aggregation by calling :meth:`SConsWrap.pop`.
:param name: Identifier for the nest level
:param nestable: A nestable object - see
:meth:`Ne... | [
"def",
"add",
"(",
"self",
",",
"name",
",",
"nestable",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"checkpoints",
"[",
"name",
"]",
"=",
"self",
".",
"nest",
"self",
".",
"nest",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"nest",
")",
"retur... | Adds a level to the nesting and creates a checkpoint that can be
reverted to later for aggregation by calling :meth:`SConsWrap.pop`.
:param name: Identifier for the nest level
:param nestable: A nestable object - see
:meth:`Nest.add() <nestly.core.Nest.add>`.
:param kw: Addi... | [
"Adds",
"a",
"level",
"to",
"the",
"nesting",
"and",
"creates",
"a",
"checkpoint",
"that",
"can",
"be",
"reverted",
"to",
"later",
"for",
"aggregation",
"by",
"calling",
":",
"meth",
":",
"SConsWrap",
".",
"pop",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scons.py#L81-L94 |
fhcrc/nestly | nestly/scons.py | SConsWrap.pop | def pop(self, name=None):
"""
Reverts to the nest stage just before the corresponding call of
:meth:`SConsWrap.add_aggregate`. However, any aggregate collections
which have been worked on will still be accessible, and can be called
operated on together after calling this method.... | python | def pop(self, name=None):
"""
Reverts to the nest stage just before the corresponding call of
:meth:`SConsWrap.add_aggregate`. However, any aggregate collections
which have been worked on will still be accessible, and can be called
operated on together after calling this method.... | [
"def",
"pop",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"not",
"None",
":",
"self",
".",
"nest",
"=",
"self",
".",
"checkpoints",
"[",
"name",
"]",
"keys",
"=",
"list",
"(",
"self",
".",
"checkpoints",
".",
"keys",
"(",... | Reverts to the nest stage just before the corresponding call of
:meth:`SConsWrap.add_aggregate`. However, any aggregate collections
which have been worked on will still be accessible, and can be called
operated on together after calling this method. If no name is passed,
will revert to... | [
"Reverts",
"to",
"the",
"nest",
"stage",
"just",
"before",
"the",
"corresponding",
"call",
"of",
":",
"meth",
":",
"SConsWrap",
".",
"add_aggregate",
".",
"However",
"any",
"aggregate",
"collections",
"which",
"have",
"been",
"worked",
"on",
"will",
"still",
... | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scons.py#L96-L116 |
fhcrc/nestly | nestly/scons.py | SConsWrap.add_nest | def add_nest(self, name=None, **kw):
"""A simple decorator which wraps :meth:`nestly.core.Nest.add`."""
def deco(func):
self.add(name or func.__name__, func, **kw)
return func
return deco | python | def add_nest(self, name=None, **kw):
"""A simple decorator which wraps :meth:`nestly.core.Nest.add`."""
def deco(func):
self.add(name or func.__name__, func, **kw)
return func
return deco | [
"def",
"add_nest",
"(",
"self",
",",
"name",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"def",
"deco",
"(",
"func",
")",
":",
"self",
".",
"add",
"(",
"name",
"or",
"func",
".",
"__name__",
",",
"func",
",",
"*",
"*",
"kw",
")",
"return",
"f... | A simple decorator which wraps :meth:`nestly.core.Nest.add`. | [
"A",
"simple",
"decorator",
"which",
"wraps",
":",
"meth",
":",
"nestly",
".",
"core",
".",
"Nest",
".",
"add",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scons.py#L118-L123 |
fhcrc/nestly | nestly/scons.py | SConsWrap.add_target | def add_target(self, name=None):
"""
Add an SCons target to this nest.
The function decorated will be immediately called with each of the
output directories and current control dictionaries. Each result will
be added to the respective control dictionary for later nests to
... | python | def add_target(self, name=None):
"""
Add an SCons target to this nest.
The function decorated will be immediately called with each of the
output directories and current control dictionaries. Each result will
be added to the respective control dictionary for later nests to
... | [
"def",
"add_target",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"def",
"deco",
"(",
"func",
")",
":",
"def",
"nestfunc",
"(",
"control",
")",
":",
"destdir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"dest_dir",
",",
"control",
... | Add an SCons target to this nest.
The function decorated will be immediately called with each of the
output directories and current control dictionaries. Each result will
be added to the respective control dictionary for later nests to
access.
:param name: Name for the target i... | [
"Add",
"an",
"SCons",
"target",
"to",
"this",
"nest",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scons.py#L136-L155 |
fhcrc/nestly | nestly/scons.py | SConsWrap.add_target_with_env | def add_target_with_env(self, environment, name=None):
"""Add an SCons target to this nest, with an SCons Environment
The function decorated will be immediately called with three arguments:
* ``environment``: A clone of the SCons environment, with variables
populated for all values i... | python | def add_target_with_env(self, environment, name=None):
"""Add an SCons target to this nest, with an SCons Environment
The function decorated will be immediately called with three arguments:
* ``environment``: A clone of the SCons environment, with variables
populated for all values i... | [
"def",
"add_target_with_env",
"(",
"self",
",",
"environment",
",",
"name",
"=",
"None",
")",
":",
"def",
"deco",
"(",
"func",
")",
":",
"def",
"nestfunc",
"(",
"control",
")",
":",
"env",
"=",
"environment",
".",
"Clone",
"(",
")",
"for",
"k",
",",
... | Add an SCons target to this nest, with an SCons Environment
The function decorated will be immediately called with three arguments:
* ``environment``: A clone of the SCons environment, with variables
populated for all values in the control dictionary, plus a variable
``OUTDIR``.
... | [
"Add",
"an",
"SCons",
"target",
"to",
"this",
"nest",
"with",
"an",
"SCons",
"Environment"
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scons.py#L157-L189 |
fhcrc/nestly | nestly/scons.py | SConsWrap.add_aggregate | def add_aggregate(self, name, data_fac):
"""
Add an aggregate target to this nest.
Since nests added after the aggregate can access the construct returned
by the factory function value, it can be mutated to provide additional
values for use when the decorated function is called... | python | def add_aggregate(self, name, data_fac):
"""
Add an aggregate target to this nest.
Since nests added after the aggregate can access the construct returned
by the factory function value, it can be mutated to provide additional
values for use when the decorated function is called... | [
"def",
"add_aggregate",
"(",
"self",
",",
"name",
",",
"data_fac",
")",
":",
"@",
"self",
".",
"add_target",
"(",
"name",
")",
"def",
"wrap",
"(",
"outdir",
",",
"c",
")",
":",
"return",
"data_fac",
"(",
")"
] | Add an aggregate target to this nest.
Since nests added after the aggregate can access the construct returned
by the factory function value, it can be mutated to provide additional
values for use when the decorated function is called.
To do something with the aggregates, you must :met... | [
"Add",
"an",
"aggregate",
"target",
"to",
"this",
"nest",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scons.py#L191-L213 |
fhcrc/nestly | nestly/scons.py | SConsWrap.add_controls | def add_controls(self, env, target_name='control',
file_name='control.json',
encoder_cls=SConsEncoder):
"""
Adds a target to build a control file at each of the current leaves.
:param env: SCons Environment object
:param target_name: Name for ta... | python | def add_controls(self, env, target_name='control',
file_name='control.json',
encoder_cls=SConsEncoder):
"""
Adds a target to build a control file at each of the current leaves.
:param env: SCons Environment object
:param target_name: Name for ta... | [
"def",
"add_controls",
"(",
"self",
",",
"env",
",",
"target_name",
"=",
"'control'",
",",
"file_name",
"=",
"'control.json'",
",",
"encoder_cls",
"=",
"SConsEncoder",
")",
":",
"if",
"not",
"HAS_SCONS",
":",
"raise",
"ImportError",
"(",
"'SCons not available'",... | Adds a target to build a control file at each of the current leaves.
:param env: SCons Environment object
:param target_name: Name for target in nest
:param file_name: Name for output file. | [
"Adds",
"a",
"target",
"to",
"build",
"a",
"control",
"file",
"at",
"each",
"of",
"the",
"current",
"leaves",
"."
] | train | https://github.com/fhcrc/nestly/blob/4d7818b5950f405d2067a6b8577d5afb7527c9ff/nestly/scons.py#L215-L234 |
SetBased/py-etlt | etlt/cleaner/MoneyCleaner.py | MoneyCleaner.clean | def clean(amount):
"""
Converts a number to a number with decimal point.
:param str amount: The input number.
:rtype: str
"""
# Return empty input immediately.
if not amount:
return amount
if re.search(r'[\. ][0-9]{3},[0-9]{1,2}$', amount):
... | python | def clean(amount):
"""
Converts a number to a number with decimal point.
:param str amount: The input number.
:rtype: str
"""
# Return empty input immediately.
if not amount:
return amount
if re.search(r'[\. ][0-9]{3},[0-9]{1,2}$', amount):
... | [
"def",
"clean",
"(",
"amount",
")",
":",
"# Return empty input immediately.",
"if",
"not",
"amount",
":",
"return",
"amount",
"if",
"re",
".",
"search",
"(",
"r'[\\. ][0-9]{3},[0-9]{1,2}$'",
",",
"amount",
")",
":",
"# Assume amount is in 1.123,12 or 1 123,12 format (Du... | Converts a number to a number with decimal point.
:param str amount: The input number.
:rtype: str | [
"Converts",
"a",
"number",
"to",
"a",
"number",
"with",
"decimal",
"point",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/cleaner/MoneyCleaner.py#L18-L43 |
SetBased/py-etlt | etlt/dimension/Type2ReferenceDimension.py | Type2ReferenceDimension.get_id | def get_id(self, natural_key, date, enhancement=None):
"""
Returns the technical ID for a natural key at a date or None if the given natural key is not valid.
:param T natural_key: The natural key.
:param str date: The date in ISO 8601 (YYYY-MM-DD) format.
:param T enhancement: ... | python | def get_id(self, natural_key, date, enhancement=None):
"""
Returns the technical ID for a natural key at a date or None if the given natural key is not valid.
:param T natural_key: The natural key.
:param str date: The date in ISO 8601 (YYYY-MM-DD) format.
:param T enhancement: ... | [
"def",
"get_id",
"(",
"self",
",",
"natural_key",
",",
"date",
",",
"enhancement",
"=",
"None",
")",
":",
"if",
"not",
"date",
":",
"return",
"None",
"# If the natural key is known return the technical ID immediately.",
"if",
"natural_key",
"in",
"self",
".",
"_ma... | Returns the technical ID for a natural key at a date or None if the given natural key is not valid.
:param T natural_key: The natural key.
:param str date: The date in ISO 8601 (YYYY-MM-DD) format.
:param T enhancement: Enhancement data of the dimension row.
:rtype: int|None | [
"Returns",
"the",
"technical",
"ID",
"for",
"a",
"natural",
"key",
"at",
"a",
"date",
"or",
"None",
"if",
"the",
"given",
"natural",
"key",
"is",
"not",
"valid",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/dimension/Type2ReferenceDimension.py#L56-L101 |
celliern/triflow | triflow/core/fields.py | BaseFields.factory | def factory(coords,
dependent_variables,
helper_functions):
"""Fields factory generating specialized container build around a
triflow Model and xarray.
Parameters
----------
coords: iterable of str:
coordinates name. First co... | python | def factory(coords,
dependent_variables,
helper_functions):
"""Fields factory generating specialized container build around a
triflow Model and xarray.
Parameters
----------
coords: iterable of str:
coordinates name. First co... | [
"def",
"factory",
"(",
"coords",
",",
"dependent_variables",
",",
"helper_functions",
")",
":",
"Field",
"=",
"type",
"(",
"'Field'",
",",
"BaseFields",
".",
"__bases__",
",",
"dict",
"(",
"BaseFields",
".",
"__dict__",
")",
")",
"Field",
".",
"_coords",
"... | Fields factory generating specialized container build around a
triflow Model and xarray.
Parameters
----------
coords: iterable of str:
coordinates name. First coordinate have to be shared with all
variables
dependent_variables : iterable tu... | [
"Fields",
"factory",
"generating",
"specialized",
"container",
"build",
"around",
"a",
"triflow",
"Model",
"and",
"xarray",
"."
] | train | https://github.com/celliern/triflow/blob/9522de077c43c8af7d4bf08fbd4ce4b7b480dccb/triflow/core/fields.py#L41-L77 |
celliern/triflow | triflow/core/fields.py | BaseFields.factory1D | def factory1D(dependent_variables,
helper_functions):
"""Fields factory generating specialized container build around a
triflow Model and xarray.
Wrapper for 1D data.
Parameters
----------
dependent_variables : iterable for str
n... | python | def factory1D(dependent_variables,
helper_functions):
"""Fields factory generating specialized container build around a
triflow Model and xarray.
Wrapper for 1D data.
Parameters
----------
dependent_variables : iterable for str
n... | [
"def",
"factory1D",
"(",
"dependent_variables",
",",
"helper_functions",
")",
":",
"return",
"BaseFields",
".",
"factory",
"(",
"(",
"\"x\"",
",",
")",
",",
"[",
"(",
"name",
",",
"(",
"\"x\"",
",",
")",
")",
"for",
"name",
"in",
"dependent_variables",
"... | Fields factory generating specialized container build around a
triflow Model and xarray.
Wrapper for 1D data.
Parameters
----------
dependent_variables : iterable for str
name of the dependent variables
helper_functions : iterable of str
... | [
"Fields",
"factory",
"generating",
"specialized",
"container",
"build",
"around",
"a",
"triflow",
"Model",
"and",
"xarray",
".",
"Wrapper",
"for",
"1D",
"data",
"."
] | train | https://github.com/celliern/triflow/blob/9522de077c43c8af7d4bf08fbd4ce4b7b480dccb/triflow/core/fields.py#L80-L105 |
celliern/triflow | triflow/core/fields.py | BaseFields.uflat | def uflat(self):
"""return a flatten **copy** of the main numpy array with only the
dependant variables.
Be carefull, modification of these data will not be reflected on
the main array!
""" # noqa
aligned_arrays = [self[key].values[[(slice(None)
... | python | def uflat(self):
"""return a flatten **copy** of the main numpy array with only the
dependant variables.
Be carefull, modification of these data will not be reflected on
the main array!
""" # noqa
aligned_arrays = [self[key].values[[(slice(None)
... | [
"def",
"uflat",
"(",
"self",
")",
":",
"# noqa",
"aligned_arrays",
"=",
"[",
"self",
"[",
"key",
"]",
".",
"values",
"[",
"[",
"(",
"slice",
"(",
"None",
")",
"if",
"c",
"in",
"coords",
"else",
"None",
")",
"for",
"c",
"in",
"self",
".",
"_coords... | return a flatten **copy** of the main numpy array with only the
dependant variables.
Be carefull, modification of these data will not be reflected on
the main array! | [
"return",
"a",
"flatten",
"**",
"copy",
"**",
"of",
"the",
"main",
"numpy",
"array",
"with",
"only",
"the",
"dependant",
"variables",
"."
] | train | https://github.com/celliern/triflow/blob/9522de077c43c8af7d4bf08fbd4ce4b7b480dccb/triflow/core/fields.py#L147-L159 |
mk-fg/graphite-metrics | graphite_metrics/collectors/cron_log.py | file_follow_durable | def file_follow_durable( path,
min_dump_interval=10,
xattr_name='user.collectd.logtail.pos', xattr_update=True,
**follow_kwz ):
'''Records log position into xattrs after reading line every
min_dump_interval seconds.
Checksum of the last line at the position
is also recorded (so line itself don't have to ... | python | def file_follow_durable( path,
min_dump_interval=10,
xattr_name='user.collectd.logtail.pos', xattr_update=True,
**follow_kwz ):
'''Records log position into xattrs after reading line every
min_dump_interval seconds.
Checksum of the last line at the position
is also recorded (so line itself don't have to ... | [
"def",
"file_follow_durable",
"(",
"path",
",",
"min_dump_interval",
"=",
"10",
",",
"xattr_name",
"=",
"'user.collectd.logtail.pos'",
",",
"xattr_update",
"=",
"True",
",",
"*",
"*",
"follow_kwz",
")",
":",
"from",
"xattr",
"import",
"xattr",
"from",
"io",
"i... | Records log position into xattrs after reading line every
min_dump_interval seconds.
Checksum of the last line at the position
is also recorded (so line itself don't have to fit into xattr) to make sure
file wasn't truncated between last xattr dump and re-open. | [
"Records",
"log",
"position",
"into",
"xattrs",
"after",
"reading",
"line",
"every",
"min_dump_interval",
"seconds",
".",
"Checksum",
"of",
"the",
"last",
"line",
"at",
"the",
"position",
"is",
"also",
"recorded",
"(",
"so",
"line",
"itself",
"don",
"t",
"ha... | train | https://github.com/mk-fg/graphite-metrics/blob/f0ba28d1ed000b2316d3c403206eba78dd7b4c50/graphite_metrics/collectors/cron_log.py#L78-L135 |
klen/django-netauth | netauth/backends/__init__.py | BaseBackend.complete | def complete(self, request, response):
""" Complete net auth.
"""
extra = self.get_extra_data(response)
data = {}
for form_field, backend_field in self.PROFILE_MAPPING.items():
data[form_field] = self.extract_data(extra, backend_field)
request.session['extra']... | python | def complete(self, request, response):
""" Complete net auth.
"""
extra = self.get_extra_data(response)
data = {}
for form_field, backend_field in self.PROFILE_MAPPING.items():
data[form_field] = self.extract_data(extra, backend_field)
request.session['extra']... | [
"def",
"complete",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"extra",
"=",
"self",
".",
"get_extra_data",
"(",
"response",
")",
"data",
"=",
"{",
"}",
"for",
"form_field",
",",
"backend_field",
"in",
"self",
".",
"PROFILE_MAPPING",
".",
"it... | Complete net auth. | [
"Complete",
"net",
"auth",
"."
] | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/backends/__init__.py#L35-L48 |
klen/django-netauth | netauth/backends/__init__.py | BaseBackend.merge_accounts | def merge_accounts(self, request):
"""
Attach NetID account to regular django
account and then redirect user. In this situation
user dont have to fill extra fields because he filled
them when first account (request.user) was created.
Note that self.indentity must be alre... | python | def merge_accounts(self, request):
"""
Attach NetID account to regular django
account and then redirect user. In this situation
user dont have to fill extra fields because he filled
them when first account (request.user) was created.
Note that self.indentity must be alre... | [
"def",
"merge_accounts",
"(",
"self",
",",
"request",
")",
":",
"# create new net ID record in database",
"# and attach it to request.user account.",
"try",
":",
"netid",
"=",
"NetID",
".",
"objects",
".",
"get",
"(",
"identity",
"=",
"self",
".",
"identity",
",",
... | Attach NetID account to regular django
account and then redirect user. In this situation
user dont have to fill extra fields because he filled
them when first account (request.user) was created.
Note that self.indentity must be already set in this stage by
validate_response func... | [
"Attach",
"NetID",
"account",
"to",
"regular",
"django",
"account",
"and",
"then",
"redirect",
"user",
".",
"In",
"this",
"situation",
"user",
"dont",
"have",
"to",
"fill",
"extra",
"fields",
"because",
"he",
"filled",
"them",
"when",
"first",
"account",
"("... | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/backends/__init__.py#L50-L68 |
klen/django-netauth | netauth/backends/__init__.py | BaseBackend.login_user | def login_user(self, request):
"""
Try to login user by net identity.
Do nothing in case of failure.
"""
# only actavted users can login if activation required.
user = auth.authenticate(identity=self.identity, provider=self.provider)
if user and settings.ACTIVATIO... | python | def login_user(self, request):
"""
Try to login user by net identity.
Do nothing in case of failure.
"""
# only actavted users can login if activation required.
user = auth.authenticate(identity=self.identity, provider=self.provider)
if user and settings.ACTIVATIO... | [
"def",
"login_user",
"(",
"self",
",",
"request",
")",
":",
"# only actavted users can login if activation required.",
"user",
"=",
"auth",
".",
"authenticate",
"(",
"identity",
"=",
"self",
".",
"identity",
",",
"provider",
"=",
"self",
".",
"provider",
")",
"i... | Try to login user by net identity.
Do nothing in case of failure. | [
"Try",
"to",
"login",
"user",
"by",
"net",
"identity",
".",
"Do",
"nothing",
"in",
"case",
"of",
"failure",
"."
] | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/backends/__init__.py#L70-L85 |
klen/django-netauth | netauth/backends/__init__.py | BaseBackend.fill_extra_fields | def fill_extra_fields(self, request, data):
"""
Try to fetch extra data from provider, if this data is enough
to validate settings.EXTRA_FORM then call save method of form
class and login the user.
The extra parameter can be some complex object
this is why we use method ... | python | def fill_extra_fields(self, request, data):
"""
Try to fetch extra data from provider, if this data is enough
to validate settings.EXTRA_FORM then call save method of form
class and login the user.
The extra parameter can be some complex object
this is why we use method ... | [
"def",
"fill_extra_fields",
"(",
"self",
",",
"request",
",",
"data",
")",
":",
"form",
"=",
"str_to_class",
"(",
"settings",
".",
"EXTRA_FORM",
")",
"(",
"data",
")",
"if",
"form",
".",
"is_valid",
"(",
")",
":",
"form",
".",
"save",
"(",
"request",
... | Try to fetch extra data from provider, if this data is enough
to validate settings.EXTRA_FORM then call save method of form
class and login the user.
The extra parameter can be some complex object
this is why we use method function 'extra_data' to
extract data from this object.
... | [
"Try",
"to",
"fetch",
"extra",
"data",
"from",
"provider",
"if",
"this",
"data",
"is",
"enough",
"to",
"validate",
"settings",
".",
"EXTRA_FORM",
"then",
"call",
"save",
"method",
"of",
"form",
"class",
"and",
"login",
"the",
"user",
"."
] | train | https://github.com/klen/django-netauth/blob/228e4297fda98d5f9df35f86a01f87c6fb05ab1d/netauth/backends/__init__.py#L87-L105 |
SetBased/py-etlt | etlt/condition/GlobCondition.py | GlobCondition.match | def match(self, row):
"""
Returns True if the field matches the glob expression of this simple condition. Returns False otherwise.
:param dict row: The row.
:rtype: bool
"""
return fnmatch.fnmatchcase(row[self._field], self._expression) | python | def match(self, row):
"""
Returns True if the field matches the glob expression of this simple condition. Returns False otherwise.
:param dict row: The row.
:rtype: bool
"""
return fnmatch.fnmatchcase(row[self._field], self._expression) | [
"def",
"match",
"(",
"self",
",",
"row",
")",
":",
"return",
"fnmatch",
".",
"fnmatchcase",
"(",
"row",
"[",
"self",
".",
"_field",
"]",
",",
"self",
".",
"_expression",
")"
] | Returns True if the field matches the glob expression of this simple condition. Returns False otherwise.
:param dict row: The row.
:rtype: bool | [
"Returns",
"True",
"if",
"the",
"field",
"matches",
"the",
"glob",
"expression",
"of",
"this",
"simple",
"condition",
".",
"Returns",
"False",
"otherwise",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/condition/GlobCondition.py#L19-L27 |
SetBased/py-etlt | etlt/cleaner/DateCleaner.py | DateCleaner.clean | def clean(date, ignore_time=False):
"""
Converts a date in miscellaneous format to ISO-8601 (YYYY-MM-DD) format.
:param str date: The input date.
:param bool ignore_time: If true any trailing time prt is ignore.
:rtype: str
"""
# Return empty input immediately.
... | python | def clean(date, ignore_time=False):
"""
Converts a date in miscellaneous format to ISO-8601 (YYYY-MM-DD) format.
:param str date: The input date.
:param bool ignore_time: If true any trailing time prt is ignore.
:rtype: str
"""
# Return empty input immediately.
... | [
"def",
"clean",
"(",
"date",
",",
"ignore_time",
"=",
"False",
")",
":",
"# Return empty input immediately.",
"if",
"not",
"date",
":",
"return",
"date",
"parts",
"=",
"re",
".",
"split",
"(",
"r'[\\-/. ]'",
",",
"date",
")",
"if",
"(",
"len",
"(",
"part... | Converts a date in miscellaneous format to ISO-8601 (YYYY-MM-DD) format.
:param str date: The input date.
:param bool ignore_time: If true any trailing time prt is ignore.
:rtype: str | [
"Converts",
"a",
"date",
"in",
"miscellaneous",
"format",
"to",
"ISO",
"-",
"8601",
"(",
"YYYY",
"-",
"MM",
"-",
"DD",
")",
"format",
"."
] | train | https://github.com/SetBased/py-etlt/blob/1c5b8ea60293c14f54d7845a9fe5c595021f66f2/etlt/cleaner/DateCleaner.py#L40-L90 |
justquick/django-native-tags | native_tags/contrib/context.py | template_string | def template_string(context, template):
'Return the rendered template content with the current context'
if not isinstance(context, Context):
context = Context(context)
return Template(template).render(context) | python | def template_string(context, template):
'Return the rendered template content with the current context'
if not isinstance(context, Context):
context = Context(context)
return Template(template).render(context) | [
"def",
"template_string",
"(",
"context",
",",
"template",
")",
":",
"if",
"not",
"isinstance",
"(",
"context",
",",
"Context",
")",
":",
"context",
"=",
"Context",
"(",
"context",
")",
"return",
"Template",
"(",
"template",
")",
".",
"render",
"(",
"con... | Return the rendered template content with the current context | [
"Return",
"the",
"rendered",
"template",
"content",
"with",
"the",
"current",
"context"
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/context.py#L34-L38 |
Maplecroft/Winston | winston/utils.py | raster_to_shape | def raster_to_shape(raster):
"""Take a raster and return a polygon representing the outer edge."""
left = raster.bounds.left
right = raster.bounds.right
top = raster.bounds.top
bottom = raster.bounds.bottom
top_left = (left, top)
top_right = (right, top)
bottom_left = (left, bottom)
... | python | def raster_to_shape(raster):
"""Take a raster and return a polygon representing the outer edge."""
left = raster.bounds.left
right = raster.bounds.right
top = raster.bounds.top
bottom = raster.bounds.bottom
top_left = (left, top)
top_right = (right, top)
bottom_left = (left, bottom)
... | [
"def",
"raster_to_shape",
"(",
"raster",
")",
":",
"left",
"=",
"raster",
".",
"bounds",
".",
"left",
"right",
"=",
"raster",
".",
"bounds",
".",
"right",
"top",
"=",
"raster",
".",
"bounds",
".",
"top",
"bottom",
"=",
"raster",
".",
"bounds",
".",
"... | Take a raster and return a polygon representing the outer edge. | [
"Take",
"a",
"raster",
"and",
"return",
"a",
"polygon",
"representing",
"the",
"outer",
"edge",
"."
] | train | https://github.com/Maplecroft/Winston/blob/d70394c60d5b56d8b374b4db2240394dfd45cfa8/winston/utils.py#L33-L47 |
justquick/django-native-tags | native_tags/contrib/generic_markup.py | apply_markup | def apply_markup(value, arg=None):
"""
Applies text-to-HTML conversion.
Takes an optional argument to specify the name of a filter to use.
"""
if arg is not None:
return formatter(value, filter_name=arg)
return formatter(value) | python | def apply_markup(value, arg=None):
"""
Applies text-to-HTML conversion.
Takes an optional argument to specify the name of a filter to use.
"""
if arg is not None:
return formatter(value, filter_name=arg)
return formatter(value) | [
"def",
"apply_markup",
"(",
"value",
",",
"arg",
"=",
"None",
")",
":",
"if",
"arg",
"is",
"not",
"None",
":",
"return",
"formatter",
"(",
"value",
",",
"filter_name",
"=",
"arg",
")",
"return",
"formatter",
"(",
"value",
")"
] | Applies text-to-HTML conversion.
Takes an optional argument to specify the name of a filter to use. | [
"Applies",
"text",
"-",
"to",
"-",
"HTML",
"conversion",
".",
"Takes",
"an",
"optional",
"argument",
"to",
"specify",
"the",
"name",
"of",
"a",
"filter",
"to",
"use",
"."
] | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/generic_markup.py#L12-L21 |
justquick/django-native-tags | native_tags/contrib/generic_markup.py | smartypants | def smartypants(value):
"""
Applies SmartyPants to a piece of text, applying typographic
niceties.
Requires the Python SmartyPants library to be installed; see
http://web.chad.org/projects/smartypants.py/
"""
try:
from smartypants import smartyPants
except ImportError:
... | python | def smartypants(value):
"""
Applies SmartyPants to a piece of text, applying typographic
niceties.
Requires the Python SmartyPants library to be installed; see
http://web.chad.org/projects/smartypants.py/
"""
try:
from smartypants import smartyPants
except ImportError:
... | [
"def",
"smartypants",
"(",
"value",
")",
":",
"try",
":",
"from",
"smartypants",
"import",
"smartyPants",
"except",
"ImportError",
":",
"if",
"settings",
".",
"DEBUG",
":",
"raise",
"TemplateSyntaxError",
"(",
"\"Error in smartypants filter: the Python smartypants modul... | Applies SmartyPants to a piece of text, applying typographic
niceties.
Requires the Python SmartyPants library to be installed; see
http://web.chad.org/projects/smartypants.py/ | [
"Applies",
"SmartyPants",
"to",
"a",
"piece",
"of",
"text",
"applying",
"typographic",
"niceties",
".",
"Requires",
"the",
"Python",
"SmartyPants",
"library",
"to",
"be",
"installed",
";",
"see",
"http",
":",
"//",
"web",
".",
"chad",
".",
"org",
"/",
"pro... | train | https://github.com/justquick/django-native-tags/blob/d40b976ee1cb13faeb04f0dedf02933d4274abf2/native_tags/contrib/generic_markup.py#L25-L41 |
henzk/django-productline | django_productline/features/multilanguage/settings.py | refine_MIDDLEWARE_CLASSES | def refine_MIDDLEWARE_CLASSES(original):
"""
Django docs say that the LocaleMiddleware should come after the SessionMiddleware.
Here, we make sure that the SessionMiddleware is enabled and then place the
LocaleMiddleware at the correct position.
Be careful with the order when refining the Middleware... | python | def refine_MIDDLEWARE_CLASSES(original):
"""
Django docs say that the LocaleMiddleware should come after the SessionMiddleware.
Here, we make sure that the SessionMiddleware is enabled and then place the
LocaleMiddleware at the correct position.
Be careful with the order when refining the Middleware... | [
"def",
"refine_MIDDLEWARE_CLASSES",
"(",
"original",
")",
":",
"try",
":",
"session_middleware_index",
"=",
"original",
".",
"index",
"(",
"'django.contrib.sessions.middleware.SessionMiddleware'",
")",
"original",
".",
"insert",
"(",
"session_middleware_index",
"+",
"1",
... | Django docs say that the LocaleMiddleware should come after the SessionMiddleware.
Here, we make sure that the SessionMiddleware is enabled and then place the
LocaleMiddleware at the correct position.
Be careful with the order when refining the MiddlewareClasses with following features.
:param original:... | [
"Django",
"docs",
"say",
"that",
"the",
"LocaleMiddleware",
"should",
"come",
"after",
"the",
"SessionMiddleware",
".",
"Here",
"we",
"make",
"sure",
"that",
"the",
"SessionMiddleware",
"is",
"enabled",
"and",
"then",
"place",
"the",
"LocaleMiddleware",
"at",
"t... | train | https://github.com/henzk/django-productline/blob/24ff156924c1a8c07b99cbb8a1de0a42b8d81f60/django_productline/features/multilanguage/settings.py#L18-L33 |
seibert-media/Highton | highton/call_mixins/list_call_mixin.py | ListCallMixin.list | def list(cls, params=None):
"""
Retrieves a list of the model
:param params: params as dictionary
:type params: dict
:return: the list of the parsed xml objects
:rtype: list
"""
return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
... | python | def list(cls, params=None):
"""
Retrieves a list of the model
:param params: params as dictionary
:type params: dict
:return: the list of the parsed xml objects
:rtype: list
"""
return fields.ListField(name=cls.ENDPOINT, init_class=cls).decode(
... | [
"def",
"list",
"(",
"cls",
",",
"params",
"=",
"None",
")",
":",
"return",
"fields",
".",
"ListField",
"(",
"name",
"=",
"cls",
".",
"ENDPOINT",
",",
"init_class",
"=",
"cls",
")",
".",
"decode",
"(",
"cls",
".",
"element_from_string",
"(",
"cls",
".... | Retrieves a list of the model
:param params: params as dictionary
:type params: dict
:return: the list of the parsed xml objects
:rtype: list | [
"Retrieves",
"a",
"list",
"of",
"the",
"model"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/list_call_mixin.py#L12-L23 |
ionelmc/python-cogen | examples/cogen-chat/ChatApp/chatapp/websetup.py | setup_config | def setup_config(command, filename, section, vars):
"""Place any commands to setup chatapp here"""
confuri = "config:" + filename
if ":" in section:
confuri += "#" + section.rsplit(":", 1)[-1]
conf = appconfig(confuri)
load_environment(conf.global_conf, conf.local_conf) | python | def setup_config(command, filename, section, vars):
"""Place any commands to setup chatapp here"""
confuri = "config:" + filename
if ":" in section:
confuri += "#" + section.rsplit(":", 1)[-1]
conf = appconfig(confuri)
load_environment(conf.global_conf, conf.local_conf) | [
"def",
"setup_config",
"(",
"command",
",",
"filename",
",",
"section",
",",
"vars",
")",
":",
"confuri",
"=",
"\"config:\"",
"+",
"filename",
"if",
"\":\"",
"in",
"section",
":",
"confuri",
"+=",
"\"#\"",
"+",
"section",
".",
"rsplit",
"(",
"\":\"",
","... | Place any commands to setup chatapp here | [
"Place",
"any",
"commands",
"to",
"setup",
"chatapp",
"here"
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-chat/ChatApp/chatapp/websetup.py#L11-L18 |
ionelmc/python-cogen | examples/cogen-chat/ChatApp/chatapp/controllers/chat.py | Client.watch | def watch(self):
"""This is a coroutine that runs permanently for each participant to the
chat. If the participant has more than 10 unpulled messages this
coroutine will die.
`pubsub` is a queue that hosts the messages from all the
participants.
* subscribe regi... | python | def watch(self):
"""This is a coroutine that runs permanently for each participant to the
chat. If the participant has more than 10 unpulled messages this
coroutine will die.
`pubsub` is a queue that hosts the messages from all the
participants.
* subscribe regi... | [
"def",
"watch",
"(",
"self",
")",
":",
"yield",
"pubsub",
".",
"subscribe",
"(",
")",
"while",
"1",
":",
"messages",
"=",
"yield",
"pubsub",
".",
"fetch",
"(",
")",
"print",
"messages",
"try",
":",
"yield",
"self",
".",
"messages",
".",
"put_nowait",
... | This is a coroutine that runs permanently for each participant to the
chat. If the participant has more than 10 unpulled messages this
coroutine will die.
`pubsub` is a queue that hosts the messages from all the
participants.
* subscribe registers this coro to the queue
... | [
"This",
"is",
"a",
"coroutine",
"that",
"runs",
"permanently",
"for",
"each",
"participant",
"to",
"the",
"chat",
".",
"If",
"the",
"participant",
"has",
"more",
"than",
"10",
"unpulled",
"messages",
"this",
"coroutine",
"will",
"die",
".",
"pubsub",
"is",
... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-chat/ChatApp/chatapp/controllers/chat.py#L24-L47 |
ionelmc/python-cogen | examples/cogen-chat/ChatApp/chatapp/controllers/chat.py | ChatController.push | def push(self):
"""This action puts a message in the global queue that all the clients
will get via the 'pull' action."""
print `request.body`
yield request.environ['cogen.call'](pubsub.publish)(
"%s: %s" % (session['client'].name, request.body)
)
# the... | python | def push(self):
"""This action puts a message in the global queue that all the clients
will get via the 'pull' action."""
print `request.body`
yield request.environ['cogen.call'](pubsub.publish)(
"%s: %s" % (session['client'].name, request.body)
)
# the... | [
"def",
"push",
"(",
"self",
")",
":",
"print",
"`request.body`",
"yield",
"request",
".",
"environ",
"[",
"'cogen.call'",
"]",
"(",
"pubsub",
".",
"publish",
")",
"(",
"\"%s: %s\"",
"%",
"(",
"session",
"[",
"'client'",
"]",
".",
"name",
",",
"request",
... | This action puts a message in the global queue that all the clients
will get via the 'pull' action. | [
"This",
"action",
"puts",
"a",
"message",
"in",
"the",
"global",
"queue",
"that",
"all",
"the",
"clients",
"will",
"get",
"via",
"the",
"pull",
"action",
"."
] | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-chat/ChatApp/chatapp/controllers/chat.py#L50-L61 |
ionelmc/python-cogen | examples/cogen-chat/ChatApp/chatapp/controllers/chat.py | ChatController.pull | def pull(self):
"""This action does some state checking (adds a object in the session
that will identify this chat participant and adds a coroutine to manage
it's state) and gets new messages or bail out in 10 seconds if there are
no messages."""
if not 'client' in session o... | python | def pull(self):
"""This action does some state checking (adds a object in the session
that will identify this chat participant and adds a coroutine to manage
it's state) and gets new messages or bail out in 10 seconds if there are
no messages."""
if not 'client' in session o... | [
"def",
"pull",
"(",
"self",
")",
":",
"if",
"not",
"'client'",
"in",
"session",
"or",
"session",
"[",
"'client'",
"]",
".",
"dead",
":",
"client",
"=",
"Client",
"(",
"str",
"(",
"request",
".",
"environ",
"[",
"'pylons.routes_dict'",
"]",
"[",
"'id'",... | This action does some state checking (adds a object in the session
that will identify this chat participant and adds a coroutine to manage
it's state) and gets new messages or bail out in 10 seconds if there are
no messages. | [
"This",
"action",
"does",
"some",
"state",
"checking",
"(",
"adds",
"a",
"object",
"in",
"the",
"session",
"that",
"will",
"identify",
"this",
"chat",
"participant",
"and",
"adds",
"a",
"coroutine",
"to",
"manage",
"it",
"s",
"state",
")",
"and",
"gets",
... | train | https://github.com/ionelmc/python-cogen/blob/83b0edb88425eba6e5bfda9f1dcd34642517e2a8/examples/cogen-chat/ChatApp/chatapp/controllers/chat.py#L63-L86 |
erikdejonge/arguments | examples/classbased.py | main | def main():
"""
main
"""
args = MainArguments()
if args.tool.lower() == "tool1":
args = Tool1Arguments()
elif args.tool.lower() == "tool2":
args = Tool2Arguments()
else:
print("Unknown tool", args.tool)
print(args) | python | def main():
"""
main
"""
args = MainArguments()
if args.tool.lower() == "tool1":
args = Tool1Arguments()
elif args.tool.lower() == "tool2":
args = Tool2Arguments()
else:
print("Unknown tool", args.tool)
print(args) | [
"def",
"main",
"(",
")",
":",
"args",
"=",
"MainArguments",
"(",
")",
"if",
"args",
".",
"tool",
".",
"lower",
"(",
")",
"==",
"\"tool1\"",
":",
"args",
"=",
"Tool1Arguments",
"(",
")",
"elif",
"args",
".",
"tool",
".",
"lower",
"(",
")",
"==",
"... | main | [
"main"
] | train | https://github.com/erikdejonge/arguments/blob/fc222d3989d459343a81944cabb56854014335ed/examples/classbased.py#L98-L111 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/manager.py | get_or_create_home_repo | def get_or_create_home_repo(reset=False):
"""
Check to make sure we never operate with a non-existing local repo
"""
dosetup = True
if os.path.exists(ONTOSPY_LOCAL):
dosetup = False
if reset:
import shutil
var = input("Delete the local library and all of its contents? (y/n) ")
if var == "y":
shut... | python | def get_or_create_home_repo(reset=False):
"""
Check to make sure we never operate with a non-existing local repo
"""
dosetup = True
if os.path.exists(ONTOSPY_LOCAL):
dosetup = False
if reset:
import shutil
var = input("Delete the local library and all of its contents? (y/n) ")
if var == "y":
shut... | [
"def",
"get_or_create_home_repo",
"(",
"reset",
"=",
"False",
")",
":",
"dosetup",
"=",
"True",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"ONTOSPY_LOCAL",
")",
":",
"dosetup",
"=",
"False",
"if",
"reset",
":",
"import",
"shutil",
"var",
"=",
"input",
... | Check to make sure we never operate with a non-existing local repo | [
"Check",
"to",
"make",
"sure",
"we",
"never",
"operate",
"with",
"a",
"non",
"-",
"existing",
"local",
"repo"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/manager.py#L14-L54 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/manager.py | get_pickled_ontology | def get_pickled_ontology(filename):
""" try to retrieve a cached ontology """
pickledfile = ONTOSPY_LOCAL_CACHE + "/" + filename + ".pickle"
if GLOBAL_DISABLE_CACHE:
printDebug("WARNING: DEMO MODE cache has been disabled in __init__.py ==============", "red")
if os.path.isfile(pickledfile) and not GLOBAL_DISABLE_... | python | def get_pickled_ontology(filename):
""" try to retrieve a cached ontology """
pickledfile = ONTOSPY_LOCAL_CACHE + "/" + filename + ".pickle"
if GLOBAL_DISABLE_CACHE:
printDebug("WARNING: DEMO MODE cache has been disabled in __init__.py ==============", "red")
if os.path.isfile(pickledfile) and not GLOBAL_DISABLE_... | [
"def",
"get_pickled_ontology",
"(",
"filename",
")",
":",
"pickledfile",
"=",
"ONTOSPY_LOCAL_CACHE",
"+",
"\"/\"",
"+",
"filename",
"+",
"\".pickle\"",
"if",
"GLOBAL_DISABLE_CACHE",
":",
"printDebug",
"(",
"\"WARNING: DEMO MODE cache has been disabled in __init__.py =========... | try to retrieve a cached ontology | [
"try",
"to",
"retrieve",
"a",
"cached",
"ontology"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/manager.py#L102-L114 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/manager.py | del_pickled_ontology | def del_pickled_ontology(filename):
""" try to remove a cached ontology """
pickledfile = ONTOSPY_LOCAL_CACHE + "/" + filename + ".pickle"
if os.path.isfile(pickledfile) and not GLOBAL_DISABLE_CACHE:
os.remove(pickledfile)
return True
else:
return None | python | def del_pickled_ontology(filename):
""" try to remove a cached ontology """
pickledfile = ONTOSPY_LOCAL_CACHE + "/" + filename + ".pickle"
if os.path.isfile(pickledfile) and not GLOBAL_DISABLE_CACHE:
os.remove(pickledfile)
return True
else:
return None | [
"def",
"del_pickled_ontology",
"(",
"filename",
")",
":",
"pickledfile",
"=",
"ONTOSPY_LOCAL_CACHE",
"+",
"\"/\"",
"+",
"filename",
"+",
"\".pickle\"",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"pickledfile",
")",
"and",
"not",
"GLOBAL_DISABLE_CACHE",
":",
... | try to remove a cached ontology | [
"try",
"to",
"remove",
"a",
"cached",
"ontology"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/manager.py#L117-L124 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/manager.py | rename_pickled_ontology | def rename_pickled_ontology(filename, newname):
""" try to rename a cached ontology """
pickledfile = ONTOSPY_LOCAL_CACHE + "/" + filename + ".pickle"
newpickledfile = ONTOSPY_LOCAL_CACHE + "/" + newname + ".pickle"
if os.path.isfile(pickledfile) and not GLOBAL_DISABLE_CACHE:
os.rename(pickledfile, newpickledfile... | python | def rename_pickled_ontology(filename, newname):
""" try to rename a cached ontology """
pickledfile = ONTOSPY_LOCAL_CACHE + "/" + filename + ".pickle"
newpickledfile = ONTOSPY_LOCAL_CACHE + "/" + newname + ".pickle"
if os.path.isfile(pickledfile) and not GLOBAL_DISABLE_CACHE:
os.rename(pickledfile, newpickledfile... | [
"def",
"rename_pickled_ontology",
"(",
"filename",
",",
"newname",
")",
":",
"pickledfile",
"=",
"ONTOSPY_LOCAL_CACHE",
"+",
"\"/\"",
"+",
"filename",
"+",
"\".pickle\"",
"newpickledfile",
"=",
"ONTOSPY_LOCAL_CACHE",
"+",
"\"/\"",
"+",
"newname",
"+",
"\".pickle\"",... | try to rename a cached ontology | [
"try",
"to",
"rename",
"a",
"cached",
"ontology"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/manager.py#L127-L135 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/manager.py | do_pickle_ontology | def do_pickle_ontology(filename, g=None):
"""
from a valid filename, generate the graph instance and pickle it too
note: option to pass a pre-generated graph instance too
2015-09-17: added code to increase recursion limit if cPickle fails
see http://stackoverflow.com/questions/2134706/hitting-maximum-recursion-de... | python | def do_pickle_ontology(filename, g=None):
"""
from a valid filename, generate the graph instance and pickle it too
note: option to pass a pre-generated graph instance too
2015-09-17: added code to increase recursion limit if cPickle fails
see http://stackoverflow.com/questions/2134706/hitting-maximum-recursion-de... | [
"def",
"do_pickle_ontology",
"(",
"filename",
",",
"g",
"=",
"None",
")",
":",
"ONTOSPY_LOCAL_MODELS",
"=",
"get_home_location",
"(",
")",
"pickledpath",
"=",
"ONTOSPY_LOCAL_CACHE",
"+",
"\"/\"",
"+",
"filename",
"+",
"\".pickle\"",
"if",
"not",
"g",
":",
"g",... | from a valid filename, generate the graph instance and pickle it too
note: option to pass a pre-generated graph instance too
2015-09-17: added code to increase recursion limit if cPickle fails
see http://stackoverflow.com/questions/2134706/hitting-maximum-recursion-depth-using-pythons-pickle-cpickle | [
"from",
"a",
"valid",
"filename",
"generate",
"the",
"graph",
"instance",
"and",
"pickle",
"it",
"too",
"note",
":",
"option",
"to",
"pass",
"a",
"pre",
"-",
"generated",
"graph",
"instance",
"too",
"2015",
"-",
"09",
"-",
"17",
":",
"added",
"code",
"... | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/manager.py#L138-L167 |
seibert-media/Highton | highton/call_mixins/update_call_mixin.py | UpdateCallMixin.update | def update(self):
"""
Updates the object
:return:
:rtype: response
"""
return self._put_request(
data=self.element_to_string(
self.encode()
),
endpoint=self.ENDPOINT + '/' + str(self.id)
) | python | def update(self):
"""
Updates the object
:return:
:rtype: response
"""
return self._put_request(
data=self.element_to_string(
self.encode()
),
endpoint=self.ENDPOINT + '/' + str(self.id)
) | [
"def",
"update",
"(",
"self",
")",
":",
"return",
"self",
".",
"_put_request",
"(",
"data",
"=",
"self",
".",
"element_to_string",
"(",
"self",
".",
"encode",
"(",
")",
")",
",",
"endpoint",
"=",
"self",
".",
"ENDPOINT",
"+",
"'/'",
"+",
"str",
"(",
... | Updates the object
:return:
:rtype: response | [
"Updates",
"the",
"object"
] | train | https://github.com/seibert-media/Highton/blob/1519e4fb105f62882c2e7bc81065d994649558d8/highton/call_mixins/update_call_mixin.py#L10-L22 |
DavidMStraub/ckmutil | ckmutil/phases.py | mixing_phases | def mixing_phases(U):
"""Return the angles and CP phases of the CKM or PMNS matrix
in standard parametrization, starting from a matrix with arbitrary phase
convention."""
f = {}
# angles
f['t13'] = asin(abs(U[0,2]))
if U[0,0] == 0:
f['t12'] = pi/2
else:
f['t12'] = atan(ab... | python | def mixing_phases(U):
"""Return the angles and CP phases of the CKM or PMNS matrix
in standard parametrization, starting from a matrix with arbitrary phase
convention."""
f = {}
# angles
f['t13'] = asin(abs(U[0,2]))
if U[0,0] == 0:
f['t12'] = pi/2
else:
f['t12'] = atan(ab... | [
"def",
"mixing_phases",
"(",
"U",
")",
":",
"f",
"=",
"{",
"}",
"# angles",
"f",
"[",
"'t13'",
"]",
"=",
"asin",
"(",
"abs",
"(",
"U",
"[",
"0",
",",
"2",
"]",
")",
")",
"if",
"U",
"[",
"0",
",",
"0",
"]",
"==",
"0",
":",
"f",
"[",
"'t1... | Return the angles and CP phases of the CKM or PMNS matrix
in standard parametrization, starting from a matrix with arbitrary phase
convention. | [
"Return",
"the",
"angles",
"and",
"CP",
"phases",
"of",
"the",
"CKM",
"or",
"PMNS",
"matrix",
"in",
"standard",
"parametrization",
"starting",
"from",
"a",
"matrix",
"with",
"arbitrary",
"phase",
"convention",
"."
] | train | https://github.com/DavidMStraub/ckmutil/blob/b6e9cf368c18f2dbc7c8a6ce01242c2f5b58207a/ckmutil/phases.py#L8-L40 |
DavidMStraub/ckmutil | ckmutil/phases.py | rephase_standard | def rephase_standard(UuL, UdL, UuR, UdR):
"""Function to rephase the quark rotation matrices in order to
obtain the CKM matrix in standard parametrization.
The input matrices are assumed to diagonalize the up-type and down-type
quark matrices like
```
UuL.conj().T @ Mu @ UuR = Mu_diag
UdL.... | python | def rephase_standard(UuL, UdL, UuR, UdR):
"""Function to rephase the quark rotation matrices in order to
obtain the CKM matrix in standard parametrization.
The input matrices are assumed to diagonalize the up-type and down-type
quark matrices like
```
UuL.conj().T @ Mu @ UuR = Mu_diag
UdL.... | [
"def",
"rephase_standard",
"(",
"UuL",
",",
"UdL",
",",
"UuR",
",",
"UdR",
")",
":",
"K",
"=",
"UuL",
".",
"conj",
"(",
")",
".",
"T",
"@",
"UdL",
"f",
"=",
"mixing_phases",
"(",
"K",
")",
"Fdelta",
"=",
"np",
".",
"diag",
"(",
"np",
".",
"ex... | Function to rephase the quark rotation matrices in order to
obtain the CKM matrix in standard parametrization.
The input matrices are assumed to diagonalize the up-type and down-type
quark matrices like
```
UuL.conj().T @ Mu @ UuR = Mu_diag
UdL.conj().T @ Md @ UdR = Md_diag
```
The CK... | [
"Function",
"to",
"rephase",
"the",
"quark",
"rotation",
"matrices",
"in",
"order",
"to",
"obtain",
"the",
"CKM",
"matrix",
"in",
"standard",
"parametrization",
"."
] | train | https://github.com/DavidMStraub/ckmutil/blob/b6e9cf368c18f2dbc7c8a6ce01242c2f5b58207a/ckmutil/phases.py#L42-L62 |
DavidMStraub/ckmutil | ckmutil/phases.py | rephase_pmns_standard | def rephase_pmns_standard(Unu, UeL, UeR):
"""Function to rephase the lepton rotation matrices in order to
obtain the PMNS matrix in standard parametrization.
The input matrices are assumed to diagonalize the charged lepton and
neutrino mass matrices like
```
UeL.conj().T @ Me @ UeR = Me_diag
... | python | def rephase_pmns_standard(Unu, UeL, UeR):
"""Function to rephase the lepton rotation matrices in order to
obtain the PMNS matrix in standard parametrization.
The input matrices are assumed to diagonalize the charged lepton and
neutrino mass matrices like
```
UeL.conj().T @ Me @ UeR = Me_diag
... | [
"def",
"rephase_pmns_standard",
"(",
"Unu",
",",
"UeL",
",",
"UeR",
")",
":",
"U",
"=",
"UeL",
".",
"conj",
"(",
")",
".",
"T",
"@",
"Unu",
"f",
"=",
"mixing_phases",
"(",
"U",
")",
"Fdelta",
"=",
"np",
".",
"diag",
"(",
"np",
".",
"exp",
"(",
... | Function to rephase the lepton rotation matrices in order to
obtain the PMNS matrix in standard parametrization.
The input matrices are assumed to diagonalize the charged lepton and
neutrino mass matrices like
```
UeL.conj().T @ Me @ UeR = Me_diag
Unu.T @ Mnu @ Unu = Mnu_diag
```
The ... | [
"Function",
"to",
"rephase",
"the",
"lepton",
"rotation",
"matrices",
"in",
"order",
"to",
"obtain",
"the",
"PMNS",
"matrix",
"in",
"standard",
"parametrization",
"."
] | train | https://github.com/DavidMStraub/ckmutil/blob/b6e9cf368c18f2dbc7c8a6ce01242c2f5b58207a/ckmutil/phases.py#L64-L83 |
alexmojaki/outdated | outdated/__init__.py | check_outdated | def check_outdated(package, version):
"""
Given the name of a package on PyPI and a version (both strings), checks
if the given version is the latest version of the package available.
Returns a 2-tuple (is_outdated, latest_version) where
is_outdated is a boolean which is True if the given version i... | python | def check_outdated(package, version):
"""
Given the name of a package on PyPI and a version (both strings), checks
if the given version is the latest version of the package available.
Returns a 2-tuple (is_outdated, latest_version) where
is_outdated is a boolean which is True if the given version i... | [
"def",
"check_outdated",
"(",
"package",
",",
"version",
")",
":",
"from",
"pkg_resources",
"import",
"parse_version",
"parsed_version",
"=",
"parse_version",
"(",
"version",
")",
"latest",
"=",
"None",
"with",
"utils",
".",
"cache_file",
"(",
"package",
",",
... | Given the name of a package on PyPI and a version (both strings), checks
if the given version is the latest version of the package available.
Returns a 2-tuple (is_outdated, latest_version) where
is_outdated is a boolean which is True if the given version is earlier
than the latest version, which is th... | [
"Given",
"the",
"name",
"of",
"a",
"package",
"on",
"PyPI",
"and",
"a",
"version",
"(",
"both",
"strings",
")",
"checks",
"if",
"the",
"given",
"version",
"is",
"the",
"latest",
"version",
"of",
"the",
"package",
"available",
"."
] | train | https://github.com/alexmojaki/outdated/blob/565bb3fe1adc30da5e50249912cd2ac494662659/outdated/__init__.py#L12-L65 |
alexmojaki/outdated | outdated/__init__.py | warn_if_outdated | def warn_if_outdated(package,
version,
raise_exceptions=False,
background=True,
):
"""
Higher level convenience function using check_outdated.
The package and version arguments are the same.
If the package is outdated,... | python | def warn_if_outdated(package,
version,
raise_exceptions=False,
background=True,
):
"""
Higher level convenience function using check_outdated.
The package and version arguments are the same.
If the package is outdated,... | [
"def",
"warn_if_outdated",
"(",
"package",
",",
"version",
",",
"raise_exceptions",
"=",
"False",
",",
"background",
"=",
"True",
",",
")",
":",
"def",
"check",
"(",
")",
":",
"# noinspection PyUnusedLocal",
"is_outdated",
"=",
"False",
"with",
"utils",
".",
... | Higher level convenience function using check_outdated.
The package and version arguments are the same.
If the package is outdated, a warning (OutdatedPackageWarning) will
be emitted.
Any exception in check_outdated will be converted to a warning (OutdatedCheckFailedWarning)
unless raise_exceptio... | [
"Higher",
"level",
"convenience",
"function",
"using",
"check_outdated",
"."
] | train | https://github.com/alexmojaki/outdated/blob/565bb3fe1adc30da5e50249912cd2ac494662659/outdated/__init__.py#L68-L112 |
celliern/triflow | triflow/core/model.py | _generate_sympify_namespace | def _generate_sympify_namespace(
independent_variables, dependent_variables, helper_functions
):
"""Generate the link between the symbols of the derivatives and the
sympy Derivative operation.
Parameters
----------
independent_variable : str
name of the independant variable ("... | python | def _generate_sympify_namespace(
independent_variables, dependent_variables, helper_functions
):
"""Generate the link between the symbols of the derivatives and the
sympy Derivative operation.
Parameters
----------
independent_variable : str
name of the independant variable ("... | [
"def",
"_generate_sympify_namespace",
"(",
"independent_variables",
",",
"dependent_variables",
",",
"helper_functions",
")",
":",
"# noqa",
"independent_variable",
"=",
"independent_variables",
"[",
"0",
"]",
"# TEMP FIX BEFORE REAL ND",
"symbolic_independent_variable",
"=",
... | Generate the link between the symbols of the derivatives and the
sympy Derivative operation.
Parameters
----------
independent_variable : str
name of the independant variable ("x")
dependent_variables : iterable of str
names of the dependent variables
helper_func... | [
"Generate",
"the",
"link",
"between",
"the",
"symbols",
"of",
"the",
"derivatives",
"and",
"the",
"sympy",
"Derivative",
"operation",
"."
] | train | https://github.com/celliern/triflow/blob/9522de077c43c8af7d4bf08fbd4ce4b7b480dccb/triflow/core/model.py#L25-L74 |
zetaops/pyoko | pyoko/manage.py | BaseDumpHandler._prepare_output_multi | def _prepare_output_multi(self, model):
"""If printing to a different file per model, change the file for the current model"""
model_name = model.__name__
current_path = os.path.join(self._output_path, '{model}.{extension}'.format(
model=model_name,
extension=self.EXTENSI... | python | def _prepare_output_multi(self, model):
"""If printing to a different file per model, change the file for the current model"""
model_name = model.__name__
current_path = os.path.join(self._output_path, '{model}.{extension}'.format(
model=model_name,
extension=self.EXTENSI... | [
"def",
"_prepare_output_multi",
"(",
"self",
",",
"model",
")",
":",
"model_name",
"=",
"model",
".",
"__name__",
"current_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"_output_path",
",",
"'{model}.{extension}'",
".",
"format",
"(",
"model"... | If printing to a different file per model, change the file for the current model | [
"If",
"printing",
"to",
"a",
"different",
"file",
"per",
"model",
"change",
"the",
"file",
"for",
"the",
"current",
"model"
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L362-L370 |
zetaops/pyoko | pyoko/manage.py | LoadData.prepare_buckets | def prepare_buckets(self):
"""
loads buckets to bucket cache.
"""
for mdl in self.registry.get_base_models():
bucket = mdl(super_context).objects.adapter.bucket
self.buckets[bucket.name] = bucket | python | def prepare_buckets(self):
"""
loads buckets to bucket cache.
"""
for mdl in self.registry.get_base_models():
bucket = mdl(super_context).objects.adapter.bucket
self.buckets[bucket.name] = bucket | [
"def",
"prepare_buckets",
"(",
"self",
")",
":",
"for",
"mdl",
"in",
"self",
".",
"registry",
".",
"get_base_models",
"(",
")",
":",
"bucket",
"=",
"mdl",
"(",
"super_context",
")",
".",
"objects",
".",
"adapter",
".",
"bucket",
"self",
".",
"buckets",
... | loads buckets to bucket cache. | [
"loads",
"buckets",
"to",
"bucket",
"cache",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L606-L612 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._print_split_model | def _print_split_model(self, path, apps_models):
"""
Print each model in apps_models into its own file.
"""
for app, models in apps_models:
for model in models:
model_name = model().title
if self._has_extension(path):
model_... | python | def _print_split_model(self, path, apps_models):
"""
Print each model in apps_models into its own file.
"""
for app, models in apps_models:
for model in models:
model_name = model().title
if self._has_extension(path):
model_... | [
"def",
"_print_split_model",
"(",
"self",
",",
"path",
",",
"apps_models",
")",
":",
"for",
"app",
",",
"models",
"in",
"apps_models",
":",
"for",
"model",
"in",
"models",
":",
"model_name",
"=",
"model",
"(",
")",
".",
"title",
"if",
"self",
".",
"_ha... | Print each model in apps_models into its own file. | [
"Print",
"each",
"model",
"in",
"apps_models",
"into",
"its",
"own",
"file",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L819-L830 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._print_split_app | def _print_split_app(self, path, apps_models):
"""
Print each app in apps_models associative list into its own file.
"""
for app, models in apps_models:
# Convert dir/file.puml to dir/file.app.puml to print to an app specific file
if self._has_extension(path):
... | python | def _print_split_app(self, path, apps_models):
"""
Print each app in apps_models associative list into its own file.
"""
for app, models in apps_models:
# Convert dir/file.puml to dir/file.app.puml to print to an app specific file
if self._has_extension(path):
... | [
"def",
"_print_split_app",
"(",
"self",
",",
"path",
",",
"apps_models",
")",
":",
"for",
"app",
",",
"models",
"in",
"apps_models",
":",
"# Convert dir/file.puml to dir/file.app.puml to print to an app specific file",
"if",
"self",
".",
"_has_extension",
"(",
"path",
... | Print each app in apps_models associative list into its own file. | [
"Print",
"each",
"app",
"in",
"apps_models",
"associative",
"list",
"into",
"its",
"own",
"file",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L832-L843 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._print_single_file | def _print_single_file(self, path, apps_models):
"""
Print apps_models which contains a list of 2-tuples containing apps and their models
into a single file.
"""
if path:
outfile = codecs.open(path, 'w', encoding='utf-8')
self._print = lambda s: outfile.wr... | python | def _print_single_file(self, path, apps_models):
"""
Print apps_models which contains a list of 2-tuples containing apps and their models
into a single file.
"""
if path:
outfile = codecs.open(path, 'w', encoding='utf-8')
self._print = lambda s: outfile.wr... | [
"def",
"_print_single_file",
"(",
"self",
",",
"path",
",",
"apps_models",
")",
":",
"if",
"path",
":",
"outfile",
"=",
"codecs",
".",
"open",
"(",
"path",
",",
"'w'",
",",
"encoding",
"=",
"'utf-8'",
")",
"self",
".",
"_print",
"=",
"lambda",
"s",
"... | Print apps_models which contains a list of 2-tuples containing apps and their models
into a single file. | [
"Print",
"apps_models",
"which",
"contains",
"a",
"list",
"of",
"2",
"-",
"tuples",
"containing",
"apps",
"and",
"their",
"models",
"into",
"a",
"single",
"file",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L845-L858 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._print_app | def _print_app(self, app, models):
"""
Print the models of app, showing them in a package.
"""
self._print(self._app_start % app)
self._print_models(models)
self._print(self._app_end) | python | def _print_app(self, app, models):
"""
Print the models of app, showing them in a package.
"""
self._print(self._app_start % app)
self._print_models(models)
self._print(self._app_end) | [
"def",
"_print_app",
"(",
"self",
",",
"app",
",",
"models",
")",
":",
"self",
".",
"_print",
"(",
"self",
".",
"_app_start",
"%",
"app",
")",
"self",
".",
"_print_models",
"(",
"models",
")",
"self",
".",
"_print",
"(",
"self",
".",
"_app_end",
")"
... | Print the models of app, showing them in a package. | [
"Print",
"the",
"models",
"of",
"app",
"showing",
"them",
"in",
"a",
"package",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L860-L866 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._print_fields | def _print_fields(self, fields):
"""Print the fields, padding the names as necessary to align them."""
# Prepare a formatting string that aligns the names and types based on the longest ones
longest_name = max(fields, key=lambda f: len(f[1]))[1]
longest_type = max(fields, key=lambda f: l... | python | def _print_fields(self, fields):
"""Print the fields, padding the names as necessary to align them."""
# Prepare a formatting string that aligns the names and types based on the longest ones
longest_name = max(fields, key=lambda f: len(f[1]))[1]
longest_type = max(fields, key=lambda f: l... | [
"def",
"_print_fields",
"(",
"self",
",",
"fields",
")",
":",
"# Prepare a formatting string that aligns the names and types based on the longest ones",
"longest_name",
"=",
"max",
"(",
"fields",
",",
"key",
"=",
"lambda",
"f",
":",
"len",
"(",
"f",
"[",
"1",
"]",
... | Print the fields, padding the names as necessary to align them. | [
"Print",
"the",
"fields",
"padding",
"the",
"names",
"as",
"necessary",
"to",
"align",
"them",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L884-L893 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._format_listnodes | def _format_listnodes(self, listnodes):
"""
Format ListNodes and their fields into tuples that can be printed with _print_fields().
"""
fields = list()
for name, node in listnodes:
fields.append(('--', '', '', '--'))
fields.append(('', '**%s(ListNode)**' %... | python | def _format_listnodes(self, listnodes):
"""
Format ListNodes and their fields into tuples that can be printed with _print_fields().
"""
fields = list()
for name, node in listnodes:
fields.append(('--', '', '', '--'))
fields.append(('', '**%s(ListNode)**' %... | [
"def",
"_format_listnodes",
"(",
"self",
",",
"listnodes",
")",
":",
"fields",
"=",
"list",
"(",
")",
"for",
"name",
",",
"node",
"in",
"listnodes",
":",
"fields",
".",
"append",
"(",
"(",
"'--'",
",",
"''",
",",
"''",
",",
"'--'",
")",
")",
"field... | Format ListNodes and their fields into tuples that can be printed with _print_fields(). | [
"Format",
"ListNodes",
"and",
"their",
"fields",
"into",
"tuples",
"that",
"can",
"be",
"printed",
"with",
"_print_fields",
"()",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L895-L909 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._get_model_fields | def _get_model_fields(self, model, prefix=_field_prefix):
"""
Find all fields of given model that are not default models.
"""
fields = list()
for field_name, field in model()._ordered_fields:
# Filter the default fields
if field_name not in getattr(model, ... | python | def _get_model_fields(self, model, prefix=_field_prefix):
"""
Find all fields of given model that are not default models.
"""
fields = list()
for field_name, field in model()._ordered_fields:
# Filter the default fields
if field_name not in getattr(model, ... | [
"def",
"_get_model_fields",
"(",
"self",
",",
"model",
",",
"prefix",
"=",
"_field_prefix",
")",
":",
"fields",
"=",
"list",
"(",
")",
"for",
"field_name",
",",
"field",
"in",
"model",
"(",
")",
".",
"_ordered_fields",
":",
"# Filter the default fields",
"if... | Find all fields of given model that are not default models. | [
"Find",
"all",
"fields",
"of",
"given",
"model",
"that",
"are",
"not",
"default",
"models",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L911-L923 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._get_model_nodes | def _get_model_nodes(self, model):
"""
Find all the non-auto created nodes of the model.
"""
nodes = [(name, node) for name, node in model._nodes.items()
if node._is_auto_created is False]
nodes.sort(key=lambda n: n[0])
return nodes | python | def _get_model_nodes(self, model):
"""
Find all the non-auto created nodes of the model.
"""
nodes = [(name, node) for name, node in model._nodes.items()
if node._is_auto_created is False]
nodes.sort(key=lambda n: n[0])
return nodes | [
"def",
"_get_model_nodes",
"(",
"self",
",",
"model",
")",
":",
"nodes",
"=",
"[",
"(",
"name",
",",
"node",
")",
"for",
"name",
",",
"node",
"in",
"model",
".",
"_nodes",
".",
"items",
"(",
")",
"if",
"node",
".",
"_is_auto_created",
"is",
"False",
... | Find all the non-auto created nodes of the model. | [
"Find",
"all",
"the",
"non",
"-",
"auto",
"created",
"nodes",
"of",
"the",
"model",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L925-L932 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._format_links_fields | def _format_links_fields(self, links):
"""
Format the fields containing links into 4-tuples printable by _print_fields().
"""
fields = list()
for link in links:
linked_model = link['mdl'](super_context)
null = self._marker_true if link['null'] is True else... | python | def _format_links_fields(self, links):
"""
Format the fields containing links into 4-tuples printable by _print_fields().
"""
fields = list()
for link in links:
linked_model = link['mdl'](super_context)
null = self._marker_true if link['null'] is True else... | [
"def",
"_format_links_fields",
"(",
"self",
",",
"links",
")",
":",
"fields",
"=",
"list",
"(",
")",
"for",
"link",
"in",
"links",
":",
"linked_model",
"=",
"link",
"[",
"'mdl'",
"]",
"(",
"super_context",
")",
"null",
"=",
"self",
".",
"_marker_true",
... | Format the fields containing links into 4-tuples printable by _print_fields(). | [
"Format",
"the",
"fields",
"containing",
"links",
"into",
"4",
"-",
"tuples",
"printable",
"by",
"_print_fields",
"()",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L934-L947 |
zetaops/pyoko | pyoko/manage.py | GenerateDiagrams._print_links | def _print_links(self, model, links):
"""
Print links that start from model.
"""
for link in links:
if link['o2o'] is True:
link_type = self._one_to_one
elif link['m2m'] is True:
link_type = self._many_to_many
else:
... | python | def _print_links(self, model, links):
"""
Print links that start from model.
"""
for link in links:
if link['o2o'] is True:
link_type = self._one_to_one
elif link['m2m'] is True:
link_type = self._many_to_many
else:
... | [
"def",
"_print_links",
"(",
"self",
",",
"model",
",",
"links",
")",
":",
"for",
"link",
"in",
"links",
":",
"if",
"link",
"[",
"'o2o'",
"]",
"is",
"True",
":",
"link_type",
"=",
"self",
".",
"_one_to_one",
"elif",
"link",
"[",
"'m2m'",
"]",
"is",
... | Print links that start from model. | [
"Print",
"links",
"that",
"start",
"from",
"model",
"."
] | train | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/manage.py#L949-L961 |
renanivo/with | withtool/main.py | main | def main():
"""
Usage: with (--version | <command>)
Arguments:
command The command to use as prefix to your context.
Options:
-h --help Show this screen.
--version Show the current version.
"""
arguments = docopt(main.__doc__)
if arguments.get('--version'):
print('with {}'... | python | def main():
"""
Usage: with (--version | <command>)
Arguments:
command The command to use as prefix to your context.
Options:
-h --help Show this screen.
--version Show the current version.
"""
arguments = docopt(main.__doc__)
if arguments.get('--version'):
print('with {}'... | [
"def",
"main",
"(",
")",
":",
"arguments",
"=",
"docopt",
"(",
"main",
".",
"__doc__",
")",
"if",
"arguments",
".",
"get",
"(",
"'--version'",
")",
":",
"print",
"(",
"'with {}'",
".",
"format",
"(",
"withtool",
".",
"__version__",
")",
")",
"sys",
"... | Usage: with (--version | <command>)
Arguments:
command The command to use as prefix to your context.
Options:
-h --help Show this screen.
--version Show the current version. | [
"Usage",
":",
"with",
"(",
"--",
"version",
"|",
"<command",
">",
")"
] | train | https://github.com/renanivo/with/blob/19740e83dddd256ed020942f59ee9708ab38b96c/withtool/main.py#L12-L32 |
cthoyt/onto2nx | src/onto2nx/ontospy/core/utils.py | printBasicInfo | def printBasicInfo(onto):
"""
Terminal printing of basic ontology information
"""
rdfGraph = onto.rdfGraph
print("_" * 50, "\n")
print("TRIPLES = %s" % len(rdfGraph))
print("_" * 50)
print("\nNAMESPACES:\n")
for x in onto.ontologyNamespaces:
print("%s : %s" % (x[0], x[1]))
... | python | def printBasicInfo(onto):
"""
Terminal printing of basic ontology information
"""
rdfGraph = onto.rdfGraph
print("_" * 50, "\n")
print("TRIPLES = %s" % len(rdfGraph))
print("_" * 50)
print("\nNAMESPACES:\n")
for x in onto.ontologyNamespaces:
print("%s : %s" % (x[0], x[1]))
... | [
"def",
"printBasicInfo",
"(",
"onto",
")",
":",
"rdfGraph",
"=",
"onto",
".",
"rdfGraph",
"print",
"(",
"\"_\"",
"*",
"50",
",",
"\"\\n\"",
")",
"print",
"(",
"\"TRIPLES = %s\"",
"%",
"len",
"(",
"rdfGraph",
")",
")",
"print",
"(",
"\"_\"",
"*",
"50",
... | Terminal printing of basic ontology information | [
"Terminal",
"printing",
"of",
"basic",
"ontology",
"information"
] | train | https://github.com/cthoyt/onto2nx/blob/94c86e5e187cca67534afe0260097177b66e02c8/src/onto2nx/ontospy/core/utils.py#L279-L301 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.