From 9997a003d9200782c446b790adf7aabbd8270263 Mon Sep 17 00:00:00 2001 From: smithumble Date: Tue, 9 Oct 2018 11:31:28 +0300 Subject: [PATCH 1/6] Add constants.ini file. Add BUDGET_PERIOD_FROM constant. --- src/openprocurement/api/constants.ini | 2 ++ src/openprocurement/api/constants.py | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 src/openprocurement/api/constants.ini diff --git a/src/openprocurement/api/constants.ini b/src/openprocurement/api/constants.ini new file mode 100644 index 0000000000..a719e46292 --- /dev/null +++ b/src/openprocurement/api/constants.ini @@ -0,0 +1,2 @@ +[DEFAULT] +BUDGET_PERIOD_FROM = 2017-10-1 \ No newline at end of file diff --git a/src/openprocurement/api/constants.py b/src/openprocurement/api/constants.py index acc42323c5..1cf47a87a2 100644 --- a/src/openprocurement/api/constants.py +++ b/src/openprocurement/api/constants.py @@ -1,6 +1,10 @@ # -*- coding: utf-8 -*- import os import re +import sys +from ConfigParser import ConfigParser, DEFAULTSECT + +from iso8601 import parse_date from pytz import timezone from datetime import datetime from pkg_resources import get_distribution @@ -49,3 +53,25 @@ def read_json(name): CPV_BLOCK_FROM = datetime(2017, 6, 2, tzinfo=TZ) ATC_INN_CLASSIFICATIONS_FROM = datetime(2017, 12, 22, tzinfo=TZ) + +def get_default_constants_file_path(): + return os.path.join(os.path.dirname(os.path.realpath(__file__)), 'constants.ini') + +def load_constants(file_path): + config = ConfigParser() + try: + with open(file_path) as fp: + config.readfp(fp) + except Exception as e: + raise type(e), type(e)( + 'Can\'t read file \'{0}\': use current path or override using ' + 'CONSTANTS_FILE_PATH env variable'.format(file_path)), sys.exc_info()[2] + return config + +def get_constant(config, constant, section=DEFAULTSECT, parse_func=parse_date): + return parse_func(config.get(section, constant)) + +CONSTANTS_FILE_PATH = os.environ.get('CONSTANTS_FILE_PATH', get_default_constants_file_path()) +CONSTANTS_CONFIG = load_constants(CONSTANTS_FILE_PATH) + +BUDGET_PERIOD_FROM = get_constant(CONSTANTS_CONFIG, 'BUDGET_PERIOD_FROM') From 24a303c499c63262bd335e0653e5ad84e738f3c2 Mon Sep 17 00:00:00 2001 From: smithumble Date: Tue, 9 Oct 2018 11:44:52 +0300 Subject: [PATCH 2/6] Set TZ to constants date parser. --- src/openprocurement/api/constants.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openprocurement/api/constants.py b/src/openprocurement/api/constants.py index 1cf47a87a2..55a8c9c06d 100644 --- a/src/openprocurement/api/constants.py +++ b/src/openprocurement/api/constants.py @@ -68,7 +68,10 @@ def load_constants(file_path): 'CONSTANTS_FILE_PATH env variable'.format(file_path)), sys.exc_info()[2] return config -def get_constant(config, constant, section=DEFAULTSECT, parse_func=parse_date): +def parse_date_tz(datestring): + return parse_date(datestring, TZ) + +def get_constant(config, constant, section=DEFAULTSECT, parse_func=parse_date_tz): return parse_func(config.get(section, constant)) CONSTANTS_FILE_PATH = os.environ.get('CONSTANTS_FILE_PATH', get_default_constants_file_path()) From 01053ab7d922bddfca83b0ded1385f4514cae759 Mon Sep 17 00:00:00 2001 From: vladkhard Date: Wed, 24 Oct 2018 12:27:21 +0300 Subject: [PATCH 3/6] fix IsoDurationType bug with datetime.timedelta --- src/openprocurement/api/models.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/openprocurement/api/models.py b/src/openprocurement/api/models.py index 3fe76dea15..58466f5de4 100644 --- a/src/openprocurement/api/models.py +++ b/src/openprocurement/api/models.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import re -from datetime import datetime +from datetime import datetime, timedelta from decimal import Decimal, InvalidOperation, ROUND_HALF_UP from iso8601 import parse_date, ParseError from isodate import ISO8601Error, parse_duration, duration_isoformat @@ -174,6 +174,8 @@ class IsoDurationType(BaseType): def to_native(self, value, context=None): if isinstance(value, Duration): return value + elif isinstance(value, timedelta): + return value try: return parse_duration(value) except TypeError: From 875a70ec35c43eb88bdd26eab41ea6feec0661da Mon Sep 17 00:00:00 2001 From: Taras Kozlovskyi Date: Mon, 29 Oct 2018 14:02:00 +0200 Subject: [PATCH 4/6] Prettify code --- src/openprocurement/api/models.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/openprocurement/api/models.py b/src/openprocurement/api/models.py index 58466f5de4..59fbec761b 100644 --- a/src/openprocurement/api/models.py +++ b/src/openprocurement/api/models.py @@ -172,9 +172,7 @@ class IsoDurationType(BaseType): } def to_native(self, value, context=None): - if isinstance(value, Duration): - return value - elif isinstance(value, timedelta): + if isinstance(value, Duration) or isinstance(value, timedelta): return value try: return parse_duration(value) From 048b78be646b25f8b2d24c8dc1d911bac437c562 Mon Sep 17 00:00:00 2001 From: Taras Kozlovskyi Date: Mon, 29 Oct 2018 15:30:45 +0200 Subject: [PATCH 5/6] Added tests on IsoDurationType with datetime.timedelta and Duration --- src/openprocurement/api/tests/dev_tools.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/openprocurement/api/tests/dev_tools.py b/src/openprocurement/api/tests/dev_tools.py index bfb628760c..0dcbaef83e 100644 --- a/src/openprocurement/api/tests/dev_tools.py +++ b/src/openprocurement/api/tests/dev_tools.py @@ -2,7 +2,7 @@ import os import sys import unittest - +from datetime import timedelta from isodate import duration_isoformat from isodate.duration import Duration from schematics.transforms import whitelist @@ -104,6 +104,15 @@ def test_iso_duration_type(self): self.assertEqual('P3Y6M4DT12H30M5S', res_dur1) self.assertEqual('P2Y18M4DT12H30M5S', res_dur2) + def test_iso_duration_type_from_timedelta(self): + duration_instance = IsoDurationType() + duration = timedelta(days=1) + self.assertEqual(duration_instance(duration), duration) + + def test_iso_duration_type_from_Duration(self): + duration_instance = IsoDurationType() + duration = Duration(months=1, days=1) + self.assertEqual(duration_instance(duration), duration) def suite(): suite = unittest.TestSuite() From 77a8b39f66f8444acd487dba6196f9c0c63b369e Mon Sep 17 00:00:00 2001 From: Dmitriy Belyaev Date: Tue, 6 Nov 2018 13:46:22 +0200 Subject: [PATCH 6/6] update versions from openprocurement.buildout repo --- versions.cfg | 165 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 135 insertions(+), 30 deletions(-) diff --git a/versions.cfg b/versions.cfg index a4b015ab07..eb28d7d228 100644 --- a/versions.cfg +++ b/versions.cfg @@ -1,48 +1,153 @@ [versions] + +APScheduler = 3.0.6 +CouchDB = 1.0.1 +Genshi = 0.7 +Jinja2 = 2.7.3 +Paste = 1.7.5.1 +PasteDeploy = 1.5.2 +Pygments = 2.0.2 +Sphinx = 1.3.4 +WebOb = 1.6.1 +WebTest = 2.0.20 +ZEO = 4.0.0 +ZODB = 4.0.1 +circus = 0.13.0 +circus-web = 1.0.0 +collective.recipe.sphinxbuilder = 0.8.2 +collective.recipe.template = 1.11 +coverage = 4.0.3 +jsonpointer = 1.9 +mr.developer = 1.31 +nose = 1.3.7 +persistent = 4.0.8 +py = 1.4.26 +repoze.lru = 0.6 +repoze.profile = 2.1 +translationstring = 1.3 +venusian = 1.0 +waitress = 0.8.10 +zc.buildout = 2.2.5 +zc.recipe.egg = 2.0.3 +zdaemon = 4.0.0 +zope.configuration = 4.0.3 +zope.deprecation = 4.1.1 +zope.interface = 4.1.1 +zope.proxy = 4.1.4 +ExtendedJournalHandler = 0.0.1 +mock = 1.0 +BTrees = 4.0.8 +Mako = 1.0.0 +MarkupSafe = 0.23 +TornadIO2 = 0.0.3 +ZConfig = 3.0.4 +ZODB3 = 3.11.0 +anyjson = 0.3.3 +backports.ssl-match-hostname = 3.4.0.2 beautifulsoup4 = 4.3.2 boto = 2.31.1 +certifi = 14.05.14 chaussette = 1.3.0 cornice = 1.2.0.dev0 -CouchDB = 1.0 couchdb-schematics = 1.1.1 -coverage = 4.0.3 docutils = 0.12 +futures = 2.2.0 gevent = 1.1.1 greenlet = 0.4.9 +iowait = 0.2 iso8601 = 0.1.11 -Jinja2 = 2.7.3 jsonpatch = 1.13-jsondiff.unicode.replacefix.0 -jsonpointer = 1.9 -LEPL = 5.1.3 -MarkupSafe = 0.23 -mock = 1.0.1 -nose = 1.3.7 -PasteDeploy = 1.5.2 -pbkdf2 = 1.3 -py = 1.4.26 -Pygments = 2.0.2 -pyramid = 1.6.1 -pyramid-exclog = 0.7 +psutil = 2.1.3 +pyprof2calltree = 1.3.2 +pyramid = 1.7 +pyramid-zcml = 1.0.0 pytest = 2.6.4 pytest-cov = 2.5.1 -python-coveralls = 2.9.1 pytz = 2014.10 -PyYAML = 3.11 -repoze.lru = 0.6 -requests = 2.7.0 -rfc6266 = 0.0.6 +pyzmq = 14.4.1 +requests = 2.10.0 schematics = 1.1.1 -sh = 1.11 +setuptools = 7.0 simplejson = 3.6.5 six = 1.9.0 -Sphinx = 1.3.1 sphinxcontrib-httpdomain = 1.4.0 -translationstring = 1.3 -tzlocal = 1.1.2 -venusian = 1.0 -waitress = 0.8.10 -WebOb = 1.5.1 -WebTest = 2.0.20 -zc.recipe.egg = 2.0.1 -zope.deprecation = 4.1.1 -zope.interface = 4.1.1 +tomako = 0.1.0 +tornado = 4.0.2 +transaction = 1.4.3 +tzlocal = 1.2.1 +zc.lockfile = 1.1.0 +zope.annotation = 4.2.0 +zope.authentication = 4.1.0 +zope.browser = 2.0.2 +zope.component = 4.1.0 +zope.event = 4.0.3 +zope.i18nmessageid = 4.0.3 +zope.location = 4.0.3 +zope.schema = 4.4.2 +zope.security = 4.0.1 +zope.securitypolicy = 3.7.0 +loggly-handler = 0.1.2 +requests-futures = 0.9.5 +SQLAlchemy = 1.0.9 +pysqlite = 2.8.2 +pyramid-exclog = 0.7 +Babel = 1.3 +netaddr = 0.7.13 +oslo.config = 1.6.0 +oslo.context = 0.1.0 +oslo.i18n = 1.3.1 +pbr = 0.10.7 +request-id-middleware = 0.1.2 +stevedore = 1.2.0 +argparse = 1.3.0 +oslo.middleware = 0.4.0 +pip = 6.0.7 +rfc6266 = 0.0.6 +LEPL = 5.1.3 +z3c.recipe.usercrontab = 1.1 +awscli = 1.7.12 +bcdoc = 0.13.0 +botocore = 0.93.0 +colorama = 0.3.3 +python-dateutil = 2.4.0 +rsa = 3.1.4 +pbkdf2 = 1.3 +pycrypto = 2.6.1 +grequests = 0.2.0 +cffi = 1.4.1 +cryptography = 1.2.3 +idna = 2.0 +pyOpenSSL = 0.15.1 +enum34 = 1.0.4 +ipaddress = 1.0.14 +ndg-httpsclient = 0.4.0 +pycparser = 2.14 +pyasn1 = 0.1.8 +server-cookie-middleware = 0.2 +barbecue = 0.2 +unweb.recipe.uwsgi = 0.4 +alabaster = 0.7.6 +snowballstemmer = 1.2.0 +sphinx-rtd-theme = 0.1.9 +zc.sourcerelease = 0.4.0 +repoze.retry = 1.3 +funcsigs = 0.4 +http-parser = 0.8.3 +socketpool = 0.5.3 +PyYAML = 3.11 +munch = 2.0.4 +restkit = 4.2.2 +retrying = 1.3.3 +python-consul = 0.6.0 +LazyDB = 0.1.68 +openprocurement-client = 2.0.0 +libnacl = 1.4.5 +redis = 2.10.5 +sact.recipe.jinjatemplate = 1.3.0 +z3c.recipe.mkdir = 0.6 +openprocurement.circus.plugins = 1.0 +openprocurement.subscribers.serverid = 1.0 +esculator = 0.0.2 +python-coveralls = 2.9.1 +jmespath = 0.9.3 +isodate = 0.6.0