aboutsummaryrefslogtreecommitdiffstats
path: root/bsie/lib/naming_policy.py
diff options
context:
space:
mode:
Diffstat (limited to 'bsie/lib/naming_policy.py')
-rw-r--r--bsie/lib/naming_policy.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/bsie/lib/naming_policy.py b/bsie/lib/naming_policy.py
index 9b9a45d..3e7c940 100644
--- a/bsie/lib/naming_policy.py
+++ b/bsie/lib/naming_policy.py
@@ -4,6 +4,9 @@ import abc
import os
import typing
+# external imports
+import urllib.parse
+
# bsie imports
from bsie.utils import bsfs, errors, ns
from bsie.utils.node import Node
@@ -84,6 +87,8 @@ class DefaultNamingPolicy(NamingPolicy):
return self.name_file(node)
if node.node_type == ns.bsn.Preview:
return self.name_preview(node)
+ if node.node_type == ns.bsn.Tag:
+ return self.name_tag(node)
raise errors.ProgrammingError('no naming policy available for {node.node_type}')
def name_file(self, node: Node) -> Node:
@@ -112,4 +117,14 @@ class DefaultNamingPolicy(NamingPolicy):
node.uri = getattr(self._prefix.preview(), fragment)
return node
+ def name_tag(self, node: Node) -> Node:
+ # NOTE: Must ensure to produce the same name for that tags with the same label.
+ if 'label' in node.hints: # tag label
+ fragment = urllib.parse.quote(node.hints['label'])
+ else: # random name
+ fragment = self._uuid()
+ # FIXME: match to existing tags in bsfs storage!
+ node.uri = getattr(self._prefix.tag(), fragment)
+ return node
+
## EOF ##