Skip to content

Commit

Permalink
Merge pull request #4 from majiidd/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
majiidd committed Oct 28, 2020
2 parents 79f4850 + 5482c01 commit e9264c6
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 42 deletions.
10 changes: 9 additions & 1 deletion .appveyor.yml
@@ -1,4 +1,4 @@
version: '1.5.0.{build}'
version: '1.5.1.{build}'

environment:
matrix:
Expand Down Expand Up @@ -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%

Expand Down
9 changes: 5 additions & 4 deletions .travis.yml
@@ -1,15 +1,16 @@
dist: xenial
os: linux
dist: bionic
language: python
python:
- "2.7"
- "3.5"
- "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;
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
@@ -1 +1 @@
include README.md
include LICENSE README.md
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion persiantools/__init__.py
Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions 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

Expand Down Expand Up @@ -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)
Expand Down
20 changes: 0 additions & 20 deletions persiantools/utils.py
Expand Up @@ -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")
4 changes: 2 additions & 2 deletions 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
1 change: 1 addition & 0 deletions setup.py
Expand Up @@ -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",
Expand Down
9 changes: 0 additions & 9 deletions tests/test_utils.py
Expand Up @@ -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")

0 comments on commit e9264c6

Please sign in to comment.