From 64254e31bc6b5b8ba2994aa196a6049098780b48 Mon Sep 17 00:00:00 2001 From: Stefano Borini <sborini@enthought.com> Date: Mon, 24 Jul 2017 12:06:23 +0100 Subject: [PATCH] Added new id for parameters --- force_bdss/ids.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/force_bdss/ids.py b/force_bdss/ids.py index 76b3016..81ff106 100644 --- a/force_bdss/ids.py +++ b/force_bdss/ids.py @@ -25,6 +25,30 @@ def bundle_id(producer, identifier): A unique identifier for the bundle. The producer has authority and control over the uniqueness of this identifier. + Returns + ------- + str: an identifier to be used in the bundle. + """ + return _string_id("bundle", producer, identifier) + + +def mco_parameter_id(producer, identifier): + return _string_id("mco_parameter", producer, identifier) + + +def _string_id(entity_namespace, producer, identifier): + """Creates an id for a generic entity. + + Parameters + ---------- + entity_namespace: str + A namespace for the entity we want to address (e.g. "bundle") + producer: str + the company or research institute unique identifier (e.g. "enthought") + identifier: str + A unique identifier for the bundle. The producer has authority and + control over the uniqueness of this identifier. + Returns ------- str: an identifier to be used in the bundle. @@ -35,7 +59,7 @@ def bundle_id(producer, identifier): " " not in entry and len(entry) != 0) - if not all(map(is_valid, [producer, identifier])): + if not all(map(is_valid, [entity_namespace, producer, identifier])): raise ValueError("Invalid parameters specified.") - return "force.bdss.bundles.{}.{}".format(producer, identifier) + return "force.bdss.{}.{}.{}".format(entity_namespace, producer, identifier) -- GitLab