Merge pull request #18038 from glassez/tree-update
[qBittorrent.git] / src / update_qrc_files.py
blob1767bc962706ab78ecffac0449dfbe5fb8dbe851
1 #!/usr/bin/env python
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are met:
6 # * Redistributions of source code must retain the above copyright notice,
7 # this list of conditions and the following disclaimer.
8 # * Redistributions in binary form must reproduce the above copyright
9 # notice, this list of conditions and the following disclaimer in the
10 # documentation and/or other materials provided with the distribution.
11 # * Neither the name of the author nor the names of its contributors may be
12 # used to endorse or promote products derived from this software without
13 # specific prior written permission.
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
27 # Small script to update qrc files (lang.qrc, icons.qrc)
28 # by Christophe Dumez <chris@qbittorrent.org>
30 import os
31 from os.path import splitext, join
33 # update languages files directory
34 languages_list = [x for x in os.listdir('lang') if x.endswith('.qm')]
35 output = '''<!DOCTYPE RCC><RCC version="1.0">
36 <qresource>
37 '''
38 for language in languages_list:
39 output += ' <file>%s</file>'%('lang'+os.sep+language)
40 output += os.linesep
41 output += '''</qresource>
42 </RCC>'''
43 lang_file = open('lang.qrc', 'w')
44 lang_file.write(output)
45 lang_file.close()
47 # update search_engine directory
48 os.chdir('gui/searchengine')
49 search_list = []
50 for root, dirs, files in os.walk('nova3'):
51 for file in files:
52 if file.startswith("__"):
53 continue
54 if splitext(file)[-1] in ('.py', '.png'):
55 search_list.append(join(root, file))
57 output = '''<!DOCTYPE RCC><RCC version="1.0">
58 <qresource>
59 '''
60 for file in search_list:
61 output += ' <file>%s</file>'%(file)
62 output += os.linesep
63 output += '''</qresource>
64 </RCC>'''
65 search_file = open('search.qrc', 'w')
66 search_file.write(output)
67 search_file.close()
69 os.chdir('../..');
71 # update icons files directory
72 icons_list = []
73 for root, dirs, files in os.walk('icons'):
74 if 'skin_unused' in dirs:
75 dirs.remove('skin_unused')
76 for file in files:
77 if splitext(file)[-1] in ('.png', '.jpg', '.gif'):
78 icons_list.append(join(root, file))
80 output = '''<!DOCTYPE RCC><RCC version="1.0">
81 <qresource>
82 '''
83 for icon in icons_list:
84 output += ' <file>%s</file>'%(icon)
85 output += os.linesep
86 output += '''</qresource>
87 </RCC>'''
88 icons_file = open('icons.qrc', 'w')
89 icons_file.write(output)
90 icons_file.close()