designspace: normalize platform path separator in getSourcePath

This commit is contained in:
Cosimo Lupo 2019-01-02 16:11:32 +00:00
parent a0e4c04c1e
commit e640806657
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482

View File

@ -1282,13 +1282,15 @@ class DesignSpaceDocument(LogMixin, AsDictMixin):
'path' attribute, or if the latter is not set, the concatenation of 'path' attribute, or if the latter is not set, the concatenation of
the source's (relative) 'filename' attribute and the designspace's the source's (relative) 'filename' attribute and the designspace's
directory. directory.
The returned path uses the platform-specific path separator: i.e.
forward slash on POSIX, backslash on Windows.
Raises DesignSpaceDocumentError if sourceDescriptor.path is None and Raises DesignSpaceDocumentError if sourceDescriptor.path is None and
self.path is None, or sourceDescriptor.filename is None. self.path is None, or sourceDescriptor.filename is None.
""" """
if sourceDescriptor.path: if sourceDescriptor.path:
# prefer absolute path if present # prefer absolute path if present
return sourceDescriptor.path return os.path.normpath(sourceDescriptor.path)
if self.path is None: if self.path is None:
raise DesignSpaceDocumentError( raise DesignSpaceDocumentError(
"DesignSpaceDocument 'path' attribute is not defined; cannot " "DesignSpaceDocument 'path' attribute is not defined; cannot "