usdmanager package¶
Subpackages¶
Submodules¶
- usdmanager.constants module
- usdmanager.file_dialog module
- usdmanager.file_status module
- usdmanager.find_dialog module
- usdmanager.highlighter module
- usdmanager.images_rc module
- usdmanager.include_panel module
- usdmanager.linenumbers module
- usdmanager.preferences_dialog module
- usdmanager.utils module
- usdmanager.version module
Module contents¶
Application module for usdmanager.
Class hierarchy:
- App
- UsdMngrWindow (multiple windows allowed)
- AddressBar
- TabWidget
- TabBar
- BrowserTab (one tab per file)
- LineNumbers
- TextBrowser
- TextEdit
- UsdMngrWindow (multiple windows allowed)
-
class
usdmanager.
AddressBar
(parent)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Custom QLineEdit class to enable drag/drop.
-
goPressed
¶ Used by autodoc_mock_imports.
-
openFile
¶ Used by autodoc_mock_imports.
-
-
class
usdmanager.
AddressBarCompleter
(model, parent=None)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Custom completer for AddressBar.
-
class
usdmanager.
App
(*args, **kwargs)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Application class that initializes the main Qt window as defined in a ui template file.
-
app
= None¶
-
appDisplayName
= 'USD Manager'¶
-
config
= None¶
-
createWindowFrame
()[source]¶ Create a a new widget based on self.uiSource.
Returns: A dynamically-created widget object. Rtype: CustomWidget
-
uiSource
¶ alias of
UsdMngrWindow
-
-
class
usdmanager.
BrowserTab
(parent=None)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
A QWidget that contains custom objects for each tab in the browser. This primarily consists of a text browser and text editor.
-
changeTab
¶ Used by autodoc_mock_imports.
-
findPath
(path)[source]¶ Find the index of the given path in the tab’s history.
Parameters: - path : str
Path to search for in history.
Returns: Index of the given path in the history, or 0 if not found.
Rtype: int
-
getCurrentPath
()[source]¶ Get the absolute path of the current file.
Returns: Absolute path to current file Ex: /studio/filename.usd Rtype: str
-
getCurrentTextWidget
()[source]¶ Get the current text widget (browser or editor).
Returns: The current text widget, based on edit mode Rtype: TextBrowser | QtGui.QTextEdit
-
getCurrentUrl
()[source]¶ Get the absolute path to the current file with any query strings appended.
Returns: Absolute path to current file plus any query strings. Ex: /studio/filename.usd?line=14 Rtype: QtCore.QUrl
-
getFileStatus
()[source]¶ Get the current file’s status.
Returns: The current file’s cached status Rtype: FileStatus
-
isBackwardAvailable
()[source]¶ Check if you can go back in history.
Returns: If the backward action for history is available. Rtype: bool
-
isDirty
()[source]¶ Check if the current file has been modified in app.
Returns: If the current text editor document has been modified Rtype: bool
-
isForwardAvailable
()[source]¶ Check if you can go forward in history.
Returns: If the forward action for history is available. Rtype: bool
-
onActionTriggered
(*args)[source]¶ Slot called when a file action is activated (e.g. a file from the Recent Files menu).
-
openFile
¶ Used by autodoc_mock_imports.
-
restoreTab
¶ Used by autodoc_mock_imports.
-
setTabSpaces
(useSpaces=True, tabSpaces=4)[source]¶ Set the width of a tab character in spaces, both for display and editing.
Parameters: - useSpaces : bool
Use spaces instead of a tab character
- spaces : int
Tab size in spaces
-
updateBreadcrumb
()[source]¶ Update the breadcrumb of file browsing paths and the action for the currently open file, which lets us restore the tab after it is closed.
-
updateFileStatus
(truncated=False)[source]¶ Check the status of a file.
Parameters: - truncated : bool
If the file was truncated on read, and therefore should never be edited.
-
updateHistory
(url, update=False, truncated=False)[source]¶ Add a newly created file to the tab’s history.
Parameters: - url : QtCore.QUrl
Link for file to add to history list.
- update : bool
Update the path’s file status cache.
- truncated : bool
If the file was truncated on read, and therefore should never be edited.
-
-
class
usdmanager.
PathCacheDict
[source]¶ Bases:
collections.defaultdict
Cache if file paths referenced more than once in a file exist, so we don’t check on disk over and over.
-
class
usdmanager.
RecentFile
(path, parent)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Action representing an individual file in the Recent Files menu.
-
openFile
¶ Used by autodoc_mock_imports.
-
-
class
usdmanager.
Settings
(*args, **kwargs)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Add a method to get bool values from settings, since bool is stored as the str “true” or “false.”
-
boolValue
(key, default=False)[source]¶ Boolean values are saved to settings as the string “true” or “false”. Convert a setting back to a bool, since we don’t have QVariant objects in Qt.py.
Parameters: - key : str
Settings key
Returns: True of the value is “true”; otherwise False. False if the value is undefined.
Rtype: bool
-
-
class
usdmanager.
TabBar
(parent=None)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Customized QTabBar to enable re-ordering of tabs.
-
crossWindowTabMoveRequested
¶ Used by autodoc_mock_imports.
-
currentWindowIndex
()[source]¶ Get the index of the current active window.
Returns: Index of the current active window Rtype: int
-
tabMoveRequested
¶ Used by autodoc_mock_imports.
-
-
class
usdmanager.
TabWidget
(parent=None)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Customized QTabWidget to enable re-ordering of tabs with a custom QTabBar.
-
class
usdmanager.
TextBrowser
(parent=None)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Customized QTextBrowser to override mouse events.
-
copySelectionToClipboard
()[source]¶ Store current selection to the middle mouse selection.
Doing this on selectionChanged signal instead of mouseReleaseEvent causes the following to be output in Qt5: “QXcbClipboard: SelectionRequest too old”
For some reason, this isn’t needed for QTextEdit but is for QTextBrowser?
-
-
class
usdmanager.
TextEdit
(parent=None, tabSpaces=4, useSpaces=True)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
Customized QTextEdit to allow entering spaces with the Tab key.
-
commentOutText
(commentStart='#', commentEnd='')[source]¶ Comment out selected lines.
TODO: For languages that use a different syntax for multi-line comments, use that when multiple lines are selected?
Parameters: - commentStart : str
String used for commenting out lines.
- commentEnd : str
If the comment can be applied to multiple lines, this is the string marking the end of the comment.
-
keyPressEvent
(e)[source]¶ Override the Tab key to insert spaces instead.
Parameters: - e : QtGui.QKeyEvent
Key press event
-
-
class
usdmanager.
UsdMngrWindow
(parent=None, **kwargs)[source]¶ Bases:
sphinx.ext.autodoc.importer._MockObject
File Browser/Text Editor for quick navigation and editing among text-based files that reference other files. Normal links are colored blue (USD Crate files are a different shade of blue). The linked file exists. Links to multiple files are colored yellow. Files may or may not exist. Links that cannot be resolved or confirmed as valid files are colored red.
Ideas (in no particular order):
- Better usdz support (https://graphics.pixar.com/usd/docs/Usdz-File-Format-Specification.html)
- Support nested references on read
- Ability to write and repackage as usdz
- Add a preference for which files to enable teletype for (currently hard-coded to .log and .txt files).
- Plug-ins based on active file type (ABC-specific commands, USD commands, etc.)
- Link matching RegEx based on active file type instead of all using the same rules. Different extensions to search for based on file type, too.
- Cache converted crate files or previously read in files?
- Add customized print options like name of file and date headers, similar to printing a web page.
- Move setSource link parsing to a thread?
- Move file status to a thread?
- From Pixar: There’s one feature in a tool our sim dept wrote that might be useful to incorporate into your browser, which can help immensely for big files, and it’s to basically allow filtering of what gets displayed for the usd file’s contents. Not just like pattern matching so only certain prims/properties get shown (though that is also useful), but things like “don’t show timeSamples” or “only show first and last values for each array with an ellipsis in the middle”.
- Dark theme syntax highlighting could use work. The bare minimum to get this working was done.
- Going from Edit mode back to Browse mode shouldn’t reload the document if the file on disk hasn’t changed. Not sure why this is slower than just loading the browse tab in the first place…
- More detailed history that persists between sessions.
- Cross-platform testing:
- Windows mostly untested.
- Mac could use more testing and work with icons and theme.
- Remember scroll position per file so going back in history jumps you to approximately where you were before.
- Missing file links should allow you to easily create the file.
- When opening a * file path, don’t open file browser dialog if encountering files + directories in the glob
Known issues:
- AddressBar file completer has problems occasionally.
- Figure out why network printers aren’t showing up. Linux or DWA issue? macOS and Windows are fine.
- Qt.py problems:
- PyQt5
- Non-critical messages
- QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-mdsandell’
- QXcbConnection: XCB error: 3 (BadWindow), sequence: 878, resource id: 26166399, major code: 40 (TranslateCoords), minor code: 0
- Non-critical messages
- PySide2
- Preferences dialog doesn’t center on main window, can’t load via loadUiType
- PyQt5
-
addItemToMenu
(path, menu, maxLen=None, start=0, end=None)[source]¶ Add a path to a history menu.
Parameters: - path : str
The full path to add to the history menu.
- menu : QtGui.QMenu
Menu to add history item to.
- maxLen : int
Optional maximum number of history items in the menu.
- start : int
Optional number of actions at the start of the menu to ignore.
- end : int
Optional number of actions at the end of the menu to ignore.
-
changeTab
(tab)[source]¶ Set the current tab to the calling tab.
Parameters: - tab : QtWidgets.QWidget
Tab widget
-
closeTab
(checked=False, index=None)[source]¶ Close the current tab.
Parameters: - checked : bool
For signal only
- index : int | None
Try to close this specific tab instead of where the context menu originated.
Returns: If the tab was closed or not. If the tab needed to be saved, for example, and the user cancelled, this returns False.
Rtype: bool
-
compileLinkRegEx
()[source]¶ Compile regular expression to find links based on the acceptable extensions stored in self.programs.
NOTE: If this RegEx is changed, the syntax highlighting rule needs to be as well.
- TODO: Support different search rules for different file extensions. Since we use the RegEx match groups in
- setSource, each file type might be responsible for building its own HTML representation at that point.
-
connectTabSignals
(tab)[source]¶ Connect signals for a new tab.
Parameters: - tab : TabWidget
Tab widget
-
static
convertTeletype
(t)[source]¶ Convert teletype codes to HTML styles. This method assumes you have already escaped any necessary HTML characters.
Parameters: - t : str
Original text
Returns: String with teletype codes converted to HTML styles.
Rtype: str
-
createHighlighter
(highlighterClass)[source]¶ Create a language-specific master highlighter to be used for any file of that language.
Parameters: - highlighterClass : highlighter.MasterHighlighter
Master highlighter or subclass
Returns: Highlighter instance
Rtype: highlighter.MasterHighlighter
-
currentTabChanged
(idx)[source]¶ Slot called when the current tab has changed.
Parameters: - idx : int
Index of the newly selected tab
-
customTabWidgetContextMenu
(pos)[source]¶ Slot for the right-click context menu for the tab widget.
Parameters: - pos : QtCore.QPoint
Position of the right-click
-
customTextBrowserContextMenu
(pos)[source]¶ Slot for the right-click context menu when in Browse mode.
Parameters: - pos : QtCore.QPoint
Position of the right-click
-
customTextEditorContextMenu
(pos)[source]¶ Slot for the right-click context menu when in Edit mode.
Parameters: - pos : QtCore.QPoint
Position of the right-click
-
diffFile
()[source]¶ Compare current version of file in app to current version on disk. Allows you to make comparisons using a temporary file, without saving your changes.
-
dirtySave
()[source]¶ Present a save dialog for dirty tabs to know if they’re safe to close/reload or not.
Returns: False if Cancel selected. True if Discard selected. True if Save selected (and actually saving). Rtype: bool
-
disconnectTabSignals
(tab)[source]¶ Disconnect signals for a tab.
Parameters: - tab : TabWidget
Tab widget
-
duplicateTab
()[source]¶ Duplicate the tab that was right-clicked. This doesn’t duplicate edit state or any history at the moment.
-
editModeChanged
¶ Used by autodoc_mock_imports.
-
find
(flags=None, startPos=3, loop=True)[source]¶ Find next hit for the search text.
Parameters: - flags
Options for document().find().
- startPos : int
Position from which the search should begin. 0=Start of document 1=End of document 2=Start of selection 3=End of selection (default)
- loop : bool
True lets us loop through the beginning or end of a document if the phrase was not found from the current position. False limits that behavior so that we don’t endlessly loop.
-
find2
(startPos=3, loop=True, findText=None)[source]¶ Find functionality for find/replace dialog.
Parameters: - startPos : int
Position from which the search should begin. 0=Start of document 1=End of document 2=Start of selection 3=End of selection (default)
- loop : bool
True lets us loop through the beginning or end of a document if the phrase was not found from the current position. False limits that behavior so that we don’t endlessly loop.
- findText : str
Text to find.
-
findAndReplace
(findText, replaceText, startPos=0)[source]¶ Replace a single occurrence of a phrase.
Parameters: - findText : str
Text to find
- replaceText : str
Text to replace with
- startPos : int
Position from which the search should begin. 0=Start of document (default) 1=End of document 2=Start of selection 3=End of selection
Returns: Whether or not a match was found.
Rtype: bool
-
getCommentStrings
()[source]¶ Get the language-specific string(s) for a comment.
Returns: Tuple of start str and end str defining a comment. Rtype: tuple
-
getFindText
()[source]¶ Get the text to find.
Returns: The search text from the Find/Replace dialog. Rtype: str
-
static
getPermissionString
(path)[source]¶ Get permissions string for a file’s mode. Qt.py compatibility fix since QFileInfo.permissions isn’t in PySide2.
Parameters: - path : str
File path
Returns: String corresponding to read (r), write (w), and execute (x) permissions for file.
-
getReplaceText
()[source]¶ Get the text to replace the search text with.
Returns: The replace text from the Find/Replace dialog. Rtype: str
-
getSaveAsPath
(path=None)[source]¶ Get a path from the user to save an arbitrary file as.
Parameters: - path : str | None
Path to use for selecting default file extension filter.
Returns: Tuple of the absolute path user wants to save file as (or None if no file was selected or an error occurred) and the file format if explicitly set for USD files (e.g. usda)
Rtype: (str`|None, `int)
-
goToLineNumber
(line=1)[source]¶ Go to the given line number
Parameters: - line : int
Line number to scroll to. Defaults to 1 (top of document).
-
isDarkTheme
()[source]¶ Check if any dark theme is active based on launch preference and the background lightness.
Returns: True if launched with the dark theme preference or the lightness factor of the window background is less than 0.5. The 0.5 threshold to determine if it’s dark is completely arbitrary. Rtype: bool
-
launchProcess
(args, **kwargs)[source]¶ Launch a program with the path str as an argument.
Any additional keyword arguments are passed to the Popen object.
Parameters: - args : list | str
A sequence of program arguments with the program as the first arg. If also passing in shell=True, this should be a single string.
Returns: Returns process ID or None
Rtype: subprocess.Popen | None
-
launchProgramOfChoice
(path=None)[source]¶ Open a file with a program given by the user.
Parameters: - path : str
File to open. If None, use currently open file.
-
moveTab
(fromIndex, toIndex)[source]¶ Rearrange tabs in menu after a drag/drop event. This isn’t moving the tab itself. That’s handled in the TabWidget class.
Parameters: - fromIndex : int
Original tab position
- toIndex : int
New tab position
-
moveTabAcrossWindows
(fromIndex, toIndex, fromWindow, toWindow)[source]¶ Rearrange tabs in menu after a drag/drop event. This isn’t moving the tab itself. That’s handled in the TabWidget class.
Parameters: - fromIndex : int
Original tab position
- toIndex : int
New tab position
-
onBreadcrumbActivated
(path)[source]¶ Slot called when a breadcrumb link (history for the current tab) is selected.
Parameters: - path : str
Breadcrumb path
-
openFileDialog
(path=None)[source]¶ Show the Open File dialog and open any selected files.
Parameters: - path : str | None
File path to pre-select on open
-
openFileDialogToCurrentPath
()[source]¶ Show the Open File dialog and open any selected files, pre-selecting the current file (if any).
-
openRecent
(path)[source]¶ Open an item from the Open Recent menu in a new tab.
Parameters: - path : str
File path
-
openUrl
(checked=False, url=None)[source]¶ Open a URL in a web browser. This method doesn’t do anything if the URL evaluates to False.
Parameters: - checked : bool
For signal only
- url : str
A URL to open. If one is not provided, it defaults to self.appURL.
-
overrideCursor
(**kwds)[source]¶ For use with the “with” keyword, so the override cursor is always restored via a try/finally block, even if the commands in-between fail.
- Example:
- with overrideCursor():
- # do something that may raise an error
-
printPreview
(checked=False)[source]¶ Open a print preview dialog.
Parameters: - checked : bool
For signal only
-
readUsdCrateFile
(fileStr)[source]¶ Read in a USD crate file via usdcat converting a temp file to ASCII.
Parameters: - fileStr : str
USD file path
Returns: ASCII file text
Rtype: bool
-
refreshTab
()[source]¶ Refresh the current tab.
Returns: If the tab was reloaded successfully. Rtype: bool
-
removeTab
(index)[source]¶ Stores as recently closed tab, then closes it.
Parameters: - index : int
Index of tab to remove.
-
replaceAllInOpenFiles
()[source]¶ Iterate through all the writable tabs, finding and replacing the search text.
-
restoreOverrideCursor
()[source]¶ If an override cursor is currently set, restore the previous cursor.
-
restoreTab
(tab)[source]¶ Restore a previously closed tab.
Parameters: - tab : QtWidgets.QWidget
Tab widget
-
saveFile
(filePath, fileFormat=4, _checkUsd=True)[source]¶ Save the current file as the given filePath.
Parameters: - filePath : str
Path to save file as.
- fileFormat : int
File format when saving as a generic extension
- _checkUsd : bool
Check if this needs to be written as a binary USD file instead of a text file
Returns: If saved or not.
Rtype: bool
-
saveFileAs
()[source]¶ Save the current file with a new filename.
Returns: If saved or not. Rtype: bool
-
saveLinkAs
()[source]¶ The user right-clicked a link and wants to save it as a new file. Get a new file path with the Save As dialog and copy the original file to the new file, opening the new file in a new tab.
-
saveTab
()[source]¶ If the file already has a name, save it; otherwise, get a filename and save it.
Returns: If saved or not. Rtype: bool
-
setDirtyTab
(dirty=True)[source]¶ Set the dirty state of the current tab.
Parameters: - dirty : bool
If the current tab is dirty.
-
setHighlighter
(ext=None)[source]¶ Set the current tab’s highlighter based on the current file extension.
Parameters: - ext : str | None
File extension (language) to highlight.
-
setIncludePanelActionState
(pos=0, index=0)[source]¶ Set the check state of the include panel action. If it is visible, the action will be checked.
Parameters: - pos : int
Position from left edge of widget. For catching signal only.
- index : int
Splitter handle index. For catching signal only.
-
setOverrideCursor
(cursor=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶ Set the override cursor if it is not already set.
Parameters: - cursor
Qt cursor
-
setSource
(link, isNewFile=True, newTab=False, hScrollPos=0, vScrollPos=0)[source]¶ Create a new tab or update the current one. Process a file to add links. Send the formatted text to the appropriate tab.
Parameters: - link : QtCore.QUrl
File to open.
- isNewFile : bool
Optional bool for if this is a new file or an item from history.
- newTab : bool
Optional bool to open in a new tab no matter what.
- hScrollPos : int
Horizontal scroll bar position.
- vScrollPos : int
Vertical scroll bar position.
Returns: True if the file was loaded successfully (or was dirty but the user cancelled the save prompt).
Rtype: bool
-
setSourceFinish
(success=True, warning=None, details=None)[source]¶ Finish updating UI after loading a new source.
Parameters: - success : bool
If the file was loaded successfully or not
- warning : str | None
Optional warning message
- details : str | None
Optional details for the warning message
Returns: Success
Rtype: bool
-
setSources
(files)[source]¶ Open multiple files in new tabs.
Parameters: - files : list
List of string-based paths to open
-
setupUi
()[source]¶ Create and lay out the widgets defined in the ui file, then add additional modifications to the UI.
-
showAboutDialog
(*args)[source]¶ Display a modal dialog box that shows the “about” information for the application.
-
showCriticalMessage
(message, details=None, title=None)[source]¶ Show an error message with optional details text (useful for tracebacks).
Parameters: - message : str
Main message
- details : str | None
Optional details
- title : str
Dialog title (defaults to app name)
Returns: Selected StandardButton value
Rtype: int
-
showSuccessMessage
(msg, title=None)[source]¶ Display a generic message if the user’s preferences are not set to only show warnings/errors.
Parameters: - msg : str
Message to display.
- title : str | None
Optional title.
-
showWarningMessage
(message, details=None, title=None, icon=<sphinx.ext.autodoc.importer._MockObject object>)[source]¶ Show a warning message with optional details text (useful for tracebacks).
Parameters: - message : str
Main message
- details : str | None
Optional details
- title : str
Dialog title (defaults to app name)
- icon : int
QMessageBox.Icon
Returns: Selected StandardButton value
Rtype: int
-
toggleEdit
()[source]¶ Switch between Browse mode and Edit mode.
Returns: True if we switched modes; otherwise, False. This only returns False if we were in Edit mode and the user cancelled due to unsaved changes. Rtype: bool
-
toggleInclude
(checked)[source]¶ Show/Hide the side file browser.
Parameters: - checked : bool
State of checked menu.
-
updatePreference_findMatchCase
(checked)[source]¶ Stores a bool representation of checkbox’s state.
Parameters: - checked : int
State of checkbox.
-
updatingButtons
¶ Used by autodoc_mock_imports.
-
validateAddressBar
(address)[source]¶ Validate the text in the address bar. Currently, this just ensures the address is not an empty string.
Parameters: - address : str
Current text in the address bar.
-
validateFileSize
(path)[source]¶ If a file’s size is above a certain threshold, confirm the user still wants to open the file.
Parameters: - path : str
File path
Returns: If we should open the file or not
Rtype: bool
-
validateFindBar
(text)[source]¶ Update widgets on the Find bar as the search text changes.
Parameters: - text : str
Current text in the find bar.
- Better usdz support (https://graphics.pixar.com/usd/docs/Usdz-File-Format-Specification.html)