blob: 7e9df9d0490359a5e7f38f0ba2b54012fa4ddabd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/usr/bin/env python
#
# Copyright 2015-2022 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.
# rcc-depends.py is a small tool that can be used as a drop-in
# replacement for 'rcc -list' as a command to find dependencies
# for .qrc files.
from __future__ import (unicode_literals, print_function, division)
import os
import platform
import sys
from xml.dom import minidom
def main():
inputs = sys.argv[1:]
for fn in inputs:
with open(fn, 'r') as f:
absFn = os.path.abspath(fn)
fnDir = os.path.dirname(absFn)
s = f.read()
dom = minidom.parseString(s)
fileTags = dom.getElementsByTagName('file')
for fileTag in fileTags:
textNode = fileTag.childNodes[0].wholeText
absPath = os.path.normpath(os.path.join(fnDir, textNode))
if platform.system() == 'Windows':
try:
output = os.path.relpath(absPath)
except ValueError:
# In some cases, Qt lives on another drive than Mumble.
# This means that we can't create relative path from
# our absolute path.
# In those cases, use the absolute path instead.
output = absPath
output = output.replace('\\', '/')
else:
output = os.path.relpath(absPath)
print(output)
if __name__ == '__main__':
main()
|