Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
criu
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhul
criu
Commits
7b4a264e
Commit
7b4a264e
authored
Jan 15, 2015
by
Pavel Emelyanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crit: Small inf/outf evaluation cleanup
Signed-off-by:
Pavel Emelyanov
<
xemul@parallels.com
>
parent
a9ccdccc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
29 deletions
+19
-29
crit
crit
+19
-29
No files found.
crit
View file @
7b4a264e
...
@@ -26,45 +26,35 @@ def handle_cmdline_opts():
...
@@ -26,45 +26,35 @@ def handle_cmdline_opts():
return
opts
return
opts
def
inf
(
opts
):
if
opts
[
'in'
]:
return
open
(
opts
[
'in'
],
'r'
)
else
:
return
sys
.
stdin
def
outf
(
opts
):
if
opts
[
'out'
]:
return
open
(
opts
[
'out'
],
'w+'
)
else
:
return
sys
.
stdout
def
decode
(
opts
):
def
decode
(
opts
):
indent
=
None
indent
=
None
img
=
pycriu
.
images
.
load
(
inf
(
opts
))
# If no input file is set -- stdin is used.
if
opts
[
'in'
]:
with
open
(
opts
[
'in'
],
'r'
)
as
f
:
img
=
pycriu
.
images
.
load
(
f
)
else
:
img
=
pycriu
.
images
.
load
(
sys
.
stdin
)
# For stdout --format nice is set by default.
# For stdout --format nice is set by default.
if
opts
[
'format'
]
==
'nice'
or
(
opts
[
'format'
]
==
None
and
opts
[
'out'
]
==
None
):
if
opts
[
'format'
]
==
'nice'
or
(
opts
[
'format'
]
==
None
and
opts
[
'out'
]
==
None
):
indent
=
4
indent
=
4
# If no output file is set -- stdout is used.
f
=
outf
(
opts
)
if
opts
[
'out'
]:
json
.
dump
(
img
,
f
,
indent
=
indent
)
with
open
(
opts
[
'out'
],
'w+'
)
as
f
:
if
f
==
sys
.
stdout
:
json
.
dump
(
img
,
f
,
indent
=
indent
)
f
.
write
(
"
\n
"
)
else
:
json
.
dump
(
img
,
sys
.
stdout
,
indent
=
indent
)
sys
.
stdout
.
write
(
"
\n
"
)
def
encode
(
opts
):
def
encode
(
opts
):
# If no input file is set -- stdin is used.
img
=
json
.
load
(
inf
(
opts
))
if
opts
[
'in'
]:
pycriu
.
images
.
dump
(
img
,
outf
(
opts
))
with
open
(
opts
[
'in'
],
'r'
)
as
f
:
img
=
json
.
load
(
f
)
else
:
img
=
json
.
load
(
sys
.
stdin
)
# If no output file is set -- stdout is used.
if
opts
[
'out'
]:
with
open
(
opts
[
'out'
],
'w+'
)
as
f
:
pycriu
.
images
.
dump
(
img
,
f
)
else
:
pycriu
.
images
.
dump
(
img
,
sys
.
stdout
)
def
main
():
def
main
():
#Handle cmdline options
#Handle cmdline options
...
...
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