diff options
| author | tassaron | 2022-04-28 19:48:01 -0400 |
|---|---|---|
| committer | tassaron | 2022-04-28 19:48:01 -0400 |
| commit | a4dff0b3e0aa817822c1a490a423192a8cbf97eb (patch) | |
| tree | 403f432cb5915e3cb6a2fb6cf53c8aae4aecf32a /src | |
| parent | 1fda5fbe8121f15f7a6e13ddedefb0cf07ae5d48 (diff) | |
remove punctuation from project names at commandline
stop someone shooting themself in the foot by doing `avp /?` on Windows
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/main.py b/src/main.py index 39fa997..ec4b8bc 100644 --- a/src/main.py +++ b/src/main.py @@ -2,6 +2,8 @@ from PyQt5 import uic, QtWidgets import sys import os import logging +import re +import string from .__init__ import wd @@ -10,11 +12,8 @@ log = logging.getLogger('AVP.Main') def main(): - app = QtWidgets.QApplication(sys.argv) - app.setApplicationName("audio-visualizer") + # Determine primary mode proj = None - - # Determine mode mode = 'GUI' if len(sys.argv) > 2: mode = 'commandline' @@ -22,9 +21,14 @@ def main(): if sys.argv[1].startswith('-'): mode = 'commandline' else: + # remove unsafe punctuation characters such as \/?*&^%$# + sys.argv[1] = re.sub(f'[{re.escape(string.punctuation)}]', '', sys.argv[1]) # opening a project file with gui proj = sys.argv[1] + # Create Qt Application + app = QtWidgets.QApplication(sys.argv) + app.setApplicationName("audio-visualizer") # Launch program if mode == 'commandline': from .command import Command @@ -56,5 +60,6 @@ def main(): sys.exit(app.exec_()) + if __name__ == "__main__": main() |
