hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cf37f40ad42a31f7927d55a616af9a9d81b415d2 | orbichord/orbichord | orbichord/utils.py | [
"MIT"
] | Python | playAudio | <not_specific> | def playAudio(stream):
"""Generate audio play from stream."""
midi = stream.write('midi')
fs = FluidSynth('/usr/share/soundfonts/FluidR3_GM.sf2')
filename = 'audio-{}.wav'.format(uuid.uuid4().hex)
fs.midi_to_audio(midi, filename)
audio = Audio(filename=filename)
os.remove(filename)
retur... | Generate audio play from stream. | Generate audio play from stream. | [
"Generate",
"audio",
"play",
"from",
"stream",
"."
] | def playAudio(stream):
midi = stream.write('midi')
fs = FluidSynth('/usr/share/soundfonts/FluidR3_GM.sf2')
filename = 'audio-{}.wav'.format(uuid.uuid4().hex)
fs.midi_to_audio(midi, filename)
audio = Audio(filename=filename)
os.remove(filename)
return audio | [
"def",
"playAudio",
"(",
"stream",
")",
":",
"midi",
"=",
"stream",
".",
"write",
"(",
"'midi'",
")",
"fs",
"=",
"FluidSynth",
"(",
"'/usr/share/soundfonts/FluidR3_GM.sf2'",
")",
"filename",
"=",
"'audio-{}.wav'",
".",
"format",
"(",
"uuid",
".",
"uuid4",
"(... | Generate audio play from stream. | [
"Generate",
"audio",
"play",
"from",
"stream",
"."
] | [
"\"\"\"Generate audio play from stream.\"\"\""
] | [
{
"param": "stream",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "stream",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | _init_with_read_defaults | <not_specific> | def _init_with_read_defaults(cls):
"""Class decorator that calls the read_defaults class method in order to
set default values for class attributes"""
cls.read_defaults(filename=None)
return cls | Class decorator that calls the read_defaults class method in order to
set default values for class attributes | Class decorator that calls the read_defaults class method in order to
set default values for class attributes | [
"Class",
"decorator",
"that",
"calls",
"the",
"read_defaults",
"class",
"method",
"in",
"order",
"to",
"set",
"default",
"values",
"for",
"class",
"attributes"
] | def _init_with_read_defaults(cls):
cls.read_defaults(filename=None)
return cls | [
"def",
"_init_with_read_defaults",
"(",
"cls",
")",
":",
"cls",
".",
"read_defaults",
"(",
"filename",
"=",
"None",
")",
"return",
"cls"
] | Class decorator that calls the read_defaults class method in order to
set default values for class attributes | [
"Class",
"decorator",
"that",
"calls",
"the",
"read_defaults",
"class",
"method",
"in",
"order",
"to",
"set",
"default",
"values",
"for",
"class",
"attributes"
] | [
"\"\"\"Class decorator that calls the read_defaults class method in order to\n set default values for class attributes\"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | _init_default_backends | <not_specific> | def _init_default_backends(cls):
"""Register all built-in backends"""
for backend in _BACKENDS:
cls.register_backend(backend)
return cls | Register all built-in backends | Register all built-in backends | [
"Register",
"all",
"built",
"-",
"in",
"backends"
] | def _init_default_backends(cls):
for backend in _BACKENDS:
cls.register_backend(backend)
return cls | [
"def",
"_init_default_backends",
"(",
"cls",
")",
":",
"for",
"backend",
"in",
"_BACKENDS",
":",
"cls",
".",
"register_backend",
"(",
"backend",
")",
"return",
"cls"
] | Register all built-in backends | [
"Register",
"all",
"built",
"-",
"in",
"backends"
] | [
"\"\"\"Register all built-in backends\"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | read_defaults | null | def read_defaults(cls, filename=None):
"""Set class attributes from the INI file with the given file name
The file must be in the format specified in
https://docs.python.org/3.5/library/configparser.html#supported-ini-file-structure
with the default ConfigParser settings, except that al... | Set class attributes from the INI file with the given file name
The file must be in the format specified in
https://docs.python.org/3.5/library/configparser.html#supported-ini-file-structure
with the default ConfigParser settings, except that all keys are case
sensitive. It must contain... |
All keys in the "Attributes" section must be start with a letter, and
must consist only of letters, numbers, and underscores. Keys in the
"Resources" section can be arbitrary string. The key names 'resources'
and 'backends' may not be used. An example for a valid config file is:.
[Resources]
queue = exec
nodes = 1... | [
"All",
"keys",
"in",
"the",
"\"",
"Attributes",
"\"",
"section",
"must",
"be",
"start",
"with",
"a",
"letter",
"and",
"must",
"consist",
"only",
"of",
"letters",
"numbers",
"and",
"underscores",
".",
"Keys",
"in",
"the",
"\"",
"Resources",
"\"",
"section",... | def read_defaults(cls, filename=None):
logger = logging.getLogger(__name__)
def attr_setter(key, val):
if not re.match(r'^[a-zA-Z]\w*$', key):
raise ConfigParserError(("Key '%s' is invalid. Keys "
"must be valid attribute names, i.e., they must match "
... | [
"def",
"read_defaults",
"(",
"cls",
",",
"filename",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"def",
"attr_setter",
"(",
"key",
",",
"val",
")",
":",
"if",
"not",
"re",
".",
"match",
"(",
"r'^[a-zA-Z]\\w*... | Set class attributes from the INI file with the given file name
The file must be in the format specified in
https://docs.python.org/3.5/library/configparser.html#supported-ini-file-structure
with the default ConfigParser settings, except that all keys are case
sensitive. | [
"Set",
"class",
"attributes",
"from",
"the",
"INI",
"file",
"with",
"the",
"given",
"file",
"name",
"The",
"file",
"must",
"be",
"in",
"the",
"format",
"specified",
"in",
"https",
":",
"//",
"docs",
".",
"python",
".",
"org",
"/",
"3",
".",
"5",
"/",... | [
"\"\"\"Set class attributes from the INI file with the given file name\n\n The file must be in the format specified in\n https://docs.python.org/3.5/library/configparser.html#supported-ini-file-structure\n with the default ConfigParser settings, except that all keys are case\n sensitive.... | [
{
"param": "cls",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens"... |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | _default_filename | null | def _default_filename(self):
"""If self.filename is None, attempt to set it from the jobname"""
if self.filename is None:
if 'jobname' in self.resources:
self.filename = "%s.%s" \
% (self.resources['jobname'],
... | If self.filename is None, attempt to set it from the jobname | If self.filename is None, attempt to set it from the jobname | [
"If",
"self",
".",
"filename",
"is",
"None",
"attempt",
"to",
"set",
"it",
"from",
"the",
"jobname"
] | def _default_filename(self):
if self.filename is None:
if 'jobname' in self.resources:
self.filename = "%s.%s" \
% (self.resources['jobname'],
self._backends[self.backend].extension) | [
"def",
"_default_filename",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
"is",
"None",
":",
"if",
"'jobname'",
"in",
"self",
".",
"resources",
":",
"self",
".",
"filename",
"=",
"\"%s.%s\"",
"%",
"(",
"self",
".",
"resources",
"[",
"'jobname'",
... | If self.filename is None, attempt to set it from the jobname | [
"If",
"self",
".",
"filename",
"is",
"None",
"attempt",
"to",
"set",
"it",
"from",
"the",
"jobname"
] | [
"\"\"\"If self.filename is None, attempt to set it from the jobname\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | render_script | <not_specific> | def render_script(self, scriptbody, jobscript=False):
"""Render the body of a script. This brings both the main `body`, as
well as the `prologue`, `epilogue`, and any auxiliary scripts into the
final form in which they will be executed.
Rendering proceeds in the following steps:
... | Render the body of a script. This brings both the main `body`, as
well as the `prologue`, `epilogue`, and any auxiliary scripts into the
final form in which they will be executed.
Rendering proceeds in the following steps:
* Add a "shbang" (e.g. ``#!/bin/bash``) based on the `shell` at... | Render the body of a script.
Rendering proceeds in the following steps.
Add a "shbang" based on the `shell` attribute
if the `scriptbody` does not yet have a shbang on the first line
(otherwise the existing shbang will remain)
If rendering the body of a JobScript (`jobscript=True`), add
backend-specific resource he... | [
"Render",
"the",
"body",
"of",
"a",
"script",
".",
"Rendering",
"proceeds",
"in",
"the",
"following",
"steps",
".",
"Add",
"a",
"\"",
"shbang",
"\"",
"based",
"on",
"the",
"`",
"shell",
"`",
"attribute",
"if",
"the",
"`",
"scriptbody",
"`",
"does",
"no... | def render_script(self, scriptbody, jobscript=False):
rendered_lines = []
backend = self._backends[self.backend]
if jobscript:
rendered_lines.extend(backend.resource_headers(self))
scriptbody = backend.replace_body_vars(scriptbody)
mappings = dict(self.__class__.__dic... | [
"def",
"render_script",
"(",
"self",
",",
"scriptbody",
",",
"jobscript",
"=",
"False",
")",
":",
"rendered_lines",
"=",
"[",
"]",
"backend",
"=",
"self",
".",
"_backends",
"[",
"self",
".",
"backend",
"]",
"if",
"jobscript",
":",
"rendered_lines",
".",
... | Render the body of a script. | [
"Render",
"the",
"body",
"of",
"a",
"script",
"."
] | [
"\"\"\"Render the body of a script. This brings both the main `body`, as\n well as the `prologue`, `epilogue`, and any auxiliary scripts into the\n final form in which they will be executed.\n\n Rendering proceeds in the following steps:\n\n * Add a \"shbang\" (e.g. ``#!/bin/bash``) base... | [
{
"param": "self",
"type": null
},
{
"param": "scriptbody",
"type": null
},
{
"param": "jobscript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "scriptbody",
"type": null,
"docstring": null,
"docstring_toke... |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | write | null | def write(self, filename=None):
"""Write out the fully rendered jobscript to file. If filename is not
None, write to the given *local* file. Otherwise, write to the local or
remote file specified in the filename attribute, in the folder
specified by the rootdir and workdir attributes. Th... | Write out the fully rendered jobscript to file. If filename is not
None, write to the given *local* file. Otherwise, write to the local or
remote file specified in the filename attribute, in the folder
specified by the rootdir and workdir attributes. The folder will be
created if it does... | Write out the fully rendered jobscript to file. If filename is not
None, write to the given *local* file. Otherwise, write to the local or
remote file specified in the filename attribute, in the folder
specified by the rootdir and workdir attributes. The folder will be
created if it does not exist already. A '~' in `fi... | [
"Write",
"out",
"the",
"fully",
"rendered",
"jobscript",
"to",
"file",
".",
"If",
"filename",
"is",
"not",
"None",
"write",
"to",
"the",
"given",
"*",
"local",
"*",
"file",
".",
"Otherwise",
"write",
"to",
"the",
"local",
"or",
"remote",
"file",
"specifi... | def write(self, filename=None):
remote = self.remote
if filename is None:
self._default_filename()
filename = self.filename
filename = os.path.join(self.rootdir, self.workdir, filename)
else:
remote = None
if filename is None:
r... | [
"def",
"write",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"remote",
"=",
"self",
".",
"remote",
"if",
"filename",
"is",
"None",
":",
"self",
".",
"_default_filename",
"(",
")",
"filename",
"=",
"self",
".",
"filename",
"filename",
"=",
"os",... | Write out the fully rendered jobscript to file. | [
"Write",
"out",
"the",
"fully",
"rendered",
"jobscript",
"to",
"file",
"."
] | [
"\"\"\"Write out the fully rendered jobscript to file. If filename is not\n None, write to the given *local* file. Otherwise, write to the local or\n remote file specified in the filename attribute, in the folder\n specified by the rootdir and workdir attributes. The folder will be\n cre... | [
{
"param": "self",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens... |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | _run_prologue | null | def _run_prologue(self):
"""Render and run the prologue script"""
if self.prologue is not None:
prologue = self.render_script(self.prologue)
with tempfile.NamedTemporaryFile('w', delete=False) as prologue_fh:
prologue_fh.write(prologue)
tempfilenam... | Render and run the prologue script | Render and run the prologue script | [
"Render",
"and",
"run",
"the",
"prologue",
"script"
] | def _run_prologue(self):
if self.prologue is not None:
prologue = self.render_script(self.prologue)
with tempfile.NamedTemporaryFile('w', delete=False) as prologue_fh:
prologue_fh.write(prologue)
tempfilename = prologue_fh.name
set_executable(t... | [
"def",
"_run_prologue",
"(",
"self",
")",
":",
"if",
"self",
".",
"prologue",
"is",
"not",
"None",
":",
"prologue",
"=",
"self",
".",
"render_script",
"(",
"self",
".",
"prologue",
")",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"'w'",
",",
"del... | Render and run the prologue script | [
"Render",
"and",
"run",
"the",
"prologue",
"script"
] | [
"\"\"\"Render and run the prologue script\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | status | <not_specific> | def status(self):
"""Return the job status as one of the codes defined in the
`clusterjob.status` module.
finished, communicate with the cluster to determine the job's status.
"""
if self._status >= COMPLETED:
return self._status
else:
for i in ran... | Return the job status as one of the codes defined in the
`clusterjob.status` module.
finished, communicate with the cluster to determine the job's status.
| Return the job status as one of the codes defined in the
`clusterjob.status` module.
finished, communicate with the cluster to determine the job's status. | [
"Return",
"the",
"job",
"status",
"as",
"one",
"of",
"the",
"codes",
"defined",
"in",
"the",
"`",
"clusterjob",
".",
"status",
"`",
"module",
".",
"finished",
"communicate",
"with",
"the",
"cluster",
"to",
"determine",
"the",
"job",
"'",
"s",
"status",
"... | def status(self):
if self._status >= COMPLETED:
return self._status
else:
for i in range(0, 26):
try:
cmd = self.backend.cmd_status(self, finished=False)
response = self._run_cmd(cmd, self.remote, ignore_exit_code=True,
... | [
"def",
"status",
"(",
"self",
")",
":",
"if",
"self",
".",
"_status",
">=",
"COMPLETED",
":",
"return",
"self",
".",
"_status",
"else",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"26",
")",
":",
"try",
":",
"cmd",
"=",
"self",
".",
"backend",... | Return the job status as one of the codes defined in the
`clusterjob.status` module. | [
"Return",
"the",
"job",
"status",
"as",
"one",
"of",
"the",
"codes",
"defined",
"in",
"the",
"`",
"clusterjob",
".",
"status",
"`",
"module",
"."
] | [
"\"\"\"Return the job status as one of the codes defined in the\n `clusterjob.status` module.\n finished, communicate with the cluster to determine the job's status.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | load | <not_specific> | def load(cls, cache_file, backend=None):
"""Instantiate AsyncResult from dumped `cache_file`.
This is the inverse of :meth:`dump`.
Parameters
----------
cache_file: str
Name of file from which the run should be read.
backend: clusterjob.backen... | Instantiate AsyncResult from dumped `cache_file`.
This is the inverse of :meth:`dump`.
Parameters
----------
cache_file: str
Name of file from which the run should be read.
backend: clusterjob.backends.ClusterjobBackend or None
The bac... |
Parameters
str
Name of file from which the run should be read.
clusterjob.backends.ClusterjobBackend or None
The backend instance for the job. If None, the backend will be
determined by the *name* of the dumped job's backend. | [
"Parameters",
"str",
"Name",
"of",
"file",
"from",
"which",
"the",
"run",
"should",
"be",
"read",
".",
"clusterjob",
".",
"backends",
".",
"ClusterjobBackend",
"or",
"None",
"The",
"backend",
"instance",
"for",
"the",
"job",
".",
"If",
"None",
"the",
"back... | def load(cls, cache_file, backend=None):
with open(cache_file, 'rb') as pickle_fh:
(remote, backend_name, max_sleep_interval, job_id, status,
epilogue, ssh, scp) = pickle.load(pickle_fh)
if backend is None:
backend = JobScript._backends[backend_name]
ar = cls... | [
"def",
"load",
"(",
"cls",
",",
"cache_file",
",",
"backend",
"=",
"None",
")",
":",
"with",
"open",
"(",
"cache_file",
",",
"'rb'",
")",
"as",
"pickle_fh",
":",
"(",
"remote",
",",
"backend_name",
",",
"max_sleep_interval",
",",
"job_id",
",",
"status",... | Instantiate AsyncResult from dumped `cache_file`. | [
"Instantiate",
"AsyncResult",
"from",
"dumped",
"`",
"cache_file",
"`",
"."
] | [
"\"\"\"Instantiate AsyncResult from dumped `cache_file`.\n\n This is the inverse of :meth:`dump`.\n\n Parameters\n ----------\n\n cache_file: str\n Name of file from which the run should be read.\n\n backend: clusterjob.backends.ClusterjobBackend or None\n ... | [
{
"param": "cls",
"type": null
},
{
"param": "cache_file",
"type": null
},
{
"param": "backend",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cache_file",
"type": null,
"docstring": null,
"docstring_token... |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | wait | <not_specific> | def wait(self, timeout=None):
"""Wait until the result is available or until roughly timeout seconds
pass."""
logger = logging.getLogger(__name__)
if int(self.max_sleep_interval) < int(self._min_sleep_interval):
self.max_sleep_interval = int(self._min_sleep_interval)
... | Wait until the result is available or until roughly timeout seconds
pass. | Wait until the result is available or until roughly timeout seconds
pass. | [
"Wait",
"until",
"the",
"result",
"is",
"available",
"or",
"until",
"roughly",
"timeout",
"seconds",
"pass",
"."
] | def wait(self, timeout=None):
logger = logging.getLogger(__name__)
if int(self.max_sleep_interval) < int(self._min_sleep_interval):
self.max_sleep_interval = int(self._min_sleep_interval)
t0 = time.time()
sleep_seconds = min(5, self.max_sleep_interval)
status = self.s... | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"if",
"int",
"(",
"self",
".",
"max_sleep_interval",
")",
"<",
"int",
"(",
"self",
".",
"_min_sleep_interval",
")",
":"... | Wait until the result is available or until roughly timeout seconds
pass. | [
"Wait",
"until",
"the",
"result",
"is",
"available",
"or",
"until",
"roughly",
"timeout",
"seconds",
"pass",
"."
] | [
"\"\"\"Wait until the result is available or until roughly timeout seconds\n pass.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "timeout",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "timeout",
"type": null,
"docstring": null,
"docstring_tokens"... |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | successful | <not_specific> | def successful(self):
"""Return True if the job finished with a COMPLETED status, False if it
finished with a CANCELLED or FAILED status. Raise an `AssertionError`
if the job has not completed"""
status = self.status
assert status >= COMPLETED, "status is %s" % status
ret... | Return True if the job finished with a COMPLETED status, False if it
finished with a CANCELLED or FAILED status. Raise an `AssertionError`
if the job has not completed | Return True if the job finished with a COMPLETED status, False if it
finished with a CANCELLED or FAILED status. Raise an `AssertionError`
if the job has not completed | [
"Return",
"True",
"if",
"the",
"job",
"finished",
"with",
"a",
"COMPLETED",
"status",
"False",
"if",
"it",
"finished",
"with",
"a",
"CANCELLED",
"or",
"FAILED",
"status",
".",
"Raise",
"an",
"`",
"AssertionError",
"`",
"if",
"the",
"job",
"has",
"not",
"... | def successful(self):
status = self.status
assert status >= COMPLETED, "status is %s" % status
return (self.status == COMPLETED) | [
"def",
"successful",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"status",
"assert",
"status",
">=",
"COMPLETED",
",",
"\"status is %s\"",
"%",
"status",
"return",
"(",
"self",
".",
"status",
"==",
"COMPLETED",
")"
] | Return True if the job finished with a COMPLETED status, False if it
finished with a CANCELLED or FAILED status. | [
"Return",
"True",
"if",
"the",
"job",
"finished",
"with",
"a",
"COMPLETED",
"status",
"False",
"if",
"it",
"finished",
"with",
"a",
"CANCELLED",
"or",
"FAILED",
"status",
"."
] | [
"\"\"\"Return True if the job finished with a COMPLETED status, False if it\n finished with a CANCELLED or FAILED status. Raise an `AssertionError`\n if the job has not completed\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | cancel | <not_specific> | def cancel(self):
"""Instruct the cluster to cancel the running job. Has no effect if
job is not running"""
if self.status > COMPLETED:
return
cmd = self.backend.cmd_cancel(self)
self._run_cmd(cmd, self.remote, ignore_exit_code=True, ssh=self.ssh)
self._status... | Instruct the cluster to cancel the running job. Has no effect if
job is not running | Instruct the cluster to cancel the running job. Has no effect if
job is not running | [
"Instruct",
"the",
"cluster",
"to",
"cancel",
"the",
"running",
"job",
".",
"Has",
"no",
"effect",
"if",
"job",
"is",
"not",
"running"
] | def cancel(self):
if self.status > COMPLETED:
return
cmd = self.backend.cmd_cancel(self)
self._run_cmd(cmd, self.remote, ignore_exit_code=True, ssh=self.ssh)
self._status = CANCELLED
self.dump() | [
"def",
"cancel",
"(",
"self",
")",
":",
"if",
"self",
".",
"status",
">",
"COMPLETED",
":",
"return",
"cmd",
"=",
"self",
".",
"backend",
".",
"cmd_cancel",
"(",
"self",
")",
"self",
".",
"_run_cmd",
"(",
"cmd",
",",
"self",
".",
"remote",
",",
"ig... | Instruct the cluster to cancel the running job. | [
"Instruct",
"the",
"cluster",
"to",
"cancel",
"the",
"running",
"job",
"."
] | [
"\"\"\"Instruct the cluster to cancel the running job. Has no effect if\n job is not running\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c13714241236d6364b3676806ad67994c058f453 | timostrunk/clusterjob | clusterjob/__init__.py | [
"MIT"
] | Python | run_epilogue | null | def run_epilogue(self):
"""Run the epilogue script in the current working directory.
raises:
subprocess.CalledProcessError: if the script does not finish with
exit code zero.
"""
logger = logging.getLogger(__name__)
if self.epilogue is not None:
... | Run the epilogue script in the current working directory.
raises:
subprocess.CalledProcessError: if the script does not finish with
exit code zero.
| Run the epilogue script in the current working directory.
raises:
subprocess.CalledProcessError: if the script does not finish with
exit code zero. | [
"Run",
"the",
"epilogue",
"script",
"in",
"the",
"current",
"working",
"directory",
".",
"raises",
":",
"subprocess",
".",
"CalledProcessError",
":",
"if",
"the",
"script",
"does",
"not",
"finish",
"with",
"exit",
"code",
"zero",
"."
] | def run_epilogue(self):
logger = logging.getLogger(__name__)
if self.epilogue is not None:
with tempfile.NamedTemporaryFile('w', delete=False) as epilogue_fh:
epilogue_fh.write(self.epilogue)
tempfilename = epilogue_fh.name
set_executable(tempfilen... | [
"def",
"run_epilogue",
"(",
"self",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"if",
"self",
".",
"epilogue",
"is",
"not",
"None",
":",
"with",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"'w'",
",",
"delete",
"=",
"False... | Run the epilogue script in the current working directory. | [
"Run",
"the",
"epilogue",
"script",
"in",
"the",
"current",
"working",
"directory",
"."
] | [
"\"\"\"Run the epilogue script in the current working directory.\n\n raises:\n subprocess.CalledProcessError: if the script does not finish with\n exit code zero.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f8c27623b68dde6c0efd09191e98b6d0fb16d03e | timostrunk/clusterjob | clusterjob/backends/pbspro.py | [
"MIT"
] | Python | resource_headers | <not_specific> | def resource_headers(self, jobscript):
"""Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
"""
resources = jobscript.resources
lines = []
cores_per_node... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
| Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | def resource_headers(self, jobscript):
resources = jobscript.resources
lines = []
cores_per_node = 1
nodes = 1
ppn = 1
threads = 1
if 'ppn' in resources:
ppn = resources['ppn']
cores_per_node *= ppn
if 'threads' in resources:
... | [
"def",
"resource_headers",
"(",
"self",
",",
"jobscript",
")",
":",
"resources",
"=",
"jobscript",
".",
"resources",
"lines",
"=",
"[",
"]",
"cores_per_node",
"=",
"1",
"nodes",
"=",
"1",
"ppn",
"=",
"1",
"threads",
"=",
"1",
"if",
"'ppn'",
"in",
"reso... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | [
"\"\"\"Given a :class:`~clusterjob.JobScript` instance, return a list of\n lines that encode the resource requirements, to be added at the top of\n the rendered job script\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "jobscript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "jobscript",
"type": null,
"docstring": null,
"docstring_token... |
bfb9ef908f520ffc40d52f6e3e887c673b34563c | timostrunk/clusterjob | clusterjob/backends/sge.py | [
"MIT"
] | Python | resource_headers | <not_specific> | def resource_headers(self, jobscript):
"""Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
"""
lines = []
for (key, val) in jobscript.resources.items():
... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
| Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | def resource_headers(self, jobscript):
lines = []
for (key, val) in jobscript.resources.items():
if key in self.resource_replacements:
pbs_key = self.resource_replacements[key]
if key == 'mem':
val = str(val) + "m"
else:
... | [
"def",
"resource_headers",
"(",
"self",
",",
"jobscript",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"val",
")",
"in",
"jobscript",
".",
"resources",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"self",
".",
"resource_replacements",
... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | [
"\"\"\"Given a :class:`~clusterjob.JobScript` instance, return a list of\n lines that encode the resource requirements, to be added at the top of\n the rendered job script\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "jobscript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "jobscript",
"type": null,
"docstring": null,
"docstring_token... |
bfb9ef908f520ffc40d52f6e3e887c673b34563c | timostrunk/clusterjob | clusterjob/backends/sge.py | [
"MIT"
] | Python | replace_body_vars | <not_specific> | def replace_body_vars(self, body):
"""Given a multiline string that is the body of the job script, replace
the placeholders for environment variables with backend-specific
realizations, and return the modified body. See the `job_vars`
attribute for the mappings that are performed.
... | Given a multiline string that is the body of the job script, replace
the placeholders for environment variables with backend-specific
realizations, and return the modified body. See the `job_vars`
attribute for the mappings that are performed.
| Given a multiline string that is the body of the job script, replace
the placeholders for environment variables with backend-specific
realizations, and return the modified body. See the `job_vars`
attribute for the mappings that are performed. | [
"Given",
"a",
"multiline",
"string",
"that",
"is",
"the",
"body",
"of",
"the",
"job",
"script",
"replace",
"the",
"placeholders",
"for",
"environment",
"variables",
"with",
"backend",
"-",
"specific",
"realizations",
"and",
"return",
"the",
"modified",
"body",
... | def replace_body_vars(self, body):
for key, val in self.job_vars.items():
body = body.replace(key, val)
return body | [
"def",
"replace_body_vars",
"(",
"self",
",",
"body",
")",
":",
"for",
"key",
",",
"val",
"in",
"self",
".",
"job_vars",
".",
"items",
"(",
")",
":",
"body",
"=",
"body",
".",
"replace",
"(",
"key",
",",
"val",
")",
"return",
"body"
] | Given a multiline string that is the body of the job script, replace
the placeholders for environment variables with backend-specific
realizations, and return the modified body. | [
"Given",
"a",
"multiline",
"string",
"that",
"is",
"the",
"body",
"of",
"the",
"job",
"script",
"replace",
"the",
"placeholders",
"for",
"environment",
"variables",
"with",
"backend",
"-",
"specific",
"realizations",
"and",
"return",
"the",
"modified",
"body",
... | [
"\"\"\"Given a multiline string that is the body of the job script, replace\n the placeholders for environment variables with backend-specific\n realizations, and return the modified body. See the `job_vars`\n attribute for the mappings that are performed.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "body",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "body",
"type": null,
"docstring": null,
"docstring_tokens": [... |
8dd704515d8c252cad39ca1cd57e79f7973c4344 | timostrunk/clusterjob | clusterjob/backends/lsf.py | [
"MIT"
] | Python | resource_headers | <not_specific> | def resource_headers(self, jobscript):
"""Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
"""
resources = jobscript.resources
lines = []
cores_per_node... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
| Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | def resource_headers(self, jobscript):
resources = jobscript.resources
lines = []
cores_per_node = 1
nodes = 1
if 'ppn' in resources:
cores_per_node *= resources['ppn']
if 'threads' in resources:
cores_per_node *= resources['threads']
if 'n... | [
"def",
"resource_headers",
"(",
"self",
",",
"jobscript",
")",
":",
"resources",
"=",
"jobscript",
".",
"resources",
"lines",
"=",
"[",
"]",
"cores_per_node",
"=",
"1",
"nodes",
"=",
"1",
"if",
"'ppn'",
"in",
"resources",
":",
"cores_per_node",
"*=",
"reso... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | [
"\"\"\"Given a :class:`~clusterjob.JobScript` instance, return a list of\n lines that encode the resource requirements, to be added at the top of\n the rendered job script\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "jobscript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "jobscript",
"type": null,
"docstring": null,
"docstring_token... |
2f736a8d40ee5538901eb8799051ba4a846fbf78 | timostrunk/clusterjob | clusterjob/utils.py | [
"MIT"
] | Python | split_seq | <not_specific> | def split_seq(seq, n_chunks):
"""Split the given sequence into `n_chunks`. Suitable for distributing an
array of jobs over a fixed number of workers.
>>> split_seq([1,2,3,4,5,6], 3)
[[1, 2], [3, 4], [5, 6]]
>>> split_seq([1,2,3,4,5,6], 2)
[[1, 2, 3], [4, 5, 6]]
>>> split_seq([1,2,3,4,5,6,7]... | Split the given sequence into `n_chunks`. Suitable for distributing an
array of jobs over a fixed number of workers.
>>> split_seq([1,2,3,4,5,6], 3)
[[1, 2], [3, 4], [5, 6]]
>>> split_seq([1,2,3,4,5,6], 2)
[[1, 2, 3], [4, 5, 6]]
>>> split_seq([1,2,3,4,5,6,7], 3)
[[1, 2], [3, 4, 5], [6, 7]]
... | Split the given sequence into `n_chunks`. Suitable for distributing an
array of jobs over a fixed number of workers.
| [
"Split",
"the",
"given",
"sequence",
"into",
"`",
"n_chunks",
"`",
".",
"Suitable",
"for",
"distributing",
"an",
"array",
"of",
"jobs",
"over",
"a",
"fixed",
"number",
"of",
"workers",
"."
] | def split_seq(seq, n_chunks):
newseq = []
splitsize = 1.0/n_chunks*len(seq)
for i in range(n_chunks):
newseq.append(seq[int(round(i*splitsize)):int(round((i+1)*splitsize))])
return newseq | [
"def",
"split_seq",
"(",
"seq",
",",
"n_chunks",
")",
":",
"newseq",
"=",
"[",
"]",
"splitsize",
"=",
"1.0",
"/",
"n_chunks",
"*",
"len",
"(",
"seq",
")",
"for",
"i",
"in",
"range",
"(",
"n_chunks",
")",
":",
"newseq",
".",
"append",
"(",
"seq",
... | Split the given sequence into `n_chunks`. | [
"Split",
"the",
"given",
"sequence",
"into",
"`",
"n_chunks",
"`",
"."
] | [
"\"\"\"Split the given sequence into `n_chunks`. Suitable for distributing an\n array of jobs over a fixed number of workers.\n\n >>> split_seq([1,2,3,4,5,6], 3)\n [[1, 2], [3, 4], [5, 6]]\n >>> split_seq([1,2,3,4,5,6], 2)\n [[1, 2, 3], [4, 5, 6]]\n >>> split_seq([1,2,3,4,5,6,7], 3)\n [[1, 2], ... | [
{
"param": "seq",
"type": null
},
{
"param": "n_chunks",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "seq",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "n_chunks",
"type": null,
"docstring": null,
"docstring_tokens"... |
2f736a8d40ee5538901eb8799051ba4a846fbf78 | timostrunk/clusterjob | clusterjob/utils.py | [
"MIT"
] | Python | run_cmd | <not_specific> | def run_cmd(cmd, remote, rootdir='', workdir='', ignore_exit_code=False,
ssh='ssh'):
r'''Run the given cmd in the given workdir, either locally or remotely, and
return the combined stdout/stderr
Parameters:
cmd (list of str or str): Command to execute, as list consisting of the
... | r'''Run the given cmd in the given workdir, either locally or remotely, and
return the combined stdout/stderr
Parameters:
cmd (list of str or str): Command to execute, as list consisting of the
command, and options. Alternatively, the command can be given a
single string, which... | r'''Run the given cmd in the given workdir, either locally or remotely, and
return the combined stdout/stderr | [
"r",
"'",
"'",
"'",
"Run",
"the",
"given",
"cmd",
"in",
"the",
"given",
"workdir",
"either",
"locally",
"or",
"remotely",
"and",
"return",
"the",
"combined",
"stdout",
"/",
"stderr"
] | def run_cmd(cmd, remote, rootdir='', workdir='', ignore_exit_code=False,
ssh='ssh'):
logger = logging.getLogger(__name__)
workdir = os.path.join(rootdir, workdir)
if type(cmd) in [list, tuple]:
use_shell = False
else:
cmd = str(cmd)
use_shell = True
try:
if re... | [
"def",
"run_cmd",
"(",
"cmd",
",",
"remote",
",",
"rootdir",
"=",
"''",
",",
"workdir",
"=",
"''",
",",
"ignore_exit_code",
"=",
"False",
",",
"ssh",
"=",
"'ssh'",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"workdir",
... | r'''Run the given cmd in the given workdir, either locally or remotely, and
return the combined stdout/stderr | [
"r",
"'",
"'",
"'",
"Run",
"the",
"given",
"cmd",
"in",
"the",
"given",
"workdir",
"either",
"locally",
"or",
"remotely",
"and",
"return",
"the",
"combined",
"stdout",
"/",
"stderr"
] | [
"r'''Run the given cmd in the given workdir, either locally or remotely, and\n return the combined stdout/stderr\n\n Parameters:\n cmd (list of str or str): Command to execute, as list consisting of the\n command, and options. Alternatively, the command can be given a\n single st... | [
{
"param": "cmd",
"type": null
},
{
"param": "remote",
"type": null
},
{
"param": "rootdir",
"type": null
},
{
"param": "workdir",
"type": null
},
{
"param": "ignore_exit_code",
"type": null
},
{
"param": "ssh",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cmd",
"type": null,
"docstring": "Command to execute, as list consisting of the\ncommand, and options. Alternatively, the command can be given a\nsingle string, which will then be executed as a shell command. Only\nuse shell comman... |
2f736a8d40ee5538901eb8799051ba4a846fbf78 | timostrunk/clusterjob | clusterjob/utils.py | [
"MIT"
] | Python | time_to_seconds | <not_specific> | def time_to_seconds(time_str):
"""Convert a string describing a time duration into seconds. The supported
formats are::
minutes
minutes:seconds
hours:minutes:seconds
days-hours
days-hours:minutes
days-hours:minutes:seconds
days:hours:minutes:seconds
... | Convert a string describing a time duration into seconds. The supported
formats are::
minutes
minutes:seconds
hours:minutes:seconds
days-hours
days-hours:minutes
days-hours:minutes:seconds
days:hours:minutes:seconds
Raises:
ValueError: if `time_s... | Convert a string describing a time duration into seconds. The supported
formats are:.
| [
"Convert",
"a",
"string",
"describing",
"a",
"time",
"duration",
"into",
"seconds",
".",
"The",
"supported",
"formats",
"are",
":",
"."
] | def time_to_seconds(time_str):
patterns = [
re.compile(r'^(?P<hours>\d+):(?P<minutes>\d+):(?P<seconds>\d+)$'),
re.compile(r'^(?P<days>\d+)-(?P<hours>\d+)$'),
re.compile(r'^(?P<minutes>\d+)$'),
re.compile(r'^(?P<minutes>\d+):(?P<seconds>\d+)$'),
re.compile(r'^(?P<days>\d+)-(?P... | [
"def",
"time_to_seconds",
"(",
"time_str",
")",
":",
"patterns",
"=",
"[",
"re",
".",
"compile",
"(",
"r'^(?P<hours>\\d+):(?P<minutes>\\d+):(?P<seconds>\\d+)$'",
")",
",",
"re",
".",
"compile",
"(",
"r'^(?P<days>\\d+)-(?P<hours>\\d+)$'",
")",
",",
"re",
".",
"compil... | Convert a string describing a time duration into seconds. | [
"Convert",
"a",
"string",
"describing",
"a",
"time",
"duration",
"into",
"seconds",
"."
] | [
"\"\"\"Convert a string describing a time duration into seconds. The supported\n formats are::\n\n minutes\n minutes:seconds\n hours:minutes:seconds\n days-hours\n days-hours:minutes\n days-hours:minutes:seconds\n days:hours:minutes:seconds\n\n Raises:\n ... | [
{
"param": "time_str",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": "if `time_str` has an invalid format.",
"docstring_tokens": [
"if",
"`",
"time_str",
"`",
"has",
"an",
"invalid",
"format",
"."
],
"type": "ValueError"
}
],
"params... |
7dae0b1c3e2022f268bd408d78e7b4ce927c253b | timostrunk/clusterjob | clusterjob/backends/__init__.py | [
"MIT"
] | Python | cmd_submit | null | def cmd_submit(self, jobscript):
"""Given a :class:`~clusterjob.JobScript` instance, return a command
that submits the job to the scheduler. The returned command must be
be a sequence of program arguments or a string, see `args` argument of
:class:`subprocess.Popen`.
"""
... | Given a :class:`~clusterjob.JobScript` instance, return a command
that submits the job to the scheduler. The returned command must be
be a sequence of program arguments or a string, see `args` argument of
:class:`subprocess.Popen`.
| Given a :class:`~clusterjob.JobScript` instance, return a command
that submits the job to the scheduler. The returned command must be
be a sequence of program arguments or a string, see `args` argument of | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"command",
"that",
"submits",
"the",
"job",
"to",
"the",
"scheduler",
".",
"The",
"returned",
"command",
"must",
"be",
"be",
"a",
"sequence",
"of",
"pr... | def cmd_submit(self, jobscript):
raise NotImplementedError() | [
"def",
"cmd_submit",
"(",
"self",
",",
"jobscript",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | Given a :class:`~clusterjob.JobScript` instance, return a command
that submits the job to the scheduler. | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"command",
"that",
"submits",
"the",
"job",
"to",
"the",
"scheduler",
"."
] | [
"\"\"\"Given a :class:`~clusterjob.JobScript` instance, return a command\n that submits the job to the scheduler. The returned command must be\n be a sequence of program arguments or a string, see `args` argument of\n :class:`subprocess.Popen`.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "jobscript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "jobscript",
"type": null,
"docstring": null,
"docstring_token... |
7dae0b1c3e2022f268bd408d78e7b4ce927c253b | timostrunk/clusterjob | clusterjob/backends/__init__.py | [
"MIT"
] | Python | resource_headers | null | def resource_headers(self, jobscript):
"""Given a :class:`~clusterjob.JobScript` instance, return a list of
lines (no trailing newlines) that encode the resource requirements, to
be added at the top of the rendered job script, between the shbang and
the script body. At the very least, ke... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines (no trailing newlines) that encode the resource requirements, to
be added at the top of the rendered job script, between the shbang and
the script body. At the very least, keys in the `jobscript` resources
dict that ... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines (no trailing newlines) that encode the resource requirements, to
be added at the top of the rendered job script, between the shbang and
the script body. At the very least, keys in the `jobscript` resources
dict that are in the list of :attr:`common... | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"(",
"no",
"trailing",
"newlines",
")",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"... | def resource_headers(self, jobscript):
raise NotImplementedError() | [
"def",
"resource_headers",
"(",
"self",
",",
"jobscript",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines (no trailing newlines) that encode the resource requirements, to
be added at the top of the rendered job script, between the shbang and
the script body. | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"(",
"no",
"trailing",
"newlines",
")",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"... | [
"\"\"\"Given a :class:`~clusterjob.JobScript` instance, return a list of\n lines (no trailing newlines) that encode the resource requirements, to\n be added at the top of the rendered job script, between the shbang and\n the script body. At the very least, keys in the `jobscript` resources\n ... | [
{
"param": "self",
"type": null
},
{
"param": "jobscript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "jobscript",
"type": null,
"docstring": null,
"docstring_token... |
464137a13cba440a5bc45c4863cb3f66b0c4c476 | timostrunk/clusterjob | clusterjob/backends/pbs.py | [
"MIT"
] | Python | resource_headers | <not_specific> | def resource_headers(self, jobscript):
"""Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
"""
resources = jobscript.resources
lines = []
cores_per_node... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
| Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | def resource_headers(self, jobscript):
resources = jobscript.resources
lines = []
cores_per_node = 1
nodes = 1
if 'ppn' in resources:
cores_per_node *= resources['ppn']
if 'threads' in resources:
cores_per_node *= resources['threads']
if 'n... | [
"def",
"resource_headers",
"(",
"self",
",",
"jobscript",
")",
":",
"resources",
"=",
"jobscript",
".",
"resources",
"lines",
"=",
"[",
"]",
"cores_per_node",
"=",
"1",
"nodes",
"=",
"1",
"if",
"'ppn'",
"in",
"resources",
":",
"cores_per_node",
"*=",
"reso... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | [
"\"\"\"Given a :class:`~clusterjob.JobScript` instance, return a list of\n lines that encode the resource requirements, to be added at the top of\n the rendered job script\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "jobscript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "jobscript",
"type": null,
"docstring": null,
"docstring_token... |
aba337868e3ccbdcaf53250353e5b45eac04585d | timostrunk/clusterjob | clusterjob/backends/slurm.py | [
"MIT"
] | Python | cmd_status | <not_specific> | def cmd_status(self, run, finished=False):
"""Given a :class:`~clusterjob.AsyncResult` instance, return a command
that queries the scheduler for the job status, as a list of command
arguments. If ``finished=True``, the scheduler is queried via
``sacct``. Otherwise, ``squeue`` is used.
... | Given a :class:`~clusterjob.AsyncResult` instance, return a command
that queries the scheduler for the job status, as a list of command
arguments. If ``finished=True``, the scheduler is queried via
``sacct``. Otherwise, ``squeue`` is used.
| Given a :class:`~clusterjob.AsyncResult` instance, return a command
that queries the scheduler for the job status, as a list of command
arguments. | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"AsyncResult",
"`",
"instance",
"return",
"a",
"command",
"that",
"queries",
"the",
"scheduler",
"for",
"the",
"job",
"status",
"as",
"a",
"list",
"of",
"command",
"arguments",
"."
] | def cmd_status(self, run, finished=False):
if finished:
return ['sacct', '--format=state', '-n', '-j', str(run.job_id)]
else:
return ['squeue', '-h', '-o', '%T', '-j', str(run.job_id)] | [
"def",
"cmd_status",
"(",
"self",
",",
"run",
",",
"finished",
"=",
"False",
")",
":",
"if",
"finished",
":",
"return",
"[",
"'sacct'",
",",
"'--format=state'",
",",
"'-n'",
",",
"'-j'",
",",
"str",
"(",
"run",
".",
"job_id",
")",
"]",
"else",
":",
... | Given a :class:`~clusterjob.AsyncResult` instance, return a command
that queries the scheduler for the job status, as a list of command
arguments. | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"AsyncResult",
"`",
"instance",
"return",
"a",
"command",
"that",
"queries",
"the",
"scheduler",
"for",
"the",
"job",
"status",
"as",
"a",
"list",
"of",
"command",
"arguments",
"."
] | [
"\"\"\"Given a :class:`~clusterjob.AsyncResult` instance, return a command\n that queries the scheduler for the job status, as a list of command\n arguments. If ``finished=True``, the scheduler is queried via\n ``sacct``. Otherwise, ``squeue`` is used.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "run",
"type": null
},
{
"param": "finished",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "run",
"type": null,
"docstring": null,
"docstring_tokens": []... |
aba337868e3ccbdcaf53250353e5b45eac04585d | timostrunk/clusterjob | clusterjob/backends/slurm.py | [
"MIT"
] | Python | resource_headers | <not_specific> | def resource_headers(self, jobscript):
"""Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
"""
lines = []
for (key, val) in jobscript.resources.items():
... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script
| Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | def resource_headers(self, jobscript):
lines = []
for (key, val) in jobscript.resources.items():
if key in self.resource_replacements:
slurm_key = self.resource_replacements[key]
val = str(val).strip()
else:
slurm_key = key
... | [
"def",
"resource_headers",
"(",
"self",
",",
"jobscript",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"val",
")",
"in",
"jobscript",
".",
"resources",
".",
"items",
"(",
")",
":",
"if",
"key",
"in",
"self",
".",
"resource_replacements",
... | Given a :class:`~clusterjob.JobScript` instance, return a list of
lines that encode the resource requirements, to be added at the top of
the rendered job script | [
"Given",
"a",
":",
"class",
":",
"`",
"~clusterjob",
".",
"JobScript",
"`",
"instance",
"return",
"a",
"list",
"of",
"lines",
"that",
"encode",
"the",
"resource",
"requirements",
"to",
"be",
"added",
"at",
"the",
"top",
"of",
"the",
"rendered",
"job",
"s... | [
"\"\"\"Given a :class:`~clusterjob.JobScript` instance, return a list of\n lines that encode the resource requirements, to be added at the top of\n the rendered job script\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "jobscript",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "jobscript",
"type": null,
"docstring": null,
"docstring_token... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _check_authentication | <not_specific> | async def _check_authentication(
self, request, request_args, request_kwargs
):
"""
Checks a request object to determine if that request contains a valid,
and authenticated JWT.
It returns a tuple:
1. Boolean whether the request is authenticated with a valid JWT
... |
Checks a request object to determine if that request contains a valid,
and authenticated JWT.
It returns a tuple:
1. Boolean whether the request is authenticated with a valid JWT
2. HTTP status code
3. Reasons (if any) for a potential authentication failure
| Checks a request object to determine if that request contains a valid,
and authenticated JWT.
It returns a tuple:
1. Boolean whether the request is authenticated with a valid JWT
2. HTTP status code
3. Reasons (if any) for a potential authentication failure | [
"Checks",
"a",
"request",
"object",
"to",
"determine",
"if",
"that",
"request",
"contains",
"a",
"valid",
"and",
"authenticated",
"JWT",
".",
"It",
"returns",
"a",
"tuple",
":",
"1",
".",
"Boolean",
"whether",
"the",
"request",
"is",
"authenticated",
"with",... | async def _check_authentication(
self, request, request_args, request_kwargs
):
try:
is_valid, status, reasons = await self._verify(
request,
request_args=request_args,
request_kwargs=request_kwargs,
)
except Exception a... | [
"async",
"def",
"_check_authentication",
"(",
"self",
",",
"request",
",",
"request_args",
",",
"request_kwargs",
")",
":",
"try",
":",
"is_valid",
",",
"status",
",",
"reasons",
"=",
"await",
"self",
".",
"_verify",
"(",
"request",
",",
"request_args",
"=",... | Checks a request object to determine if that request contains a valid,
and authenticated JWT. | [
"Checks",
"a",
"request",
"object",
"to",
"determine",
"if",
"that",
"request",
"contains",
"a",
"valid",
"and",
"authenticated",
"JWT",
"."
] | [
"\"\"\"\n Checks a request object to determine if that request contains a valid,\n and authenticated JWT.\n\n It returns a tuple:\n 1. Boolean whether the request is authenticated with a valid JWT\n 2. HTTP status code\n 3. Reasons (if any) for a potential authentication fa... | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "request_args",
"type": null
},
{
"param": "request_kwargs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _decode | <not_specific> | async def _decode(self, token, verify=True, inline_claims=None):
"""
Take a JWT and return a decoded payload. Optionally, will verify
the claims on the token.
"""
secret = await self._get_secret(token=token)
algorithm = self._get_algorithm()
kwargs = {}
f... |
Take a JWT and return a decoded payload. Optionally, will verify
the claims on the token.
| Take a JWT and return a decoded payload. Optionally, will verify
the claims on the token. | [
"Take",
"a",
"JWT",
"and",
"return",
"a",
"decoded",
"payload",
".",
"Optionally",
"will",
"verify",
"the",
"claims",
"on",
"the",
"token",
"."
] | async def _decode(self, token, verify=True, inline_claims=None):
secret = await self._get_secret(token=token)
algorithm = self._get_algorithm()
kwargs = {}
for claim in self.claims:
if claim != "exp":
setting = "claim_{}".format(claim.lower())
... | [
"async",
"def",
"_decode",
"(",
"self",
",",
"token",
",",
"verify",
"=",
"True",
",",
"inline_claims",
"=",
"None",
")",
":",
"secret",
"=",
"await",
"self",
".",
"_get_secret",
"(",
"token",
"=",
"token",
")",
"algorithm",
"=",
"self",
".",
"_get_alg... | Take a JWT and return a decoded payload. | [
"Take",
"a",
"JWT",
"and",
"return",
"a",
"decoded",
"payload",
"."
] | [
"\"\"\"\n Take a JWT and return a decoded payload. Optionally, will verify\n the claims on the token.\n \"\"\"",
"# noqa",
"# noqa",
"# noqa"
] | [
{
"param": "self",
"type": null
},
{
"param": "token",
"type": null
},
{
"param": "verify",
"type": null
},
{
"param": "inline_claims",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "token",
"type": null,
"docstring": null,
"docstring_tokens": ... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _get_payload | <not_specific> | async def _get_payload(self, user, inline_claims=None):
"""
Given a user object, create a payload and extend it as configured.
"""
payload = await utils.call(self.build_payload, user)
if (
not isinstance(payload, dict)
or self.config.user_id() not in payl... |
Given a user object, create a payload and extend it as configured.
| Given a user object, create a payload and extend it as configured. | [
"Given",
"a",
"user",
"object",
"create",
"a",
"payload",
"and",
"extend",
"it",
"as",
"configured",
"."
] | async def _get_payload(self, user, inline_claims=None):
payload = await utils.call(self.build_payload, user)
if (
not isinstance(payload, dict)
or self.config.user_id() not in payload
):
raise exceptions.InvalidPayload
payload = await utils.call(
... | [
"async",
"def",
"_get_payload",
"(",
"self",
",",
"user",
",",
"inline_claims",
"=",
"None",
")",
":",
"payload",
"=",
"await",
"utils",
".",
"call",
"(",
"self",
".",
"build_payload",
",",
"user",
")",
"if",
"(",
"not",
"isinstance",
"(",
"payload",
"... | Given a user object, create a payload and extend it as configured. | [
"Given",
"a",
"user",
"object",
"create",
"a",
"payload",
"and",
"extend",
"it",
"as",
"configured",
"."
] | [
"\"\"\"\n Given a user object, create a payload and extend it as configured.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "inline_claims",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "user",
"type": null,
"docstring": null,
"docstring_tokens": [... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _get_refresh_token | <not_specific> | async def _get_refresh_token(self, request):
"""
Extract a refresh token from a request object.
"""
return self._get_token(request, refresh_token=True) |
Extract a refresh token from a request object.
| Extract a refresh token from a request object. | [
"Extract",
"a",
"refresh",
"token",
"from",
"a",
"request",
"object",
"."
] | async def _get_refresh_token(self, request):
return self._get_token(request, refresh_token=True) | [
"async",
"def",
"_get_refresh_token",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"_get_token",
"(",
"request",
",",
"refresh_token",
"=",
"True",
")"
] | Extract a refresh token from a request object. | [
"Extract",
"a",
"refresh",
"token",
"from",
"a",
"request",
"object",
"."
] | [
"\"\"\"\n Extract a refresh token from a request object.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _get_token_from_cookies | <not_specific> | def _get_token_from_cookies(self, request, refresh_token):
"""
Extract the token if present inside the request cookies.
"""
if refresh_token:
cookie_token_name_key = "cookie_refresh_token_name"
else:
cookie_token_name_key = "cookie_access_token_name"
... |
Extract the token if present inside the request cookies.
| Extract the token if present inside the request cookies. | [
"Extract",
"the",
"token",
"if",
"present",
"inside",
"the",
"request",
"cookies",
"."
] | def _get_token_from_cookies(self, request, refresh_token):
if refresh_token:
cookie_token_name_key = "cookie_refresh_token_name"
else:
cookie_token_name_key = "cookie_access_token_name"
cookie_token_name = getattr(self.config, cookie_token_name_key)
token = reques... | [
"def",
"_get_token_from_cookies",
"(",
"self",
",",
"request",
",",
"refresh_token",
")",
":",
"if",
"refresh_token",
":",
"cookie_token_name_key",
"=",
"\"cookie_refresh_token_name\"",
"else",
":",
"cookie_token_name_key",
"=",
"\"cookie_access_token_name\"",
"cookie_token... | Extract the token if present inside the request cookies. | [
"Extract",
"the",
"token",
"if",
"present",
"inside",
"the",
"request",
"cookies",
"."
] | [
"\"\"\"\n Extract the token if present inside the request cookies.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "refresh_token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _get_token_from_headers | <not_specific> | def _get_token_from_headers(self, request, refresh_token):
"""
Extract the token if present inside the headers of a request.
"""
header = request.headers.get(self.config.authorization_header(), None)
if header is None:
return None
else:
header_pr... |
Extract the token if present inside the headers of a request.
| Extract the token if present inside the headers of a request. | [
"Extract",
"the",
"token",
"if",
"present",
"inside",
"the",
"headers",
"of",
"a",
"request",
"."
] | def _get_token_from_headers(self, request, refresh_token):
header = request.headers.get(self.config.authorization_header(), None)
if header is None:
return None
else:
header_prefix_key = "authorization_header_prefix"
header_prefix = getattr(self.config, header... | [
"def",
"_get_token_from_headers",
"(",
"self",
",",
"request",
",",
"refresh_token",
")",
":",
"header",
"=",
"request",
".",
"headers",
".",
"get",
"(",
"self",
".",
"config",
".",
"authorization_header",
"(",
")",
",",
"None",
")",
"if",
"header",
"is",
... | Extract the token if present inside the headers of a request. | [
"Extract",
"the",
"token",
"if",
"present",
"inside",
"the",
"headers",
"of",
"a",
"request",
"."
] | [
"\"\"\"\n Extract the token if present inside the headers of a request.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "refresh_token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _get_token_from_query_string | <not_specific> | def _get_token_from_query_string(self, request, refresh_token):
"""
Extract the token if present from the request args.
"""
if refresh_token:
query_string_token_name_key = "query_string_refresh_token_name"
else:
query_string_token_name_key = "query_string_... |
Extract the token if present from the request args.
| Extract the token if present from the request args. | [
"Extract",
"the",
"token",
"if",
"present",
"from",
"the",
"request",
"args",
"."
] | def _get_token_from_query_string(self, request, refresh_token):
if refresh_token:
query_string_token_name_key = "query_string_refresh_token_name"
else:
query_string_token_name_key = "query_string_access_token_name"
query_string_token_name = getattr(
self.confi... | [
"def",
"_get_token_from_query_string",
"(",
"self",
",",
"request",
",",
"refresh_token",
")",
":",
"if",
"refresh_token",
":",
"query_string_token_name_key",
"=",
"\"query_string_refresh_token_name\"",
"else",
":",
"query_string_token_name_key",
"=",
"\"query_string_access_t... | Extract the token if present from the request args. | [
"Extract",
"the",
"token",
"if",
"present",
"from",
"the",
"request",
"args",
"."
] | [
"\"\"\"\n Extract the token if present from the request args.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "refresh_token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _get_token | <not_specific> | def _get_token(self, request, refresh_token=False):
"""
Extract a token from a request object.
"""
if self.config.cookie_set():
token = self._get_token_from_cookies(request, refresh_token)
if token:
return token
else:
i... |
Extract a token from a request object.
| Extract a token from a request object. | [
"Extract",
"a",
"token",
"from",
"a",
"request",
"object",
"."
] | def _get_token(self, request, refresh_token=False):
if self.config.cookie_set():
token = self._get_token_from_cookies(request, refresh_token)
if token:
return token
else:
if self.config.cookie_strict():
raise exceptions.Miss... | [
"def",
"_get_token",
"(",
"self",
",",
"request",
",",
"refresh_token",
"=",
"False",
")",
":",
"if",
"self",
".",
"config",
".",
"cookie_set",
"(",
")",
":",
"token",
"=",
"self",
".",
"_get_token_from_cookies",
"(",
"request",
",",
"refresh_token",
")",
... | Extract a token from a request object. | [
"Extract",
"a",
"token",
"from",
"a",
"request",
"object",
"."
] | [
"\"\"\"\n Extract a token from a request object.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "refresh_token",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | _verify | <not_specific> | async def _verify(
self,
request,
return_payload=False,
verify=True,
raise_missing=False,
request_args=None,
request_kwargs=None,
*args,
**kwargs,
):
"""
Verify that a request object is authenticated.
"""
try:
... |
Verify that a request object is authenticated.
| Verify that a request object is authenticated. | [
"Verify",
"that",
"a",
"request",
"object",
"is",
"authenticated",
"."
] | async def _verify(
self,
request,
return_payload=False,
verify=True,
raise_missing=False,
request_args=None,
request_kwargs=None,
*args,
**kwargs,
):
try:
token = self._get_token(request)
is_valid = True
... | [
"async",
"def",
"_verify",
"(",
"self",
",",
"request",
",",
"return_payload",
"=",
"False",
",",
"verify",
"=",
"True",
",",
"raise_missing",
"=",
"False",
",",
"request_args",
"=",
"None",
",",
"request_kwargs",
"=",
"None",
",",
"*",
"args",
",",
"**"... | Verify that a request object is authenticated. | [
"Verify",
"that",
"a",
"request",
"object",
"is",
"authenticated",
"."
] | [
"\"\"\"\n Verify that a request object is authenticated.\n \"\"\"",
"# Make sure that the reasons all end with '.' for consistency",
"# Make sure that the reasons all end with '.' for consistency"
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "return_payload",
"type": null
},
{
"param": "verify",
"type": null
},
{
"param": "raise_missing",
"type": null
},
{
"param": "request_args",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | extract_payload | <not_specific> | async def extract_payload(self, request, verify=True, *args, **kwargs):
"""
Extract a payload from a request object.
"""
payload = await self._verify(
request, return_payload=True, verify=verify, *args, **kwargs
)
return payload |
Extract a payload from a request object.
| Extract a payload from a request object. | [
"Extract",
"a",
"payload",
"from",
"a",
"request",
"object",
"."
] | async def extract_payload(self, request, verify=True, *args, **kwargs):
payload = await self._verify(
request, return_payload=True, verify=verify, *args, **kwargs
)
return payload | [
"async",
"def",
"extract_payload",
"(",
"self",
",",
"request",
",",
"verify",
"=",
"True",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"payload",
"=",
"await",
"self",
".",
"_verify",
"(",
"request",
",",
"return_payload",
"=",
"True",
",",
"veri... | Extract a payload from a request object. | [
"Extract",
"a",
"payload",
"from",
"a",
"request",
"object",
"."
] | [
"\"\"\"\n Extract a payload from a request object.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "verify",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | extract_scopes | <not_specific> | async def extract_scopes(self, request):
"""
Extract scopes from a request object.
"""
payload = await self.extract_payload(request)
if not payload:
return None
scopes_attribute = self.config.scopes_name()
return payload.get(scopes_attribute, None) |
Extract scopes from a request object.
| Extract scopes from a request object. | [
"Extract",
"scopes",
"from",
"a",
"request",
"object",
"."
] | async def extract_scopes(self, request):
payload = await self.extract_payload(request)
if not payload:
return None
scopes_attribute = self.config.scopes_name()
return payload.get(scopes_attribute, None) | [
"async",
"def",
"extract_scopes",
"(",
"self",
",",
"request",
")",
":",
"payload",
"=",
"await",
"self",
".",
"extract_payload",
"(",
"request",
")",
"if",
"not",
"payload",
":",
"return",
"None",
"scopes_attribute",
"=",
"self",
".",
"config",
".",
"scop... | Extract scopes from a request object. | [
"Extract",
"scopes",
"from",
"a",
"request",
"object",
"."
] | [
"\"\"\"\n Extract scopes from a request object.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | extract_user_id | <not_specific> | async def extract_user_id(self, request):
"""
Extract a user id from a request object.
"""
payload = await self.extract_payload(request)
user_id_attribute = self.config.user_id()
return payload.get(user_id_attribute, None) |
Extract a user id from a request object.
| Extract a user id from a request object. | [
"Extract",
"a",
"user",
"id",
"from",
"a",
"request",
"object",
"."
] | async def extract_user_id(self, request):
payload = await self.extract_payload(request)
user_id_attribute = self.config.user_id()
return payload.get(user_id_attribute, None) | [
"async",
"def",
"extract_user_id",
"(",
"self",
",",
"request",
")",
":",
"payload",
"=",
"await",
"self",
".",
"extract_payload",
"(",
"request",
")",
"user_id_attribute",
"=",
"self",
".",
"config",
".",
"user_id",
"(",
")",
"return",
"payload",
".",
"ge... | Extract a user id from a request object. | [
"Extract",
"a",
"user",
"id",
"from",
"a",
"request",
"object",
"."
] | [
"\"\"\"\n Extract a user id from a request object.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | generate_access_token | <not_specific> | async def generate_access_token(
self, user, extend_payload=None, custom_claims=None
):
"""
Generate an access token for a given user.
"""
payload = await self._get_payload(user, inline_claims=custom_claims)
secret = await self._get_secret(payload=payload, encode=True... |
Generate an access token for a given user.
| Generate an access token for a given user. | [
"Generate",
"an",
"access",
"token",
"for",
"a",
"given",
"user",
"."
] | async def generate_access_token(
self, user, extend_payload=None, custom_claims=None
):
payload = await self._get_payload(user, inline_claims=custom_claims)
secret = await self._get_secret(payload=payload, encode=True)
algorithm = self._get_algorithm()
if extend_payload:
... | [
"async",
"def",
"generate_access_token",
"(",
"self",
",",
"user",
",",
"extend_payload",
"=",
"None",
",",
"custom_claims",
"=",
"None",
")",
":",
"payload",
"=",
"await",
"self",
".",
"_get_payload",
"(",
"user",
",",
"inline_claims",
"=",
"custom_claims",
... | Generate an access token for a given user. | [
"Generate",
"an",
"access",
"token",
"for",
"a",
"given",
"user",
"."
] | [
"\"\"\"\n Generate an access token for a given user.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "extend_payload",
"type": null
},
{
"param": "custom_claims",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "user",
"type": null,
"docstring": null,
"docstring_tokens": [... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | generate_refresh_token | <not_specific> | async def generate_refresh_token(self, request, user):
"""
Generate a refresh token for a given user.
"""
refresh_token = await utils.call(self.config.generate_refresh_token())
user_id = await self._get_user_id(user)
await utils.call(
self.store_refresh_token,... |
Generate a refresh token for a given user.
| Generate a refresh token for a given user. | [
"Generate",
"a",
"refresh",
"token",
"for",
"a",
"given",
"user",
"."
] | async def generate_refresh_token(self, request, user):
refresh_token = await utils.call(self.config.generate_refresh_token())
user_id = await self._get_user_id(user)
await utils.call(
self.store_refresh_token,
user_id=user_id,
refresh_token=refresh_token,
... | [
"async",
"def",
"generate_refresh_token",
"(",
"self",
",",
"request",
",",
"user",
")",
":",
"refresh_token",
"=",
"await",
"utils",
".",
"call",
"(",
"self",
".",
"config",
".",
"generate_refresh_token",
"(",
")",
")",
"user_id",
"=",
"await",
"self",
".... | Generate a refresh token for a given user. | [
"Generate",
"a",
"refresh",
"token",
"for",
"a",
"given",
"user",
"."
] | [
"\"\"\"\n Generate a refresh token for a given user.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "user",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | is_authenticated | <not_specific> | async def is_authenticated(self, request):
"""
Checks a request object to determine if that request contains a valid,
and authenticated JWT.
"""
is_valid, *_ = await self._verify(request)
return is_valid |
Checks a request object to determine if that request contains a valid,
and authenticated JWT.
| Checks a request object to determine if that request contains a valid,
and authenticated JWT. | [
"Checks",
"a",
"request",
"object",
"to",
"determine",
"if",
"that",
"request",
"contains",
"a",
"valid",
"and",
"authenticated",
"JWT",
"."
] | async def is_authenticated(self, request):
is_valid, *_ = await self._verify(request)
return is_valid | [
"async",
"def",
"is_authenticated",
"(",
"self",
",",
"request",
")",
":",
"is_valid",
",",
"*",
"_",
"=",
"await",
"self",
".",
"_verify",
"(",
"request",
")",
"return",
"is_valid"
] | Checks a request object to determine if that request contains a valid,
and authenticated JWT. | [
"Checks",
"a",
"request",
"object",
"to",
"determine",
"if",
"that",
"request",
"contains",
"a",
"valid",
"and",
"authenticated",
"JWT",
"."
] | [
"\"\"\"\n Checks a request object to determine if that request contains a valid,\n and authenticated JWT.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
4ca4ea1232d28de0cf9de6a1a15736d57ed156fe | jekel/sanic-jwt | sanic_jwt/authentication.py | [
"MIT"
] | Python | verify_token | <not_specific> | async def verify_token(
self, token, return_payload=False, custom_claims=None
):
"""
Perform an inline verification of a token.
"""
payload = await self._decode(token, inline_claims=custom_claims)
return payload if return_payload else bool(payload) |
Perform an inline verification of a token.
| Perform an inline verification of a token. | [
"Perform",
"an",
"inline",
"verification",
"of",
"a",
"token",
"."
] | async def verify_token(
self, token, return_payload=False, custom_claims=None
):
payload = await self._decode(token, inline_claims=custom_claims)
return payload if return_payload else bool(payload) | [
"async",
"def",
"verify_token",
"(",
"self",
",",
"token",
",",
"return_payload",
"=",
"False",
",",
"custom_claims",
"=",
"None",
")",
":",
"payload",
"=",
"await",
"self",
".",
"_decode",
"(",
"token",
",",
"inline_claims",
"=",
"custom_claims",
")",
"re... | Perform an inline verification of a token. | [
"Perform",
"an",
"inline",
"verification",
"of",
"a",
"token",
"."
] | [
"\"\"\"\n Perform an inline verification of a token.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "token",
"type": null
},
{
"param": "return_payload",
"type": null
},
{
"param": "custom_claims",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "token",
"type": null,
"docstring": null,
"docstring_tokens": ... |
98a7c82f91de6b013193dce3dfbe4dbcc42c3696 | jekel/sanic-jwt | sanic_jwt/configuration.py | [
"MIT"
] | Python | extract_presets | <not_specific> | def extract_presets(app_config):
"""
Pull the application's configurations for Sanic JWT
"""
return {
x.lower()[10:]: app_config.get(x)
for x in filter(lambda x: x.startswith("SANIC_JWT"), app_config)
} |
Pull the application's configurations for Sanic JWT
| Pull the application's configurations for Sanic JWT | [
"Pull",
"the",
"application",
"'",
"s",
"configurations",
"for",
"Sanic",
"JWT"
] | def extract_presets(app_config):
return {
x.lower()[10:]: app_config.get(x)
for x in filter(lambda x: x.startswith("SANIC_JWT"), app_config)
} | [
"def",
"extract_presets",
"(",
"app_config",
")",
":",
"return",
"{",
"x",
".",
"lower",
"(",
")",
"[",
"10",
":",
"]",
":",
"app_config",
".",
"get",
"(",
"x",
")",
"for",
"x",
"in",
"filter",
"(",
"lambda",
"x",
":",
"x",
".",
"startswith",
"("... | Pull the application's configurations for Sanic JWT | [
"Pull",
"the",
"application",
"'",
"s",
"configurations",
"for",
"Sanic",
"JWT"
] | [
"\"\"\"\n Pull the application's configurations for Sanic JWT\n \"\"\""
] | [
{
"param": "app_config",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "app_config",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c44fae09e275f706c2352ef488de47b9042b2934 | glibesyck/web_map | data.py | [
"MIT"
] | Python | writing_csv_file | null | def writing_csv_file (locations:list) :
'''
Writes given information in CSV file (film, year, location, latitude, longitude).
'''
start_idx = 10000 #there are a lot of data so I will go only with these films
end_idx = 15000
idx = 0
with open('locations1.csv', 'w') as locations_file :
... |
Writes given information in CSV file (film, year, location, latitude, longitude).
| Writes given information in CSV file (film, year, location, latitude, longitude). | [
"Writes",
"given",
"information",
"in",
"CSV",
"file",
"(",
"film",
"year",
"location",
"latitude",
"longitude",
")",
"."
] | def writing_csv_file (locations:list) :
start_idx = 10000
end_idx = 15000
idx = 0
with open('locations1.csv', 'w') as locations_file :
locations_writer = csv.writer(locations_file, delimiter=',')
for line in locations :
idx += 1
if start_idx < idx < end_idx :
... | [
"def",
"writing_csv_file",
"(",
"locations",
":",
"list",
")",
":",
"start_idx",
"=",
"10000",
"end_idx",
"=",
"15000",
"idx",
"=",
"0",
"with",
"open",
"(",
"'locations1.csv'",
",",
"'w'",
")",
"as",
"locations_file",
":",
"locations_writer",
"=",
"csv",
... | Writes given information in CSV file (film, year, location, latitude, longitude). | [
"Writes",
"given",
"information",
"in",
"CSV",
"file",
"(",
"film",
"year",
"location",
"latitude",
"longitude",
")",
"."
] | [
"'''\n Writes given information in CSV file (film, year, location, latitude, longitude).\n '''",
"#there are a lot of data so I will go only with these films"
] | [
{
"param": "locations",
"type": "list"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "locations",
"type": "list",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
95ab196aa7b948177aed5d38fe28689c5e79df34 | glibesyck/web_map | map_generating.py | [
"MIT"
] | Python | haversine_distance | float | def haversine_distance(lng1, lat1, lng2, lat2) -> float:
'''
Return the distance between two point on Earth with given longitudes and
latitudes.
>>> haversine_distance(24.05, 48.08, 24.06, 48.09)
1.3372365823409342
>>> haversine_distance(48.08, 24.05, 48.09, 24.06)
1.5057991000504831
'''... |
Return the distance between two point on Earth with given longitudes and
latitudes.
>>> haversine_distance(24.05, 48.08, 24.06, 48.09)
1.3372365823409342
>>> haversine_distance(48.08, 24.05, 48.09, 24.06)
1.5057991000504831
| Return the distance between two point on Earth with given longitudes and
latitudes. | [
"Return",
"the",
"distance",
"between",
"two",
"point",
"on",
"Earth",
"with",
"given",
"longitudes",
"and",
"latitudes",
"."
] | def haversine_distance(lng1, lat1, lng2, lat2) -> float:
lng1, lat1, lng2, lat2 = map(radians, [lng1, lat1, lng2, lat2])
dlng = lng2-lng1
dlat = lat2-lat1
value = 2*asin(sqrt(sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlng/2)**2))
return value*6371 | [
"def",
"haversine_distance",
"(",
"lng1",
",",
"lat1",
",",
"lng2",
",",
"lat2",
")",
"->",
"float",
":",
"lng1",
",",
"lat1",
",",
"lng2",
",",
"lat2",
"=",
"map",
"(",
"radians",
",",
"[",
"lng1",
",",
"lat1",
",",
"lng2",
",",
"lat2",
"]",
")"... | Return the distance between two point on Earth with given longitudes and
latitudes. | [
"Return",
"the",
"distance",
"between",
"two",
"point",
"on",
"Earth",
"with",
"given",
"longitudes",
"and",
"latitudes",
"."
] | [
"'''\n Return the distance between two point on Earth with given longitudes and\n latitudes.\n >>> haversine_distance(24.05, 48.08, 24.06, 48.09)\n 1.3372365823409342\n >>> haversine_distance(48.08, 24.05, 48.09, 24.06)\n 1.5057991000504831\n '''",
"#convert to radians",
"#haversine formula... | [
{
"param": "lng1",
"type": null
},
{
"param": "lat1",
"type": null
},
{
"param": "lng2",
"type": null
},
{
"param": "lat2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lng1",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lat1",
"type": null,
"docstring": null,
"docstring_tokens": [... |
95ab196aa7b948177aed5d38fe28689c5e79df34 | glibesyck/web_map | map_generating.py | [
"MIT"
] | Python | distance_films | list | def distance_films(year:int, lat:float, lng:float, file:str) -> list:
'''
Return list of tuples (each is (film, distance_in_km)) of films which were
released in the given year, distance_in_km is distance from given point.
'''
list_of_films = []
with open (file, 'r') as csv_file :
csv_rea... |
Return list of tuples (each is (film, distance_in_km)) of films which were
released in the given year, distance_in_km is distance from given point.
| Return list of tuples (each is (film, distance_in_km)) of films which were
released in the given year, distance_in_km is distance from given point. | [
"Return",
"list",
"of",
"tuples",
"(",
"each",
"is",
"(",
"film",
"distance_in_km",
"))",
"of",
"films",
"which",
"were",
"released",
"in",
"the",
"given",
"year",
"distance_in_km",
"is",
"distance",
"from",
"given",
"point",
"."
] | def distance_films(year:int, lat:float, lng:float, file:str) -> list:
list_of_films = []
with open (file, 'r') as csv_file :
csv_reader = csv.reader(csv_file, delimiter=',')
for line in csv_reader :
if int(line[1]) == year :
distance = haversine_distance(float(line[3]... | [
"def",
"distance_films",
"(",
"year",
":",
"int",
",",
"lat",
":",
"float",
",",
"lng",
":",
"float",
",",
"file",
":",
"str",
")",
"->",
"list",
":",
"list_of_films",
"=",
"[",
"]",
"with",
"open",
"(",
"file",
",",
"'r'",
")",
"as",
"csv_file",
... | Return list of tuples (each is (film, distance_in_km)) of films which were
released in the given year, distance_in_km is distance from given point. | [
"Return",
"list",
"of",
"tuples",
"(",
"each",
"is",
"(",
"film",
"distance_in_km",
"))",
"of",
"films",
"which",
"were",
"released",
"in",
"the",
"given",
"year",
"distance_in_km",
"is",
"distance",
"from",
"given",
"point",
"."
] | [
"'''\n Return list of tuples (each is (film, distance_in_km)) of films which were\n released in the given year, distance_in_km is distance from given point.\n '''"
] | [
{
"param": "year",
"type": "int"
},
{
"param": "lat",
"type": "float"
},
{
"param": "lng",
"type": "float"
},
{
"param": "file",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "year",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lat",
"type": "float",
"docstring": null,
"docstring_tokens"... |
95ab196aa7b948177aed5d38fe28689c5e79df34 | glibesyck/web_map | map_generating.py | [
"MIT"
] | Python | ten_nearest | list | def ten_nearest(list_of_films:list) -> list:
'''
Return ten (or less) most close to films to given point.
'''
nearest_films = []
for bottom in range (len(list_of_films) - 1) :
idx = bottom
for itr in range (bottom+1, len(list_of_films)) :
if list_of_films[itr][1] < list_o... |
Return ten (or less) most close to films to given point.
| Return ten (or less) most close to films to given point. | [
"Return",
"ten",
"(",
"or",
"less",
")",
"most",
"close",
"to",
"films",
"to",
"given",
"point",
"."
] | def ten_nearest(list_of_films:list) -> list:
nearest_films = []
for bottom in range (len(list_of_films) - 1) :
idx = bottom
for itr in range (bottom+1, len(list_of_films)) :
if list_of_films[itr][1] < list_of_films[idx][1] :
idx = itr
list_of_films[bottom], li... | [
"def",
"ten_nearest",
"(",
"list_of_films",
":",
"list",
")",
"->",
"list",
":",
"nearest_films",
"=",
"[",
"]",
"for",
"bottom",
"in",
"range",
"(",
"len",
"(",
"list_of_films",
")",
"-",
"1",
")",
":",
"idx",
"=",
"bottom",
"for",
"itr",
"in",
"ran... | Return ten (or less) most close to films to given point. | [
"Return",
"ten",
"(",
"or",
"less",
")",
"most",
"close",
"to",
"films",
"to",
"given",
"point",
"."
] | [
"'''\n Return ten (or less) most close to films to given point.\n '''",
"#sorting by distance"
] | [
{
"param": "list_of_films",
"type": "list"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_of_films",
"type": "list",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
95ab196aa7b948177aed5d38fe28689c5e79df34 | glibesyck/web_map | map_generating.py | [
"MIT"
] | Python | generating_map | <not_specific> | def generating_map(list_of_films:list, lat:float, lng:float, year:int) :
'''
Generates map with given properties.
'''
map = folium.Map(location=[lat, lng], zoom_start=1000)
fg_films = folium.FeatureGroup(name='Films')
for film in list_of_films :
fg_films.add_child(folium.Marker(location=... |
Generates map with given properties.
| Generates map with given properties. | [
"Generates",
"map",
"with",
"given",
"properties",
"."
] | def generating_map(list_of_films:list, lat:float, lng:float, year:int) :
map = folium.Map(location=[lat, lng], zoom_start=1000)
fg_films = folium.FeatureGroup(name='Films')
for film in list_of_films :
fg_films.add_child(folium.Marker(location=[film[1], film[2]],
popup=film[0], icon=folium.Ic... | [
"def",
"generating_map",
"(",
"list_of_films",
":",
"list",
",",
"lat",
":",
"float",
",",
"lng",
":",
"float",
",",
"year",
":",
"int",
")",
":",
"map",
"=",
"folium",
".",
"Map",
"(",
"location",
"=",
"[",
"lat",
",",
"lng",
"]",
",",
"zoom_start... | Generates map with given properties. | [
"Generates",
"map",
"with",
"given",
"properties",
"."
] | [
"'''\n Generates map with given properties.\n '''"
] | [
{
"param": "list_of_films",
"type": "list"
},
{
"param": "lat",
"type": "float"
},
{
"param": "lng",
"type": "float"
},
{
"param": "year",
"type": "int"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "list_of_films",
"type": "list",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lat",
"type": "float",
"docstring": null,
"docstri... |
95cc7c2ad2775098d147df5fd0b53de8f2aec13d | milikhin/seabass-editor | generic/py-backend/fs_utils/list_dir.py | [
"MIT"
] | Python | _extract_file_info | <not_specific> | def _extract_file_info(directory, root_path, name):
"""Returns file description required for QML FileList component.
Keyword arguments:
directory -- file directory
root_path -- current root directory (to estimate nested level)
name -- file name
"""
file_path = join(directory, name)
rel_... | Returns file description required for QML FileList component.
Keyword arguments:
directory -- file directory
root_path -- current root directory (to estimate nested level)
name -- file name
| Returns file description required for QML FileList component. | [
"Returns",
"file",
"description",
"required",
"for",
"QML",
"FileList",
"component",
"."
] | def _extract_file_info(directory, root_path, name):
file_path = join(directory, name)
rel_path = relpath(file_path, root_path)
return {
"name": name,
"path": file_path,
"dir_name": dirname(file_path),
"is_file": isfile(file_path),
"is_dir": isdir(file_path),
"... | [
"def",
"_extract_file_info",
"(",
"directory",
",",
"root_path",
",",
"name",
")",
":",
"file_path",
"=",
"join",
"(",
"directory",
",",
"name",
")",
"rel_path",
"=",
"relpath",
"(",
"file_path",
",",
"root_path",
")",
"return",
"{",
"\"name\"",
":",
"name... | Returns file description required for QML FileList component. | [
"Returns",
"file",
"description",
"required",
"for",
"QML",
"FileList",
"component",
"."
] | [
"\"\"\"Returns file description required for QML FileList component.\n\n Keyword arguments:\n directory -- file directory\n root_path -- current root directory (to estimate nested level)\n name -- file name\n \"\"\""
] | [
{
"param": "directory",
"type": null
},
{
"param": "root_path",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "directory",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "root_path",
"type": null,
"docstring": null,
"docstring_... |
95cc7c2ad2775098d147df5fd0b53de8f2aec13d | milikhin/seabass-editor | generic/py-backend/fs_utils/list_dir.py | [
"MIT"
] | Python | _extreact_qml_file_info | <not_specific> | def _extreact_qml_file_info(file):
"""Returns file object in QML-ready format"""
return {
"name": file["name"],
"path": file["path"],
"isFile": file["is_file"],
"isDir": file["is_dir"],
"level": file["level"]
} | Returns file object in QML-ready format | Returns file object in QML-ready format | [
"Returns",
"file",
"object",
"in",
"QML",
"-",
"ready",
"format"
] | def _extreact_qml_file_info(file):
return {
"name": file["name"],
"path": file["path"],
"isFile": file["is_file"],
"isDir": file["is_dir"],
"level": file["level"]
} | [
"def",
"_extreact_qml_file_info",
"(",
"file",
")",
":",
"return",
"{",
"\"name\"",
":",
"file",
"[",
"\"name\"",
"]",
",",
"\"path\"",
":",
"file",
"[",
"\"path\"",
"]",
",",
"\"isFile\"",
":",
"file",
"[",
"\"is_file\"",
"]",
",",
"\"isDir\"",
":",
"fi... | Returns file object in QML-ready format | [
"Returns",
"file",
"object",
"in",
"QML",
"-",
"ready",
"format"
] | [
"\"\"\"Returns file object in QML-ready format\"\"\""
] | [
{
"param": "file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
95cc7c2ad2775098d147df5fd0b53de8f2aec13d | milikhin/seabass-editor | generic/py-backend/fs_utils/list_dir.py | [
"MIT"
] | Python | _filename_comparator | <not_specific> | def _filename_comparator(a_str, b_str):
"""Compares file name (case insensitive)"""
if a_str.lower() < b_str.lower():
return -1
if a_str.lower() > b_str.lower():
return 1
return 0 | Compares file name (case insensitive) | Compares file name (case insensitive) | [
"Compares",
"file",
"name",
"(",
"case",
"insensitive",
")"
] | def _filename_comparator(a_str, b_str):
if a_str.lower() < b_str.lower():
return -1
if a_str.lower() > b_str.lower():
return 1
return 0 | [
"def",
"_filename_comparator",
"(",
"a_str",
",",
"b_str",
")",
":",
"if",
"a_str",
".",
"lower",
"(",
")",
"<",
"b_str",
".",
"lower",
"(",
")",
":",
"return",
"-",
"1",
"if",
"a_str",
".",
"lower",
"(",
")",
">",
"b_str",
".",
"lower",
"(",
")"... | Compares file name (case insensitive) | [
"Compares",
"file",
"name",
"(",
"case",
"insensitive",
")"
] | [
"\"\"\"Compares file name (case insensitive)\"\"\""
] | [
{
"param": "a_str",
"type": null
},
{
"param": "b_str",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a_str",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b_str",
"type": null,
"docstring": null,
"docstring_tokens":... |
95cc7c2ad2775098d147df5fd0b53de8f2aec13d | milikhin/seabass-editor | generic/py-backend/fs_utils/list_dir.py | [
"MIT"
] | Python | _same_dir_file_comparator | <not_specific> | def _same_dir_file_comparator(a_file, b_file):
"""
Cmp function for files within the same dir.
Sorts directories first.
"""
if a_file["is_dir"] and not b_file["is_dir"]:
return -1
if not a_file["is_dir"] and b_file["is_dir"]:
return 1
return _filename_comparator(a_file["name"... |
Cmp function for files within the same dir.
Sorts directories first.
| Cmp function for files within the same dir.
Sorts directories first. | [
"Cmp",
"function",
"for",
"files",
"within",
"the",
"same",
"dir",
".",
"Sorts",
"directories",
"first",
"."
] | def _same_dir_file_comparator(a_file, b_file):
if a_file["is_dir"] and not b_file["is_dir"]:
return -1
if not a_file["is_dir"] and b_file["is_dir"]:
return 1
return _filename_comparator(a_file["name"], b_file["name"]) | [
"def",
"_same_dir_file_comparator",
"(",
"a_file",
",",
"b_file",
")",
":",
"if",
"a_file",
"[",
"\"is_dir\"",
"]",
"and",
"not",
"b_file",
"[",
"\"is_dir\"",
"]",
":",
"return",
"-",
"1",
"if",
"not",
"a_file",
"[",
"\"is_dir\"",
"]",
"and",
"b_file",
"... | Cmp function for files within the same dir. | [
"Cmp",
"function",
"for",
"files",
"within",
"the",
"same",
"dir",
"."
] | [
"\"\"\"\n Cmp function for files within the same dir.\n Sorts directories first.\n \"\"\""
] | [
{
"param": "a_file",
"type": null
},
{
"param": "b_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b_file",
"type": null,
"docstring": null,
"docstring_tokens... |
95cc7c2ad2775098d147df5fd0b53de8f2aec13d | milikhin/seabass-editor | generic/py-backend/fs_utils/list_dir.py | [
"MIT"
] | Python | _diff_dir_file_comparator | <not_specific> | def _diff_dir_file_comparator(a_file, b_file):
"""
Cmp function for files within different dirs.
Entry's children are placed before the next sibling.
"""
a_dir_path = a_file["path"] if a_file["is_dir"] else a_file["dir_name"]
b_dir_path = b_file["path"] if b_file["is_dir"] else b_file["dir_name"... |
Cmp function for files within different dirs.
Entry's children are placed before the next sibling.
| Cmp function for files within different dirs.
Entry's children are placed before the next sibling. | [
"Cmp",
"function",
"for",
"files",
"within",
"different",
"dirs",
".",
"Entry",
"'",
"s",
"children",
"are",
"placed",
"before",
"the",
"next",
"sibling",
"."
] | def _diff_dir_file_comparator(a_file, b_file):
a_dir_path = a_file["path"] if a_file["is_dir"] else a_file["dir_name"]
b_dir_path = b_file["path"] if b_file["is_dir"] else b_file["dir_name"]
common_path = commonpath([a_dir_path, b_dir_path])
a_rel_path = relpath(a_dir_path, common_path)
b_rel_path =... | [
"def",
"_diff_dir_file_comparator",
"(",
"a_file",
",",
"b_file",
")",
":",
"a_dir_path",
"=",
"a_file",
"[",
"\"path\"",
"]",
"if",
"a_file",
"[",
"\"is_dir\"",
"]",
"else",
"a_file",
"[",
"\"dir_name\"",
"]",
"b_dir_path",
"=",
"b_file",
"[",
"\"path\"",
"... | Cmp function for files within different dirs. | [
"Cmp",
"function",
"for",
"files",
"within",
"different",
"dirs",
"."
] | [
"\"\"\"\n Cmp function for files within different dirs.\n Entry's children are placed before the next sibling.\n \"\"\""
] | [
{
"param": "a_file",
"type": null
},
{
"param": "b_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b_file",
"type": null,
"docstring": null,
"docstring_tokens... |
95cc7c2ad2775098d147df5fd0b53de8f2aec13d | milikhin/seabass-editor | generic/py-backend/fs_utils/list_dir.py | [
"MIT"
] | Python | _file_comparator | <not_specific> | def _file_comparator(a_file, b_file):
"""
Comparator for sorting files list.
Sorting order ensures that printing the list gives us in a tree-like representation:
- dir1
- dir1/nested_dir1
- dir1/nested_dir1/very_nested_dir1
- dir1/nested_file1
- dir2
- file1
- ...
Rules:
... |
Comparator for sorting files list.
Sorting order ensures that printing the list gives us in a tree-like representation:
- dir1
- dir1/nested_dir1
- dir1/nested_dir1/very_nested_dir1
- dir1/nested_file1
- dir2
- file1
- ...
Rules:
- directories have priority over files at th... | Comparator for sorting files list.
Sorting order ensures that printing the list gives us in a tree-like representation:
dir1
dir1/nested_dir1
dir1/nested_dir1/very_nested_dir1
dir1/nested_file1
dir2
file1
directories have priority over files at the same level
nested directories and files must follow parent directory
(... | [
"Comparator",
"for",
"sorting",
"files",
"list",
".",
"Sorting",
"order",
"ensures",
"that",
"printing",
"the",
"list",
"gives",
"us",
"in",
"a",
"tree",
"-",
"like",
"representation",
":",
"dir1",
"dir1",
"/",
"nested_dir1",
"dir1",
"/",
"nested_dir1",
"/",... | def _file_comparator(a_file, b_file):
if a_file["dir_name"] == b_file["dir_name"]:
return _same_dir_file_comparator(a_file, b_file)
return _diff_dir_file_comparator(a_file, b_file) | [
"def",
"_file_comparator",
"(",
"a_file",
",",
"b_file",
")",
":",
"if",
"a_file",
"[",
"\"dir_name\"",
"]",
"==",
"b_file",
"[",
"\"dir_name\"",
"]",
":",
"return",
"_same_dir_file_comparator",
"(",
"a_file",
",",
"b_file",
")",
"return",
"_diff_dir_file_compar... | Comparator for sorting files list. | [
"Comparator",
"for",
"sorting",
"files",
"list",
"."
] | [
"\"\"\"\n Comparator for sorting files list.\n Sorting order ensures that printing the list gives us in a tree-like representation:\n - dir1\n - dir1/nested_dir1\n - dir1/nested_dir1/very_nested_dir1\n - dir1/nested_file1\n - dir2\n - file1\n - ...\n\n Rules:\n - directories have pr... | [
{
"param": "a_file",
"type": null
},
{
"param": "b_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "b_file",
"type": null,
"docstring": null,
"docstring_tokens... |
95cc7c2ad2775098d147df5fd0b53de8f2aec13d | milikhin/seabass-editor | generic/py-backend/fs_utils/list_dir.py | [
"MIT"
] | Python | _list_dir | <not_specific> | def _list_dir(directories):
"""
Returns listing of directory content
Keyword arguments:
directories -- directories to list files
"""
request_dirs = list(filter(exists, directories))
root_path = commonpath(request_dirs)
dir_content = [_extract_file_info(directory, root_path, file_name)
... |
Returns listing of directory content
Keyword arguments:
directories -- directories to list files
| Returns listing of directory content
Keyword arguments:
directories -- directories to list files | [
"Returns",
"listing",
"of",
"directory",
"content",
"Keyword",
"arguments",
":",
"directories",
"--",
"directories",
"to",
"list",
"files"
] | def _list_dir(directories):
request_dirs = list(filter(exists, directories))
root_path = commonpath(request_dirs)
dir_content = [_extract_file_info(directory, root_path, file_name)
for directory in request_dirs
for file_name in listdir(directory)]
tree_entries = [fi... | [
"def",
"_list_dir",
"(",
"directories",
")",
":",
"request_dirs",
"=",
"list",
"(",
"filter",
"(",
"exists",
",",
"directories",
")",
")",
"root_path",
"=",
"commonpath",
"(",
"request_dirs",
")",
"dir_content",
"=",
"[",
"_extract_file_info",
"(",
"directory"... | Returns listing of directory content
Keyword arguments:
directories -- directories to list files | [
"Returns",
"listing",
"of",
"directory",
"content",
"Keyword",
"arguments",
":",
"directories",
"--",
"directories",
"to",
"list",
"files"
] | [
"\"\"\"\n Returns listing of directory content\n\n Keyword arguments:\n directories -- directories to list files\n \"\"\""
] | [
{
"param": "directories",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "directories",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c8ed02bdf2e0601a0f958e17d4eb1ca458f3db2e | milikhin/seabass-editor | generic/py-backend/tests/fs_utils_test.py | [
"MIT"
] | Python | _generate_notification | null | def _generate_notification():
"""
Registers notification for tmp dir and create a file there.
Should generate a notification
"""
notification_thread = watch_changes([gettempdir()])
sleep(0.25)
_create_tmp_file()
# wait for notifications thread to end
notification_thread.join() |
Registers notification for tmp dir and create a file there.
Should generate a notification
| Registers notification for tmp dir and create a file there.
Should generate a notification | [
"Registers",
"notification",
"for",
"tmp",
"dir",
"and",
"create",
"a",
"file",
"there",
".",
"Should",
"generate",
"a",
"notification"
] | def _generate_notification():
notification_thread = watch_changes([gettempdir()])
sleep(0.25)
_create_tmp_file()
notification_thread.join() | [
"def",
"_generate_notification",
"(",
")",
":",
"notification_thread",
"=",
"watch_changes",
"(",
"[",
"gettempdir",
"(",
")",
"]",
")",
"sleep",
"(",
"0.25",
")",
"_create_tmp_file",
"(",
")",
"notification_thread",
".",
"join",
"(",
")"
] | Registers notification for tmp dir and create a file there. | [
"Registers",
"notification",
"for",
"tmp",
"dir",
"and",
"create",
"a",
"file",
"there",
"."
] | [
"\"\"\"\n Registers notification for tmp dir and create a file there.\n Should generate a notification\n \"\"\"",
"# wait for notifications thread to end"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c3345255534a68e300880c7f6214bf505e425d3e | milikhin/seabass-editor | generic/py-backend/fs_utils/content_hub.py | [
"MIT"
] | Python | _guess | <not_specific> | def _guess(app_name, file_name):
"""
HAK!
We are going to parse filemanager logs to guess content hub's source file's name
Thanks to https://gitlab.com/BlueKenny/uText/-/blob/master/qml/Main.py
"""
source_log_file = None
for log_entry in listdir(LOG_PATH):
if app_name + ".log" in lo... |
HAK!
We are going to parse filemanager logs to guess content hub's source file's name
Thanks to https://gitlab.com/BlueKenny/uText/-/blob/master/qml/Main.py
| HAK.
We are going to parse filemanager logs to guess content hub's source file's name
| [
"HAK",
".",
"We",
"are",
"going",
"to",
"parse",
"filemanager",
"logs",
"to",
"guess",
"content",
"hub",
"'",
"s",
"source",
"file",
"'",
"s",
"name"
] | def _guess(app_name, file_name):
source_log_file = None
for log_entry in listdir(LOG_PATH):
if app_name + ".log" in log_entry and not ".gz" in log_entry:
source_log_file = log_entry
if not source_log_file:
raise Exception("Source log file is not found for {}".format(app_name))
... | [
"def",
"_guess",
"(",
"app_name",
",",
"file_name",
")",
":",
"source_log_file",
"=",
"None",
"for",
"log_entry",
"in",
"listdir",
"(",
"LOG_PATH",
")",
":",
"if",
"app_name",
"+",
"\".log\"",
"in",
"log_entry",
"and",
"not",
"\".gz\"",
"in",
"log_entry",
... | HAK! | [
"HAK!"
] | [
"\"\"\"\n HAK!\n We are going to parse filemanager logs to guess content hub's source file's name\n\n Thanks to https://gitlab.com/BlueKenny/uText/-/blob/master/qml/Main.py\n \"\"\""
] | [
{
"param": "app_name",
"type": null
},
{
"param": "file_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "app_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file_name",
"type": null,
"docstring": null,
"docstring_t... |
5f8b433550b08818d90e253884738efdc17175bb | milikhin/seabass-editor | generic/py-backend/build_utils/scripts.py | [
"MIT"
] | Python | build | <not_specific> | def build(config_file, install=False):
"""
Runs build for the given clickable.json file
Keyword arguments:
config_file -- path to clickable.json
install -- true to install/launch buit app
"""
return exec_fn(lambda: _build(config_file, install)) |
Runs build for the given clickable.json file
Keyword arguments:
config_file -- path to clickable.json
install -- true to install/launch buit app
| Runs build for the given clickable.json file
Keyword arguments:
config_file -- path to clickable.json
install -- true to install/launch buit app | [
"Runs",
"build",
"for",
"the",
"given",
"clickable",
".",
"json",
"file",
"Keyword",
"arguments",
":",
"config_file",
"--",
"path",
"to",
"clickable",
".",
"json",
"install",
"--",
"true",
"to",
"install",
"/",
"launch",
"buit",
"app"
] | def build(config_file, install=False):
return exec_fn(lambda: _build(config_file, install)) | [
"def",
"build",
"(",
"config_file",
",",
"install",
"=",
"False",
")",
":",
"return",
"exec_fn",
"(",
"lambda",
":",
"_build",
"(",
"config_file",
",",
"install",
")",
")"
] | Runs build for the given clickable.json file
Keyword arguments:
config_file -- path to clickable.json
install -- true to install/launch buit app | [
"Runs",
"build",
"for",
"the",
"given",
"clickable",
".",
"json",
"file",
"Keyword",
"arguments",
":",
"config_file",
"--",
"path",
"to",
"clickable",
".",
"json",
"install",
"--",
"true",
"to",
"install",
"/",
"launch",
"buit",
"app"
] | [
"\"\"\"\n Runs build for the given clickable.json file\n\n Keyword arguments:\n config_file -- path to clickable.json\n install -- true to install/launch buit app\n \"\"\""
] | [
{
"param": "config_file",
"type": null
},
{
"param": "install",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "config_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "install",
"type": null,
"docstring": null,
"docstring_... |
5f8b433550b08818d90e253884738efdc17175bb | milikhin/seabass-editor | generic/py-backend/build_utils/scripts.py | [
"MIT"
] | Python | ensure_container | <not_specific> | def ensure_container():
"""
Creates a Libertine container to execute clickable if not exists
"""
return exec_fn(_init_container) |
Creates a Libertine container to execute clickable if not exists
| Creates a Libertine container to execute clickable if not exists | [
"Creates",
"a",
"Libertine",
"container",
"to",
"execute",
"clickable",
"if",
"not",
"exists"
] | def ensure_container():
return exec_fn(_init_container) | [
"def",
"ensure_container",
"(",
")",
":",
"return",
"exec_fn",
"(",
"_init_container",
")"
] | Creates a Libertine container to execute clickable if not exists | [
"Creates",
"a",
"Libertine",
"container",
"to",
"execute",
"clickable",
"if",
"not",
"exists"
] | [
"\"\"\"\n Creates a Libertine container to execute clickable if not exists\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5f8b433550b08818d90e253884738efdc17175bb | milikhin/seabass-editor | generic/py-backend/build_utils/scripts.py | [
"MIT"
] | Python | update_container | <not_specific> | def update_container():
"""
Upgrades built tools within a Libertine container
"""
return exec_fn(_update_container) |
Upgrades built tools within a Libertine container
| Upgrades built tools within a Libertine container | [
"Upgrades",
"built",
"tools",
"within",
"a",
"Libertine",
"container"
] | def update_container():
return exec_fn(_update_container) | [
"def",
"update_container",
"(",
")",
":",
"return",
"exec_fn",
"(",
"_update_container",
")"
] | Upgrades built tools within a Libertine container | [
"Upgrades",
"built",
"tools",
"within",
"a",
"Libertine",
"container"
] | [
"\"\"\"\n Upgrades built tools within a Libertine container\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d57b095c7b318e76ad1b1bee0fae44933f2fe6a3 | milikhin/seabass-editor | generic/py-backend/helpers/exec_fn.py | [
"MIT"
] | Python | exec_fn | <not_specific> | def exec_fn(func):
"""Executes given function, returns {error,result} dict"""
try:
return {'result': func()}
except Exception as error: # pylint: disable=broad-except
return {'error': str(error)} | Executes given function, returns {error,result} dict | Executes given function, returns {error,result} dict | [
"Executes",
"given",
"function",
"returns",
"{",
"error",
"result",
"}",
"dict"
] | def exec_fn(func):
try:
return {'result': func()}
except Exception as error:
return {'error': str(error)} | [
"def",
"exec_fn",
"(",
"func",
")",
":",
"try",
":",
"return",
"{",
"'result'",
":",
"func",
"(",
")",
"}",
"except",
"Exception",
"as",
"error",
":",
"return",
"{",
"'error'",
":",
"str",
"(",
"error",
")",
"}"
] | Executes given function, returns {error,result} dict | [
"Executes",
"given",
"function",
"returns",
"{",
"error",
"result",
"}",
"dict"
] | [
"\"\"\"Executes given function, returns {error,result} dict\"\"\"",
"# pylint: disable=broad-except"
] | [
{
"param": "func",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
b5a28cb0117a281ab68ed1d647135bce4a73d9c0 | milikhin/seabass-editor | generic/py-backend/fs_utils/rm.py | [
"MIT"
] | Python | _rm | <not_specific> | def _rm(path):
"""Removes file or dir at the given path"""
if isfile(path):
return remove(path)
return rmtree(path) | Removes file or dir at the given path | Removes file or dir at the given path | [
"Removes",
"file",
"or",
"dir",
"at",
"the",
"given",
"path"
] | def _rm(path):
if isfile(path):
return remove(path)
return rmtree(path) | [
"def",
"_rm",
"(",
"path",
")",
":",
"if",
"isfile",
"(",
"path",
")",
":",
"return",
"remove",
"(",
"path",
")",
"return",
"rmtree",
"(",
"path",
")"
] | Removes file or dir at the given path | [
"Removes",
"file",
"or",
"dir",
"at",
"the",
"given",
"path"
] | [
"\"\"\"Removes file or dir at the given path\"\"\""
] | [
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bc732659bc2c1cb43318a6203c6168d4fa27c690 | openstate/eml-opkomst-per-wijk | eml2csv.py | [
"MIT"
] | Python | parse_eml_file | <not_specific> | def parse_eml_file(file_path):
"""
Parses an eml file and returns results.
"""
result = []
with codecs.open(file_path, 'r', 'utf-8') as in_file:
content = in_file.read()
try:
xml = etree.fromstring(content)
except Exception as e:
content = re.sub(r'^\s... |
Parses an eml file and returns results.
| Parses an eml file and returns results. | [
"Parses",
"an",
"eml",
"file",
"and",
"returns",
"results",
"."
] | def parse_eml_file(file_path):
result = []
with codecs.open(file_path, 'r', 'utf-8') as in_file:
content = in_file.read()
try:
xml = etree.fromstring(content)
except Exception as e:
content = re.sub(r'^\s*\<\?[^\?]*\?\>', '', content)
xml = etree.froms... | [
"def",
"parse_eml_file",
"(",
"file_path",
")",
":",
"result",
"=",
"[",
"]",
"with",
"codecs",
".",
"open",
"(",
"file_path",
",",
"'r'",
",",
"'utf-8'",
")",
"as",
"in_file",
":",
"content",
"=",
"in_file",
".",
"read",
"(",
")",
"try",
":",
"xml",... | Parses an eml file and returns results. | [
"Parses",
"an",
"eml",
"file",
"and",
"returns",
"results",
"."
] | [
"\"\"\"\n Parses an eml file and returns results.\n \"\"\"",
"# Ugh, we need to know the namespaces. Ugly hack. For som reason",
"# etree does not query the default declared namespace, so you have to",
"# be explicit.",
"# pprint(xml)"
] | [
{
"param": "file_path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_path",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
30a7c676fdee8a387838278c84a150ff9ecfea79 | mgreenw/flask-restapi-example | models.py | [
"MIT"
] | Python | serialize | <not_specific> | def serialize(self):
"""Return object data in easily serializeable format"""
return {
'id': self.id,
'name': self.name,
'reviews': [review.serialize for review in self.reviews]
} | Return object data in easily serializeable format | Return object data in easily serializeable format | [
"Return",
"object",
"data",
"in",
"easily",
"serializeable",
"format"
] | def serialize(self):
return {
'id': self.id,
'name': self.name,
'reviews': [review.serialize for review in self.reviews]
} | [
"def",
"serialize",
"(",
"self",
")",
":",
"return",
"{",
"'id'",
":",
"self",
".",
"id",
",",
"'name'",
":",
"self",
".",
"name",
",",
"'reviews'",
":",
"[",
"review",
".",
"serialize",
"for",
"review",
"in",
"self",
".",
"reviews",
"]",
"}"
] | Return object data in easily serializeable format | [
"Return",
"object",
"data",
"in",
"easily",
"serializeable",
"format"
] | [
"\"\"\"Return object data in easily serializeable format\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
30a7c676fdee8a387838278c84a150ff9ecfea79 | mgreenw/flask-restapi-example | models.py | [
"MIT"
] | Python | serialize | <not_specific> | def serialize(self):
"""Return object data in easily serializeable format"""
return {
'id': self.id,
'doctor_id': self.doctor_id,
'description': self.description,
} | Return object data in easily serializeable format | Return object data in easily serializeable format | [
"Return",
"object",
"data",
"in",
"easily",
"serializeable",
"format"
] | def serialize(self):
return {
'id': self.id,
'doctor_id': self.doctor_id,
'description': self.description,
} | [
"def",
"serialize",
"(",
"self",
")",
":",
"return",
"{",
"'id'",
":",
"self",
".",
"id",
",",
"'doctor_id'",
":",
"self",
".",
"doctor_id",
",",
"'description'",
":",
"self",
".",
"description",
",",
"}"
] | Return object data in easily serializeable format | [
"Return",
"object",
"data",
"in",
"easily",
"serializeable",
"format"
] | [
"\"\"\"Return object data in easily serializeable format\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8e013b616e4e326d9613e1e0f81d0aec878057db | ljmartin/cut_tree_balanced | cut_tree_balanced.py | [
"BSD-3-Clause"
] | Python | cut_tree_balanced | <not_specific> | def cut_tree_balanced(linkage_matrix_Z, max_cluster_size, verbose=False):
"""This function performs a balanced cut tree of a SciPy linkage matrix built using any linkage method
(e.g. 'ward'). It builds upon the SciPy and Numpy libraries.
The function looks recursively along the hierarchical ... | This function performs a balanced cut tree of a SciPy linkage matrix built using any linkage method
(e.g. 'ward'). It builds upon the SciPy and Numpy libraries.
The function looks recursively along the hierarchical tree, from the root (single cluster gathering
all the samples) to the lea... | This function performs a balanced cut tree of a SciPy linkage matrix built using any linkage method
. It builds upon the SciPy and Numpy libraries.
The function looks recursively along the hierarchical tree, from the root (single cluster gathering
all the samples) to the leaves , retrieving the biggest
possible cluste... | [
"This",
"function",
"performs",
"a",
"balanced",
"cut",
"tree",
"of",
"a",
"SciPy",
"linkage",
"matrix",
"built",
"using",
"any",
"linkage",
"method",
".",
"It",
"builds",
"upon",
"the",
"SciPy",
"and",
"Numpy",
"libraries",
".",
"The",
"function",
"looks",
... | def cut_tree_balanced(linkage_matrix_Z, max_cluster_size, verbose=False):
try:
assert max_cluster_size >= 1
full_cut = cut_tree(linkage_matrix_Z)
if verbose:
print("Interim full cut tree (square matrix)")
print("Shape = " + str(full_cut.shape))
print(full_... | [
"def",
"cut_tree_balanced",
"(",
"linkage_matrix_Z",
",",
"max_cluster_size",
",",
"verbose",
"=",
"False",
")",
":",
"try",
":",
"assert",
"max_cluster_size",
">=",
"1",
"full_cut",
"=",
"cut_tree",
"(",
"linkage_matrix_Z",
")",
"if",
"verbose",
":",
"print",
... | This function performs a balanced cut tree of a SciPy linkage matrix built using any linkage method
(e.g. | [
"This",
"function",
"performs",
"a",
"balanced",
"cut",
"tree",
"of",
"a",
"SciPy",
"linkage",
"matrix",
"built",
"using",
"any",
"linkage",
"method",
"(",
"e",
".",
"g",
"."
] | [
"\"\"\"This function performs a balanced cut tree of a SciPy linkage matrix built using any linkage method \n (e.g. 'ward'). It builds upon the SciPy and Numpy libraries. \n \n The function looks recursively along the hierarchical tree, from the root (single cluster gathering \n all the samp... | [
{
"param": "linkage_matrix_Z",
"type": null
},
{
"param": "max_cluster_size",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [
{
"docstring": "one-dimensional numpy array of integers containing for each input sample its corresponding\ncluster id. The cluster id is an integer which is higher for deeper tree levels.\n\none-dimensional numpy array of arrays containing for each input sample its\ncorresponding cluster tre... |
88697cc28f158fc9f296dfa4d6b3cc5165ca1695 | vishnumani2009/sklearn-fastText | skfasttext/FastTextClassifier.py | [
"BSD-3-Clause"
] | Python | fit | <not_specific> | def fit(self,input_file):
'''
Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
'''
self.classifier = ft.supervised(input_file, self.output, dim=self.dim, lr=self.l... |
Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
| takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file | [
"takes",
"input",
"file",
"in",
"format",
"returns",
"classifier",
"object",
"to",
"do",
":",
"add",
"option",
"to",
"feed",
"list",
"of",
"X",
"and",
"Y",
"or",
"file"
] | def fit(self,input_file):
self.classifier = ft.supervised(input_file, self.output, dim=self.dim, lr=self.lr, epoch=self.epoch, min_count=self.min_count, word_ngrams=self.word_ngrams, bucket=self.bucket, thread=self.thread, silent=self.silent, label_prefix=self.lpr)
return(None) | [
"def",
"fit",
"(",
"self",
",",
"input_file",
")",
":",
"self",
".",
"classifier",
"=",
"ft",
".",
"supervised",
"(",
"input_file",
",",
"self",
".",
"output",
",",
"dim",
"=",
"self",
".",
"dim",
",",
"lr",
"=",
"self",
".",
"lr",
",",
"epoch",
... | Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file | [
"Input",
":",
"takes",
"input",
"file",
"in",
"format",
"returns",
"classifier",
"object",
"to",
"do",
":",
"add",
"option",
"to",
"feed",
"list",
"of",
"X",
"and",
"Y",
"or",
"file"
] | [
"'''\n Input: takes input file in format\n returns classifier object\n to do: add option to feed list of X and Y or file\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "input_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input_file",
"type": null,
"docstring": null,
"docstring_toke... |
88697cc28f158fc9f296dfa4d6b3cc5165ca1695 | vishnumani2009/sklearn-fastText | skfasttext/FastTextClassifier.py | [
"BSD-3-Clause"
] | Python | predict | <not_specific> | def predict(self,test_file,csvflag=True,k_best=1):
'''
Input: Takes input test finle in format
return results object
to do: add unit tests using sentiment analysis dataset
to do: Add K best labels options for csvflag = False
... |
Input: Takes input test finle in format
return results object
to do: add unit tests using sentiment analysis dataset
to do: Add K best labels options for csvflag = False
| Takes input test finle in format
return results object
to do: add unit tests using sentiment analysis dataset
to do: Add K best labels options for csvflag = False | [
"Takes",
"input",
"test",
"finle",
"in",
"format",
"return",
"results",
"object",
"to",
"do",
":",
"add",
"unit",
"tests",
"using",
"sentiment",
"analysis",
"dataset",
"to",
"do",
":",
"Add",
"K",
"best",
"labels",
"options",
"for",
"csvflag",
"=",
"False"... | def predict(self,test_file,csvflag=True,k_best=1):
try:
if csvflag==False and type(test_file) == 'list':
self.result=self.classifier.predict(test_file,k=k_best)
if csvflag:
lines=open(test_file,"r").readlines()
... | [
"def",
"predict",
"(",
"self",
",",
"test_file",
",",
"csvflag",
"=",
"True",
",",
"k_best",
"=",
"1",
")",
":",
"try",
":",
"if",
"csvflag",
"==",
"False",
"and",
"type",
"(",
"test_file",
")",
"==",
"'list'",
":",
"self",
".",
"result",
"=",
"sel... | Input: Takes input test finle in format
return results object
to do: add unit tests using sentiment analysis dataset
to do: Add K best labels options for csvflag = False | [
"Input",
":",
"Takes",
"input",
"test",
"finle",
"in",
"format",
"return",
"results",
"object",
"to",
"do",
":",
"add",
"unit",
"tests",
"using",
"sentiment",
"analysis",
"dataset",
"to",
"do",
":",
"Add",
"K",
"best",
"labels",
"options",
"for",
"csvflag"... | [
"'''\n Input: Takes input test finle in format\n return results object\n to do: add unit tests using sentiment analysis dataset \n to do: Add K best labels options for csvflag = False \n \n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "test_file",
"type": null
},
{
"param": "csvflag",
"type": null
},
{
"param": "k_best",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "test_file",
"type": null,
"docstring": null,
"docstring_token... |
88697cc28f158fc9f296dfa4d6b3cc5165ca1695 | vishnumani2009/sklearn-fastText | skfasttext/FastTextClassifier.py | [
"BSD-3-Clause"
] | Python | report | <not_specific> | def report(self,ytrue,ypred):
'''
Input: predicted and true labels
return reort of classification
to do: add label option and unit testing
'''
print(classification_report(ytrue,ypred))
return... |
Input: predicted and true labels
return reort of classification
to do: add label option and unit testing
| predicted and true labels
return reort of classification
to do: add label option and unit testing | [
"predicted",
"and",
"true",
"labels",
"return",
"reort",
"of",
"classification",
"to",
"do",
":",
"add",
"label",
"option",
"and",
"unit",
"testing"
] | def report(self,ytrue,ypred):
print(classification_report(ytrue,ypred))
return None | [
"def",
"report",
"(",
"self",
",",
"ytrue",
",",
"ypred",
")",
":",
"print",
"(",
"classification_report",
"(",
"ytrue",
",",
"ypred",
")",
")",
"return",
"None"
] | Input: predicted and true labels
return reort of classification
to do: add label option and unit testing | [
"Input",
":",
"predicted",
"and",
"true",
"labels",
"return",
"reort",
"of",
"classification",
"to",
"do",
":",
"add",
"label",
"option",
"and",
"unit",
"testing"
] | [
"'''\n Input: predicted and true labels\n return reort of classification\n to do: add label option and unit testing\n \n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "ytrue",
"type": null
},
{
"param": "ypred",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ytrue",
"type": null,
"docstring": null,
"docstring_tokens": ... |
88697cc28f158fc9f296dfa4d6b3cc5165ca1695 | vishnumani2009/sklearn-fastText | skfasttext/FastTextClassifier.py | [
"BSD-3-Clause"
] | Python | predict_proba | <not_specific> | def predict_proba(self,test_file,csvflag=True,k_best=1):
'''
Input: List of sentences
return reort of classification
to do: check output of classifier predct_proba add label option and unit testing
'''
try:
... |
Input: List of sentences
return reort of classification
to do: check output of classifier predct_proba add label option and unit testing
| List of sentences
return reort of classification
to do: check output of classifier predct_proba add label option and unit testing | [
"List",
"of",
"sentences",
"return",
"reort",
"of",
"classification",
"to",
"do",
":",
"check",
"output",
"of",
"classifier",
"predct_proba",
"add",
"label",
"option",
"and",
"unit",
"testing"
] | def predict_proba(self,test_file,csvflag=True,k_best=1):
try:
if csvflag==False and type(test_file) == 'list':
self.result=self.classifier.predict_proba(test_file,k=k_best)
if csvflag:
lines=open(test_file,"r").r... | [
"def",
"predict_proba",
"(",
"self",
",",
"test_file",
",",
"csvflag",
"=",
"True",
",",
"k_best",
"=",
"1",
")",
":",
"try",
":",
"if",
"csvflag",
"==",
"False",
"and",
"type",
"(",
"test_file",
")",
"==",
"'list'",
":",
"self",
".",
"result",
"=",
... | Input: List of sentences
return reort of classification
to do: check output of classifier predct_proba add label option and unit testing | [
"Input",
":",
"List",
"of",
"sentences",
"return",
"reort",
"of",
"classification",
"to",
"do",
":",
"check",
"output",
"of",
"classifier",
"predct_proba",
"add",
"label",
"option",
"and",
"unit",
"testing"
] | [
"'''\n Input: List of sentences\n return reort of classification\n to do: check output of classifier predct_proba add label option and unit testing\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "test_file",
"type": null
},
{
"param": "csvflag",
"type": null
},
{
"param": "k_best",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "test_file",
"type": null,
"docstring": null,
"docstring_token... |
1f2e3f732aa675dc9c5f02e4330aa4922c717671 | vishnumani2009/sklearn-fastText | fasttextclf.py | [
"BSD-3-Clause"
] | Python | fit | <not_specific> | def fit(self,input_file):
'''
Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
'''
self.classifier = ft.supervised(input_file, self.output, dim=se... |
Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
| takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file | [
"takes",
"input",
"file",
"in",
"format",
"returns",
"classifier",
"object",
"to",
"do",
":",
"add",
"option",
"to",
"feed",
"list",
"of",
"X",
"and",
"Y",
"or",
"file"
] | def fit(self,input_file):
self.classifier = ft.supervised(input_file, self.output, dim=self.dim, lr=self.lr, epoch=self.epoch, min_count=self.min_count, word_ngrams=self.word_ngrams, bucket=self.bucket, thread=self.thread, silent=self.silent, label_prefix=self.lpr)
return(self.classisife... | [
"def",
"fit",
"(",
"self",
",",
"input_file",
")",
":",
"self",
".",
"classifier",
"=",
"ft",
".",
"supervised",
"(",
"input_file",
",",
"self",
".",
"output",
",",
"dim",
"=",
"self",
".",
"dim",
",",
"lr",
"=",
"self",
".",
"lr",
",",
"epoch",
... | Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file | [
"Input",
":",
"takes",
"input",
"file",
"in",
"format",
"returns",
"classifier",
"object",
"to",
"do",
":",
"add",
"option",
"to",
"feed",
"list",
"of",
"X",
"and",
"Y",
"or",
"file"
] | [
"'''\n Input: takes input file in format\n returns classifier object\n to do: add option to feed list of X and Y or file\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "input_file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input_file",
"type": null,
"docstring": null,
"docstring_toke... |
1f2e3f732aa675dc9c5f02e4330aa4922c717671 | vishnumani2009/sklearn-fastText | fasttextclf.py | [
"BSD-3-Clause"
] | Python | predict_proba | <not_specific> | def predict_proba(self,X):
'''
Input: List of sentences
return reort of classification
to do: check output of classifier predct_proba add label option and unit testing
'''
labels=self.classifier.predict_proba(X)
... |
Input: List of sentences
return reort of classification
to do: check output of classifier predct_proba add label option and unit testing
| List of sentences
return reort of classification
to do: check output of classifier predct_proba add label option and unit testing | [
"List",
"of",
"sentences",
"return",
"reort",
"of",
"classification",
"to",
"do",
":",
"check",
"output",
"of",
"classifier",
"predct_proba",
"add",
"label",
"option",
"and",
"unit",
"testing"
] | def predict_proba(self,X):
labels=self.classifier.predict_proba(X)
return(labels) | [
"def",
"predict_proba",
"(",
"self",
",",
"X",
")",
":",
"labels",
"=",
"self",
".",
"classifier",
".",
"predict_proba",
"(",
"X",
")",
"return",
"(",
"labels",
")"
] | Input: List of sentences
return reort of classification
to do: check output of classifier predct_proba add label option and unit testing | [
"Input",
":",
"List",
"of",
"sentences",
"return",
"reort",
"of",
"classification",
"to",
"do",
":",
"check",
"output",
"of",
"classifier",
"predct_proba",
"add",
"label",
"option",
"and",
"unit",
"testing"
] | [
"'''\n Input: List of sentences\n return reort of classification\n to do: check output of classifier predct_proba add label option and unit testing\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "X",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
1f2e3f732aa675dc9c5f02e4330aa4922c717671 | vishnumani2009/sklearn-fastText | fasttextclf.py | [
"BSD-3-Clause"
] | Python | fit | null | def fit(self,X,modelname='model',csvflag=False):
'''
Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
to do: check options for the api call
to do: write unit test... |
Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
to do: check options for the api call
to do: write unit test
| takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
to do: check options for the api call
to do: write unit test | [
"takes",
"input",
"file",
"in",
"format",
"returns",
"classifier",
"object",
"to",
"do",
":",
"add",
"option",
"to",
"feed",
"list",
"of",
"X",
"and",
"Y",
"or",
"file",
"to",
"do",
":",
"check",
"options",
"for",
"the",
"api",
"call",
"to",
"do",
":... | def fit(self,X,modelname='model',csvflag=False):
try:
if not csvflag:
self.model=ft.skipgram(X, modelname, lr=self.lr, dim=self.dim,lr_update_rate=self.lr_update_rate,epoch=self.epoch,bucket=self.bucket,loss=self.loss,thread=self.n_thread)
exce... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"modelname",
"=",
"'model'",
",",
"csvflag",
"=",
"False",
")",
":",
"try",
":",
"if",
"not",
"csvflag",
":",
"self",
".",
"model",
"=",
"ft",
".",
"skipgram",
"(",
"X",
",",
"modelname",
",",
"lr",
"=",
... | Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
to do: check options for the api call
to do: write unit test | [
"Input",
":",
"takes",
"input",
"file",
"in",
"format",
"returns",
"classifier",
"object",
"to",
"do",
":",
"add",
"option",
"to",
"feed",
"list",
"of",
"X",
"and",
"Y",
"or",
"file",
"to",
"do",
":",
"check",
"options",
"for",
"the",
"api",
"call",
... | [
"'''\n Input: takes input file in format\n returns classifier object\n to do: add option to feed list of X and Y or file\n to do: check options for the api call \n to do: write unit test\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "X",
"type": null
},
{
"param": "modelname",
"type": null
},
{
"param": "csvflag",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
1f2e3f732aa675dc9c5f02e4330aa4922c717671 | vishnumani2009/sklearn-fastText | fasttextclf.py | [
"BSD-3-Clause"
] | Python | fit | null | def fit(self,X,modelname='model'):
'''
Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
to do: check options for the api call
to do: write unit test
... |
Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
to do: check options for the api call
to do: write unit test
| takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
to do: check options for the api call
to do: write unit test | [
"takes",
"input",
"file",
"in",
"format",
"returns",
"classifier",
"object",
"to",
"do",
":",
"add",
"option",
"to",
"feed",
"list",
"of",
"X",
"and",
"Y",
"or",
"file",
"to",
"do",
":",
"check",
"options",
"for",
"the",
"api",
"call",
"to",
"do",
":... | def fit(self,X,modelname='model'):
try:
if not csvflag:
self.model=ft.cbow(X, modelname, lr=self.lr, dim=self.dim,lr_update_rate=self.lr_update_rate,epoch=self.epoch,bucket=self.bucket,loss=self.loss,thread=self.n_thread)
except:
print("E... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"modelname",
"=",
"'model'",
")",
":",
"try",
":",
"if",
"not",
"csvflag",
":",
"self",
".",
"model",
"=",
"ft",
".",
"cbow",
"(",
"X",
",",
"modelname",
",",
"lr",
"=",
"self",
".",
"lr",
",",
"dim",
... | Input: takes input file in format
returns classifier object
to do: add option to feed list of X and Y or file
to do: check options for the api call
to do: write unit test | [
"Input",
":",
"takes",
"input",
"file",
"in",
"format",
"returns",
"classifier",
"object",
"to",
"do",
":",
"add",
"option",
"to",
"feed",
"list",
"of",
"X",
"and",
"Y",
"or",
"file",
"to",
"do",
":",
"check",
"options",
"for",
"the",
"api",
"call",
... | [
"'''\n Input: takes input file in format\n returns classifier object\n to do: add option to feed list of X and Y or file\n to do: check options for the api call \n to do: write unit test\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "X",
"type": null
},
{
"param": "modelname",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
c979b299a796a9f5fdd77cec0e76956e1f919b1f | LucaCocchi/fmriprep | fmriprep/workflows/bold/resampling.py | [
"BSD-3-Clause"
] | Python | init_bold_preproc_report_wf | <not_specific> | def init_bold_preproc_report_wf(mem_gb, reportlets_dir, name='bold_preproc_report_wf'):
"""
This workflow generates and saves a reportlet showing the effect of resampling
the BOLD signal using the standard deviation maps.
.. workflow::
:graph2use: orig
:simple_form: yes
from fm... |
This workflow generates and saves a reportlet showing the effect of resampling
the BOLD signal using the standard deviation maps.
.. workflow::
:graph2use: orig
:simple_form: yes
from fmriprep.workflows.bold.resampling import init_bold_preproc_report_wf
wf = init_bold_prep... | This workflow generates and saves a reportlet showing the effect of resampling
the BOLD signal using the standard deviation maps.
Parameters
mem_gb : float
Size of BOLD file in GB
reportlets_dir : str
Directory in which to save reportlets
name : str, optional
Workflow name (default: bold_preproc_report_wf)
Input... | [
"This",
"workflow",
"generates",
"and",
"saves",
"a",
"reportlet",
"showing",
"the",
"effect",
"of",
"resampling",
"the",
"BOLD",
"signal",
"using",
"the",
"standard",
"deviation",
"maps",
".",
"Parameters",
"mem_gb",
":",
"float",
"Size",
"of",
"BOLD",
"file"... | def init_bold_preproc_report_wf(mem_gb, reportlets_dir, name='bold_preproc_report_wf'):
from nipype.algorithms.confounds import TSNR
from niworkflows.interfaces import SimpleBeforeAfter
workflow = Workflow(name=name)
inputnode = pe.Node(niu.IdentityInterface(
fields=['in_pre', 'in_post', 'name_s... | [
"def",
"init_bold_preproc_report_wf",
"(",
"mem_gb",
",",
"reportlets_dir",
",",
"name",
"=",
"'bold_preproc_report_wf'",
")",
":",
"from",
"nipype",
".",
"algorithms",
".",
"confounds",
"import",
"TSNR",
"from",
"niworkflows",
".",
"interfaces",
"import",
"SimpleBe... | This workflow generates and saves a reportlet showing the effect of resampling
the BOLD signal using the standard deviation maps. | [
"This",
"workflow",
"generates",
"and",
"saves",
"a",
"reportlet",
"showing",
"the",
"effect",
"of",
"resampling",
"the",
"BOLD",
"signal",
"using",
"the",
"standard",
"deviation",
"maps",
"."
] | [
"\"\"\"\n This workflow generates and saves a reportlet showing the effect of resampling\n the BOLD signal using the standard deviation maps.\n\n .. workflow::\n :graph2use: orig\n :simple_form: yes\n\n from fmriprep.workflows.bold.resampling import init_bold_preproc_report_wf\n ... | [
{
"param": "mem_gb",
"type": null
},
{
"param": "reportlets_dir",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mem_gb",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "reportlets_dir",
"type": null,
"docstring": null,
"docstrin... |
bab4f3409f85ce33bf728d175b2c85fb59b20a02 | opendatatrentino/opendata-harvester | harvester/cli.py | [
"BSD-2-Clause"
] | Python | configure_logging | <not_specific> | def configure_logging(self):
"""
Create logging handlers for any log output.
Modified version to set custom formatter for console
"""
root_logger = logging.getLogger('')
root_logger.setLevel(logging.DEBUG)
# Set up logging to a file
if self.options.log_fi... |
Create logging handlers for any log output.
Modified version to set custom formatter for console
| Create logging handlers for any log output.
Modified version to set custom formatter for console | [
"Create",
"logging",
"handlers",
"for",
"any",
"log",
"output",
".",
"Modified",
"version",
"to",
"set",
"custom",
"formatter",
"for",
"console"
] | def configure_logging(self):
root_logger = logging.getLogger('')
root_logger.setLevel(logging.DEBUG)
if self.options.log_file:
file_handler = logging.FileHandler(
filename=self.options.log_file,
)
formatter = logging.Formatter(self.LOG_FILE_MES... | [
"def",
"configure_logging",
"(",
"self",
")",
":",
"root_logger",
"=",
"logging",
".",
"getLogger",
"(",
"''",
")",
"root_logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"if",
"self",
".",
"options",
".",
"log_file",
":",
"file_handler",
"=",
... | Create logging handlers for any log output. | [
"Create",
"logging",
"handlers",
"for",
"any",
"log",
"output",
"."
] | [
"\"\"\"\n Create logging handlers for any log output.\n Modified version to set custom formatter for console\n \"\"\"",
"# Set up logging to a file",
"# Always send higher-level messages to the console via stderr",
"# formatter = logging.Formatter(self.CONSOLE_MESSAGE_FORMAT)"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8384bf5a8c09ce2f57bb1fb3d1c74d55be06db60 | opendatatrentino/opendata-harvester | harvester_odt/pat_statistica/client.py | [
"BSD-2-Clause"
] | Python | force_iter_datasets | null | def force_iter_datasets(self):
"""Iterate datasets, then try guessing numbers"""
found = set()
for record in self.iter_datasets():
found.add(int(record['id']))
yield record
# Let's try guessing numbers up to 20% more than the highest
# id found in the li... | Iterate datasets, then try guessing numbers | Iterate datasets, then try guessing numbers | [
"Iterate",
"datasets",
"then",
"try",
"guessing",
"numbers"
] | def force_iter_datasets(self):
found = set()
for record in self.iter_datasets():
found.add(int(record['id']))
yield record
stop = int(max(int(x) for x in found) * 1.2)
for i in xrange(1, stop + 1):
if i in found:
continue
tr... | [
"def",
"force_iter_datasets",
"(",
"self",
")",
":",
"found",
"=",
"set",
"(",
")",
"for",
"record",
"in",
"self",
".",
"iter_datasets",
"(",
")",
":",
"found",
".",
"add",
"(",
"int",
"(",
"record",
"[",
"'id'",
"]",
")",
")",
"yield",
"record",
"... | Iterate datasets, then try guessing numbers | [
"Iterate",
"datasets",
"then",
"try",
"guessing",
"numbers"
] | [
"\"\"\"Iterate datasets, then try guessing numbers\"\"\"",
"# Let's try guessing numbers up to 20% more than the highest",
"# id found in the list.",
"# We already returned this one",
"# Simply ignore anything bad that would happen.."
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8384bf5a8c09ce2f57bb1fb3d1c74d55be06db60 | opendatatrentino/opendata-harvester | harvester_odt/pat_statistica/client.py | [
"BSD-2-Clause"
] | Python | _add_extended_metadata | <not_specific> | def _add_extended_metadata(self, dataset):
"""Download extended metadata for this dataset
"""
# Download linked resources, to extract metadata
# ------------------------------------------------------------
dataset['_links'] = {}
dataset_data = {}
keys = [
... | Download extended metadata for this dataset
| Download extended metadata for this dataset | [
"Download",
"extended",
"metadata",
"for",
"this",
"dataset"
] | def _add_extended_metadata(self, dataset):
dataset['_links'] = {}
dataset_data = {}
keys = [
('Indicatore', 'indicatore'),
('TabNumeratore', 'numeratore'),
('TabDenominatore', 'denominatore'),
]
for orig, key in keys:
if orig in dat... | [
"def",
"_add_extended_metadata",
"(",
"self",
",",
"dataset",
")",
":",
"dataset",
"[",
"'_links'",
"]",
"=",
"{",
"}",
"dataset_data",
"=",
"{",
"}",
"keys",
"=",
"[",
"(",
"'Indicatore'",
",",
"'indicatore'",
")",
",",
"(",
"'TabNumeratore'",
",",
"'nu... | Download extended metadata for this dataset | [
"Download",
"extended",
"metadata",
"for",
"this",
"dataset"
] | [
"\"\"\"Download extended metadata for this dataset\n \"\"\"",
"# Download linked resources, to extract metadata",
"# ------------------------------------------------------------",
"# Add resource titles, now that we have them",
"# ------------------------------------------------------------"
] | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
2aa32101c31a5af669a1857b38375cd80613ab12 | opendatatrentino/opendata-harvester | harvester/ext/storage/mongodb.py | [
"BSD-2-Clause"
] | Python | _get_collection | <not_specific> | def _get_collection(self, name):
"""
Return collection object, by name.
Prefix will be prepended automatically.
"""
name = self._get_collection_name(name)
return self._database[name] |
Return collection object, by name.
Prefix will be prepended automatically.
| Return collection object, by name.
Prefix will be prepended automatically. | [
"Return",
"collection",
"object",
"by",
"name",
".",
"Prefix",
"will",
"be",
"prepended",
"automatically",
"."
] | def _get_collection(self, name):
name = self._get_collection_name(name)
return self._database[name] | [
"def",
"_get_collection",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"self",
".",
"_get_collection_name",
"(",
"name",
")",
"return",
"self",
".",
"_database",
"[",
"name",
"]"
] | Return collection object, by name. | [
"Return",
"collection",
"object",
"by",
"name",
"."
] | [
"\"\"\"\n Return collection object, by name.\n Prefix will be prepended automatically.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
2aa32101c31a5af669a1857b38375cd80613ab12 | opendatatrentino/opendata-harvester | harvester/ext/storage/mongodb.py | [
"BSD-2-Clause"
] | Python | _get_collection_name | <not_specific> | def _get_collection_name(self, name):
"""
Return a collection name, with prepended prefix.
"""
if not isinstance(name, (list, tuple)):
name = (name,)
name = list(name)
name.insert(0, self._mongo_prefix)
return '.'.join(filter(None, name)) |
Return a collection name, with prepended prefix.
| Return a collection name, with prepended prefix. | [
"Return",
"a",
"collection",
"name",
"with",
"prepended",
"prefix",
"."
] | def _get_collection_name(self, name):
if not isinstance(name, (list, tuple)):
name = (name,)
name = list(name)
name.insert(0, self._mongo_prefix)
return '.'.join(filter(None, name)) | [
"def",
"_get_collection_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"name",
"=",
"(",
"name",
",",
")",
"name",
"=",
"list",
"(",
"name",
")",
"name",
".",
"ins... | Return a collection name, with prepended prefix. | [
"Return",
"a",
"collection",
"name",
"with",
"prepended",
"prefix",
"."
] | [
"\"\"\"\n Return a collection name, with prepended prefix.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
2aa32101c31a5af669a1857b38375cd80613ab12 | opendatatrentino/opendata-harvester | harvester/ext/storage/mongodb.py | [
"BSD-2-Clause"
] | Python | _list_sub_collections | null | def _list_sub_collections(self, prefix=None, strip=True):
"""
List all the collections having the selected prefix.
:param prefix: string or list/tuple containing prefix parts.
:param strip: if True (default), strip prefix from names
"""
prefix = self._join_prefix(self._... |
List all the collections having the selected prefix.
:param prefix: string or list/tuple containing prefix parts.
:param strip: if True (default), strip prefix from names
| List all the collections having the selected prefix. | [
"List",
"all",
"the",
"collections",
"having",
"the",
"selected",
"prefix",
"."
] | def _list_sub_collections(self, prefix=None, strip=True):
prefix = self._join_prefix(self._mongo_prefix, prefix)
prefix = '.'.join(prefix)
if prefix:
prefix += '.'
striplen = len(prefix) if strip else 0
for name in self._database.collection_names():
if nam... | [
"def",
"_list_sub_collections",
"(",
"self",
",",
"prefix",
"=",
"None",
",",
"strip",
"=",
"True",
")",
":",
"prefix",
"=",
"self",
".",
"_join_prefix",
"(",
"self",
".",
"_mongo_prefix",
",",
"prefix",
")",
"prefix",
"=",
"'.'",
".",
"join",
"(",
"pr... | List all the collections having the selected prefix. | [
"List",
"all",
"the",
"collections",
"having",
"the",
"selected",
"prefix",
"."
] | [
"\"\"\"\n List all the collections having the selected prefix.\n\n :param prefix: string or list/tuple containing prefix parts.\n :param strip: if True (default), strip prefix from names\n \"\"\"",
"# Ignore system collections"
] | [
{
"param": "self",
"type": null
},
{
"param": "prefix",
"type": null
},
{
"param": "strip",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "prefix",
"type": null,
"docstring": "string or list/tuple containin... |
2aa32101c31a5af669a1857b38375cd80613ab12 | opendatatrentino/opendata-harvester | harvester/ext/storage/mongodb.py | [
"BSD-2-Clause"
] | Python | gridfs | <not_specific> | def gridfs(self):
"""
The inner gridfs is made available "publicly" too,
as it is used by the director to perform more advanced
queries etc.
"""
return self._get_gridfs() |
The inner gridfs is made available "publicly" too,
as it is used by the director to perform more advanced
queries etc.
| The inner gridfs is made available "publicly" too,
as it is used by the director to perform more advanced
queries etc. | [
"The",
"inner",
"gridfs",
"is",
"made",
"available",
"\"",
"publicly",
"\"",
"too",
"as",
"it",
"is",
"used",
"by",
"the",
"director",
"to",
"perform",
"more",
"advanced",
"queries",
"etc",
"."
] | def gridfs(self):
return self._get_gridfs() | [
"def",
"gridfs",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_gridfs",
"(",
")"
] | The inner gridfs is made available "publicly" too,
as it is used by the director to perform more advanced
queries etc. | [
"The",
"inner",
"gridfs",
"is",
"made",
"available",
"\"",
"publicly",
"\"",
"too",
"as",
"it",
"is",
"used",
"by",
"the",
"director",
"to",
"perform",
"more",
"advanced",
"queries",
"etc",
"."
] | [
"\"\"\"\n The inner gridfs is made available \"publicly\" too,\n as it is used by the director to perform more advanced\n queries etc.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
51d539e748647f7649e191758a2bca22be1d900e | opendatatrentino/opendata-harvester | harvester_odt/jobcontrol_jobs.py | [
"BSD-2-Clause"
] | Python | crawl_statistica_subpro | <not_specific> | def crawl_statistica_subpro(storage):
"""Run crawler for statistica - subprovinciale"""
import harvester_odt.pat_statistica.crawler
storage = get_storage_from_arg(storage)
with jobcontrol_integration():
harvester_odt.pat_statistica.crawler.crawl_statistica_subpro(storage)
return storage | Run crawler for statistica - subprovinciale | Run crawler for statistica - subprovinciale | [
"Run",
"crawler",
"for",
"statistica",
"-",
"subprovinciale"
] | def crawl_statistica_subpro(storage):
import harvester_odt.pat_statistica.crawler
storage = get_storage_from_arg(storage)
with jobcontrol_integration():
harvester_odt.pat_statistica.crawler.crawl_statistica_subpro(storage)
return storage | [
"def",
"crawl_statistica_subpro",
"(",
"storage",
")",
":",
"import",
"harvester_odt",
".",
"pat_statistica",
".",
"crawler",
"storage",
"=",
"get_storage_from_arg",
"(",
"storage",
")",
"with",
"jobcontrol_integration",
"(",
")",
":",
"harvester_odt",
".",
"pat_sta... | Run crawler for statistica - subprovinciale | [
"Run",
"crawler",
"for",
"statistica",
"-",
"subprovinciale"
] | [
"\"\"\"Run crawler for statistica - subprovinciale\"\"\""
] | [
{
"param": "storage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "storage",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
51d539e748647f7649e191758a2bca22be1d900e | opendatatrentino/opendata-harvester | harvester_odt/jobcontrol_jobs.py | [
"BSD-2-Clause"
] | Python | convert_statistica_to_ckan | <not_specific> | def convert_statistica_to_ckan(input_storage, storage):
"""Convert data from pat_statistica to Ckan"""
from harvester_odt.pat_statistica.converter \
import convert_statistica_to_ckan
input_storage = get_storage_from_arg(input_storage)
storage = get_storage_from_arg(storage)
with jobcontrol... | Convert data from pat_statistica to Ckan | Convert data from pat_statistica to Ckan | [
"Convert",
"data",
"from",
"pat_statistica",
"to",
"Ckan"
] | def convert_statistica_to_ckan(input_storage, storage):
from harvester_odt.pat_statistica.converter \
import convert_statistica_to_ckan
input_storage = get_storage_from_arg(input_storage)
storage = get_storage_from_arg(storage)
with jobcontrol_integration():
convert_statistica_to_ckan(in... | [
"def",
"convert_statistica_to_ckan",
"(",
"input_storage",
",",
"storage",
")",
":",
"from",
"harvester_odt",
".",
"pat_statistica",
".",
"converter",
"import",
"convert_statistica_to_ckan",
"input_storage",
"=",
"get_storage_from_arg",
"(",
"input_storage",
")",
"storage... | Convert data from pat_statistica to Ckan | [
"Convert",
"data",
"from",
"pat_statistica",
"to",
"Ckan"
] | [
"\"\"\"Convert data from pat_statistica to Ckan\"\"\""
] | [
{
"param": "input_storage",
"type": null
},
{
"param": "storage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_storage",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "storage",
"type": null,
"docstring": null,
"docstrin... |
51d539e748647f7649e191758a2bca22be1d900e | opendatatrentino/opendata-harvester | harvester_odt/jobcontrol_jobs.py | [
"BSD-2-Clause"
] | Python | convert_statistica_subpro_to_ckan | <not_specific> | def convert_statistica_subpro_to_ckan(input_storage, storage):
"""Convert data from pat_statistica_subpro to Ckan"""
from harvester_odt.pat_statistica.converter \
import convert_statistica_subpro_to_ckan
input_storage = get_storage_from_arg(input_storage)
storage = get_storage_from_arg(storage)... | Convert data from pat_statistica_subpro to Ckan | Convert data from pat_statistica_subpro to Ckan | [
"Convert",
"data",
"from",
"pat_statistica_subpro",
"to",
"Ckan"
] | def convert_statistica_subpro_to_ckan(input_storage, storage):
from harvester_odt.pat_statistica.converter \
import convert_statistica_subpro_to_ckan
input_storage = get_storage_from_arg(input_storage)
storage = get_storage_from_arg(storage)
with jobcontrol_integration():
convert_statist... | [
"def",
"convert_statistica_subpro_to_ckan",
"(",
"input_storage",
",",
"storage",
")",
":",
"from",
"harvester_odt",
".",
"pat_statistica",
".",
"converter",
"import",
"convert_statistica_subpro_to_ckan",
"input_storage",
"=",
"get_storage_from_arg",
"(",
"input_storage",
"... | Convert data from pat_statistica_subpro to Ckan | [
"Convert",
"data",
"from",
"pat_statistica_subpro",
"to",
"Ckan"
] | [
"\"\"\"Convert data from pat_statistica_subpro to Ckan\"\"\""
] | [
{
"param": "input_storage",
"type": null
},
{
"param": "storage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_storage",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "storage",
"type": null,
"docstring": null,
"docstrin... |
51d539e748647f7649e191758a2bca22be1d900e | opendatatrentino/opendata-harvester | harvester_odt/jobcontrol_jobs.py | [
"BSD-2-Clause"
] | Python | convert_geocatalogo_to_ckan | <not_specific> | def convert_geocatalogo_to_ckan(input_storage, storage):
"""Convert data from pat_geocatalogo to Ckan"""
from harvester_odt.pat_geocatalogo.converter \
import GeoCatalogoToCkan
input_storage = get_storage_from_arg(input_storage)
storage = get_storage_from_arg(storage)
converter = GeoCatalog... | Convert data from pat_geocatalogo to Ckan | Convert data from pat_geocatalogo to Ckan | [
"Convert",
"data",
"from",
"pat_geocatalogo",
"to",
"Ckan"
] | def convert_geocatalogo_to_ckan(input_storage, storage):
from harvester_odt.pat_geocatalogo.converter \
import GeoCatalogoToCkan
input_storage = get_storage_from_arg(input_storage)
storage = get_storage_from_arg(storage)
converter = GeoCatalogoToCkan('', {})
with jobcontrol_integration():
... | [
"def",
"convert_geocatalogo_to_ckan",
"(",
"input_storage",
",",
"storage",
")",
":",
"from",
"harvester_odt",
".",
"pat_geocatalogo",
".",
"converter",
"import",
"GeoCatalogoToCkan",
"input_storage",
"=",
"get_storage_from_arg",
"(",
"input_storage",
")",
"storage",
"=... | Convert data from pat_geocatalogo to Ckan | [
"Convert",
"data",
"from",
"pat_geocatalogo",
"to",
"Ckan"
] | [
"\"\"\"Convert data from pat_geocatalogo to Ckan\"\"\""
] | [
{
"param": "input_storage",
"type": null
},
{
"param": "storage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_storage",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "storage",
"type": null,
"docstring": null,
"docstrin... |
51d539e748647f7649e191758a2bca22be1d900e | opendatatrentino/opendata-harvester | harvester_odt/jobcontrol_jobs.py | [
"BSD-2-Clause"
] | Python | debugging_job | <not_specific> | def debugging_job(storage):
"""
Job to be used for debugging purposes.
"""
storage = get_storage_from_arg(storage)
with jobcontrol_integration():
report_progress(None, 0, 1)
job = execution_context.current_job
logger.debug('Running job: {0!r}'.format(job))
deps = list(job.get... |
Job to be used for debugging purposes.
| Job to be used for debugging purposes. | [
"Job",
"to",
"be",
"used",
"for",
"debugging",
"purposes",
"."
] | def debugging_job(storage):
storage = get_storage_from_arg(storage)
with jobcontrol_integration():
report_progress(None, 0, 1)
job = execution_context.current_job
logger.debug('Running job: {0!r}'.format(job))
deps = list(job.get_deps())
logger.debug('Found {0} dependencies'.format(len(d... | [
"def",
"debugging_job",
"(",
"storage",
")",
":",
"storage",
"=",
"get_storage_from_arg",
"(",
"storage",
")",
"with",
"jobcontrol_integration",
"(",
")",
":",
"report_progress",
"(",
"None",
",",
"0",
",",
"1",
")",
"job",
"=",
"execution_context",
".",
"cu... | Job to be used for debugging purposes. | [
"Job",
"to",
"be",
"used",
"for",
"debugging",
"purposes",
"."
] | [
"\"\"\"\n Job to be used for debugging purposes.\n \"\"\""
] | [
{
"param": "storage",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "storage",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
51e654da2eb760a964385c6ae7d0815e46fcaafb | opendatatrentino/opendata-harvester | tests/conftest.py | [
"BSD-2-Clause"
] | Python | director_client | <not_specific> | def director_client(request):
"""Fixture returning a client attached to the flask app"""
from harvester.director.web import app
tc = app.test_client()
return tc | Fixture returning a client attached to the flask app | Fixture returning a client attached to the flask app | [
"Fixture",
"returning",
"a",
"client",
"attached",
"to",
"the",
"flask",
"app"
] | def director_client(request):
from harvester.director.web import app
tc = app.test_client()
return tc | [
"def",
"director_client",
"(",
"request",
")",
":",
"from",
"harvester",
".",
"director",
".",
"web",
"import",
"app",
"tc",
"=",
"app",
".",
"test_client",
"(",
")",
"return",
"tc"
] | Fixture returning a client attached to the flask app | [
"Fixture",
"returning",
"a",
"client",
"attached",
"to",
"the",
"flask",
"app"
] | [
"\"\"\"Fixture returning a client attached to the flask app\"\"\""
] | [
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
51e654da2eb760a964385c6ae7d0815e46fcaafb | opendatatrentino/opendata-harvester | tests/conftest.py | [
"BSD-2-Clause"
] | Python | director_worker | <not_specific> | def director_worker(request):
"""Fixture starting a celery worker in background"""
from multiprocessing import Process
from harvester.director.tasks import worker
p = Process(target=lambda: worker.worker_main(['test-celery-worker']))
def cleanup():
p.terminate()
request.addfinalizer(c... | Fixture starting a celery worker in background | Fixture starting a celery worker in background | [
"Fixture",
"starting",
"a",
"celery",
"worker",
"in",
"background"
] | def director_worker(request):
from multiprocessing import Process
from harvester.director.tasks import worker
p = Process(target=lambda: worker.worker_main(['test-celery-worker']))
def cleanup():
p.terminate()
request.addfinalizer(cleanup)
p.start()
return p | [
"def",
"director_worker",
"(",
"request",
")",
":",
"from",
"multiprocessing",
"import",
"Process",
"from",
"harvester",
".",
"director",
".",
"tasks",
"import",
"worker",
"p",
"=",
"Process",
"(",
"target",
"=",
"lambda",
":",
"worker",
".",
"worker_main",
... | Fixture starting a celery worker in background | [
"Fixture",
"starting",
"a",
"celery",
"worker",
"in",
"background"
] | [
"\"\"\"Fixture starting a celery worker in background\"\"\""
] | [
{
"param": "request",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33d0e20b79e87d4568c66d378fccdc32045304ec | opendatatrentino/opendata-harvester | harvester/utils/__init__.py | [
"BSD-2-Clause"
] | Python | plugin_options_from_cmdline | <not_specific> | def plugin_options_from_cmdline(options):
"""
Convert a list of options from command-line arguments
into a format suitable for passing to plugin constructor.
"""
conf_options = {}
if options is not None:
for option in options:
key, value = [x.strip() for x in option.split('=... |
Convert a list of options from command-line arguments
into a format suitable for passing to plugin constructor.
| Convert a list of options from command-line arguments
into a format suitable for passing to plugin constructor. | [
"Convert",
"a",
"list",
"of",
"options",
"from",
"command",
"-",
"line",
"arguments",
"into",
"a",
"format",
"suitable",
"for",
"passing",
"to",
"plugin",
"constructor",
"."
] | def plugin_options_from_cmdline(options):
conf_options = {}
if options is not None:
for option in options:
key, value = [x.strip() for x in option.split('=', 1)]
if ':' in key:
k_type, key = key.split(':', 1)
value = convert_string(k_type, value)
... | [
"def",
"plugin_options_from_cmdline",
"(",
"options",
")",
":",
"conf_options",
"=",
"{",
"}",
"if",
"options",
"is",
"not",
"None",
":",
"for",
"option",
"in",
"options",
":",
"key",
",",
"value",
"=",
"[",
"x",
".",
"strip",
"(",
")",
"for",
"x",
"... | Convert a list of options from command-line arguments
into a format suitable for passing to plugin constructor. | [
"Convert",
"a",
"list",
"of",
"options",
"from",
"command",
"-",
"line",
"arguments",
"into",
"a",
"format",
"suitable",
"for",
"passing",
"to",
"plugin",
"constructor",
"."
] | [
"\"\"\"\n Convert a list of options from command-line arguments\n into a format suitable for passing to plugin constructor.\n \"\"\""
] | [
{
"param": "options",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "options",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33d0e20b79e87d4568c66d378fccdc32045304ec | opendatatrentino/opendata-harvester | harvester/utils/__init__.py | [
"BSD-2-Clause"
] | Python | prepare_plugin_options | <not_specific> | def prepare_plugin_options(plugin_class, options):
"""
Prepare plugin options by extracting / converting supported
values from a plugin.
"""
opt_schema = plugin_class.get_options()
if options is None:
options = {}
conf = {}
for opt_def in opt_schema.itervalues():
if op... |
Prepare plugin options by extracting / converting supported
values from a plugin.
| Prepare plugin options by extracting / converting supported
values from a plugin. | [
"Prepare",
"plugin",
"options",
"by",
"extracting",
"/",
"converting",
"supported",
"values",
"from",
"a",
"plugin",
"."
] | def prepare_plugin_options(plugin_class, options):
opt_schema = plugin_class.get_options()
if options is None:
options = {}
conf = {}
for opt_def in opt_schema.itervalues():
if opt_def.name in options:
type_, value = options.pop(opt_def.name)
if type_ is None:
... | [
"def",
"prepare_plugin_options",
"(",
"plugin_class",
",",
"options",
")",
":",
"opt_schema",
"=",
"plugin_class",
".",
"get_options",
"(",
")",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"{",
"}",
"conf",
"=",
"{",
"}",
"for",
"opt_def",
"in",
... | Prepare plugin options by extracting / converting supported
values from a plugin. | [
"Prepare",
"plugin",
"options",
"by",
"extracting",
"/",
"converting",
"supported",
"values",
"from",
"a",
"plugin",
"."
] | [
"\"\"\"\n Prepare plugin options by extracting / converting supported\n values from a plugin.\n \"\"\"",
"# Take type, value from the passed-in value",
"# If type is not specified on the command line,",
"# use the default type for this option.",
"# Perform type conversion",
"# Option was not spec... | [
{
"param": "plugin_class",
"type": null
},
{
"param": "options",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "plugin_class",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "options",
"type": null,
"docstring": null,
"docstring... |
33d0e20b79e87d4568c66d378fccdc32045304ec | opendatatrentino/opendata-harvester | harvester/utils/__init__.py | [
"BSD-2-Clause"
] | Python | to_ordinal | <not_specific> | def to_ordinal(number):
"""Return the "ordinal" representation of a number"""
assert isinstance(number, int)
sr = str(number) # string representation
ld = sr[-1] # last digit
try:
# Second to last digit
stld = sr[-2]
except IndexError:
stld = None
if stld != '1'... | Return the "ordinal" representation of a number | Return the "ordinal" representation of a number | [
"Return",
"the",
"\"",
"ordinal",
"\"",
"representation",
"of",
"a",
"number"
] | def to_ordinal(number):
assert isinstance(number, int)
sr = str(number)
ld = sr[-1]
try:
stld = sr[-2]
except IndexError:
stld = None
if stld != '1':
if ld == '1':
return sr + 'st'
if ld == '2':
return sr + 'nd'
if ld == '3':
... | [
"def",
"to_ordinal",
"(",
"number",
")",
":",
"assert",
"isinstance",
"(",
"number",
",",
"int",
")",
"sr",
"=",
"str",
"(",
"number",
")",
"ld",
"=",
"sr",
"[",
"-",
"1",
"]",
"try",
":",
"stld",
"=",
"sr",
"[",
"-",
"2",
"]",
"except",
"Index... | Return the "ordinal" representation of a number | [
"Return",
"the",
"\"",
"ordinal",
"\"",
"representation",
"of",
"a",
"number"
] | [
"\"\"\"Return the \"ordinal\" representation of a number\"\"\"",
"# string representation",
"# last digit",
"# Second to last digit"
] | [
{
"param": "number",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "number",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33d0e20b79e87d4568c66d378fccdc32045304ec | opendatatrentino/opendata-harvester | harvester/utils/__init__.py | [
"BSD-2-Clause"
] | Python | decode_faulty_json | <not_specific> | def decode_faulty_json(text):
"""
Attempt to decode json containing newlines inside strings,
which is invalid for the JSON standard.
"""
text = text.replace('\n', ' ').replace('\r', '')
return json.loads(text) |
Attempt to decode json containing newlines inside strings,
which is invalid for the JSON standard.
| Attempt to decode json containing newlines inside strings,
which is invalid for the JSON standard. | [
"Attempt",
"to",
"decode",
"json",
"containing",
"newlines",
"inside",
"strings",
"which",
"is",
"invalid",
"for",
"the",
"JSON",
"standard",
"."
] | def decode_faulty_json(text):
text = text.replace('\n', ' ').replace('\r', '')
return json.loads(text) | [
"def",
"decode_faulty_json",
"(",
"text",
")",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"'\\n'",
",",
"' '",
")",
".",
"replace",
"(",
"'\\r'",
",",
"''",
")",
"return",
"json",
".",
"loads",
"(",
"text",
")"
] | Attempt to decode json containing newlines inside strings,
which is invalid for the JSON standard. | [
"Attempt",
"to",
"decode",
"json",
"containing",
"newlines",
"inside",
"strings",
"which",
"is",
"invalid",
"for",
"the",
"JSON",
"standard",
"."
] | [
"\"\"\"\n Attempt to decode json containing newlines inside strings,\n which is invalid for the JSON standard.\n \"\"\""
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33d0e20b79e87d4568c66d378fccdc32045304ec | opendatatrentino/opendata-harvester | harvester/utils/__init__.py | [
"BSD-2-Clause"
] | Python | normalize_case | <not_specific> | def normalize_case(text):
"""
Normalize case of some (all-{upper|lower}case) text.
Uses a wordlist to determine which words need capitalization.
"""
# todo: figure out a smarter way :)
SPECIAL_CASE_WORDS = [
'Trento', 'Provincia',
]
text = text.lower()
for word in SPECIAL_CA... |
Normalize case of some (all-{upper|lower}case) text.
Uses a wordlist to determine which words need capitalization.
| Normalize case of some (all-{upper|lower}case) text.
Uses a wordlist to determine which words need capitalization. | [
"Normalize",
"case",
"of",
"some",
"(",
"all",
"-",
"{",
"upper|lower",
"}",
"case",
")",
"text",
".",
"Uses",
"a",
"wordlist",
"to",
"determine",
"which",
"words",
"need",
"capitalization",
"."
] | def normalize_case(text):
SPECIAL_CASE_WORDS = [
'Trento', 'Provincia',
]
text = text.lower()
for word in SPECIAL_CASE_WORDS:
text.replace(word.lower(), word)
return text.capitalize() | [
"def",
"normalize_case",
"(",
"text",
")",
":",
"SPECIAL_CASE_WORDS",
"=",
"[",
"'Trento'",
",",
"'Provincia'",
",",
"]",
"text",
"=",
"text",
".",
"lower",
"(",
")",
"for",
"word",
"in",
"SPECIAL_CASE_WORDS",
":",
"text",
".",
"replace",
"(",
"word",
".... | Normalize case of some (all-{upper|lower}case) text. | [
"Normalize",
"case",
"of",
"some",
"(",
"all",
"-",
"{",
"upper|lower",
"}",
"case",
")",
"text",
"."
] | [
"\"\"\"\n Normalize case of some (all-{upper|lower}case) text.\n Uses a wordlist to determine which words need capitalization.\n \"\"\"",
"# todo: figure out a smarter way :)"
] | [
{
"param": "text",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ee1db9fbc30653f062a9269ee97396b5196876c6 | opendatatrentino/opendata-harvester | harvester/ext/importer/ckan_sync_client.py | [
"BSD-2-Clause"
] | Python | sync | <not_specific> | def sync(self, source_name, data):
"""
Synchronize data from a source into Ckan.
- datasets are matched by _harvest_source
- groups and organizations are matched by name
:param source_name:
String identifying the source of the data. Used to build
ids tha... |
Synchronize data from a source into Ckan.
- datasets are matched by _harvest_source
- groups and organizations are matched by name
:param source_name:
String identifying the source of the data. Used to build
ids that will be used in further synchronizations.
... | Synchronize data from a source into Ckan.
datasets are matched by _harvest_source
groups and organizations are matched by name | [
"Synchronize",
"data",
"from",
"a",
"source",
"into",
"Ckan",
".",
"datasets",
"are",
"matched",
"by",
"_harvest_source",
"groups",
"and",
"organizations",
"are",
"matched",
"by",
"name"
] | def sync(self, source_name, data):
groups = dict(
(key, CkanGroup(val))
for key, val in data['group'].iteritems())
organizations = dict(
(key, CkanOrganization(val))
for key, val in data['organization'].iteritems())
groups_map = self._upsert_groups... | [
"def",
"sync",
"(",
"self",
",",
"source_name",
",",
"data",
")",
":",
"groups",
"=",
"dict",
"(",
"(",
"key",
",",
"CkanGroup",
"(",
"val",
")",
")",
"for",
"key",
",",
"val",
"in",
"data",
"[",
"'group'",
"]",
".",
"iteritems",
"(",
")",
")",
... | Synchronize data from a source into Ckan. | [
"Synchronize",
"data",
"from",
"a",
"source",
"into",
"Ckan",
"."
] | [
"\"\"\"\n Synchronize data from a source into Ckan.\n\n - datasets are matched by _harvest_source\n - groups and organizations are matched by name\n\n :param source_name:\n String identifying the source of the data. Used to build\n ids that will be used in further s... | [
{
"param": "self",
"type": null
},
{
"param": "source_name",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source_name",
"type": null,
"docstring": "String identifying the so... |
ee1db9fbc30653f062a9269ee97396b5196876c6 | opendatatrentino/opendata-harvester | harvester/ext/importer/ckan_sync_client.py | [
"BSD-2-Clause"
] | Python | _find_datasets_by_source | <not_specific> | def _find_datasets_by_source(self, source_name):
"""
Find all datasets matching the current source.
Returns a dict mapping source ids with dataset objects.
"""
# HACK: We are reporting *twice* the number of datasets,
# to give an estimate of the remaining steps..
... |
Find all datasets matching the current source.
Returns a dict mapping source ids with dataset objects.
| Find all datasets matching the current source.
Returns a dict mapping source ids with dataset objects. | [
"Find",
"all",
"datasets",
"matching",
"the",
"current",
"source",
".",
"Returns",
"a",
"dict",
"mapping",
"source",
"ids",
"with",
"dataset",
"objects",
"."
] | def _find_datasets_by_source(self, source_name):
_total = len(self._client.list_datasets())
_current = itertools.count(1).next
results = {}
report_progress(('get ckan state',), 0, _total * 2)
for dataset in self._client.iter_datasets():
if HARVEST_SOURCE_ID_FIELD in d... | [
"def",
"_find_datasets_by_source",
"(",
"self",
",",
"source_name",
")",
":",
"_total",
"=",
"len",
"(",
"self",
".",
"_client",
".",
"list_datasets",
"(",
")",
")",
"_current",
"=",
"itertools",
".",
"count",
"(",
"1",
")",
".",
"next",
"results",
"=",
... | Find all datasets matching the current source. | [
"Find",
"all",
"datasets",
"matching",
"the",
"current",
"source",
"."
] | [
"\"\"\"\n Find all datasets matching the current source.\n Returns a dict mapping source ids with dataset objects.\n \"\"\"",
"# HACK: We are reporting *twice* the number of datasets,",
"# to give an estimate of the remaining steps.."
] | [
{
"param": "self",
"type": null
},
{
"param": "source_name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source_name",
"type": null,
"docstring": null,
"docstring_tok... |
8320d741d0f8e87ee54849e8fd4773b7b52443d3 | opendatatrentino/opendata-harvester | harvester/utils/xml_data_extraction.py | [
"BSD-2-Clause"
] | Python | xml_extract_text_values | <not_specific> | def xml_extract_text_values(s):
"""
Extract all the text found in an xml, along with its path.
:param s: The XML data, as string
:return: a dictionary mapping ``{path: [values ...]}``
"""
tree = lxml.etree.fromstring(s)
found_data = defaultdict(list)
def _get_tag_name(elem):
l... |
Extract all the text found in an xml, along with its path.
:param s: The XML data, as string
:return: a dictionary mapping ``{path: [values ...]}``
| Extract all the text found in an xml, along with its path. | [
"Extract",
"all",
"the",
"text",
"found",
"in",
"an",
"xml",
"along",
"with",
"its",
"path",
"."
] | def xml_extract_text_values(s):
tree = lxml.etree.fromstring(s)
found_data = defaultdict(list)
def _get_tag_name(elem):
localname = lxml.etree.QName(elem.tag).localname
if elem.prefix is not None:
return ':'.join((elem.prefix, localname))
return localname
def _get_tag... | [
"def",
"xml_extract_text_values",
"(",
"s",
")",
":",
"tree",
"=",
"lxml",
".",
"etree",
".",
"fromstring",
"(",
"s",
")",
"found_data",
"=",
"defaultdict",
"(",
"list",
")",
"def",
"_get_tag_name",
"(",
"elem",
")",
":",
"localname",
"=",
"lxml",
".",
... | Extract all the text found in an xml, along with its path. | [
"Extract",
"all",
"the",
"text",
"found",
"in",
"an",
"xml",
"along",
"with",
"its",
"path",
"."
] | [
"\"\"\"\n Extract all the text found in an xml, along with its path.\n\n :param s: The XML data, as string\n :return: a dictionary mapping ``{path: [values ...]}``\n \"\"\"",
"# for elem in tree.xpath('//*[text()]'):",
"# was just garbage.."
] | [
{
"param": "s",
"type": null
}
] | {
"returns": [
{
"docstring": "a dictionary mapping ``{path: [values ...]}``",
"docstring_tokens": [
"a",
"dictionary",
"mapping",
"`",
"`",
"{",
"path",
":",
"[",
"values",
"...",
"]",
"}",
... |
3bef3da18480ad83f3204456b5c7911afb1f39a8 | opendatatrentino/opendata-harvester | harvester_odt/comunweb/crawler.py | [
"BSD-2-Clause"
] | Python | _list_object_classes | <not_specific> | def _list_object_classes(self):
"""
Return a list of available "object classes" for the crawled site.
Each item in the list is a dict like this::
{
"identifier": "open_data",
"link": "http://.../api/opendata/v1/content/class/open_data",
"name": "... |
Return a list of available "object classes" for the crawled site.
Each item in the list is a dict like this::
{
"identifier": "open_data",
"link": "http://.../api/opendata/v1/content/class/open_data",
"name": "Open Data"
},
| Return a list of available "object classes" for the crawled site.
Each item in the list is a dict like this:.
| [
"Return",
"a",
"list",
"of",
"available",
"\"",
"object",
"classes",
"\"",
"for",
"the",
"crawled",
"site",
".",
"Each",
"item",
"in",
"the",
"list",
"is",
"a",
"dict",
"like",
"this",
":",
"."
] | def _list_object_classes(self):
response = requests.get(urlparse.urljoin(
self.url, '/api/opendata/v1/content/classList'))
assert response.ok
return response.json()['classes'] | [
"def",
"_list_object_classes",
"(",
"self",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"urlparse",
".",
"urljoin",
"(",
"self",
".",
"url",
",",
"'/api/opendata/v1/content/classList'",
")",
")",
"assert",
"response",
".",
"ok",
"return",
"response... | Return a list of available "object classes" for the crawled site. | [
"Return",
"a",
"list",
"of",
"available",
"\"",
"object",
"classes",
"\"",
"for",
"the",
"crawled",
"site",
"."
] | [
"\"\"\"\n Return a list of available \"object classes\" for the crawled site.\n\n Each item in the list is a dict like this::\n\n {\n \"identifier\": \"open_data\",\n \"link\": \"http://.../api/opendata/v1/content/class/open_data\",\n \"name\": \"Open Data\"... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3bef3da18480ad83f3204456b5c7911afb1f39a8 | opendatatrentino/opendata-harvester | harvester_odt/comunweb/crawler.py | [
"BSD-2-Clause"
] | Python | _scan_pages | <not_specific> | def _scan_pages(self, start_url):
"""
Keep downloading pages from a paged API request and yield
objects found in each page, until the end is reached.
Each yielded item is a dict like this::
{
"classIdentifier": "open_data",
"dateModified": 1399274108... |
Keep downloading pages from a paged API request and yield
objects found in each page, until the end is reached.
Each yielded item is a dict like this::
{
"classIdentifier": "open_data",
"dateModified": 1399274108,
"datePublished": 1399240800,
... | Keep downloading pages from a paged API request and yield
objects found in each page, until the end is reached.
Each yielded item is a dict like this:.
| [
"Keep",
"downloading",
"pages",
"from",
"a",
"paged",
"API",
"request",
"and",
"yield",
"objects",
"found",
"in",
"each",
"page",
"until",
"the",
"end",
"is",
"reached",
".",
"Each",
"yielded",
"item",
"is",
"a",
"dict",
"like",
"this",
":",
"."
] | def _scan_pages(self, start_url):
offset, limit = 0, 50
while True:
page_url = '{0}/offset/{1}/limit/{2}'.format(
start_url.rstrip('/'), offset, limit)
response = requests.get(page_url)
nodes = response.json()['nodes']
if len(nodes) < 1:
... | [
"def",
"_scan_pages",
"(",
"self",
",",
"start_url",
")",
":",
"offset",
",",
"limit",
"=",
"0",
",",
"50",
"while",
"True",
":",
"page_url",
"=",
"'{0}/offset/{1}/limit/{2}'",
".",
"format",
"(",
"start_url",
".",
"rstrip",
"(",
"'/'",
")",
",",
"offset... | Keep downloading pages from a paged API request and yield
objects found in each page, until the end is reached. | [
"Keep",
"downloading",
"pages",
"from",
"a",
"paged",
"API",
"request",
"and",
"yield",
"objects",
"found",
"in",
"each",
"page",
"until",
"the",
"end",
"is",
"reached",
"."
] | [
"\"\"\"\n Keep downloading pages from a paged API request and yield\n objects found in each page, until the end is reached.\n\n Each yielded item is a dict like this::\n\n {\n \"classIdentifier\": \"open_data\",\n \"dateModified\": 1399274108,\n \"dat... | [
{
"param": "self",
"type": null
},
{
"param": "start_url",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "start_url",
"type": null,
"docstring": null,
"docstring_token... |
faab2cbc0da47673efe05fe345fc812c127a6162 | opendatatrentino/opendata-harvester | harvester_odt/comunweb/converter.py | [
"BSD-2-Clause"
] | Python | _comunweb_dataset_to_ckan | <not_specific> | def _comunweb_dataset_to_ckan(self, obj):
"""
Prepare an object from comunweb for insertion to ckan
"""
metadata = obj['full_metadata']
values = comunweb_normalize_field_values(metadata)
# License is available in:
# metadata['fields']['licenza']['value']['link']... |
Prepare an object from comunweb for insertion to ckan
| Prepare an object from comunweb for insertion to ckan | [
"Prepare",
"an",
"object",
"from",
"comunweb",
"for",
"insertion",
"to",
"ckan"
] | def _comunweb_dataset_to_ckan(self, obj):
metadata = obj['full_metadata']
values = comunweb_normalize_field_values(metadata)
license_url = metadata['fields']['licenza']['value']['link']
license_id = self._get_cached_license(license_url)
dataset = {
'name': slugify(obj... | [
"def",
"_comunweb_dataset_to_ckan",
"(",
"self",
",",
"obj",
")",
":",
"metadata",
"=",
"obj",
"[",
"'full_metadata'",
"]",
"values",
"=",
"comunweb_normalize_field_values",
"(",
"metadata",
")",
"license_url",
"=",
"metadata",
"[",
"'fields'",
"]",
"[",
"'licen... | Prepare an object from comunweb for insertion to ckan | [
"Prepare",
"an",
"object",
"from",
"comunweb",
"for",
"insertion",
"to",
"ckan"
] | [
"\"\"\"\n Prepare an object from comunweb for insertion to ckan\n \"\"\"",
"# License is available in:",
"# metadata['fields']['licenza']['value']['link']",
"# Downloading that URL gets to a json file; license id is in:",
"# data['fields']['titolo']['value']",
"# todo: set this?",
"# Set d... | [
{
"param": "self",
"type": null
},
{
"param": "obj",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "obj",
"type": null,
"docstring": null,
"docstring_tokens": []... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.