|
12 | 12 | http://docs.opencv.org/3.2.0/db/de0/group__core__utils.html#ga4910d7f86336cd4eff9dd05575667e41
|
13 | 13 | """
|
14 | 14 | from __future__ import print_function
|
| 15 | +import sys |
| 16 | +sys.dont_write_bytecode = True # Don't generate .pyc files / __pycache__ directories |
| 17 | + |
15 | 18 | import os
|
| 19 | +from pprint import pprint |
16 | 20 | import re
|
17 |
| -import sys |
18 | 21 | import logging
|
| 22 | +import json |
| 23 | + |
19 | 24 | import html_functions
|
20 | 25 | import doxygen_scan
|
21 | 26 |
|
22 | 27 | loglevel=os.environ.get("LOGLEVEL", None)
|
23 | 28 | if loglevel:
|
24 | 29 | logging.basicConfig(level=loglevel)
|
25 | 30 |
|
26 |
| - |
27 | 31 | ROOT_DIR = sys.argv[1]
|
28 | 32 | PYTHON_SIGNATURES_FILE = sys.argv[2]
|
29 |
| -JAVA_PYTHON = sys.argv[3] |
| 33 | +JAVA_OR_PYTHON = sys.argv[3] |
30 | 34 |
|
31 | 35 | ADD_JAVA = False
|
32 | 36 | ADD_PYTHON = False
|
33 |
| -if JAVA_PYTHON == "python": |
| 37 | +if JAVA_OR_PYTHON == "python": |
34 | 38 | ADD_PYTHON = True
|
35 | 39 |
|
36 |
| -import json |
37 | 40 | python_signatures = dict()
|
38 | 41 | with open(PYTHON_SIGNATURES_FILE, "rt") as f:
|
39 | 42 | python_signatures = json.load(f)
|
40 | 43 | print("Loaded Python signatures: %d" % len(python_signatures))
|
41 | 44 |
|
42 |
| -# only name -> class |
43 |
| -# name and ret -> constant |
44 |
| -# name, ret, arg-> function / class method |
45 |
| - |
46 |
| -class Configuration(): |
47 |
| - def __init__(self): |
48 |
| - self.ADD_PYTHON = ADD_PYTHON |
49 |
| - self.python_signatures = python_signatures |
50 |
| - self.ADD_JAVA = ADD_JAVA |
51 |
| - |
52 |
| -config = Configuration() |
53 |
| - |
54 | 45 | import xml.etree.ElementTree as ET
|
55 | 46 | root = ET.parse(ROOT_DIR + 'opencv.tag')
|
56 |
| -files_dict = dict() |
| 47 | +files_dict = {} |
57 | 48 |
|
58 | 49 | # constants and function from opencv.tag
|
59 | 50 | namespaces = root.findall("./compound[@kind='namespace']")
|
60 | 51 | #print("Found {} namespaces".format(len(namespaces)))
|
61 | 52 | for ns in namespaces:
|
62 | 53 | ns_name = ns.find("./name").text
|
63 | 54 | #print('NS: {}'.format(ns_name))
|
64 |
| - |
65 |
| - files_dict = doxygen_scan.scan_namespace_constants(ns, ns_name, files_dict) |
66 |
| - files_dict = doxygen_scan.scan_namespace_functions(ns, ns_name, files_dict) |
| 55 | + doxygen_scan.scan_namespace_constants(ns, ns_name, files_dict) |
| 56 | + doxygen_scan.scan_namespace_functions(ns, ns_name, files_dict) |
67 | 57 |
|
68 | 58 | # class methods from opencv.tag
|
69 | 59 | classes = root.findall("./compound[@kind='class']")
|
70 | 60 | #print("Found {} classes".format(len(classes)))
|
71 | 61 | for c in classes:
|
72 | 62 | c_name = c.find("./name").text
|
73 |
| - name = ns_name + '::' + c_name |
74 | 63 | file = c.find("./filename").text
|
75 |
| - #print('Class: {} => {}'.format(name, file)) |
76 |
| - files_dict = doxygen_scan.scan_class_methods(c, c_name, files_dict) |
| 64 | + #print('Class: {} => {}'.format(c_name, file)) |
| 65 | + doxygen_scan.scan_class_methods(c, c_name, files_dict) |
| 66 | + |
| 67 | +print('Doxygen files to scan: %s' % len(files_dict)) |
| 68 | + |
| 69 | +files_processed = 0 |
| 70 | +files_skipped = 0 |
| 71 | +symbols_processed = 0 |
77 | 72 |
|
78 |
| -# test |
79 | 73 | for file in files_dict:
|
80 |
| - soup = html_functions.load_html_file(ROOT_DIR + file) |
81 |
| - if file == "dd/d9e/classcv_1_1VideoWriter.html":#"d4/d86/group__imgproc__filter.html":#"d4/d86/group__imgproc__filter.html": |
82 |
| - anchor_list = files_dict[file] |
83 |
| - counter = 0 |
84 |
| - anchor_tmp_list = [] |
85 |
| - for anchor in anchor_list: |
86 |
| - counter += 1 |
87 |
| - # if the next anchor shares the same C++ name (= same method/function), join them together |
88 |
| - if counter < len(anchor_list) and anchor_list[counter].cppname == anchor.cppname: |
89 |
| - anchor_tmp_list.append(anchor) |
90 |
| - continue |
91 |
| - else: |
92 |
| - anchor_tmp_list.append(anchor) |
93 |
| - # check if extists a python equivalent signature |
94 |
| - for signature in python_signatures: # signature is a key with the C++ name |
95 |
| - if signature == anchor.cppname: # if available name in python |
96 |
| - # they should also have the same type |
97 |
| - soup = html_functions.append_python_signature(python_signatures[signature], anchor_tmp_list, soup) |
98 |
| - #print(signature) |
99 |
| - # reset anchor temporary list |
100 |
| - anchor_tmp_list[:] = [] |
101 |
| - html_functions.update_html(ROOT_DIR + file, soup) |
| 74 | + #if file != "dd/d9e/classcv_1_1VideoWriter.html": |
| 75 | + #if file != "d4/d86/group__imgproc__filter.html": |
| 76 | + #if file != "df/dfb/group__imgproc__object.html": |
| 77 | + # continue |
| 78 | + #print('File: ' + file) |
| 79 | + |
| 80 | + anchor_list = files_dict[file] |
| 81 | + active_anchors = [a for a in anchor_list if a.cppname in python_signatures] |
| 82 | + if len(active_anchors) == 0: # no linked Python symbols |
| 83 | + #print('Skip: ' + file) |
| 84 | + files_skipped = files_skipped + 1 |
| 85 | + continue |
| 86 | + |
| 87 | + active_anchors_dict = {a.anchor: a for a in active_anchors} |
| 88 | + if len(active_anchors_dict) != len(active_anchors): |
| 89 | + logging.info('Duplicate entries detected: %s -> %s (%s)' % (len(active_anchors), len(active_anchors_dict), file)) |
| 90 | + |
| 91 | + files_processed = files_processed + 1 |
| 92 | + |
| 93 | + #pprint(active_anchors) |
| 94 | + symbols_processed = symbols_processed + len(active_anchors_dict) |
| 95 | + |
| 96 | + logging.info('File: %r' % file) |
| 97 | + html_functions.insert_python_signatures(python_signatures, active_anchors_dict, ROOT_DIR + file) |
| 98 | + |
| 99 | +print('Done (processed files %d, symbols %d, skipped %d files)' % (files_processed, symbols_processed, files_skipped)) |
0 commit comments