[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [taler-merchant-frontend-examples] 01/03: Adding initial lo
From: |
gnunet |
Subject: |
[GNUnet-SVN] [taler-merchant-frontend-examples] 01/03: Adding initial logic for amounts arithmetics in Python library. |
Date: |
Mon, 20 Feb 2017 17:08:06 +0100 |
This is an automated email from the git hooks/post-receive script.
marcello pushed a commit to branch master
in repository merchant-frontend-examples.
commit de86dc7d48959ac5f2f9eee2245df54ff8761333
Author: Marcello Stanisci <address@hidden>
AuthorDate: Mon Feb 20 16:51:40 2017 +0100
Adding initial logic for amounts arithmetics
in Python library.
---
Makefile | 2 +-
Python/pytaler/__init__.py | 0
Python/pytaler/amounts.py | 29 +++++++++++++++++++++++++++++
Python/setup.py | 11 +++++++++++
4 files changed, 41 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index d3a8693..4a1d444 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
.PHONY: graphics
-SUBDIRS := php
+SUBDIRS := php Python
all: $(SUBDIRS)
diff --git a/Python/pytaler/__init__.py b/Python/pytaler/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/Python/pytaler/amounts.py b/Python/pytaler/amounts.py
new file mode 100644
index 0000000..9c5e83c
--- /dev/null
+++ b/Python/pytaler/amounts.py
@@ -0,0 +1,29 @@
+# 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
+
+FRACTION = 100000000
+
+def amount_get_zero(currency):
+ return {"value": 0, "fraction": 0, "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
diff --git a/Python/setup.py b/Python/setup.py
new file mode 100755
index 0000000..5727698
--- /dev/null
+++ b/Python/setup.py
@@ -0,0 +1,11 @@
+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