Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
104
Merge Requests
104
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
nexedi
slapos
Commits
7e9771cc
Commit
7e9771cc
authored
Dec 27, 2023
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fd1a95da
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
9 deletions
+23
-9
software/ors-amarisoft/ru/xbuildout.py
software/ors-amarisoft/ru/xbuildout.py
+23
-9
No files found.
software/ors-amarisoft/ru/xbuildout.py
View file @
7e9771cc
...
...
@@ -52,24 +52,38 @@ def encode(s: str): # -> str
# decode provides reverse operation for encode.
def
decode
(
s
:
str
):
# -> str | ValueError | UnicodeDecodeError
def
decode
(
s
:
str
):
# -> str | ValueError
try
:
return
_decode
(
s
)
except
Exception
as
e
:
raise
ValueError
(
"decoding %r"
%
s
)
from
e
def
_decode
(
s
):
s
=
s
.
encode
(
'utf-8'
)
outv
=
[]
emit
=
outv
.
append
def
bad
(
reason
):
raise
ValueError
(
reason
)
while
len
(
s
)
>
0
:
c
=
s
[
0
:
1
]
c
=
s
[:
1
]
s
=
s
[
1
:]
if
c
!=
b'_'
:
emit
(
c
)
continue
if
len
(
s
)
<
2
:
bad
(
"truncated escape sequence"
)
x
=
s
[:
2
]
s
=
s
[
2
:]
if
len
(
s
)
<
1
:
raise
ValueError
(
"truncated escape sequence"
)
x
=
s
[:
1
]
s
=
s
[
1
:]
if
x
==
b'_'
:
emit
(
b'_'
)
continue
if
len
(
s
)
<
1
:
raise
ValueError
(
"truncated escape sequence"
)
x
+=
s
[:
1
]
s
=
s
[
1
:]
i
=
int
(
x
,
16
)
# raises ValueError if not ok
c
=
bytes
([
i
])
emit
(
c
)
...
...
@@ -106,7 +120,7 @@ def test_encode():
(
'_'
,
'__'
),
(
' '
,
'_20'
),
(
'αβγ'
,
'_ce_b1_ce_b2_ce_b3'
),
(
'a b+c_d'
'a_20b_43
c__d'
),
(
'a b+c_d'
,
'a_20b_2b
c__d'
),
]
for
(
s
,
encok
)
in
testv
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment