Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
277132a2
"examples/community/lpw_stable_diffusion_xl.py" did not exist on "ad8f985e81d0e0bac0375cd81b909987e8b2a7f9"
Commit
277132a2
authored
May 23, 2012
by
Jesse Beder
Browse files
Refactored emitter test template code
parent
5af3fc04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
7 deletions
+23
-7
test/create-emitter-tests.py
test/create-emitter-tests.py
+23
-7
No files found.
test/create-emitter-tests.py
View file @
277132a2
...
@@ -46,15 +46,31 @@ def scalar(value, tag='', anchor='', anchor_id=0):
...
@@ -46,15 +46,31 @@ def scalar(value, tag='', anchor='', anchor_id=0):
emit
+=
[
'"%s"'
%
encode
(
value
)]
emit
+=
[
'"%s"'
%
encode
(
value
)]
return
{
'emit'
:
emit
,
'handle'
:
'SCALAR("%s", %s, "%s")'
%
(
out_tag
,
anchor_id
,
encode
(
value
))}
return
{
'emit'
:
emit
,
'handle'
:
'SCALAR("%s", %s, "%s")'
%
(
out_tag
,
anchor_id
,
encode
(
value
))}
def
gen_outlines
():
def
comment
(
value
):
yield
[
doc_start
(),
scalar
(
'foo
\n
'
),
doc_end
()]
return
{
'emit'
:
'YAML::Comment("%s")'
%
value
,
'handle'
:
''
}
yield
[
doc_start
(
True
),
scalar
(
'foo
\n
'
),
doc_end
()]
yield
[
doc_start
(),
scalar
(
'foo
\n
'
),
doc_end
(
True
)]
def
gen_templates
():
yield
[
doc_start
(
True
),
scalar
(
'foo
\n
'
),
doc_end
(
True
)]
yield
[[
doc_start
(),
doc_start
(
True
)],
[
scalar
(
'foo
\n
'
)],
[
doc_end
(),
doc_end
(
True
)]]
def
expand
(
template
):
if
len
(
template
)
==
0
:
pass
elif
len
(
template
)
==
1
:
for
item
in
template
[
0
]:
if
isinstance
(
item
,
list
):
yield
item
else
:
yield
[
item
]
else
:
for
car
in
expand
(
template
[:
1
]):
for
cdr
in
expand
(
template
[
1
:]):
yield
car
+
cdr
def
gen_events
():
def
gen_events
():
for
events
in
gen_outlines
():
for
template
in
gen_templates
():
yield
events
for
events
in
expand
(
template
):
yield
events
def
gen_tests
():
def
gen_tests
():
for
events
in
gen_events
():
for
events
in
gen_events
():
...
...
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