From 007785a711fa6ce391f903152f05d43e6a4fadc2 Mon Sep 17 00:00:00 2001
From: Vincent Texier <vit@free.fr>
Date: Sun, 15 Jul 2018 15:48:52 +0200
Subject: [PATCH] issue #56 WIP - Constants in upper case

https://www.python.org/dev/peps/pep-0008/#constants
---
 duniterpy/api/endpoint.py            | 36 ++++++++++-----------
 duniterpy/constants.py               | 38 +++++++++++-----------
 duniterpy/documents/block.py         | 18 +++++------
 duniterpy/documents/certification.py | 48 ++++++++++++++--------------
 duniterpy/documents/crc_pubkey.py    |  4 +--
 duniterpy/documents/document.py      |  4 +--
 duniterpy/documents/membership.py    | 14 ++++----
 duniterpy/documents/peer.py          |  6 ++--
 duniterpy/documents/transaction.py   | 20 ++++++------
 duniterpy/documents/ws2p/heads.py    | 24 +++++++-------
 duniterpy/grammars/output.py         |  6 ++--
 11 files changed, 109 insertions(+), 109 deletions(-)

diff --git a/duniterpy/api/endpoint.py b/duniterpy/api/endpoint.py
index 1b205979..45e98814 100644
--- a/duniterpy/api/endpoint.py
+++ b/duniterpy/api/endpoint.py
@@ -119,9 +119,9 @@ class BMAEndpoint(Endpoint):
     API = "BASIC_MERKLED_API"
     re_inline = re.compile(
         '^BASIC_MERKLED_API(?: ({host_regex}))?(?: ({ipv4_regex}))?(?: ({ipv6_regex}))?(?: ([0-9]+))$'.format(
-            host_regex=host_regex,
-            ipv4_regex=ipv4_regex,
-            ipv6_regex=ipv6_regex))
+            host_regex=HOST_REGEX,
+            ipv4_regex=IPV4_REGEX,
+            ipv6_regex=IPV6_REGEX))
 
     def __init__(self, server: str, ipv4: str, ipv6: str, port: int):
         """
@@ -200,10 +200,10 @@ class SecuredBMAEndpoint(BMAEndpoint):
     API = "BMAS"
     re_inline = re.compile(
         '^BMAS(?: ({host_regex}))?(?: ({ipv4_regex}))?(?: ({ipv6_regex}))? ([0-9]+)(?: ({path_regex}))?$'.format(
-            host_regex=host_regex,
-            ipv4_regex=ipv4_regex,
-            ipv6_regex=ipv6_regex,
-            path_regex=path_regex))
+            host_regex=HOST_REGEX,
+            ipv4_regex=IPV4_REGEX,
+            ipv6_regex=IPV6_REGEX,
+            path_regex=PATH_REGEX))
 
     def __init__(self, server: str, ipv4: str, ipv6: str, port: int, path: str):
         """
@@ -268,11 +268,11 @@ class WS2PEndpoint(Endpoint):
     API = "WS2P"
     re_inline = re.compile(
         '^WS2P ({ws2pid_regex}) ((?:{host_regex})|(?:{ipv4_regex})) ([0-9]+)?(?: ({path_regex}))?$'.format(
-            ws2pid_regex=ws2pid_regex,
-            host_regex=host_regex,
-            ipv4_regex=ipv4_regex,
-            ipv6_regex=ipv6_regex,
-            path_regex=path_regex))
+            ws2pid_regex=WS2PID_REGEX,
+            host_regex=HOST_REGEX,
+            ipv4_regex=IPV4_REGEX,
+            ipv6_regex=IPV6_REGEX,
+            path_regex=PATH_REGEX))
 
     def __init__(self, ws2pid, server, port, path):
         self.ws2pid = ws2pid
@@ -324,9 +324,9 @@ class WS2PEndpoint(Endpoint):
 class ESUserEndpoint(Endpoint):
     API = "ES_USER_API"
     re_inline = re.compile(
-        '^ES_USER_API ((?:{host_regex})|(?:{ipv4_regex})) ([0-9]+)$'.format(ws2pid_regex=ws2pid_regex,
-                                                                            host_regex=host_regex,
-                                                                            ipv4_regex=ipv4_regex))
+        '^ES_USER_API ((?:{host_regex})|(?:{ipv4_regex})) ([0-9]+)$'.format(ws2pid_regex=WS2PID_REGEX,
+                                                                            host_regex=HOST_REGEX,
+                                                                            ipv4_regex=IPV4_REGEX))
 
     def __init__(self, server, port):
         self.server = server
@@ -371,9 +371,9 @@ class ESUserEndpoint(Endpoint):
 class ESSubscribtionEndpoint(Endpoint):
     API = "ES_SUBSCRIPTION_API"
     re_inline = re.compile(
-        '^ES_SUBSCRIPTION_API ((?:{host_regex})|(?:{ipv4_regex})) ([0-9]+)$'.format(ws2pid_regex=ws2pid_regex,
-                                                                                    host_regex=host_regex,
-                                                                                    ipv4_regex=ipv4_regex))
+        '^ES_SUBSCRIPTION_API ((?:{host_regex})|(?:{ipv4_regex})) ([0-9]+)$'.format(ws2pid_regex=WS2PID_REGEX,
+                                                                                    host_regex=HOST_REGEX,
+                                                                                    ipv4_regex=IPV4_REGEX))
 
     def __init__(self, server, port):
         self.server = server
diff --git a/duniterpy/constants.py b/duniterpy/constants.py
index 7e6b875e..46fc3028 100644
--- a/duniterpy/constants.py
+++ b/duniterpy/constants.py
@@ -1,17 +1,17 @@
-uid_regex = "[A-Za-z0-9_-]{2,100}"
-pubkey_regex = "(?![OIl])[1-9A-Za-z]{42,45}"
-signature_regex = "[A-Za-z0-9+/]+(?:=|==)?"
-block_hash_regex = "[0-9a-fA-F]{5,64}"
-transaction_hash_regex = "[0-9a-fA-F]{5,64}"
-hash_regex = "[A-F0-9]{64}"
-block_id_regex = "[0-9]+"
-block_uid_regex = "{block_id_regex}-{block_hash_regex}".format(block_id_regex=block_id_regex,
-                                                               block_hash_regex=block_hash_regex)
-conditions_regex = "(&&|\|\|| |[()]|(SIG\({pubkey_regex}\)|(XHX\({hash_regex}\))))*" \
-    .format(pubkey_regex=pubkey_regex, hash_regex=hash_regex)
-ipv4_regex = '(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][' \
+UID_REGEX = "[A-Za-z0-9_-]{2,100}"
+PUBKEY_REGEX = "(?![OIl])[1-9A-Za-z]{42,45}"
+SIGNATURE_REGEX = "[A-Za-z0-9+/]+(?:=|==)?"
+BLOCK_HASH_REGEX = "[0-9a-fA-F]{5,64}"
+TRANSACTION_HASH_REGEX = "[0-9a-fA-F]{5,64}"
+HASH_REGEX = "[A-F0-9]{64}"
+BLOCK_ID_REGEX = "[0-9]+"
+BLOCK_UID_REGEX = "{block_id_regex}-{block_hash_regex}".format(block_id_regex=BLOCK_ID_REGEX,
+                                                               block_hash_regex=BLOCK_HASH_REGEX)
+CONDITIONS_REGEX = "(&&|\|\|| |[()]|(SIG\({pubkey_regex}\)|(XHX\({hash_regex}\))))*" \
+    .format(pubkey_regex=PUBKEY_REGEX, hash_regex=HASH_REGEX)
+IPV4_REGEX = '(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][' \
              '0-9]|25[0-5])'
-ipv6_regex = '(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[' \
+IPV6_REGEX = '(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[' \
              '0-4][0-9]|25[0-5])\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|::(?:[0-9A-Fa-f]{1,' \
              '4}:){5}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){' \
              '3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))|(?:[0-9A-Fa-f]{1,4})?::(?:[0-9A-Fa-f]{1,' \
@@ -27,9 +27,9 @@ ipv6_regex = '(?:(?:[0-9A-Fa-f]{1,4}:){6}(?:[0-9A-Fa-f]{1,4}:[0-9A-Fa-f]{1,4}|(?
              '4}|(?:(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(?:[0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][' \
              '0-9]|25[0-5]))|(?:(?:[0-9A-Fa-f]{1,4}:){,5}[0-9A-Fa-f]{1,4})?::[0-9A-Fa-f]{1,4}|(?:(?:[0-9A-Fa-f]{1,' \
              '4}:){,6}[0-9A-Fa-f]{1,4})?::)(?:%.+)?'
-ws2pid_regex = "[0-9a-f]{8}"
-host_regex = "[a-z0-9-_.]*(?:.[a-zA-Z])?"
-path_regex = "[/\w \.-]*/?"
-ws2p_private_prefix_regex = "O[CT][SAM]"
-ws2p_public_prefix_regex = "I[CT]"
-ws2p_head_regex = "HEAD:?(?:[0-9]+)?"
+HOST_REGEX = "[a-z0-9-_.]*(?:.[a-zA-Z])?"
+PATH_REGEX = "[/\w \.-]*/?"
+WS2PID_REGEX = "[0-9a-f]{8}"
+WS2P_PRIVATE_PREFIX_REGEX = "O[CT][SAM]"
+WS2P_PUBLIC_PREFIX_REGEX = "I[CT]"
+WS2P_HEAD_REGEX = "HEAD:?(?:[0-9]+)?"
diff --git a/duniterpy/documents/block.py b/duniterpy/documents/block.py
index 8606000f..0d751ea2 100644
--- a/duniterpy/documents/block.py
+++ b/duniterpy/documents/block.py
@@ -6,7 +6,7 @@ from .certification import Identity, Certification, Revocation
 from .document import Document, MalformedDocumentError
 from .membership import Membership
 from .transaction import Transaction
-from ..constants import pubkey_regex, block_id_regex, block_hash_regex
+from ..constants import PUBKEY_REGEX, BLOCK_ID_REGEX, BLOCK_HASH_REGEX
 
 
 def block_uid(value):
@@ -24,9 +24,9 @@ class BlockUID:
     """
     A simple block id
     """
-    re_block_uid = re.compile("({block_id_regex})-({block_hash_regex})".format(block_id_regex=block_id_regex,
-                                                                               block_hash_regex=block_hash_regex))
-    re_hash = re.compile("({block_hash_regex})".format(block_hash_regex=block_hash_regex))
+    re_block_uid = re.compile("({block_id_regex})-({block_hash_regex})".format(block_id_regex=BLOCK_ID_REGEX,
+                                                                               block_hash_regex=BLOCK_HASH_REGEX))
+    re_hash = re.compile("({block_hash_regex})".format(block_hash_regex=BLOCK_HASH_REGEX))
 
     @classmethod
     def empty(cls):
@@ -133,12 +133,12 @@ The class Block handles Block documents.
     re_mediantime = re.compile("MedianTime: ([0-9]+)\n")
     re_universaldividend = re.compile("UniversalDividend: ([0-9]+)\n")
     re_unitbase = re.compile("UnitBase: ([0-9]+)\n")
-    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
+    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
     re_issuers_frame = re.compile("IssuersFrame: ([0-9]+)\n")
     re_issuers_frame_var = re.compile("IssuersFrameVar: (0|-?[1-9]\d{0,18})\n")
     re_different_issuers_count = re.compile("DifferentIssuersCount: ([0-9]+)\n")
-    re_previoushash = re.compile("PreviousHash: ({block_hash_regex})\n".format(block_hash_regex=block_hash_regex))
-    re_previousissuer = re.compile("PreviousIssuer: ({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
+    re_previoushash = re.compile("PreviousHash: ({block_hash_regex})\n".format(block_hash_regex=BLOCK_HASH_REGEX))
+    re_previousissuer = re.compile("PreviousIssuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
     re_parameters = re.compile("Parameters: ([0-9]+\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):\
 ([0-9]+):([0-9]+):([0-9]+\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+\.[0-9]+)\n")
     re_parameters_v10 = re.compile("Parameters: ([0-9]+\.[0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):\
@@ -151,10 +151,10 @@ The class Block handles Block documents.
     re_leavers = re.compile("Leavers:\n")
     re_revoked = re.compile("Revoked:\n")
     re_excluded = re.compile("Excluded:\n")
-    re_exclusion = re.compile("({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
+    re_exclusion = re.compile("({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
     re_certifications = re.compile("Certifications:\n")
     re_transactions = re.compile("Transactions:\n")
-    re_hash = re.compile("InnerHash: ({block_hash_regex})\n".format(block_hash_regex=block_hash_regex))
+    re_hash = re.compile("InnerHash: ({block_hash_regex})\n".format(block_hash_regex=BLOCK_HASH_REGEX))
     re_noonce = re.compile("Nonce: ([0-9]+)\n")
 
     fields_parsers = {**Document.fields_parsers, **{
diff --git a/duniterpy/documents/certification.py b/duniterpy/documents/certification.py
index 342ba3a7..7e4fdc13 100644
--- a/duniterpy/documents/certification.py
+++ b/duniterpy/documents/certification.py
@@ -2,7 +2,7 @@ import base64
 import logging
 import re
 
-from ..constants import pubkey_regex, signature_regex, block_id_regex, block_uid_regex, uid_regex
+from ..constants import PUBKEY_REGEX, SIGNATURE_REGEX, BLOCK_ID_REGEX, BLOCK_UID_REGEX, UID_REGEX
 from .document import Document, MalformedDocumentError
 
 
@@ -12,15 +12,15 @@ class Identity(Document):
     """
 
     re_inline = re.compile("({pubkey_regex}):({signature_regex}):({block_uid_regex}):([^\n]+)\n"
-                           .format(pubkey_regex=pubkey_regex,
-                                   signature_regex=signature_regex,
-                                   block_uid_regex=block_uid_regex))
+                           .format(pubkey_regex=PUBKEY_REGEX,
+                                   signature_regex=SIGNATURE_REGEX,
+                                   block_uid_regex=BLOCK_UID_REGEX))
     re_type = re.compile("Type: (Identity)")
-    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
-    re_unique_id = re.compile("UniqueID: ({uid_regex})\n".format(uid_regex=uid_regex))
+    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
+    re_unique_id = re.compile("UniqueID: ({uid_regex})\n".format(uid_regex=UID_REGEX))
     re_uid = re.compile("UID:([^\n]+)\n")
-    re_meta_ts = re.compile("META:TS:({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
-    re_timestamp = re.compile("Timestamp: ({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
+    re_meta_ts = re.compile("META:TS:({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
+    re_timestamp = re.compile("Timestamp: ({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
 
     fields_parsers = {**Document.fields_parsers, **{
         "Type": re_type,
@@ -118,19 +118,19 @@ class Certification(Document):
     """
 
     re_inline = re.compile("({certifier_regex}):({certified_regex}):({block_id_regex}):({signature_regex})\n".format(
-        certifier_regex=pubkey_regex,
-        certified_regex=pubkey_regex,
-        block_id_regex=block_id_regex,
-        signature_regex=signature_regex
+        certifier_regex=PUBKEY_REGEX,
+        certified_regex=PUBKEY_REGEX,
+        block_id_regex=BLOCK_ID_REGEX,
+        signature_regex=SIGNATURE_REGEX
     ))
-    re_timestamp = re.compile("META:TS:({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
+    re_timestamp = re.compile("META:TS:({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
     re_type = re.compile("Type: (Certification)")
-    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
-    re_idty_issuer = re.compile("IdtyIssuer: ({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
-    re_idty_unique_id = re.compile("IdtyUniqueID: ({uid_regex})\n".format(uid_regex=uid_regex))
-    re_idty_timestamp = re.compile("IdtyTimestamp: ({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
-    re_idty_signature = re.compile("IdtySignature: ({signature_regex})\n".format(signature_regex=signature_regex))
-    re_cert_timestamp = re.compile("CertTimestamp: ({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
+    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
+    re_idty_issuer = re.compile("IdtyIssuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
+    re_idty_unique_id = re.compile("IdtyUniqueID: ({uid_regex})\n".format(uid_regex=UID_REGEX))
+    re_idty_timestamp = re.compile("IdtyTimestamp: ({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
+    re_idty_signature = re.compile("IdtySignature: ({signature_regex})\n".format(signature_regex=SIGNATURE_REGEX))
+    re_cert_timestamp = re.compile("CertTimestamp: ({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
 
     fields_parsers = {**Document.fields_parsers, **{
         "Type": re_type,
@@ -273,15 +273,15 @@ class Revocation(Document):
     A document describing a self-revocation.
     """
     re_inline = re.compile("({pubkey_regex}):({signature_regex})\n".format(
-        pubkey_regex=pubkey_regex,
-        signature_regex=signature_regex
+        pubkey_regex=PUBKEY_REGEX,
+        signature_regex=SIGNATURE_REGEX
     ))
 
     re_type = re.compile("Type: (Revocation)")
-    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
+    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
     re_uniqueid = re.compile("IdtyUniqueID: ([^\n]+)\n")
-    re_timestamp = re.compile("IdtyTimestamp: ({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
-    re_idtysignature = re.compile("IdtySignature: ({signature_regex})\n".format(signature_regex=signature_regex))
+    re_timestamp = re.compile("IdtyTimestamp: ({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
+    re_idtysignature = re.compile("IdtySignature: ({signature_regex})\n".format(signature_regex=SIGNATURE_REGEX))
 
     fields_parsers = {**Document.fields_parsers, **{
         "Type": re_type,
diff --git a/duniterpy/documents/crc_pubkey.py b/duniterpy/documents/crc_pubkey.py
index 616cc29f..c8a63391 100644
--- a/duniterpy/documents/crc_pubkey.py
+++ b/duniterpy/documents/crc_pubkey.py
@@ -1,7 +1,7 @@
 import base58
 import re
 import hashlib
-from ..constants import pubkey_regex
+from ..constants import PUBKEY_REGEX
 from ..helpers import ensure_str
 
 
@@ -9,7 +9,7 @@ class CRCPubkey:
     """
     Class to implement a crc on a pubkey
     """
-    re_crc_pubkey = re.compile("({pubkey_regex}):([A-Za-z0-9]{{3}})".format(pubkey_regex=pubkey_regex))
+    re_crc_pubkey = re.compile("({pubkey_regex}):([A-Za-z0-9]{{3}})".format(pubkey_regex=PUBKEY_REGEX))
 
     def __init__(self, pubkey, crc):
         """
diff --git a/duniterpy/documents/document.py b/duniterpy/documents/document.py
index cbd4a750..a2c21e47 100644
--- a/duniterpy/documents/document.py
+++ b/duniterpy/documents/document.py
@@ -3,7 +3,7 @@ import hashlib
 import logging
 import re
 
-from ..constants import signature_regex
+from ..constants import SIGNATURE_REGEX
 
 
 class MalformedDocumentError(Exception):
@@ -18,7 +18,7 @@ class MalformedDocumentError(Exception):
 class Document:
     re_version = re.compile("Version: ([0-9]+)\n")
     re_currency = re.compile("Currency: ([^\n]+)\n")
-    re_signature = re.compile("({signature_regex})\n".format(signature_regex=signature_regex))
+    re_signature = re.compile("({signature_regex})\n".format(signature_regex=SIGNATURE_REGEX))
 
     fields_parsers = {
         "Version": re_version,
diff --git a/duniterpy/documents/membership.py b/duniterpy/documents/membership.py
index 24bcea77..be436afe 100644
--- a/duniterpy/documents/membership.py
+++ b/duniterpy/documents/membership.py
@@ -6,7 +6,7 @@ Created on 2 déc. 2014
 import re
 
 from .document import Document, MalformedDocumentError
-from ..constants import block_uid_regex, signature_regex, pubkey_regex
+from ..constants import BLOCK_UID_REGEX, SIGNATURE_REGEX, PUBKEY_REGEX
 
 
 class Membership(Document):
@@ -27,15 +27,15 @@ class Membership(Document):
     # PUBLIC_KEY:SIGNATURE:NUMBER:HASH:TIMESTAMP:USER_ID
     re_inline = re.compile(
         "({pubkey_regex}):({signature_regex}):({ms_block_uid_regex}):({identity_block_uid_regex}):([^\n]+)\n"
-        .format(pubkey_regex=pubkey_regex, signature_regex=signature_regex,
-                ms_block_uid_regex=block_uid_regex,
-                identity_block_uid_regex=block_uid_regex))
+        .format(pubkey_regex=PUBKEY_REGEX, signature_regex=SIGNATURE_REGEX,
+                ms_block_uid_regex=BLOCK_UID_REGEX,
+                identity_block_uid_regex=BLOCK_UID_REGEX))
     re_type = re.compile("Type: (Membership)")
-    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
-    re_block = re.compile("Block: ({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
+    re_issuer = re.compile("Issuer: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
+    re_block = re.compile("Block: ({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
     re_membership_type = re.compile("Membership: (IN|OUT)")
     re_userid = re.compile("UserID: ([^\n]+)\n")
-    re_certts = re.compile("CertTS: ({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
+    re_certts = re.compile("CertTS: ({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
 
     fields_parsers = {**Document.fields_parsers, **{
         "Type": re_type,
diff --git a/duniterpy/documents/peer.py b/duniterpy/documents/peer.py
index 408f847a..099751a4 100644
--- a/duniterpy/documents/peer.py
+++ b/duniterpy/documents/peer.py
@@ -3,7 +3,7 @@ import re
 from duniterpy.api.endpoint import endpoint
 from .document import Document
 from . import BlockUID
-from ..constants import block_hash_regex, pubkey_regex
+from ..constants import BLOCK_HASH_REGEX, PUBKEY_REGEX
 
 
 class Peer(Document):
@@ -24,8 +24,8 @@ class Peer(Document):
     """
 
     re_type = re.compile("Type: (Peer)")
-    re_pubkey = re.compile("PublicKey: ({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
-    re_block = re.compile("Block: ([0-9]+-{block_hash_regex})\n".format(block_hash_regex=block_hash_regex))
+    re_pubkey = re.compile("PublicKey: ({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
+    re_block = re.compile("Block: ([0-9]+-{block_hash_regex})\n".format(block_hash_regex=BLOCK_HASH_REGEX))
     re_endpoints = re.compile("(Endpoints:)\n")
 
     fields_parsers = {**Document.fields_parsers, **{
diff --git a/duniterpy/documents/transaction.py b/duniterpy/documents/transaction.py
index 70f54296..fd6cd7e9 100644
--- a/duniterpy/documents/transaction.py
+++ b/duniterpy/documents/transaction.py
@@ -3,7 +3,7 @@ import re
 import pypeg2
 
 from .document import Document, MalformedDocumentError
-from ..constants import pubkey_regex, transaction_hash_regex, block_id_regex, block_uid_regex
+from ..constants import PUBKEY_REGEX, TRANSACTION_HASH_REGEX, BLOCK_ID_REGEX, BLOCK_UID_REGEX
 from ..grammars import output
 
 
@@ -65,8 +65,8 @@ class Transaction(Document):
 
     re_type = re.compile("Type: (Transaction)\n")
     re_header = re.compile("TX:([0-9]+):([0-9]+):([0-9]+):([0-9]+):([0-9]+):([01]):([0-9]+)\n")
-    re_compact_blockstamp = re.compile("({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
-    re_blockstamp = re.compile("Blockstamp: ({block_uid_regex})\n".format(block_uid_regex=block_uid_regex))
+    re_compact_blockstamp = re.compile("({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
+    re_blockstamp = re.compile("Blockstamp: ({block_uid_regex})\n".format(block_uid_regex=BLOCK_UID_REGEX))
     re_locktime = re.compile("Locktime: ([0-9]+)\n")
     re_issuers = re.compile("Issuers:\n")
     re_inputs = re.compile("Inputs:\n")
@@ -74,7 +74,7 @@ class Transaction(Document):
     re_outputs = re.compile("Outputs:\n")
     re_compact_comment = re.compile("([^\n]+)\n")
     re_comment = re.compile("Comment: ([^\n]*)\n")
-    re_pubkey = re.compile("({pubkey_regex})\n".format(pubkey_regex=pubkey_regex))
+    re_pubkey = re.compile("({pubkey_regex})\n".format(pubkey_regex=PUBKEY_REGEX))
 
     fields_parsers = {**Document.fields_parsers, **{
         "Type": re_type,
@@ -437,15 +437,15 @@ class InputSource:
     """
     re_inline = re.compile(
         "(?:(?:(D):({pubkey_regex}):({block_id_regex}))|(?:(T):({transaction_hash_regex}):([0-9]+)))\n"
-        .format(pubkey_regex=pubkey_regex,
-                block_id_regex=block_id_regex,
-                transaction_hash_regex=transaction_hash_regex))
+        .format(pubkey_regex=PUBKEY_REGEX,
+                block_id_regex=BLOCK_ID_REGEX,
+                transaction_hash_regex=TRANSACTION_HASH_REGEX))
     re_inline_v3 = re.compile(
         "([0-9]+):([0-9]+):(?:(?:(D):({pubkey_regex}):({block_id_regex}))|(?:(T):({transaction_hash_regex}):\
 ([0-9]+)))\n"
-        .format(pubkey_regex=pubkey_regex,
-                block_id_regex=block_id_regex,
-                transaction_hash_regex=transaction_hash_regex))
+        .format(pubkey_regex=PUBKEY_REGEX,
+                block_id_regex=BLOCK_ID_REGEX,
+                transaction_hash_regex=TRANSACTION_HASH_REGEX))
 
     def __init__(self, amount, base, source, origin_id, index):
         """
diff --git a/duniterpy/documents/ws2p/heads.py b/duniterpy/documents/ws2p/heads.py
index 7ff2ed77..3c415613 100644
--- a/duniterpy/documents/ws2p/heads.py
+++ b/duniterpy/documents/ws2p/heads.py
@@ -2,16 +2,16 @@ import attr
 import re
 
 from ..block import BlockUID
-from ...constants import ws2p_public_prefix_regex, ws2p_private_prefix_regex,\
-    pubkey_regex, signature_regex, ws2pid_regex, block_uid_regex, ws2p_head_regex
+from ...constants import WS2P_PUBLIC_PREFIX_REGEX, WS2P_PRIVATE_PREFIX_REGEX,\
+    PUBKEY_REGEX, SIGNATURE_REGEX, WS2PID_REGEX, BLOCK_UID_REGEX, ws2p_head_regex
 
 
 @attr.s()
 class API:
     re_inline = re.compile("WS2P({ws2p_private})?({ws2p_public})?"
                             .format(
-                                    ws2p_private=ws2p_private_prefix_regex,
-                                    ws2p_public=ws2p_public_prefix_regex))
+                                    ws2p_private=WS2P_PRIVATE_PREFIX_REGEX,
+                                    ws2p_public=WS2P_PUBLIC_PREFIX_REGEX))
 
     private = attr.ib(type=str)
     public = attr.ib(type=str)
@@ -62,14 +62,14 @@ class HeadV0:
     """
 
     re_inline = re.compile("^(WS2P(?:{ws2p_private})?(?:{ws2p_public})?):({head}):({pubkey}):({blockstamp})(?::)?(.*)"
-                                .format(ws2p_private=ws2p_private_prefix_regex,
-                                        ws2p_public=ws2p_public_prefix_regex,
-                                        head=ws2p_head_regex,
-                                        version="[0-9]+",
-                                        pubkey=pubkey_regex,
-                                        blockstamp=block_uid_regex))
+                           .format(ws2p_private=WS2P_PRIVATE_PREFIX_REGEX,
+                                   ws2p_public=WS2P_PUBLIC_PREFIX_REGEX,
+                                   head=ws2p_head_regex,
+                                   version="[0-9]+",
+                                   pubkey=PUBKEY_REGEX,
+                                   blockstamp=BLOCK_UID_REGEX))
 
-    re_signature = re.compile(signature_regex)
+    re_signature = re.compile(SIGNATURE_REGEX)
 
     signature = attr.ib(type=str)
     api = attr.ib(type=API)
@@ -99,7 +99,7 @@ class HeadV1:
     re_inline = re.compile("({ws2pid}):" \
                             "({software}):({software_version}):({pow_prefix})(?::)?(.*)"
                             .format(
-                                ws2pid=ws2pid_regex,
+                                ws2pid=WS2PID_REGEX,
                                 software="[A-Za-z-_]+",
                                 software_version="[0-9]+[.][0-9]+[.][0-9]+",
                                 pow_prefix="[0-9]+"))
diff --git a/duniterpy/grammars/output.py b/duniterpy/grammars/output.py
index d1870c94..8d6340ec 100644
--- a/duniterpy/grammars/output.py
+++ b/duniterpy/grammars/output.py
@@ -1,14 +1,14 @@
 from pypeg2 import *
 
-from ..constants import pubkey_regex, hash_regex
+from ..constants import PUBKEY_REGEX, HASH_REGEX
 
 
 class Pubkey(str):
-    regex = re.compile(pubkey_regex)
+    regex = re.compile(PUBKEY_REGEX)
 
 
 class Hash(str):
-    regex = re.compile(hash_regex)
+    regex = re.compile(HASH_REGEX)
 
 
 class Int(str):
-- 
GitLab