From 5325bb4388d1b1ee55b882ca1690072c591c7f70 Mon Sep 17 00:00:00 2001 From: Majid Date: Wed, 28 Oct 2020 18:46:41 +0330 Subject: [PATCH 1/5] update ci --- .travis.yml | 9 +++++---- requirements.txt | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index f40ef2e..0d36728 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,5 @@ -dist: xenial +os: linux +dist: bionic language: python python: - "2.7" @@ -6,10 +7,10 @@ python: - "3.6" - "3.7" - "3.8" - - "3.9-dev" - - "pypy" + - "3.9" + - "3.10-dev" + - "pypy2" - "pypy3" - - "pypy3.5" install: - python -c "import sys, platform, struct; diff --git a/requirements.txt b/requirements.txt index 2e61db9..d98ede2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -coverage==5.2.1 +coverage==5.3 pytest==4.6.11 -pytest-cov==2.10.0 +pytest-cov==2.10.1 pytz==2020.1 From 3f68b26050e57c66c85831653682eb7e1fbdd701 Mon Sep 17 00:00:00 2001 From: Majid Date: Wed, 28 Oct 2020 19:08:10 +0330 Subject: [PATCH 2/5] =?UTF-8?q?=E2=9D=A4=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .appveyor.yml | 10 +++++++++- persiantools/__init__.py | 2 +- setup.py | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index f8464ea..976e02b 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,4 +1,4 @@ -version: '1.5.0.{build}' +version: '1.5.1.{build}' environment: matrix: @@ -42,6 +42,14 @@ environment: PYTHON_VERSION: 3.8 PYTHON_ARCH: 64 + - PYTHON: C:\Python39 + PYTHON_VERSION: 3.9 + PYTHON_ARCH: 32 + + - PYTHON: C:\Python39-x64 + PYTHON_VERSION: 3.9 + PYTHON_ARCH: 64 + init: - ECHO %PYTHON% %PYTHON_VERSION% %PYTHON_ARCH% diff --git a/persiantools/__init__.py b/persiantools/__init__.py index a9461e9..13bad97 100644 --- a/persiantools/__init__.py +++ b/persiantools/__init__.py @@ -9,7 +9,7 @@ __title__ = "persiantools" __url__ = "https://github.com/majiidd/persiantools" -__version__ = "1.5.0" +__version__ = "1.5.1" __build__ = __version__ __author__ = "Majid Hajiloo" __author_email__ = "majid.hajiloo@gmail.com" diff --git a/setup.py b/setup.py index a5a95d4..a0f6156 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,7 @@ def readme(): "Programming Language :: Python :: 3.9", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", + "Topic :: Software Development", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Localization", From 082fb68ff5459dabd383572a011b40854977d4dd Mon Sep 17 00:00:00 2001 From: Majid Date: Wed, 28 Oct 2020 19:38:03 +0330 Subject: [PATCH 3/5] =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BB=E2=80=8D?= =?UTF-8?q?=F0=9F=A6=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MANIFEST.in | 2 +- README.md | 3 ++- setup.py | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 4bf4483..a7ad28c 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include README.md \ No newline at end of file +include LICENSE README.md \ No newline at end of file diff --git a/README.md b/README.md index a2a2670..876a22b 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,9 @@ ## Install Package ```{.sourceCode .bash} -pip install persiantools +python -m pip install persiantools ``` +Persiantools supports Python 2.7 & 3.5+. ## How to use diff --git a/setup.py b/setup.py index a0f6156..aafaf02 100644 --- a/setup.py +++ b/setup.py @@ -51,4 +51,5 @@ def readme(): install_requires=[], include_package_data=True, zip_safe=False, + python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", ) From 44ec964d2dbd261c54f35f30fd85ff1490de3157 Mon Sep 17 00:00:00 2001 From: Majid Date: Wed, 28 Oct 2020 20:11:04 +0330 Subject: [PATCH 4/5] remove check_int_field --- persiantools/jdatetime.py | 7 ++++--- persiantools/utils.py | 20 -------------------- tests/test_utils.py | 9 --------- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/persiantools/jdatetime.py b/persiantools/jdatetime.py index 92a1283..26d1e63 100644 --- a/persiantools/jdatetime.py +++ b/persiantools/jdatetime.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import sys from datetime import date, timedelta, tzinfo, time as _time, datetime as dt +import operator from persiantools import digits, utils, PY2 @@ -160,9 +161,9 @@ def locale(self, locale): @classmethod def _check_date_fields(cls, year, month, day, locale): - year = utils.check_int_field(year) - month = utils.check_int_field(month) - day = utils.check_int_field(day) + year = operator.index(year) + month = operator.index(month) + day = operator.index(day) if not MINYEAR <= year <= MAXYEAR: raise ValueError("year must be in %d..%d" % (MINYEAR, MAXYEAR), year) diff --git a/persiantools/utils.py b/persiantools/utils.py index 0d234c4..25fd7a7 100644 --- a/persiantools/utils.py +++ b/persiantools/utils.py @@ -13,23 +13,3 @@ def replace(string, dictionary): pattern = re.compile("|".join(dictionary.keys())) return pattern.sub(lambda x: dictionary[x.group()], string) - - -def check_int_field(value): - if isinstance(value, int): - return value - - if not isinstance(value, float): - try: - value = value.__int__() - except AttributeError: - pass - else: - if isinstance(value, int): - return value - - raise TypeError("__int__ returned non-int (type %s)" % type(value).__name__) - - raise TypeError("an integer is required (got type %s)" % type(value).__name__) - - raise TypeError("integer argument expected, got float") diff --git a/tests/test_utils.py b/tests/test_utils.py index 53830a7..fe652dd 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -22,12 +22,3 @@ def test_replace(self): ), u"اایی بس که نباشیم و جهان خخووااههدد بود", ) - - def test_int(self): - self.assertEqual(utils.check_int_field(100010001), 100010001) - - with pytest.raises(TypeError): - utils.check_int_field(1111.9999) - - with pytest.raises(TypeError): - utils.check_int_field("1000") From 5482c01f4c1ce7d3c2ecfa9f946a0db479dd1f5f Mon Sep 17 00:00:00 2001 From: Majid Date: Wed, 28 Oct 2020 20:30:06 +0330 Subject: [PATCH 5/5] =?UTF-8?q?=E2=9B=85=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index aafaf02..a0f6156 100644 --- a/setup.py +++ b/setup.py @@ -51,5 +51,4 @@ def readme(): install_requires=[], include_package_data=True, zip_safe=False, - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*", )