|
| 1 | +Subject: [PATCH] python: Stop generating libxml2class.txt |
| 2 | +python: Fix file variable not defined during exception |
| 3 | +python: Concat generated files in generator.py |
| 4 | +--- |
| 5 | +Index: python/generator.py |
| 6 | +IDEA additional info: |
| 7 | +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP |
| 8 | +<+>UTF-8 |
| 9 | +=================================================================== |
| 10 | +diff --git a/python/generator.py b/python/generator.py |
| 11 | +--- a/python/generator.py (revision fc4adba90e21e4c49270f159baf1c4c71d51f247) |
| 12 | ++++ b/python/generator.py (revision 38cc2b53eda8bf36d3032ada5cf1d4d59dfd322d) |
| 13 | +@@ -683,7 +683,7 @@ |
| 14 | + parser.feed(data) |
| 15 | + parser.close() |
| 16 | + except IOError as msg: |
| 17 | +- print(file, ":", msg) |
| 18 | ++ print("Failed to open libxml2-api.xml:", msg) |
| 19 | + sys.exit(1) |
| 20 | + |
| 21 | + n = len(list(functions.keys())) |
| 22 | +@@ -697,7 +697,7 @@ |
| 23 | + parser.feed(data) |
| 24 | + parser.close() |
| 25 | + except IOError as msg: |
| 26 | +- print(file, ":", msg) |
| 27 | ++ print("Failed to open libxml2-python-api.xml:", msg) |
| 28 | + |
| 29 | + |
| 30 | + print("Found %d functions in libxml2-python-api.xml" % ( |
| 31 | +@@ -1091,12 +1091,19 @@ |
| 32 | + func = nameFixup(name, "None", file, file) |
| 33 | + info = (0, func, name, ret, args, file) |
| 34 | + function_classes['None'].append(info) |
| 35 | +- |
| 36 | +- classes = open(os.path.join(dstPref, "libxml2class.py"), "w") |
| 37 | +- txt = open(os.path.join(dstPref, "libxml2class.txt"), "w") |
| 38 | +- txt.write(" Generated Classes for libxml2-python\n\n") |
| 39 | ++ |
| 40 | ++ libxml_content = "" |
| 41 | ++ try: |
| 42 | ++ with open(os.path.join(srcPref, "libxml.py"), "r") as libxml_file: |
| 43 | ++ libxml_content = libxml_file.read() |
| 44 | ++ except IOError as msg: |
| 45 | ++ print("Error reading libxml.py:", msg) |
| 46 | ++ sys.exit(1) |
| 47 | + |
| 48 | +- txt.write("#\n# Global functions of the module\n#\n\n") |
| 49 | ++ classes = open(os.path.join(dstPref, "libxml2.py"), "w") |
| 50 | ++ |
| 51 | ++ classes.write(libxml_content) |
| 52 | ++ |
| 53 | + if "None" in function_classes: |
| 54 | + flist = function_classes["None"] |
| 55 | + flist = sorted(flist, key=cmp_to_key(functionCompare)) |
| 56 | +@@ -1105,10 +1112,8 @@ |
| 57 | + (index, func, name, ret, args, file) = info |
| 58 | + if file != oldfile: |
| 59 | + classes.write("#\n# Functions from module %s\n#\n\n" % file) |
| 60 | +- txt.write("\n# functions from module %s\n" % file) |
| 61 | + oldfile = file |
| 62 | + classes.write("def %s(" % func) |
| 63 | +- txt.write("%s()\n" % func) |
| 64 | + n = 0 |
| 65 | + for arg in args: |
| 66 | + if n != 0: |
| 67 | +@@ -1184,14 +1189,11 @@ |
| 68 | + classes.write(" return ret\n") |
| 69 | + classes.write("\n") |
| 70 | + |
| 71 | +- txt.write("\n\n#\n# Set of classes of the module\n#\n\n") |
| 72 | + for classname in classes_list: |
| 73 | + if classname == "None": |
| 74 | + pass |
| 75 | + else: |
| 76 | + if classname in classes_ancestor: |
| 77 | +- txt.write("\n\nClass %s(%s)\n" % (classname, |
| 78 | +- classes_ancestor[classname])) |
| 79 | + classes.write("class %s(%s):\n" % (classname, |
| 80 | + classes_ancestor[classname])) |
| 81 | + classes.write(" def __init__(self, _obj=None):\n") |
| 82 | +@@ -1215,7 +1217,6 @@ |
| 83 | + classes.write(" return \"%s\" %% (self.name, int(pos_id (self)))\n\n" % ( |
| 84 | + format)) |
| 85 | + else: |
| 86 | +- txt.write("Class %s()\n" % (classname)) |
| 87 | + classes.write("class %s:\n" % (classname)) |
| 88 | + classes.write(" def __init__(self, _obj=None):\n") |
| 89 | + if classname in reference_keepers: |
| 90 | +@@ -1246,16 +1247,13 @@ |
| 91 | + if file != oldfile: |
| 92 | + if file == "python_accessor": |
| 93 | + classes.write(" # accessors for %s\n" % (classname)) |
| 94 | +- txt.write(" # accessors\n") |
| 95 | + else: |
| 96 | + classes.write(" #\n") |
| 97 | + classes.write(" # %s functions from module %s\n" % ( |
| 98 | + classname, file)) |
| 99 | +- txt.write("\n # functions from module %s\n" % file) |
| 100 | + classes.write(" #\n\n") |
| 101 | + oldfile = file |
| 102 | + classes.write(" def %s(self" % func) |
| 103 | +- txt.write(" %s()\n" % func) |
| 104 | + n = 0 |
| 105 | + for arg in args: |
| 106 | + if n != index: |
| 107 | +@@ -1380,7 +1378,6 @@ |
| 108 | + classes.write("%s = %s\n" % (name,value)) |
| 109 | + classes.write("\n") |
| 110 | + |
| 111 | +- txt.close() |
| 112 | + classes.close() |
| 113 | + |
| 114 | + buildStubs() |
| 115 | +Index: python/meson.build |
| 116 | +IDEA additional info: |
| 117 | +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP |
| 118 | +<+>UTF-8 |
| 119 | +=================================================================== |
| 120 | +diff --git a/python/meson.build b/python/meson.build |
| 121 | +--- a/python/meson.build (revision fc4adba90e21e4c49270f159baf1c4c71d51f247) |
| 122 | ++++ b/python/meson.build (revision 38cc2b53eda8bf36d3032ada5cf1d4d59dfd322d) |
| 123 | +@@ -16,8 +16,7 @@ |
| 124 | + 'libxml2-py.h', |
| 125 | + 'libxml2-export.c', |
| 126 | + 'libxml2-py.c', |
| 127 | +- 'libxml2class.py', |
| 128 | +- 'libxml2class.txt', |
| 129 | ++ 'libxml2.py', |
| 130 | + ], |
| 131 | + command: [py, '@INPUT@', meson.current_build_dir()], |
| 132 | + ) |
| 133 | +@@ -25,16 +24,6 @@ |
| 134 | + sources : [pygenerated[0]], |
| 135 | + ) |
| 136 | + |
| 137 | +- libxml2_py = custom_target( |
| 138 | +- 'libxml2.py', |
| 139 | +- input: [files('libxml.py'), pygenerated[3]], |
| 140 | +- output: 'libxml2.py', |
| 141 | +- command: [find_program('cat'), '@INPUT@'], |
| 142 | +- capture: true, |
| 143 | +- install: true, |
| 144 | +- install_dir: py.get_install_dir(), |
| 145 | +- ) |
| 146 | +- |
| 147 | + libxml2mod_src = [ |
| 148 | + files('libxml.c', 'types.c'), |
| 149 | + pygenerated[2], |
| 150 | +Index: python/setup.py.in |
| 151 | +IDEA additional info: |
| 152 | +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP |
| 153 | +<+>UTF-8 |
| 154 | +=================================================================== |
| 155 | +diff --git a/python/setup.py.in b/python/setup.py.in |
| 156 | +--- a/python/setup.py.in (revision fc4adba90e21e4c49270f159baf1c4c71d51f247) |
| 157 | ++++ b/python/setup.py.in (revision ffef921be312157147d3b825a8e92d80e50a9e86) |
| 158 | +@@ -116,20 +116,6 @@ |
| 159 | + print(sys.exc_info()[0], sys.exc_info()[1]) |
| 160 | + sys.exit(1) |
| 161 | + |
| 162 | +- head = open("libxml.py", "r") |
| 163 | +- generated = open("libxml2class.py", "r") |
| 164 | +- result = open("libxml2.py", "w") |
| 165 | +- for line in head.readlines(): |
| 166 | +- if WITHDLLS: |
| 167 | +- result.write(altImport(line)) |
| 168 | +- else: |
| 169 | +- result.write(line) |
| 170 | +- for line in generated.readlines(): |
| 171 | +- result.write(line) |
| 172 | +- head.close() |
| 173 | +- generated.close() |
| 174 | +- result.close() |
| 175 | +- |
| 176 | + with_xslt=0 |
| 177 | + if missing("libxslt-py.c") or missing("libxslt.py"): |
| 178 | + if missing("xsltgenerator.py") or missing("libxslt-api.xml"): |
0 commit comments