3 ## This file is part of the libsigrokdecode project.
5 ## Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
7 ## This program is free software; you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation; either version 3 of the License, or
10 ## (at your option) any later version.
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program; if not, see <http://www.gnu.org/licenses/>.
23 from shutil import copy
24 from getopt import getopt
27 def install(srcdir, dstdir):
29 for pd in os.listdir(srcdir):
30 pd_dir = srcdir + '/' + pd
31 if not os.path.isdir(pd_dir):
34 for f in os.listdir(pd_dir):
35 pd_file = pd_dir + '/' + f
36 if not os.path.isfile(pd_file):
39 install_list.extend(config_get_extra_install(pd_file))
41 install_list.append(f)
42 worklist.append((pd, pd_dir, install_list))
44 print("Installing %d protocol decoders:" % len(worklist))
46 for pd, pd_dir, install_list in worklist:
48 if (col + len(msg) > 80):
53 pd_dst = os.path.join(dstdir, pd)
57 if e.errno != os.errno.EEXIST:
61 for f in install_list:
62 copy(os.path.join(pd_dir, f), pd_dst)
66 def config_get_extra_install(config_file):
68 for line in open(config_file).read().split('\n'):
70 if len(line) == 0 or line[0] == '#':
73 if words[0] != 'extra-install':
75 install_list.extend(words[1:])
87 install-decoders [-i <decoder source>] -o <install path>""")
98 opts, args = getopt(sys.argv[1:], 'i:o:')
104 except Exception as e:
107 if len(args) != 0 or dst is None: