# Path: dpa/app/entity.py
# class EntityError(Exception):
#     pass
# 
# class EntityRegistry(Singleton):
# 
#     # -------------------------------------------------------------------------
#     def init(self):
#         self._registry = defaultdict(list)
# 
#     # -------------------------------------------------------------------------
#     def get_entity_classes(self, app_name):
# 
#         # XXX should be filtered based on current ptask. 
#         # for example, anim stages may want to expose different entity types
#         # than modeling or lighting
# 
#         return self._registry.get(app_name, [])
# 
#     # -------------------------------------------------------------------------
#     def register(self, app_name, cls):
#         self._registry[app_name].append(cls)
# 
# Path: dpa/maya/entity/base.py
# class MayaEntity(Entity):
# 
#     # -------------------------------------------------------------------------
#     @classmethod
#     def get_import_file(cls, session, name, category, representation,
#         relative=True):
# 
#         session_file_path = session.cmds.file(q=True, sceneName=True)
# 
#         if relative:
#             relative_to = os.path.dirname(session_file_path)
#         else:
#             relative_to = None
# 
#         return super(MayaEntity, cls).get_import_file(session, name, category, 
#             representation, relative_to=relative_to)
# 
#     # -------------------------------------------------------------------------
#     @classmethod
#     def _abc_import(cls, session, representation, *args, **kwargs):
# 
#         # XXX
#         product = representation.product_version.product
# 
#         merge_under_selection = kwargs.pop('merge_under_selection', True)
# 
#         # AbcImport, for some ridiculous reason, treats imports as being 
#         # relative to the project rather than the actual file that you're 
#         # working in. This may bite us depending on how alembics are loaded
#         # from disk, but just to get something working, don't use a relative
#         # path.
#         abc_file = cls.get_import_file(session, product.name, 
#             product.category, representation, relative=False)
#     
#         if merge_under_selection:
#             session.mel.eval('AbcImport -m "import" -connect "/" "{path}"'.\
#                 format(path=abc_file))
#         else:
#             session.mel.eval('AbcImport -m "import" "{path}"'.format(
#                 path=abc_file))
# 
#     # -------------------------------------------------------------------------
#     @classmethod
#     def _fbx_import(cls, session, representation, *args, **kwargs):
# 
#         reference = kwargs.pop('reference', True)
#         
#         product = representation.product_version.product
#         fbx_file = cls.get_import_file(session, product.name, 
#             product.category, representation)
# 
#         if reference:
#             #  -options "v=0;" "/home/arizeak/Desktop/fake.fbx";
#             session.cmds.file(fbx_file, reference=True, type="FBX", 
#                 ignoreVersion=True, groupLocator=True, 
#                 mergeNamespacesOnClash=True, namespace=":", options="v=0;")
#         else:
#             session.mel.eval('FBXImport -f "{path}" -s'.format(path=fbx_file))


from dpa.app.entity import EntityError, EntityRegistry
from dpa.maya.entity.base import MayaEntity
                session.cmds.connectAttr(file_node + '.outColor',
                    shader_name + '.transparency')

        # DISPLACEMENT
        elif maps_type in ['disp', 'displacement', 'dispMap', 'displacementMap']:

            add_attr = 'rmanAddAttr {sn} {attr} "";'
            session.mel.eval(add_attr.format(sn=shader_name,
                    attr='rman__riattr__displacementbound_sphere'))

            session.mel.eval(add_attr.format(sn=shader_name,
                    attr='rman__riattr__displacementbound_coordinatesystem'))

            session.mel.eval(add_attr.format(sn=shader_name,
                    attr='rman__riattr__trace_displacements'))

            if connect:
                session.cmds.connectAttr(file_node + '.outColor.outColorR',
                    shader_name + '.displacementScalar')

            session.cmds.setAttr(shader_name + '.displacementAmount', 1.0)

            session.cmds.setAttr(
                shader_name + ".rman__riattr__displacementbound_sphere", 1.0)

            session.mel.eval('rmanSetAttr {sn} {val} 0;'.format(sn=shader_name,
                    val='enableDisplacement'))

        # UNKNOWN
        else:

# Path: dpa/app/entity.py
# class EntityError(Exception):
#     pass
# 
# class EntityRegistry(Singleton):
# 
#     # -------------------------------------------------------------------------
#     def init(self):
#         self._registry = defaultdict(list)
# 
#     # -------------------------------------------------------------------------
#     def get_entity_classes(self, app_name):
# 
#         # XXX should be filtered based on current ptask. 
#         # for example, anim stages may want to expose different entity types
#         # than modeling or lighting
# 
#         return self._registry.get(app_name, [])
# 
#     # -------------------------------------------------------------------------
#     def register(self, app_name, cls):
#         self._registry[app_name].append(cls)
# 
# Path: dpa/maya/entity/base.py
# class MayaEntity(Entity):
# 
#     # -------------------------------------------------------------------------
#     @classmethod
#     def get_import_file(cls, session, name, category, representation,
#         relative=True):
# 
#         session_file_path = session.cmds.file(q=True, sceneName=True)
# 
#         if relative:
#             relative_to = os.path.dirname(session_file_path)
#         else:
#             relative_to = None
# 
#         return super(MayaEntity, cls).get_import_file(session, name, category, 
#             representation, relative_to=relative_to)
# 
#     # -------------------------------------------------------------------------
#     @classmethod
#     def _abc_import(cls, session, representation, *args, **kwargs):
# 
#         # XXX
#         product = representation.product_version.product
# 
#         merge_under_selection = kwargs.pop('merge_under_selection', True)
# 
#         # AbcImport, for some ridiculous reason, treats imports as being 
#         # relative to the project rather than the actual file that you're 
#         # working in. This may bite us depending on how alembics are loaded
#         # from disk, but just to get something working, don't use a relative
#         # path.
#         abc_file = cls.get_import_file(session, product.name, 
#             product.category, representation, relative=False)
#     
#         if merge_under_selection:
#             session.mel.eval('AbcImport -m "import" -connect "/" "{path}"'.\
#                 format(path=abc_file))
#         else:
#             session.mel.eval('AbcImport -m "import" "{path}"'.format(
#                 path=abc_file))
# 
#     # -------------------------------------------------------------------------
#     @classmethod
#     def _fbx_import(cls, session, representation, *args, **kwargs):
# 
#         reference = kwargs.pop('reference', True)
#         
#         product = representation.product_version.product
#         fbx_file = cls.get_import_file(session, product.name, 
#             product.category, representation)
# 
#         if reference:
#             #  -options "v=0;" "/home/arizeak/Desktop/fake.fbx";
#             session.cmds.file(fbx_file, reference=True, type="FBX", 
#                 ignoreVersion=True, groupLocator=True, 
#                 mergeNamespacesOnClash=True, namespace=":", options="v=0;")
#         else:
#             session.mel.eval('FBXImport -f "{path}" -s'.format(path=fbx_file))


# Path: dpa/maya/entity/maps.py
from dpa.app.entity import EntityError, EntityRegistry
from dpa.maya.entity.base import MayaEntity

                session.cmds.connectAttr(file_node + '.outColor',
                    shader_name + '.transparency')

        # DISPLACEMENT
        elif maps_type in ['disp', 'displacement', 'dispMap', 'displacementMap']:

            add_attr = 'rmanAddAttr {sn} {attr} "";'
            session.mel.eval(add_attr.format(sn=shader_name,
                    attr='rman__riattr__displacementbound_sphere'))

            session.mel.eval(add_attr.format(sn=shader_name,
                    attr='rman__riattr__displacementbound_coordinatesystem'))

            session.mel.eval(add_attr.format(sn=shader_name,
                    attr='rman__riattr__trace_displacements'))

            if connect:
                session.cmds.connectAttr(file_node + '.outColor.outColorR',
                    shader_name + '.displacementScalar')

            session.cmds.setAttr(shader_name + '.displacementAmount', 1.0)

            session.cmds.setAttr(
                shader_name + ".rman__riattr__displacementbound_sphere", 1.0)

            session.mel.eval('rmanSetAttr {sn} {val} 0;'.format(sn=shader_name,
                    val='enableDisplacement'))

        # UNKNOWN
        else:

            raise EntityError("Don't know how to process map type: " + maps_type)