├── .gitignore ├── LICENSE.txt ├── README.md ├── hard_reload.py └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | ############# 2 | ## Windows detritus 3 | ############# 4 | 5 | # Windows image file caches 6 | Thumbs.db 7 | ehthumbs.db 8 | 9 | # Folder config file 10 | Desktop.ini 11 | 12 | # Recycle Bin used on file shares 13 | $RECYCLE.BIN/ 14 | 15 | # Mac crap 16 | .DS_Store 17 | 18 | 19 | ############# 20 | ## Python 21 | ############# 22 | 23 | *.py[co] 24 | 25 | # Packages 26 | *.egg 27 | *.egg-info 28 | dist/ 29 | build/ 30 | eggs/ 31 | parts/ 32 | var/ 33 | sdist/ 34 | develop-eggs/ 35 | .installed.cfg 36 | 37 | # Installer logs 38 | pip-log.txt 39 | 40 | # Unit test / coverage reports 41 | .coverage 42 | .tox 43 | 44 | #Translations 45 | *.mo 46 | 47 | # custom 48 | .ropeproject/ 49 | venv/ 50 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Cesar Saez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Hard_Reload 2 | =========== 3 | 4 | `hard_reload` is a Maya Qt widget for reloading python packages, useful for develoment! 5 | Type in the module name you want to reload, and press enter. 6 | 7 | ![image](https://github.com/csaez/hard_reload/assets/3758308/f9c244e9-3f9e-4b59-994f-1fd35a62a128) 8 | 9 | 10 | Installation 11 | ------------ 12 | 13 | Copy or symlink `hard_reload.py` to your maya/scripts directory __or__ clone 14 | this repo and install the package by typing in a terminal: 15 | 16 | ```bash 17 | python setup.py install 18 | ``` 19 | 20 | > Last method might require root access 21 | 22 | Usage 23 | ----- 24 | 25 | Once installed you can launch `hard_reload` by typing: 26 | 27 | ```python 28 | import hard_reload 29 | hard_reload.show() 30 | ``` 31 | -------------------------------------------------------------------------------- /hard_reload.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | 4 | try: 5 | from PySide6 import QtGui, QtCore, QtWidgets 6 | except ImportError: 7 | try: 8 | from PySide2 import QtGui, QtCore, QtWidgets 9 | except ImportError: 10 | from PySide import QtGui, QtCore 11 | QtWidgets = QtGui 12 | 13 | 14 | class HardReload(QtWidgets.QDialog): 15 | 16 | def __init__(self, parent=None): 17 | super(HardReload, self).__init__(parent) 18 | self.setWindowTitle("Hard Reload") 19 | 20 | self.ui_lineEdit = QtWidgets.QLineEdit(self) 21 | ui_completer = QtWidgets.QCompleter( 22 | [i.split(".")[0] for i in sys.modules.keys()], self) 23 | ui_completer.setCompletionMode(QtWidgets.QCompleter.InlineCompletion) 24 | ui_completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) 25 | self.ui_lineEdit.setCompleter(ui_completer) 26 | 27 | hbox = QtWidgets.QHBoxLayout() 28 | hbox.addWidget(self.ui_lineEdit) 29 | self.setLayout(hbox) 30 | 31 | self.ui_lineEdit.returnPressed.connect(self.accept) 32 | 33 | def move_window(self, pos=None): 34 | pos = pos or QtGui.QCursor.pos() 35 | self.move(pos.x(), pos.y()) 36 | 37 | def accept(self, *args, **kwds): 38 | module_name = str(self.ui_lineEdit.text()) 39 | if len(module_name): 40 | hard_reload(module_name) 41 | super(HardReload, self).close(*args, **kwds) 42 | 43 | 44 | def get_parent(): 45 | parent = QtWidgets.QApplication.activeWindow() 46 | if parent: 47 | _ = parent.parent() 48 | while _: 49 | parent = _ 50 | _ = parent.parent() 51 | return parent 52 | 53 | 54 | def hard_reload(module_name): 55 | for k in sys.modules.keys(): 56 | if k.startswith(module_name): 57 | del sys.modules[k] 58 | 59 | 60 | def show(): 61 | w = HardReload(get_parent()) 62 | w.move_window() 63 | w.exec_() 64 | 65 | 66 | def __main__(): 67 | QtWidgets.QApplication(sys.argv) 68 | show() 69 | sys.exit() 70 | 71 | 72 | if __name__ == "__main__": 73 | __main__() 74 | 75 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | # Copyright (c) 2015 Cesar Saez 4 | 5 | # Permission is hereby granted, free of charge, to any person obtaining a copy 6 | # of this software and associated documentation files (the "Software"), to deal 7 | # in the Software without restriction, including without limitation the rights 8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | # copies of the Software, and to permit persons to whom the Software is 10 | # furnished to do so, subject to the following conditions: 11 | 12 | # The above copyright notice and this permission notice shall be included in 13 | # all copies or substantial portions of the Software. 14 | 15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | # THE SOFTWARE. 22 | 23 | from setuptools import setup 24 | 25 | setup( 26 | name="hard_reload", 27 | version="0.3.0", 28 | author="Cesar Saez", 29 | author_email="hi@cesarsaaez.me", 30 | description="Simple GUI to flush selected python modules in memory.", 31 | url="http://github.com/csaez/hard_reload", 32 | license="The MIT License", 33 | py_modules=["hard_reload"], 34 | ) 35 | --------------------------------------------------------------------------------