@@ -511,24 +511,41 @@ def _get_asset_from_path(self, path):
511511 _ , basename = os .path .split (path )
512512 filename , extension = os .path .splitext (basename )
513513
514- # Look in the dict of pre-loaded assets before checking the filesystem.
515- try :
514+ assetdir = None
515+ if self ._parent .namescope .has_identifier (
516+ constants .BASEPATH , constants .ASSETDIR_NAMESPACE
517+ ):
518+ assetdir = self ._parent .namescope .get (
519+ constants .BASEPATH , constants .ASSETDIR_NAMESPACE
520+ )
521+
522+ if path in self ._parent .namescope .assets :
523+ # Look in the dict of pre-loaded assets before checking the filesystem.
516524 contents = self ._parent .namescope .assets [path ]
517- except KeyError :
525+ else :
518526 # Construct the full path to the asset file, prefixed by the path to the
519527 # model directory, and by `meshdir` or `texturedir` if appropriate.
520528 path_parts = []
521529 if self ._parent .namescope .model_dir :
522530 path_parts .append (self ._parent .namescope .model_dir )
523- try :
524- base_path = self ._parent .namescope .get (constants .BASEPATH ,
525- self ._path_namespace )
531+
532+ if self ._parent .namescope .has_identifier (
533+ constants .BASEPATH , self ._path_namespace
534+ ):
535+ base_path = self ._parent .namescope .get (
536+ constants .BASEPATH , self ._path_namespace
537+ )
526538 path_parts .append (base_path )
527- except KeyError :
528- pass
539+ elif (
540+ self ._path_namespace
541+ in (constants .TEXTUREDIR_NAMESPACE , constants .MESHDIR_NAMESPACE )
542+ and assetdir is not None
543+ ):
544+ path_parts .append (assetdir )
529545 path_parts .append (path )
530546 full_path = os .path .join (* path_parts ) # pylint: disable=no-value-for-parameter
531547 contents = resources .GetResource (full_path )
548+
532549 if self ._parent .tag == constants .SKIN :
533550 return SkinAsset (contents = contents , parent = self ._parent ,
534551 extension = extension , prefix = filename )
0 commit comments