<commit_before># -*- coding: utf-8 -*-
# Copyright (c) 2012 The Pycroft Authors. See the AUTHORS file.
# This file is part of the Pycroft project and licensed under the terms of
# the Apache License, Version 2.0. See the LICENSE file for details.
"""
    pycroft.model.dormitory
    ~~~~~~~~~~~~~~

    This module contains the classes Dormitory, Room, Subnet, VLan.

    :copyright: (c) 2011 by AG DSN.
"""

#from sqlalchemy.dialects import postgresql
from base import ModelBase
from sqlalchemy import ForeignKey
from sqlalchemy import Table, Column
from sqlalchemy.orm import relationship, backref
from sqlalchemy.types import Boolean, Integer, String, Enum
import ipaddr


association_table_dormitory_vlan = Table('association_dormitory_vlan',
                                         ModelBase.metadata,
                                         Column('dormitory_id', Integer,
                                                ForeignKey('dormitory.id')),
                                         Column('vlan_id', Integer,
                                                ForeignKey('vlan.id')))


association_table_subnet_vlan = Table("association_subnet_vlan",
                                        ModelBase.metadata,
                                        Column("subnet_id", Integer,
                                                ForeignKey("subnet.id")),
                                        Column("vlan_id", Integer,
                                                ForeignKey("vlan.id")))


class Dormitory(ModelBase):
    number = Column(String(3), unique=True, nullable=False)
    short_name = Column(String(5), unique=True, nullable=False)
    street = Column(String(20), nullable=False)

    #many to many from Dormitory to VLan
    vlans = relationship("VLan",
                            backref=backref("dormitories"),
                            secondary=association_table_dormitory_vlan)

    # methods

    def __repr__(self):
        return "Dormitory(number={}, short_name={}, street={})".format(
               self.number, self.short_name, self.street)


class Room(ModelBase):
    number = Column(String(36), nullable=False)
    level = Column(Integer, nullable=False)
    inhabitable = Column(Boolean, nullable=False)

    # many to one from Room to Dormitory
    dormitory_id = Column(Integer, ForeignKey("dormitory.id"), nullable=False)
    dormitory = relationship("Dormitory", backref=backref("rooms"))

<commit_msg>add room regex<commit_after># -*- coding: utf-8 -*-
# Copyright (c) 2012 The Pycroft Authors. See the AUTHORS file.
# This file is part of the Pycroft project and licensed under the terms of
# the Apache License, Version 2.0. See the LICENSE file for details.
"""
    pycroft.model.dormitory
    ~~~~~~~~~~~~~~

    This module contains the classes Dormitory, Room, Subnet, VLan.

    :copyright: (c) 2011 by AG DSN.
"""

#from sqlalchemy.dialects import postgresql
from base import ModelBase
from sqlalchemy import ForeignKey
from sqlalchemy import Table, Column
from sqlalchemy.orm import relationship, backref
from sqlalchemy.types import Boolean, Integer, String, Enum
import ipaddr


association_table_dormitory_vlan = Table('association_dormitory_vlan',
                                         ModelBase.metadata,
                                         Column('dormitory_id', Integer,
                                                ForeignKey('dormitory.id')),
                                         Column('vlan_id', Integer,
                                                ForeignKey('vlan.id')))


association_table_subnet_vlan = Table("association_subnet_vlan",
                                        ModelBase.metadata,
                                        Column("subnet_id", Integer,
                                                ForeignKey("subnet.id")),
                                        Column("vlan_id", Integer,
                                                ForeignKey("vlan.id")))


class Dormitory(ModelBase):
    number = Column(String(3), unique=True, nullable=False)
    short_name = Column(String(5), unique=True, nullable=False)
    street = Column(String(20), nullable=False)

    #many to many from Dormitory to VLan
    vlans = relationship("VLan",
                            backref=backref("dormitories"),
                            secondary=association_table_dormitory_vlan)

    # methods

    def __repr__(self):
        return "Dormitory(number={}, short_name={}, street={})".format(
               self.number, self.short_name, self.street)


class Room(ModelBase):
    number = Column(String(36), nullable=False)
    level = Column(Integer, nullable=False)
    inhabitable = Column(Boolean, nullable=False)

    # many to one from Room to Dormitory
    dormitory_id = Column(Integer, ForeignKey("dormitory.id"), nullable=False)
    dormitory = relationship("Dormitory", backref=backref("rooms"))

    room_regex = "^[0-9]{1,6}$"

{'fraction_non_alphanumeric': 0.09811855148695124, 'fraction_numerical': 0.007687639085575561, 'mean_word_length': 2.034990791896869, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5365219', 'n_tokens_mistral': 1309, 'n_tokens_neox': 1246, 'n_words': 328}