otupy.profiles.ctxd.data.name.Name
- class Name(name)
Bases:
ChoiceService or Link identifier
The Name class is designed to contain multiple alternative identifiers for a Service. The current options include:
uri: A valid URI. It is normally expected that the URI corresponds to a reachable service, but this is not strictly required by this implementation, as the URI is only used as identifier (not as a locator).
reverse-dns: This field has the same syntax as a DNS name, but in reverse order (e.g., com.apple.service.xyz). It is commonly used by software frameworks that needs unique names for entities, but does not require to locate them with a DNS.
uuid: A UUID of 128 bits following usual formats and structure.
local: A format-free string that might not be unique and has local meaning only (e.g., “host0”).
The current design assumes a single identifier can be given (differently, e.g., from Specifiers). This choice makes simpler comparing two Names to see if they are equal (with multiple identifiers it is not clear how to manage cases where only a subset matches).
Methods
Builds instance from dictionary
Return the id of the Service/Link
Get the class corresponding to the current choice
Returns the name of the choice
Returns the objet instance embedded in the register.
Return the id as plain string
Converts to dictionary
Return the identifier type
Attributes
List of registered name/class options available
Selected name for the Choice
Class corresponding to the choice
- __init__(name)
Create a Name object
The correct type is automatically inferred from the type of the supplied object. If a plain string is used, the “local” type is used.
- Parameters:
name – The identifier of the Service or Link.
- classmethod fromdict(dic, e)
Builds instance from dictionary
It is used during deserialization to create an otupy instance from the text message. It takes an
Encoderinstance that is used to recursively build instances of the inner objects (theEncoderprovides standard methods to create instances of base objects like strings, integers, boolean).- Parameters:
dic – The intermediary dictionary representation from which the object is built.
e – The
Encoderthat is being used.
- Returns:
An instance of this class initialized from the dictionary values.
- get()
Return the id of the Service/Link
Return the identifier stored in this class.
- return:
A reference to the object that contains the id. The original object type is returned (see ‘str’ to get a plain string).
- classmethod getClass(choice)
Get the class corresponding to the current choice
It may be implemented by any derived class, if a different logic than the Register class is followed to store the name/class bindings.
- Parameters:
choice – The name of the alternative that is being looked for.
- Returns:
The class corresponding to the provided choice.
- getName()
Returns the name of the choice
Returns the name of object, which is the selector carried by the Choice element. This does not include the object itself.
- getObj()
Returns the objet instance embedded in the register.
- obj
Class corresponding to the choice
- register = {'local': <class 'str'>, 'reverse-dns': <class 'otupy.types.data.hostname.Hostname'>, 'uri': <class 'otupy.types.data.uri.URI'>, 'uuid': <class 'uuid.UUID'>}
List of registered name/class options available
- str()
Return the id as plain string
Return the id of the Service/Link as plain string, independently of its type. :return: String representation of the object.
- todict(e)
Converts to dictionary
It is used to convert this object to an intermediary representation during serialization. It takes an
Encoderargument that is used to recursively serialize inner data and structures (theEncoderprovides standard methods for converting base types to dictionaries)..- Parameters:
e – The
Encoderthat is being used.- Returns:
A dictionary compliants to the Language Specification’s serialization rules.
- type()
Return the identifier type
Return the class of the identifier.
- Returns:
The class object of the identifier instance.