Skip to content

Commit

Permalink
fix unicode matching
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-mangin committed Jan 12, 2021
1 parent bc61ff8 commit 11b9b22
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions data/exabgp.yang
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module exabgp {
// ExaBGP does use python "re" for regex, therefore all regexes
// need to be expressed in a common subset of both XSD and re
// \\p{N}\\p{L} is replaced by a unicode matching of \w

namespace "https://github.com/exa-networks/exabgp";
prefix exabgp;

Expand Down
8 changes: 7 additions & 1 deletion src/exabgp/conf/yang/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ def _python_name(self, name):

def _if_pattern(self, pattern):
self.imported.add('re')
# fix known ietf regex use
pattern = pattern.replace('\\p{N}\\p{L}','\\w')
return [
If(
test=UnaryOp(
Expand All @@ -81,6 +83,11 @@ def _if_pattern(self, pattern):
args=[
Constant(value=pattern, kind=None),
Name(id='value', ctx=Load()),
Attribute(
value=Name(id='re', ctx=Load()),
attr='UNICODE',
ctx=Load(),
),
],
keywords=[],
),
Expand All @@ -95,7 +102,6 @@ def _if_pattern(self, pattern):
]

def _if_length(self, minimum, maximum):
self.imported.add('re')
return [
If(
test=Compare(
Expand Down

0 comments on commit 11b9b22

Please sign in to comment.