set_parts

namefiles.ANameGiver.set_parts(self, **filename_parts)

Sets filename parts with new values. Only parts complying to the file name convention are taken.

Parameters

**filename_parts – Parts which should be set with new values.

Examples

>>> from doctestprinter import doctest_print
>>> from jsonschema import Draft7Validator
>>> from namefiles import ANameGiver, get_filename_convention
>>> class MyNameGiver(ANameGiver):
...     CUSTOM_VALIDATOR = Draft7Validator(get_filename_convention())
...     @classmethod
...     def get_filename_validator(cls) -> FilenameConvention:
...         # Put your custom file naming convention (jsonschema) here
...         return cls.CUSTOM_VALIDATOR
>>> sample_giver = MyNameGiver()
>>> a_lot_of_stuff = {
...     "identifier": "Z",
...     "sub_id": "BRA",
...     "location": "zoo",
...     "age": 27,
...     "name": "Hank"
... }
>>> sample_giver.set_parts(**a_lot_of_stuff)
>>> sample_giver
MyNameGiver(identifier: Z, sub_id: BRA)