[elbe-devel] [PATCH 1/4] Revert "Python3: change imports for python3 compatibility"

Torben Hohn torben.hohn at linutronix.de
Wed Oct 28 14:57:48 CET 2020


On Fri, Oct 02, 2020 at 07:46:17PM +0200, bage at linutronix.de wrote:
> From: Bastian Germann <bage at linutronix.de>
> 
> This reverts commit cde271c60f27b05d035ac49de387ca6d4905c9fa
> but uses the Python 3 version of the imports only.
> 
> Signed-off-by: Bastian Germann <bage at linutronix.de>


see below...

> ---
>  elbepack/asyncworker.py | 10 ++--------
>  elbepack/db.py          |  5 +----
>  elbepack/rfs.py         |  8 ++------
>  3 files changed, 5 insertions(+), 18 deletions(-)
> 
> diff --git a/elbepack/asyncworker.py b/elbepack/asyncworker.py
> index b342de131..3d72fe88b 100644
> --- a/elbepack/asyncworker.py
> +++ b/elbepack/asyncworker.py
> @@ -6,8 +6,10 @@
>  # SPDX-License-Identifier: GPL-3.0-or-later
>  
>  from threading import Thread
> +from queue import Queue
>  from os import path, getcwd, chdir
>  from contextlib import contextmanager
> +from urllib.parse import quote
>  import logging
>  
>  from elbepack.db import get_versioned_filename
> @@ -19,14 +21,6 @@ from elbepack.elbeproject import AptCacheCommitError, AptCacheUpdateError
>  from elbepack.shellhelper import do
>  from elbepack.log import elbe_logging, read_maxlevel, reset_level
>  
> -# pylint: disable=ungrouped-imports
> -try:
> -    from Queue import Queue
> -    from urllib import quote
> -except ImportError:
> -    from queue import Queue
> -    from urllib.parse import quote
> -
>  
>  # TODO:py3 Remove object inheritance
>  # pylint: disable=useless-object-inheritance
> diff --git a/elbepack/db.py b/elbepack/db.py
> index c9ac55892..682cfca7a 100644
> --- a/elbepack/db.py
> +++ b/elbepack/db.py
> @@ -16,6 +16,7 @@ import glob
>  from datetime import datetime
>  from shutil import (rmtree, copyfile, copyfileobj)
>  from contextlib import contextmanager
> +from urllib.parse import quote
>  from threading import Thread
>  
>  from passlib.hash import pbkdf2_sha512
> @@ -33,10 +34,6 @@ from sqlalchemy.exc import OperationalError
>  from elbepack.elbeproject import ElbeProject
>  from elbepack.elbexml import (ElbeXML, ValidationMode)
>  from elbepack.dosunix import dos2unix
> -try:
> -    from urllib.parse import quote
> -except ImportError:
> -    from urllib import quote
>  
>  Base = declarative_base()
>  
> diff --git a/elbepack/rfs.py b/elbepack/rfs.py
> index 76a6485f8..e063d3282 100644
> --- a/elbepack/rfs.py
> +++ b/elbepack/rfs.py
> @@ -8,6 +8,7 @@
>  # SPDX-License-Identifier: GPL-3.0-or-later
>  
>  import os
> +import urllib

please "from urllib.parse import urlsplit"



>  import logging
>  
>  from elbepack.efilesystem import BuildImgFs
> @@ -15,11 +16,6 @@ from elbepack.templates import (write_pack_template, get_preseed,
>                                  preseed_to_text)
>  from elbepack.shellhelper import CommandError, do, chroot, get_command_out
>  
> -try:
> -    from urlparse import urlsplit
> -except ImportError:
> -    from urllib.parse import urlsplit
> -
>  
>  def create_apt_prefs(xml, rfs):
>  
> @@ -40,7 +36,7 @@ def create_apt_prefs(xml, rfs):
>              if 'pin' not in repo.et.attrib:
>                  continue
>  
> -            origin = urlsplit(repo.et.text.strip()).hostname
> +            origin = urllib.parse.urlsplit(repo.et.text.strip()).hostname

and drop this hunk.


then 

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

>              pin = repo.et.attrib['pin']
>              if 'package' in repo.et.attrib:
>                  package = repo.et.attrib['package']
> -- 
> 2.28.0
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner


More information about the elbe-devel mailing list