Package: cs.tagset
Tags and sets of tags
withformatsupport and optional ontology information.Latest release 20240211:TagFile.parse_tag_line: recognise dotted_identifiers directly, avoids misparsing bare "nan" as float NaN.Tag.parse_value: BUGFIX parse - always to the primary types first (int, float) before trying any funny extra types.Seecs.fstagsfor support for applying these to filesystem objects
such as directories and files.Seecs.sqltagsfor support for databases of entities with tags,
not directly associated with filesystem objects.
This is suited to both log entries (entities with no "name")
and large collections of named entities;
both acceptTags and can be searched on that basis.All of the available complexity is optional:
you can useTags without bothering withTagSets
orTagsOntologys.This module contains the following main classes:Tag: an object with a.nameand optional.value(defaultNone)
and also an optional reference.ontologyfor associating semantics with tag values.
The.value, if notNone, will often be a string,
but may be any Python object.
If you're using these viacs.fstags,
the object will need to be JSON transcribeable.TagSet: adictsubclass representing a set ofTags
to associate with something;
it also has setlike.addand.discardmethods.
As such it only supports a singleTagfor a given tag name,
but that tag value can of course be a sequence or mapping
for more elaborate tag values.TagsOntology:
a mapping of type names toTagSets defining the type
and also to entries for the metadata for specific per-type values.Here's a simple example with someTags and aTagSet.>>> tags = TagSet()
>>> # add a "bare" Tag named 'blue' with no value
>>> tags.add('blue')
>>> # add a "topic=tagging" Tag
>>> tags.set('topic', 'tagging')
>>> # make a "subtopic" Tag and add it
>>> subtopic = Tag('subtopic', 'ontologies')
>>> tags.add(subtopic)
>>> # Tags have nice repr() and str()
>>> subtopic
Tag(name='subtopic',value='ontologies')
>>> print(subtopic)
subtopic=ontologies
>>> # a TagSet also has a nice repr() and str()
>>> tags
TagSet:{'blue': None, 'topic': 'tagging', 'subtopic': 'ontologies'}
>>> print(tags)
blue subtopic=ontologies topic=tagging
>>> tags2 = TagSet({'a': 1}, b=3, c=[1,2,3], d='dee')
>>> tags2
TagSet:{'a': 1, 'b': 3, 'c': [1, 2, 3], 'd': 'dee'}
>>> print(tags2)
a=1 b=3 c=[1,2,3] d=dee
>>> # since you can print a TagSet to a file as a line of text
>>> # you can get it back from a line of text
>>> TagSet.from_line('a=1 b=3 c=[1,2,3] d=dee')
TagSet:{'a': 1, 'b': 3, 'c': [1, 2, 3], 'd': 'dee'}
>>> # because TagSets are dicts you can format strings with them
>>> print('topic:{topic} subtopic:{subtopic}'.format_map(tags))
topic:tagging subtopic:ontologies
>>> # TagSets have convenient membership tests
>>> # test for blueness
>>> 'blue' in tags
True
>>> # test for redness
>>> 'red' in tags
False
>>> # test for any "subtopic" tag
>>> 'subtopic' in tags
True
>>> # test for subtopic=ontologies
>>> print(subtopic)
subtopic=ontologies
>>> subtopic in tags
True
>>> # test for subtopic=libraries
>>> subtopic2 = Tag('subtopic', 'libraries')
>>> subtopic2 in tags
FalseOntologiesTags andTagSets suffice to apply simple annotations to things.
However, an ontology brings meaning to those annotations.See theTagsOntologyclass for implementation details,
access methods and more examples.Consider a record about a movie, with these tags (aTagSet):title="Avengers Assemble"
series="Avengers (Marvel)"
cast={"Scarlett Johansson":"Black Widow (Marvel)"}where we have the movie title,
a name for the series in which it resides,
and a cast as an association of actors with roles.An ontology lets us associate implied types and metadata with these values.Here's an example ontology supporting the aboveTagSet:type.cast type=dict key_type=person member_type=character description="members of a production"
type.character description="an identified member of a story"
type.series type=str
character.marvel.black_widow type=character names=["Natasha Romanov"]
person.scarlett_johansson fullname="Scarlett Johansson" bio="Known for Black Widow in the Marvel stories."The type information for acastis defined by the ontology entry namedtype.cast,
which tells us that acastTagis adict,
whose keys are of typepersonand whose values are of typecharacter.
(The default type isstr.)To find out the underlying type for acharacterwe look that up in the ontology in turn;
because it does not have a specifiedtypeTag, it it taken to be astr.Having the types for acast,
it is now possible to look up the metadata for the described cast members.The key"Scarlett Johansson"is aperson(from the type definition ofcast).
The ontology entry for her is namedperson.scarlett_johanssonwhich is computed as:person: the type namescarlett_johansson: obtained by downcasing"Scarlett Johansson"and replacing whitespace with an underscore.
The full conversion process is defined
by theTagsOntology.value_to_tag_namefunction.The key"Black Widow (Marvel)"is acharacter(again, from the type definition ofcast).
The ontology entry for her is namedcharacter.marvel.black_widowwhich is computed as:character: the type namemarvel.black_widow: obtained by downcasing"Black Widow (Marvel)",
replacing whitespace with an underscore,
and moving a bracketed suffix to the front as an unbracketed prefix.
The full conversion process is defined
by theTagsOntology.value_to_tag_namefunction.Format StringsYou can just usestr.format_mapas shown above
for the direct values in aTagSet,
since it subclassesdict.However,TagSets also subclasscs.lex.FormatableMixinand therefore have a richerformat_asmethod which has an extended syntax
for the format component.
Command line tools likefstagsuse this for output format specifications.An example:>>> # an ontology specifying the type for a colour
>>> # and some information about the colour "blue"
>>> ont = TagsOntology(
...   {
...       'type.colour':
...       TagSet(description="a colour, a hue", type="str"),
...       'colour.blue':
...       TagSet(
...           url='https://en.wikipedia.org/wiki/Blue',
...           wavelengths='450nm-495nm'
...       ),
...   }
... )
>>> # tag set with a "blue" tag, using the ontology above
>>> tags = TagSet(colour='blue', labels=['a', 'b', 'c'], size=9, _ontology=ont)
>>> tags.format_as('The colour is {colour}.')
'The colour is blue.'
>>> # format a string about the tags showing some metadata about the colour
>>> tags.format_as('Information about the colour may be found here: {colour:metadata.url}')
'Information about the colour may be found here: https://en.wikipedia.org/wiki/Blue'Functionas_unixtime(tag_value)Convert a tag value to a UNIX timestamp.This acceptsint,float(already a timestamp)
anddateordatetime(usedatetime.timestamp() for a nonnaivedatetime, otherwisetime.mktime(tag_value.time_tuple())`,
which assumes the local time zone).ClassBaseTagSets(cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container)Base class for collections ofTagSetinstances
such ascs.fstags.FSTagsandcs.sqltags.SQLTags.Examples of this include:cs.fstags.FSTags: a mapping of filesystem paths to their associatedTagSetcs.sqltags.SQLTags: a mapping of names toTagSets stored in an SQL databaseSubclasses must implement:get(name,default=None): return theTagSetassociated
withname, ordefault.__setitem__(name,tagset): associate aTagSetwith the keyname;
this is called by the__missing__method with a newly createdTagSet.keys(self): return an iterable of namesSubclasses may reasonably want to override the following:startup_shutdown(self): context manager to allocate and release any
needed resources such as database connectionsSubclasses may implement:__len__(self): return the number of namesTheTagSetfactory used to fetch or create aTagSetis
namedTagSetClass. The default implementation honours two
class attributes:TAGSETCLASS_DEFAULT: initiallyTagSetTAGSETCLASS_PREFIX_MAPPING: a mapping of type names toTagSetsubclassesThe type name of aTagSetname is the first dotted component.
For example,artist.nick_cavehas the type nameartist.
A subclass ofBaseTagSetscould utiliise anArtistTagSetsubclass ofTagSetand provide:TAGSETCLASS_PREFIX_MAPPING = {
  'artist': ArtistTagSet,
}in its class definition. Accesses toartist.* entities would
result inArtistTagSetinstances and access to other enitities
would result in ordinaryTagSetinstances.MethodBaseTagSets.__init__(self, *, ontology=None):
Initialise the collection.ClassMappingTagSets(BaseTagSets, cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container)ABaseTagSetssubclass using an arbitrary mapping.If no mapping is supplied, adictis created for the purpose.Example:>>> tagsets = MappingTagSets()
>>> list(tagsets.keys())
[]
>>> tagsets.get('foo')
>>> tagsets['foo'] = TagSet(bah=1, zot=2)
>>> list(tagsets.keys())
['foo']
>>> tagsets.get('foo')
TagSet:{'bah': 1, 'zot': 2}
>>> list(tagsets.keys(prefix='foo'))
['foo']
>>> list(tagsets.keys(prefix='bah'))
[]ClassRegexpTagRuleA regular expression basedTagrule.This applies a regular expression to a string
and returns inferredTags.Functionselftest(argv)Run some ad hoc self tests.ClassTag(Tag, builtins.tuple, cs.lex.FormatableMixin, cs.lex.FormatableFormatter, string.Formatter)ATaghas a.name(str) and a.valueand an optional.ontology.Thenamemust be a dotted identifier.Terminology:A "bare"Taghas avalueofNone.A "naive"Taghas anontologyofNone.The constructor for aTagis unusual:both thevalueandontologyare optional,
defaulting toNoneifnameis astrthen we always construct a newTagwith the suppplied valuesifnameis not astrit should be aTaglike object to promote;
it is an error if thevalueparameter is notNonein this casean optionalprefixmay be supplied
which is prepended tonamewith a dot ('.') if not emptyThe promotion process is as follows:ifnameis aTagsubinstance
then if the suppliedontologyis notNoneand is not the ontology associated withnamethen a newTagis made,
otherwise the originalTagis returned unchangedotherwise a newTagis made fromnameusing its.valueand overriding its.ontologyif theontologyparameter is notNoneExamples:>>> ont = TagsOntology({'colour.blue': TagSet(wavelengths='450nm-495nm')})
>>> tag0 = Tag('colour', 'blue')
>>> tag0
Tag(name='colour',value='blue')
>>> tag = Tag(tag0)
>>> tag
Tag(name='colour',value='blue')
>>> tag = Tag(tag0, ontology=ont)
>>> tag # doctest: +ELLIPSIS
Tag(name='colour',value='blue',ontology=...)
>>> tag = Tag(tag0, prefix='surface')
>>> tag
Tag(name='surface.colour',value='blue')MethodTag.__init__(self, *a, **kw):
Dummy__init__to avoidFormatableMixin.__init__because we subclassnamedtuplewhich has no__init__.Functiontag_or_tag_value(*da, **dkw)A decorator for functions or methods which may be called as:func(name[,value])or as:func(Tag)The optional decorator argumentno_self(defaultFalse)
should be supplied for plain functions
as they have no leadingselfparameter to accomodate.Example:@tag_or_tag_value
def add(self, tag_name, value, *, verbose=None):This defines a.add()method
which can be called withnameandvalueor with singleTaglike object
(something with.nameand.valueattributes),
for example:tags = TagSet()
....
tags.add('colour', 'blue')
....
tag = Tag('size', 9)
tags.add(tag)ClassTagBasedTest(TagBasedTest, builtins.tuple, TagSetCriterion, cs.deco.Promotable)A test based on aTag.Attributes:spec: the source text from which this choice was parsed,
possiblyNonechoice: the apply/reject flagtag: theTagrepresenting the criterioncomparison: an indication of the test comparisonThe following comparison values are recognised:None: test for the presence of theTag'=': test that the tag value equalstag.value'<': test that the tag value is less thantag.value'<=': test that the tag value is less than or equal totag.value'>': test that the tag value is greater thantag.value'>=': test that the tag value is greater than or equal totag.value'~/': test if the tag value as a regexp is present intag.value'~': test if a matching tag value is present intag.valueClassTagFile(cs.fs.FSPathBasedSingleton, cs.obj.SingletonMixin, cs.fs.HasFSPath, BaseTagSets, cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container)A reference to a specific file containing tags.This manages a mapping ofname=>TagSet,
itself a mapping of tag name => tag value.ClassTagsCommandMixinUtility methods forcs.cmdutils.BaseCommandclasses working with tags.Optional subclass attributes:TAGSET_CRITERION_CLASS: aTagSetCriterionduck class,
defaultTagSetCriterion.
For example,cs.sqltagshas a subclass
with an.extend_querymethod for computing an SQL JOIN
used in searching for tagged entities.ClassTagSet(builtins.dict, cs.dateutils.UNIXTimeMixin, cs.lex.FormatableMixin, cs.lex.FormatableFormatter, string.Formatter, cs.mappings.AttrableMappingMixin)A setlike class associating a set of tag names with values.This actually subclassesdict, so aTagSetis a direct
mapping of tag names to values.
It accepts attribute access to simple tag values when they
do not conflict with the class methods;
the reliable method is normal item access.NOTE: iteration yieldsTags, not dict keys.Also note that all theTagsfrom aTagSetshare its ontology.Subclasses should override thesetanddiscardmethods;
thedictand mapping methods
are defined in terms of these two basic operations.TagSets have a few special properties:id: a domain specific identifier;
this may reasonably beNonefor entities
not associated with database rows;
thecs.sqltags.SQLTagsclass associates this
with the database row id.name: the entity's name;
a read only alias for the'name'Tag.
Thecs.sqltags.SQLTagsclass defines "log entries"
asTagSets with noname.unixtime: a UNIX timestamp,
afloatholding seconds since the UNIX epoch
(midnight, 1 January 1970 UTC).
This is typically the row creation time
for entities associated with database rows,
but usually the event time forTagSets describing an event.BecauseTagSetsubclassescs.mappings.AttrableMappingMixinyou can also access tag values as attributesprovidedthat they do not conflict with instance attributes
or class methods or properties.MethodTagSet.__init__(self, *a, _id=None, _ontology=None, **kw):
Initialise theTagSet.Parameters:positional parameters initialise thedictand are passed todict.__init___id: optional identity value for databaselike implementations_ontology: optionalTagsOntology to use for thisTagSet`other alphabetic keyword parameters are also used to initialise thedictand are passed todict.__init__ClassTagSetCriterion(cs.deco.Promotable)A testable criterion for aTagSet.ClassTagSetPrefixView(cs.lex.FormatableMixin, cs.lex.FormatableFormatter, string.Formatter)A view of aTagSetvia aprefix.Access to a keykaccesses theTagSetwith the keyprefix+'.'+k.This is a kind of funny hybrid of aTagand aTagSetin that some things such as__format__will format theTagnamedprefixif it exists
in preference to the subtags.Example:>>> tags = TagSet(a=1, b=2)
>>> tags
TagSet:{'a': 1, 'b': 2}
>>> tags['sub.x'] = 3
>>> tags['sub.y'] = 4
>>> tags
TagSet:{'a': 1, 'b': 2, 'sub.x': 3, 'sub.y': 4}
>>> sub = tags.sub
>>> sub
TagSetPrefixView:sub.{'x': 3, 'y': 4}
>>> sub.z = 5
>>> sub
TagSetPrefixView:sub.{'x': 3, 'y': 4, 'z': 5}
>>> tags
TagSet:{'a': 1, 'b': 2, 'sub.x': 3, 'sub.y': 4, 'sub.z': 5}ClassTagSetsSubdomain(cs.obj.SingletonMixin, cs.mappings.PrefixedMappingProxy, cs.mappings.RemappedMappingProxy)A view into aBaseTagSetsfor keys commencing with a prefix
being the subdomain plus a dot ('.').ClassTagsOntology(cs.obj.SingletonMixin, BaseTagSets, cs.resources.MultiOpenMixin, cs.context.ContextManagerMixin, collections.abc.MutableMapping, collections.abc.Mapping, collections.abc.Collection, collections.abc.Sized, collections.abc.Iterable, collections.abc.Container)An ontology for tag names.
This is based around a mapping of names
to ontological information expressed as aTagSet.Normally an object's tags are not a self contained repository of all the information;
instead a tag just names some information.As a example, consider the tagcolour=blue.
Meta information aboutblueis obtained via the ontology,
which has an entry for the colourblue.
We adopt the convention that the type is just the tag name,
so we obtain the metadata by callingontology.metadata(tag)or alternativelyontology.metadata(tag.name,tag.value)being the type name and value respectively.The ontology itself is based aroundTagSetsand effectively the callontology.metadata('colour','blue')would look up theTagSetnamedcolour.bluein the underlyingTagsets.For a self contained dataset this means that it can be its own ontology.
For tags associated with arbitrary objects
such as the filesystem tags maintained bycs.fstagsthe ontology would be a separate tags collection stored in a central place.There are two main categories of entries in an ontology:metadata: other entries namedtypename.value_keycontains aTagSetholding metadata for a value of typetypenamewhose value is mapped tovalue_keytypes: an optional entry namedtype.typenamecontains aTagSetdescribing the type namedtypename;
really this is just more metadata where the "type name" istypeMetadata areTagSetsinstances describing particular values of a type.
For example, some metadata for theTagcolour="blue":colour.blue url="https://en.wikipedia.org/wiki/Blue" wavelengths="450nm-495nm"Some metadata associated with theTagactor="Scarlett Johansson":actor.scarlett_johansson role=["Black Widow (Marvel)"]
character.marvel.black_widow fullname=["Natasha Romanov"]The tag values are lists above because an actor might play many roles, etc.There's a convention for converting human descriptions
such as the role string"Black Widow (Marvel)"to its metadata.the value"Black Widow (Marvel)"if converted to a key
by the ontology methodvalue_to_tag_name;
it moves a bracket suffix such as(Marvel)to the front as a prefixmarvel.and downcases the rest of the string and turns spaces into underscores.
This yields the value keymarvel.black_widow.the type isrole, so the ontology entry for the metadata
isrole.marvel.black_widowThis requires type information about arole.
Here are some type definitions supporting the above metadata:type.person type=str description="A person."
type.actor type=person description="An actor's stage name."
type.character type=str description="A person in a story."
type.role type_name=character description="A character role in a performance."
type.cast type=dict key_type=actor member_type=role description="Cast members and their roles."The basic types have their Python names:int,float,str,list,dict,date,datetime.
You can define subtypes of these for your own purposes
as illustrated above.For example:type.colour type=str description="A hue."which subclassesstr.Subtypes oflistinclude amember_typespecifying the type for members of aTagvalue:type.scene type=list member_type=str description="A movie scene."Subtypes ofdictinclude akey_typeand amember_typespecifying the type for keys and members of aTagvalue:Accessing type data and metadata:ATagSetmay have a reference to aTagsOntologyas.ontologyand so also do any of itsTags.ClassTagsOntologyCommand(cs.cmdutils.BaseCommand)A command line for working with ontology types.Command line usage:Usage: tagsontology subcommand [...]
  Subcommands:
    edit [{/name-regexp | entity-name}]
      Edit entities.
      With no arguments, edit all the entities.
      With an argument starting with a slash, edit the entities
      whose names match the regexp.
      Otherwise the argument is expected to be an entity name;
      edit the tags of that entity.
    help [-l] [subcommand-names...]
      Print help for subcommands.
      This outputs the full help for the named subcommands,
      or the short help for all subcommands if no names are specified.
      -l  Long help even if no subcommand-names provided.
    meta tag=value
    shell
      Run a command prompt via cmd.Cmd using this command's subcommands.
    type
        With no arguments, list the defined types.
      type type_name
        With a type name, print its `Tag`s.
      type type_name edit
        Edit the tags defining a type.
      type type_name edit meta_names_pattern...
        Edit the tags for the metadata names matching the
        meta_names_patterns.
      type type_name list
      type type_name ls
        List the metadata names for this type and their tags.
      type type_name + entity_name [tags...]
        Create type_name.entity_name and apply the tags.Release LogRelease 20240211:TagFile.parse_tag_line: recognise dotted_identifiers directly, avoids misparsing bare "nan" as float NaN.Tag.parse_value: BUGFIX parse - always to the primary types first (int, float) before trying any funny extra types.Release 20240201:
TagsOntology.metadata: actually call the .items() method!Release 20231129:TagSet.getattr: rework the attribute lookup with greater precision.TagSetPrefixView.getattr: if the attribute is not there, raise Attribute error, do not try to fall back to something else.TagSet: drop ATTRABLE_MAPPING_DEFAULT=None, caused far more confusion that it was worth.Release 20230612:TagFile.save_tagsets: catch and warn about exceptions from update_mapping[key].update, something is wrong with my SQLTags usage.TagFile.save_tagsets: update_mapping: do not swallow AttributeError.Release 20230407:
Move the (optional) ORM open/close from FSTags.startup_shutdown to TagFile.save, greatly shortens the ORM lock.Release 20230212:
Mark TagSetCriterion as Promotable.Release 20230210:TagFile: new optional update_mapping secondary mapping to which to mirror file tags, for example to an SQLTags.New .uuid:UUID property returning the UUID for the tag named 'uuid' or None.Release 20230126:
New TagSet.is_stale() method based on .expiry attribute, intended for TagSets which are caches of other primary data.Release 20221228:TagFile: drop _singleton_key, FSPathBasedSingleton provides a good default.TagFile.save_tagsets,tags_line: new optional prune=False parameter to drop empty top level dict/lists.TagFile.save: plumb prune=False parameter.Release 20220806:
New TagSetCriterion.promote(obj)->TagSetCriterion class method.Release 20220606:Tag.parse_value: bugfix parse of float.TagSet.edit: accept optional comments parameter with addition header comment lines, be more tolerant of errors, avoid losing data on error.Release 20220430:TagSetPrefixView: new as_dict() method.TagSetPrefixView.str: behave like TagSet.str.TagFile.save_tagsets: do not try to save if the file is missing and the tagsets are empty.New TagSet.from_tags(tags) factory to make a new TagSet from an iterable of tags.TagSetPrefixView: add .get and .setdefault mapping methods.RegexpTagRule: accept optional tag_prefix parameter.Tagset: new from_ini() and save_as_ini() methods to support cs.timeseries config files, probably handy elsewhere.Release 20220311:
Assorted internal changes.Release 20211212:Tag: new fallback_parse parameter for value parsing, default get_nonwhite.Tag: new from_arg factory with fallback_parse grabbing the whole string for command line arguments, thus supporting unquoted strings for ease of use.TagSetCriterion: new optional fallback_parse parameter and from_arg method as for the Tag factories.Tag.transcribe_value: accept optional json_options to control the JSON encoder, used for human friendly multiline edits in cs.app.tagger.Rename edit_many to edit_tagsets for clarity.TagsOntology: new type_values method to return values for a type (derived from their metadata entries).Tag: new alt_values method returning its TagsOntology.type_values.(Internal) New _FormatStringTagProxy which proxies a Tag but uses str(self.__proxied.value) forstrto support format strings.(Internal) TagSet.get_value: if arg_name matches a Tag, return a _FormatStringTagProxy.Tag.new: accept (tag_name,value) or (Tag) as initialisation parameters.Release 20210913:TagSet.get_value: raise KeyError in strict mode, leave placeholder otherwise.Other small changes.Release 20210906:
Many many updates; some semantics have changed.Release 20210428:
Bugfix TagSet.set: internal in place changes to a complex tag value were not noticed, causing TagFile to not update on shutdown.Release 20210420:TagSet: also subclass cs.dateutils.UNIXTimeMixin.Various TagSetNamespace updates and bugfixes.Release 20210404:
Bugfix TagBasedTest.COMPARISON_FUNCS["="]: if cmp_value is None, return true (the tag is present).Release 20210306:ExtendedNamespace,TagSetNamespace: move the .[:alpha:]* attribute support from ExtendedNamespace to TagSetNamespace because it requires Tags.TagSetNamespace.getattr: new _i, _s, _f suffixes to return int, str or float tag values (or None); fold _lc in with these.Pull most ofTaggedEntityout intoTaggedEntityMixinfor reuse by domain specific tagged entities.TaggedEntity: new .set and .discard methods.TaggedEntity: new as_editable_line, from_editable_line, edit and edit_entities methods to support editing entities using a text editor.ontologies: type entries are now prefixed with "type." and metadata entries are prefixed with "meta."; provide a worked ontology example in the introduction and improve related docstrings.TagsOntology: new .types(), .types_names(), .meta(type_name,value), .meta_names() methods.TagsOntology.getitem: create missing TagSets on demand.New TagsOntologyCommand, initially with a "type [type_name [{edit|list}]]" subcommand, ready for use as the cmd_ont subcommand of other tag related commands.TagSet: support initialisation like a dict including keywords, and move theontologyparameter to_onotology.TagSet: include AttrableMappingMixin to enable attribute access to values when there is no conflict with normal methods.UUID encode/decode support.Honour $TAGSET_EDITOR or $EDITOR as preferred interactive editor for tags.New TagSet.subtags(prefix) to extract a subset of the tags.TagsOntology.value_metadata: new optional convert parameter to override the default "convert human friendly name" algorithm, particularly to pass convert=str to things which are already the basic id.Rename TaggedEntity to TagSet.Rename TaggedEntities to TagSets.TagSet: new csvrow and from_csvrow methods imported from obsolete TaggedEntityMixin class.Move BaseTagFile from cs.fstags to TagFile in cs.tagset.TagSet: support access to the tag "c.x" via attributes provided there is no "c" tag in the way.TagSet.unixtime: implement the autoset-to-now semantics.New as_timestamp(): convert date, datetime, int or float to a UNIX timestamp.Assorted docstring updates and bugfixes.Release 20200716:Update for changed cs.obj.SingletonMixin API.Pull in TaggedEntity from cs.sqltags and add the .csvrow property and the .from_csvrow factory.Release 20200521.1:
Fix DISTINFO.install_requires, drop debug import.Release 20200521:New ValueDetail and KeyValueDetail classes for returning ontology information; TagInfo.detail now returns a ValueDetail for scalar types, a list of ValueDetails for sequence types and a list of KeyValueDetails for mapping types; drop various TagInfo mapping/iterable style methods, too confusing to use.Plumb ontology parameter throughout, always optional.Drop TypedTag, Tags now use ontologies for this.New TagsCommandMixin to support BaseCommands which manipulate Tags.Many improvements and bugfixes.Release 20200318:Note that the TagsOntology stuff is in flux and totally alpha.Tag.prefix_name factory returning a new tag if prefix is not empty, ptherwise self.TagSet.update: accept an optional prefix for inserting "foreign" tags with a distinguishing name prefix.Tag.as_json: turn sets and tuples into lists for encoding.Backport for Python < 3.7 (no fromisoformat functions).TagSet: drop unused and illplaced .titleify, .episode_title and .title methods.TagSet: remove "defaults", unused.Make TagSet a direct subclass of dict, adjust uses of .update etc.New ExtendedNamespace class which is a SimpleNamespace with some inferred attributes and a partial mapping API (keys andgetitem).New TagSet.ns() returning the Tags as an ExtendedNamespace, which doubles as a mapping for str.format_map; TagSet.format_kwargs is now an alias for this.New Tag.from_string factory to parse a str into a Tag.New TagsOntology and TypedTag classes to provide type and value-detail information; very very alpha and subject to change.Release 20200229.1:
Initial release: pull TagSet, Tag, TagChoice from cs.fstags for independent use.