-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from fyndata/develop
Release 0.7.0
- Loading branch information
Showing
23 changed files
with
2,208 additions
and
418 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
[bumpversion] | ||
current_version = 0.6.5 | ||
current_version = 0.7.0 | ||
commit = True | ||
tag = True | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ | |
""" | ||
|
||
|
||
__version__ = '0.6.5' | ||
__version__ = '0.7.0' |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
""" | ||
Base / constants | ||
================ | ||
""" | ||
import pytz | ||
|
||
from cl_sii.libs.tz_utils import PytzTimezone | ||
|
||
|
||
TZ_CL_SANTIAGO: PytzTimezone = pytz.timezone('America/Santiago') | ||
|
||
SII_OFFICIAL_TZ = TZ_CL_SANTIAGO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import codecs | ||
import io | ||
from typing import IO | ||
|
||
|
||
# notes: | ||
# - For streams and modes see 'io.open()' | ||
# - Stream classes have a pretty strange 'typing'/ABC/inheritance/etc arrangement because, | ||
# among others, they are implemented in C. | ||
# - Use `IO[X]` for arguments and `TextIO`/`BinaryIO` for return types (says GVR). | ||
# https://github.com/python/typing/issues/518#issuecomment-350903120 | ||
|
||
|
||
def with_mode_binary(stream: IO) -> bool: | ||
""" | ||
Return whether ``stream`` is a binary stream (i.e. reads bytes). | ||
""" | ||
result = False | ||
try: | ||
result = 'b' in stream.mode | ||
except AttributeError: | ||
if isinstance(stream, (io.RawIOBase, io.BufferedIOBase, io.BytesIO)): | ||
result = True | ||
|
||
return result | ||
|
||
|
||
def with_mode_text(stream: IO) -> bool: | ||
""" | ||
Return whether ``stream`` is a text stream (i.e. reads strings). | ||
""" | ||
result = False | ||
try: | ||
result = 't' in stream.mode | ||
except AttributeError: | ||
if isinstance(stream, (io.TextIOBase, io.TextIOWrapper, io.StringIO)): | ||
result = True | ||
|
||
return result | ||
|
||
|
||
def with_encoding_utf8(text_stream: IO[str]) -> bool: | ||
""" | ||
Return whether ``text_stream`` is a text stream with encoding set to UTF-8. | ||
:raises TypeError: if ``text_stream`` is not a text stream | ||
""" | ||
result = False | ||
|
||
if isinstance(text_stream, io.StringIO): | ||
# note: 'StringIO' saves (unicode) strings in memory and therefore doesn't have (or need) | ||
# an encoding, which is fine. | ||
# https://stackoverflow.com/questions/9368865/io-stringio-encoding-in-python3/9368909#9368909 | ||
result = True | ||
else: | ||
try: | ||
text_stream_encoding: str = text_stream.encoding # type: ignore | ||
except AttributeError as exc: | ||
raise TypeError("Value is not a text stream.") from exc | ||
if text_stream_encoding is None: | ||
# e.g. the strange case of `tempfile.SpooledTemporaryFile(mode='rt', encoding='utf-8')` | ||
pass | ||
else: | ||
try: | ||
text_stream_encoding_norm = codecs.lookup(text_stream_encoding).name | ||
result = text_stream_encoding_norm == 'utf-8' | ||
except LookupError: | ||
pass | ||
|
||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.