def _process_property(self, pages, path, root, block, doc): name = self._get_title(block) attrs = block.get("attrs") ifdprop = attrs.get("ifdprop") if attrs else None hprop = attrs.get("hprop") if attrs else None # Set the best-bet field to the Houdini property name doc["title"] = name if hprop and hprop != name: doc["grams"] = "%s (%s)" % (name, hprop) # Set the page fragment to the Houdini or IFD property name if hprop: ident = hprop elif ifdprop: ident = ifdprop.replace(":", "_") else: ident = util.make_id(name) doc["path"] = "%s#%s" % (path, ident) doc["type"] = doc["category"] = "property"
def urlToPath(url): """ Translates a URL from Houdini (e.g. "op:Sop/copy") and translates it into a help server path (e.g. "/nodes/sop/copy"). """ parsed = urlparse.urlparse(url) # urlparse.parse_qs properly returns a dictionary mapping to LISTS of # values, since a query string can have repeated keys, but we don't need # that capability so we'll just turn it into a dict mapping to the first # value qs = dict((key, vallist[0]) for key, vallist in urlparse.parse_qs(parsed.query).items()) if parsed.scheme in ("op", "operator"): table, name = parsed.path.split("/") if table.endswith("_state"): return "/shelf/" + name version = qs.get("version") path = components_to_path(table, qs.get("scopeop"), qs.get("namespace"), name, version) pages = get_pages() if not pages.exists(path) and version is not None: path = components_to_path(table, qs.get("scopeop"), qs.get("namespace"), name, None) return path elif parsed.scheme == "parm": s = get_searcher() r = s.reader() table, name, parmname, parmlabel = parsed.path.split("/") nodepath = components_to_path(table, qs.get("scopeop"), qs.get("namespace"), name, qs.get("version")) path1 = "%s#%s" % (nodepath, parmname) path2 = "%s#%s" % (nodepath, util.make_id(parmlabel)) if ("path", path1) in r: return path1 else: return path2 elif parsed.scheme == "gallery": table, name, entry = parsed.path.split("/") nodepath = components_to_path(table, qs.get("scopeop"), qs.get("namespace"), name, qs.get("version")) return "/gallery/" + nodepath elif parsed.scheme == "tool": return "/shelf/" + parsed.path elif parsed.scheme == "prop": # Replace any versioned mantraX.X with just "mantra" path = re.sub("^mantra[0-9.]+", "mantra", parsed.path) page, name = path.split("/") return "/props/%s#%s" % (page, name) elif parsed.scheme == "expr": return "/expressions/" + parsed.path elif parsed.scheme == "hscript": return "/commands/" + parsed.path elif parsed.scheme == "opdef": return "/nodes/" + parsed.path elif parsed.scheme == "vex": return "/vex/functions/" + parsed.path elif parsed.scheme == "pypanel": return "/pypanel/" + parsed.path