Add hashing methods to XSD datatypes classes

This commit is contained in:
Davide Brunato 2019-08-28 07:07:30 +02:00
parent dcf950605c
commit 0e4f050abb
7 changed files with 22 additions and 8 deletions

View File

@ -2,6 +2,10 @@
CHANGELOG
*********
`v1.2.1`_ (TBD)
===============
* Hashable XSD datatypes classes
`v1.2.0`_ (2019-08-14)
======================
* Added special XSD datatypes
@ -142,3 +146,4 @@ CHANGELOG
.. _v1.1.8: https://github.com/brunato/elementpath/compare/v1.1.7...v1.1.8
.. _v1.1.9: https://github.com/brunato/elementpath/compare/v1.1.8...v1.1.9
.. _v1.2.0: https://github.com/brunato/elementpath/compare/v1.1.9...v1.2.0
.. _v1.2.1: https://github.com/brunato/elementpath/compare/v1.2.0...v1.2.1

View File

@ -15,7 +15,7 @@ because `lxml.etree <http://lxml.de>`_ already has it's own implementation of XP
Installation and usage
======================
You can install the package with *pip* in a Python 2.7 or Python 3.4+ environment::
You can install the package with *pip* in a Python 2.7 or Python 3.5+ environment::
pip install elementpath

View File

@ -31,7 +31,7 @@ author = 'Davide Brunato'
# The short X.Y version
version = '1.2'
# The full version, including alpha/beta/rc tags
release = '1.2.0'
release = '1.2.1'
# -- General configuration ---------------------------------------------------

View File

@ -8,7 +8,7 @@
#
# @author Davide Brunato <brunato@sissa.it>
#
__version__ = '1.2.0'
__version__ = '1.2.1'
__author__ = "Davide Brunato"
__contact__ = "brunato@sissa.it"
__copyright__ = "Copyright 2018-2019, SISSA"

View File

@ -130,15 +130,15 @@ class Timezone(datetime.tzinfo):
def __getinitargs__(self):
return self.offset,
def __hash__(self):
return hash(self.offset)
def __eq__(self, other):
return isinstance(other, Timezone) and self.offset == other.offset
def __ne__(self, other):
return not isinstance(other, Timezone) or self.offset != other.offset
def __hash__(self):
return hash(self.offset)
def __repr__(self):
return "%s(%r)" % (self.__class__.__name__, self.offset)
@ -345,6 +345,9 @@ class AbstractDateTime(object):
else:
raise ElementPathTypeError("wrong type %r for operand %r." % (type(other), other))
def __hash__(self):
return hash((self._dt, self._year))
def __eq__(self, other):
try:
return operator.eq(*self._get_operands(other)) and self.year == other.year
@ -815,6 +818,9 @@ class Duration(object):
datetime.timedelta(months2days(1903, 7, m2), s2, ms2)),
])
def __hash__(self):
return hash((self.months, self.seconds))
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.months == other.months and self.seconds == other.seconds
@ -951,6 +957,9 @@ class UntypedAtomic(object):
else:
return type(other)(self.value), other
def __hash__(self):
return hash(self.value)
def __eq__(self, other):
return operator.eq(*self._get_operands(other, force_float=False))

View File

@ -37,7 +37,7 @@ it:
riuso:
codiceIPA: sissa
piattaforme:
spid: true
spid: false
description:
en:
genericName: elementpath

View File

@ -15,7 +15,7 @@ with open("README.rst") as readme:
setup(
name='elementpath',
version='1.2.0',
version='1.2.1',
packages=['elementpath'],
author='Davide Brunato',
author_email='brunato@sissa.it',