gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [taler-bank] 02/04: pylint


From: gnunet
Subject: [GNUnet-SVN] [taler-bank] 02/04: pylint
Date: Fri, 03 Nov 2017 17:53:39 +0100

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

marcello pushed a commit to branch master
in repository bank.

commit 5c876a276c7cc14d18751e22e90d8274e526da20
Author: Marcello Stanisci <address@hidden>
AuthorDate: Fri Nov 3 17:05:41 2017 +0100

    pylint
---
 talerbank/app/checks.py  | 11 +++++------
 talerbank/app/models.py  |  9 +++++----
 talerbank/app/schemas.py | 22 +++++++++-------------
 3 files changed, 19 insertions(+), 23 deletions(-)

diff --git a/talerbank/app/checks.py b/talerbank/app/checks.py
index 6734d3a..7d50adb 100644
--- a/talerbank/app/checks.py
+++ b/talerbank/app/checks.py
@@ -1,4 +1,4 @@
-from django.core.checks import register, Warning
+from django.core.checks import register
 from django.db.utils import OperationalError
 
 
@@ -16,9 +16,8 @@ def example_check(app_configs, **kwargs):
                 id='talerbank.E001'
             ))
     except OperationalError:
-            errors.append(Warning(
-                'Presumably non existent database',
-                hint="create a database for the application",
-                id='talerbank.E002'
-            ))
+        errors.append(Warning(
+            'Presumably non existent database',
+            hint="create a database for the application",
+            id='talerbank.E002'))
     return errors
diff --git a/talerbank/app/models.py b/talerbank/app/models.py
index ebbb9f0..064dbed 100644
--- a/talerbank/app/models.py
+++ b/talerbank/app/models.py
@@ -19,12 +19,13 @@ from __future__ import unicode_literals
 from django.contrib.auth.models import User
 from django.db import models
 from django.conf import settings
+from django.core.exceptions import ValidationError
 from . import amount
 
 class AmountField(models.Field):
-    
+
     description = 'Amount object in Taler style'
-    
+
     def __init__(self, *args, **kwargs):
         super(AmountField, self).__init__(*args, **kwargs)
 
@@ -53,8 +54,8 @@ class AmountField(models.Field):
             if None is value:
                 return amount.Amount.parse(settings.TALER_CURRENCY)
             return amount.Amount.parse(value)
-        except amount.BadAmount:
-            raise models.ValidationError()
+        except amount.BadFormatAmount:
+            raise ValidationError("Invalid input for an amount string: %s" % 
value)
 
 def get_zero_amount():
     return amount.Amount(settings.TALER_CURRENCY)
diff --git a/talerbank/app/schemas.py b/talerbank/app/schemas.py
index 91771d1..e43947d 100644
--- a/talerbank/app/schemas.py
+++ b/talerbank/app/schemas.py
@@ -20,9 +20,8 @@ definitions of JSON schemas for validating data
 """
 
 import validictory
-from django.core.exceptions import ValidationError
 
-wiredetails_schema = {
+WIREDETAILS_SCHEMA = {
     "type": "object",
     "properties": {
         "test": {
@@ -37,7 +36,7 @@ wiredetails_schema = {
     }
 }
 
-auth_schema = {
+AUTH_SCHEMA = {
     "type": "object",
     "properties": {
         "type": {"type": "string"},
@@ -45,7 +44,7 @@ auth_schema = {
     }
 }
 
-amount_schema = {
+AMOUNT_SCHEMA = {
     "type": "object",
     "properties": {
         "value": {"type": "integer"},
@@ -54,25 +53,22 @@ amount_schema = {
     }
 }
 
-incoming_request_schema = {
+INCOMING_REQUEST_SCHEMA = {
     "type": "object",
     "properties": {
-        "amount": {"type": amount_schema},
+        "amount": {"type": AMOUNT_SCHEMA},
         "wtid": {"type": "string"},
         "exchange_url": {"type": "string"},
         "credit_account": {"type": "integer"},
-        "auth": auth_schema
+        "auth": AUTH_SCHEMA
     }
 }
 
 def validate_amount(amount):
-    validictory.validate(amount, amount_schema)
+    validictory.validate(amount, AMOUNT_SCHEMA)
 
 def validate_wiredetails(wiredetails):
-    validictory.validate(wiredetails, wiredetails_schema)
+    validictory.validate(wiredetails, WIREDETAILS_SCHEMA)
 
 def validate_incoming_request(incoming_request):
-    validictory.validate(incoming_request, incoming_request_schema)
-
-def validate_auth_basic(auth_basic):
-    validictory.validate(auth_basic, auth_basic_schema)
+    validictory.validate(incoming_request, INCOMING_REQUEST_SCHEMA)

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



reply via email to

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