Ver código fonte

add colorama init to all __main__ + remove useless main() funcs

Noah Vogt 1 ano atrás
pai
commit
6a3411451a

+ 3 - 0
burn_cds_of_today.py

@@ -15,8 +15,11 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import colorama
+
 from utils import get_yyyy_mm_dd_date
 from recording import burn_cds_of_day
 
 if __name__ == "__main__":
+    colorama.init()
     burn_cds_of_day(get_yyyy_mm_dd_date())

+ 2 - 0
choose_cd_dialog.py

@@ -15,6 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import colorama
 from PyQt5.QtWidgets import (  # pylint: disable=no-name-in-module
     QMessageBox,
 )
@@ -36,5 +37,6 @@ def choose_and_burn_cd():
 
 
 if __name__ == "__main__":
+    colorama.init()
     validate_cd_record_config()
     choose_and_burn_cd()

+ 2 - 0
choose_sermon_dialog.py

@@ -15,6 +15,7 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import colorama
 from PyQt5.QtWidgets import (  # pylint: disable=no-name-in-module
     QMessageBox,
 )
@@ -36,5 +37,6 @@ def choose_and_upload_sermon():
 
 
 if __name__ == "__main__":
+    colorama.init()
     validate_sermon_upload_config()
     choose_and_upload_sermon()

+ 3 - 0
force_song.py

@@ -17,6 +17,8 @@
 
 from sys import argv
 
+import colorama
+
 from utils import (
     error_msg,
     make_sure_file_exists,
@@ -43,6 +45,7 @@ def exit_if_force_int_is_illegal():
 
 
 if __name__ == "__main__":
+    colorama.init()
     validate_obs_song_scene_switcher_config()
     make_sure_file_exists(const.NEXTSONG_CACHE_FILE)
     exit_if_force_int_is_illegal()

+ 3 - 0
next_song.py

@@ -15,6 +15,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import colorama
+
 from song_switcher import (
     SongDirection,
     cycle_to_song_direction,
@@ -24,6 +26,7 @@ from input import validate_obs_song_scene_switcher_config
 import config as const
 
 if __name__ == "__main__":
+    colorama.init()
     validate_obs_song_scene_switcher_config()
     make_sure_file_exists(const.NEXTSONG_CACHE_FILE)
     cycle_to_song_direction(SongDirection.NEXT)

+ 3 - 0
previous_song.py

@@ -15,6 +15,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import colorama
+
 from song_switcher import (
     SongDirection,
     cycle_to_song_direction,
@@ -24,6 +26,7 @@ from input import validate_obs_song_scene_switcher_config
 import config as const
 
 if __name__ == "__main__":
+    colorama.init()
     validate_obs_song_scene_switcher_config()
     make_sure_file_exists(const.NEXTSONG_CACHE_FILE)
     cycle_to_song_direction(SongDirection.PREVIOUS)

+ 4 - 5
set_cd_marker.py

@@ -20,6 +20,8 @@ from shlex import split
 from subprocess import Popen
 from re import match
 
+import colorama
+
 from utils import (
     get_yyyy_mm_dd_date,
     make_sure_file_exists,
@@ -264,11 +266,8 @@ def set_cd_marker() -> None:
         start_cd_recording()
 
 
-def main() -> None:
+if __name__ == "__main__":
+    colorama.init()
     validate_cd_record_config()
     make_sure_file_exists(const.CD_RECORD_CACHEFILE)
     set_cd_marker()
-
-
-if __name__ == "__main__":
-    main()

+ 1 - 5
slidegen.py

@@ -76,7 +76,7 @@ class Slidegen:
         )
 
 
-def main() -> None:
+if __name__ == "__main__":
     colorama.init()
 
     classic_slide_style = SlideStyle(
@@ -86,7 +86,3 @@ def main() -> None:
     )
     slidegen = Slidegen(classic_slide_style, *parse_slidegen_argv_as_tuple())
     slidegen.execute()
-
-
-if __name__ == "__main__":
-    main()

+ 1 - 5
ssync.py

@@ -42,7 +42,7 @@ def ssync(ssync_flags: SsyncFlags, slide_style: SlideStyle) -> None:
     slide_selection_iterator(ssync_flags.disable_async_enabled, slide_style)
 
 
-def main() -> None:
+if __name__ == "__main__":
     colorama.init()
 
     classic_slide_style = SlideStyle(
@@ -53,7 +53,3 @@ def main() -> None:
     ssync_flags = SsyncFlags(*parse_ssync_args_as_tuple())
 
     ssync(ssync_flags, classic_slide_style)
-
-
-if __name__ == "__main__":
-    main()

+ 4 - 5
stop_cd_recording.py

@@ -19,6 +19,8 @@ from os import kill
 from signal import SIGTERM
 from time import sleep
 
+import colorama
+
 from utils import (
     get_yyyy_mm_dd_date,
     make_sure_file_exists,
@@ -55,11 +57,8 @@ def stop_cd_recording() -> None:
         error_msg("CD Record Checkfile is invalid.")
 
 
-def main() -> None:
+if __name__ == "__main__":
+    colorama.init()
     validate_cd_record_config()
     make_sure_file_exists(const.CD_RECORD_CACHEFILE)
     stop_cd_recording()
-
-
-if __name__ == "__main__":
-    main()

+ 3 - 0
upload_sermon_of_today.py

@@ -15,6 +15,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import colorama
+
 from utils import (
     get_yyyy_mm_dd_date,
 )
@@ -28,6 +30,7 @@ from input import (
 
 
 if __name__ == "__main__":
+    colorama.init()
     validate_sermon_upload_config()
     make_sure_there_is_no_ongoing_cd_recording()
     upload_sermon_for_day(get_yyyy_mm_dd_date())