gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: r


From: gnunet
Subject: [GNUnet-SVN] [taler-merchant-frontend-examples] branch master updated: remove bundled amount, use taler-util, add example setup.py
Date: Fri, 27 Sep 2019 18:19:16 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository merchant-frontend-examples.

The following commit(s) were added to refs/heads/master by this push:
     new 180232c  remove bundled amount, use taler-util, add example setup.py
180232c is described below

commit 180232cfa78ae0ee539da11cafd9c588590994d3
Author: ng0 <address@hidden>
AuthorDate: Fri Sep 27 16:18:36 2019 +0000

    remove bundled amount, use taler-util, add example setup.py
---
 .gitignore                        |  6 ++++
 python/example/example.py         |  6 ++--
 python/example/setup.py           | 12 +++++++
 python/lib/Makefile               |  5 ---
 python/lib/pytaler/__init__.py    |  0
 python/lib/pytaler/amount.py      | 72 ---------------------------------------
 python/lib/pytaler/test_amount.py | 32 -----------------
 python/lib/setup.py               | 11 ------
 8 files changed, 21 insertions(+), 123 deletions(-)

diff --git a/.gitignore b/.gitignore
index e8425a9..987b4bd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -15,3 +15,9 @@ python/doc/tutorial.html
 python/doc/tutorial.log
 python/doc/tutorial.pdf
 python/doc/tutorial.toc
+
+__pycache__
+dist
+*.egg-info
+test-env
+
diff --git a/python/example/example.py b/python/example/example.py
index 2f90392..505144c 100644
--- a/python/example/example.py
+++ b/python/example/example.py
@@ -1,7 +1,7 @@
 import flask
 import requests
 from urllib.parse import urljoin, urlencode
-from pytaler import amount
+import taler.util.amount
 import base64
 import os
 import logging
@@ -47,8 +47,8 @@ def donate():
 
 @app.route("/generate-proposal")
 def generate_proposal():
-    DONATION = amount.string_to_amount("0.1:%s" % CURRENCY) 
-    MAX_FEE = amount.string_to_amount("0.05:%s" % CURRENCY) 
+    DONATION = amount.string_to_amount("0.1:%s" % CURRENCY)
+    MAX_FEE = amount.string_to_amount("0.05:%s" % CURRENCY)
     ORDER_ID = "tutorial-%X-%s" % (randint(0, 0xFFFFFFFF), 
datetime.today().strftime("%H_%M_%S"))
     order = dict(
         order_id=ORDER_ID,
diff --git a/python/example/setup.py b/python/example/setup.py
new file mode 100644
index 0000000..4dedfc4
--- /dev/null
+++ b/python/example/setup.py
@@ -0,0 +1,12 @@
+from setuptools import setup, find_packages
+
+setup(
+        name='example',
+        version='0.6.0rc0',
+        long_description=__doc__,
+        packages=find_packages(),
+        include_package_data=True,
+        zip_safe=False,
+        install_requires=['Flask',
+                          'taler-util']
+        )
diff --git a/python/lib/Makefile b/python/lib/Makefile
deleted file mode 100644
index cf3cacc..0000000
--- a/python/lib/Makefile
+++ /dev/null
@@ -1,5 +0,0 @@
-install:
-       pip3 install . --install-option="--prefix=$(TALER_PREFIX)" --upgrade
-
-check:
-       python3 pytaler/tests.py
diff --git a/python/lib/pytaler/__init__.py b/python/lib/pytaler/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/python/lib/pytaler/amount.py b/python/lib/pytaler/amount.py
deleted file mode 100644
index e15e623..0000000
--- a/python/lib/pytaler/amount.py
+++ /dev/null
@@ -1,72 +0,0 @@
-# This file is part of GNU TALER.
-# Copyright (C) 2014-2017 INRIA
-#
-# TALER is free software; you can redistribute it and/or modify it under the
-# terms of the GNU Lesser General Public License as published by the Free 
Software
-# Foundation; either version 2.1, or (at your option) any later version.
-#
-# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more 
details.
-#
-# You should have received a copy of the GNU Lesser General Public License 
along with
-# GNU TALER; see the file COPYING.  If not, see <http://www.gnu.org/licenses/>
-#
-# @author Marcello Stanisci
-
-import re
-
-FRACTION = 100000000
-
-def amount_get_zero(currency):
-    return dict(value=0, fraction=0, currency=currency)
-
-def string_to_amount(fmt):
-    pattern = re.compile("^[0-9]+\.[0-9]+:[A-Z]+$")
-    assert(pattern.match(fmt))
-    split = fmt.split(":")
-    num = split[0]
-    currency = split[1]
-    split = num.split(".")
-    value = int(split[0])
-    fraction = float("0." + split[1]) * FRACTION
-    return dict(value=value, fraction=int(fraction), currency=currency)
-
-
-def amount_sum(a1, a2):
-    assert(a1['currency'] == a2['currency'])
-    fractions = a1['fraction'] + a2['fraction']
-    ret = {"value": a1["value"] + a2["value"] + int(fractions / FRACTION),
-           "fraction": fractions % FRACTION,
-           "currency": a1["currency"]}
-    return ret
-
-# True if a1 == a2
-def same_amount(a1, a2):
-    return a1["value"] == a2["value"] and a1["fraction"] == a2["fraction"] and 
a1["currency"] == a2["currency"]
-
-# Computes a1 - a2
-def amount_sub(a1, a2):
-    assert(a1["currency"] == a2["currency"])
-
-    # Normalize
-    a1["value"] += int(a1["fraction"] / FRACTION)
-    a2["value"] += int(a2["fraction"] / FRACTION)
-    a1["fraction"] = a1["fraction"] % FRACTION
-    a2["fraction"] = a2["fraction"] % FRACTION
-
-    # Extra care for fraction
-    if a1["fraction"] < a2["fraction"]:
-        a1["fraction"] += FRACTION
-        a1["value"] -= 1
-        assert(a1["value"] >= 0)
-
-    # Sub
-    ret = amount_get_zero(a1["currency"])
-    ret["value"] = a1["value"] - a2["value"]
-    ret["fraction"] = a1["fraction"] - a2["fraction"]
-
-    assert(ret["value"] >= 0)
-    assert(ret["fraction"] >= 0)
-
-    return ret
diff --git a/python/lib/pytaler/test_amount.py 
b/python/lib/pytaler/test_amount.py
deleted file mode 100644
index ffc8cba..0000000
--- a/python/lib/pytaler/test_amount.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import unittest
-import amounts
-from random import randint
-
-CURRENCY = "KUDOS"
-
-class AmountsTest(unittest.TestCase):
-
-    def test_sum_sub(self):
-        a1 = amounts.amount_get_zero(CURRENCY)
-        a2 = amounts.amount_get_zero(CURRENCY)
-        v1 = randint(1, 200)
-        v2 = randint(1, 200)
-        f1 = randint(10000000, 100000000)
-        f2 = randint(10000000, 100000000)
-        a1['value'] = v1
-        a2['value'] = v2
-        a1['fraction'] = f1
-        a2['fraction'] = f2
-        res1 = amounts.amount_sum(a1, a2)
-        res2 = amounts.amount_sub(res1, a1)
-        self.assertTrue(amounts.same_amount(res2, a2))
-
-
-    def test_string_to_amount(self):
-        model = dict(value=1, fraction=0, currency=CURRENCY)
-        amount = amounts.string_to_amount("1.0:%s" % CURRENCY)
-        self.assertTrue(amounts.same_amount(model, amount))
-
-
-if __name__ == '__main__':
-    unittest.main()
diff --git a/python/lib/setup.py b/python/lib/setup.py
deleted file mode 100755
index 5727698..0000000
--- a/python/lib/setup.py
+++ /dev/null
@@ -1,11 +0,0 @@
-from setuptools import setup, find_packages
-
-setup(name='pytaler',
-      version='0.0',
-      description='Helper functions for Taler amounts',
-      url='git://taler.net/merchant-frontend-examples',
-      author='Marcello Stanisci',
-      author_email='address@hidden',
-      license='GPL',
-      packages=find_packages(),
-      zip_safe=False)

-- 
To stop receiving notification emails like this one, please contact
address@hidden.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]