architecture.py 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. import warnings
  14. from sqlalchemy import Column, Integer, Text
  15. from sqlalchemy.schema import Index
  16. from .base import BaseTimestamp
  17. class Architecture(BaseTimestamp):
  18. __tablename__ = 'architecture'
  19. arch_id = Column('id', Integer, primary_key=True)
  20. arch_string = Column(Text, nullable=False)
  21. description = Column(Text)
  22. # indexes where not created as constraints, need to do as well
  23. __table_args__ = (Index('architecture_arch_string_key', 'arch_string', unique=True), )
  24. def __init__(self, arch_string=None, description=None):
  25. self.arch_string = arch_string
  26. self.description = description
  27. def __str__(self):
  28. return self.arch_string
  29. def __repr__(self):
  30. return '<{} {}>'.format(
  31. self.__class__.__name__,
  32. self.arch_string,
  33. )
  34. def __eq__(self, val):
  35. if isinstance(val, str):
  36. warnings.warn("comparison with a `str` is deprecated", DeprecationWarning, stacklevel=2)
  37. return (self.arch_string == val)
  38. # This signals to use the normal comparison operator
  39. return NotImplemented
  40. def __ne__(self, val):
  41. if isinstance(val, str):
  42. warnings.warn("comparison with a `str` is deprecated", DeprecationWarning, stacklevel=2)
  43. return (self.arch_string != val)
  44. # This signals to use the normal comparison operator
  45. return NotImplemented
  46. __hash__ = BaseTimestamp.__hash__