Turn it into a CLI app for easier initial implementation
This commit is contained in:
		
							
								
								
									
										33
									
								
								badwitch.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								badwitch.py
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
#! /usr/bin/env python3
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
# vim:fenc=utf-8:ft=python
 | 
			
		||||
#
 | 
			
		||||
# Bad Witch
 | 
			
		||||
# Copyright © 2020 Vintage Salt <rehashedsalt@cock.li>
 | 
			
		||||
#
 | 
			
		||||
# Distributed under terms of the MIT license.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
import argparse
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
class BadWitch:
 | 
			
		||||
    def __init__(self):
 | 
			
		||||
        # Set up arguments
 | 
			
		||||
        self.argparser = argparse.ArgumentParser(description='Manage a declarative music library through YouTube scraping')
 | 
			
		||||
        self.argparser.add_argument('-c', '--config', metavar='c', nargs=1,
 | 
			
		||||
                help='Override default configuration file with this one')
 | 
			
		||||
        self.argparser.add_argument('-d', '--download-all', dest='downloadall', action='store_true',
 | 
			
		||||
                help='Download all songs declared in the songs file')
 | 
			
		||||
        self.argparser.add_argument('-v', '--verbose', action='store_true',
 | 
			
		||||
                help='Show more status messages')
 | 
			
		||||
 | 
			
		||||
    def execute(self):
 | 
			
		||||
        self.args = self.argparser.parse_args() 
 | 
			
		||||
        if self.args.verbose:
 | 
			
		||||
            print(self.args.config)
 | 
			
		||||
            print(self.args.downloadall)
 | 
			
		||||
            print(self.args.verbose)
 | 
			
		||||
 | 
			
		||||
badwitch = BadWitch()
 | 
			
		||||
badwitch.execute()
 | 
			
		||||
							
								
								
									
										43
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								main.py
									
									
									
									
									
								
							@@ -1,43 +0,0 @@
 | 
			
		||||
#! /usr/bin/env python3
 | 
			
		||||
# -*- coding: utf-8 -*-
 | 
			
		||||
# vim:fenc=utf-8
 | 
			
		||||
#
 | 
			
		||||
# Bad Witch
 | 
			
		||||
# Copyright © 2020 Vintage Salt <rehashedsalt@cock.li>
 | 
			
		||||
#
 | 
			
		||||
# Distributed under terms of the MIT license.
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
import PyQt5.QtGui as qtg
 | 
			
		||||
import PyQt5.QtWidgets as qtw
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
class BadWitch:
 | 
			
		||||
    def __init__(self, Argv):
 | 
			
		||||
        # Initialize UI
 | 
			
		||||
        self.app = qtw.QApplication(Argv)
 | 
			
		||||
        self.main_window = qtw.QMainWindow()
 | 
			
		||||
        # Initialize a UI helper
 | 
			
		||||
        self.ui = Ui_MainHelper()
 | 
			
		||||
        # Build the application
 | 
			
		||||
        self.ui.create_actions(self.app, self.main_window)
 | 
			
		||||
        self.ui.create_menus(self.app, self.main_window)
 | 
			
		||||
        self.ui.build_mainwindow(self.app, self.main_window)
 | 
			
		||||
    def show_application(self):
 | 
			
		||||
        self.main_window.show()
 | 
			
		||||
        self.app.exec_()
 | 
			
		||||
 | 
			
		||||
class Ui_MainHelper:
 | 
			
		||||
    def create_actions(self, App, MainWindow):
 | 
			
		||||
        self.action_exit = qtw.QAction(qtg.QIcon.fromTheme("application-exit"), "Quit")
 | 
			
		||||
        self.action_exit.triggered.connect(App.closeAllWindows)
 | 
			
		||||
    def create_menus(self, App, MainWindow):
 | 
			
		||||
        self.menu_file = qtw.QMenu("File")
 | 
			
		||||
    def build_mainwindow(self, App, MainWindow):
 | 
			
		||||
        self.menu_file.addAction(self.action_exit)
 | 
			
		||||
        MainWindow.menuBar().addMenu(self.menu_file)
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
    bw = BadWitch(sys.argv)
 | 
			
		||||
    bw.show_application()
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user