Little fixes found during cnfvar-api-Review
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 1 Apr 2022 14:47:59 +0000 (16:47 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Tue, 5 Apr 2022 07:20:47 +0000 (09:20 +0200)
make_dist.py
setup.py
src/cnfvar_old.py
src/dial.py
src/text_helpers.py
test/test_arnied_wrapper.py

index 849e6f5..a505124 100755 (executable)
@@ -3,7 +3,7 @@
 """
 Create source tarball, create rpm from it together with spec file.
 
-Create a source tarball that is compatbile with standard build pipelines. Then
+Create a source tarball that is compatible with standard build pipelines. Then
 run rpmbuild on it to create an installable rpm.
 
 .. codeauthor:: Intra2net AG <info@intra2net.com>
@@ -28,10 +28,11 @@ SOURCE_REGEX = re_compile(r'^Source0:\s*(\S+)\s*$')
 # dir to contain tarball
 DIST_DIR = join(BASE_DIR, 'dist')
 
-# files and dirs to add to tarball; keep in sync with %files secion in spec
+# files and dirs to add to tarball; keep in sync with %files section in spec
 DATA = (
     'COPYING.GPL', 'Linking-Exception.txt', 'README', 'CONTRIBUTING',
-    'setup.py', 'src', 'test', 'doc/about_docu.rst', 'doc/conf.py'
+    'setup.py', 'src', 'test', 'doc/about_docu.rst', 'doc/conf.py',
+    'doc/cnfvar-api-ascii-art.rst'
 )
 
 # dir where rpmbuild expects its tarballs
@@ -85,10 +86,10 @@ def create_tarball():
     name, version, tarball_file = get_spec_info()
     tarball_path = join(DIST_DIR, tarball_file)
     print(f'Creating {tarball_path}')
-    dirname = f'{name}-{version}'
+    dir_name = f'{name}-{version}'
     with tarfile.open(tarball_path, 'w:gz') as tarball:
         for entry in DATA:
-            tarball.add(entry, join(dirname, entry), filter=tar_add_filter)
+            tarball.add(entry, join(dir_name, entry), filter=tar_add_filter)
     return tarball_path
 
 
@@ -113,4 +114,3 @@ def main():
 
 if __name__ == '__main__':
     sys.exit(main())
-
index 0a9293e..a9eeae9 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -41,4 +41,4 @@ setup(name='pyi2ncommon',
           "Programming Language :: Python :: 3",
           "Operating System :: OS Independent",
       ],
-     )
+      )
index e4c46d3..29b7629 100644 (file)
@@ -451,7 +451,8 @@ def read_cnf(data):
     """
     Read cnf data from data bytes.
 
-    :param bytes data: raw data
+    :param data: raw data
+    :type data: str or bytes
     :return: the parsed cnf data
     :rtype: {str, {str, str or int}}
     """
@@ -1164,5 +1165,6 @@ def main(argv):
     usage()
     return -1
 
+
 if __name__ == "__main__":
     sys.exit(main(sys.argv))
index e34921a..30e930e 100644 (file)
@@ -79,8 +79,6 @@ __all__ = (
     "arnied_dial_hangup", "arnied_dial_doc", "arnied_dial_permanent", "dialout", "get_wan_address", "DIALOUT_MODE_PERMANENT", "DIALOUT_MODE_MANUAL", "DIALOUT_MODE_DEFAULT", "DIALOUT_MODE_BY_NAME"
 )
 
-TELL_CONND_BIN = "/usr/intranator/bin/tell-connd"
-
 DIALOUT_MODE_PERMANENT = 0
 DIALOUT_MODE_MANUAL = 1
 DIALOUT_MODE_DEFAULT = DIALOUT_MODE_PERMANENT
@@ -93,8 +91,12 @@ NEEDLE_MEMO = "  \[%s\] :(.*connected online fsm<online>.*)"
 NEEDLE_OFFLINE = re.compile("connection map:\nend of connection map")
 
 DIALTOOLS_HANGUP_BIN = "/usr/intranator/bin/hangup"
+
+#: binary for manual dialing (dial on command)
 DIALTOOLS_DOC_BIN = "/usr/intranator/bin/doc"
 DIALTOOLS_TIMEOUT = 10  # s
+
+#: client binary for talking to connd
 TELL_CONND_BIN = "/usr/intranator/bin/tell-connd"
 
 
@@ -133,7 +135,7 @@ def arnied_dial_hangup(block=False):
 
 def arnied_dial_doc(prid="P1", block=False):
     """
-    Bring provider up via arnied manual dial.
+    Bring provider up via arnied manual dial (dial on command).
 
     :param  prid:   Provider id, default *P1*. It is up to the caller to ensure
                     this is a valid provider id.
index 45680a8..a258f43 100644 (file)
@@ -49,6 +49,7 @@ end-of-color or end-of-style escape sequences instead of 0 (reset-everything).
 
 .. seealso:: http://stackoverflow.com/questions/287871/print-in-terminal-with-colors-using-python
 .. seealso:: https://en.wikipedia.org/wiki/ANSI_escape_code
+.. seealso:: :py:mod:`textwrap`
 
 
 INTERFACE
@@ -93,7 +94,8 @@ def head_and_tail(iterable, n_head=20, n_tail=20, n_elems=None,
     :yields: `n_head+n_tail` elements from iterable plus the `skip_elem` (or
              less if iterable is shorter than this).
 
-    .. seealso:: :py:func:`slice`, :py:func:`itertools.islice`
+    .. seealso:: :py:func:`slice`, :py:func:`itertools.islice`, :py:func:`textwrap.shorten`
+
     """
     if n_elems is None:
         n_elems = len(iterable)
index bce22a8..da6ddb0 100755 (executable)
@@ -27,7 +27,7 @@ import subprocess
 from src import arnied_wrapper
 
 
-class DummyCmdOutputMapping(object):
+class DummyCmdOutputMapping:
     """
     Class to replace the :py:function:`arnied_wrapper.run_cmd` function.