cgsmiles.dialects module¶
- cgsmiles.dialects.create_dialect(default_attributes, optional_attributes={}, accept_kwargs=True)[source]¶
Creates a signature of default annotations. Note that the order of the entries in the dict determines the order of the args accepted.
- cgsmiles.dialects.parse_graph_base_node(string_iterable, *, dialect_signature=<Signature (fragname: str = None, q: float = 0.0, w: float = 1.0, **kwargs)>, arg_to_fullname={'q': 'charge', 'w': 'weight'}, annotation_sep_token=';', annotation_assign_token='=', drop_none=True)¶
This base function parsers a string that describes key value pairs in having a pattern of:
key<annotation_assign_token>value<annotation_sep_token>key …
Default values, non-keyword agruments and types are defined using the dialect signature object. If args are defined the key and assignment token may be omitted.
Neither the annotation_sep_token nor the annotation_assign_token can be part of key or value. A SyntaxError is raised in this case.
- Parameters:
string_iterable – the string or iter object that contains the string
dialect_signature (inspect.Signature) – a signature defineing args, kwargs, default values and types
arg_to_fullname (dict) – maps arguments to more verbose descriptions
annotation_sep_token (str) – character used to seperate key value pairs
annotation_assign_token (str) – character used to assign a key from a value
drop_none (bool) – drop all entries with value equal to None
- Returns:
dict of key value paris
- Return type:
- Raises:
SyntaxError – an error is raised if the signature does not match or too many annotation_assign_token are given