From: Frank Brehm Date: Fri, 22 Jan 2021 14:03:46 +0000 (+0100) Subject: Transforming bin/idna-xlate to the new schema X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=277d7abcaecb5305f4ec73fa1b49f482ea12f92c;p=pixelpark%2Fadmin-tools.git Transforming bin/idna-xlate to the new schema --- diff --git a/bin/format-du b/bin/format-du index 206ff31..08ca8ca 100755 --- a/bin/format-du +++ b/bin/format-du @@ -26,10 +26,6 @@ if sys.version_info[1] < __min_py_version_minor__: import os import locale -# own modules: -cur_dir = os.getcwd() -base_dir = cur_dir - try: import pathlib from pathlib import Path diff --git a/bin/idna-xlate b/bin/idna-xlate index 374b882..14527f4 100755 --- a/bin/idna-xlate +++ b/bin/idna-xlate @@ -1,30 +1,54 @@ #!/usr/bin/env python3 +from __future__ import print_function + # Standard modules import sys + +__exp_py_version_major__ = 3 +__min_py_version_minor__ = 4 + +if sys.version_info[0] != __exp_py_version_major__: + print("This script is intended to use with Python {}.".format( + __exp_py_version_major__), file=sys.stderr) + print("You are using Python: {0}.{1}.{2}-{3}-{4}.".format( + *sys.version_info) + "\n", file=sys.stderr) + sys.exit(1) + +if sys.version_info[1] < __min_py_version_minor__: + print("A minimal Python version of {maj}.{min} is necessary to execute this script.".format( + maj=__exp_py_version_major__, min=__min_py_version_minor__), file=sys.stderr) + print("You are using Python: {0}.{1}.{2}-{3}-{4}.".format( + *sys.version_info) + "\n", file=sys.stderr) + sys.exit(1) + +# Standard modules import os -import logging import locale +try: + import pathlib + from pathlib import Path +except ImportError: + from pathlib2 import Path + import pathlib2 as pathlib + # own modules: -cur_dir = os.getcwd() -base_dir = cur_dir - -if sys.argv[0] != '' and sys.argv[0] != '-c': - bin_dir = os.path.dirname(os.path.realpath(sys.argv[0])) -else: - bin_dir = os.path.dirname(os.path.realpath(__file__)) -base_dir = os.path.abspath(os.path.join(bin_dir, '..')) -module_dir = os.path.join(base_dir, 'pp_lib') -if os.path.exists(module_dir): - sys.path.insert(0, base_dir) -from pp_lib.idna_xlate import IdnaXlateApp +my_path = Path(__file__) +my_real_path = my_path.resolve() +bin_path = my_real_path.parent +base_dir = bin_path.parent +lib_dir = base_dir.joinpath('lib') +module_dir = lib_dir.joinpath('pp_lib') -log = logging.getLogger(__name__) +if module_dir.exists(): + sys.path.insert(0, str(lib_dir)) + +from pp_lib.idna_xlate import IdnaXlateApp __author__ = 'Frank Brehm ' -__copyright__ = '(C) 2018 by Frank Brehm, Pixelpark GmbH, Berlin' +__copyright__ = '(C) 2021 by Frank Brehm, Pixelpark GmbH, Berlin' appname = os.path.basename(sys.argv[0]) diff --git a/lib/pp_lib/idna_xlate.py b/lib/pp_lib/idna_xlate.py index 86f612c..0e4cb83 100644 --- a/lib/pp_lib/idna_xlate.py +++ b/lib/pp_lib/idna_xlate.py @@ -3,7 +3,7 @@ """ @author: Frank Brehm @contact: frank.brehm@pixelpark.com -@copyright: © 2018 by Frank Brehm, Berlin +@copyright: © 2021 by Frank Brehm, Berlin @summary: The module for the 'idna-xlate' application object. """ from __future__ import absolute_import @@ -18,21 +18,20 @@ import copy import six # Own modules -from .common import pp, to_str, to_bytes - -from .app import PpApplication +from fb_tools.common import pp, to_str, to_bytes +from fb_tools.app import BaseApplication try: from .local_version import __version__ as my_version except ImportError: from .global_version import __version__ as my_version -__version__ = '0.2.1' +__version__ = '0.2.2' LOG = logging.getLogger(__name__) # ============================================================================= -class IdnaXlateApp(PpApplication): +class IdnaXlateApp(BaseApplication): """ Application class for the idna-xlate command. """