{"action":"created","issue":{"url":"https://api.github.com/repos/mogui/pyorient/issues/120","labels_url":"https://api.github.com/repos/mogui/pyorient/issues/120/labels{/name}","comments_url":"https://api.github.com/repos/mogui/pyorient/issues/120/comments","events_url":"https://api.github.com/repos/mogui/pyorient/issues/120/events","html_url":"https://github.com/mogui/pyorient/issues/120","id":111187012,"number":120,"title":"Import schema from the database","user":{"login":"lodrion","id":7409275,"avatar_url":"https://avatars.githubusercontent.com/u/7409275?v=3","gravatar_id":"","url":"https://api.github.com/users/lodrion","html_url":"https://github.com/lodrion","followers_url":"https://api.github.com/users/lodrion/followers","following_url":"https://api.github.com/users/lodrion/following{/other_user}","gists_url":"https://api.github.com/users/lodrion/gists{/gist_id}","starred_url":"https://api.github.com/users/lodrion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lodrion/subscriptions","organizations_url":"https://api.github.com/users/lodrion/orgs","repos_url":"https://api.github.com/users/lodrion/repos","events_url":"https://api.github.com/users/lodrion/events{/privacy}","received_events_url":"https://api.github.com/users/lodrion/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-10-13T14:03:56Z","updated_at":"2015-10-17T23:15:21Z","closed_at":null,"body":"It would be useful to import the OGM schema for selected classes/inheritance subtrees from the DB instead of having to define them in code"},"comment":{"url":"https://api.github.com/repos/mogui/pyorient/issues/comments/148959774","html_url":"https://github.com/mogui/pyorient/issues/120#issuecomment-148959774","issue_url":"https://api.github.com/repos/mogui/pyorient/issues/120","id":148959774,"user":{"login":"TropicalPenguin","id":11578939,"avatar_url":"https://avatars.githubusercontent.com/u/11578939?v=3","gravatar_id":"","url":"https://api.github.com/users/TropicalPenguin","html_url":"https://github.com/TropicalPenguin","followers_url":"https://api.github.com/users/TropicalPenguin/followers","following_url":"https://api.github.com/users/TropicalPenguin/following{/other_user}","gists_url":"https://api.github.com/users/TropicalPenguin/gists{/gist_id}","starred_url":"https://api.github.com/users/TropicalPenguin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TropicalPenguin/subscriptions","organizations_url":"https://api.github.com/users/TropicalPenguin/orgs","repos_url":"https://api.github.com/users/TropicalPenguin/repos","events_url":"https://api.github.com/users/TropicalPenguin/events{/privacy}","received_events_url":"https://api.github.com/users/TropicalPenguin/received_events","type":"User","site_admin":false},"created_at":"2015-10-17T23:15:21Z","updated_at":"2015-10-17T23:15:21Z","body":"@lodrion Here's my attempt.\r\n\r\nI don't know how to query indexes, so those property attributes are currently lost. This also preserves class hierarchies, so no need to merge properties manually.\r\n\r\nHere's the slightly ugly code to support sub-tree selection. Since the whole schema is queried anyway,    it shouldn't hurt too much to let users just interrogate the returned classes on their own, as you suggest.\r\n\r\n```python\r\nincluded = not class_names or class_name in class_names\r\nif not included:\r\n    for base in bases:\r\n        for name in class_names:\r\n            if name == 'V' and issubclass(base, vertex):\r\n                included = True\r\n                break\r\n            elif name == 'E' and issubclass(base, edge):\r\n                included = True\r\n                break\r\n            else:\r\n                named_class = registry.get(name, type(None))\r\n                if not named_class:\r\n                    named_class = self.registry.get(name, type(None))\r\n                if issubclass(base, named_class):\r\n                    included = True\r\n                    break\r\n        else:\r\n            continue\r\n        break\r\n\r\nif bases and included:\r\n```"}}