rheinwerk-verlag / pganonymize

A commandline tool for anonymizing PostgreSQL databases
http://pganonymize.readthedocs.io/
Other
42 stars 26 forks source link

Improvement for the provider registration #30

Closed hkage closed 3 years ago

hkage commented 3 years ago

This PR will make registration of the provider classes more clean and less code repeating (using the meta class for each provider class).

E.g. instead of using the metaclass and setting the provider id on class level:

class ClearProvider(with_metaclass(ProviderMeta, Provider)):

    id = 'clear'

    def alter_value(self, value):
        return None

it is now possible to register the class directly:

@register('clear')
class ClearProvider(Provider):

    def alter_value(self, value):
        return None

It is also possible to allow regular expressions as provider IDs (usefull for the Faker provider):

@register('fake.+')
class FakeProvider(Provider):

    regex_match = True