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
DataONEorg/d1_python
lib_common/src/d1_common/date_time.py
http_datetime_str_from_dt
def http_datetime_str_from_dt(dt): """Format datetime to HTTP Full Date format. Args: dt : datetime - tz-aware: Used in the formatted string. - tz-naive: Assumed to be in UTC. Returns: str The returned format is a is fixed-length subset of that defined by RFC 1123 and ...
python
def http_datetime_str_from_dt(dt): """Format datetime to HTTP Full Date format. Args: dt : datetime - tz-aware: Used in the formatted string. - tz-naive: Assumed to be in UTC. Returns: str The returned format is a is fixed-length subset of that defined by RFC 1123 and ...
[ "def", "http_datetime_str_from_dt", "(", "dt", ")", ":", "epoch_seconds", "=", "ts_from_dt", "(", "dt", ")", "return", "email", ".", "utils", ".", "formatdate", "(", "epoch_seconds", ",", "localtime", "=", "False", ",", "usegmt", "=", "True", ")" ]
Format datetime to HTTP Full Date format. Args: dt : datetime - tz-aware: Used in the formatted string. - tz-naive: Assumed to be in UTC. Returns: str The returned format is a is fixed-length subset of that defined by RFC 1123 and is the preferred format fo...
[ "Format", "datetime", "to", "HTTP", "Full", "Date", "format", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/date_time.py#L295-L317
DataONEorg/d1_python
lib_common/src/d1_common/date_time.py
dt_from_http_datetime_str
def dt_from_http_datetime_str(http_full_datetime): """Parse HTTP Full Date formats and return as datetime. Args: http_full_datetime : str Each of the allowed formats are supported: - Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 - Sunday, 06-Nov-94 08:49:37 GMT ; ...
python
def dt_from_http_datetime_str(http_full_datetime): """Parse HTTP Full Date formats and return as datetime. Args: http_full_datetime : str Each of the allowed formats are supported: - Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 - Sunday, 06-Nov-94 08:49:37 GMT ; ...
[ "def", "dt_from_http_datetime_str", "(", "http_full_datetime", ")", ":", "date_parts", "=", "list", "(", "email", ".", "utils", ".", "parsedate", "(", "http_full_datetime", ")", "[", ":", "6", "]", ")", "year", "=", "date_parts", "[", "0", "]", "if", "year...
Parse HTTP Full Date formats and return as datetime. Args: http_full_datetime : str Each of the allowed formats are supported: - Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 - Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 - Sun Nov 6 08:49:...
[ "Parse", "HTTP", "Full", "Date", "formats", "and", "return", "as", "datetime", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/date_time.py#L339-L364
DataONEorg/d1_python
lib_common/src/d1_common/date_time.py
normalize_datetime_to_utc
def normalize_datetime_to_utc(dt): """Adjust datetime to UTC. Apply the timezone offset to the datetime and set the timezone to UTC. This is a no-op if the datetime is already in UTC. Args: dt : datetime - tz-aware: Used in the formatted string. - tz-naive: Assumed to be in UTC....
python
def normalize_datetime_to_utc(dt): """Adjust datetime to UTC. Apply the timezone offset to the datetime and set the timezone to UTC. This is a no-op if the datetime is already in UTC. Args: dt : datetime - tz-aware: Used in the formatted string. - tz-naive: Assumed to be in UTC....
[ "def", "normalize_datetime_to_utc", "(", "dt", ")", ":", "return", "datetime", ".", "datetime", "(", "*", "dt", ".", "utctimetuple", "(", ")", "[", ":", "6", "]", ",", "microsecond", "=", "dt", ".", "microsecond", ",", "tzinfo", "=", "datetime", ".", "...
Adjust datetime to UTC. Apply the timezone offset to the datetime and set the timezone to UTC. This is a no-op if the datetime is already in UTC. Args: dt : datetime - tz-aware: Used in the formatted string. - tz-naive: Assumed to be in UTC. Returns: datetime The ...
[ "Adjust", "datetime", "to", "UTC", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/date_time.py#L399-L429
DataONEorg/d1_python
lib_common/src/d1_common/date_time.py
cast_naive_datetime_to_tz
def cast_naive_datetime_to_tz(dt, tz=UTC()): """If datetime is tz-naive, set it to ``tz``. If datetime is tz-aware, return it unmodified. Args: dt : datetime tz-naive or tz-aware datetime. tz : datetime.tzinfo The timezone to which to adjust tz-naive datetime. Returns: ...
python
def cast_naive_datetime_to_tz(dt, tz=UTC()): """If datetime is tz-naive, set it to ``tz``. If datetime is tz-aware, return it unmodified. Args: dt : datetime tz-naive or tz-aware datetime. tz : datetime.tzinfo The timezone to which to adjust tz-naive datetime. Returns: ...
[ "def", "cast_naive_datetime_to_tz", "(", "dt", ",", "tz", "=", "UTC", "(", ")", ")", ":", "if", "has_tz", "(", "dt", ")", ":", "return", "dt", "return", "dt", ".", "replace", "(", "tzinfo", "=", "tz", ")" ]
If datetime is tz-naive, set it to ``tz``. If datetime is tz-aware, return it unmodified. Args: dt : datetime tz-naive or tz-aware datetime. tz : datetime.tzinfo The timezone to which to adjust tz-naive datetime. Returns: datetime tz-aware datetime. Warning:...
[ "If", "datetime", "is", "tz", "-", "naive", "set", "it", "to", "tz", ".", "If", "datetime", "is", "tz", "-", "aware", "return", "it", "unmodified", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/date_time.py#L432-L457
DataONEorg/d1_python
lib_common/src/d1_common/date_time.py
round_to_nearest
def round_to_nearest(dt, n_round_sec=1.0): """Round datetime up or down to nearest divisor. Round datetime up or down to nearest number of seconds that divides evenly by the divisor. Any timezone is preserved but ignored in the rounding. Args: dt: datetime n_round_sec : int or float ...
python
def round_to_nearest(dt, n_round_sec=1.0): """Round datetime up or down to nearest divisor. Round datetime up or down to nearest number of seconds that divides evenly by the divisor. Any timezone is preserved but ignored in the rounding. Args: dt: datetime n_round_sec : int or float ...
[ "def", "round_to_nearest", "(", "dt", ",", "n_round_sec", "=", "1.0", ")", ":", "ts", "=", "ts_from_dt", "(", "strip_timezone", "(", "dt", ")", ")", "+", "n_round_sec", "/", "2.0", "res", "=", "dt_from_ts", "(", "ts", "-", "(", "ts", "%", "n_round_sec"...
Round datetime up or down to nearest divisor. Round datetime up or down to nearest number of seconds that divides evenly by the divisor. Any timezone is preserved but ignored in the rounding. Args: dt: datetime n_round_sec : int or float Divisor for rounding Examples: ...
[ "Round", "datetime", "up", "or", "down", "to", "nearest", "divisor", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/date_time.py#L545-L567
genialis/resolwe
resolwe/flow/managers/workload_connectors/slurm.py
Connector.submit
def submit(self, data, runtime_dir, argv): """Run process with SLURM. For details, see :meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`. """ limits = data.process.get_resource_limits() logger.debug(__( "Connector '{}' running for D...
python
def submit(self, data, runtime_dir, argv): """Run process with SLURM. For details, see :meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`. """ limits = data.process.get_resource_limits() logger.debug(__( "Connector '{}' running for D...
[ "def", "submit", "(", "self", ",", "data", ",", "runtime_dir", ",", "argv", ")", ":", "limits", "=", "data", ".", "process", ".", "get_resource_limits", "(", ")", "logger", ".", "debug", "(", "__", "(", "\"Connector '{}' running for Data with id {} ({}).\"", "...
Run process with SLURM. For details, see :meth:`~resolwe.flow.managers.workload_connectors.base.BaseConnector.submit`.
[ "Run", "process", "with", "SLURM", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/managers/workload_connectors/slurm.py#L29-L73
genialis/resolwe
resolwe/flow/utils/purge.py
get_purge_files
def get_purge_files(root, output, output_schema, descriptor, descriptor_schema): """Get files to purge.""" def remove_file(fn, paths): """From paths remove fn and dirs before fn in dir tree.""" while fn: for i in range(len(paths) - 1, -1, -1): if fn == paths[i]: ...
python
def get_purge_files(root, output, output_schema, descriptor, descriptor_schema): """Get files to purge.""" def remove_file(fn, paths): """From paths remove fn and dirs before fn in dir tree.""" while fn: for i in range(len(paths) - 1, -1, -1): if fn == paths[i]: ...
[ "def", "get_purge_files", "(", "root", ",", "output", ",", "output_schema", ",", "descriptor", ",", "descriptor_schema", ")", ":", "def", "remove_file", "(", "fn", ",", "paths", ")", ":", "\"\"\"From paths remove fn and dirs before fn in dir tree.\"\"\"", "while", "fn...
Get files to purge.
[ "Get", "files", "to", "purge", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/purge.py#L21-L97
genialis/resolwe
resolwe/flow/utils/purge.py
location_purge
def location_purge(location_id, delete=False, verbosity=0): """Print and conditionally delete files not referenced by meta data. :param location_id: Id of the :class:`~resolwe.flow.models.DataLocation` model that data objects reference to. :param delete: If ``True``, then delete unreference...
python
def location_purge(location_id, delete=False, verbosity=0): """Print and conditionally delete files not referenced by meta data. :param location_id: Id of the :class:`~resolwe.flow.models.DataLocation` model that data objects reference to. :param delete: If ``True``, then delete unreference...
[ "def", "location_purge", "(", "location_id", ",", "delete", "=", "False", ",", "verbosity", "=", "0", ")", ":", "try", ":", "location", "=", "DataLocation", ".", "objects", ".", "get", "(", "id", "=", "location_id", ")", "except", "DataLocation", ".", "D...
Print and conditionally delete files not referenced by meta data. :param location_id: Id of the :class:`~resolwe.flow.models.DataLocation` model that data objects reference to. :param delete: If ``True``, then delete unreferenced files.
[ "Print", "and", "conditionally", "delete", "files", "not", "referenced", "by", "meta", "data", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/purge.py#L100-L161
genialis/resolwe
resolwe/flow/utils/purge.py
_location_purge_all
def _location_purge_all(delete=False, verbosity=0): """Purge all data locations.""" if DataLocation.objects.exists(): for location in DataLocation.objects.filter(Q(purged=False) | Q(data=None)): location_purge(location.id, delete, verbosity) else: logger.info("No data locations")
python
def _location_purge_all(delete=False, verbosity=0): """Purge all data locations.""" if DataLocation.objects.exists(): for location in DataLocation.objects.filter(Q(purged=False) | Q(data=None)): location_purge(location.id, delete, verbosity) else: logger.info("No data locations")
[ "def", "_location_purge_all", "(", "delete", "=", "False", ",", "verbosity", "=", "0", ")", ":", "if", "DataLocation", ".", "objects", ".", "exists", "(", ")", ":", "for", "location", "in", "DataLocation", ".", "objects", ".", "filter", "(", "Q", "(", ...
Purge all data locations.
[ "Purge", "all", "data", "locations", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/purge.py#L164-L170
genialis/resolwe
resolwe/flow/utils/purge.py
_storage_purge_all
def _storage_purge_all(delete=False, verbosity=0): """Purge unreferenced storages.""" orphaned_storages = Storage.objects.filter(data=None) if verbosity >= 1: if orphaned_storages.exists(): logger.info(__("Unreferenced storages ({}):", orphaned_storages.count())) for storage...
python
def _storage_purge_all(delete=False, verbosity=0): """Purge unreferenced storages.""" orphaned_storages = Storage.objects.filter(data=None) if verbosity >= 1: if orphaned_storages.exists(): logger.info(__("Unreferenced storages ({}):", orphaned_storages.count())) for storage...
[ "def", "_storage_purge_all", "(", "delete", "=", "False", ",", "verbosity", "=", "0", ")", ":", "orphaned_storages", "=", "Storage", ".", "objects", ".", "filter", "(", "data", "=", "None", ")", "if", "verbosity", ">=", "1", ":", "if", "orphaned_storages",...
Purge unreferenced storages.
[ "Purge", "unreferenced", "storages", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/purge.py#L173-L186
genialis/resolwe
resolwe/flow/utils/purge.py
purge_all
def purge_all(delete=False, verbosity=0): """Purge all data locations.""" _location_purge_all(delete, verbosity) _storage_purge_all(delete, verbosity)
python
def purge_all(delete=False, verbosity=0): """Purge all data locations.""" _location_purge_all(delete, verbosity) _storage_purge_all(delete, verbosity)
[ "def", "purge_all", "(", "delete", "=", "False", ",", "verbosity", "=", "0", ")", ":", "_location_purge_all", "(", "delete", ",", "verbosity", ")", "_storage_purge_all", "(", "delete", ",", "verbosity", ")" ]
Purge all data locations.
[ "Purge", "all", "data", "locations", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/utils/purge.py#L189-L192
genialis/resolwe
resolwe/process/parser.py
StaticStringMetadata.get_value
def get_value(self, node): """Convert value from an AST node.""" if not isinstance(node, ast.Str): raise TypeError("must be a string literal") return node.s
python
def get_value(self, node): """Convert value from an AST node.""" if not isinstance(node, ast.Str): raise TypeError("must be a string literal") return node.s
[ "def", "get_value", "(", "self", ",", "node", ")", ":", "if", "not", "isinstance", "(", "node", ",", "ast", ".", "Str", ")", ":", "raise", "TypeError", "(", "\"must be a string literal\"", ")", "return", "node", ".", "s" ]
Convert value from an AST node.
[ "Convert", "value", "from", "an", "AST", "node", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/parser.py#L24-L29
genialis/resolwe
resolwe/process/parser.py
StaticEnumMetadata.get_value
def get_value(self, node): """Convert value from an AST node.""" if not isinstance(node, ast.Attribute): raise TypeError("must be an attribute") if node.value.id != self.choices.__name__: raise TypeError("must be an attribute of {}".format(self.choices.__name__)) ...
python
def get_value(self, node): """Convert value from an AST node.""" if not isinstance(node, ast.Attribute): raise TypeError("must be an attribute") if node.value.id != self.choices.__name__: raise TypeError("must be an attribute of {}".format(self.choices.__name__)) ...
[ "def", "get_value", "(", "self", ",", "node", ")", ":", "if", "not", "isinstance", "(", "node", ",", "ast", ".", "Attribute", ")", ":", "raise", "TypeError", "(", "\"must be an attribute\"", ")", "if", "node", ".", "value", ".", "id", "!=", "self", "."...
Convert value from an AST node.
[ "Convert", "value", "from", "an", "AST", "node", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/parser.py#L39-L47
genialis/resolwe
resolwe/process/parser.py
StaticDictMetadata.get_value
def get_value(self, node): """Convert value from an AST node.""" if not isinstance(node, ast.Dict): raise TypeError("must be a dictionary") evaluator = SafeEvaluator() try: value = evaluator.run(node) except Exception as ex: # TODO: Handle err...
python
def get_value(self, node): """Convert value from an AST node.""" if not isinstance(node, ast.Dict): raise TypeError("must be a dictionary") evaluator = SafeEvaluator() try: value = evaluator.run(node) except Exception as ex: # TODO: Handle err...
[ "def", "get_value", "(", "self", ",", "node", ")", ":", "if", "not", "isinstance", "(", "node", ",", "ast", ".", "Dict", ")", ":", "raise", "TypeError", "(", "\"must be a dictionary\"", ")", "evaluator", "=", "SafeEvaluator", "(", ")", "try", ":", "value...
Convert value from an AST node.
[ "Convert", "value", "from", "an", "AST", "node", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/parser.py#L53-L73
genialis/resolwe
resolwe/process/parser.py
ProcessVisitor.visit_field_class
def visit_field_class(self, item, descriptor=None, fields=None): """Visit a class node containing a list of field definitions.""" discovered_fields = collections.OrderedDict() field_groups = {} for node in item.body: if isinstance(node, ast.ClassDef): field_gr...
python
def visit_field_class(self, item, descriptor=None, fields=None): """Visit a class node containing a list of field definitions.""" discovered_fields = collections.OrderedDict() field_groups = {} for node in item.body: if isinstance(node, ast.ClassDef): field_gr...
[ "def", "visit_field_class", "(", "self", ",", "item", ",", "descriptor", "=", "None", ",", "fields", "=", "None", ")", ":", "discovered_fields", "=", "collections", ".", "OrderedDict", "(", ")", "field_groups", "=", "{", "}", "for", "node", "in", "item", ...
Visit a class node containing a list of field definitions.
[ "Visit", "a", "class", "node", "containing", "a", "list", "of", "field", "definitions", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/parser.py#L118-L165
genialis/resolwe
resolwe/process/parser.py
ProcessVisitor.visit_ClassDef
def visit_ClassDef(self, node): # pylint: disable=invalid-name """Visit top-level classes.""" # Resolve everything as root scope contains everything from the process module. for base in node.bases: # Cover `from resolwe.process import ...`. if isinstance(base, ast.Name) ...
python
def visit_ClassDef(self, node): # pylint: disable=invalid-name """Visit top-level classes.""" # Resolve everything as root scope contains everything from the process module. for base in node.bases: # Cover `from resolwe.process import ...`. if isinstance(base, ast.Name) ...
[ "def", "visit_ClassDef", "(", "self", ",", "node", ")", ":", "# pylint: disable=invalid-name", "# Resolve everything as root scope contains everything from the process module.", "for", "base", "in", "node", ".", "bases", ":", "# Cover `from resolwe.process import ...`.", "if", ...
Visit top-level classes.
[ "Visit", "top", "-", "level", "classes", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/parser.py#L167-L212
genialis/resolwe
resolwe/process/parser.py
SafeParser.parse
def parse(self): """Parse process. :return: A list of discovered process descriptors """ root = ast.parse(self._source) visitor = ProcessVisitor(source=self._source) visitor.visit(root) return visitor.processes
python
def parse(self): """Parse process. :return: A list of discovered process descriptors """ root = ast.parse(self._source) visitor = ProcessVisitor(source=self._source) visitor.visit(root) return visitor.processes
[ "def", "parse", "(", "self", ")", ":", "root", "=", "ast", ".", "parse", "(", "self", ".", "_source", ")", "visitor", "=", "ProcessVisitor", "(", "source", "=", "self", ".", "_source", ")", "visitor", ".", "visit", "(", "root", ")", "return", "visito...
Parse process. :return: A list of discovered process descriptors
[ "Parse", "process", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/parser.py#L225-L234
genialis/resolwe
resolwe/permissions/loader.py
get_permissions_class
def get_permissions_class(permissions_name=None): """Load and cache permissions class. If ``permissions_name`` is not given, it defaults to permissions class set in Django ``FLOW_API['PERMISSIONS']`` setting. """ def load_permissions(permissions_name): """Look for a fully qualified flow per...
python
def get_permissions_class(permissions_name=None): """Load and cache permissions class. If ``permissions_name`` is not given, it defaults to permissions class set in Django ``FLOW_API['PERMISSIONS']`` setting. """ def load_permissions(permissions_name): """Look for a fully qualified flow per...
[ "def", "get_permissions_class", "(", "permissions_name", "=", "None", ")", ":", "def", "load_permissions", "(", "permissions_name", ")", ":", "\"\"\"Look for a fully qualified flow permissions class.\"\"\"", "try", ":", "return", "import_module", "(", "'{}'", ".", "format...
Load and cache permissions class. If ``permissions_name`` is not given, it defaults to permissions class set in Django ``FLOW_API['PERMISSIONS']`` setting.
[ "Load", "and", "cache", "permissions", "class", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/permissions/loader.py#L21-L62
genialis/resolwe
resolwe/flow/models/base.py
BaseModel.save
def save(self, *args, **kwargs): """Save the model.""" name_max_len = self._meta.get_field('name').max_length if len(self.name) > name_max_len: self.name = self.name[:(name_max_len - 3)] + '...' for _ in range(MAX_SLUG_RETRIES): try: # Attempt to ...
python
def save(self, *args, **kwargs): """Save the model.""" name_max_len = self._meta.get_field('name').max_length if len(self.name) > name_max_len: self.name = self.name[:(name_max_len - 3)] + '...' for _ in range(MAX_SLUG_RETRIES): try: # Attempt to ...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "name_max_len", "=", "self", ".", "_meta", ".", "get_field", "(", "'name'", ")", ".", "max_length", "if", "len", "(", "self", ".", "name", ")", ">", "name_max_len", ":...
Save the model.
[ "Save", "the", "model", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/models/base.py#L48-L68
DataONEorg/d1_python
lib_common/src/d1_common/revision.py
get_identifiers
def get_identifiers(sysmeta_pyxb): """Get set of identifiers that provide revision context for SciObj. Returns: tuple: PID, SID, OBSOLETES_PID, OBSOLETED_BY_PID """ pid = d1_common.xml.get_opt_val(sysmeta_pyxb, 'identifier') sid = d1_common.xml.get_opt_val(sysmeta_pyxb, 'seriesId') obsoletes...
python
def get_identifiers(sysmeta_pyxb): """Get set of identifiers that provide revision context for SciObj. Returns: tuple: PID, SID, OBSOLETES_PID, OBSOLETED_BY_PID """ pid = d1_common.xml.get_opt_val(sysmeta_pyxb, 'identifier') sid = d1_common.xml.get_opt_val(sysmeta_pyxb, 'seriesId') obsoletes...
[ "def", "get_identifiers", "(", "sysmeta_pyxb", ")", ":", "pid", "=", "d1_common", ".", "xml", ".", "get_opt_val", "(", "sysmeta_pyxb", ",", "'identifier'", ")", "sid", "=", "d1_common", ".", "xml", ".", "get_opt_val", "(", "sysmeta_pyxb", ",", "'seriesId'", ...
Get set of identifiers that provide revision context for SciObj. Returns: tuple: PID, SID, OBSOLETES_PID, OBSOLETED_BY_PID
[ "Get", "set", "of", "identifiers", "that", "provide", "revision", "context", "for", "SciObj", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/revision.py#L23-L33
DataONEorg/d1_python
lib_common/src/d1_common/revision.py
topological_sort
def topological_sort(unsorted_dict): """Sort objects by dependency. Sort a dict of obsoleting PID to obsoleted PID to a list of PIDs in order of obsolescence. Args: unsorted_dict : dict Dict that holds obsolescence information. Each ``key/value`` pair establishes that the PID in ...
python
def topological_sort(unsorted_dict): """Sort objects by dependency. Sort a dict of obsoleting PID to obsoleted PID to a list of PIDs in order of obsolescence. Args: unsorted_dict : dict Dict that holds obsolescence information. Each ``key/value`` pair establishes that the PID in ...
[ "def", "topological_sort", "(", "unsorted_dict", ")", ":", "sorted_list", "=", "[", "]", "sorted_set", "=", "set", "(", ")", "found", "=", "True", "unconnected_dict", "=", "unsorted_dict", ".", "copy", "(", ")", "while", "found", ":", "found", "=", "False"...
Sort objects by dependency. Sort a dict of obsoleting PID to obsoleted PID to a list of PIDs in order of obsolescence. Args: unsorted_dict : dict Dict that holds obsolescence information. Each ``key/value`` pair establishes that the PID in ``key`` identifies an object that obsoletes ...
[ "Sort", "objects", "by", "dependency", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/revision.py#L36-L81
DataONEorg/d1_python
lib_common/src/d1_common/revision.py
get_pids_in_revision_chain
def get_pids_in_revision_chain(client, did): """Args: client: d1_client.cnclient.CoordinatingNodeClient or d1_client.mnclient.MemberNodeClient. did : str SID or a PID of any object in a revision chain. Returns: list of str: All PIDs in the chain. The returned list is in the sam...
python
def get_pids_in_revision_chain(client, did): """Args: client: d1_client.cnclient.CoordinatingNodeClient or d1_client.mnclient.MemberNodeClient. did : str SID or a PID of any object in a revision chain. Returns: list of str: All PIDs in the chain. The returned list is in the sam...
[ "def", "get_pids_in_revision_chain", "(", "client", ",", "did", ")", ":", "def", "_req", "(", "p", ")", ":", "return", "d1_common", ".", "xml", ".", "get_req_val", "(", "p", ")", "def", "_opt", "(", "p", ",", "a", ")", ":", "return", "d1_common", "."...
Args: client: d1_client.cnclient.CoordinatingNodeClient or d1_client.mnclient.MemberNodeClient. did : str SID or a PID of any object in a revision chain. Returns: list of str: All PIDs in the chain. The returned list is in the same order as the chain. The initial PID is typ...
[ "Args", ":", "client", ":", "d1_client", ".", "cnclient", ".", "CoordinatingNodeClient", "or", "d1_client", ".", "mnclient", ".", "MemberNodeClient", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/revision.py#L84-L114
DataONEorg/d1_python
dev_tools/src/d1_dev/src-format-docstrings.py
main
def main(): """Remove unused imports Unsafe! Only tested on our codebase, which uses simple absolute imports on the form, "import a.b.c". """ parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument("path", na...
python
def main(): """Remove unused imports Unsafe! Only tested on our codebase, which uses simple absolute imports on the form, "import a.b.c". """ parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter ) parser.add_argument("path", na...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "__doc__", ",", "formatter_class", "=", "argparse", ".", "RawDescriptionHelpFormatter", ")", "parser", ".", "add_argument", "(", "\"path\"", ",", "nargs", ...
Remove unused imports Unsafe! Only tested on our codebase, which uses simple absolute imports on the form, "import a.b.c".
[ "Remove", "unused", "imports", "Unsafe!" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/src-format-docstrings.py#L46-L99
DataONEorg/d1_python
dev_tools/src/d1_dev/src-format-docstrings.py
get_docstr_list
def get_docstr_list(red): """Find all triple-quoted docstrings in module.""" docstr_list = [] for n in red.find_all("string"): if n.value.startswith('"""'): docstr_list.append(n) return docstr_list
python
def get_docstr_list(red): """Find all triple-quoted docstrings in module.""" docstr_list = [] for n in red.find_all("string"): if n.value.startswith('"""'): docstr_list.append(n) return docstr_list
[ "def", "get_docstr_list", "(", "red", ")", ":", "docstr_list", "=", "[", "]", "for", "n", "in", "red", ".", "find_all", "(", "\"string\"", ")", ":", "if", "n", ".", "value", ".", "startswith", "(", "'\"\"\"'", ")", ":", "docstr_list", ".", "append", ...
Find all triple-quoted docstrings in module.
[ "Find", "all", "triple", "-", "quoted", "docstrings", "in", "module", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/src-format-docstrings.py#L144-L150
DataONEorg/d1_python
dev_tools/src/d1_dev/src-format-docstrings.py
unwrap
def unwrap(s, node_indent): """Group lines of a docstring to blocks. For now, only groups markdown list sections. A block designates a list of consequtive lines that all start at the same indentation level. The lines of the docstring are iterated top to bottom. Each line is added to `block_li...
python
def unwrap(s, node_indent): """Group lines of a docstring to blocks. For now, only groups markdown list sections. A block designates a list of consequtive lines that all start at the same indentation level. The lines of the docstring are iterated top to bottom. Each line is added to `block_li...
[ "def", "unwrap", "(", "s", ",", "node_indent", ")", ":", "def", "get_indent", "(", ")", ":", "if", "line_str", ".", "startswith", "(", "'\"\"\"'", ")", ":", "return", "node_indent", "return", "len", "(", "re", ".", "match", "(", "r\"^( *)\"", ",", "lin...
Group lines of a docstring to blocks. For now, only groups markdown list sections. A block designates a list of consequtive lines that all start at the same indentation level. The lines of the docstring are iterated top to bottom. Each line is added to `block_list` until a line is encountered tha...
[ "Group", "lines", "of", "a", "docstring", "to", "blocks", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/src-format-docstrings.py#L186-L270
DataONEorg/d1_python
dev_tools/src/d1_dev/src-format-docstrings.py
wrap
def wrap(indent_int, unwrap_str): """Wrap a single line to one or more lines that start at indent_int and end at the last word that will fit before WRAP_MARGIN_INT. If there are no word breaks (spaces) before WRAP_MARGIN_INT, force a break at WRAP_MARGIN_INT. """ with io.StringIO() as str_buf:...
python
def wrap(indent_int, unwrap_str): """Wrap a single line to one or more lines that start at indent_int and end at the last word that will fit before WRAP_MARGIN_INT. If there are no word breaks (spaces) before WRAP_MARGIN_INT, force a break at WRAP_MARGIN_INT. """ with io.StringIO() as str_buf:...
[ "def", "wrap", "(", "indent_int", ",", "unwrap_str", ")", ":", "with", "io", ".", "StringIO", "(", ")", "as", "str_buf", ":", "is_rest_block", "=", "unwrap_str", ".", "startswith", "(", "(", "\"- \"", ",", "\"* \"", ")", ")", "while", "unwrap_str", ":", ...
Wrap a single line to one or more lines that start at indent_int and end at the last word that will fit before WRAP_MARGIN_INT. If there are no word breaks (spaces) before WRAP_MARGIN_INT, force a break at WRAP_MARGIN_INT.
[ "Wrap", "a", "single", "line", "to", "one", "or", "more", "lines", "that", "start", "at", "indent_int", "and", "end", "at", "the", "last", "word", "that", "will", "fit", "before", "WRAP_MARGIN_INT", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/src-format-docstrings.py#L273-L297
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
createSimpleResourceMap
def createSimpleResourceMap(ore_pid, scimeta_pid, sciobj_pid_list): """Create a simple OAI-ORE Resource Map with one Science Metadata document and any number of Science Data objects. This creates a document that establishes an association between a Science Metadata object and any number of Science Data...
python
def createSimpleResourceMap(ore_pid, scimeta_pid, sciobj_pid_list): """Create a simple OAI-ORE Resource Map with one Science Metadata document and any number of Science Data objects. This creates a document that establishes an association between a Science Metadata object and any number of Science Data...
[ "def", "createSimpleResourceMap", "(", "ore_pid", ",", "scimeta_pid", ",", "sciobj_pid_list", ")", ":", "ore", "=", "ResourceMap", "(", ")", "ore", ".", "initialize", "(", "ore_pid", ")", "ore", ".", "addMetadataDocument", "(", "scimeta_pid", ")", "ore", ".", ...
Create a simple OAI-ORE Resource Map with one Science Metadata document and any number of Science Data objects. This creates a document that establishes an association between a Science Metadata object and any number of Science Data objects. The Science Metadata object contains information that is inde...
[ "Create", "a", "simple", "OAI", "-", "ORE", "Resource", "Map", "with", "one", "Science", "Metadata", "document", "and", "any", "number", "of", "Science", "Data", "objects", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L66-L96
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
createResourceMapFromStream
def createResourceMapFromStream(in_stream, base_url=d1_common.const.URL_DATAONE_ROOT): """Create a simple OAI-ORE Resource Map with one Science Metadata document and any number of Science Data objects, using a stream of PIDs. Args: in_stream: The first non-blank line is the PID of the resourc...
python
def createResourceMapFromStream(in_stream, base_url=d1_common.const.URL_DATAONE_ROOT): """Create a simple OAI-ORE Resource Map with one Science Metadata document and any number of Science Data objects, using a stream of PIDs. Args: in_stream: The first non-blank line is the PID of the resourc...
[ "def", "createResourceMapFromStream", "(", "in_stream", ",", "base_url", "=", "d1_common", ".", "const", ".", "URL_DATAONE_ROOT", ")", ":", "pids", "=", "[", "]", "for", "line", "in", "in_stream", ":", "pid", "=", "line", ".", "strip", "(", ")", "if", "p...
Create a simple OAI-ORE Resource Map with one Science Metadata document and any number of Science Data objects, using a stream of PIDs. Args: in_stream: The first non-blank line is the PID of the resource map itself. Second line is the science metadata PID and remaining lines are science ...
[ "Create", "a", "simple", "OAI", "-", "ORE", "Resource", "Map", "with", "one", "Science", "Metadata", "document", "and", "any", "number", "of", "Science", "Data", "objects", "using", "a", "stream", "of", "PIDs", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L99-L142
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.initialize
def initialize(self, pid, ore_software_id=d1_common.const.ORE_SOFTWARE_ID): """Create the basic ORE document structure.""" # Set nice prefixes for the namespaces for k in list(d1_common.const.ORE_NAMESPACE_DICT.keys()): self.bind(k, d1_common.const.ORE_NAMESPACE_DICT[k]) # Cr...
python
def initialize(self, pid, ore_software_id=d1_common.const.ORE_SOFTWARE_ID): """Create the basic ORE document structure.""" # Set nice prefixes for the namespaces for k in list(d1_common.const.ORE_NAMESPACE_DICT.keys()): self.bind(k, d1_common.const.ORE_NAMESPACE_DICT[k]) # Cr...
[ "def", "initialize", "(", "self", ",", "pid", ",", "ore_software_id", "=", "d1_common", ".", "const", ".", "ORE_SOFTWARE_ID", ")", ":", "# Set nice prefixes for the namespaces", "for", "k", "in", "list", "(", "d1_common", ".", "const", ".", "ORE_NAMESPACE_DICT", ...
Create the basic ORE document structure.
[ "Create", "the", "basic", "ORE", "document", "structure", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L204-L223
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.serialize_to_transport
def serialize_to_transport(self, doc_format="xml", *args, **kwargs): """Serialize ResourceMap to UTF-8 encoded XML document. Args: doc_format: str One of: ``xml``, ``n3``, ``turtle``, ``nt``, ``pretty-xml``, ``trix``, ``trig`` and ``nquads``. args and kwargs...
python
def serialize_to_transport(self, doc_format="xml", *args, **kwargs): """Serialize ResourceMap to UTF-8 encoded XML document. Args: doc_format: str One of: ``xml``, ``n3``, ``turtle``, ``nt``, ``pretty-xml``, ``trix``, ``trig`` and ``nquads``. args and kwargs...
[ "def", "serialize_to_transport", "(", "self", ",", "doc_format", "=", "\"xml\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "super", "(", "ResourceMap", ",", "self", ")", ".", "serialize", "(", "format", "=", "doc_format", ",", "encod...
Serialize ResourceMap to UTF-8 encoded XML document. Args: doc_format: str One of: ``xml``, ``n3``, ``turtle``, ``nt``, ``pretty-xml``, ``trix``, ``trig`` and ``nquads``. args and kwargs: Optional arguments forwarded to rdflib.ConjunctiveGraph.serialize(...
[ "Serialize", "ResourceMap", "to", "UTF", "-", "8", "encoded", "XML", "document", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L225-L245
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.serialize_to_display
def serialize_to_display(self, doc_format="pretty-xml", *args, **kwargs): """Serialize ResourceMap to an XML doc that is pretty printed for display. Args: doc_format: str One of: ``xml``, ``n3``, ``turtle``, ``nt``, ``pretty-xml``, ``trix``, ``trig`` and ``nquads``. ...
python
def serialize_to_display(self, doc_format="pretty-xml", *args, **kwargs): """Serialize ResourceMap to an XML doc that is pretty printed for display. Args: doc_format: str One of: ``xml``, ``n3``, ``turtle``, ``nt``, ``pretty-xml``, ``trix``, ``trig`` and ``nquads``. ...
[ "def", "serialize_to_display", "(", "self", ",", "doc_format", "=", "\"pretty-xml\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "(", "super", "(", "ResourceMap", ",", "self", ")", ".", "serialize", "(", "format", "=", "doc_format", "...
Serialize ResourceMap to an XML doc that is pretty printed for display. Args: doc_format: str One of: ``xml``, ``n3``, ``turtle``, ``nt``, ``pretty-xml``, ``trix``, ``trig`` and ``nquads``. args and kwargs: Optional arguments forwarded to rdflib.Conjunct...
[ "Serialize", "ResourceMap", "to", "an", "XML", "doc", "that", "is", "pretty", "printed", "for", "display", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L247-L269
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.deserialize
def deserialize(self, *args, **kwargs): """Deserialize Resource Map XML doc. The source is specified using one of source, location, file or data. Args: source: InputSource, file-like object, or string In the case of a string the string is the location of the source. ...
python
def deserialize(self, *args, **kwargs): """Deserialize Resource Map XML doc. The source is specified using one of source, location, file or data. Args: source: InputSource, file-like object, or string In the case of a string the string is the location of the source. ...
[ "def", "deserialize", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "parse", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "_ore_initialized", "=", "True" ]
Deserialize Resource Map XML doc. The source is specified using one of source, location, file or data. Args: source: InputSource, file-like object, or string In the case of a string the string is the location of the source. location: str String indicating t...
[ "Deserialize", "Resource", "Map", "XML", "doc", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L272-L305
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.getAggregation
def getAggregation(self): """Returns: str : URIRef of the Aggregation entity """ self._check_initialized() return [ o for o in self.subjects(predicate=rdflib.RDF.type, object=ORE.Aggregation) ][0]
python
def getAggregation(self): """Returns: str : URIRef of the Aggregation entity """ self._check_initialized() return [ o for o in self.subjects(predicate=rdflib.RDF.type, object=ORE.Aggregation) ][0]
[ "def", "getAggregation", "(", "self", ")", ":", "self", ".", "_check_initialized", "(", ")", "return", "[", "o", "for", "o", "in", "self", ".", "subjects", "(", "predicate", "=", "rdflib", ".", "RDF", ".", "type", ",", "object", "=", "ORE", ".", "Agg...
Returns: str : URIRef of the Aggregation entity
[ "Returns", ":" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L307-L316
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.getObjectByPid
def getObjectByPid(self, pid): """ Args: pid : str Returns: str : URIRef of the entry identified by ``pid``.""" self._check_initialized() opid = rdflib.term.Literal(pid) res = [o for o in self.subjects(predicate=DCTERMS.identifier, object=opid)] return res[0]
python
def getObjectByPid(self, pid): """ Args: pid : str Returns: str : URIRef of the entry identified by ``pid``.""" self._check_initialized() opid = rdflib.term.Literal(pid) res = [o for o in self.subjects(predicate=DCTERMS.identifier, object=opid)] return res[0]
[ "def", "getObjectByPid", "(", "self", ",", "pid", ")", ":", "self", ".", "_check_initialized", "(", ")", "opid", "=", "rdflib", ".", "term", ".", "Literal", "(", "pid", ")", "res", "=", "[", "o", "for", "o", "in", "self", ".", "subjects", "(", "pre...
Args: pid : str Returns: str : URIRef of the entry identified by ``pid``.
[ "Args", ":", "pid", ":", "str" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L318-L328
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.addResource
def addResource(self, pid): """Add a resource to the Resource Map. Args: pid : str """ self._check_initialized() try: # is entry already in place? self.getObjectByPid(pid) return except IndexError: pass #...
python
def addResource(self, pid): """Add a resource to the Resource Map. Args: pid : str """ self._check_initialized() try: # is entry already in place? self.getObjectByPid(pid) return except IndexError: pass #...
[ "def", "addResource", "(", "self", ",", "pid", ")", ":", "self", ".", "_check_initialized", "(", ")", "try", ":", "# is entry already in place?", "self", ".", "getObjectByPid", "(", "pid", ")", "return", "except", "IndexError", ":", "pass", "# Entry not present,...
Add a resource to the Resource Map. Args: pid : str
[ "Add", "a", "resource", "to", "the", "Resource", "Map", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L330-L350
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.setDocuments
def setDocuments(self, documenting_pid, documented_pid): """Add a CiTO, the Citation Typing Ontology, triple asserting that ``documenting_pid`` documents ``documented_pid``. Adds assertion: ``documenting_pid cito:documents documented_pid`` Args: documenting_pid: str ...
python
def setDocuments(self, documenting_pid, documented_pid): """Add a CiTO, the Citation Typing Ontology, triple asserting that ``documenting_pid`` documents ``documented_pid``. Adds assertion: ``documenting_pid cito:documents documented_pid`` Args: documenting_pid: str ...
[ "def", "setDocuments", "(", "self", ",", "documenting_pid", ",", "documented_pid", ")", ":", "self", ".", "_check_initialized", "(", ")", "documenting_id", "=", "self", ".", "getObjectByPid", "(", "documenting_pid", ")", "documented_id", "=", "self", ".", "getOb...
Add a CiTO, the Citation Typing Ontology, triple asserting that ``documenting_pid`` documents ``documented_pid``. Adds assertion: ``documenting_pid cito:documents documented_pid`` Args: documenting_pid: str PID of a Science Object that documents ``documented_pid``. ...
[ "Add", "a", "CiTO", "the", "Citation", "Typing", "Ontology", "triple", "asserting", "that", "documenting_pid", "documents", "documented_pid", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L352-L369
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.setDocumentedBy
def setDocumentedBy(self, documented_pid, documenting_pid): """Add a CiTO, the Citation Typing Ontology, triple asserting that ``documented_pid`` isDocumentedBy ``documenting_pid``. Adds assertion: ``documented_pid cito:isDocumentedBy documenting_pid`` Args: documented_pid: s...
python
def setDocumentedBy(self, documented_pid, documenting_pid): """Add a CiTO, the Citation Typing Ontology, triple asserting that ``documented_pid`` isDocumentedBy ``documenting_pid``. Adds assertion: ``documented_pid cito:isDocumentedBy documenting_pid`` Args: documented_pid: s...
[ "def", "setDocumentedBy", "(", "self", ",", "documented_pid", ",", "documenting_pid", ")", ":", "self", ".", "_check_initialized", "(", ")", "documented_id", "=", "self", ".", "getObjectByPid", "(", "documented_pid", ")", "documenting_id", "=", "self", ".", "get...
Add a CiTO, the Citation Typing Ontology, triple asserting that ``documented_pid`` isDocumentedBy ``documenting_pid``. Adds assertion: ``documented_pid cito:isDocumentedBy documenting_pid`` Args: documented_pid: str PID of a Science Object that is documented by ``document...
[ "Add", "a", "CiTO", "the", "Citation", "Typing", "Ontology", "triple", "asserting", "that", "documented_pid", "isDocumentedBy", "documenting_pid", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L371-L388
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.addDataDocuments
def addDataDocuments(self, scidata_pid_list, scimeta_pid=None): """Add Science Data object(s) Args: scidata_pid_list : list of str List of one or more PIDs of Science Data objects scimeta_pid: str PID of a Science Metadata object that documents the Science D...
python
def addDataDocuments(self, scidata_pid_list, scimeta_pid=None): """Add Science Data object(s) Args: scidata_pid_list : list of str List of one or more PIDs of Science Data objects scimeta_pid: str PID of a Science Metadata object that documents the Science D...
[ "def", "addDataDocuments", "(", "self", ",", "scidata_pid_list", ",", "scimeta_pid", "=", "None", ")", ":", "mpids", "=", "self", ".", "getAggregatedScienceMetadataPids", "(", ")", "if", "scimeta_pid", "is", "None", ":", "if", "len", "(", "mpids", ")", ">", ...
Add Science Data object(s) Args: scidata_pid_list : list of str List of one or more PIDs of Science Data objects scimeta_pid: str PID of a Science Metadata object that documents the Science Data objects.
[ "Add", "Science", "Data", "object", "(", "s", ")" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L400-L425
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.getResourceMapPid
def getResourceMapPid(self): """Returns: str : PID of the Resource Map itself. """ ore = [ o for o in self.subjects(predicate=rdflib.RDF.type, object=ORE.ResourceMap) ][0] pid = [str(o) for o in self.objects(predicate=DCTERMS.identifier, subject=ore)][ ...
python
def getResourceMapPid(self): """Returns: str : PID of the Resource Map itself. """ ore = [ o for o in self.subjects(predicate=rdflib.RDF.type, object=ORE.ResourceMap) ][0] pid = [str(o) for o in self.objects(predicate=DCTERMS.identifier, subject=ore)][ ...
[ "def", "getResourceMapPid", "(", "self", ")", ":", "ore", "=", "[", "o", "for", "o", "in", "self", ".", "subjects", "(", "predicate", "=", "rdflib", ".", "RDF", ".", "type", ",", "object", "=", "ORE", ".", "ResourceMap", ")", "]", "[", "0", "]", ...
Returns: str : PID of the Resource Map itself.
[ "Returns", ":" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L427-L439
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.getAllTriples
def getAllTriples(self): """Returns: list of tuples : Each tuple holds a subject, predicate, object triple """ return [(str(s), str(p), str(o)) for s, p, o in self]
python
def getAllTriples(self): """Returns: list of tuples : Each tuple holds a subject, predicate, object triple """ return [(str(s), str(p), str(o)) for s, p, o in self]
[ "def", "getAllTriples", "(", "self", ")", ":", "return", "[", "(", "str", "(", "s", ")", ",", "str", "(", "p", ")", ",", "str", "(", "o", ")", ")", "for", "s", ",", "p", ",", "o", "in", "self", "]" ]
Returns: list of tuples : Each tuple holds a subject, predicate, object triple
[ "Returns", ":" ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L441-L447
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.getSubjectObjectsByPredicate
def getSubjectObjectsByPredicate(self, predicate): """ Args: predicate : str Predicate for which to return subject, object tuples. Returns: list of subject, object tuples: All subject/objects with ``predicate``. Notes: Equivalent SPARQL: .. highlight: sql :...
python
def getSubjectObjectsByPredicate(self, predicate): """ Args: predicate : str Predicate for which to return subject, object tuples. Returns: list of subject, object tuples: All subject/objects with ``predicate``. Notes: Equivalent SPARQL: .. highlight: sql :...
[ "def", "getSubjectObjectsByPredicate", "(", "self", ",", "predicate", ")", ":", "return", "sorted", "(", "set", "(", "[", "(", "str", "(", "s", ")", ",", "str", "(", "o", ")", ")", "for", "s", ",", "o", "in", "self", ".", "subject_objects", "(", "r...
Args: predicate : str Predicate for which to return subject, object tuples. Returns: list of subject, object tuples: All subject/objects with ``predicate``. Notes: Equivalent SPARQL: .. highlight: sql :: SELECT DISTINCT ?s ?o WHERE {{ ?s {0} ...
[ "Args", ":", "predicate", ":", "str", "Predicate", "for", "which", "to", "return", "subject", "object", "tuples", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L468-L497
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap.parseDoc
def parseDoc(self, doc_str, format="xml"): """Parse a OAI-ORE Resource Maps document. See Also: ``rdflib.ConjunctiveGraph.parse`` for documentation on arguments. """ self.parse(data=doc_str, format=format) self._ore_initialized = True return self
python
def parseDoc(self, doc_str, format="xml"): """Parse a OAI-ORE Resource Maps document. See Also: ``rdflib.ConjunctiveGraph.parse`` for documentation on arguments. """ self.parse(data=doc_str, format=format) self._ore_initialized = True return self
[ "def", "parseDoc", "(", "self", ",", "doc_str", ",", "format", "=", "\"xml\"", ")", ":", "self", ".", "parse", "(", "data", "=", "doc_str", ",", "format", "=", "format", ")", "self", ".", "_ore_initialized", "=", "True", "return", "self" ]
Parse a OAI-ORE Resource Maps document. See Also: ``rdflib.ConjunctiveGraph.parse`` for documentation on arguments.
[ "Parse", "a", "OAI", "-", "ORE", "Resource", "Maps", "document", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L606-L614
DataONEorg/d1_python
lib_common/src/d1_common/resource_map.py
ResourceMap._pid_to_id
def _pid_to_id(self, pid): """Converts a pid to a URI that can be used as an OAI-ORE identifier.""" return d1_common.url.joinPathElements( self._base_url, self._version_tag, "resolve", d1_common.url.encodePathElement(pid), )
python
def _pid_to_id(self, pid): """Converts a pid to a URI that can be used as an OAI-ORE identifier.""" return d1_common.url.joinPathElements( self._base_url, self._version_tag, "resolve", d1_common.url.encodePathElement(pid), )
[ "def", "_pid_to_id", "(", "self", ",", "pid", ")", ":", "return", "d1_common", ".", "url", ".", "joinPathElements", "(", "self", ".", "_base_url", ",", "self", ".", "_version_tag", ",", "\"resolve\"", ",", "d1_common", ".", "url", ".", "encodePathElement", ...
Converts a pid to a URI that can be used as an OAI-ORE identifier.
[ "Converts", "a", "pid", "to", "a", "URI", "that", "can", "be", "used", "as", "an", "OAI", "-", "ORE", "identifier", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/resource_map.py#L618-L625
DataONEorg/d1_python
utilities/src/d1_util/check_object_checksums.py
make_checksum_validation_script
def make_checksum_validation_script(stats_list): """Make batch files required for checking checksums from another machine.""" if not os.path.exists('./hash_check'): os.mkdir('./hash_check') with open('./hash_check/curl.sh', 'w') as curl_f, open( './hash_check/md5.txt', 'w' ) as md5_f, o...
python
def make_checksum_validation_script(stats_list): """Make batch files required for checking checksums from another machine.""" if not os.path.exists('./hash_check'): os.mkdir('./hash_check') with open('./hash_check/curl.sh', 'w') as curl_f, open( './hash_check/md5.txt', 'w' ) as md5_f, o...
[ "def", "make_checksum_validation_script", "(", "stats_list", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "'./hash_check'", ")", ":", "os", ".", "mkdir", "(", "'./hash_check'", ")", "with", "open", "(", "'./hash_check/curl.sh'", ",", "'w'", ...
Make batch files required for checking checksums from another machine.
[ "Make", "batch", "files", "required", "for", "checking", "checksums", "from", "another", "machine", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/utilities/src/d1_util/check_object_checksums.py#L113-L160
MarkusH/django-osm-field
osm_field/fields.py
LatitudeField.formfield
def formfield(self, **kwargs): """ :returns: A :class:`~django.forms.FloatField` with ``max_value`` 90 and ``min_value`` -90. """ kwargs.update({ 'max_value': 90, 'min_value': -90, }) return super(LatitudeField, self).formfield(**kwargs...
python
def formfield(self, **kwargs): """ :returns: A :class:`~django.forms.FloatField` with ``max_value`` 90 and ``min_value`` -90. """ kwargs.update({ 'max_value': 90, 'min_value': -90, }) return super(LatitudeField, self).formfield(**kwargs...
[ "def", "formfield", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "{", "'max_value'", ":", "90", ",", "'min_value'", ":", "-", "90", ",", "}", ")", "return", "super", "(", "LatitudeField", ",", "self", ")", ".", "for...
:returns: A :class:`~django.forms.FloatField` with ``max_value`` 90 and ``min_value`` -90.
[ ":", "returns", ":", "A", ":", "class", ":", "~django", ".", "forms", ".", "FloatField", "with", "max_value", "90", "and", "min_value", "-", "90", "." ]
train
https://github.com/MarkusH/django-osm-field/blob/00e6613a93162e781a2b7d404b582ce83802f19a/osm_field/fields.py#L78-L87
MarkusH/django-osm-field
osm_field/fields.py
LongitudeField.formfield
def formfield(self, **kwargs): """ :returns: A :class:`~django.forms.FloatField` with ``max_value`` 180 and ``min_value`` -180. """ kwargs.update({ 'max_value': 180, 'min_value': -180, }) return super(LongitudeField, self).formfield(**k...
python
def formfield(self, **kwargs): """ :returns: A :class:`~django.forms.FloatField` with ``max_value`` 180 and ``min_value`` -180. """ kwargs.update({ 'max_value': 180, 'min_value': -180, }) return super(LongitudeField, self).formfield(**k...
[ "def", "formfield", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "{", "'max_value'", ":", "180", ",", "'min_value'", ":", "-", "180", ",", "}", ")", "return", "super", "(", "LongitudeField", ",", "self", ")", ".", "...
:returns: A :class:`~django.forms.FloatField` with ``max_value`` 180 and ``min_value`` -180.
[ ":", "returns", ":", "A", ":", "class", ":", "~django", ".", "forms", ".", "FloatField", "with", "max_value", "180", "and", "min_value", "-", "180", "." ]
train
https://github.com/MarkusH/django-osm-field/blob/00e6613a93162e781a2b7d404b582ce83802f19a/osm_field/fields.py#L106-L115
MarkusH/django-osm-field
osm_field/fields.py
OSMField.formfield
def formfield(self, **kwargs): """ :returns: A :class:`~osm_field.forms.OSMFormField` with a :class:`~osm_field.widgets.OSMWidget`. """ widget_kwargs = { 'lat_field': self.latitude_field_name, 'lon_field': self.longitude_field_name, } ...
python
def formfield(self, **kwargs): """ :returns: A :class:`~osm_field.forms.OSMFormField` with a :class:`~osm_field.widgets.OSMWidget`. """ widget_kwargs = { 'lat_field': self.latitude_field_name, 'lon_field': self.longitude_field_name, } ...
[ "def", "formfield", "(", "self", ",", "*", "*", "kwargs", ")", ":", "widget_kwargs", "=", "{", "'lat_field'", ":", "self", ".", "latitude_field_name", ",", "'lon_field'", ":", "self", ".", "longitude_field_name", ",", "}", "if", "self", ".", "data_field_name...
:returns: A :class:`~osm_field.forms.OSMFormField` with a :class:`~osm_field.widgets.OSMWidget`.
[ ":", "returns", ":", "A", ":", "class", ":", "~osm_field", ".", "forms", ".", "OSMFormField", "with", "a", ":", "class", ":", "~osm_field", ".", "widgets", ".", "OSMWidget", "." ]
train
https://github.com/MarkusH/django-osm-field/blob/00e6613a93162e781a2b7d404b582ce83802f19a/osm_field/fields.py#L199-L218
MarkusH/django-osm-field
osm_field/fields.py
OSMField.latitude_field_name
def latitude_field_name(self): """ The name of the related :class:`LatitudeField`. """ if self._lat_field_name is None: self._lat_field_name = self.name + '_lat' return self._lat_field_name
python
def latitude_field_name(self): """ The name of the related :class:`LatitudeField`. """ if self._lat_field_name is None: self._lat_field_name = self.name + '_lat' return self._lat_field_name
[ "def", "latitude_field_name", "(", "self", ")", ":", "if", "self", ".", "_lat_field_name", "is", "None", ":", "self", ".", "_lat_field_name", "=", "self", ".", "name", "+", "'_lat'", "return", "self", ".", "_lat_field_name" ]
The name of the related :class:`LatitudeField`.
[ "The", "name", "of", "the", "related", ":", "class", ":", "LatitudeField", "." ]
train
https://github.com/MarkusH/django-osm-field/blob/00e6613a93162e781a2b7d404b582ce83802f19a/osm_field/fields.py#L221-L227
MarkusH/django-osm-field
osm_field/fields.py
OSMField.longitude_field_name
def longitude_field_name(self): """ The name of the related :class:`LongitudeField`. """ if self._lon_field_name is None: self._lon_field_name = self.name + '_lon' return self._lon_field_name
python
def longitude_field_name(self): """ The name of the related :class:`LongitudeField`. """ if self._lon_field_name is None: self._lon_field_name = self.name + '_lon' return self._lon_field_name
[ "def", "longitude_field_name", "(", "self", ")", ":", "if", "self", ".", "_lon_field_name", "is", "None", ":", "self", ".", "_lon_field_name", "=", "self", ".", "name", "+", "'_lon'", "return", "self", ".", "_lon_field_name" ]
The name of the related :class:`LongitudeField`.
[ "The", "name", "of", "the", "related", ":", "class", ":", "LongitudeField", "." ]
train
https://github.com/MarkusH/django-osm-field/blob/00e6613a93162e781a2b7d404b582ce83802f19a/osm_field/fields.py#L230-L236
genialis/resolwe
resolwe/flow/migrations/0005_data_dependency_3.py
update_dependency_kinds
def update_dependency_kinds(apps, schema_editor): """Update historical dependency kinds as they may be wrong.""" DataDependency = apps.get_model('flow', 'DataDependency') for dependency in DataDependency.objects.all(): # Assume dependency is of subprocess kind. dependency.kind = 'subprocess'...
python
def update_dependency_kinds(apps, schema_editor): """Update historical dependency kinds as they may be wrong.""" DataDependency = apps.get_model('flow', 'DataDependency') for dependency in DataDependency.objects.all(): # Assume dependency is of subprocess kind. dependency.kind = 'subprocess'...
[ "def", "update_dependency_kinds", "(", "apps", ",", "schema_editor", ")", ":", "DataDependency", "=", "apps", ".", "get_model", "(", "'flow'", ",", "'DataDependency'", ")", "for", "dependency", "in", "DataDependency", ".", "objects", ".", "all", "(", ")", ":",...
Update historical dependency kinds as they may be wrong.
[ "Update", "historical", "dependency", "kinds", "as", "they", "may", "be", "wrong", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/migrations/0005_data_dependency_3.py#L10-L35
genialis/resolwe
resolwe/flow/expression_engines/jinja/__init__.py
Environment.escape
def escape(self, value): """Escape given value.""" value = soft_unicode(value) if self._engine._escape is None: # pylint: disable=protected-access return value return self._engine._escape(value)
python
def escape(self, value): """Escape given value.""" value = soft_unicode(value) if self._engine._escape is None: # pylint: disable=protected-access return value return self._engine._escape(value)
[ "def", "escape", "(", "self", ",", "value", ")", ":", "value", "=", "soft_unicode", "(", "value", ")", "if", "self", ".", "_engine", ".", "_escape", "is", "None", ":", "# pylint: disable=protected-access", "return", "value", "return", "self", ".", "_engine",...
Escape given value.
[ "Escape", "given", "value", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/__init__.py#L70-L77
genialis/resolwe
resolwe/flow/expression_engines/jinja/__init__.py
ExpressionEngine._wrap_jinja_filter
def _wrap_jinja_filter(self, function): """Propagate exceptions as undefined values filter.""" def wrapper(*args, **kwargs): """Filter wrapper.""" try: return function(*args, **kwargs) except Exception: # pylint: disable=broad-except r...
python
def _wrap_jinja_filter(self, function): """Propagate exceptions as undefined values filter.""" def wrapper(*args, **kwargs): """Filter wrapper.""" try: return function(*args, **kwargs) except Exception: # pylint: disable=broad-except r...
[ "def", "_wrap_jinja_filter", "(", "self", ",", "function", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"Filter wrapper.\"\"\"", "try", ":", "return", "function", "(", "*", "args", ",", "*", "*", "kwargs", ")", ...
Propagate exceptions as undefined values filter.
[ "Propagate", "exceptions", "as", "undefined", "values", "filter", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/__init__.py#L115-L129
genialis/resolwe
resolwe/flow/expression_engines/jinja/__init__.py
ExpressionEngine._register_custom_filters
def _register_custom_filters(self): """Register any custom filter modules.""" custom_filters = self.settings.get('CUSTOM_FILTERS', []) if not isinstance(custom_filters, list): raise KeyError("`CUSTOM_FILTERS` setting must be a list.") for filter_module_name in custom_filters...
python
def _register_custom_filters(self): """Register any custom filter modules.""" custom_filters = self.settings.get('CUSTOM_FILTERS', []) if not isinstance(custom_filters, list): raise KeyError("`CUSTOM_FILTERS` setting must be a list.") for filter_module_name in custom_filters...
[ "def", "_register_custom_filters", "(", "self", ")", ":", "custom_filters", "=", "self", ".", "settings", ".", "get", "(", "'CUSTOM_FILTERS'", ",", "[", "]", ")", "if", "not", "isinstance", "(", "custom_filters", ",", "list", ")", ":", "raise", "KeyError", ...
Register any custom filter modules.
[ "Register", "any", "custom", "filter", "modules", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/__init__.py#L131-L154
genialis/resolwe
resolwe/flow/expression_engines/jinja/__init__.py
ExpressionEngine._evaluation_context
def _evaluation_context(self, escape, safe_wrapper): """Configure the evaluation context.""" self._escape = escape self._safe_wrapper = safe_wrapper try: yield finally: self._escape = None self._safe_wrapper = None
python
def _evaluation_context(self, escape, safe_wrapper): """Configure the evaluation context.""" self._escape = escape self._safe_wrapper = safe_wrapper try: yield finally: self._escape = None self._safe_wrapper = None
[ "def", "_evaluation_context", "(", "self", ",", "escape", ",", "safe_wrapper", ")", ":", "self", ".", "_escape", "=", "escape", "self", ".", "_safe_wrapper", "=", "safe_wrapper", "try", ":", "yield", "finally", ":", "self", ".", "_escape", "=", "None", "se...
Configure the evaluation context.
[ "Configure", "the", "evaluation", "context", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/__init__.py#L157-L166
genialis/resolwe
resolwe/flow/expression_engines/jinja/__init__.py
ExpressionEngine.evaluate_block
def evaluate_block(self, template, context=None, escape=None, safe_wrapper=None): """Evaluate a template block.""" if context is None: context = {} try: with self._evaluation_context(escape, safe_wrapper): template = self._environment.from_string(template...
python
def evaluate_block(self, template, context=None, escape=None, safe_wrapper=None): """Evaluate a template block.""" if context is None: context = {} try: with self._evaluation_context(escape, safe_wrapper): template = self._environment.from_string(template...
[ "def", "evaluate_block", "(", "self", ",", "template", ",", "context", "=", "None", ",", "escape", "=", "None", ",", "safe_wrapper", "=", "None", ")", ":", "if", "context", "is", "None", ":", "context", "=", "{", "}", "try", ":", "with", "self", ".",...
Evaluate a template block.
[ "Evaluate", "a", "template", "block", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/__init__.py#L168-L180
genialis/resolwe
resolwe/flow/expression_engines/jinja/__init__.py
ExpressionEngine.evaluate_inline
def evaluate_inline(self, expression, context=None, escape=None, safe_wrapper=None): """Evaluate an inline expression.""" if context is None: context = {} try: with self._evaluation_context(escape, safe_wrapper): compiled = self._environment.compile_expre...
python
def evaluate_inline(self, expression, context=None, escape=None, safe_wrapper=None): """Evaluate an inline expression.""" if context is None: context = {} try: with self._evaluation_context(escape, safe_wrapper): compiled = self._environment.compile_expre...
[ "def", "evaluate_inline", "(", "self", ",", "expression", ",", "context", "=", "None", ",", "escape", "=", "None", ",", "safe_wrapper", "=", "None", ")", ":", "if", "context", "is", "None", ":", "context", "=", "{", "}", "try", ":", "with", "self", "...
Evaluate an inline expression.
[ "Evaluate", "an", "inline", "expression", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/expression_engines/jinja/__init__.py#L182-L192
DataONEorg/d1_python
dev_tools/src/d1_dev/util.py
update_module_file
def update_module_file(redbaron_tree, module_path, show_diff=False, dry_run=False): """Set show_diff to False to overwrite module_path with a new file generated from ``redbaron_tree``. Returns True if tree is different from source. """ with tempfile.NamedTemporaryFile() as tmp_file: tmp_fi...
python
def update_module_file(redbaron_tree, module_path, show_diff=False, dry_run=False): """Set show_diff to False to overwrite module_path with a new file generated from ``redbaron_tree``. Returns True if tree is different from source. """ with tempfile.NamedTemporaryFile() as tmp_file: tmp_fi...
[ "def", "update_module_file", "(", "redbaron_tree", ",", "module_path", ",", "show_diff", "=", "False", ",", "dry_run", "=", "False", ")", ":", "with", "tempfile", ".", "NamedTemporaryFile", "(", ")", "as", "tmp_file", ":", "tmp_file", ".", "write", "(", "red...
Set show_diff to False to overwrite module_path with a new file generated from ``redbaron_tree``. Returns True if tree is different from source.
[ "Set", "show_diff", "to", "False", "to", "overwrite", "module_path", "with", "a", "new", "file", "generated", "from", "redbaron_tree", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/util.py#L54-L71
DataONEorg/d1_python
dev_tools/src/d1_dev/util.py
find_repo_root_by_path
def find_repo_root_by_path(path): """Given a path to an item in a git repository, find the root of the repository.""" repo = git.Repo(path, search_parent_directories=True) repo_path = repo.git.rev_parse('--show-toplevel') logging.info('Repository: {}'.format(repo_path)) return repo_path
python
def find_repo_root_by_path(path): """Given a path to an item in a git repository, find the root of the repository.""" repo = git.Repo(path, search_parent_directories=True) repo_path = repo.git.rev_parse('--show-toplevel') logging.info('Repository: {}'.format(repo_path)) return repo_path
[ "def", "find_repo_root_by_path", "(", "path", ")", ":", "repo", "=", "git", ".", "Repo", "(", "path", ",", "search_parent_directories", "=", "True", ")", "repo_path", "=", "repo", ".", "git", ".", "rev_parse", "(", "'--show-toplevel'", ")", "logging", ".", ...
Given a path to an item in a git repository, find the root of the repository.
[ "Given", "a", "path", "to", "an", "item", "in", "a", "git", "repository", "find", "the", "root", "of", "the", "repository", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/dev_tools/src/d1_dev/util.py#L181-L186
DataONEorg/d1_python
client_cli/src/d1_cli/impl/operation_formatter.py
OperationFormatter._format_value
def _format_value(self, operation, key, indent): """A value that exists in the operation but has value None is displayed. A value that does not exist in the operation is left out entirely. The value name in the operation must match the value name in the template, but the location does n...
python
def _format_value(self, operation, key, indent): """A value that exists in the operation but has value None is displayed. A value that does not exist in the operation is left out entirely. The value name in the operation must match the value name in the template, but the location does n...
[ "def", "_format_value", "(", "self", ",", "operation", ",", "key", ",", "indent", ")", ":", "v", "=", "self", ".", "_find_value", "(", "operation", ",", "key", ")", "if", "v", "==", "\"NOT_FOUND\"", ":", "return", "[", "]", "if", "not", "isinstance", ...
A value that exists in the operation but has value None is displayed. A value that does not exist in the operation is left out entirely. The value name in the operation must match the value name in the template, but the location does not have to match.
[ "A", "value", "that", "exists", "in", "the", "operation", "but", "has", "value", "None", "is", "displayed", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/client_cli/src/d1_cli/impl/operation_formatter.py#L94-L121
DataONEorg/d1_python
gmn/src/d1_gmn/app/views/headers.py
add_cors_headers
def add_cors_headers(response, request): """Add Cross-Origin Resource Sharing (CORS) headers to response. - ``method_list`` is a list of HTTP methods that are allowed for the endpoint that was called. It should not include "OPTIONS", which is included automatically since it's allowed for all endpoi...
python
def add_cors_headers(response, request): """Add Cross-Origin Resource Sharing (CORS) headers to response. - ``method_list`` is a list of HTTP methods that are allowed for the endpoint that was called. It should not include "OPTIONS", which is included automatically since it's allowed for all endpoi...
[ "def", "add_cors_headers", "(", "response", ",", "request", ")", ":", "opt_method_list", "=", "\",\"", ".", "join", "(", "request", ".", "allowed_method_list", "+", "[", "\"OPTIONS\"", "]", ")", "response", "[", "\"Allow\"", "]", "=", "opt_method_list", "respo...
Add Cross-Origin Resource Sharing (CORS) headers to response. - ``method_list`` is a list of HTTP methods that are allowed for the endpoint that was called. It should not include "OPTIONS", which is included automatically since it's allowed for all endpoints.
[ "Add", "Cross", "-", "Origin", "Resource", "Sharing", "(", "CORS", ")", "headers", "to", "response", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/views/headers.py#L69-L82
genialis/resolwe
resolwe/process/runtime.py
Process.run_process
def run_process(self, slug, inputs): """Run a new process from a running process.""" def export_files(value): """Export input files of spawned process.""" if isinstance(value, str) and os.path.isfile(value): # TODO: Use the protocol to export files and get the ...
python
def run_process(self, slug, inputs): """Run a new process from a running process.""" def export_files(value): """Export input files of spawned process.""" if isinstance(value, str) and os.path.isfile(value): # TODO: Use the protocol to export files and get the ...
[ "def", "run_process", "(", "self", ",", "slug", ",", "inputs", ")", ":", "def", "export_files", "(", "value", ")", ":", "\"\"\"Export input files of spawned process.\"\"\"", "if", "isinstance", "(", "value", ",", "str", ")", "and", "os", ".", "path", ".", "i...
Run a new process from a running process.
[ "Run", "a", "new", "process", "from", "a", "running", "process", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/runtime.py#L177-L193
genialis/resolwe
resolwe/process/runtime.py
Process.info
def info(self, *args): """Log informational message.""" report = resolwe_runtime_utils.info(' '.join([str(x) for x in args])) # TODO: Use the protocol to report progress. print(report)
python
def info(self, *args): """Log informational message.""" report = resolwe_runtime_utils.info(' '.join([str(x) for x in args])) # TODO: Use the protocol to report progress. print(report)
[ "def", "info", "(", "self", ",", "*", "args", ")", ":", "report", "=", "resolwe_runtime_utils", ".", "info", "(", "' '", ".", "join", "(", "[", "str", "(", "x", ")", "for", "x", "in", "args", "]", ")", ")", "# TODO: Use the protocol to report progress.",...
Log informational message.
[ "Log", "informational", "message", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/runtime.py#L204-L208
genialis/resolwe
resolwe/process/runtime.py
Process.get_data_id_by_slug
def get_data_id_by_slug(self, slug): """Find data object ID for given slug. This method queries the Resolwe API and requires network access. """ resolwe_host = os.environ.get('RESOLWE_HOST_URL') url = urllib.parse.urljoin(resolwe_host, '/api/data?slug={}&fields=id'.format(slug))...
python
def get_data_id_by_slug(self, slug): """Find data object ID for given slug. This method queries the Resolwe API and requires network access. """ resolwe_host = os.environ.get('RESOLWE_HOST_URL') url = urllib.parse.urljoin(resolwe_host, '/api/data?slug={}&fields=id'.format(slug))...
[ "def", "get_data_id_by_slug", "(", "self", ",", "slug", ")", ":", "resolwe_host", "=", "os", ".", "environ", ".", "get", "(", "'RESOLWE_HOST_URL'", ")", "url", "=", "urllib", ".", "parse", ".", "urljoin", "(", "resolwe_host", ",", "'/api/data?slug={}&fields=id...
Find data object ID for given slug. This method queries the Resolwe API and requires network access.
[ "Find", "data", "object", "ID", "for", "given", "slug", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/runtime.py#L222-L238
genialis/resolwe
resolwe/process/runtime.py
Process.requirements
def requirements(self): """Process requirements.""" class dotdict(dict): # pylint: disable=invalid-name """Dot notation access to dictionary attributes.""" def __getattr__(self, attr): value = self.get(attr) return dotdict(value) if isinstance(va...
python
def requirements(self): """Process requirements.""" class dotdict(dict): # pylint: disable=invalid-name """Dot notation access to dictionary attributes.""" def __getattr__(self, attr): value = self.get(attr) return dotdict(value) if isinstance(va...
[ "def", "requirements", "(", "self", ")", ":", "class", "dotdict", "(", "dict", ")", ":", "# pylint: disable=invalid-name", "\"\"\"Dot notation access to dictionary attributes.\"\"\"", "def", "__getattr__", "(", "self", ",", "attr", ")", ":", "value", "=", "self", "....
Process requirements.
[ "Process", "requirements", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/runtime.py#L245-L254
genialis/resolwe
resolwe/process/runtime.py
Process.start
def start(self, inputs): """Start the process. :param inputs: An instance of `Inputs` describing the process inputs :return: An instance of `Outputs` describing the process outputs """ self.logger.info("Process is starting") outputs = Outputs(self._meta.outputs) ...
python
def start(self, inputs): """Start the process. :param inputs: An instance of `Inputs` describing the process inputs :return: An instance of `Outputs` describing the process outputs """ self.logger.info("Process is starting") outputs = Outputs(self._meta.outputs) ...
[ "def", "start", "(", "self", ",", "inputs", ")", ":", "self", ".", "logger", ".", "info", "(", "\"Process is starting\"", ")", "outputs", "=", "Outputs", "(", "self", ".", "_meta", ".", "outputs", ")", "self", ".", "logger", ".", "info", "(", "\"Proces...
Start the process. :param inputs: An instance of `Inputs` describing the process inputs :return: An instance of `Outputs` describing the process outputs
[ "Start", "the", "process", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/process/runtime.py#L256-L279
genialis/resolwe
resolwe/flow/execution_engines/python/__init__.py
ExecutionEngine.discover_process
def discover_process(self, path): """Perform process discovery in given path. This method will be called during process registration and should return a list of dictionaries with discovered process schemas. """ if not path.lower().endswith('.py'): return [] ...
python
def discover_process(self, path): """Perform process discovery in given path. This method will be called during process registration and should return a list of dictionaries with discovered process schemas. """ if not path.lower().endswith('.py'): return [] ...
[ "def", "discover_process", "(", "self", ",", "path", ")", ":", "if", "not", "path", ".", "lower", "(", ")", ".", "endswith", "(", "'.py'", ")", ":", "return", "[", "]", "parser", "=", "SafeParser", "(", "open", "(", "path", ")", ".", "read", "(", ...
Perform process discovery in given path. This method will be called during process registration and should return a list of dictionaries with discovered process schemas.
[ "Perform", "process", "discovery", "in", "given", "path", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/python/__init__.py#L30-L42
genialis/resolwe
resolwe/flow/execution_engines/python/__init__.py
ExecutionEngine.evaluate
def evaluate(self, data): """Evaluate the code needed to compute a given Data object.""" return 'PYTHONPATH="{runtime}" python3 -u -m resolwe.process {program} --slug {slug} --inputs {inputs}'.format( runtime=PYTHON_RUNTIME_VOLUME, program=PYTHON_PROGRAM_VOLUME, slug=...
python
def evaluate(self, data): """Evaluate the code needed to compute a given Data object.""" return 'PYTHONPATH="{runtime}" python3 -u -m resolwe.process {program} --slug {slug} --inputs {inputs}'.format( runtime=PYTHON_RUNTIME_VOLUME, program=PYTHON_PROGRAM_VOLUME, slug=...
[ "def", "evaluate", "(", "self", ",", "data", ")", ":", "return", "'PYTHONPATH=\"{runtime}\" python3 -u -m resolwe.process {program} --slug {slug} --inputs {inputs}'", ".", "format", "(", "runtime", "=", "PYTHON_RUNTIME_VOLUME", ",", "program", "=", "PYTHON_PROGRAM_VOLUME", ",...
Evaluate the code needed to compute a given Data object.
[ "Evaluate", "the", "code", "needed", "to", "compute", "a", "given", "Data", "object", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/python/__init__.py#L44-L51
genialis/resolwe
resolwe/flow/execution_engines/python/__init__.py
ExecutionEngine.prepare_runtime
def prepare_runtime(self, runtime_dir, data): """Prepare runtime directory.""" # Copy over Python process runtime (resolwe.process). import resolwe.process as runtime_package src_dir = os.path.dirname(inspect.getsourcefile(runtime_package)) dest_package_dir = os.path.join(runtim...
python
def prepare_runtime(self, runtime_dir, data): """Prepare runtime directory.""" # Copy over Python process runtime (resolwe.process). import resolwe.process as runtime_package src_dir = os.path.dirname(inspect.getsourcefile(runtime_package)) dest_package_dir = os.path.join(runtim...
[ "def", "prepare_runtime", "(", "self", ",", "runtime_dir", ",", "data", ")", ":", "# Copy over Python process runtime (resolwe.process).", "import", "resolwe", ".", "process", "as", "runtime_package", "src_dir", "=", "os", ".", "path", ".", "dirname", "(", "inspect"...
Prepare runtime directory.
[ "Prepare", "runtime", "directory", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/python/__init__.py#L53-L96
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
get_subject_with_local_validation
def get_subject_with_local_validation(jwt_bu64, cert_obj): """Validate the JWT and return the subject it contains. - The JWT is validated by checking that it was signed with a CN certificate. - The returned subject can be trusted for authz and authn operations. - Possible validation errors include: ...
python
def get_subject_with_local_validation(jwt_bu64, cert_obj): """Validate the JWT and return the subject it contains. - The JWT is validated by checking that it was signed with a CN certificate. - The returned subject can be trusted for authz and authn operations. - Possible validation errors include: ...
[ "def", "get_subject_with_local_validation", "(", "jwt_bu64", ",", "cert_obj", ")", ":", "try", ":", "jwt_dict", "=", "validate_and_decode", "(", "jwt_bu64", ",", "cert_obj", ")", "except", "JwtException", "as", "e", ":", "return", "log_jwt_bu64_info", "(", "loggin...
Validate the JWT and return the subject it contains. - The JWT is validated by checking that it was signed with a CN certificate. - The returned subject can be trusted for authz and authn operations. - Possible validation errors include: - A trusted (TLS/SSL) connection could not be made to the C...
[ "Validate", "the", "JWT", "and", "return", "the", "subject", "it", "contains", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L54-L88
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
get_subject_with_remote_validation
def get_subject_with_remote_validation(jwt_bu64, base_url): """Same as get_subject_with_local_validation() except that the signing certificate is automatically downloaded from the CN. - Additional possible validations errors: - The certificate could not be retrieved from the root CN. """ ce...
python
def get_subject_with_remote_validation(jwt_bu64, base_url): """Same as get_subject_with_local_validation() except that the signing certificate is automatically downloaded from the CN. - Additional possible validations errors: - The certificate could not be retrieved from the root CN. """ ce...
[ "def", "get_subject_with_remote_validation", "(", "jwt_bu64", ",", "base_url", ")", ":", "cert_obj", "=", "d1_common", ".", "cert", ".", "x509", ".", "download_as_obj", "(", "base_url", ")", "return", "get_subject_with_local_validation", "(", "jwt_bu64", ",", "cert_...
Same as get_subject_with_local_validation() except that the signing certificate is automatically downloaded from the CN. - Additional possible validations errors: - The certificate could not be retrieved from the root CN.
[ "Same", "as", "get_subject_with_local_validation", "()", "except", "that", "the", "signing", "certificate", "is", "automatically", "downloaded", "from", "the", "CN", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L91-L101
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
get_subject_with_file_validation
def get_subject_with_file_validation(jwt_bu64, cert_path): """Same as get_subject_with_local_validation() except that the signing certificate is read from a local PEM file.""" cert_obj = d1_common.cert.x509.deserialize_pem_file(cert_path) return get_subject_with_local_validation(jwt_bu64, cert_obj)
python
def get_subject_with_file_validation(jwt_bu64, cert_path): """Same as get_subject_with_local_validation() except that the signing certificate is read from a local PEM file.""" cert_obj = d1_common.cert.x509.deserialize_pem_file(cert_path) return get_subject_with_local_validation(jwt_bu64, cert_obj)
[ "def", "get_subject_with_file_validation", "(", "jwt_bu64", ",", "cert_path", ")", ":", "cert_obj", "=", "d1_common", ".", "cert", ".", "x509", ".", "deserialize_pem_file", "(", "cert_path", ")", "return", "get_subject_with_local_validation", "(", "jwt_bu64", ",", "...
Same as get_subject_with_local_validation() except that the signing certificate is read from a local PEM file.
[ "Same", "as", "get_subject_with_local_validation", "()", "except", "that", "the", "signing", "certificate", "is", "read", "from", "a", "local", "PEM", "file", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L104-L108
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
get_subject_without_validation
def get_subject_without_validation(jwt_bu64): """Extract subject from the JWT without validating the JWT. - The extracted subject cannot be trusted for authn or authz. Args: jwt_bu64: bytes JWT, encoded using a a URL safe flavor of Base64. Returns: str: The subject contained in th...
python
def get_subject_without_validation(jwt_bu64): """Extract subject from the JWT without validating the JWT. - The extracted subject cannot be trusted for authn or authz. Args: jwt_bu64: bytes JWT, encoded using a a URL safe flavor of Base64. Returns: str: The subject contained in th...
[ "def", "get_subject_without_validation", "(", "jwt_bu64", ")", ":", "try", ":", "jwt_dict", "=", "get_jwt_dict", "(", "jwt_bu64", ")", "except", "JwtException", "as", "e", ":", "return", "log_jwt_bu64_info", "(", "logging", ".", "error", ",", "str", "(", "e", ...
Extract subject from the JWT without validating the JWT. - The extracted subject cannot be trusted for authn or authz. Args: jwt_bu64: bytes JWT, encoded using a a URL safe flavor of Base64. Returns: str: The subject contained in the JWT.
[ "Extract", "subject", "from", "the", "JWT", "without", "validating", "the", "JWT", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L111-L131
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
get_jwt_dict
def get_jwt_dict(jwt_bu64): """Parse Base64 encoded JWT and return as a dict. - JWTs contain a set of values serialized to a JSON dict. This decodes the JWT and returns it as a dict containing Unicode strings. - In addition, a SHA1 hash is added to the dict for convenience. Args: jwt_bu64:...
python
def get_jwt_dict(jwt_bu64): """Parse Base64 encoded JWT and return as a dict. - JWTs contain a set of values serialized to a JSON dict. This decodes the JWT and returns it as a dict containing Unicode strings. - In addition, a SHA1 hash is added to the dict for convenience. Args: jwt_bu64:...
[ "def", "get_jwt_dict", "(", "jwt_bu64", ")", ":", "jwt_tup", "=", "get_jwt_tup", "(", "jwt_bu64", ")", "try", ":", "jwt_dict", "=", "json", ".", "loads", "(", "jwt_tup", "[", "0", "]", ".", "decode", "(", "'utf-8'", ")", ")", "jwt_dict", ".", "update",...
Parse Base64 encoded JWT and return as a dict. - JWTs contain a set of values serialized to a JSON dict. This decodes the JWT and returns it as a dict containing Unicode strings. - In addition, a SHA1 hash is added to the dict for convenience. Args: jwt_bu64: bytes JWT, encoded using a...
[ "Parse", "Base64", "encoded", "JWT", "and", "return", "as", "a", "dict", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L181-L203
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
validate_and_decode
def validate_and_decode(jwt_bu64, cert_obj): """Validate the JWT and return as a dict. - JWTs contain a set of values serialized to a JSON dict. This decodes the JWT and returns it as a dict. Args: jwt_bu64: bytes The JWT encoded using a a URL safe flavor of Base64. cert_obj: cr...
python
def validate_and_decode(jwt_bu64, cert_obj): """Validate the JWT and return as a dict. - JWTs contain a set of values serialized to a JSON dict. This decodes the JWT and returns it as a dict. Args: jwt_bu64: bytes The JWT encoded using a a URL safe flavor of Base64. cert_obj: cr...
[ "def", "validate_and_decode", "(", "jwt_bu64", ",", "cert_obj", ")", ":", "try", ":", "return", "jwt", ".", "decode", "(", "jwt_bu64", ".", "strip", "(", ")", ",", "cert_obj", ".", "public_key", "(", ")", ",", "algorithms", "=", "[", "'RS256'", "]", ",...
Validate the JWT and return as a dict. - JWTs contain a set of values serialized to a JSON dict. This decodes the JWT and returns it as a dict. Args: jwt_bu64: bytes The JWT encoded using a a URL safe flavor of Base64. cert_obj: cryptography.Certificate Public certificate us...
[ "Validate", "the", "JWT", "and", "return", "as", "a", "dict", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L206-L231
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
log_jwt_dict_info
def log_jwt_dict_info(log, msg_str, jwt_dict): """Dump JWT to log. Args: log: Logger Logger to which to write the message. msg_str: str A message to write to the log before the JWT values. jwt_dict: dict JWT containing values to log. Returns: None """...
python
def log_jwt_dict_info(log, msg_str, jwt_dict): """Dump JWT to log. Args: log: Logger Logger to which to write the message. msg_str: str A message to write to the log before the JWT values. jwt_dict: dict JWT containing values to log. Returns: None """...
[ "def", "log_jwt_dict_info", "(", "log", ",", "msg_str", ",", "jwt_dict", ")", ":", "d", "=", "ts_to_str", "(", "jwt_dict", ")", "# Log known items in specific order, then the rest just sorted", "log_list", "=", "[", "(", "b", ",", "d", ".", "pop", "(", "a", ")...
Dump JWT to log. Args: log: Logger Logger to which to write the message. msg_str: str A message to write to the log before the JWT values. jwt_dict: dict JWT containing values to log. Returns: None
[ "Dump", "JWT", "to", "log", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L234-L261
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
ts_to_str
def ts_to_str(jwt_dict): """Convert timestamps in JWT to human readable dates. Args: jwt_dict: dict JWT with some keys containing timestamps. Returns: dict: Copy of input dict where timestamps have been replaced with human readable dates. """ d = ts_to_dt(jwt_dict) f...
python
def ts_to_str(jwt_dict): """Convert timestamps in JWT to human readable dates. Args: jwt_dict: dict JWT with some keys containing timestamps. Returns: dict: Copy of input dict where timestamps have been replaced with human readable dates. """ d = ts_to_dt(jwt_dict) f...
[ "def", "ts_to_str", "(", "jwt_dict", ")", ":", "d", "=", "ts_to_dt", "(", "jwt_dict", ")", "for", "k", ",", "v", "in", "list", "(", "d", ".", "items", "(", ")", ")", ":", "if", "isinstance", "(", "v", ",", "datetime", ".", "datetime", ")", ":", ...
Convert timestamps in JWT to human readable dates. Args: jwt_dict: dict JWT with some keys containing timestamps. Returns: dict: Copy of input dict where timestamps have been replaced with human readable dates.
[ "Convert", "timestamps", "in", "JWT", "to", "human", "readable", "dates", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L284-L300
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
ts_to_dt
def ts_to_dt(jwt_dict): """Convert timestamps in JWT to datetime objects. Args: jwt_dict: dict JWT with some keys containing timestamps. Returns: dict: Copy of input dict where timestamps have been replaced with datetime.datetime() objects. """ d = jwt_dict.copy() fo...
python
def ts_to_dt(jwt_dict): """Convert timestamps in JWT to datetime objects. Args: jwt_dict: dict JWT with some keys containing timestamps. Returns: dict: Copy of input dict where timestamps have been replaced with datetime.datetime() objects. """ d = jwt_dict.copy() fo...
[ "def", "ts_to_dt", "(", "jwt_dict", ")", ":", "d", "=", "jwt_dict", ".", "copy", "(", ")", "for", "k", ",", "v", "in", "[", "v", "[", ":", "2", "]", "for", "v", "in", "CLAIM_LIST", "if", "v", "[", "2", "]", "]", ":", "if", "k", "in", "jwt_d...
Convert timestamps in JWT to datetime objects. Args: jwt_dict: dict JWT with some keys containing timestamps. Returns: dict: Copy of input dict where timestamps have been replaced with datetime.datetime() objects.
[ "Convert", "timestamps", "in", "JWT", "to", "datetime", "objects", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L303-L319
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
encode_bu64
def encode_bu64(b): """Encode bytes to a URL safe flavor of Base64 used by JWTs. - Reverse of decode_bu64(). Args: b: bytes Bytes to Base64 encode. Returns: bytes: URL safe Base64 encoded version of input. """ s = base64.standard_b64encode(b) s = s.rstrip('=') s =...
python
def encode_bu64(b): """Encode bytes to a URL safe flavor of Base64 used by JWTs. - Reverse of decode_bu64(). Args: b: bytes Bytes to Base64 encode. Returns: bytes: URL safe Base64 encoded version of input. """ s = base64.standard_b64encode(b) s = s.rstrip('=') s =...
[ "def", "encode_bu64", "(", "b", ")", ":", "s", "=", "base64", ".", "standard_b64encode", "(", "b", ")", "s", "=", "s", ".", "rstrip", "(", "'='", ")", "s", "=", "s", ".", "replace", "(", "'+'", ",", "'-'", ")", "s", "=", "s", ".", "replace", ...
Encode bytes to a URL safe flavor of Base64 used by JWTs. - Reverse of decode_bu64(). Args: b: bytes Bytes to Base64 encode. Returns: bytes: URL safe Base64 encoded version of input.
[ "Encode", "bytes", "to", "a", "URL", "safe", "flavor", "of", "Base64", "used", "by", "JWTs", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L322-L339
DataONEorg/d1_python
lib_common/src/d1_common/cert/jwt.py
decode_bu64
def decode_bu64(b): """Encode bytes to a URL safe flavor of Base64 used by JWTs. - Reverse of encode_bu64(). Args: b: bytes URL safe Base64 encoded bytes to encode. Returns: bytes: Decoded bytes. """ s = b s = s.replace(b'-', b'+') s = s.replace(b'_', b'/') p ...
python
def decode_bu64(b): """Encode bytes to a URL safe flavor of Base64 used by JWTs. - Reverse of encode_bu64(). Args: b: bytes URL safe Base64 encoded bytes to encode. Returns: bytes: Decoded bytes. """ s = b s = s.replace(b'-', b'+') s = s.replace(b'_', b'/') p ...
[ "def", "decode_bu64", "(", "b", ")", ":", "s", "=", "b", "s", "=", "s", ".", "replace", "(", "b'-'", ",", "b'+'", ")", "s", "=", "s", ".", "replace", "(", "b'_'", ",", "b'/'", ")", "p", "=", "len", "(", "s", ")", "%", "4", "if", "p", "=="...
Encode bytes to a URL safe flavor of Base64 used by JWTs. - Reverse of encode_bu64(). Args: b: bytes URL safe Base64 encoded bytes to encode. Returns: bytes: Decoded bytes.
[ "Encode", "bytes", "to", "a", "URL", "safe", "flavor", "of", "Base64", "used", "by", "JWTs", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/jwt.py#L342-L367
genialis/resolwe
resolwe/flow/execution_engines/bash/__init__.py
ExecutionEngine.evaluate
def evaluate(self, data): """Evaluate the code needed to compute a given Data object.""" try: inputs = copy.deepcopy(data.input) hydrate_input_references(inputs, data.process.input_schema) hydrate_input_uploads(inputs, data.process.input_schema) # Include...
python
def evaluate(self, data): """Evaluate the code needed to compute a given Data object.""" try: inputs = copy.deepcopy(data.input) hydrate_input_references(inputs, data.process.input_schema) hydrate_input_uploads(inputs, data.process.input_schema) # Include...
[ "def", "evaluate", "(", "self", ",", "data", ")", ":", "try", ":", "inputs", "=", "copy", ".", "deepcopy", "(", "data", ".", "input", ")", "hydrate_input_references", "(", "inputs", ",", "data", ".", "process", ".", "input_schema", ")", "hydrate_input_uplo...
Evaluate the code needed to compute a given Data object.
[ "Evaluate", "the", "code", "needed", "to", "compute", "a", "given", "Data", "object", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/bash/__init__.py#L54-L87
genialis/resolwe
resolwe/flow/execution_engines/bash/__init__.py
ExecutionEngine._escape
def _escape(self, value): """Escape given value unless it is safe.""" if isinstance(value, SafeString): return value return shellescape.quote(value)
python
def _escape(self, value): """Escape given value unless it is safe.""" if isinstance(value, SafeString): return value return shellescape.quote(value)
[ "def", "_escape", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "SafeString", ")", ":", "return", "value", "return", "shellescape", ".", "quote", "(", "value", ")" ]
Escape given value unless it is safe.
[ "Escape", "given", "value", "unless", "it", "is", "safe", "." ]
train
https://github.com/genialis/resolwe/blob/f7bb54932c81ec0cfc5b5e80d238fceaeaa48d86/resolwe/flow/execution_engines/bash/__init__.py#L89-L94
DataONEorg/d1_python
gmn/src/d1_gmn/app/sciobj_store.py
open_sciobj_file_by_pid_ctx
def open_sciobj_file_by_pid_ctx(pid, write=False): """Open the file containing the Science Object bytes of ``pid`` in the default location within the tree of the local SciObj store. If ``write`` is True, the file is opened for writing and any missing directories are created. Return the file handle and ...
python
def open_sciobj_file_by_pid_ctx(pid, write=False): """Open the file containing the Science Object bytes of ``pid`` in the default location within the tree of the local SciObj store. If ``write`` is True, the file is opened for writing and any missing directories are created. Return the file handle and ...
[ "def", "open_sciobj_file_by_pid_ctx", "(", "pid", ",", "write", "=", "False", ")", ":", "abs_path", "=", "get_abs_sciobj_file_path_by_pid", "(", "pid", ")", "with", "open_sciobj_file_by_path_ctx", "(", "abs_path", ",", "write", ")", "as", "sciobj_file", ":", "yiel...
Open the file containing the Science Object bytes of ``pid`` in the default location within the tree of the local SciObj store. If ``write`` is True, the file is opened for writing and any missing directories are created. Return the file handle and file_url with the file location in a suitable form for...
[ "Open", "the", "file", "containing", "the", "Science", "Object", "bytes", "of", "pid", "in", "the", "default", "location", "within", "the", "tree", "of", "the", "local", "SciObj", "store", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sciobj_store.py#L74-L87
DataONEorg/d1_python
gmn/src/d1_gmn/app/sciobj_store.py
open_sciobj_file_by_path_ctx
def open_sciobj_file_by_path_ctx(abs_path, write=False): """Open the file containing the Science Object bytes at the custom location ``abs_path`` in the local filesystem. If ``write`` is True, the file is opened for writing and any missing directores are created. Return the file handle and file_url wit...
python
def open_sciobj_file_by_path_ctx(abs_path, write=False): """Open the file containing the Science Object bytes at the custom location ``abs_path`` in the local filesystem. If ``write`` is True, the file is opened for writing and any missing directores are created. Return the file handle and file_url wit...
[ "def", "open_sciobj_file_by_path_ctx", "(", "abs_path", ",", "write", "=", "False", ")", ":", "if", "write", ":", "d1_common", ".", "utils", ".", "filesystem", ".", "create_missing_directories_for_file", "(", "abs_path", ")", "try", ":", "with", "open", "(", "...
Open the file containing the Science Object bytes at the custom location ``abs_path`` in the local filesystem. If ``write`` is True, the file is opened for writing and any missing directores are created. Return the file handle and file_url with the file location in a suitable form for storing in the DB...
[ "Open", "the", "file", "containing", "the", "Science", "Object", "bytes", "at", "the", "custom", "location", "abs_path", "in", "the", "local", "filesystem", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sciobj_store.py#L91-L109
DataONEorg/d1_python
gmn/src/d1_gmn/app/sciobj_store.py
open_sciobj_file_by_pid
def open_sciobj_file_by_pid(pid, write=False): """Open the file containing the Science Object bytes at the custom location ``abs_path`` in the local filesystem for read.""" abs_path = get_abs_sciobj_file_path_by_pid(pid) if write: d1_common.utils.filesystem.create_missing_directories_for_file(ab...
python
def open_sciobj_file_by_pid(pid, write=False): """Open the file containing the Science Object bytes at the custom location ``abs_path`` in the local filesystem for read.""" abs_path = get_abs_sciobj_file_path_by_pid(pid) if write: d1_common.utils.filesystem.create_missing_directories_for_file(ab...
[ "def", "open_sciobj_file_by_pid", "(", "pid", ",", "write", "=", "False", ")", ":", "abs_path", "=", "get_abs_sciobj_file_path_by_pid", "(", "pid", ")", "if", "write", ":", "d1_common", ".", "utils", ".", "filesystem", ".", "create_missing_directories_for_file", "...
Open the file containing the Science Object bytes at the custom location ``abs_path`` in the local filesystem for read.
[ "Open", "the", "file", "containing", "the", "Science", "Object", "bytes", "at", "the", "custom", "location", "abs_path", "in", "the", "local", "filesystem", "for", "read", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sciobj_store.py#L134-L140
DataONEorg/d1_python
gmn/src/d1_gmn/app/sciobj_store.py
open_sciobj_file_by_path
def open_sciobj_file_by_path(abs_path, write=False): """Open a SciObj file for read or write. If opened for write, create any missing directories. For a SciObj stored in the default SciObj store, the path includes the PID hash based directory levels. This is the only method in GMN that opens SciObj fil...
python
def open_sciobj_file_by_path(abs_path, write=False): """Open a SciObj file for read or write. If opened for write, create any missing directories. For a SciObj stored in the default SciObj store, the path includes the PID hash based directory levels. This is the only method in GMN that opens SciObj fil...
[ "def", "open_sciobj_file_by_path", "(", "abs_path", ",", "write", "=", "False", ")", ":", "if", "write", ":", "d1_common", ".", "utils", ".", "filesystem", ".", "create_missing_directories_for_file", "(", "abs_path", ")", "return", "open", "(", "abs_path", ",", ...
Open a SciObj file for read or write. If opened for write, create any missing directories. For a SciObj stored in the default SciObj store, the path includes the PID hash based directory levels. This is the only method in GMN that opens SciObj files, so can be modified to customize the SciObj storage l...
[ "Open", "a", "SciObj", "file", "for", "read", "or", "write", ".", "If", "opened", "for", "write", "create", "any", "missing", "directories", ".", "For", "a", "SciObj", "stored", "in", "the", "default", "SciObj", "store", "the", "path", "includes", "the", ...
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sciobj_store.py#L143-L158
DataONEorg/d1_python
gmn/src/d1_gmn/app/sciobj_store.py
get_rel_sciobj_file_path
def get_rel_sciobj_file_path(pid): """Get the relative local path to the file holding an object's bytes. - The path is relative to settings.OBJECT_STORE_PATH - There is a one-to-one mapping between pid and path - The path is based on a SHA1 hash. It's now possible to craft SHA1 collisions, but it...
python
def get_rel_sciobj_file_path(pid): """Get the relative local path to the file holding an object's bytes. - The path is relative to settings.OBJECT_STORE_PATH - There is a one-to-one mapping between pid and path - The path is based on a SHA1 hash. It's now possible to craft SHA1 collisions, but it...
[ "def", "get_rel_sciobj_file_path", "(", "pid", ")", ":", "hash_str", "=", "hashlib", ".", "sha1", "(", "pid", ".", "encode", "(", "'utf-8'", ")", ")", ".", "hexdigest", "(", ")", "return", "os", ".", "path", ".", "join", "(", "hash_str", "[", ":", "2...
Get the relative local path to the file holding an object's bytes. - The path is relative to settings.OBJECT_STORE_PATH - There is a one-to-one mapping between pid and path - The path is based on a SHA1 hash. It's now possible to craft SHA1 collisions, but it's so unlikely that we ignore it for now ...
[ "Get", "the", "relative", "local", "path", "to", "the", "file", "holding", "an", "object", "s", "bytes", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sciobj_store.py#L161-L172
DataONEorg/d1_python
gmn/src/d1_gmn/app/sciobj_store.py
get_abs_sciobj_file_path_by_url
def get_abs_sciobj_file_path_by_url(file_url): """Get the absolute path to the file holding an object's bytes. - ``file_url`` is an absolute or relative file:// url as stored in the DB. """ assert_sciobj_store_exists() m = re.match(r'file://(.*?)/(.*)', file_url, re.IGNORECASE) if m.group(1) =...
python
def get_abs_sciobj_file_path_by_url(file_url): """Get the absolute path to the file holding an object's bytes. - ``file_url`` is an absolute or relative file:// url as stored in the DB. """ assert_sciobj_store_exists() m = re.match(r'file://(.*?)/(.*)', file_url, re.IGNORECASE) if m.group(1) =...
[ "def", "get_abs_sciobj_file_path_by_url", "(", "file_url", ")", ":", "assert_sciobj_store_exists", "(", ")", "m", "=", "re", ".", "match", "(", "r'file://(.*?)/(.*)'", ",", "file_url", ",", "re", ".", "IGNORECASE", ")", "if", "m", ".", "group", "(", "1", ")"...
Get the absolute path to the file holding an object's bytes. - ``file_url`` is an absolute or relative file:// url as stored in the DB.
[ "Get", "the", "absolute", "path", "to", "the", "file", "holding", "an", "object", "s", "bytes", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/sciobj_store.py#L254-L265
DataONEorg/d1_python
utilities/src/d1_util/find_gmn_instances.py
get_gmn_version
def get_gmn_version(base_url): """Return the version currently running on a GMN instance. (is_gmn, version_or_error) """ home_url = d1_common.url.joinPathElements(base_url, 'home') try: response = requests.get(home_url, verify=False) except requests.exceptions.ConnectionError as e: ...
python
def get_gmn_version(base_url): """Return the version currently running on a GMN instance. (is_gmn, version_or_error) """ home_url = d1_common.url.joinPathElements(base_url, 'home') try: response = requests.get(home_url, verify=False) except requests.exceptions.ConnectionError as e: ...
[ "def", "get_gmn_version", "(", "base_url", ")", ":", "home_url", "=", "d1_common", ".", "url", ".", "joinPathElements", "(", "base_url", ",", "'home'", ")", "try", ":", "response", "=", "requests", ".", "get", "(", "home_url", ",", "verify", "=", "False", ...
Return the version currently running on a GMN instance. (is_gmn, version_or_error)
[ "Return", "the", "version", "currently", "running", "on", "a", "GMN", "instance", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/utilities/src/d1_util/find_gmn_instances.py#L179-L199
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
extract_subjects
def extract_subjects(subject_info_xml, primary_str): """Extract a set of authenticated subjects from a DataONE SubjectInfo. - See subject_info_tree for details. Args: subject_info_xml : str A SubjectInfo XML document. primary_str : str A DataONE subject, typically ...
python
def extract_subjects(subject_info_xml, primary_str): """Extract a set of authenticated subjects from a DataONE SubjectInfo. - See subject_info_tree for details. Args: subject_info_xml : str A SubjectInfo XML document. primary_str : str A DataONE subject, typically ...
[ "def", "extract_subjects", "(", "subject_info_xml", ",", "primary_str", ")", ":", "subject_info_pyxb", "=", "deserialize_subject_info", "(", "subject_info_xml", ")", "subject_info_tree", "=", "gen_subject_info_tree", "(", "subject_info_pyxb", ",", "primary_str", ")", "ret...
Extract a set of authenticated subjects from a DataONE SubjectInfo. - See subject_info_tree for details. Args: subject_info_xml : str A SubjectInfo XML document. primary_str : str A DataONE subject, typically a DataONE compliant serialization of the DN of t...
[ "Extract", "a", "set", "of", "authenticated", "subjects", "from", "a", "DataONE", "SubjectInfo", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L144-L249
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
deserialize_subject_info
def deserialize_subject_info(subject_info_xml): """Deserialize SubjectInfo XML doc to native object. Args: subject_info_xml: str SubjectInfo XML doc Returns: SubjectInfo PyXB object """ try: return d1_common.xml.deserialize(subject_info_xml) except ValueErr...
python
def deserialize_subject_info(subject_info_xml): """Deserialize SubjectInfo XML doc to native object. Args: subject_info_xml: str SubjectInfo XML doc Returns: SubjectInfo PyXB object """ try: return d1_common.xml.deserialize(subject_info_xml) except ValueErr...
[ "def", "deserialize_subject_info", "(", "subject_info_xml", ")", ":", "try", ":", "return", "d1_common", ".", "xml", ".", "deserialize", "(", "subject_info_xml", ")", "except", "ValueError", "as", "e", ":", "raise", "d1_common", ".", "types", ".", "exceptions", ...
Deserialize SubjectInfo XML doc to native object. Args: subject_info_xml: str SubjectInfo XML doc Returns: SubjectInfo PyXB object
[ "Deserialize", "SubjectInfo", "XML", "doc", "to", "native", "object", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L252-L271
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
gen_subject_info_tree
def gen_subject_info_tree(subject_info_pyxb, authn_subj, include_duplicates=False): """Convert the flat, self referential lists in the SubjectInfo to a tree structure. Args: subject_info_pyxb: SubjectInfo PyXB object authn_subj: str The authenticated subject that becomes the root s...
python
def gen_subject_info_tree(subject_info_pyxb, authn_subj, include_duplicates=False): """Convert the flat, self referential lists in the SubjectInfo to a tree structure. Args: subject_info_pyxb: SubjectInfo PyXB object authn_subj: str The authenticated subject that becomes the root s...
[ "def", "gen_subject_info_tree", "(", "subject_info_pyxb", ",", "authn_subj", ",", "include_duplicates", "=", "False", ")", ":", "class", "State", ":", "\"\"\"self.\"\"\"", "pass", "state", "=", "State", "(", ")", "state", ".", "subject_info_pyxb", "=", "subject_in...
Convert the flat, self referential lists in the SubjectInfo to a tree structure. Args: subject_info_pyxb: SubjectInfo PyXB object authn_subj: str The authenticated subject that becomes the root subject in the tree of subjects built from the SubjectInfo. Only su...
[ "Convert", "the", "flat", "self", "referential", "lists", "in", "the", "SubjectInfo", "to", "a", "tree", "structure", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L275-L318
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
_trim_tree
def _trim_tree(state): """Trim empty leaf nodes from the tree. - To simplify the tree conversion, empty nodes are added before it is known if they will contain items that connect back to the authenticated subject. If there are no connections, the nodes remain empty, which causes them to be removed ...
python
def _trim_tree(state): """Trim empty leaf nodes from the tree. - To simplify the tree conversion, empty nodes are added before it is known if they will contain items that connect back to the authenticated subject. If there are no connections, the nodes remain empty, which causes them to be removed ...
[ "def", "_trim_tree", "(", "state", ")", ":", "for", "n", "in", "list", "(", "state", ".", "tree", ".", "leaf_node_gen", ")", ":", "if", "n", ".", "type_str", "==", "TYPE_NODE_TAG", ":", "n", ".", "parent", ".", "child_list", ".", "remove", "(", "n", ...
Trim empty leaf nodes from the tree. - To simplify the tree conversion, empty nodes are added before it is known if they will contain items that connect back to the authenticated subject. If there are no connections, the nodes remain empty, which causes them to be removed here. - Removing a leaf n...
[ "Trim", "empty", "leaf", "nodes", "from", "the", "tree", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L378-L392
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
SubjectInfoNode.add_child
def add_child(self, label_str, type_str): """Add a child node.""" child_node = SubjectInfoNode(label_str, type_str) child_node.parent = self self.child_list.append(child_node) return child_node
python
def add_child(self, label_str, type_str): """Add a child node.""" child_node = SubjectInfoNode(label_str, type_str) child_node.parent = self self.child_list.append(child_node) return child_node
[ "def", "add_child", "(", "self", ",", "label_str", ",", "type_str", ")", ":", "child_node", "=", "SubjectInfoNode", "(", "label_str", ",", "type_str", ")", "child_node", ".", "parent", "=", "self", "self", ".", "child_list", ".", "append", "(", "child_node",...
Add a child node.
[ "Add", "a", "child", "node", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L413-L418
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
SubjectInfoNode.get_path_str
def get_path_str(self, sep=os.path.sep, type_str=None): """Get path from root to this node. Args: sep: str One or more characters to insert between each element in the path. Defaults to "/" on Unix and "\" on Windows. type_str: SU...
python
def get_path_str(self, sep=os.path.sep, type_str=None): """Get path from root to this node. Args: sep: str One or more characters to insert between each element in the path. Defaults to "/" on Unix and "\" on Windows. type_str: SU...
[ "def", "get_path_str", "(", "self", ",", "sep", "=", "os", ".", "path", ".", "sep", ",", "type_str", "=", "None", ")", ":", "return", "sep", ".", "join", "(", "list", "(", "reversed", "(", "[", "v", ".", "label_str", "for", "v", "in", "self", "."...
Get path from root to this node. Args: sep: str One or more characters to insert between each element in the path. Defaults to "/" on Unix and "\" on Windows. type_str: SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include ...
[ "Get", "path", "from", "root", "to", "this", "node", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L452-L478
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
SubjectInfoNode.get_leaf_node_path_list
def get_leaf_node_path_list(self, sep=os.path.sep, type_str=None): """Get paths for all leaf nodes for the tree rooted at this node. Args: sep: str One or more characters to insert between each element in the path. Defaults to "/" on Unix and "\" on Windows. ...
python
def get_leaf_node_path_list(self, sep=os.path.sep, type_str=None): """Get paths for all leaf nodes for the tree rooted at this node. Args: sep: str One or more characters to insert between each element in the path. Defaults to "/" on Unix and "\" on Windows. ...
[ "def", "get_leaf_node_path_list", "(", "self", ",", "sep", "=", "os", ".", "path", ".", "sep", ",", "type_str", "=", "None", ")", ":", "return", "[", "v", ".", "get_path_str", "(", "sep", ",", "type_str", ")", "for", "v", "in", "self", ".", "leaf_nod...
Get paths for all leaf nodes for the tree rooted at this node. Args: sep: str One or more characters to insert between each element in the path. Defaults to "/" on Unix and "\" on Windows. type_str: SUBJECT_NODE_TAG, TYPE_NODE_TAG or None...
[ "Get", "paths", "for", "all", "leaf", "nodes", "for", "the", "tree", "rooted", "at", "this", "node", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L480-L496
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
SubjectInfoNode.get_path_list
def get_path_list(self, type_str=None): """Get list of the labels of the nodes leading up to this node from the root. Args: type_str: SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include information from nodes of that type. Returns: ...
python
def get_path_list(self, type_str=None): """Get list of the labels of the nodes leading up to this node from the root. Args: type_str: SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include information from nodes of that type. Returns: ...
[ "def", "get_path_list", "(", "self", ",", "type_str", "=", "None", ")", ":", "return", "list", "(", "reversed", "(", "[", "v", ".", "label_str", "for", "v", "in", "self", ".", "parent_gen", "if", "type_str", "in", "(", "None", ",", "v", ".", "type_st...
Get list of the labels of the nodes leading up to this node from the root. Args: type_str: SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include information from nodes of that type. Returns: list of str: The labels of the nodes leading up...
[ "Get", "list", "of", "the", "labels", "of", "the", "nodes", "leading", "up", "to", "this", "node", "from", "the", "root", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L498-L514
DataONEorg/d1_python
lib_common/src/d1_common/cert/subject_info.py
SubjectInfoNode.get_label_set
def get_label_set(self, type_str=None): """Get a set of label_str for the tree rooted at this node. Args: type_str: SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include information from nodes of that type. Returns: set: The label...
python
def get_label_set(self, type_str=None): """Get a set of label_str for the tree rooted at this node. Args: type_str: SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include information from nodes of that type. Returns: set: The label...
[ "def", "get_label_set", "(", "self", ",", "type_str", "=", "None", ")", ":", "return", "{", "v", ".", "label_str", "for", "v", "in", "self", ".", "node_gen", "if", "type_str", "in", "(", "None", ",", "v", ".", "type_str", ")", "}" ]
Get a set of label_str for the tree rooted at this node. Args: type_str: SUBJECT_NODE_TAG, TYPE_NODE_TAG or None. If set, only include information from nodes of that type. Returns: set: The labels of the nodes leading up to this node from the roo...
[ "Get", "a", "set", "of", "label_str", "for", "the", "tree", "rooted", "at", "this", "node", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/cert/subject_info.py#L521-L533
DataONEorg/d1_python
lib_common/src/d1_common/utils/progress_logger.py
ProgressLogger.start_task_type
def start_task_type(self, task_type_str, total_task_count): """Call when about to start processing a new type of task, typically just before entering a loop that processes many task of the given type. Args: task_type_str (str): The name of the task, used as a dict ke...
python
def start_task_type(self, task_type_str, total_task_count): """Call when about to start processing a new type of task, typically just before entering a loop that processes many task of the given type. Args: task_type_str (str): The name of the task, used as a dict ke...
[ "def", "start_task_type", "(", "self", ",", "task_type_str", ",", "total_task_count", ")", ":", "assert", "(", "task_type_str", "not", "in", "self", ".", "_task_dict", ")", ",", "\"Task type has already been started\"", "self", ".", "_task_dict", "[", "task_type_str...
Call when about to start processing a new type of task, typically just before entering a loop that processes many task of the given type. Args: task_type_str (str): The name of the task, used as a dict key and printed in the progress updates. tot...
[ "Call", "when", "about", "to", "start", "processing", "a", "new", "type", "of", "task", "typically", "just", "before", "entering", "a", "loop", "that", "processes", "many", "task", "of", "the", "given", "type", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/utils/progress_logger.py#L126-L151
DataONEorg/d1_python
lib_common/src/d1_common/utils/progress_logger.py
ProgressLogger.end_task_type
def end_task_type(self, task_type_str): """Call when processing of all tasks of the given type is completed, typically just after exiting a loop that processes many tasks of the given type. Progress messages logged at intervals will typically not include the final entry which shows that...
python
def end_task_type(self, task_type_str): """Call when processing of all tasks of the given type is completed, typically just after exiting a loop that processes many tasks of the given type. Progress messages logged at intervals will typically not include the final entry which shows that...
[ "def", "end_task_type", "(", "self", ",", "task_type_str", ")", ":", "assert", "(", "task_type_str", "in", "self", ".", "_task_dict", ")", ",", "\"Task type has not been started yet: {}\"", ".", "format", "(", "task_type_str", ")", "self", ".", "_log_progress", "(...
Call when processing of all tasks of the given type is completed, typically just after exiting a loop that processes many tasks of the given type. Progress messages logged at intervals will typically not include the final entry which shows that processing is 100% complete, so a final progress m...
[ "Call", "when", "processing", "of", "all", "tasks", "of", "the", "given", "type", "is", "completed", "typically", "just", "after", "exiting", "a", "loop", "that", "processes", "many", "tasks", "of", "the", "given", "type", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/utils/progress_logger.py#L155-L168
DataONEorg/d1_python
lib_common/src/d1_common/utils/progress_logger.py
ProgressLogger.start_task
def start_task(self, task_type_str, current_task_index=None): """Call when processing is about to start on a single task of the given task type, typically at the top inside of the loop that processes the tasks. Args: task_type_str (str): The name of the task, used as...
python
def start_task(self, task_type_str, current_task_index=None): """Call when processing is about to start on a single task of the given task type, typically at the top inside of the loop that processes the tasks. Args: task_type_str (str): The name of the task, used as...
[ "def", "start_task", "(", "self", ",", "task_type_str", ",", "current_task_index", "=", "None", ")", ":", "assert", "(", "task_type_str", "in", "self", ".", "_task_dict", ")", ",", "\"Task type has not been started yet: {}\"", ".", "format", "(", "task_type_str", ...
Call when processing is about to start on a single task of the given task type, typically at the top inside of the loop that processes the tasks. Args: task_type_str (str): The name of the task, used as a dict key and printed in the progress updates. ...
[ "Call", "when", "processing", "is", "about", "to", "start", "on", "a", "single", "task", "of", "the", "given", "task", "type", "typically", "at", "the", "top", "inside", "of", "the", "loop", "that", "processes", "the", "tasks", "." ]
train
https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/lib_common/src/d1_common/utils/progress_logger.py#L171-L193