def main(): """ Main method of the cursor maker program. Parses the first flag and figures out what to do based on it... """ args = sys.argv[1:] if (len(args) == 0): # No arguments, launch the gui if possible if (launch_gui is not None): launch_gui(None) else: print( "Unable to import and run gui, check if PySide2 is installed..." ) print_help() return # --help, print the help info... if (args[0] == "--help"): print_help() # --open, grab next argument, and attempt to have gui open it... elif (args[0] == "--open"): if (len(args) > 1): if (launch_gui is not None): launch_gui(args[1]) else: print( "Unable to import and run gui, check if PySide2 is installed..." ) else: print("No file provided...") launch_gui(None) # --build, load in the project file and build the theme in place using utils api... elif (args[0] == "--build"): for config_file in args[1:]: try: config_path = Path(config_file).resolve() metadata, fc_data = theme_util.load_project(config_path) fc_data = { name: cursor for name, (cur_path, cursor) in fc_data.items() } theme_util.build_theme(config_path.parent.name, config_path.parent.parent, metadata, fc_data) except Exception as e: print(e) raise e print("Build Successful!") else: # Rogue arguments or flags passed, just print help... print_help()
def build_project(self): dir_picker = DirectoryPicker(self, "Select Directory to Build Project In") dir_picker.exec_() directory_info = dir_picker.get_results() if directory_info is not None: theme_name, theme_dir = directory_info cursors = {} for cursor_name, selector in self._cursor_selectors.items(): if selector.current_cursor is not None: cursors[cursor_name] = selector.current_cursor theme_util.build_theme(theme_name, theme_dir, self._metadata, cursors)
def build_in_place(self): if self._open_build_project is None: return project_folder = Path(self._open_build_project).parent theme_name, dir_path = project_folder.name, project_folder.parent cursors = {} for cursor_name, selector in self._cursor_selectors.items(): if selector.current_cursor is not None: cursors[cursor_name] = selector.current_cursor theme_util.build_theme(theme_name, dir_path, self._metadata, cursors) QtWidgets.QMessageBox.information( self, "Cursor Theme Maker", f"Project '{self._open_build_project}' Built!!!")