Skip to content

Commit

Permalink
update some config docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianPugh committed Sep 29, 2023
1 parent 48d41cd commit ae7c6b4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions autoregistry/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def update(self, new: dict) -> None:
setattr(self, key, value)

def getitem(self, registry: dict, key: str):
"""Key/Value lookup with keysplitting and optional case-insensitivity."""
keys = key_split(key)
for key in keys:
if not self.case_sensitive:
Expand All @@ -70,10 +71,30 @@ def getitem(self, registry: dict, key: str):
def format(self, name: str) -> str:
"""Convert and validate a function or class name to a registry key.
Operations are performed in the following order (if configured):
1. ``regex`` validator
2. ``prefix`` validation, then stripping.
3. ``suffix`` validation, then stripping.
4. ``snake_case`` transform (``FooBar`` -> ``foo_bar``).
5. ``hyphen`` transform (``foo_bar`` -> ``foo-bar``).
6. ``transform`` arbitrary user-provided string transform.
7. The lookup string representation is then stored as all
lowercase if ``case_sensitive=False``.
Parameters
----------
name: str
Name to convert to a registry key.
Raises
------
InvalidNameError
If the provided name fails a validation check (``prefix``, ``suffix``, ``regex``).
Returns
-------
str
New name after applying all transformation and validation rules.
"""
if self._regex_validator and not self._regex_validator.match(name):
raise InvalidNameError(f"{name} name must match regex {self.regex}")
Expand Down

0 comments on commit ae7c6b4

Please sign in to comment.