(self, path)
Constructs a `Asset` given a file path.
Constructs a `Asset` given a file path.
Constructs a Asset given a file path .
def _get_asset_from_path(self, path):
    """Constructs a `Asset` given a file path."""
    _, basename = os.path.split(path)
    filename, extension = os.path.splitext(basename)

    # Look in the dict of pre-loaded assets before checking the filesystem.
    try:
      contents = self._parent.namescope.assets[path]
    except KeyError:
      # Construct the full path to the asset file, prefixed by the path to the
      # model directory, and by `meshdir` or `texturedir` if appropriate.
      path_parts = []
      if self._parent.namescope.model_dir:
        path_parts.append(self._parent.namescope.model_dir)
      try:
        base_path = self._parent.namescope.get(constants.BASEPATH,
                                               self._path_namespace)
        path_parts.append(base_path)
      except KeyError:
        pass
      path_parts.append(path)
      full_path = os.path.join(*path_parts)  # pylint: disable=no-value-for-parameter
      contents = resources.GetResource(full_path)
    if self._parent.tag == constants.SKIN:
      return SkinAsset(contents=contents, parent=self._parent,
                       extension=extension, prefix=filename)
    else:
      return Asset(contents=contents, extension=extension, prefix=filename)
def _get_asset_from_path ( self , path ) : _ , basename = os . path . split ( path ) filename , extension = os . path . splitext ( basename ) # Look in the dict of pre-loaded assets before checking the filesystem. try : contents = self . _parent . namescope . assets [ path ] except KeyError : # Construct the full path to the asset file, prefixed by the path to the # model directory, and by `meshdir` or `texturedir` if appropriate. path_parts = [ ] if self . _parent . namescope . model_dir : path_parts . append ( self . _parent . namescope . model_dir ) try : base_path = self . _parent . namescope . get ( constants . BASEPATH , self . _path_namespace ) path_parts . append ( base_path ) except KeyError : pass path_parts . append ( path ) full_path = os . path . join ( * path_parts ) # pylint: disable=no-value-for-parameter contents = resources . GetResource ( full_path ) if self . _parent . tag == constants . SKIN : return SkinAsset ( contents = contents , parent = self . _parent , extension = extension , prefix = filename ) else : return Asset ( contents = contents , extension = extension , prefix = filename )