فهرست منبع

remove dependency + fix BOM input file encoding

Noah Vogt 2 سال پیش
والد
کامیت
7592177ff3
5فایلهای تغییر یافته به همراه8 افزوده شده و 7 حذف شده
  1. 0 1
      README.md
  2. 4 2
      input/parse_file.py
  3. 1 1
      input/slide_selection_iterator.py
  4. 1 1
      sync/syncing_needed.py
  5. 2 2
      utils/songchooser.py

+ 0 - 1
README.md

@@ -306,7 +306,6 @@ First, install a reasonably new version of
 
 - [git](https://git-scm.com/)
 - [fzf](https://github.com/junegunn/fzf)
-- printf (Provided by coreutils. Windows user should download gnuwin32.)
 - [imagemagick](https://imagemagick.org/script/download.php) (If you are a windows user, select the c/c++ developer headers. Also you may need vcredist for imagemagick to work.)
 - [python3](https://www.python.org/)
 - some python packages that are not in the standard library using:

+ 4 - 2
input/parse_file.py

@@ -30,7 +30,9 @@ import config as const
 def parse_metadata(slidegen) -> None:
     metadata_dict = dict.fromkeys(const.METADATA_STRINGS)
     try:
-        with open(slidegen.song_file_path, mode="r", encoding="utf8") as opener:
+        with open(
+            slidegen.song_file_path, mode="r", encoding="utf-8-sig"
+        ) as opener:
             content = opener.readlines()
     except IOError:
         error_msg(
@@ -91,7 +93,7 @@ def parse_songtext(slidegen) -> None:
 def get_songchooser_cachefile_content() -> list:
     try:
         with open(
-            const.NEXTSONG_CACHE_FILE, mode="r", encoding="utf8"
+            const.NEXTSONG_CACHE_FILE, mode="r", encoding="utf-8-sig"
         ) as cachefile_reader:
             cachefile_content = cachefile_reader.readlines()
     except (FileNotFoundError, PermissionError, IOError) as error:

+ 1 - 1
input/slide_selection_iterator.py

@@ -175,7 +175,7 @@ def create_and_get_dest_dir(obs_slides_dir, index) -> str:
 def read_chosen_song_file() -> str:
     with open(
         os.path.join(const.SSYNC_CACHE_DIR, const.SSYNC_CHOSEN_FILE_NAMING),
-        encoding="utf-8",
+        encoding="utf-8-sig",
         mode="r",
     ) as tempfile_file_opener:
         chosen_song_file = tempfile_file_opener.read()[:-1].strip()

+ 1 - 1
sync/syncing_needed.py

@@ -44,7 +44,7 @@ def syncing_needed(offline_flag_enabled: bool) -> bool:
     with open(
         os.path.join(const.SSYNC_CACHE_DIR, const.SSYNC_CACHEFILE_NAMING),
         mode="r",
-        encoding="utf-8",
+        encoding="utf-8-sig",
     ) as cachefile_reader:
         cachefile_content = cachefile_reader.readlines()
     for line in cachefile_content:

+ 2 - 2
utils/songchooser.py

@@ -28,7 +28,7 @@ def make_sure_cachefile_exists() -> None:
     if not path.isfile(const.NEXTSONG_CACHE_FILE):
         try:
             with open(
-                const.NEXTSONG_CACHE_FILE, mode="w+", encoding="utf8"
+                const.NEXTSONG_CACHE_FILE, mode="w+", encoding="utf-8-sig"
             ) as file_creator:
                 file_creator.write("")
         except (FileNotFoundError, PermissionError, IOError) as error:
@@ -65,7 +65,7 @@ def create_cachfile_for_song(song) -> None:
     log("writing song {} to cachefile...".format(song))
     try:
         with open(
-            const.NEXTSONG_CACHE_FILE, mode="w", encoding="utf8"
+            const.NEXTSONG_CACHE_FILE, mode="w", encoding="utf-8-sig"
         ) as file_writer:
             file_writer.write(calculate_yyyy_mm_dd_date() + "\n")
             file_writer.write(str(song) + "\n")