[projects/pld-builder.new] Make StringIO and ConfigParser imports work on both py2 and py3

baggins baggins at pld-linux.org
Sun Jan 17 19:47:17 CET 2021


commit 308677c36e1494e9253672c9d09b52e745d91be1
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Jan 17 19:46:28 2021 +0100

    Make StringIO and ConfigParser imports work on both py2 and py3

 PLD_Builder/acl.py             | 5 ++++-
 PLD_Builder/bqueue.py          | 5 ++++-
 PLD_Builder/config.py          | 5 ++++-
 PLD_Builder/gpg.py             | 5 ++++-
 PLD_Builder/install.py         | 5 ++++-
 PLD_Builder/mailer.py          | 5 ++++-
 PLD_Builder/notify.py          | 5 ++++-
 PLD_Builder/pipeutil.py        | 5 ++++-
 PLD_Builder/request_fetcher.py | 5 ++++-
 PLD_Builder/request_handler.py | 5 ++++-
 PLD_Builder/srpm_builder.py    | 5 ++++-
 PLD_Builder/wrap.py            | 5 ++++-
 12 files changed, 48 insertions(+), 12 deletions(-)
---
diff --git a/PLD_Builder/acl.py b/PLD_Builder/acl.py
index 5f06219..54ab26f 100644
--- a/PLD_Builder/acl.py
+++ b/PLD_Builder/acl.py
@@ -1,6 +1,9 @@
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
-import ConfigParser
+if sys.version_info[0] == 2:
+    import ConfigParser
+else:
+    import configparser as ConfigParser
 import string
 import fnmatch
 import os
diff --git a/PLD_Builder/bqueue.py b/PLD_Builder/bqueue.py
index 30ecf20..4c9b687 100644
--- a/PLD_Builder/bqueue.py
+++ b/PLD_Builder/bqueue.py
@@ -3,7 +3,10 @@
 import re
 import gzip
 import time
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 import os
 import fcntl
 import string
diff --git a/PLD_Builder/config.py b/PLD_Builder/config.py
index 2fcfe60..636ddcd 100644
--- a/PLD_Builder/config.py
+++ b/PLD_Builder/config.py
@@ -1,6 +1,9 @@
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
-import ConfigParser
+if sys.version_info[0] == 2:
+    import ConfigParser
+else:
+    import configparser as ConfigParser
 import string
 import os
 import syslog
diff --git a/PLD_Builder/gpg.py b/PLD_Builder/gpg.py
index c2f9ce9..d73897f 100644
--- a/PLD_Builder/gpg.py
+++ b/PLD_Builder/gpg.py
@@ -3,7 +3,10 @@
 import log
 import subprocess
 import re
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 
 import util
 import os
diff --git a/PLD_Builder/install.py b/PLD_Builder/install.py
index 8044959..ddb5bea 100644
--- a/PLD_Builder/install.py
+++ b/PLD_Builder/install.py
@@ -2,7 +2,10 @@
 
 import re, os
 import string
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 
 import chroot
 import util
diff --git a/PLD_Builder/mailer.py b/PLD_Builder/mailer.py
index cbed042..7e260b8 100644
--- a/PLD_Builder/mailer.py
+++ b/PLD_Builder/mailer.py
@@ -3,7 +3,10 @@
 import time
 import os
 import sys
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 
 from config import config
 import util
diff --git a/PLD_Builder/notify.py b/PLD_Builder/notify.py
index 5b0368f..1d31e59 100644
--- a/PLD_Builder/notify.py
+++ b/PLD_Builder/notify.py
@@ -1,6 +1,9 @@
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 
 import mailer
 import gpg
diff --git a/PLD_Builder/pipeutil.py b/PLD_Builder/pipeutil.py
index 4979fea..a67fb07 100644
--- a/PLD_Builder/pipeutil.py
+++ b/PLD_Builder/pipeutil.py
@@ -2,7 +2,10 @@
 
 import select
 import os
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 
 def rw_pipe(buf_, infd, outfd):
     buf = StringIO.StringIO()
diff --git a/PLD_Builder/request_fetcher.py b/PLD_Builder/request_fetcher.py
index 9877cde..5428b75 100644
--- a/PLD_Builder/request_fetcher.py
+++ b/PLD_Builder/request_fetcher.py
@@ -5,7 +5,10 @@ import signal
 import os
 import urllib
 import urllib2
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 import sys
 import gzip
 
diff --git a/PLD_Builder/request_handler.py b/PLD_Builder/request_handler.py
index f960560..d84b4cc 100644
--- a/PLD_Builder/request_handler.py
+++ b/PLD_Builder/request_handler.py
@@ -4,7 +4,10 @@ import email
 import string
 import time
 import os
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 import sys
 import fnmatch
 
diff --git a/PLD_Builder/srpm_builder.py b/PLD_Builder/srpm_builder.py
index ca3452c..5f5b8d0 100644
--- a/PLD_Builder/srpm_builder.py
+++ b/PLD_Builder/srpm_builder.py
@@ -4,7 +4,10 @@ import email
 import string
 import time
 import os
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 import sys
 import re
 import shutil
diff --git a/PLD_Builder/wrap.py b/PLD_Builder/wrap.py
index b9809a3..5ff1d52 100644
--- a/PLD_Builder/wrap.py
+++ b/PLD_Builder/wrap.py
@@ -3,7 +3,10 @@
 import sys
 import log
 import traceback
-import StringIO
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 import os
 import time
 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/projects/pld-builder.new.git/commitdiff/308677c36e1494e9253672c9d09b52e745d91be1



More information about the pld-cvs-commit mailing list