Created
November 29, 2013 09:50
-
-
Save bartv/7703580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Imp.export import dependency_manager | |
from Imp.resources import Resource | |
@dependency_manager | |
def use_relations(config_model, resources): | |
for _id, resource in resources.items(): | |
res_class = resource.model.__class__ | |
if resource.model.__module__ == "std" and res_class.__name__ == "File": | |
model = resource.model | |
for name, attr in model.__entity__._attributes.items(): | |
# check if the attribute is a relation | |
if hasattr(attr, "end"): | |
# get our side | |
attr_end = attr.end | |
if attr_end.depends: | |
requirement = getattr(model, name) | |
print("%s depends on %s" % (model, requirement)) | |
req_resource = Resource.get_resource(requirement) | |
if not req_resource: | |
print(" but %s is not exported" % requirement) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment