architecture.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # This program is free software; you can redistribute it and/or modify
  2. # it under the terms of the GNU General Public License as published by
  3. # the Free Software Foundation; either version 2 of the License, or
  4. # (at your option) any later version.
  5. # This program is distributed in the hope that it will be useful,
  6. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. # GNU General Public License for more details.
  9. # You should have received a copy of the GNU General Public License
  10. # along with this program; if not, write to the Free Software
  11. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  12. ################################################################################
  13. from sqlalchemy import Column, Integer, Text
  14. from sqlalchemy.schema import Index
  15. from .base import BaseTimestamp
  16. class Architecture(BaseTimestamp):
  17. __tablename__ = 'architecture'
  18. arch_id = Column('id', Integer, primary_key=True)
  19. arch_string = Column(Text, nullable=False)
  20. description = Column(Text)
  21. # indexes where not created as constraints, need to do as well
  22. __table_args__ = (Index('architecture_arch_string_key', 'arch_string', unique=True), )
  23. def __init__(self, arch_string=None, description=None):
  24. self.arch_string = arch_string
  25. self.description = description
  26. def __str__(self):
  27. return self.arch_string
  28. def __repr__(self):
  29. return '<{} {}>'.format(
  30. self.__class__.__name__,
  31. self.arch_string,
  32. )
  33. def __eq__(self, val):
  34. if isinstance(val, str):
  35. return (self.arch_string == val)
  36. # This signals to use the normal comparison operator
  37. return NotImplemented
  38. def __ne__(self, val):
  39. if isinstance(val, str):
  40. return (self.arch_string != val)
  41. # This signals to use the normal comparison operator
  42. return NotImplemented