usdmanager.parsers.usd module¶
USD file parsers
-
class
usdmanager.parsers.usd.
UsdAsciiParser
(*args, **kwargs)[source]¶ Bases:
usdmanager.parser.AbstractExtParser
USD ASCII files.
Treat as plain text. This is the simplest of the Usd parsers, which other USD parsers should inherit from.
-
exts
= ('usda',)¶
-
fileFormat
= 1¶
-
parse
(nativeAbsPath, fileInfo, link)[source]¶ Parse a file for links, generating a plain text version and HTML version of the file text.
Parameters: - nativeAbsPath : str
OS-native absolute file path
- fileInfo : QFileInfo
File info object
- link : QUrl
Full file path URL
-
parseLongLine
(line)[source]¶ Process a long line. Link parsing is skipped, and long USD arrays are truncated in the middle.
Parameters: - line : str
Line of text
Returns: Line of text
Rtype: str
-
parseMatch
(match, linkPath, nativeAbsPath, fileInfo)[source]¶ Parse a RegEx match of a path to another file.
Override for specific language parsing.
Parameters: - match
RegEx match object
- linkPath : str
Displayed file path matched by the RegEx
- nativeAbsPath : str
OS-native absolute file path for the file being parsed
- fileInfo : QFileInfo
File info object for the file being parsed
Returns: HTML link
Rtype: str
Raises ValueError: If path does not exist or cannot be resolved.
-
-
class
usdmanager.parsers.usd.
UsdCrateParser
(*args, **kwargs)[source]¶ Bases:
usdmanager.parsers.usd.UsdAsciiParser
Parse USD file assuming it is a crate file.
Don’t bother checking the fist line for PXR-USDC. If this is a valid ASCII USD file and not binary, but we use this parser accidentally, the file will load slower (since we do a usdcat conversion) but won’t break anything.
-
acceptsFile
(fileInfo, link)[source]¶ Accept .usdc files, or .usd files that do have a true binary query string value (i.e. .usd files we’ve already confirmed are crate).
Parameters: - fileInfo : QFileInfo
File info object
- link : QtCore.QUrl
Full URL, potentially with query string
-
binary
= True¶
-
exts
= ('usdc',)¶
-
fileFormat
= 2¶
-
static
generateTempFile
(fileName, tmpDir=None)[source]¶ Generate a temporary ASCII USD file that the user can edit.
Parameters: - fileName : str
Binary USD file path
- tmpDir : str | None
Temp directory to create the new file within
Returns: Temporary file name
Rtype: str
Raises OSError: If USD conversion fails
-
icon
¶ Used by autodoc_mock_imports.
-
read
(path)[source]¶ Parameters: - path : str
OS-native absolute file path
Returns: List of lines of text of file. Can be overridden by subclasses to handle things like crate conversion from binary to ASCII.
Rtype: [str]
-
write
(qFile, filePath, tab, tmpDir)[source]¶ Write out the text to an ASCII file, then convert it to crate.
Parameters: - qFile : QtCore.QFile
Object representing the file to write to
- filePath : str
File path to write to
- tab : str
Tab being written
- tmpDir : str
Temporary directory, if needed for any write operations.
Raises SaveFileError: If the file write fails.
-
-
class
usdmanager.parsers.usd.
UsdParser
(*args, **kwargs)[source]¶ Bases:
usdmanager.parsers.usd.UsdAsciiParser
Parse ambiguous USD files that may be ASCII or crate.
-
acceptsFile
(fileInfo, link)[source]¶ Accept .usd files that do not have a true binary query string in the URL (i.e. we haven’t yet opened this file to determine if it is crate, or we have checked and it wasn’t crate).
Parameters: - fileInfo : QFileInfo
File info object
- link : QtCore.QUrl
Full URL, potentially with query string
-
exts
= ('usd',)¶
-
fileFormat
= 0¶
-
read
(path)[source]¶ Parameters: - path : str
OS-native absolute file path
Returns: List of lines of text of file. Can be overridden by subclasses to handle things like crate conversion from binary to ASCII.
Rtype: [str]
-
setBinary
(binary)[source]¶ Set if the parser is currently parsing a binary or ASCII file.
Parameters: - binary : bool
If the current file is binary or ASCII.
-
write
(*args, **kwargs)[source]¶ Write out the text to an ASCII or crate file.
Parameters: - qFile : QtCore.QFile
Object representing the file to write to
- filePath : str
File path to write to
- tab : str
Tab being written
- tmpDir : str
Temporary directory, if needed for any write operations.
Raises SaveFileError: If the file write fails.
-
-
class
usdmanager.parsers.usd.
UsdzParser
(*args, **kwargs)[source]¶ Bases:
usdmanager.parsers.usd.UsdParser
Parse zipped USD archives.
-
exts
= ('usdz',)¶
-
fileFormat
= 3¶
-
icon
¶ Used by autodoc_mock_imports.
-
read
(path, layer=None, cache=None, tmpDir=None)[source]¶ Read in a USD zip (.usdz) file via usdzip, uncompressing to a temp directory.
Parameters: - path : str
USDZ file path
- layer : str | None
Default layer within file (e.g. the portion within the square brackets here: @foo.usdz[path/to/file/within/package.usd]@)
- cache : dict | None
Dictionary of cached (e.g. unzipped) files
- tmpDir : str | None
Temporary directory to use for unzipping
Returns: Destination file
Rtype: str
Raises zipfile.BadZipfile: For bad ZIP files
Raises zipfile.LargeZipFile: When a ZIP file would require ZIP64 functionality but that has not been enabled
Raises ValueError: If default layer not found
-
write
(*args, **kwargs)[source]¶ Write out a USD zip file.
Parameters: - qFile : QtCore.QFile
Object representing the file to write to
- filePath : str
File path to write to
- tab : str
Tab being written
- tmpDir : str
Temporary directory, if needed for any write operations.
Raises SaveFileError: If the file write fails.
-