Skip to content

Commit

Permalink
Use autodetection for encodings on open statements.
Browse files Browse the repository at this point in the history
  • Loading branch information
nomike committed Sep 18, 2024
1 parent cc8f1ca commit 43ef423
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions templatehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# pylint: disable=unused-import
import urllib
from datetime import datetime, timezone, tzinfo
import locale

# pylint: disable=unused-import
import markdown
Expand All @@ -29,7 +30,7 @@
# pylint: disable=invalid-name
config = None

with open("../config.yaml", encoding='utf-8') as file:
with open("../config.yaml", encoding=locale.getencoding()) as file:
config = yaml.load(file, Loader=yaml.SafeLoader)


Expand Down Expand Up @@ -81,7 +82,7 @@ def listdir(path):
"""
ignorelist = ['index', 'index.md', '*.scmsfasicon', '*.scmstarget']
if os.path.exists(os.path.join(pathprefix, path, '.scmsignore')):
with open(os.path.join(pathprefix, path, '.scmsignore'), encoding='utf-8') as scsmignore:
with open(os.path.join(pathprefix, path, '.scmsignore'), encoding=locale.getencoding()) as scsmignore:
ignorelist.extend([line.strip('\n') for line in scsmignore.readlines()])
dirlist = [
os.path.basename(f)
Expand Down Expand Up @@ -112,15 +113,15 @@ def listchildren(path):
"""
ignorelist = ['index', 'index.md', '*.scmsfasicon', '*.scmstarget']
if os.path.exists(os.path.join(pathprefix, path, '.scmsignore')):
with open(os.path.join(pathprefix, path, '.scmsignore'), encoding='utf-8') as scmsignore:
with open(os.path.join(pathprefix, path, '.scmsignore'), encoding=locale.getencoding()) as scmsignore:
ignorelist.extend([line.strip('\n') for line in scmsignore.readlines()])
dirlist = [
[os.path.basename(f), os.path.basename(f)]
for f in os.listdir(os.path.join(pathprefix, path))
if regex.match('^(?!\\.).*(?<!~)$', f) and not f in ignorelist
]
if os.path.exists(os.path.join(pathprefix, path, '.scmslinks')):
with open(os.path.join(pathprefix, path, '.scmslinks'), encoding='utf-8') as scmslinks:
with open(os.path.join(pathprefix, path, '.scmslinks'), encoding=locale.getencoding()) as scmslinks:
additional_links = json.load(scmslinks)
dirlist.extend(additional_links)
removeitems = []
Expand Down

0 comments on commit 43ef423

Please sign in to comment.