1#!/usr/local/bin/python3.8 2# Copyright © 2020, Canonical Ltd 3# 4# This program is free software; you can redistribute it and/or 5# modify it under the terms of the GNU Lesser General Public 6# License as published by the Free Software Foundation; either 7# version 2.1 of the License, or (at your option) any later version. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12# Lesser General Public License for more details. 13# 14# You should have received a copy of the GNU Lesser General Public 15# License along with this library. If not, see <http://www.gnu.org/licenses/>. 16# Authors: 17# Marco Trevisan <marco.trevisan@canonical.com> 18 19import argparse 20import fnmatch 21import os 22import xml.etree.ElementTree as ET 23 24if __name__ == '__main__': 25 parser = argparse.ArgumentParser() 26 parser.add_argument('gresource_source', type=argparse.FileType('r')) 27 parser.add_argument('--path', default='') 28 parser.add_argument('--filter', action='append', default=[]) 29 30 args = parser.parse_args() 31 gsource_xml = ET.ElementTree(file=args.gresource_source.name) 32 source_files = [f.text for f in gsource_xml.findall('.//gresource/file')] 33 34 filtered = [] 35 for f in source_files: 36 if [fl for fl in args.filter if fnmatch.fnmatch(f, fl)]: 37 continue 38 39 filtered.append(os.path.join(args.path, f)) 40 41 print('\n'.join(filtered)) 42