text
stringlengths
0
828
'subordinate_arrays': _map_relations(obj.subordinate_arrays, p, language),
'matches': obj.matches
}"
4576,"def collection_adapter(obj, request):
'''
Adapter for rendering a :class:`skosprovider.skos.Collection` to json.
:param skosprovider.skos.Collection obj: The collection to be rendered.
:rtype: :class:`dict`
'''
p = request.skos_registry.get_provider(obj.concept_scheme.uri)
language = request.params.get('language', request.locale_name)
label = obj.label(language)
return {
'id': obj.id,
'type': 'collection',
'uri': obj.uri,
'label': label.label if label else None,
'concept_scheme': {
'uri': obj.concept_scheme.uri,
'labels': obj.concept_scheme.labels
},
'labels': obj.labels,
'notes': obj.notes,
'sources': obj.sources,
'members': _map_relations(obj.members, p, language),
'member_of': _map_relations(obj.member_of, p, language),
'superordinates': _map_relations(obj.superordinates, p, language)
}"
4577,"def _map_relations(relations, p, language='any'):
'''
:param: :class:`list` relations: Relations to be mapped. These are
concept or collection id's.
:param: :class:`skosprovider.providers.VocabularyProvider` p: Provider
to look up id's.
:param string language: Language to render the relations' labels in
:rtype: :class:`list`
'''
ret = []
for r in relations:
c = p.get_by_id(r)
if c:
ret.append(_map_relation(c, language))
else:
log.warning(
'A relation references a concept or collection %d in provider %s that can not be found. Please check the integrity of your data.' %
(r, p.get_vocabulary_id())
)
return ret"
4578,"def _map_relation(c, language='any'):
""""""
Map related concept or collection, leaving out the relations.
:param c: the concept or collection to map
:param string language: Language to render the relation's label in
:rtype: :class:`dict`
""""""
label = c.label(language)
return {
'id': c.id,
'type': c.type,
'uri': c.uri,
'label': label.label if label else None
}"
4579,"def note_adapter(obj, request):
'''
Adapter for rendering a :class:`skosprovider.skos.Note` to json.
:param skosprovider.skos.Note obj: The note to be rendered.
:rtype: :class:`dict`
'''
return {
'note': obj.note,
'type': obj.type,
'language': obj.language,
'markup': obj.markup
}"
4580,"def tag(
log,
filepath,
tags=False,
rating=False,
wherefrom=False):
""""""Add tags and ratings to your macOS files and folders
**Key Arguments:**
- ``log`` -- logger
- ``filepath`` -- the path to the file needing tagged
- ``tags`` -- comma or space-separated string, or list of tags. Use `False` to leave file tags as they are. Use """" or [] to remove tags. Default *False*.
- ``rating`` -- a rating to add to the file. Use 0 to remove rating or `False` to leave file rating as it is. Default *False*.
- ``wherefrom`` -- add a URL to indicate where the file come from. Use `False` to leave file location as it is. Use """" to remove location. Default *False*.
**Return:**
- None
**Usage:**
To add any combination of tags, rating and a source URL to a file on macOS, use the following:
.. code-block:: python