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.

compile()[source]

Compile regular expression to find links in USD files.

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

exts = ('usdc',)
fileFormat = 2
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]

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]