summaryrefslogtreecommitdiff
path: root/tools/install-decoders
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2016-11-20 16:51:47 +0100
committerUwe Hermann <uwe@hermann-uwe.de>2016-12-06 22:10:14 +0100
commit3ab22459a92d2e129362ded379f6b75c0f6d4cdf (patch)
treee1c7a22bc6de8bf5b87bb82a3d5771c3fc1f07b5 /tools/install-decoders
parentd2297b8729027787f2dcbf988d42a9dfdd03fd5c (diff)
downloadlibsigrokdecode-3ab22459a92d2e129362ded379f6b75c0f6d4cdf.tar.gz
libsigrokdecode-3ab22459a92d2e129362ded379f6b75c0f6d4cdf.zip
build support: sort list of installed items, factor out pretty printer
Alpha-sort the list of installed items, to support developers which scan the list for newly added items. Factor out the logic which pretty prints installed items while maintaining a maximum screen output line length.
Diffstat (limited to 'tools/install-decoders')
-rwxr-xr-xtools/install-decoders24
1 files changed, 17 insertions, 7 deletions
diff --git a/tools/install-decoders b/tools/install-decoders
index 8445da5..3772bd5 100755
--- a/tools/install-decoders
+++ b/tools/install-decoders
@@ -24,6 +24,20 @@ from shutil import copy
from getopt import getopt
+_inst_pp_col_max = 80
+_inst_pp_col = 0
+def _install_pretty_print(item):
+ """Pretty print an install item. Enforce maximum line width."""
+ global _inst_pp_col
+ if item is None:
+ _inst_pp_col = 0
+ return
+ _inst_pp_col += len(item)
+ if _inst_pp_col > _inst_pp_col_max:
+ print()
+ _inst_pp_col = len(item)
+ print(item, end = "")
+
def install(srcdir, dstdir, s):
worklist = []
for pd in os.listdir(srcdir):
@@ -42,15 +56,10 @@ def install(srcdir, dstdir, s):
if install_list:
worklist.append((pd, pd_dir, install_list))
+ worklist.sort()
print("Installing %d %s:" % (len(worklist), s))
- col = 0
for pd, pd_dir, install_list in worklist:
- msg = pd + ' '
- if (col + len(msg) > 80):
- print()
- col = 0
- print(msg, end='')
- col += len(msg)
+ _install_pretty_print("{} ".format(pd))
pd_dst = os.path.join(dstdir, pd)
try:
os.mkdir(pd_dst)
@@ -62,6 +71,7 @@ def install(srcdir, dstdir, s):
for f in install_list:
copy(os.path.join(pd_dir, f), pd_dst)
print()
+ _install_pretty_print(None)
def config_get_extra_install(config_file):