diff --git a/src/sakia/core/account.py b/src/sakia/core/account.py index 4af3477d7c9f8e44a78f44d30cee019fcf19754b..1f5cd1c3b272b076febea057c3c4905a524a27eb 100644 --- a/src/sakia/core/account.py +++ b/src/sakia/core/account.py @@ -11,7 +11,7 @@ from ucoinpy.key import SigningKey import logging import time import asyncio -from distutils.version import StrictVersion +from pkg_resources import parse_version from PyQt5.QtCore import QObject, pyqtSignal @@ -106,9 +106,9 @@ class Account(QObject): salt = json_data['salt'] pubkey = json_data['pubkey'] if 'file_version' in json_data: - file_version = StrictVersion(json_data['file_version']) + file_version = parse_version(json_data['file_version']) else: - file_version = StrictVersion('0.11.5') + file_version = parse_version('0.11.5') name = json_data['name'] contacts = [] diff --git a/src/sakia/core/app.py b/src/sakia/core/app.py index 860be4955f64da5b9fae58833a21ef1e14ad717a..5cf4033473af2267152db794cf89df2124f2c6cc 100644 --- a/src/sakia/core/app.py +++ b/src/sakia/core/app.py @@ -11,7 +11,7 @@ import shutil import json import datetime import aiohttp -from distutils.version import StrictVersion +from pkg_resources import parse_version from PyQt5.QtCore import QObject, pyqtSignal, QTranslator, QCoreApplication, QLocale from ucoinpy.api.bma import API @@ -279,7 +279,7 @@ class Application(QObject): if os.path.exists(network_path): with open(network_path, 'r') as json_data: data = json.load(json_data) - community.network.merge_with_json(data['network'], StrictVersion(data['version'])) + community.network.merge_with_json(data['network'], parse_version(data['version'])) if os.path.exists(bma_path): with open(bma_path, 'r') as json_data: diff --git a/src/sakia/core/community.py b/src/sakia/core/community.py index cbc86b64e31cc79f449a7aa8ecd38924a411ccc6..be3f008626789cce14333931a1b08e94075e4d0a 100644 --- a/src/sakia/core/community.py +++ b/src/sakia/core/community.py @@ -62,7 +62,7 @@ class Community(QObject): Load a community from json :param dict json_data: The community as a dict in json format - :param distutils.version.StrictVersion file_version: the file sakia version + :param NormalizedVersion file_version: the file sakia version """ currency = json_data['currency'] network = Network.from_json(currency, json_data['peers'], file_version) diff --git a/src/sakia/core/net/network.py b/src/sakia/core/net/network.py index 7cb64c1d9634f299ce7e55f7cdda65980040d0c4..eb4e02ec258705f9194b59a9f5d513e319039658 100644 --- a/src/sakia/core/net/network.py +++ b/src/sakia/core/net/network.py @@ -63,7 +63,7 @@ class Network(QObject): last stopped sakia :param dict json_data: Nodes in json format - :param distutils.version.StrictVersion file_version: The node version + :param NormalizedVersion file_version: The node version """ for data in json_data: node = Node.from_json(self.currency, data, file_version) @@ -94,7 +94,7 @@ class Network(QObject): :param str currency: The currency name of a community :param dict json_data: A json_data view of a network - :param distutils.version.StrictVersion file_version: the version of the json file + :param NormalizedVersion file_version: the version of the json file """ nodes = [] for data in json_data: diff --git a/src/sakia/core/net/node.py b/src/sakia/core/net/node.py index fe2d5c2a3fd52c22faa0304d4bcd3957693e0147..6c407bab524725276b2d6d20787a34e6e426de72 100644 --- a/src/sakia/core/net/node.py +++ b/src/sakia/core/net/node.py @@ -19,7 +19,7 @@ import time import jsonschema import asyncio import aiohttp -from distutils.version import StrictVersion +from pkg_resources import parse_version from socket import gaierror from PyQt5.QtCore import QObject, pyqtSignal @@ -123,7 +123,7 @@ class Node(QObject): :param str currency: the currency of the community :param dict data: the json data of the node - :param StrictVersion file_version: the version of the file + :param NormalizedVersion file_version: the version of the file :return: A new node :rtype: Node """ @@ -160,7 +160,7 @@ class Node(QObject): if 'fork_window' in data: fork_window = data['fork_window'] - if file_version < StrictVersion("0.12"): + if file_version < parse_version("0.12"): for endpoint_data in data['endpoints']: endpoints.append(Endpoint.from_inline(endpoint_data)) diff --git a/src/sakia/tests/unit/core/test_community.py b/src/sakia/tests/unit/core/test_community.py index 80e0f2f34de13303b2bf00ab29802b5ccd34bde5..760764e330c3b007631edef042b841ef634a5021 100644 --- a/src/sakia/tests/unit/core/test_community.py +++ b/src/sakia/tests/unit/core/test_community.py @@ -1,6 +1,6 @@ import sys import unittest -from distutils.version import StrictVersion +from pkg_resources import parse_version from PyQt5.QtCore import QLocale from sakia.core.net.api.bma.access import BmaAccess from sakia.core.net.network import Network @@ -22,6 +22,6 @@ class TestCommunity(unittest.TestCase, QuamashTest): community = Community("test_currency", network, bma_access) json_data = community.jsonify() - community_from_json = Community.load(json_data, StrictVersion('0.12.0')) + community_from_json = Community.load(json_data, parse_version('0.12.0')) self.assertEqual(community.name, community_from_json.name) self.assertEqual(len(community.network._nodes), len(community_from_json.network._nodes))