mumble/scripts/rcc-depends.py
2017-01-08 21:05:57 +01:00

39 lines
1.1 KiB
Python
Executable File

#!/usr/bin/env python
#
# Copyright 2005-2017 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))
relPath = os.path.relpath(absPath)
output = relPath
if platform.system() == 'Windows':
output = output.replace('\\', '/')
print(output)
if __name__ == '__main__':
main()