mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
lib/py: drop python 2 compatibility
This patch removes code introduced for compatibility with Python 2 in commits: bf80fee (lib: correctly handle stdin/stdout (Python 3)) b82f222 (lib: fix crit-recode fix for Python 2) Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
This commit is contained in:
parent
d388b91de2
commit
002f2372a9
@ -11,8 +11,6 @@ def inf(opts):
|
||||
if opts['in']:
|
||||
return open(opts['in'], 'rb')
|
||||
else:
|
||||
if (sys.version_info < (3, 0)):
|
||||
return sys.stdin
|
||||
if sys.stdin.isatty():
|
||||
# If we are reading from a terminal (not a pipe) we want text input and not binary
|
||||
return sys.stdin
|
||||
@ -28,8 +26,6 @@ def outf(opts, decode):
|
||||
mode = 'w+'
|
||||
return open(opts['out'], mode)
|
||||
else:
|
||||
if (sys.version_info < (3, 0)):
|
||||
return sys.stdout
|
||||
if decode:
|
||||
return sys.stdout
|
||||
return sys.stdout.buffer
|
||||
|
@ -42,7 +42,6 @@ import base64
|
||||
import struct
|
||||
import os
|
||||
import array
|
||||
import sys
|
||||
|
||||
from . import magic
|
||||
from . import pb
|
||||
@ -71,18 +70,12 @@ class MagicException(Exception):
|
||||
|
||||
def decode_base64_data(data):
|
||||
"""A helper function to decode base64 data."""
|
||||
if (sys.version_info > (3, 0)):
|
||||
return base64.decodebytes(str.encode(data))
|
||||
else:
|
||||
return base64.decodebytes(data)
|
||||
return base64.decodebytes(str.encode(data))
|
||||
|
||||
|
||||
def write_base64_data(f, data):
|
||||
"""A helper function to write base64 encoded data to a file."""
|
||||
if (sys.version_info > (3, 0)):
|
||||
f.write(base64.decodebytes(str.encode(data)))
|
||||
else:
|
||||
f.write(base64.decodebytes(data))
|
||||
f.write(base64.decodebytes(str.encode(data)))
|
||||
|
||||
|
||||
# Generic class to handle loading/dumping criu images entries from/to bin
|
||||
|
@ -3,7 +3,6 @@ import collections
|
||||
import os
|
||||
import quopri
|
||||
import socket
|
||||
import sys
|
||||
from ipaddress import IPv4Address, IPv6Address, ip_address
|
||||
|
||||
from google.protobuf.descriptor import FieldDescriptor as FD
|
||||
@ -247,17 +246,11 @@ def encode_dev(field, value):
|
||||
|
||||
|
||||
def encode_base64(value):
|
||||
if (sys.version_info > (3, 0)):
|
||||
return base64.encodebytes(value).decode()
|
||||
else:
|
||||
return base64.encodebytes(value)
|
||||
return base64.encodebytes(value).decode()
|
||||
|
||||
|
||||
def decode_base64(value):
|
||||
if (sys.version_info > (3, 0)):
|
||||
return base64.decodebytes(str.encode(value))
|
||||
else:
|
||||
return base64.decodebytes(value)
|
||||
return base64.decodebytes(str.encode(value))
|
||||
|
||||
|
||||
def encode_unix(value):
|
||||
|
Loading…
x
Reference in New Issue
Block a user