<commit_before>class AuthInfo:
    def __init__(self, franchise_code, subscriber_code, departament_code,
                 username, password):
        self.subscriber_code = subscriber_code
        self.franchise_code = franchise_code
        self.departament_code = departament_code
        self.username = username
        self.password = password

    def as_dict(self):
        return {'mrw:AuthInfo': [
            {'mrw:CodigoFranquicia': self.franchise_code},
            {'mrw:CodigoAbonado': self.subscriber_code},
            {'mrw:CodigoDepartamento': self.departament_code},
            {'mrw:UserName': self.username},
            {'mrw:Password': <PASSWORD>.password},
        ]}
<commit_msg>Refactor using a metaclass<commit_after>from collections import OrderedDict as odict


class Field:
    def __init__(self, tag_name):
        self.tag_name = tag_name
        self.value = None

        # These values will be set by metaclass
        self.name = None
        self.default = None

    def __get__(self, obj, objtype=None):
        if obj is None:
            return self
        else:
            return obj.__dict__.get(self.name, self.default)

    def __set__(self, obj, value):
        self.value = value
        obj.__dict__[self.name] = value

    def __repr__(self):
        return '<Field name={!r}>'.format(self.name)


class ModelMeta(type):
    def __new__(mcs, clsname, bases, clsdict):
        fields = []
        for name, value in clsdict.items():
            if isinstance(value, Field):
                value.name = name  # Init `Field.name`
                fields.append(value)
        clsdict['fields'] = fields
        return type.__new__(mcs, clsname, bases, clsdict)

    @classmethod
    def __prepare__(mcs, clsname, bases):
        return odict()


class Model(metaclass=ModelMeta):
    root_tag = 'root'

    def __init__(self, **kwargs):
        for name, value in kwargs.items():
            setattr(self, name, value)

    def as_dict(self):
        tags = [{k.tag_name: k.value} for k in self.fields]
        return {self.root_tag: tags}


class AuthInfo(Model):
    root_tag = 'mrw:AuthInfo'

    franchise_code = Field('mrw:CodigoFranquicia')
    subscriber_code = Field('mrw:CodigoAbonado')
    departament_code = Field('mrw:CodigoDepartamento')
    username = Field('mrw:UserName')
    password = Field('<PASSWORD>')

{'fraction_non_alphanumeric': 0.10919055649241147, 'fraction_numerical': 0.0, 'mean_word_length': 2.526002971768202, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1256776', 'n_tokens_mistral': 736, 'n_tokens_neox': 727, 'n_words': 165}