summaryrefslogtreecommitdiff
path: root/compat.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2016-11-13 11:54:19 +0100
committerAnthon van der Neut <anthon@mnt.org>2016-11-13 11:54:19 +0100
commit51dfde5d2dc2d568478387104ba0c6398ffa4b60 (patch)
tree58f064c690f27d65c5855c242ad1222b157b73b4 /compat.py
parentb96e72c24f8d3a9e2902ba70c653664aad18ec7b (diff)
downloadruamel.yaml-51dfde5d2dc2d568478387104ba0c6398ffa4b60.tar.gz
fix for issue #72, dot allowed in anchor
Diffstat (limited to 'compat.py')
-rw-r--r--compat.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/compat.py b/compat.py
index 001fbf9..1cbe923 100644
--- a/compat.py
+++ b/compat.py
@@ -120,3 +120,23 @@ def dbg(val=None):
def nprint(*args, **kw):
if dbg:
print(*args, **kw)
+
+# char checkers following production rules
+
+
+def check_namespace_char(ch):
+ if u'\x21' <= ch <= u'\x7E': # ! to ~
+ return True
+ if u'\xA0' <= ch <= u'\xD7FF':
+ return True
+ if (u'\xE000' <= ch <= u'\xFFFD') and ch != u'\xFEFF': # excl. byte order mark
+ return True
+ if u'\x10000' <= ch <= u'\x10FFFF':
+ return True
+ return False
+
+
+def check_anchorname_char(ch):
+ if ch in u',[]{}':
+ return False
+ return check_namespace_char(ch)