def main(): args = parse_args() config = util.load_yaml(args.config) files = util.input_files(args.files) lang = language.get(args.lang, None)["TypeMap"] files.extend([f"{PRESTO_HOME}/{file}" for file in config.JavaClasses]) classes = defaultdict(util.attrdict) depends = defaultdict(set) subclasses = {} for abstract_name, abstract_value in config.AbstractClasses.items(): classes[abstract_name].class_name = abstract_name classes[abstract_name].field_name = member_name(abstract_name) classes[abstract_name].abstract = True classes[abstract_name].super_class = abstract_value.super if "comparable" in abstract_value: classes[abstract_name].comparable = True classes[abstract_name].subclasses = [] for subclass in abstract_value.subclasses: subclasses[subclass.name] = util.attrdict(super=abstract_name, key=subclass.key) classes[abstract_name].subclasses.append( util.attrdict( type=subclass.name, name=member_name(subclass.name), key=subclass.key, )) classes[abstract_name].subclasses[-1]._N = len( classes[abstract_name].subclasses) classes[abstract_name].subclasses[-1]._last = True if "source" in abstract_value: file = abstract_value.source process_file(f"{PRESTO_HOME}/{file}", config, lang, subclasses, classes, depends) else: classes[abstract_name].fields = [] add_extra(abstract_name, abstract_name, config, lang, classes, depends) for file in files: process_file(file, config, lang, subclasses, classes, depends) depends = list(topological({k: list(v) for k, v in depends.items()}))[::-1] comment = "// This file is generated DO NOT EDIT @" + "generated" result = [{"comment": comment}] result += [classes[name] for name in depends if name in classes] result += [classes[name] for name in config.AddToOutput] if args.json: print(util.to_json(result))
def make_call(self, method, url, payload=None): if payload: enc_payload = simplejson.dumps(payload) else: enc_payload = "" response = requests.request(method, self.baseuri+url, data=enc_payload, auth=self.auth()) response_body = simplejson.loads(response.text) #print response_body if response.status_code not in (200, 201): raise GithubV3APIError(response.status_code, response_body['message'], response_body) return attrdict(response_body)
def make_call(self, method, url, payload=None): if payload: enc_payload = simplejson.dumps(payload) else: enc_payload = "" response = requests.request(method, self.baseuri + url, data=enc_payload, auth=self.auth()) response_body = simplejson.loads(response.text) # print response_body if response.status_code not in (200, 201): raise GithubV3APIError(response.status_code, response_body["message"], response_body) return attrdict(response_body)
def add_field(current_class, filename, field_name, field_type, config, lang, classes, depends): if filename in config.EnumMap and field_type in config.EnumMap[filename]: field_type = config.EnumMap[filename][field_type] field_flag = {} field_text = field_type field_local = True if "super_class" in classes[current_class]: super = classes[classes[current_class].super_class] if "fields" in super: if (len( list( filter(lambda x: x.field_name == field_name, super.fields))) != 0): field_local = False for key, value in lang.items(): if type(value) == str: field_text = regex.sub(key, value, field_text) else: field_text, n = regex.subn(key, value["replace"], field_text) if n > 0: if value["flag"]: field_flag.update(value["flag"]) classes[current_class].fields.append( util.attrdict(field_type=field_type, field_name=field_name, field_text=field_text)) classes[current_class].fields[-1].update(field_flag) classes[current_class].fields[-1]._N = len(classes[current_class].fields) if current_class == field_type: classes[current_class].fields[-1].optional = True classes[current_class].fields[-1].field_local = field_local if (field_type in classes and "abstract" in classes[field_type] and classes[field_type].abstract): classes[current_class].fields[-1].optional = True types = set(regex.sub("[^a-zA-Z0-9_]+", " ", field_type).split()) types.discard(current_class) depends[current_class].update(types)
float: Symbol("s", "number"), str: Symbol("s", "text"), Symbol: Symbol("s", "symbol"), Location: Symbol("s", "location")} class NoSuchLocationError(Exception): pass class UndefinedDocError(Exception): pass # {{{ notify = notify = attrdict(valueChanged = Symbol("", "value-changed"), addProperty = Symbol("", "add-property"), delProperty = Symbol("", "del-property"), addSlice = Symbol("", "add-slice"), delSlice = Symbol("", "del-slice"), tagChanged = Symbol("", "tag-changed"), noSuchLocation = Symbol("", "no-such-location")) # }}} # {{{ class BaseDoc(object): # {{{ def strToSymbol(x): def strToSymbol(x): if isinstance(x, str): return Symbol("", x) else: return x # }}}
Keyboard commands: f: Output frames of the OpenGL buffer. g: Toggle grid. p: Print metadata. r: Toggle rotation minimizing frames. s: Toggle geometry display (if available). t: Toggle turntable. x: Toggle origin display. z: Reset the view. 2: Toggle seed path display. ?: Print this message. ''' runner = None opt = attrdict() opt.current_frame = 1 opt.frame_format = "out.%04d.png" opt.history = [] opt.history_max = 256 opt.meta = attrdict() opt.refresh_rate = int(1000 / 30) opt.rotate_x = 0.0 opt.rotate_y = 0.2 opt.turntable_rate = math.pi / 10 opt.want_continuous = False opt.want_frames = False opt.want_geometry = True opt.want_grid = True opt.want_xyz = False opt.want_history = False
def process_file(filepath, config, lang, subclasses, classes, depends): filename = util.get_filename(filepath) if filepath.endswith(".hpp.inc"): special(filepath, filename[:-len(".hpp.inc")], "hinc", classes, depends) return if filepath.endswith(".cpp.inc"): special(filepath, filename[:-len(".cpp.inc")], "cinc", classes, depends) return fileroot = os.path.splitext(filename)[0] current_enum = "" current_class = "" json = False lineno = 1 for line in preprocess_file(filepath): lineno += 1 fields = line.split() if regex.match(r"^ *$", line): continue # Find any enums in the java class # match = regex.match(r" *(public|private) enum .*", line) if match: current_enum = fields[2] if fileroot in config.EnumMap and current_enum in config.EnumMap[ fileroot]: current_enum = config.EnumMap[fileroot][current_enum] classes[current_enum].class_name = current_enum classes[current_enum].enum = True classes[current_enum].elements = [] if current_enum != "": line = regex.sub(r"\([^)]+\)", " ", line) fields = line.split() match = regex.match(r"^[A-Z0-9_]+[,;]?$", fields[0]) if current_enum != "" and match: line = regex.sub(r"//.*$", "", line) line = regex.sub(r"[{;]", "", line) names = line.split(",") for name in names: name = name.strip() if name == "": continue name = name.split()[0] classes[current_enum].elements.append( util.attrdict(element=name)) classes[current_enum].elements[-1]._N = len( classes[current_enum].elements) match = regex.match(r".*;$|^}$|^};$", line) if current_enum != "" and match: classes[current_enum].elements[-1]._last = True current_enum = "" # Use the JsonCreator as the definition of a class # match = regex.match(r".*@JsonCreator.*", line) if match: json = True line = regex.sub(r"[()]", " ", line) fields = line.split() match = regex.match(r" *public.*", line) if json and match: current_class = fields[1] if fields[1] != "static" else fields[2] classes[current_class].class_name = current_class classes[current_class].struct = True classes[current_class].fields = [] if current_class in subclasses: classes[current_class].subclass = True classes[current_class].super_class = subclasses[ current_class].super classes[current_class].json_key = subclasses[current_class].key match = regex.match(r" *@JsonProperty.*", line) if json and match and len(fields) >= 3: line = regex.sub(r"^[^@]*", "", line) line = regex.sub(r"@Nullable", "", line) fields = line.split() fields[-1] = regex.sub(r",", "", fields[-1]) if fields[1][0] == '"': type = " ".join(fields[2:-1]) name = regex.sub('"', "", fields[1]) else: type = " ".join(fields[1:-1]) name = fields[-1] add_field(current_class, fileroot, name, type, config, lang, classes, depends) match = regex.match(r" *{ *", line) if json and match: add_extra(current_class, fileroot, config, lang, classes, depends) if len(classes[current_class].fields) == 0: classes.pop(current_class) json = False continue json = False return classes
} class NoSuchLocationError(Exception): pass class UndefinedDocError(Exception): pass # {{{ notify = notify = attrdict(valueChanged=Symbol("", "value-changed"), addProperty=Symbol("", "add-property"), delProperty=Symbol("", "del-property"), addSlice=Symbol("", "add-slice"), delSlice=Symbol("", "del-slice"), tagChanged=Symbol("", "tag-changed"), noSuchLocation=Symbol("", "no-such-location")) # }}} # {{{ class BaseDoc(object): # {{{ def strToSymbol(x): def strToSymbol(x): if isinstance(x, str): return Symbol("", x) else: return x