repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
uchicago-cs/deepdish | deepdish/core.py | bytesize | def bytesize(arr):
"""
Returns the memory byte size of a Numpy array as an integer.
"""
byte_size = np.prod(arr.shape) * np.dtype(arr.dtype).itemsize
return byte_size | python | def bytesize(arr):
"""
Returns the memory byte size of a Numpy array as an integer.
"""
byte_size = np.prod(arr.shape) * np.dtype(arr.dtype).itemsize
return byte_size | [
"def",
"bytesize",
"(",
"arr",
")",
":",
"byte_size",
"=",
"np",
".",
"prod",
"(",
"arr",
".",
"shape",
")",
"*",
"np",
".",
"dtype",
"(",
"arr",
".",
"dtype",
")",
".",
"itemsize",
"return",
"byte_size"
] | Returns the memory byte size of a Numpy array as an integer. | [
"Returns",
"the",
"memory",
"byte",
"size",
"of",
"a",
"Numpy",
"array",
"as",
"an",
"integer",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/core.py#L23-L28 |
uchicago-cs/deepdish | deepdish/core.py | apply_once | def apply_once(func, arr, axes, keepdims=True):
"""
Similar to `numpy.apply_over_axes`, except this performs the operation over
a flattened version of all the axes, meaning that the function will only be
called once. This only makes a difference for non-linear functions.
Parameters
----------
... | python | def apply_once(func, arr, axes, keepdims=True):
"""
Similar to `numpy.apply_over_axes`, except this performs the operation over
a flattened version of all the axes, meaning that the function will only be
called once. This only makes a difference for non-linear functions.
Parameters
----------
... | [
"def",
"apply_once",
"(",
"func",
",",
"arr",
",",
"axes",
",",
"keepdims",
"=",
"True",
")",
":",
"all_axes",
"=",
"np",
".",
"arange",
"(",
"arr",
".",
"ndim",
")",
"if",
"isinstance",
"(",
"axes",
",",
"int",
")",
":",
"axes",
"=",
"{",
"axes"... | Similar to `numpy.apply_over_axes`, except this performs the operation over
a flattened version of all the axes, meaning that the function will only be
called once. This only makes a difference for non-linear functions.
Parameters
----------
func : callback
Function that operates well on Nu... | [
"Similar",
"to",
"numpy",
".",
"apply_over_axes",
"except",
"this",
"performs",
"the",
"operation",
"over",
"a",
"flattened",
"version",
"of",
"all",
"the",
"axes",
"meaning",
"that",
"the",
"function",
"will",
"only",
"be",
"called",
"once",
".",
"This",
"o... | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/core.py#L74-L162 |
uchicago-cs/deepdish | deepdish/core.py | tupled_argmax | def tupled_argmax(a):
"""
Argmax that returns an index tuple. Note that `numpy.argmax` will return a
scalar index as if you had flattened the array.
Parameters
----------
a : array_like
Input array.
Returns
-------
index : tuple
Tuple of index, even if `a` is one-di... | python | def tupled_argmax(a):
"""
Argmax that returns an index tuple. Note that `numpy.argmax` will return a
scalar index as if you had flattened the array.
Parameters
----------
a : array_like
Input array.
Returns
-------
index : tuple
Tuple of index, even if `a` is one-di... | [
"def",
"tupled_argmax",
"(",
"a",
")",
":",
"return",
"np",
".",
"unravel_index",
"(",
"np",
".",
"argmax",
"(",
"a",
")",
",",
"np",
".",
"shape",
"(",
"a",
")",
")"
] | Argmax that returns an index tuple. Note that `numpy.argmax` will return a
scalar index as if you had flattened the array.
Parameters
----------
a : array_like
Input array.
Returns
-------
index : tuple
Tuple of index, even if `a` is one-dimensional. Note that this can
... | [
"Argmax",
"that",
"returns",
"an",
"index",
"tuple",
".",
"Note",
"that",
"numpy",
".",
"argmax",
"will",
"return",
"a",
"scalar",
"index",
"as",
"if",
"you",
"had",
"flattened",
"the",
"array",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/core.py#L165-L192 |
uchicago-cs/deepdish | deepdish/core.py | timed | def timed(name=None, file=sys.stdout, callback=None, wall_clock=True):
"""
Context manager to make it easy to time the execution of a piece of code.
This timer will never run your code several times and is meant more for
simple in-production timing, instead of benchmarking. Reports the
wall-clock ti... | python | def timed(name=None, file=sys.stdout, callback=None, wall_clock=True):
"""
Context manager to make it easy to time the execution of a piece of code.
This timer will never run your code several times and is meant more for
simple in-production timing, instead of benchmarking. Reports the
wall-clock ti... | [
"def",
"timed",
"(",
"name",
"=",
"None",
",",
"file",
"=",
"sys",
".",
"stdout",
",",
"callback",
"=",
"None",
",",
"wall_clock",
"=",
"True",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"yield",
"end",
"=",
"time",
".",
"time",
"(",
... | Context manager to make it easy to time the execution of a piece of code.
This timer will never run your code several times and is meant more for
simple in-production timing, instead of benchmarking. Reports the
wall-clock time (using `time.time`) and not the processor time.
Parameters
----------
... | [
"Context",
"manager",
"to",
"make",
"it",
"easy",
"to",
"time",
"the",
"execution",
"of",
"a",
"piece",
"of",
"code",
".",
"This",
"timer",
"will",
"never",
"run",
"your",
"code",
"several",
"times",
"and",
"is",
"meant",
"more",
"for",
"simple",
"in",
... | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/core.py#L200-L253 |
uchicago-cs/deepdish | deepdish/util/padding.py | pad | def pad(data, padwidth, value=0.0):
"""
Pad an array with a specific value.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
padwidth : int or tuple
If int, it will pad using this amount at the beginning and end of all
dimensions. If it is a tu... | python | def pad(data, padwidth, value=0.0):
"""
Pad an array with a specific value.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
padwidth : int or tuple
If int, it will pad using this amount at the beginning and end of all
dimensions. If it is a tu... | [
"def",
"pad",
"(",
"data",
",",
"padwidth",
",",
"value",
"=",
"0.0",
")",
":",
"data",
"=",
"np",
".",
"asarray",
"(",
"data",
")",
"shape",
"=",
"data",
".",
"shape",
"if",
"isinstance",
"(",
"padwidth",
",",
"int",
")",
":",
"padwidth",
"=",
"... | Pad an array with a specific value.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
padwidth : int or tuple
If int, it will pad using this amount at the beginning and end of all
dimensions. If it is a tuple (of same length as `ndim`), then the
... | [
"Pad",
"an",
"array",
"with",
"a",
"specific",
"value",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/util/padding.py#L5-L50 |
uchicago-cs/deepdish | deepdish/util/padding.py | pad_to_size | def pad_to_size(data, shape, value=0.0):
"""
This is similar to `pad`, except you specify the final shape of the array.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
shape : tuple
Final shape of padded array. Should be tuple of length ``data.ndim``.... | python | def pad_to_size(data, shape, value=0.0):
"""
This is similar to `pad`, except you specify the final shape of the array.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
shape : tuple
Final shape of padded array. Should be tuple of length ``data.ndim``.... | [
"def",
"pad_to_size",
"(",
"data",
",",
"shape",
",",
"value",
"=",
"0.0",
")",
":",
"shape",
"=",
"[",
"data",
".",
"shape",
"[",
"i",
"]",
"if",
"shape",
"[",
"i",
"]",
"==",
"-",
"1",
"else",
"shape",
"[",
"i",
"]",
"for",
"i",
"in",
"rang... | This is similar to `pad`, except you specify the final shape of the array.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
shape : tuple
Final shape of padded array. Should be tuple of length ``data.ndim``.
If it has to pad unevenly, it will pad one m... | [
"This",
"is",
"similar",
"to",
"pad",
"except",
"you",
"specify",
"the",
"final",
"shape",
"of",
"the",
"array",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/util/padding.py#L53-L96 |
uchicago-cs/deepdish | deepdish/util/padding.py | pad_repeat_border | def pad_repeat_border(data, padwidth):
"""
Similar to `pad`, except the border value from ``data`` is used to pad.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
padwidth : int or tuple
If int, it will pad using this amount at the beginning and end o... | python | def pad_repeat_border(data, padwidth):
"""
Similar to `pad`, except the border value from ``data`` is used to pad.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
padwidth : int or tuple
If int, it will pad using this amount at the beginning and end o... | [
"def",
"pad_repeat_border",
"(",
"data",
",",
"padwidth",
")",
":",
"data",
"=",
"np",
".",
"asarray",
"(",
"data",
")",
"shape",
"=",
"data",
".",
"shape",
"if",
"isinstance",
"(",
"padwidth",
",",
"int",
")",
":",
"padwidth",
"=",
"(",
"padwidth",
... | Similar to `pad`, except the border value from ``data`` is used to pad.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
padwidth : int or tuple
If int, it will pad using this amount at the beginning and end of all
dimensions. If it is a tuple (of same... | [
"Similar",
"to",
"pad",
"except",
"the",
"border",
"value",
"from",
"data",
"is",
"used",
"to",
"pad",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/util/padding.py#L99-L157 |
uchicago-cs/deepdish | deepdish/util/padding.py | pad_repeat_border_corner | def pad_repeat_border_corner(data, shape):
"""
Similar to `pad_repeat_border`, except the padding is always done on the
upper end of each axis and the target size is specified.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
shape : tuple
Final sh... | python | def pad_repeat_border_corner(data, shape):
"""
Similar to `pad_repeat_border`, except the padding is always done on the
upper end of each axis and the target size is specified.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
shape : tuple
Final sh... | [
"def",
"pad_repeat_border_corner",
"(",
"data",
",",
"shape",
")",
":",
"new_data",
"=",
"np",
".",
"empty",
"(",
"shape",
")",
"new_data",
"[",
"[",
"slice",
"(",
"upper",
")",
"for",
"upper",
"in",
"data",
".",
"shape",
"]",
"]",
"=",
"data",
"for"... | Similar to `pad_repeat_border`, except the padding is always done on the
upper end of each axis and the target size is specified.
Parameters
----------
data : ndarray
Numpy array of any dimension and type.
shape : tuple
Final shape of padded array. Should be tuple of length ``data.n... | [
"Similar",
"to",
"pad_repeat_border",
"except",
"the",
"padding",
"is",
"always",
"done",
"on",
"the",
"upper",
"end",
"of",
"each",
"axis",
"and",
"the",
"target",
"size",
"is",
"specified",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/util/padding.py#L160-L197 |
uchicago-cs/deepdish | deepdish/io/hdf5io.py | _dict_native_ok | def _dict_native_ok(d):
"""
This checks if a dictionary can be saved natively as HDF5 groups.
If it can't, it will be pickled.
"""
if len(d) >= 256:
return False
# All keys must be strings
for k in d:
if not isinstance(k, six.string_types):
return False
ret... | python | def _dict_native_ok(d):
"""
This checks if a dictionary can be saved natively as HDF5 groups.
If it can't, it will be pickled.
"""
if len(d) >= 256:
return False
# All keys must be strings
for k in d:
if not isinstance(k, six.string_types):
return False
ret... | [
"def",
"_dict_native_ok",
"(",
"d",
")",
":",
"if",
"len",
"(",
"d",
")",
">=",
"256",
":",
"return",
"False",
"# All keys must be strings",
"for",
"k",
"in",
"d",
":",
"if",
"not",
"isinstance",
"(",
"k",
",",
"six",
".",
"string_types",
")",
":",
"... | This checks if a dictionary can be saved natively as HDF5 groups.
If it can't, it will be pickled. | [
"This",
"checks",
"if",
"a",
"dictionary",
"can",
"be",
"saved",
"natively",
"as",
"HDF5",
"groups",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/io/hdf5io.py#L70-L84 |
uchicago-cs/deepdish | deepdish/io/hdf5io.py | _load_nonlink_level | def _load_nonlink_level(handler, level, pathtable, pathname):
"""
Loads level and builds appropriate type, without handling softlinks
"""
if isinstance(level, tables.Group):
if _sns and (level._v_title.startswith('SimpleNamespace:') or
DEEPDISH_IO_ROOT_IS_SNS in level._v_att... | python | def _load_nonlink_level(handler, level, pathtable, pathname):
"""
Loads level and builds appropriate type, without handling softlinks
"""
if isinstance(level, tables.Group):
if _sns and (level._v_title.startswith('SimpleNamespace:') or
DEEPDISH_IO_ROOT_IS_SNS in level._v_att... | [
"def",
"_load_nonlink_level",
"(",
"handler",
",",
"level",
",",
"pathtable",
",",
"pathname",
")",
":",
"if",
"isinstance",
"(",
"level",
",",
"tables",
".",
"Group",
")",
":",
"if",
"_sns",
"and",
"(",
"level",
".",
"_v_title",
".",
"startswith",
"(",
... | Loads level and builds appropriate type, without handling softlinks | [
"Loads",
"level",
"and",
"builds",
"appropriate",
"type",
"without",
"handling",
"softlinks"
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/io/hdf5io.py#L349-L462 |
uchicago-cs/deepdish | deepdish/io/hdf5io.py | _load_level | def _load_level(handler, level, pathtable):
"""
Loads level and builds appropriate type, handling softlinks if necessary
"""
if isinstance(level, tables.link.SoftLink):
# this is a link, so see if target is already loaded, return it
pathname = level.target
node = level()
else... | python | def _load_level(handler, level, pathtable):
"""
Loads level and builds appropriate type, handling softlinks if necessary
"""
if isinstance(level, tables.link.SoftLink):
# this is a link, so see if target is already loaded, return it
pathname = level.target
node = level()
else... | [
"def",
"_load_level",
"(",
"handler",
",",
"level",
",",
"pathtable",
")",
":",
"if",
"isinstance",
"(",
"level",
",",
"tables",
".",
"link",
".",
"SoftLink",
")",
":",
"# this is a link, so see if target is already loaded, return it",
"pathname",
"=",
"level",
".... | Loads level and builds appropriate type, handling softlinks if necessary | [
"Loads",
"level",
"and",
"builds",
"appropriate",
"type",
"handling",
"softlinks",
"if",
"necessary"
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/io/hdf5io.py#L465-L483 |
uchicago-cs/deepdish | deepdish/io/hdf5io.py | save | def save(path, data, compression='default'):
"""
Save any Python structure to an HDF5 file. It is particularly suited for
Numpy arrays. This function works similar to ``numpy.save``, except if you
save a Python object at the top level, you do not need to issue
``data.flat[0]`` to retrieve it from in... | python | def save(path, data, compression='default'):
"""
Save any Python structure to an HDF5 file. It is particularly suited for
Numpy arrays. This function works similar to ``numpy.save``, except if you
save a Python object at the top level, you do not need to issue
``data.flat[0]`` to retrieve it from in... | [
"def",
"save",
"(",
"path",
",",
"data",
",",
"compression",
"=",
"'default'",
")",
":",
"filters",
"=",
"_get_compression_filters",
"(",
"compression",
")",
"with",
"tables",
".",
"open_file",
"(",
"path",
",",
"mode",
"=",
"'w'",
")",
"as",
"h5file",
"... | Save any Python structure to an HDF5 file. It is particularly suited for
Numpy arrays. This function works similar to ``numpy.save``, except if you
save a Python object at the top level, you do not need to issue
``data.flat[0]`` to retrieve it from inside a Numpy array of type
``object``.
Some type... | [
"Save",
"any",
"Python",
"structure",
"to",
"an",
"HDF5",
"file",
".",
"It",
"is",
"particularly",
"suited",
"for",
"Numpy",
"arrays",
".",
"This",
"function",
"works",
"similar",
"to",
"numpy",
".",
"save",
"except",
"if",
"you",
"save",
"a",
"Python",
... | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/io/hdf5io.py#L504-L598 |
uchicago-cs/deepdish | deepdish/io/hdf5io.py | load | def load(path, group=None, sel=None, unpack=False):
"""
Loads an HDF5 saved with `save`.
This function requires the `PyTables <http://www.pytables.org/>`_ module to
be installed.
Parameters
----------
path : string
Filename from which to load the data.
group : string or list
... | python | def load(path, group=None, sel=None, unpack=False):
"""
Loads an HDF5 saved with `save`.
This function requires the `PyTables <http://www.pytables.org/>`_ module to
be installed.
Parameters
----------
path : string
Filename from which to load the data.
group : string or list
... | [
"def",
"load",
"(",
"path",
",",
"group",
"=",
"None",
",",
"sel",
"=",
"None",
",",
"unpack",
"=",
"False",
")",
":",
"with",
"tables",
".",
"open_file",
"(",
"path",
",",
"mode",
"=",
"'r'",
")",
"as",
"h5file",
":",
"pathtable",
"=",
"{",
"}",... | Loads an HDF5 saved with `save`.
This function requires the `PyTables <http://www.pytables.org/>`_ module to
be installed.
Parameters
----------
path : string
Filename from which to load the data.
group : string or list
Load a specific group in the HDF5 hierarchy. If `group` is... | [
"Loads",
"an",
"HDF5",
"saved",
"with",
"save",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/io/hdf5io.py#L601-L679 |
uchicago-cs/deepdish | deepdish/io/ls.py | sorted_maybe_numeric | def sorted_maybe_numeric(x):
"""
Sorts x with numeric semantics if all keys are nonnegative integers.
Otherwise uses standard string sorting.
"""
all_numeric = all(map(str.isdigit, x))
if all_numeric:
return sorted(x, key=int)
else:
return sorted(x) | python | def sorted_maybe_numeric(x):
"""
Sorts x with numeric semantics if all keys are nonnegative integers.
Otherwise uses standard string sorting.
"""
all_numeric = all(map(str.isdigit, x))
if all_numeric:
return sorted(x, key=int)
else:
return sorted(x) | [
"def",
"sorted_maybe_numeric",
"(",
"x",
")",
":",
"all_numeric",
"=",
"all",
"(",
"map",
"(",
"str",
".",
"isdigit",
",",
"x",
")",
")",
"if",
"all_numeric",
":",
"return",
"sorted",
"(",
"x",
",",
"key",
"=",
"int",
")",
"else",
":",
"return",
"s... | Sorts x with numeric semantics if all keys are nonnegative integers.
Otherwise uses standard string sorting. | [
"Sorts",
"x",
"with",
"numeric",
"semantics",
"if",
"all",
"keys",
"are",
"nonnegative",
"integers",
".",
"Otherwise",
"uses",
"standard",
"string",
"sorting",
"."
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/io/ls.py#L64-L73 |
uchicago-cs/deepdish | deepdish/io/ls.py | abbreviate | def abbreviate(s, maxlength=25):
"""Color-aware abbreviator"""
assert maxlength >= 4
skip = False
abbrv = None
i = 0
for j, c in enumerate(s):
if c == '\033':
skip = True
elif skip:
if c == 'm':
skip = False
else:
i += 1... | python | def abbreviate(s, maxlength=25):
"""Color-aware abbreviator"""
assert maxlength >= 4
skip = False
abbrv = None
i = 0
for j, c in enumerate(s):
if c == '\033':
skip = True
elif skip:
if c == 'm':
skip = False
else:
i += 1... | [
"def",
"abbreviate",
"(",
"s",
",",
"maxlength",
"=",
"25",
")",
":",
"assert",
"maxlength",
">=",
"4",
"skip",
"=",
"False",
"abbrv",
"=",
"None",
"i",
"=",
"0",
"for",
"j",
",",
"c",
"in",
"enumerate",
"(",
"s",
")",
":",
"if",
"c",
"==",
"'\... | Color-aware abbreviator | [
"Color",
"-",
"aware",
"abbreviator"
] | train | https://github.com/uchicago-cs/deepdish/blob/01af93621fe082a3972fe53ba7375388c02b0085/deepdish/io/ls.py#L117-L140 |
genialis/resolwe | resolwe/flow/executors/prepare.py | BaseFlowExecutorPreparer.extend_settings | def extend_settings(self, data_id, files, secrets):
"""Extend the settings the manager will serialize.
:param data_id: The :class:`~resolwe.flow.models.Data` object id
being prepared for.
:param files: The settings dictionary to be serialized. Keys are
filenames, values ... | python | def extend_settings(self, data_id, files, secrets):
"""Extend the settings the manager will serialize.
:param data_id: The :class:`~resolwe.flow.models.Data` object id
being prepared for.
:param files: The settings dictionary to be serialized. Keys are
filenames, values ... | [
"def",
"extend_settings",
"(",
"self",
",",
"data_id",
",",
"files",
",",
"secrets",
")",
":",
"data",
"=",
"Data",
".",
"objects",
".",
"select_related",
"(",
"'process'",
")",
".",
"get",
"(",
"pk",
"=",
"data_id",
")",
"files",
"[",
"ExecutorFiles",
... | Extend the settings the manager will serialize.
:param data_id: The :class:`~resolwe.flow.models.Data` object id
being prepared for.
:param files: The settings dictionary to be serialized. Keys are
filenames, values are the objects that will be serialized
into those ... | [
"Extend",
"the",
"settings",
"the",
"manager",
"will",
"serialize",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/prepare.py#L30-L56 |
genialis/resolwe | resolwe/flow/executors/prepare.py | BaseFlowExecutorPreparer.get_tools_paths | def get_tools_paths(self):
"""Get tools' paths."""
if settings.DEBUG or is_testing():
return list(get_apps_tools().values())
else:
tools_root = settings.FLOW_TOOLS_ROOT
subdirs = next(os.walk(tools_root))[1]
return [os.path.join(tools_root, sdir)... | python | def get_tools_paths(self):
"""Get tools' paths."""
if settings.DEBUG or is_testing():
return list(get_apps_tools().values())
else:
tools_root = settings.FLOW_TOOLS_ROOT
subdirs = next(os.walk(tools_root))[1]
return [os.path.join(tools_root, sdir)... | [
"def",
"get_tools_paths",
"(",
"self",
")",
":",
"if",
"settings",
".",
"DEBUG",
"or",
"is_testing",
"(",
")",
":",
"return",
"list",
"(",
"get_apps_tools",
"(",
")",
".",
"values",
"(",
")",
")",
"else",
":",
"tools_root",
"=",
"settings",
".",
"FLOW_... | Get tools' paths. | [
"Get",
"tools",
"paths",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/prepare.py#L58-L67 |
genialis/resolwe | resolwe/flow/executors/prepare.py | BaseFlowExecutorPreparer.resolve_data_path | def resolve_data_path(self, data=None, filename=None):
"""Resolve data path for use with the executor.
:param data: Data object instance
:param filename: Filename to resolve
:return: Resolved filename, which can be used to access the
given data file in programs executed usin... | python | def resolve_data_path(self, data=None, filename=None):
"""Resolve data path for use with the executor.
:param data: Data object instance
:param filename: Filename to resolve
:return: Resolved filename, which can be used to access the
given data file in programs executed usin... | [
"def",
"resolve_data_path",
"(",
"self",
",",
"data",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"data",
"is",
"None",
":",
"return",
"settings",
".",
"FLOW_EXECUTOR",
"[",
"'DATA_DIR'",
"]",
"return",
"data",
".",
"location",
".",
"get_p... | Resolve data path for use with the executor.
:param data: Data object instance
:param filename: Filename to resolve
:return: Resolved filename, which can be used to access the
given data file in programs executed using this executor | [
"Resolve",
"data",
"path",
"for",
"use",
"with",
"the",
"executor",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/prepare.py#L76-L87 |
genialis/resolwe | resolwe/flow/executors/prepare.py | BaseFlowExecutorPreparer.resolve_upload_path | def resolve_upload_path(self, filename=None):
"""Resolve upload path for use with the executor.
:param filename: Filename to resolve
:return: Resolved filename, which can be used to access the
given uploaded file in programs executed using this
executor
"""
... | python | def resolve_upload_path(self, filename=None):
"""Resolve upload path for use with the executor.
:param filename: Filename to resolve
:return: Resolved filename, which can be used to access the
given uploaded file in programs executed using this
executor
"""
... | [
"def",
"resolve_upload_path",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"if",
"filename",
"is",
"None",
":",
"return",
"settings",
".",
"FLOW_EXECUTOR",
"[",
"'UPLOAD_DIR'",
"]",
"return",
"os",
".",
"path",
".",
"join",
"(",
"settings",
".",
... | Resolve upload path for use with the executor.
:param filename: Filename to resolve
:return: Resolved filename, which can be used to access the
given uploaded file in programs executed using this
executor | [
"Resolve",
"upload",
"path",
"for",
"use",
"with",
"the",
"executor",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/executors/prepare.py#L89-L100 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | wrap | def wrap(access_pyxb, read_only=False):
"""Work with the AccessPolicy in a SystemMetadata PyXB object.
Args:
access_pyxb : AccessPolicy PyXB object
The AccessPolicy to modify.
read_only: bool
Do not update the wrapped AccessPolicy.
When only a single AccessPolicy operation is ... | python | def wrap(access_pyxb, read_only=False):
"""Work with the AccessPolicy in a SystemMetadata PyXB object.
Args:
access_pyxb : AccessPolicy PyXB object
The AccessPolicy to modify.
read_only: bool
Do not update the wrapped AccessPolicy.
When only a single AccessPolicy operation is ... | [
"def",
"wrap",
"(",
"access_pyxb",
",",
"read_only",
"=",
"False",
")",
":",
"w",
"=",
"AccessPolicyWrapper",
"(",
"access_pyxb",
")",
"yield",
"w",
"if",
"not",
"read_only",
":",
"w",
".",
"get_normalized_pyxb",
"(",
")"
] | Work with the AccessPolicy in a SystemMetadata PyXB object.
Args:
access_pyxb : AccessPolicy PyXB object
The AccessPolicy to modify.
read_only: bool
Do not update the wrapped AccessPolicy.
When only a single AccessPolicy operation is needed, there's no need to use this
context... | [
"Work",
"with",
"the",
"AccessPolicy",
"in",
"a",
"SystemMetadata",
"PyXB",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L220-L237 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | wrap_sysmeta_pyxb | def wrap_sysmeta_pyxb(sysmeta_pyxb, read_only=False):
"""Work with the AccessPolicy in a SystemMetadata PyXB object.
Args:
sysmeta_pyxb : SystemMetadata PyXB object
SystemMetadata containing the AccessPolicy to modify.
read_only: bool
Do not update the wrapped AccessPolicy.
Wh... | python | def wrap_sysmeta_pyxb(sysmeta_pyxb, read_only=False):
"""Work with the AccessPolicy in a SystemMetadata PyXB object.
Args:
sysmeta_pyxb : SystemMetadata PyXB object
SystemMetadata containing the AccessPolicy to modify.
read_only: bool
Do not update the wrapped AccessPolicy.
Wh... | [
"def",
"wrap_sysmeta_pyxb",
"(",
"sysmeta_pyxb",
",",
"read_only",
"=",
"False",
")",
":",
"w",
"=",
"AccessPolicyWrapper",
"(",
"sysmeta_pyxb",
".",
"accessPolicy",
")",
"yield",
"w",
"if",
"not",
"read_only",
":",
"sysmeta_pyxb",
".",
"accessPolicy",
"=",
"w... | Work with the AccessPolicy in a SystemMetadata PyXB object.
Args:
sysmeta_pyxb : SystemMetadata PyXB object
SystemMetadata containing the AccessPolicy to modify.
read_only: bool
Do not update the wrapped AccessPolicy.
When only a single AccessPolicy operation is needed, there's no... | [
"Work",
"with",
"the",
"AccessPolicy",
"in",
"a",
"SystemMetadata",
"PyXB",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L241-L266 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.get_highest_perm_str | def get_highest_perm_str(self, subj_str):
"""
Args:
subj_str : str
Subject for which to retrieve the highest permission.
Return:
The highest permission for subject or None if subject does not have any permissions.
"""
pres_perm_set = self._present_perm_set_for_subj(self... | python | def get_highest_perm_str(self, subj_str):
"""
Args:
subj_str : str
Subject for which to retrieve the highest permission.
Return:
The highest permission for subject or None if subject does not have any permissions.
"""
pres_perm_set = self._present_perm_set_for_subj(self... | [
"def",
"get_highest_perm_str",
"(",
"self",
",",
"subj_str",
")",
":",
"pres_perm_set",
"=",
"self",
".",
"_present_perm_set_for_subj",
"(",
"self",
".",
"_perm_dict",
",",
"subj_str",
")",
"return",
"(",
"None",
"if",
"not",
"pres_perm_set",
"else",
"self",
"... | Args:
subj_str : str
Subject for which to retrieve the highest permission.
Return:
The highest permission for subject or None if subject does not have any permissions. | [
"Args",
":",
"subj_str",
":",
"str",
"Subject",
"for",
"which",
"to",
"retrieve",
"the",
"highest",
"permission",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L311-L323 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.get_effective_perm_list | def get_effective_perm_list(self, subj_str):
"""
Args:
subj_str : str
Subject for which to retrieve the effective permissions.
Returns:
list of str: List of permissions up to and including the highest permission for
subject, ordered lower to higher, or empty list if subject do... | python | def get_effective_perm_list(self, subj_str):
"""
Args:
subj_str : str
Subject for which to retrieve the effective permissions.
Returns:
list of str: List of permissions up to and including the highest permission for
subject, ordered lower to higher, or empty list if subject do... | [
"def",
"get_effective_perm_list",
"(",
"self",
",",
"subj_str",
")",
":",
"highest_perm_str",
"=",
"self",
".",
"get_highest_perm_str",
"(",
"subj_str",
")",
"if",
"highest_perm_str",
"is",
"None",
":",
"return",
"[",
"]",
"return",
"self",
".",
"_equal_or_lower... | Args:
subj_str : str
Subject for which to retrieve the effective permissions.
Returns:
list of str: List of permissions up to and including the highest permission for
subject, ordered lower to higher, or empty list if subject does not have any
permissions.
E.g.: If 'write' is... | [
"Args",
":",
"subj_str",
":",
"str",
"Subject",
"for",
"which",
"to",
"retrieve",
"the",
"effective",
"permissions",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L325-L341 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.get_subjects_with_equal_or_higher_perm | def get_subjects_with_equal_or_higher_perm(self, perm_str):
"""
Args:
perm_str : str
Permission, ``read``, ``write`` or ``changePermission``.
Returns:
set of str : Subj that have perm equal or higher than ``perm_str``.
Since the lowest permission a subject can have is ``read`... | python | def get_subjects_with_equal_or_higher_perm(self, perm_str):
"""
Args:
perm_str : str
Permission, ``read``, ``write`` or ``changePermission``.
Returns:
set of str : Subj that have perm equal or higher than ``perm_str``.
Since the lowest permission a subject can have is ``read`... | [
"def",
"get_subjects_with_equal_or_higher_perm",
"(",
"self",
",",
"perm_str",
")",
":",
"self",
".",
"_assert_valid_permission",
"(",
"perm_str",
")",
"return",
"{",
"s",
"for",
"p",
"in",
"self",
".",
"_equal_or_higher_perm",
"(",
"perm_str",
")",
"for",
"s",
... | Args:
perm_str : str
Permission, ``read``, ``write`` or ``changePermission``.
Returns:
set of str : Subj that have perm equal or higher than ``perm_str``.
Since the lowest permission a subject can have is ``read``, passing ``read``
will return all subjects. | [
"Args",
":",
"perm_str",
":",
"str",
"Permission",
"read",
"write",
"or",
"changePermission",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L343-L360 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.dump | def dump(self):
"""Dump the current state to debug level log."""
logging.debug('AccessPolicy:')
map(
logging.debug,
[
' {}'.format(s)
for s in pprint.pformat(self.get_normalized_perm_list()).splitlines()
],
) | python | def dump(self):
"""Dump the current state to debug level log."""
logging.debug('AccessPolicy:')
map(
logging.debug,
[
' {}'.format(s)
for s in pprint.pformat(self.get_normalized_perm_list()).splitlines()
],
) | [
"def",
"dump",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"'AccessPolicy:'",
")",
"map",
"(",
"logging",
".",
"debug",
",",
"[",
"' {}'",
".",
"format",
"(",
"s",
")",
"for",
"s",
"in",
"pprint",
".",
"pformat",
"(",
"self",
".",
"get_no... | Dump the current state to debug level log. | [
"Dump",
"the",
"current",
"state",
"to",
"debug",
"level",
"log",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L362-L371 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.subj_has_perm | def subj_has_perm(self, subj_str, perm_str):
"""Returns:
bool: ``True`` if ``subj_str`` has perm equal to or higher than ``perm_str``.
"""
self._assert_valid_permission(perm_str)
return perm_str in self.get_effective_perm_list(subj_str) | python | def subj_has_perm(self, subj_str, perm_str):
"""Returns:
bool: ``True`` if ``subj_str`` has perm equal to or higher than ``perm_str``.
"""
self._assert_valid_permission(perm_str)
return perm_str in self.get_effective_perm_list(subj_str) | [
"def",
"subj_has_perm",
"(",
"self",
",",
"subj_str",
",",
"perm_str",
")",
":",
"self",
".",
"_assert_valid_permission",
"(",
"perm_str",
")",
"return",
"perm_str",
"in",
"self",
".",
"get_effective_perm_list",
"(",
"subj_str",
")"
] | Returns:
bool: ``True`` if ``subj_str`` has perm equal to or higher than ``perm_str``. | [
"Returns",
":"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L426-L433 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.add_authenticated_read | def add_authenticated_read(self):
"""Add ``read`` perm for all authenticated subj.
Public ``read`` is removed if present.
"""
self.remove_perm(d1_common.const.SUBJECT_PUBLIC, 'read')
self.add_perm(d1_common.const.SUBJECT_AUTHENTICATED, 'read') | python | def add_authenticated_read(self):
"""Add ``read`` perm for all authenticated subj.
Public ``read`` is removed if present.
"""
self.remove_perm(d1_common.const.SUBJECT_PUBLIC, 'read')
self.add_perm(d1_common.const.SUBJECT_AUTHENTICATED, 'read') | [
"def",
"add_authenticated_read",
"(",
"self",
")",
":",
"self",
".",
"remove_perm",
"(",
"d1_common",
".",
"const",
".",
"SUBJECT_PUBLIC",
",",
"'read'",
")",
"self",
".",
"add_perm",
"(",
"d1_common",
".",
"const",
".",
"SUBJECT_AUTHENTICATED",
",",
"'read'",... | Add ``read`` perm for all authenticated subj.
Public ``read`` is removed if present. | [
"Add",
"read",
"perm",
"for",
"all",
"authenticated",
"subj",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L456-L463 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.add_verified_read | def add_verified_read(self):
"""Add ``read`` perm for all verified subj.
Public ``read`` is removed if present.
"""
self.remove_perm(d1_common.const.SUBJECT_PUBLIC, 'read')
self.add_perm(d1_common.const.SUBJECT_VERIFIED, 'read') | python | def add_verified_read(self):
"""Add ``read`` perm for all verified subj.
Public ``read`` is removed if present.
"""
self.remove_perm(d1_common.const.SUBJECT_PUBLIC, 'read')
self.add_perm(d1_common.const.SUBJECT_VERIFIED, 'read') | [
"def",
"add_verified_read",
"(",
"self",
")",
":",
"self",
".",
"remove_perm",
"(",
"d1_common",
".",
"const",
".",
"SUBJECT_PUBLIC",
",",
"'read'",
")",
"self",
".",
"add_perm",
"(",
"d1_common",
".",
"const",
".",
"SUBJECT_VERIFIED",
",",
"'read'",
")"
] | Add ``read`` perm for all verified subj.
Public ``read`` is removed if present. | [
"Add",
"read",
"perm",
"for",
"all",
"verified",
"subj",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L465-L472 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.add_perm | def add_perm(self, subj_str, perm_str):
"""Add a permission for a subject.
Args:
subj_str : str
Subject for which to add permission(s)
perm_str : str
Permission to add. Implicitly adds all lower permissions. E.g., ``write``
will also add ``read``... | python | def add_perm(self, subj_str, perm_str):
"""Add a permission for a subject.
Args:
subj_str : str
Subject for which to add permission(s)
perm_str : str
Permission to add. Implicitly adds all lower permissions. E.g., ``write``
will also add ``read``... | [
"def",
"add_perm",
"(",
"self",
",",
"subj_str",
",",
"perm_str",
")",
":",
"self",
".",
"_assert_valid_permission",
"(",
"perm_str",
")",
"self",
".",
"_perm_dict",
".",
"setdefault",
"(",
"perm_str",
",",
"set",
"(",
")",
")",
".",
"add",
"(",
"subj_st... | Add a permission for a subject.
Args:
subj_str : str
Subject for which to add permission(s)
perm_str : str
Permission to add. Implicitly adds all lower permissions. E.g., ``write``
will also add ``read``. | [
"Add",
"a",
"permission",
"for",
"a",
"subject",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L474-L487 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.remove_perm | def remove_perm(self, subj_str, perm_str):
"""Remove permission from a subject.
Args:
subj_str : str
Subject for which to remove permission(s)
perm_str : str
Permission to remove. Implicitly removes all higher permissions. E.g., ``write``
will al... | python | def remove_perm(self, subj_str, perm_str):
"""Remove permission from a subject.
Args:
subj_str : str
Subject for which to remove permission(s)
perm_str : str
Permission to remove. Implicitly removes all higher permissions. E.g., ``write``
will al... | [
"def",
"remove_perm",
"(",
"self",
",",
"subj_str",
",",
"perm_str",
")",
":",
"self",
".",
"_assert_valid_permission",
"(",
"perm_str",
")",
"for",
"perm_str",
"in",
"self",
".",
"_equal_or_higher_perm",
"(",
"perm_str",
")",
":",
"self",
".",
"_perm_dict",
... | Remove permission from a subject.
Args:
subj_str : str
Subject for which to remove permission(s)
perm_str : str
Permission to remove. Implicitly removes all higher permissions. E.g., ``write``
will also remove ``changePermission`` if previously granted. | [
"Remove",
"permission",
"from",
"a",
"subject",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L489-L503 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper.remove_subj | def remove_subj(self, subj_str):
"""Remove all permissions for subject.
Args:
subj_str : str
Subject for which to remove all permissions. Since subjects can only be present
in the AccessPolicy when they have one or more permissions, this removes the
subject... | python | def remove_subj(self, subj_str):
"""Remove all permissions for subject.
Args:
subj_str : str
Subject for which to remove all permissions. Since subjects can only be present
in the AccessPolicy when they have one or more permissions, this removes the
subject... | [
"def",
"remove_subj",
"(",
"self",
",",
"subj_str",
")",
":",
"for",
"subj_set",
"in",
"list",
"(",
"self",
".",
"_perm_dict",
".",
"values",
"(",
")",
")",
":",
"subj_set",
"-=",
"{",
"subj_str",
"}"
] | Remove all permissions for subject.
Args:
subj_str : str
Subject for which to remove all permissions. Since subjects can only be present
in the AccessPolicy when they have one or more permissions, this removes the
subject itself as well.
The subject ma... | [
"Remove",
"all",
"permissions",
"for",
"subject",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L505-L523 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._perm_dict_from_pyxb | def _perm_dict_from_pyxb(self, access_pyxb):
"""Return dict representation of AccessPolicy PyXB obj."""
subj_dict = self._subj_dict_from_pyxb(access_pyxb)
return self._perm_dict_from_subj_dict(subj_dict) | python | def _perm_dict_from_pyxb(self, access_pyxb):
"""Return dict representation of AccessPolicy PyXB obj."""
subj_dict = self._subj_dict_from_pyxb(access_pyxb)
return self._perm_dict_from_subj_dict(subj_dict) | [
"def",
"_perm_dict_from_pyxb",
"(",
"self",
",",
"access_pyxb",
")",
":",
"subj_dict",
"=",
"self",
".",
"_subj_dict_from_pyxb",
"(",
"access_pyxb",
")",
"return",
"self",
".",
"_perm_dict_from_subj_dict",
"(",
"subj_dict",
")"
] | Return dict representation of AccessPolicy PyXB obj. | [
"Return",
"dict",
"representation",
"of",
"AccessPolicy",
"PyXB",
"obj",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L529-L532 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._perm_dict_from_subj_dict | def _perm_dict_from_subj_dict(self, subj_dict):
"""Return dict where keys and values of ``subj_dict`` have been flipped
around."""
perm_dict = {}
for subj_str, perm_set in list(subj_dict.items()):
for perm_str in perm_set:
perm_dict.setdefault(perm_str, set())... | python | def _perm_dict_from_subj_dict(self, subj_dict):
"""Return dict where keys and values of ``subj_dict`` have been flipped
around."""
perm_dict = {}
for subj_str, perm_set in list(subj_dict.items()):
for perm_str in perm_set:
perm_dict.setdefault(perm_str, set())... | [
"def",
"_perm_dict_from_subj_dict",
"(",
"self",
",",
"subj_dict",
")",
":",
"perm_dict",
"=",
"{",
"}",
"for",
"subj_str",
",",
"perm_set",
"in",
"list",
"(",
"subj_dict",
".",
"items",
"(",
")",
")",
":",
"for",
"perm_str",
"in",
"perm_set",
":",
"perm... | Return dict where keys and values of ``subj_dict`` have been flipped
around. | [
"Return",
"dict",
"where",
"keys",
"and",
"values",
"of",
"subj_dict",
"have",
"been",
"flipped",
"around",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L534-L541 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._pyxb_from_perm_dict | def _pyxb_from_perm_dict(self, perm_dict):
"""Return an AccessPolicy PyXB representation of ``perm_dict``
- If ``norm_perm_list`` is empty, None is returned. The schema does not allow
AccessPolicy to be empty, but in SystemMetadata, it can be left out
altogether. So returning None inste... | python | def _pyxb_from_perm_dict(self, perm_dict):
"""Return an AccessPolicy PyXB representation of ``perm_dict``
- If ``norm_perm_list`` is empty, None is returned. The schema does not allow
AccessPolicy to be empty, but in SystemMetadata, it can be left out
altogether. So returning None inste... | [
"def",
"_pyxb_from_perm_dict",
"(",
"self",
",",
"perm_dict",
")",
":",
"norm_perm_list",
"=",
"self",
".",
"_norm_perm_list_from_perm_dict",
"(",
"perm_dict",
")",
"return",
"self",
".",
"_pyxb_from_norm_perm_list",
"(",
"norm_perm_list",
")"
] | Return an AccessPolicy PyXB representation of ``perm_dict``
- If ``norm_perm_list`` is empty, None is returned. The schema does not allow
AccessPolicy to be empty, but in SystemMetadata, it can be left out
altogether. So returning None instead of an empty AccessPolicy allows the
result ... | [
"Return",
"an",
"AccessPolicy",
"PyXB",
"representation",
"of",
"perm_dict"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L543-L553 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._pyxb_from_norm_perm_list | def _pyxb_from_norm_perm_list(self, norm_perm_list):
"""Return an AccessPolicy PyXB representation of ``norm_perm_list``"""
# Using accessPolicy() instead of AccessPolicy() and accessRule() instead of
# AccessRule() gives PyXB the type information required for using this as a
# root elem... | python | def _pyxb_from_norm_perm_list(self, norm_perm_list):
"""Return an AccessPolicy PyXB representation of ``norm_perm_list``"""
# Using accessPolicy() instead of AccessPolicy() and accessRule() instead of
# AccessRule() gives PyXB the type information required for using this as a
# root elem... | [
"def",
"_pyxb_from_norm_perm_list",
"(",
"self",
",",
"norm_perm_list",
")",
":",
"# Using accessPolicy() instead of AccessPolicy() and accessRule() instead of",
"# AccessRule() gives PyXB the type information required for using this as a",
"# root element.",
"access_pyxb",
"=",
"d1_common... | Return an AccessPolicy PyXB representation of ``norm_perm_list`` | [
"Return",
"an",
"AccessPolicy",
"PyXB",
"representation",
"of",
"norm_perm_list"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L555-L568 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._subj_dict_from_pyxb | def _subj_dict_from_pyxb(self, access_pyxb):
"""Return a dict representation of ``access_pyxb``, which is an AccessPolicy
PyXB object.
This also remove any duplicate subjects and permissions in the PyXB object.
"""
subj_dict = {}
for allow_pyxb in access_pyxb.allow:
... | python | def _subj_dict_from_pyxb(self, access_pyxb):
"""Return a dict representation of ``access_pyxb``, which is an AccessPolicy
PyXB object.
This also remove any duplicate subjects and permissions in the PyXB object.
"""
subj_dict = {}
for allow_pyxb in access_pyxb.allow:
... | [
"def",
"_subj_dict_from_pyxb",
"(",
"self",
",",
"access_pyxb",
")",
":",
"subj_dict",
"=",
"{",
"}",
"for",
"allow_pyxb",
"in",
"access_pyxb",
".",
"allow",
":",
"perm_set",
"=",
"set",
"(",
")",
"for",
"perm_pyxb",
"in",
"allow_pyxb",
".",
"permission",
... | Return a dict representation of ``access_pyxb``, which is an AccessPolicy
PyXB object.
This also remove any duplicate subjects and permissions in the PyXB object. | [
"Return",
"a",
"dict",
"representation",
"of",
"access_pyxb",
"which",
"is",
"an",
"AccessPolicy",
"PyXB",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L570-L584 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._highest_perm_dict_from_perm_dict | def _highest_perm_dict_from_perm_dict(self, perm_dict):
"""Return a perm_dict where only the highest permission for each subject is
included."""
highest_perm_dict = copy.copy(perm_dict)
for ordered_str in reversed(ORDERED_PERM_LIST):
for lower_perm in self._lower_perm_list(or... | python | def _highest_perm_dict_from_perm_dict(self, perm_dict):
"""Return a perm_dict where only the highest permission for each subject is
included."""
highest_perm_dict = copy.copy(perm_dict)
for ordered_str in reversed(ORDERED_PERM_LIST):
for lower_perm in self._lower_perm_list(or... | [
"def",
"_highest_perm_dict_from_perm_dict",
"(",
"self",
",",
"perm_dict",
")",
":",
"highest_perm_dict",
"=",
"copy",
".",
"copy",
"(",
"perm_dict",
")",
"for",
"ordered_str",
"in",
"reversed",
"(",
"ORDERED_PERM_LIST",
")",
":",
"for",
"lower_perm",
"in",
"sel... | Return a perm_dict where only the highest permission for each subject is
included. | [
"Return",
"a",
"perm_dict",
"where",
"only",
"the",
"highest",
"permission",
"for",
"each",
"subject",
"is",
"included",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L586-L594 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._norm_perm_list_from_perm_dict | def _norm_perm_list_from_perm_dict(self, perm_dict):
"""Return a minimal, ordered, hashable list of subjects and permissions."""
high_perm_dict = self._highest_perm_dict_from_perm_dict(perm_dict)
return [
[k, list(sorted(high_perm_dict[k]))]
for k in ORDERED_PERM_LIST
... | python | def _norm_perm_list_from_perm_dict(self, perm_dict):
"""Return a minimal, ordered, hashable list of subjects and permissions."""
high_perm_dict = self._highest_perm_dict_from_perm_dict(perm_dict)
return [
[k, list(sorted(high_perm_dict[k]))]
for k in ORDERED_PERM_LIST
... | [
"def",
"_norm_perm_list_from_perm_dict",
"(",
"self",
",",
"perm_dict",
")",
":",
"high_perm_dict",
"=",
"self",
".",
"_highest_perm_dict_from_perm_dict",
"(",
"perm_dict",
")",
"return",
"[",
"[",
"k",
",",
"list",
"(",
"sorted",
"(",
"high_perm_dict",
"[",
"k"... | Return a minimal, ordered, hashable list of subjects and permissions. | [
"Return",
"a",
"minimal",
"ordered",
"hashable",
"list",
"of",
"subjects",
"and",
"permissions",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L596-L603 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._effective_perm_list_from_iter | def _effective_perm_list_from_iter(self, perm_iter):
"""Return list of effective permissions for for highest permission in
``perm_iter``, ordered lower to higher, or None if ``perm_iter`` is empty."""
highest_perm_str = self._highest_perm_from_iter(perm_iter)
return (
self._e... | python | def _effective_perm_list_from_iter(self, perm_iter):
"""Return list of effective permissions for for highest permission in
``perm_iter``, ordered lower to higher, or None if ``perm_iter`` is empty."""
highest_perm_str = self._highest_perm_from_iter(perm_iter)
return (
self._e... | [
"def",
"_effective_perm_list_from_iter",
"(",
"self",
",",
"perm_iter",
")",
":",
"highest_perm_str",
"=",
"self",
".",
"_highest_perm_from_iter",
"(",
"perm_iter",
")",
"return",
"(",
"self",
".",
"_equal_or_lower_perm_list",
"(",
"highest_perm_str",
")",
"if",
"hi... | Return list of effective permissions for for highest permission in
``perm_iter``, ordered lower to higher, or None if ``perm_iter`` is empty. | [
"Return",
"list",
"of",
"effective",
"permissions",
"for",
"for",
"highest",
"permission",
"in",
"perm_iter",
"ordered",
"lower",
"to",
"higher",
"or",
"None",
"if",
"perm_iter",
"is",
"empty",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L605-L613 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._present_perm_set_for_subj | def _present_perm_set_for_subj(self, perm_dict, subj_str):
"""Return a set containing only the permissions that are present in the
``perm_dict`` for ``subj_str``"""
return {p for p, s in list(perm_dict.items()) if subj_str in s} | python | def _present_perm_set_for_subj(self, perm_dict, subj_str):
"""Return a set containing only the permissions that are present in the
``perm_dict`` for ``subj_str``"""
return {p for p, s in list(perm_dict.items()) if subj_str in s} | [
"def",
"_present_perm_set_for_subj",
"(",
"self",
",",
"perm_dict",
",",
"subj_str",
")",
":",
"return",
"{",
"p",
"for",
"p",
",",
"s",
"in",
"list",
"(",
"perm_dict",
".",
"items",
"(",
")",
")",
"if",
"subj_str",
"in",
"s",
"}"
] | Return a set containing only the permissions that are present in the
``perm_dict`` for ``subj_str`` | [
"Return",
"a",
"set",
"containing",
"only",
"the",
"permissions",
"that",
"are",
"present",
"in",
"the",
"perm_dict",
"for",
"subj_str"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L615-L618 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._highest_perm_from_iter | def _highest_perm_from_iter(self, perm_iter):
"""Return the highest perm present in ``perm_iter`` or None if ``perm_iter`` is
empty."""
perm_set = set(perm_iter)
for perm_str in reversed(ORDERED_PERM_LIST):
if perm_str in perm_set:
return perm_str | python | def _highest_perm_from_iter(self, perm_iter):
"""Return the highest perm present in ``perm_iter`` or None if ``perm_iter`` is
empty."""
perm_set = set(perm_iter)
for perm_str in reversed(ORDERED_PERM_LIST):
if perm_str in perm_set:
return perm_str | [
"def",
"_highest_perm_from_iter",
"(",
"self",
",",
"perm_iter",
")",
":",
"perm_set",
"=",
"set",
"(",
"perm_iter",
")",
"for",
"perm_str",
"in",
"reversed",
"(",
"ORDERED_PERM_LIST",
")",
":",
"if",
"perm_str",
"in",
"perm_set",
":",
"return",
"perm_str"
] | Return the highest perm present in ``perm_iter`` or None if ``perm_iter`` is
empty. | [
"Return",
"the",
"highest",
"perm",
"present",
"in",
"perm_iter",
"or",
"None",
"if",
"perm_iter",
"is",
"empty",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L620-L626 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._ordered_idx_from_perm | def _ordered_idx_from_perm(self, perm_str):
"""Return the ordered index of ``perm_str`` or None if ``perm_str`` is not a
valid permission."""
for i, ordered_str in enumerate(ORDERED_PERM_LIST):
if perm_str == ordered_str:
return i | python | def _ordered_idx_from_perm(self, perm_str):
"""Return the ordered index of ``perm_str`` or None if ``perm_str`` is not a
valid permission."""
for i, ordered_str in enumerate(ORDERED_PERM_LIST):
if perm_str == ordered_str:
return i | [
"def",
"_ordered_idx_from_perm",
"(",
"self",
",",
"perm_str",
")",
":",
"for",
"i",
",",
"ordered_str",
"in",
"enumerate",
"(",
"ORDERED_PERM_LIST",
")",
":",
"if",
"perm_str",
"==",
"ordered_str",
":",
"return",
"i"
] | Return the ordered index of ``perm_str`` or None if ``perm_str`` is not a
valid permission. | [
"Return",
"the",
"ordered",
"index",
"of",
"perm_str",
"or",
"None",
"if",
"perm_str",
"is",
"not",
"a",
"valid",
"permission",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L628-L633 |
DataONEorg/d1_python | lib_common/src/d1_common/wrap/access_policy.py | AccessPolicyWrapper._assert_valid_permission | def _assert_valid_permission(self, perm_str):
"""Raise D1 exception if ``perm_str`` is not a valid permission."""
if perm_str not in ORDERED_PERM_LIST:
raise d1_common.types.exceptions.InvalidRequest(
0,
'Permission must be one of {}. perm_str="{}"'.format(
... | python | def _assert_valid_permission(self, perm_str):
"""Raise D1 exception if ``perm_str`` is not a valid permission."""
if perm_str not in ORDERED_PERM_LIST:
raise d1_common.types.exceptions.InvalidRequest(
0,
'Permission must be one of {}. perm_str="{}"'.format(
... | [
"def",
"_assert_valid_permission",
"(",
"self",
",",
"perm_str",
")",
":",
"if",
"perm_str",
"not",
"in",
"ORDERED_PERM_LIST",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
".",
"InvalidRequest",
"(",
"0",
",",
"'Permission must be one of {}. perm_str=... | Raise D1 exception if ``perm_str`` is not a valid permission. | [
"Raise",
"D1",
"exception",
"if",
"perm_str",
"is",
"not",
"a",
"valid",
"permission",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/wrap/access_policy.py#L654-L662 |
DataONEorg/d1_python | client_cli/src/d1_cli/dataone.py | handle_unexpected_exception | def handle_unexpected_exception(max_traceback_levels=100):
"""Suppress stack traces for common errors and provide hints for how to resolve
them."""
exc_type, exc_msgs = sys.exc_info()[:2]
if exc_type.__name__ == "SSLError":
d1_cli.impl.util.print_error(
"""HTTPS / TLS / SSL / X.509v3... | python | def handle_unexpected_exception(max_traceback_levels=100):
"""Suppress stack traces for common errors and provide hints for how to resolve
them."""
exc_type, exc_msgs = sys.exc_info()[:2]
if exc_type.__name__ == "SSLError":
d1_cli.impl.util.print_error(
"""HTTPS / TLS / SSL / X.509v3... | [
"def",
"handle_unexpected_exception",
"(",
"max_traceback_levels",
"=",
"100",
")",
":",
"exc_type",
",",
"exc_msgs",
"=",
"sys",
".",
"exc_info",
"(",
")",
"[",
":",
"2",
"]",
"if",
"exc_type",
".",
"__name__",
"==",
"\"SSLError\"",
":",
"d1_cli",
".",
"i... | Suppress stack traces for common errors and provide hints for how to resolve
them. | [
"Suppress",
"stack",
"traces",
"for",
"common",
"errors",
"and",
"provide",
"hints",
"for",
"how",
"to",
"resolve",
"them",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/dataone.py#L430-L456 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/create.py | create_sciobj | def create_sciobj(request, sysmeta_pyxb):
"""Create object file and database entries for a new native locally stored (non-
proxied) science object.
This method takes a request object and is only called from the views that
handle:
- MNStorage.create()
- MNStorage.update()
Various sanity ch... | python | def create_sciobj(request, sysmeta_pyxb):
"""Create object file and database entries for a new native locally stored (non-
proxied) science object.
This method takes a request object and is only called from the views that
handle:
- MNStorage.create()
- MNStorage.update()
Various sanity ch... | [
"def",
"create_sciobj",
"(",
"request",
",",
"sysmeta_pyxb",
")",
":",
"pid",
"=",
"d1_common",
".",
"xml",
".",
"get_req_val",
"(",
"sysmeta_pyxb",
".",
"identifier",
")",
"set_mn_controlled_values",
"(",
"request",
",",
"sysmeta_pyxb",
",",
"is_modification",
... | Create object file and database entries for a new native locally stored (non-
proxied) science object.
This method takes a request object and is only called from the views that
handle:
- MNStorage.create()
- MNStorage.update()
Various sanity checking is performed. Raises D1 exceptions that ar... | [
"Create",
"object",
"file",
"and",
"database",
"entries",
"for",
"a",
"new",
"native",
"locally",
"stored",
"(",
"non",
"-",
"proxied",
")",
"science",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/create.py#L35-L83 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/create.py | _save_sciobj_bytes_from_request | def _save_sciobj_bytes_from_request(request, pid):
"""Django stores small uploads in memory and streams large uploads directly to disk.
Uploads stored in memory are represented by UploadedFile and on disk,
TemporaryUploadedFile. To store an UploadedFile on disk, it's iterated and saved in
chunks. To st... | python | def _save_sciobj_bytes_from_request(request, pid):
"""Django stores small uploads in memory and streams large uploads directly to disk.
Uploads stored in memory are represented by UploadedFile and on disk,
TemporaryUploadedFile. To store an UploadedFile on disk, it's iterated and saved in
chunks. To st... | [
"def",
"_save_sciobj_bytes_from_request",
"(",
"request",
",",
"pid",
")",
":",
"sciobj_path",
"=",
"d1_gmn",
".",
"app",
".",
"sciobj_store",
".",
"get_abs_sciobj_file_path_by_pid",
"(",
"pid",
")",
"if",
"hasattr",
"(",
"request",
".",
"FILES",
"[",
"'object'"... | Django stores small uploads in memory and streams large uploads directly to disk.
Uploads stored in memory are represented by UploadedFile and on disk,
TemporaryUploadedFile. To store an UploadedFile on disk, it's iterated and saved in
chunks. To store a TemporaryUploadedFile, it's moved from the temporary... | [
"Django",
"stores",
"small",
"uploads",
"in",
"memory",
"and",
"streams",
"large",
"uploads",
"directly",
"to",
"disk",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/create.py#L119-L140 |
DataONEorg/d1_python | gmn/src/d1_gmn/app/views/create.py | set_mn_controlled_values | def set_mn_controlled_values(request, sysmeta_pyxb, is_modification):
"""See the description of TRUST_CLIENT_* in settings.py."""
now_datetime = d1_common.date_time.utc_now()
default_value_list = [
('originMemberNode', django.conf.settings.NODE_IDENTIFIER, True),
('authoritativeMemberNode',... | python | def set_mn_controlled_values(request, sysmeta_pyxb, is_modification):
"""See the description of TRUST_CLIENT_* in settings.py."""
now_datetime = d1_common.date_time.utc_now()
default_value_list = [
('originMemberNode', django.conf.settings.NODE_IDENTIFIER, True),
('authoritativeMemberNode',... | [
"def",
"set_mn_controlled_values",
"(",
"request",
",",
"sysmeta_pyxb",
",",
"is_modification",
")",
":",
"now_datetime",
"=",
"d1_common",
".",
"date_time",
".",
"utc_now",
"(",
")",
"default_value_list",
"=",
"[",
"(",
"'originMemberNode'",
",",
"django",
".",
... | See the description of TRUST_CLIENT_* in settings.py. | [
"See",
"the",
"description",
"of",
"TRUST_CLIENT_",
"*",
"in",
"settings",
".",
"py",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/create.py#L143-L176 |
genialis/resolwe | resolwe/flow/models/entity.py | EntityQuerySet.duplicate | def duplicate(self, contributor=None, inherit_collections=False):
"""Duplicate (make a copy) ``Entity`` objects.
:param contributor: Duplication user
:param inherit_collections: If ``True`` then duplicated
entities will be added to collections the original entity
is part... | python | def duplicate(self, contributor=None, inherit_collections=False):
"""Duplicate (make a copy) ``Entity`` objects.
:param contributor: Duplication user
:param inherit_collections: If ``True`` then duplicated
entities will be added to collections the original entity
is part... | [
"def",
"duplicate",
"(",
"self",
",",
"contributor",
"=",
"None",
",",
"inherit_collections",
"=",
"False",
")",
":",
"return",
"[",
"entity",
".",
"duplicate",
"(",
"contributor",
",",
"inherit_collections",
")",
"for",
"entity",
"in",
"self",
"]"
] | Duplicate (make a copy) ``Entity`` objects.
:param contributor: Duplication user
:param inherit_collections: If ``True`` then duplicated
entities will be added to collections the original entity
is part of. Duplicated entities' data objects will also be
added to the ... | [
"Duplicate",
"(",
"make",
"a",
"copy",
")",
"Entity",
"objects",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/entity.py#L17-L31 |
genialis/resolwe | resolwe/flow/models/entity.py | EntityQuerySet.move_to_collection | def move_to_collection(self, source_collection, destination_collection):
"""Move entities from source to destination collection."""
for entity in self:
entity.move_to_collection(source_collection, destination_collection) | python | def move_to_collection(self, source_collection, destination_collection):
"""Move entities from source to destination collection."""
for entity in self:
entity.move_to_collection(source_collection, destination_collection) | [
"def",
"move_to_collection",
"(",
"self",
",",
"source_collection",
",",
"destination_collection",
")",
":",
"for",
"entity",
"in",
"self",
":",
"entity",
".",
"move_to_collection",
"(",
"source_collection",
",",
"destination_collection",
")"
] | Move entities from source to destination collection. | [
"Move",
"entities",
"from",
"source",
"to",
"destination",
"collection",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/entity.py#L34-L37 |
genialis/resolwe | resolwe/flow/models/entity.py | Entity.duplicate | def duplicate(self, contributor=None, inherit_collections=False):
"""Duplicate (make a copy)."""
duplicate = Entity.objects.get(id=self.id)
duplicate.pk = None
duplicate.slug = None
duplicate.name = 'Copy of {}'.format(self.name)
duplicate.duplicated = now()
if co... | python | def duplicate(self, contributor=None, inherit_collections=False):
"""Duplicate (make a copy)."""
duplicate = Entity.objects.get(id=self.id)
duplicate.pk = None
duplicate.slug = None
duplicate.name = 'Copy of {}'.format(self.name)
duplicate.duplicated = now()
if co... | [
"def",
"duplicate",
"(",
"self",
",",
"contributor",
"=",
"None",
",",
"inherit_collections",
"=",
"False",
")",
":",
"duplicate",
"=",
"Entity",
".",
"objects",
".",
"get",
"(",
"id",
"=",
"self",
".",
"id",
")",
"duplicate",
".",
"pk",
"=",
"None",
... | Duplicate (make a copy). | [
"Duplicate",
"(",
"make",
"a",
"copy",
")",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/entity.py#L74-L110 |
genialis/resolwe | resolwe/flow/models/entity.py | Entity.move_to_collection | def move_to_collection(self, source_collection, destination_collection):
"""Move entity from source to destination collection."""
# Remove from collection.
self.collections.remove(source_collection) # pylint: disable=no-member
source_collection.data.remove(*self.data.all()) # pylint: d... | python | def move_to_collection(self, source_collection, destination_collection):
"""Move entity from source to destination collection."""
# Remove from collection.
self.collections.remove(source_collection) # pylint: disable=no-member
source_collection.data.remove(*self.data.all()) # pylint: d... | [
"def",
"move_to_collection",
"(",
"self",
",",
"source_collection",
",",
"destination_collection",
")",
":",
"# Remove from collection.",
"self",
".",
"collections",
".",
"remove",
"(",
"source_collection",
")",
"# pylint: disable=no-member",
"source_collection",
".",
"da... | Move entity from source to destination collection. | [
"Move",
"entity",
"from",
"source",
"to",
"destination",
"collection",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/entity.py#L112-L120 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/os_escape.py | unquote | def unquote(s):
"""unquote('abc%20def') -> 'abc def'."""
res = s.split('%')
# fastpath
if len(res) == 1:
return s
s = res[0]
for item in res[1:]:
try:
s += _hextochr[item[:2]] + item[2:]
except KeyError:
s += '%' + item
except UnicodeDecode... | python | def unquote(s):
"""unquote('abc%20def') -> 'abc def'."""
res = s.split('%')
# fastpath
if len(res) == 1:
return s
s = res[0]
for item in res[1:]:
try:
s += _hextochr[item[:2]] + item[2:]
except KeyError:
s += '%' + item
except UnicodeDecode... | [
"def",
"unquote",
"(",
"s",
")",
":",
"res",
"=",
"s",
".",
"split",
"(",
"'%'",
")",
"# fastpath",
"if",
"len",
"(",
"res",
")",
"==",
"1",
":",
"return",
"s",
"s",
"=",
"res",
"[",
"0",
"]",
"for",
"item",
"in",
"res",
"[",
"1",
":",
"]",... | unquote('abc%20def') -> 'abc def'. | [
"unquote",
"(",
"abc%20def",
")",
"-",
">",
"abc",
"def",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/os_escape.py#L61-L75 |
DataONEorg/d1_python | client_onedrive/src/d1_onedrive/impl/os_escape.py | quote | def quote(s, unsafe='/'):
"""Pass in a dictionary that has unsafe characters as the keys, and the percent
encoded value as the value."""
res = s.replace('%', '%25')
for c in unsafe:
res = res.replace(c, '%' + (hex(ord(c)).upper())[2:])
return res | python | def quote(s, unsafe='/'):
"""Pass in a dictionary that has unsafe characters as the keys, and the percent
encoded value as the value."""
res = s.replace('%', '%25')
for c in unsafe:
res = res.replace(c, '%' + (hex(ord(c)).upper())[2:])
return res | [
"def",
"quote",
"(",
"s",
",",
"unsafe",
"=",
"'/'",
")",
":",
"res",
"=",
"s",
".",
"replace",
"(",
"'%'",
",",
"'%25'",
")",
"for",
"c",
"in",
"unsafe",
":",
"res",
"=",
"res",
".",
"replace",
"(",
"c",
",",
"'%'",
"+",
"(",
"hex",
"(",
"... | Pass in a dictionary that has unsafe characters as the keys, and the percent
encoded value as the value. | [
"Pass",
"in",
"a",
"dictionary",
"that",
"has",
"unsafe",
"characters",
"as",
"the",
"keys",
"and",
"the",
"percent",
"encoded",
"value",
"as",
"the",
"value",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_onedrive/src/d1_onedrive/impl/os_escape.py#L78-L84 |
genialis/resolwe | resolwe/flow/elastic_indexes/data.py | DataIndex.get_dependencies | def get_dependencies(self):
"""Return dependencies, which should trigger updates of this model."""
# pylint: disable=no-member
return super().get_dependencies() + [
Data.collection_set,
Data.entity_set,
Data.parents,
] | python | def get_dependencies(self):
"""Return dependencies, which should trigger updates of this model."""
# pylint: disable=no-member
return super().get_dependencies() + [
Data.collection_set,
Data.entity_set,
Data.parents,
] | [
"def",
"get_dependencies",
"(",
"self",
")",
":",
"# pylint: disable=no-member",
"return",
"super",
"(",
")",
".",
"get_dependencies",
"(",
")",
"+",
"[",
"Data",
".",
"collection_set",
",",
"Data",
".",
"entity_set",
",",
"Data",
".",
"parents",
",",
"]"
] | Return dependencies, which should trigger updates of this model. | [
"Return",
"dependencies",
"which",
"should",
"trigger",
"updates",
"of",
"this",
"model",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/elastic_indexes/data.py#L52-L59 |
wilson-eft/wilson | wilson/util/qcd.py | alpha_s | def alpha_s(scale, f, alphasMZ=0.1185, loop=3):
"""3-loop computation of alpha_s for f flavours
with initial condition alpha_s(MZ) = 0.1185"""
if scale == MZ and f == 5:
return alphasMZ # nothing to do
_sane(scale, f)
crd = rundec.CRunDec()
if f == 5:
return_value = crd.AlphasEx... | python | def alpha_s(scale, f, alphasMZ=0.1185, loop=3):
"""3-loop computation of alpha_s for f flavours
with initial condition alpha_s(MZ) = 0.1185"""
if scale == MZ and f == 5:
return alphasMZ # nothing to do
_sane(scale, f)
crd = rundec.CRunDec()
if f == 5:
return_value = crd.AlphasEx... | [
"def",
"alpha_s",
"(",
"scale",
",",
"f",
",",
"alphasMZ",
"=",
"0.1185",
",",
"loop",
"=",
"3",
")",
":",
"if",
"scale",
"==",
"MZ",
"and",
"f",
"==",
"5",
":",
"return",
"alphasMZ",
"# nothing to do",
"_sane",
"(",
"scale",
",",
"f",
")",
"crd",
... | 3-loop computation of alpha_s for f flavours
with initial condition alpha_s(MZ) = 0.1185 | [
"3",
"-",
"loop",
"computation",
"of",
"alpha_s",
"for",
"f",
"flavours",
"with",
"initial",
"condition",
"alpha_s",
"(",
"MZ",
")",
"=",
"0",
".",
"1185"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/qcd.py#L20-L54 |
wilson-eft/wilson | wilson/util/qcd.py | m_b | def m_b(mbmb, scale, f, alphasMZ=0.1185, loop=3):
r"""Get running b quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_b(m_b)$"""
if scale == mbmb and f == 5:
return mbmb # nothing to do
_sane(scale, f)
alphas_mb = alpha_s(mb... | python | def m_b(mbmb, scale, f, alphasMZ=0.1185, loop=3):
r"""Get running b quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_b(m_b)$"""
if scale == mbmb and f == 5:
return mbmb # nothing to do
_sane(scale, f)
alphas_mb = alpha_s(mb... | [
"def",
"m_b",
"(",
"mbmb",
",",
"scale",
",",
"f",
",",
"alphasMZ",
"=",
"0.1185",
",",
"loop",
"=",
"3",
")",
":",
"if",
"scale",
"==",
"mbmb",
"and",
"f",
"==",
"5",
":",
"return",
"mbmb",
"# nothing to do",
"_sane",
"(",
"scale",
",",
"f",
")"... | r"""Get running b quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_b(m_b)$ | [
"r",
"Get",
"running",
"b",
"quark",
"mass",
"in",
"the",
"MSbar",
"scheme",
"at",
"the",
"scale",
"scale",
"in",
"the",
"theory",
"with",
"f",
"dynamical",
"quark",
"flavours",
"starting",
"from",
"$m_b",
"(",
"m_b",
")",
"$"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/qcd.py#L58-L91 |
wilson-eft/wilson | wilson/util/qcd.py | m_c | def m_c(mcmc, scale, f, alphasMZ=0.1185, loop=3):
r"""Get running c quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_c(m_c)$"""
if scale == mcmc:
return mcmc # nothing to do
_sane(scale, f)
crd = rundec.CRunDec()
alphas... | python | def m_c(mcmc, scale, f, alphasMZ=0.1185, loop=3):
r"""Get running c quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_c(m_c)$"""
if scale == mcmc:
return mcmc # nothing to do
_sane(scale, f)
crd = rundec.CRunDec()
alphas... | [
"def",
"m_c",
"(",
"mcmc",
",",
"scale",
",",
"f",
",",
"alphasMZ",
"=",
"0.1185",
",",
"loop",
"=",
"3",
")",
":",
"if",
"scale",
"==",
"mcmc",
":",
"return",
"mcmc",
"# nothing to do",
"_sane",
"(",
"scale",
",",
"f",
")",
"crd",
"=",
"rundec",
... | r"""Get running c quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_c(m_c)$ | [
"r",
"Get",
"running",
"c",
"quark",
"mass",
"in",
"the",
"MSbar",
"scheme",
"at",
"the",
"scale",
"scale",
"in",
"the",
"theory",
"with",
"f",
"dynamical",
"quark",
"flavours",
"starting",
"from",
"$m_c",
"(",
"m_c",
")",
"$"
] | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/qcd.py#L95-L117 |
wilson-eft/wilson | wilson/util/qcd.py | m_s | def m_s(ms2, scale, f, alphasMZ=0.1185, loop=3):
r"""Get running s quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_s(2 \,\text{GeV})$"""
if scale == 2 and f == 3:
return ms2 # nothing to do
_sane(scale, f)
crd = rundec.CRu... | python | def m_s(ms2, scale, f, alphasMZ=0.1185, loop=3):
r"""Get running s quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_s(2 \,\text{GeV})$"""
if scale == 2 and f == 3:
return ms2 # nothing to do
_sane(scale, f)
crd = rundec.CRu... | [
"def",
"m_s",
"(",
"ms2",
",",
"scale",
",",
"f",
",",
"alphasMZ",
"=",
"0.1185",
",",
"loop",
"=",
"3",
")",
":",
"if",
"scale",
"==",
"2",
"and",
"f",
"==",
"3",
":",
"return",
"ms2",
"# nothing to do",
"_sane",
"(",
"scale",
",",
"f",
")",
"... | r"""Get running s quark mass in the MSbar scheme at the scale `scale`
in the theory with `f` dynamical quark flavours starting from $m_s(2 \,\text{GeV})$ | [
"r",
"Get",
"running",
"s",
"quark",
"mass",
"in",
"the",
"MSbar",
"scheme",
"at",
"the",
"scale",
"scale",
"in",
"the",
"theory",
"with",
"f",
"dynamical",
"quark",
"flavours",
"starting",
"from",
"$m_s",
"(",
"2",
"\\",
"\\",
"text",
"{",
"GeV",
"}",... | train | https://github.com/wilson-eft/wilson/blob/4164f55ff663d4f668c6e2b4575fd41562662cc9/wilson/util/qcd.py#L121-L149 |
genialis/resolwe | resolwe/flow/management/commands/collecttools.py | Command.get_confirmation | def get_confirmation(self):
"""Get user confirmation to proceed."""
if self.clear:
action = 'This will DELETE ALL FILES in this location!'
else:
action = 'This will overwrite existing files!'
message = (
"\n"
"You have requested to collect... | python | def get_confirmation(self):
"""Get user confirmation to proceed."""
if self.clear:
action = 'This will DELETE ALL FILES in this location!'
else:
action = 'This will overwrite existing files!'
message = (
"\n"
"You have requested to collect... | [
"def",
"get_confirmation",
"(",
"self",
")",
":",
"if",
"self",
".",
"clear",
":",
"action",
"=",
"'This will DELETE ALL FILES in this location!'",
"else",
":",
"action",
"=",
"'This will overwrite existing files!'",
"message",
"=",
"(",
"\"\\n\"",
"\"You have requested... | Get user confirmation to proceed. | [
"Get",
"user",
"confirmation",
"to",
"proceed",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/management/commands/collecttools.py#L50-L74 |
genialis/resolwe | resolwe/flow/management/commands/collecttools.py | Command.clear_dir | def clear_dir(self):
"""Delete contents of the directory on the given path."""
self.stdout.write("Deleting contents of '{}'.".format(self.destination_path))
for filename in os.listdir(self.destination_path):
if os.path.isfile(filename) or os.path.islink(filename):
os... | python | def clear_dir(self):
"""Delete contents of the directory on the given path."""
self.stdout.write("Deleting contents of '{}'.".format(self.destination_path))
for filename in os.listdir(self.destination_path):
if os.path.isfile(filename) or os.path.islink(filename):
os... | [
"def",
"clear_dir",
"(",
"self",
")",
":",
"self",
".",
"stdout",
".",
"write",
"(",
"\"Deleting contents of '{}'.\"",
".",
"format",
"(",
"self",
".",
"destination_path",
")",
")",
"for",
"filename",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"destinat... | Delete contents of the directory on the given path. | [
"Delete",
"contents",
"of",
"the",
"directory",
"on",
"the",
"given",
"path",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/management/commands/collecttools.py#L76-L84 |
genialis/resolwe | resolwe/flow/management/commands/collecttools.py | Command.change_path_prefix | def change_path_prefix(self, path, old_prefix, new_prefix, app_name):
"""Change path prefix and include app name."""
relative_path = os.path.relpath(path, old_prefix)
return os.path.join(new_prefix, app_name, relative_path) | python | def change_path_prefix(self, path, old_prefix, new_prefix, app_name):
"""Change path prefix and include app name."""
relative_path = os.path.relpath(path, old_prefix)
return os.path.join(new_prefix, app_name, relative_path) | [
"def",
"change_path_prefix",
"(",
"self",
",",
"path",
",",
"old_prefix",
",",
"new_prefix",
",",
"app_name",
")",
":",
"relative_path",
"=",
"os",
".",
"path",
".",
"relpath",
"(",
"path",
",",
"old_prefix",
")",
"return",
"os",
".",
"path",
".",
"join"... | Change path prefix and include app name. | [
"Change",
"path",
"prefix",
"and",
"include",
"app",
"name",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/management/commands/collecttools.py#L86-L89 |
genialis/resolwe | resolwe/flow/management/commands/collecttools.py | Command.collect | def collect(self):
"""Get tools' locations and copy them to a single location."""
for app_name, tools_path in get_apps_tools().items():
self.stdout.write("Copying files from '{}'.".format(tools_path))
app_name = app_name.replace('.', '_')
app_destination_path = os.p... | python | def collect(self):
"""Get tools' locations and copy them to a single location."""
for app_name, tools_path in get_apps_tools().items():
self.stdout.write("Copying files from '{}'.".format(tools_path))
app_name = app_name.replace('.', '_')
app_destination_path = os.p... | [
"def",
"collect",
"(",
"self",
")",
":",
"for",
"app_name",
",",
"tools_path",
"in",
"get_apps_tools",
"(",
")",
".",
"items",
"(",
")",
":",
"self",
".",
"stdout",
".",
"write",
"(",
"\"Copying files from '{}'.\"",
".",
"format",
"(",
"tools_path",
")",
... | Get tools' locations and copy them to a single location. | [
"Get",
"tools",
"locations",
"and",
"copy",
"them",
"to",
"a",
"single",
"location",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/management/commands/collecttools.py#L91-L118 |
genialis/resolwe | resolwe/flow/management/commands/collecttools.py | Command.handle | def handle(self, **options):
"""Collect tools."""
self.set_options(**options)
os.makedirs(self.destination_path, exist_ok=True)
if self.interactive and any(os.listdir(self.destination_path)):
self.get_confirmation()
if self.clear:
self.clear_dir()
... | python | def handle(self, **options):
"""Collect tools."""
self.set_options(**options)
os.makedirs(self.destination_path, exist_ok=True)
if self.interactive and any(os.listdir(self.destination_path)):
self.get_confirmation()
if self.clear:
self.clear_dir()
... | [
"def",
"handle",
"(",
"self",
",",
"*",
"*",
"options",
")",
":",
"self",
".",
"set_options",
"(",
"*",
"*",
"options",
")",
"os",
".",
"makedirs",
"(",
"self",
".",
"destination_path",
",",
"exist_ok",
"=",
"True",
")",
"if",
"self",
".",
"interacti... | Collect tools. | [
"Collect",
"tools",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/management/commands/collecttools.py#L120-L132 |
genialis/resolwe | resolwe/flow/utils/__init__.py | get_data_checksum | def get_data_checksum(proc_input, proc_slug, proc_version):
"""Compute checksum of processor inputs, name and version."""
checksum = hashlib.sha256()
checksum.update(json.dumps(proc_input, sort_keys=True).encode('utf-8'))
checksum.update(proc_slug.encode('utf-8'))
checksum.update(str(proc_version).e... | python | def get_data_checksum(proc_input, proc_slug, proc_version):
"""Compute checksum of processor inputs, name and version."""
checksum = hashlib.sha256()
checksum.update(json.dumps(proc_input, sort_keys=True).encode('utf-8'))
checksum.update(proc_slug.encode('utf-8'))
checksum.update(str(proc_version).e... | [
"def",
"get_data_checksum",
"(",
"proc_input",
",",
"proc_slug",
",",
"proc_version",
")",
":",
"checksum",
"=",
"hashlib",
".",
"sha256",
"(",
")",
"checksum",
".",
"update",
"(",
"json",
".",
"dumps",
"(",
"proc_input",
",",
"sort_keys",
"=",
"True",
")"... | Compute checksum of processor inputs, name and version. | [
"Compute",
"checksum",
"of",
"processor",
"inputs",
"name",
"and",
"version",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/__init__.py#L29-L35 |
genialis/resolwe | resolwe/flow/utils/__init__.py | dict_dot | def dict_dot(d, k, val=None, default=None):
"""Get or set value using a dot-notation key in a multilevel dict."""
if val is None and k == '':
return d
def set_default(dict_or_model, key, default_value):
"""Set default field value."""
if isinstance(dict_or_model, models.Model):
... | python | def dict_dot(d, k, val=None, default=None):
"""Get or set value using a dot-notation key in a multilevel dict."""
if val is None and k == '':
return d
def set_default(dict_or_model, key, default_value):
"""Set default field value."""
if isinstance(dict_or_model, models.Model):
... | [
"def",
"dict_dot",
"(",
"d",
",",
"k",
",",
"val",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"val",
"is",
"None",
"and",
"k",
"==",
"''",
":",
"return",
"d",
"def",
"set_default",
"(",
"dict_or_model",
",",
"key",
",",
"default_valu... | Get or set value using a dot-notation key in a multilevel dict. | [
"Get",
"or",
"set",
"value",
"using",
"a",
"dot",
"-",
"notation",
"key",
"in",
"a",
"multilevel",
"dict",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/__init__.py#L38-L82 |
genialis/resolwe | resolwe/flow/utils/__init__.py | get_apps_tools | def get_apps_tools():
"""Get applications' tools and their paths.
Return a dict with application names as keys and paths to tools'
directories as values. Applications without tools are omitted.
"""
tools_paths = {}
for app_config in apps.get_app_configs():
proc_path = os.path.join(app_... | python | def get_apps_tools():
"""Get applications' tools and their paths.
Return a dict with application names as keys and paths to tools'
directories as values. Applications without tools are omitted.
"""
tools_paths = {}
for app_config in apps.get_app_configs():
proc_path = os.path.join(app_... | [
"def",
"get_apps_tools",
"(",
")",
":",
"tools_paths",
"=",
"{",
"}",
"for",
"app_config",
"in",
"apps",
".",
"get_app_configs",
"(",
")",
":",
"proc_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"app_config",
".",
"path",
",",
"'tools'",
")",
"if",... | Get applications' tools and their paths.
Return a dict with application names as keys and paths to tools'
directories as values. Applications without tools are omitted. | [
"Get",
"applications",
"tools",
"and",
"their",
"paths",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/__init__.py#L85-L106 |
genialis/resolwe | resolwe/flow/utils/__init__.py | rewire_inputs | def rewire_inputs(data_list):
"""Rewire inputs of provided data objects.
Input parameter is a list of original and copied data object model
instances: ``[{'original': original, 'copy': copy}]``. This
function finds which objects reference other objects (in the list)
on the input and replaces origin... | python | def rewire_inputs(data_list):
"""Rewire inputs of provided data objects.
Input parameter is a list of original and copied data object model
instances: ``[{'original': original, 'copy': copy}]``. This
function finds which objects reference other objects (in the list)
on the input and replaces origin... | [
"def",
"rewire_inputs",
"(",
"data_list",
")",
":",
"if",
"len",
"(",
"data_list",
")",
"<",
"2",
":",
"return",
"data_list",
"mapped_ids",
"=",
"{",
"bundle",
"[",
"'original'",
"]",
".",
"id",
":",
"bundle",
"[",
"'copy'",
"]",
".",
"id",
"for",
"b... | Rewire inputs of provided data objects.
Input parameter is a list of original and copied data object model
instances: ``[{'original': original, 'copy': copy}]``. This
function finds which objects reference other objects (in the list)
on the input and replaces original objects with the copies (mutates
... | [
"Rewire",
"inputs",
"of",
"provided",
"data",
"objects",
"."
] | train | https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/__init__.py#L109-L143 |
DataONEorg/d1_python | lib_common/src/d1_common/types/generated/dataoneTypes_v1.py | CreateFromDocument | def CreateFromDocument(xml_text, default_namespace=None, location_base=None):
"""Parse the given XML and use the document element to create a Python instance.
@param xml_text An XML document. This should be data (Python 2
str or Python 3 bytes), or a text (Python 2 unicode or Python 3
str) in the L{py... | python | def CreateFromDocument(xml_text, default_namespace=None, location_base=None):
"""Parse the given XML and use the document element to create a Python instance.
@param xml_text An XML document. This should be data (Python 2
str or Python 3 bytes), or a text (Python 2 unicode or Python 3
str) in the L{py... | [
"def",
"CreateFromDocument",
"(",
"xml_text",
",",
"default_namespace",
"=",
"None",
",",
"location_base",
"=",
"None",
")",
":",
"if",
"pyxb",
".",
"XMLStyle_saxer",
"!=",
"pyxb",
".",
"_XMLStyle",
":",
"dom",
"=",
"pyxb",
".",
"utils",
".",
"domutils",
"... | Parse the given XML and use the document element to create a Python instance.
@param xml_text An XML document. This should be data (Python 2
str or Python 3 bytes), or a text (Python 2 unicode or Python 3
str) in the L{pyxb._InputEncoding} encoding.
@keyword default_namespace The L{pyxb.Namespace} in... | [
"Parse",
"the",
"given",
"XML",
"and",
"use",
"the",
"document",
"element",
"to",
"create",
"a",
"Python",
"instance",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/generated/dataoneTypes_v1.py#L42-L75 |
DataONEorg/d1_python | lib_common/src/d1_common/types/generated/dataoneTypes_v1.py | CreateFromDOM | def CreateFromDOM(node, default_namespace=None):
"""Create a Python instance from the given DOM node. The node tag must correspond to
an element declaration in this module.
@deprecated: Forcing use of DOM interface is unnecessary; use L{CreateFromDocument}.
"""
if default_namespace is None:
... | python | def CreateFromDOM(node, default_namespace=None):
"""Create a Python instance from the given DOM node. The node tag must correspond to
an element declaration in this module.
@deprecated: Forcing use of DOM interface is unnecessary; use L{CreateFromDocument}.
"""
if default_namespace is None:
... | [
"def",
"CreateFromDOM",
"(",
"node",
",",
"default_namespace",
"=",
"None",
")",
":",
"if",
"default_namespace",
"is",
"None",
":",
"default_namespace",
"=",
"Namespace",
".",
"fallbackNamespace",
"(",
")",
"return",
"pyxb",
".",
"binding",
".",
"basis",
".",
... | Create a Python instance from the given DOM node. The node tag must correspond to
an element declaration in this module.
@deprecated: Forcing use of DOM interface is unnecessary; use L{CreateFromDocument}. | [
"Create",
"a",
"Python",
"instance",
"from",
"the",
"given",
"DOM",
"node",
".",
"The",
"node",
"tag",
"must",
"correspond",
"to",
"an",
"element",
"declaration",
"in",
"this",
"module",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/types/generated/dataoneTypes_v1.py#L78-L87 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.postloop | def postloop(self):
"""Take care of any unfinished business.
Despite the claims in the Cmd documentation, Cmd.postloop() is not a stub.
"""
cmd.Cmd.postloop(self) # Clean up command completion
d1_cli.impl.util.print_info("Exiting...") | python | def postloop(self):
"""Take care of any unfinished business.
Despite the claims in the Cmd documentation, Cmd.postloop() is not a stub.
"""
cmd.Cmd.postloop(self) # Clean up command completion
d1_cli.impl.util.print_info("Exiting...") | [
"def",
"postloop",
"(",
"self",
")",
":",
"cmd",
".",
"Cmd",
".",
"postloop",
"(",
"self",
")",
"# Clean up command completion",
"d1_cli",
".",
"impl",
".",
"util",
".",
"print_info",
"(",
"\"Exiting...\"",
")"
] | Take care of any unfinished business.
Despite the claims in the Cmd documentation, Cmd.postloop() is not a stub. | [
"Take",
"care",
"of",
"any",
"unfinished",
"business",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L60-L67 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.precmd | def precmd(self, line):
"""This method is called after the line has been input but before it has been
interpreted.
If you want to modify the input line before execution (for example, variable
substitution) do it here.
"""
line = self.prefix + line
self._history ... | python | def precmd(self, line):
"""This method is called after the line has been input but before it has been
interpreted.
If you want to modify the input line before execution (for example, variable
substitution) do it here.
"""
line = self.prefix + line
self._history ... | [
"def",
"precmd",
"(",
"self",
",",
"line",
")",
":",
"line",
"=",
"self",
".",
"prefix",
"+",
"line",
"self",
".",
"_history",
"+=",
"[",
"line",
".",
"strip",
"(",
")",
"]",
"return",
"line"
] | This method is called after the line has been input but before it has been
interpreted.
If you want to modify the input line before execution (for example, variable
substitution) do it here. | [
"This",
"method",
"is",
"called",
"after",
"the",
"line",
"has",
"been",
"input",
"but",
"before",
"it",
"has",
"been",
"interpreted",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L69-L79 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.default | def default(self, line):
"""Called on an input line when the command prefix is not recognized."""
args = self._split_args(line, 0, 99)
d1_cli.impl.util.print_error("Unknown command: {}".format(args[0])) | python | def default(self, line):
"""Called on an input line when the command prefix is not recognized."""
args = self._split_args(line, 0, 99)
d1_cli.impl.util.print_error("Unknown command: {}".format(args[0])) | [
"def",
"default",
"(",
"self",
",",
"line",
")",
":",
"args",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"99",
")",
"d1_cli",
".",
"impl",
".",
"util",
".",
"print_error",
"(",
"\"Unknown command: {}\"",
".",
"format",
"(",
"args",
... | Called on an input line when the command prefix is not recognized. | [
"Called",
"on",
"an",
"input",
"line",
"when",
"the",
"command",
"prefix",
"is",
"not",
"recognized",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L93-L96 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_help | def do_help(self, line):
"""Get help on commands "help" or "?" with no arguments displays a list_objects
of commands for which help is available "help <command>" or "?
<command>" gives help on <command>
"""
command, = self._split_args(line, 0, 1)
if command is None:
... | python | def do_help(self, line):
"""Get help on commands "help" or "?" with no arguments displays a list_objects
of commands for which help is available "help <command>" or "?
<command>" gives help on <command>
"""
command, = self._split_args(line, 0, 1)
if command is None:
... | [
"def",
"do_help",
"(",
"self",
",",
"line",
")",
":",
"command",
",",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"1",
")",
"if",
"command",
"is",
"None",
":",
"return",
"self",
".",
"_print_help",
"(",
")",
"cmd",
".",
"Cmd",
".... | Get help on commands "help" or "?" with no arguments displays a list_objects
of commands for which help is available "help <command>" or "?
<command>" gives help on <command> | [
"Get",
"help",
"on",
"commands",
"help",
"or",
"?",
"with",
"no",
"arguments",
"displays",
"a",
"list_objects",
"of",
"commands",
"for",
"which",
"help",
"is",
"available",
"help",
"<command",
">",
"or",
"?"
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L106-L116 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_history | def do_history(self, line):
"""history Display a list of commands that have been entered."""
self._split_args(line, 0, 0)
for idx, item in enumerate(self._history):
d1_cli.impl.util.print_info("{0: 3d} {1}".format(idx, item)) | python | def do_history(self, line):
"""history Display a list of commands that have been entered."""
self._split_args(line, 0, 0)
for idx, item in enumerate(self._history):
d1_cli.impl.util.print_info("{0: 3d} {1}".format(idx, item)) | [
"def",
"do_history",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"for",
"idx",
",",
"item",
"in",
"enumerate",
"(",
"self",
".",
"_history",
")",
":",
"d1_cli",
".",
"impl",
".",
"util",
"... | history Display a list of commands that have been entered. | [
"history",
"Display",
"a",
"list",
"of",
"commands",
"that",
"have",
"been",
"entered",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L118-L122 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_exit | def do_exit(self, line):
"""exit Exit from the CLI."""
n_remaining_operations = len(self._command_processor.get_operation_queue())
if n_remaining_operations:
d1_cli.impl.util.print_warn(
"""There are {} unperformed operations in the write operation queue. These will
b... | python | def do_exit(self, line):
"""exit Exit from the CLI."""
n_remaining_operations = len(self._command_processor.get_operation_queue())
if n_remaining_operations:
d1_cli.impl.util.print_warn(
"""There are {} unperformed operations in the write operation queue. These will
b... | [
"def",
"do_exit",
"(",
"self",
",",
"line",
")",
":",
"n_remaining_operations",
"=",
"len",
"(",
"self",
".",
"_command_processor",
".",
"get_operation_queue",
"(",
")",
")",
"if",
"n_remaining_operations",
":",
"d1_cli",
".",
"impl",
".",
"util",
".",
"prin... | exit Exit from the CLI. | [
"exit",
"Exit",
"from",
"the",
"CLI",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L124-L136 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_eof | def do_eof(self, line):
"""Exit on system EOF character."""
d1_cli.impl.util.print_info("")
self.do_exit(line) | python | def do_eof(self, line):
"""Exit on system EOF character."""
d1_cli.impl.util.print_info("")
self.do_exit(line) | [
"def",
"do_eof",
"(",
"self",
",",
"line",
")",
":",
"d1_cli",
".",
"impl",
".",
"util",
".",
"print_info",
"(",
"\"\"",
")",
"self",
".",
"do_exit",
"(",
"line",
")"
] | Exit on system EOF character. | [
"Exit",
"on",
"system",
"EOF",
"character",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L142-L145 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_set | def do_set(self, line):
"""set [parameter [value]] set (without parameters): Display the value of all
session variables.
set <session variable>: Display the value of a single session variable. set
<session variable> <value>: Set the value of a session variable.
"""
sess... | python | def do_set(self, line):
"""set [parameter [value]] set (without parameters): Display the value of all
session variables.
set <session variable>: Display the value of a single session variable. set
<session variable> <value>: Set the value of a session variable.
"""
sess... | [
"def",
"do_set",
"(",
"self",
",",
"line",
")",
":",
"session_parameter",
",",
"value",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"2",
")",
"if",
"value",
"is",
"None",
":",
"self",
".",
"_command_processor",
".",
"get_session",
"(",... | set [parameter [value]] set (without parameters): Display the value of all
session variables.
set <session variable>: Display the value of a single session variable. set
<session variable> <value>: Set the value of a session variable. | [
"set",
"[",
"parameter",
"[",
"value",
"]]",
"set",
"(",
"without",
"parameters",
")",
":",
"Display",
"the",
"value",
"of",
"all",
"session",
"variables",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L151-L168 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_load | def do_load(self, line):
"""load [file] Load session variables from file load (without parameters): Load
session from default file ~/.dataone_cli.conf load.
<file>: Load session from specified file.
"""
config_file = self._split_args(line, 0, 1)[0]
self._command_process... | python | def do_load(self, line):
"""load [file] Load session variables from file load (without parameters): Load
session from default file ~/.dataone_cli.conf load.
<file>: Load session from specified file.
"""
config_file = self._split_args(line, 0, 1)[0]
self._command_process... | [
"def",
"do_load",
"(",
"self",
",",
"line",
")",
":",
"config_file",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"1",
")",
"[",
"0",
"]",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"load",
"(",
"config_file... | load [file] Load session variables from file load (without parameters): Load
session from default file ~/.dataone_cli.conf load.
<file>: Load session from specified file. | [
"load",
"[",
"file",
"]",
"Load",
"session",
"variables",
"from",
"file",
"load",
"(",
"without",
"parameters",
")",
":",
"Load",
"session",
"from",
"default",
"file",
"~",
"/",
".",
"dataone_cli",
".",
"conf",
"load",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L170-L183 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_save | def do_save(self, line):
"""save [config_file] Save session variables to file save (without parameters):
Save session to default file ~/.dataone_cli.conf save.
<file>: Save session to specified file.
"""
config_file = self._split_args(line, 0, 1)[0]
self._command_proces... | python | def do_save(self, line):
"""save [config_file] Save session variables to file save (without parameters):
Save session to default file ~/.dataone_cli.conf save.
<file>: Save session to specified file.
"""
config_file = self._split_args(line, 0, 1)[0]
self._command_proces... | [
"def",
"do_save",
"(",
"self",
",",
"line",
")",
":",
"config_file",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"1",
")",
"[",
"0",
"]",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"save",
"(",
"config_file... | save [config_file] Save session variables to file save (without parameters):
Save session to default file ~/.dataone_cli.conf save.
<file>: Save session to specified file. | [
"save",
"[",
"config_file",
"]",
"Save",
"session",
"variables",
"to",
"file",
"save",
"(",
"without",
"parameters",
")",
":",
"Save",
"session",
"to",
"default",
"file",
"~",
"/",
".",
"dataone_cli",
".",
"conf",
"save",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L185-L198 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_reset | def do_reset(self, line):
"""reset Set all session variables to their default values."""
self._split_args(line, 0, 0)
self._command_processor.get_session().reset()
self._print_info_if_verbose("Successfully reset session variables") | python | def do_reset(self, line):
"""reset Set all session variables to their default values."""
self._split_args(line, 0, 0)
self._command_processor.get_session().reset()
self._print_info_if_verbose("Successfully reset session variables") | [
"def",
"do_reset",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"reset",
"(",
")",
"self",
".",
"_print_info_if_verbose",
"("... | reset Set all session variables to their default values. | [
"reset",
"Set",
"all",
"session",
"variables",
"to",
"their",
"default",
"values",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L200-L204 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_allowaccess | def do_allowaccess(self, line):
"""allowaccess <subject> [access-level] Set the access level for subject Access
level is "read", "write" or "changePermission".
Access level defaults to "read" if not specified. Special subjects: public:
Any subject, authenticated and not authenticated ... | python | def do_allowaccess(self, line):
"""allowaccess <subject> [access-level] Set the access level for subject Access
level is "read", "write" or "changePermission".
Access level defaults to "read" if not specified. Special subjects: public:
Any subject, authenticated and not authenticated ... | [
"def",
"do_allowaccess",
"(",
"self",
",",
"line",
")",
":",
"subject",
",",
"permission",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"1",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_access_control",
... | allowaccess <subject> [access-level] Set the access level for subject Access
level is "read", "write" or "changePermission".
Access level defaults to "read" if not specified. Special subjects: public:
Any subject, authenticated and not authenticated authenticatedUser: Any
subject th... | [
"allowaccess",
"<subject",
">",
"[",
"access",
"-",
"level",
"]",
"Set",
"the",
"access",
"level",
"for",
"subject",
"Access",
"level",
"is",
"read",
"write",
"or",
"changePermission",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L210-L226 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_denyaccess | def do_denyaccess(self, line):
"""denyaccess <subject> Remove subject from access policy."""
subject, = self._split_args(line, 1, 0)
self._command_processor.get_session().get_access_control().remove_allowed_subject(
subject
)
self._print_info_if_verbose(
'... | python | def do_denyaccess(self, line):
"""denyaccess <subject> Remove subject from access policy."""
subject, = self._split_args(line, 1, 0)
self._command_processor.get_session().get_access_control().remove_allowed_subject(
subject
)
self._print_info_if_verbose(
'... | [
"def",
"do_denyaccess",
"(",
"self",
",",
"line",
")",
":",
"subject",
",",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_access_control",
"(",
")",
"."... | denyaccess <subject> Remove subject from access policy. | [
"denyaccess",
"<subject",
">",
"Remove",
"subject",
"from",
"access",
"policy",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L228-L236 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_clearaccess | def do_clearaccess(self, line):
"""clearaccess Remove all subjects from access policy Only the submitter will
have access to the object."""
self._split_args(line, 0, 0)
self._command_processor.get_session().get_access_control().clear()
self._print_info_if_verbose("Removed all sub... | python | def do_clearaccess(self, line):
"""clearaccess Remove all subjects from access policy Only the submitter will
have access to the object."""
self._split_args(line, 0, 0)
self._command_processor.get_session().get_access_control().clear()
self._print_info_if_verbose("Removed all sub... | [
"def",
"do_clearaccess",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_access_control",
"(",
")",
".",
"clear",
"(",
")",... | clearaccess Remove all subjects from access policy Only the submitter will
have access to the object. | [
"clearaccess",
"Remove",
"all",
"subjects",
"from",
"access",
"policy",
"Only",
"the",
"submitter",
"will",
"have",
"access",
"to",
"the",
"object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L238-L243 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_allowrep | def do_allowrep(self, line):
"""allowrep Allow new objects to be replicated."""
self._split_args(line, 0, 0)
self._command_processor.get_session().get_replication_policy().set_replication_allowed(
True
)
self._print_info_if_verbose("Set replication policy to allow rep... | python | def do_allowrep(self, line):
"""allowrep Allow new objects to be replicated."""
self._split_args(line, 0, 0)
self._command_processor.get_session().get_replication_policy().set_replication_allowed(
True
)
self._print_info_if_verbose("Set replication policy to allow rep... | [
"def",
"do_allowrep",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_replication_policy",
"(",
")",
".",
"set_replication_allo... | allowrep Allow new objects to be replicated. | [
"allowrep",
"Allow",
"new",
"objects",
"to",
"be",
"replicated",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L249-L255 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_denyrep | def do_denyrep(self, line):
"""denyrep Prevent new objects from being replicated."""
self._split_args(line, 0, 0)
self._command_processor.get_session().get_replication_policy().set_replication_allowed(
False
)
self._print_info_if_verbose("Set replication policy to den... | python | def do_denyrep(self, line):
"""denyrep Prevent new objects from being replicated."""
self._split_args(line, 0, 0)
self._command_processor.get_session().get_replication_policy().set_replication_allowed(
False
)
self._print_info_if_verbose("Set replication policy to den... | [
"def",
"do_denyrep",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_replication_policy",
"(",
")",
".",
"set_replication_allow... | denyrep Prevent new objects from being replicated. | [
"denyrep",
"Prevent",
"new",
"objects",
"from",
"being",
"replicated",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L257-L263 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_preferrep | def do_preferrep(self, line):
"""preferrep <member node> [member node ...] Add one or more preferred Member
Nodes to replication policy."""
mns = self._split_args(line, 1, -1)
self._command_processor.get_session().get_replication_policy().add_preferred(
mns
)
... | python | def do_preferrep(self, line):
"""preferrep <member node> [member node ...] Add one or more preferred Member
Nodes to replication policy."""
mns = self._split_args(line, 1, -1)
self._command_processor.get_session().get_replication_policy().add_preferred(
mns
)
... | [
"def",
"do_preferrep",
"(",
"self",
",",
"line",
")",
":",
"mns",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"-",
"1",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_replication_policy",
"(",
")",
".",... | preferrep <member node> [member node ...] Add one or more preferred Member
Nodes to replication policy. | [
"preferrep",
"<member",
"node",
">",
"[",
"member",
"node",
"...",
"]",
"Add",
"one",
"or",
"more",
"preferred",
"Member",
"Nodes",
"to",
"replication",
"policy",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L265-L274 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_blockrep | def do_blockrep(self, line):
"""blockrep <member node> [member node ...] Add one or more blocked Member Node
to replication policy."""
mns = self._split_args(line, 1, -1)
self._command_processor.get_session().get_replication_policy().add_blocked(mns)
self._print_info_if_verbose(
... | python | def do_blockrep(self, line):
"""blockrep <member node> [member node ...] Add one or more blocked Member Node
to replication policy."""
mns = self._split_args(line, 1, -1)
self._command_processor.get_session().get_replication_policy().add_blocked(mns)
self._print_info_if_verbose(
... | [
"def",
"do_blockrep",
"(",
"self",
",",
"line",
")",
":",
"mns",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"-",
"1",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_replication_policy",
"(",
")",
".",
... | blockrep <member node> [member node ...] Add one or more blocked Member Node
to replication policy. | [
"blockrep",
"<member",
"node",
">",
"[",
"member",
"node",
"...",
"]",
"Add",
"one",
"or",
"more",
"blocked",
"Member",
"Node",
"to",
"replication",
"policy",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L276-L283 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_removerep | def do_removerep(self, line):
"""removerep <member node> [member node ...] Remove one or more Member Nodes
from replication policy."""
mns = self._split_args(line, 1, -1)
self._command_processor.get_session().get_replication_policy().repremove(mns)
self._print_info_if_verbose(
... | python | def do_removerep(self, line):
"""removerep <member node> [member node ...] Remove one or more Member Nodes
from replication policy."""
mns = self._split_args(line, 1, -1)
self._command_processor.get_session().get_replication_policy().repremove(mns)
self._print_info_if_verbose(
... | [
"def",
"do_removerep",
"(",
"self",
",",
"line",
")",
":",
"mns",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"-",
"1",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_replication_policy",
"(",
")",
".",... | removerep <member node> [member node ...] Remove one or more Member Nodes
from replication policy. | [
"removerep",
"<member",
"node",
">",
"[",
"member",
"node",
"...",
"]",
"Remove",
"one",
"or",
"more",
"Member",
"Nodes",
"from",
"replication",
"policy",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L285-L292 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_numberrep | def do_numberrep(self, line):
"""numberrep <number of replicas> Set preferred number of replicas for new
objects If the preferred number of replicas is set to zero, replication is also
disallowed."""
n_replicas = self._split_args(line, 1, 0)[0]
self._command_processor.get_session... | python | def do_numberrep(self, line):
"""numberrep <number of replicas> Set preferred number of replicas for new
objects If the preferred number of replicas is set to zero, replication is also
disallowed."""
n_replicas = self._split_args(line, 1, 0)[0]
self._command_processor.get_session... | [
"def",
"do_numberrep",
"(",
"self",
",",
"line",
")",
":",
"n_replicas",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"0",
")",
"[",
"0",
"]",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_replication_policy",... | numberrep <number of replicas> Set preferred number of replicas for new
objects If the preferred number of replicas is set to zero, replication is also
disallowed. | [
"numberrep",
"<number",
"of",
"replicas",
">",
"Set",
"preferred",
"number",
"of",
"replicas",
"for",
"new",
"objects",
"If",
"the",
"preferred",
"number",
"of",
"replicas",
"is",
"set",
"to",
"zero",
"replication",
"is",
"also",
"disallowed",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L294-L302 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_clearrep | def do_clearrep(self, line):
"""clearrep Set the replication policy to default.
The default replication policy has no preferred or blocked member nodes, allows
replication and sets the preferred number of replicas to 3.
"""
self._split_args(line, 0, 0)
self._command_pro... | python | def do_clearrep(self, line):
"""clearrep Set the replication policy to default.
The default replication policy has no preferred or blocked member nodes, allows
replication and sets the preferred number of replicas to 3.
"""
self._split_args(line, 0, 0)
self._command_pro... | [
"def",
"do_clearrep",
"(",
"self",
",",
"line",
")",
":",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"get_session",
"(",
")",
".",
"get_replication_policy",
"(",
")",
".",
"clear",
"(",
")"... | clearrep Set the replication policy to default.
The default replication policy has no preferred or blocked member nodes, allows
replication and sets the preferred number of replicas to 3. | [
"clearrep",
"Set",
"the",
"replication",
"policy",
"to",
"default",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L304-L313 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_get | def do_get(self, line):
"""get <identifier> <file> Get an object from a Member Node.
The object is saved to <file>.
"""
pid, output_file = self._split_args(line, 2, 0)
self._command_processor.science_object_get(pid, output_file)
self._print_info_if_verbose(
... | python | def do_get(self, line):
"""get <identifier> <file> Get an object from a Member Node.
The object is saved to <file>.
"""
pid, output_file = self._split_args(line, 2, 0)
self._command_processor.science_object_get(pid, output_file)
self._print_info_if_verbose(
... | [
"def",
"do_get",
"(",
"self",
",",
"line",
")",
":",
"pid",
",",
"output_file",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"2",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"science_object_get",
"(",
"pid",
",",
"output_file",
")",
"s... | get <identifier> <file> Get an object from a Member Node.
The object is saved to <file>. | [
"get",
"<identifier",
">",
"<file",
">",
"Get",
"an",
"object",
"from",
"a",
"Member",
"Node",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L319-L329 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_meta | def do_meta(self, line):
"""meta <identifier> [file] Get the System Metadata that is associated with a
Science Object.
If the metadata is not on the Coordinating Node, the Member Node is checked.
Provide ``file`` to save the System Metada to disk instead of displaying it.
"""
... | python | def do_meta(self, line):
"""meta <identifier> [file] Get the System Metadata that is associated with a
Science Object.
If the metadata is not on the Coordinating Node, the Member Node is checked.
Provide ``file`` to save the System Metada to disk instead of displaying it.
"""
... | [
"def",
"do_meta",
"(",
"self",
",",
"line",
")",
":",
"pid",
",",
"output_file",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"1",
")",
"self",
".",
"_command_processor",
".",
"system_metadata_get",
"(",
"pid",
",",
"output_file",
")",
... | meta <identifier> [file] Get the System Metadata that is associated with a
Science Object.
If the metadata is not on the Coordinating Node, the Member Node is checked.
Provide ``file`` to save the System Metada to disk instead of displaying it. | [
"meta",
"<identifier",
">",
"[",
"file",
"]",
"Get",
"the",
"System",
"Metadata",
"that",
"is",
"associated",
"with",
"a",
"Science",
"Object",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L331-L347 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_list | def do_list(self, line):
"""list [path] Retrieve a list of available Science Data Objects from Member
Node The response is filtered by the from-date, to-date, search, start and count
session variables.
See also: search
"""
path = self._split_args(line, 0, 1, pad=False)
... | python | def do_list(self, line):
"""list [path] Retrieve a list of available Science Data Objects from Member
Node The response is filtered by the from-date, to-date, search, start and count
session variables.
See also: search
"""
path = self._split_args(line, 0, 1, pad=False)
... | [
"def",
"do_list",
"(",
"self",
",",
"line",
")",
":",
"path",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"1",
",",
"pad",
"=",
"False",
")",
"if",
"len",
"(",
"path",
")",
":",
"path",
"=",
"path",
"[",
"0",
"]",
"self",
"."... | list [path] Retrieve a list of available Science Data Objects from Member
Node The response is filtered by the from-date, to-date, search, start and count
session variables.
See also: search | [
"list",
"[",
"path",
"]",
"Retrieve",
"a",
"list",
"of",
"available",
"Science",
"Data",
"Objects",
"from",
"Member",
"Node",
"The",
"response",
"is",
"filtered",
"by",
"the",
"from",
"-",
"date",
"to",
"-",
"date",
"search",
"start",
"and",
"count",
"se... | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L349-L360 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_log | def do_log(self, line):
"""log [path] Retrieve event log from Member Node The response is filtered by
the from-date, to-date, start and count session parameters."""
path = self._split_args(line, 0, 1, pad=False)
if len(path):
path = path[0]
self._command_processor.log... | python | def do_log(self, line):
"""log [path] Retrieve event log from Member Node The response is filtered by
the from-date, to-date, start and count session parameters."""
path = self._split_args(line, 0, 1, pad=False)
if len(path):
path = path[0]
self._command_processor.log... | [
"def",
"do_log",
"(",
"self",
",",
"line",
")",
":",
"path",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"0",
",",
"1",
",",
"pad",
"=",
"False",
")",
"if",
"len",
"(",
"path",
")",
":",
"path",
"=",
"path",
"[",
"0",
"]",
"self",
".",... | log [path] Retrieve event log from Member Node The response is filtered by
the from-date, to-date, start and count session parameters. | [
"log",
"[",
"path",
"]",
"Retrieve",
"event",
"log",
"from",
"Member",
"Node",
"The",
"response",
"is",
"filtered",
"by",
"the",
"from",
"-",
"date",
"to",
"-",
"date",
"start",
"and",
"count",
"session",
"parameters",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L362-L368 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_resolve | def do_resolve(self, line):
"""resolve <identifier> Find all locations from which the given Science Object
can be downloaded."""
pid, = self._split_args(line, 1, 0)
self._command_processor.resolve(pid) | python | def do_resolve(self, line):
"""resolve <identifier> Find all locations from which the given Science Object
can be downloaded."""
pid, = self._split_args(line, 1, 0)
self._command_processor.resolve(pid) | [
"def",
"do_resolve",
"(",
"self",
",",
"line",
")",
":",
"pid",
",",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"resolve",
"(",
"pid",
")"
] | resolve <identifier> Find all locations from which the given Science Object
can be downloaded. | [
"resolve",
"<identifier",
">",
"Find",
"all",
"locations",
"from",
"which",
"the",
"given",
"Science",
"Object",
"can",
"be",
"downloaded",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L370-L374 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_create | def do_create(self, line):
"""create <identifier> <file> Create a new Science Object on a Member Node.
The System Metadata that becomes associated with the new Science Object is
generated from the session variables.
"""
pid, sciobj_path = self._split_args(line, 2, 0)
se... | python | def do_create(self, line):
"""create <identifier> <file> Create a new Science Object on a Member Node.
The System Metadata that becomes associated with the new Science Object is
generated from the session variables.
"""
pid, sciobj_path = self._split_args(line, 2, 0)
se... | [
"def",
"do_create",
"(",
"self",
",",
"line",
")",
":",
"pid",
",",
"sciobj_path",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"2",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"science_object_create",
"(",
"pid",
",",
"sciobj_path",
")"... | create <identifier> <file> Create a new Science Object on a Member Node.
The System Metadata that becomes associated with the new Science Object is
generated from the session variables. | [
"create",
"<identifier",
">",
"<file",
">",
"Create",
"a",
"new",
"Science",
"Object",
"on",
"a",
"Member",
"Node",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L380-L391 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_update | def do_update(self, line):
"""update <old-pid> <new-pid> <file> Replace an existing Science Object in a.
:term:`MN` with another.
"""
curr_pid, pid_new, input_file = self._split_args(line, 3, 0)
self._command_processor.science_object_update(curr_pid, input_file, pid_new)
... | python | def do_update(self, line):
"""update <old-pid> <new-pid> <file> Replace an existing Science Object in a.
:term:`MN` with another.
"""
curr_pid, pid_new, input_file = self._split_args(line, 3, 0)
self._command_processor.science_object_update(curr_pid, input_file, pid_new)
... | [
"def",
"do_update",
"(",
"self",
",",
"line",
")",
":",
"curr_pid",
",",
"pid_new",
",",
"input_file",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"3",
",",
"0",
")",
"self",
".",
"_command_processor",
".",
"science_object_update",
"(",
"curr_pid",
... | update <old-pid> <new-pid> <file> Replace an existing Science Object in a.
:term:`MN` with another. | [
"update",
"<old",
"-",
"pid",
">",
"<new",
"-",
"pid",
">",
"<file",
">",
"Replace",
"an",
"existing",
"Science",
"Object",
"in",
"a",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L393-L403 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_package | def do_package(self, line):
"""package <package-pid> <science-metadata-pid> <science-pid> [science- pid.
...] Create a simple OAI-ORE Resource Map on a Member Node.
"""
pids = self._split_args(line, 3, -1, pad=False)
self._command_processor.create_package(pids)
self._pr... | python | def do_package(self, line):
"""package <package-pid> <science-metadata-pid> <science-pid> [science- pid.
...] Create a simple OAI-ORE Resource Map on a Member Node.
"""
pids = self._split_args(line, 3, -1, pad=False)
self._command_processor.create_package(pids)
self._pr... | [
"def",
"do_package",
"(",
"self",
",",
"line",
")",
":",
"pids",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"3",
",",
"-",
"1",
",",
"pad",
"=",
"False",
")",
"self",
".",
"_command_processor",
".",
"create_package",
"(",
"pids",
")",
"self",... | package <package-pid> <science-metadata-pid> <science-pid> [science- pid.
...] Create a simple OAI-ORE Resource Map on a Member Node. | [
"package",
"<package",
"-",
"pid",
">",
"<science",
"-",
"metadata",
"-",
"pid",
">",
"<science",
"-",
"pid",
">",
"[",
"science",
"-",
"pid",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L405-L417 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_archive | def do_archive(self, line):
"""archive <identifier> [identifier ...] Mark one or more existing Science
Objects as archived."""
pids = self._split_args(line, 1, -1)
self._command_processor.science_object_archive(pids)
self._print_info_if_verbose(
"Added archive operati... | python | def do_archive(self, line):
"""archive <identifier> [identifier ...] Mark one or more existing Science
Objects as archived."""
pids = self._split_args(line, 1, -1)
self._command_processor.science_object_archive(pids)
self._print_info_if_verbose(
"Added archive operati... | [
"def",
"do_archive",
"(",
"self",
",",
"line",
")",
":",
"pids",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"-",
"1",
")",
"self",
".",
"_command_processor",
".",
"science_object_archive",
"(",
"pids",
")",
"self",
".",
"_print_info_if_... | archive <identifier> [identifier ...] Mark one or more existing Science
Objects as archived. | [
"archive",
"<identifier",
">",
"[",
"identifier",
"...",
"]",
"Mark",
"one",
"or",
"more",
"existing",
"Science",
"Objects",
"as",
"archived",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L419-L428 |
DataONEorg/d1_python | client_cli/src/d1_cli/impl/command_parser.py | CLI.do_updateaccess | def do_updateaccess(self, line):
"""updateaccess <identifier> [identifier ...] Update the Access Policy on one or
more existing Science Data Objects."""
pids = self._split_args(line, 1, -1)
self._command_processor.update_access_policy(pids)
self._print_info_if_verbose(
... | python | def do_updateaccess(self, line):
"""updateaccess <identifier> [identifier ...] Update the Access Policy on one or
more existing Science Data Objects."""
pids = self._split_args(line, 1, -1)
self._command_processor.update_access_policy(pids)
self._print_info_if_verbose(
... | [
"def",
"do_updateaccess",
"(",
"self",
",",
"line",
")",
":",
"pids",
"=",
"self",
".",
"_split_args",
"(",
"line",
",",
"1",
",",
"-",
"1",
")",
"self",
".",
"_command_processor",
".",
"update_access_policy",
"(",
"pids",
")",
"self",
".",
"_print_info_... | updateaccess <identifier> [identifier ...] Update the Access Policy on one or
more existing Science Data Objects. | [
"updateaccess",
"<identifier",
">",
"[",
"identifier",
"...",
"]",
"Update",
"the",
"Access",
"Policy",
"on",
"one",
"or",
"more",
"existing",
"Science",
"Data",
"Objects",
"."
] | train | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/command_parser.py#L430-L439 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.