*: pylint: Explicitly specify encoding when open a file

This is recommended by PEP-0597: https://peps.python.org/pep-0597/

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2022-07-04 19:45:57 -04:00
1 parent 05815bc992
commit 3c7bc4a192
49 files changed
+165 -138

No files matched your search

+6 -2
View File
@@ -4,6 +4,7 @@ FreedomBox app for configuring date and time.
"""
import logging
import pathlib
from django.contrib import messages
from django.utils.translation import gettext as _
@@ -17,6 +18,7 @@ logger = logging.getLogger(__name__)
class DateTimeAppView(AppView):
"""Serve configuration page."""
form_class = DateTimeForm
app_id = 'datetime'
@@ -25,9 +27,11 @@ class DateTimeAppView(AppView):
status['time_zone'] = self.get_current_time_zone()
return status
def get_current_time_zone(self):
@staticmethod
def get_current_time_zone():
"""Get current time zone."""
time_zone = open('/etc/timezone').read().rstrip()
path = pathlib.Path('/etc/timezone')
time_zone = path.read_text(encoding='utf-8').rstip()
return time_zone or 'none'
def form_valid(self, form):