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 47 48 49 50 51 52 53 54 55 56 57 58
|
"""Help you manage your pyuic.json file (pyqt-distutils)
Usage:
pyuicfg -g
pyuicfg -g --pyqt5
pyuicfg -g --pyside
pyuicfg -a SOURCE_FILE DESTINATION_PACKAGE
pyuicfg -r SOURCE_FILE
pyuicfg (-h | --help)
pyuicfg --version
Options:
-h, --help Show help
--version Show version
-g Generate pyuic.json
-a SOURCE_FILE DESTINATION_PACKAGE Add file to pyuic.json
-r SOURCE_FILE Remove file from pyuic.json
--pyqt5 Generate a pyuic.json file for PyQt5 instead of PyQt4
--pyside Generate a pyuic.json file for PySide instead of PyQt4
"""
import os
from docopt import docopt
from pyqt_distutils import __version__
from pyqt_distutils.config import Config, QtApi
def qt_api_from_args(arguments):
if arguments['--pyqt5']:
return QtApi.pyqt5
elif arguments['--pyside']:
return QtApi.pyside
return QtApi.pyqt4
def main():
arguments = docopt(__doc__, version=__version__)
generate = arguments['-g']
file_to_add = arguments['-a']
destination_package = arguments['DESTINATION_PACKAGE']
file_to_remove = arguments['-r']
api = qt_api_from_args(arguments)
cfg = Config()
if generate:
if os.path.exists('pyuic.json'):
choice = input('pyuic.json already exists. Do you want to replace '
'it? (y/N) ').lower()
if choice != 'y':
return
cfg.generate(api)
elif file_to_add:
cfg.add(file_to_add, destination_package)
elif file_to_remove:
cfg.remove(file_to_remove)
if __name__ == '__main__':
main()
|