diff options
author | emkael <emkael@tlen.pl> | 2024-02-13 01:26:08 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2024-02-13 01:26:08 +0100 |
commit | 3c44a072bd3833c34fa6c15553cce0594247aa9d (patch) | |
tree | 9c18a0bc9d0f65d25163d0912d7d05eda9941b31 /squaredeal | |
parent | 9e487aae490aca64f89634ad608729e4094d8847 (diff) |
Input file encoding option back functioning
Diffstat (limited to 'squaredeal')
-rw-r--r-- | squaredeal/__init__.py | 15 | ||||
-rw-r--r-- | squaredeal/sqd.py | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/squaredeal/__init__.py b/squaredeal/__init__.py index ee2b8c2..8ed571f 100644 --- a/squaredeal/__init__.py +++ b/squaredeal/__init__.py @@ -44,10 +44,11 @@ class SquareDeal(object): BIGDEALX_PATH = None - def __init__(self, sqd_file, sqk_file=None): + def __init__(self, sqd_file, sqk_file=None, encoding=None): self.sqd = SQD() self.sqd_file = sqd_file self.sqk_file = sqk_file + self.sqd_encoding = encoding def create(self, event_name=None, delayed_information=None, overwrite=False, **kwargs): self.sqd.name = event_name @@ -59,7 +60,7 @@ class SquareDeal(object): self.sqd.tofile(self.sqd_file) def set_name(self, event_name, **kwargs): - self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file) + self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file, encoding=self.sqd_encoding) if self.sqd.published: raise SquareDealError('Cannot change name: event already published') @@ -69,7 +70,7 @@ class SquareDeal(object): self.sqd.tofile(self.sqd_file) def set_di(self, delayed_information, **kwargs): - self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file) + self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file, encoding=self.sqd_encoding) if self.sqd.published: raise SquareDealError('Cannot change delayed information description: event already published') @@ -79,7 +80,7 @@ class SquareDeal(object): self.sqd.tofile(self.sqd_file) def add_phase(self, sessions, boards, prefix, description='', **kwargs): - self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file) + self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file, encoding=self.sqd_encoding) if self.sqd.published: raise SquareDealError('Cannot add phase: event already published') @@ -94,7 +95,7 @@ class SquareDeal(object): self.sqd.tofile(self.sqd_file) def publish(self, **kwargs): - self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file) + self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file, encoding=self.sqd_encoding) if self.sqd.published: raise SquareDealError('Cannot mark as published: event already published') @@ -112,7 +113,7 @@ class SquareDeal(object): self.sqd.tofile(self.sqd_file, sqkpath=self.sqk_file) def set_dv(self, delayed_information, **kwargs): - self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file) + self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file, encoding=self.sqd_encoding) if not self.sqd.published: raise SquareDealError('Cannot set delayed information value: event not published') @@ -125,7 +126,7 @@ class SquareDeal(object): if not SquareDeal.BIGDEALX_PATH: raise SquareDealError('Path to BigDeal is not set, initialize SquareDeal.BIGDEALX_PATH value') - self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file) + self.sqd.fromfile(self.sqd_file, sqkpath=self.sqk_file, encoding=self.sqd_encoding) if not self.sqd.published: raise SquareDealError('Cannot generate PBN files: event info is not marked as published') diff --git a/squaredeal/sqd.py b/squaredeal/sqd.py index 3de3f34..60ef4a3 100644 --- a/squaredeal/sqd.py +++ b/squaredeal/sqd.py @@ -68,7 +68,9 @@ class SQD(object): self.published = False self.sqd_path = None - def fromfile(self, sqdpath, sqkpath=None, encoding='utf-8'): + def fromfile(self, sqdpath, sqkpath=None, encoding=None): + if not encoding: + encoding = 'utf-8' with open(sqdpath, encoding=encoding) as sqdfile: contents = [line.strip() for line in sqdfile.readlines()] self._init_values() |