X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=tools%2Finstall-decoders;h=3772bd5aefbc108b0698c3645d57bfe0ad7e0e46;hp=4a6e1d91d450a7913ac3dd73f74cd25e24b29e93;hb=d62ee705a0807493781bf1e314c73399bb8d72c5;hpb=169f42726fcd44ca9a98c914b835ae6ff31295c3 diff --git a/tools/install-decoders b/tools/install-decoders index 4a6e1d9..3772bd5 100755 --- a/tools/install-decoders +++ b/tools/install-decoders @@ -1,22 +1,22 @@ #!/usr/bin/env python3 -# -# This file is part of the libsigrokdecode project. -# -# Copyright (C) 2013 Bert Vermeulen -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, see . -# +## +## This file is part of the libsigrokdecode project. +## +## Copyright (C) 2013 Bert Vermeulen +## +## This program is free software; you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or +## (at your option) any later version. +## +## This program is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; if not, see . +## import os import sys @@ -24,7 +24,21 @@ from shutil import copy from getopt import getopt -def install(srcdir, dstdir): +_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): pd_dir = srcdir + '/' + pd @@ -39,17 +53,13 @@ def install(srcdir, dstdir): install_list.extend(config_get_extra_install(pd_file)) elif f[-3:] == '.py': install_list.append(f) - worklist.append((pd, pd_dir, install_list)) + if install_list: + worklist.append((pd, pd_dir, install_list)) - print("Installing %d protocol decoders:" % len(worklist)) - col = 0 + worklist.sort() + print("Installing %d %s:" % (len(worklist), s)) 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) @@ -61,6 +71,7 @@ def install(srcdir, dstdir): 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): @@ -107,6 +118,7 @@ except Exception as e: if len(args) != 0 or dst is None: usage() -install(src, dst) +install(src, dst, 'protocol decoders') +install(src + '/common', dst + '/common', 'common modules')