"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.8.2/src/bindings/src_list.py" (20 May 2019, 1335 Bytes) of package /linux/privat/cutter-1.8.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "src_list.py" see the Fossies "Dox" file reference documentation.

    1 #!/bin/env python3
    2 
    3 import os
    4 import xml.etree.ElementTree as et
    5 import sys
    6 
    7 
    8 script_path = os.path.dirname(os.path.realpath(__file__))
    9 
   10 
   11 def get_cpp_files_gen(args, include_package=True):
   12     ts_tree = et.parse(os.path.join(script_path, "bindings.xml"))
   13     ts_root = ts_tree.getroot()
   14 
   15     package = ts_root.attrib["package"]
   16 
   17     type_tags = ["object-type", "value-type"]
   18     types = [child.attrib["name"] for child in ts_root if child.tag in type_tags]
   19 
   20     cpp_files_gen = [f"{package.lower()}_module_wrapper.cpp"]
   21     cpp_files_gen.extend([f"{typename.lower()}_wrapper.cpp" for typename in types])
   22 
   23     if include_package:
   24         cpp_files_gen = [os.path.join(package, f) for f in cpp_files_gen]
   25 
   26     if len(args) > 0:
   27         cpp_files_gen = [os.path.join(args[0], f) for f in cpp_files_gen]
   28 
   29     return cpp_files_gen
   30 
   31 
   32 def cmd_cmake(args):
   33     sys.stdout.write(";".join(get_cpp_files_gen(args)))
   34 
   35 
   36 def cmd_qmake(args):
   37     sys.stdout.write("\n".join(get_cpp_files_gen(args)) + "\n")
   38 
   39 
   40 def cmd_meson(args):
   41     sys.stdout.write(";".join(get_cpp_files_gen(args, include_package=False)))
   42 
   43 
   44 cmds = {"cmake": cmd_cmake, "qmake": cmd_qmake, "meson": cmd_meson}
   45 
   46 if len(sys.argv) < 2 or sys.argv[1] not in cmds:
   47     print(f"""usage: {sys.argv[0]} [{"/".join(cmds.keys())}] [base path]""")
   48     exit(1)
   49 cmds[sys.argv[1]](sys.argv[2:])