Skip to content

Commit

Permalink
Fixes tsave function bug (#115)
Browse files Browse the repository at this point in the history
`tsave` function bug in Windows fixed (#113)
  • Loading branch information
sepandhaghighi authored Mar 24, 2020
1 parent 2a0f13e commit 59abb40
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ matrix:
- os: linux
python: 2.7
include:
- os: linux
python: 3.8
dist: xenial
- os: linux
python: 3.7
dist: xenial
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- `mode` parameter added to `font_list` and `art_list` functions
- `decoration` parameter added to `text2art`, `tprint` and `tsave` functions
- `\n` support bug fixed
- `tsave` function bug in Windows fixed
### Removed
- `requirements.txt`
## [4.5] - 2020-01-29
Expand Down
12 changes: 6 additions & 6 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@ build: false

environment:
matrix:
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.2"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python27"
PYTHON_VERSION: "2.7.2"
PYTHON_ARCH: "64"
- PYTHON: "C:\\Python35"
PYTHON_VERSION: "3.5.5"
PYTHON_ARCH: "32"
Expand All @@ -26,6 +20,12 @@ environment:
- PYTHON: "C:\\Python37"
PYTHON_VERSION: "3.7.0"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python38"
PYTHON_VERSION: "3.8.0"
PYTHON_ARCH: "64"
- PYTHON: "C:\\Python38"
PYTHON_VERSION: "3.8.0"
PYTHON_ARCH: "32"
- PYTHON: "C:\\Python34"
PYTHON_VERSION: "3.4.6"
PYTHON_ARCH: "64"
Expand Down
10 changes: 2 additions & 8 deletions art/art.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import os
import sys
import random
import codecs


class artError(Exception): # pragma: no cover
Expand Down Expand Up @@ -278,18 +277,13 @@ def tsave(
index = index + 1
else:
break
file = codecs.open(test_name + extension, "w", encoding='utf-8')
file = open(test_name + extension, "w", encoding='utf-8')
result = text2art(
text,
font=font,
decoration=decoration,
chr_ignore=chr_ignore)
try:
file.write(result)
except UnicodeDecodeError: # pragma: no cover
file.close()
file = codecs.open(test_name + extension, "w")
file.write(result)
file.write(result)
file.close()
if print_status:
print("Saved! \nFilename: " + test_name + extension)
Expand Down
7 changes: 7 additions & 0 deletions art/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4646,12 +4646,19 @@
'OK'
>>> Data["Status"]
True
>>> result = []
>>> for i in FONT_NAMES:
... t = tsave("save-test",font=i,filename="save_test.txt",print_status=False,overwrite=True)
... result.append(t["Status"])
>>> all(result)
True
>>> os.remove("art.txt")
>>> os.remove("art2.txt")
>>> os.remove("art3.txt")
>>> os.remove("test.bw")
>>> os.remove("test.txt")
>>> os.remove("test1.txt")
>>> os.remove("test1.2.txt")
>>> os.remove("save_test.txt")
'''

0 comments on commit 59abb40

Please sign in to comment.