From d124452b54e0c071bc9ba99082cc22136780f49e Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Wed, 31 May 2023 12:12:59 +0200 Subject: [PATCH] Updating setup.py * collecting executable scripts below bin/ by itself * Applying linter changes --- setup.py | 54 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/setup.py b/setup.py index 974e3b0..0151c07 100644 --- a/setup.py +++ b/setup.py @@ -2,27 +2,24 @@ # -*- coding: utf-8 -*- """ +@summary: Scripts and modules for tasks specific to Digitas Pixelpark. + @author: Frank Brehm @contact: frank.brehm@pixelpark.com @license: LGPL3+ -@copyright: © 2021 Frank Brehm, Digitas Pixelpark, Berlin -@summary: Modules for handling the PowerDNS API +@copyright: © 2023 Frank Brehm, Digitas Pixelpark, Berlin """ from __future__ import print_function +import glob import os -import sys -import re import pprint -import glob +import re import subprocess - +import sys from pathlib import Path -# Third party modules -from setuptools import setup - -ENCODING = "utf-8" +ENCODING = 'utf-8' # own modules: # __base_dir__ = os.path.abspath(os.path.dirname(__file__)) @@ -48,6 +45,7 @@ PATHS = { # ----------------------------------- def pp(obj): + """Return a pretty print string of the given value.""" pprinter = pprint.PrettyPrinter(indent=4) return pprinter.pformat(obj) @@ -57,8 +55,11 @@ def pp(obj): if __module_dir__.exists() and __init_py__.is_file(): sys.path.insert(0, str(__lib_dir__)) +# Third party modules import pp_admintools +from setuptools import setup + __packet_version__ = pp_admintools.__version__ __packet_name__ = 'pp_admintools' @@ -78,13 +79,14 @@ if sys.version_info[0] >= 3: # ----------------------------------- def read(fname): - + """Read the given file and return its contant.""" f = Path(fname) return f.read_text() # ----------------------------------- def is_python_file(filename): + """Return, whether the given file seems to be a Python source file.""" if str(filename).endswith('.py'): return True else: @@ -100,7 +102,7 @@ __requirements__ = [ # ----------------------------------- def read_requirements(): - + """Read the requiremments.txt file.""" req_file = __base_dir__ / 'requirements.txt' if not req_file.is_file(): return @@ -133,16 +135,25 @@ read_requirements() # print("Found required modules:\n" + pp(__requirements__) + '\n') # ----------------------------------- -__scripts__ = [ - 'bin/check-ldap-dn-attributes', - 'bin/dns-deploy-zones', - 'bin/mirror-ldap-instance', - 'bin/mkldappasswd', - 'bin/remove-ldap-user', - 'bin/set-ldap-password', -] +__scripts__ = [] + +def get_scripts(): + """Collect binary script files from bin/.""" + fpattern = os.path.join(__bin_dir__, '*') + for fname in glob.glob(fpattern): + script_name = os.path.relpath(fname, __base_dir__) + if not os.path.isfile(fname): + continue + if not os.access(fname, os.X_OK): + continue + + if script_name not in __scripts__: + __scripts__.append(script_name) + + # print("Found scripts: {}\n".format(pp(__scripts__))) + -# print("Given scripts:\n" + pp(__scripts__) + "\n") +get_scripts() # ----------------------------------- __data_files__ = [] @@ -168,6 +179,7 @@ PO_FILES = 'locale/*/LC_MESSAGES/*.po' __package_data__ = {} def create_mo_files(): + """Compile the translation files.""" mo_files = [] for po_path in glob.glob(PO_FILES): mo = Path(po_path.replace('.po', '.mo')) -- 2.39.5