diff --git a/force_bdss/ids.py b/force_bdss/ids.py index 76b3016b09e4626fe7229cd8190d56b55aa13550..81ff1062170f547fc95cd90a79516781ad3848c6 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)