Skip to content

Commit

Permalink
Use codecs module for text-based rot13
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Nov 7, 2020
1 parent c99ce0a commit eba1021
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 3 additions & 2 deletions paradocx/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def quickstart(self):

if __name__ == '__main__':
import sys
import codecs
from textwrap import dedent
from this import s as zen_encoded
from openpack.basepack import CoreProperties
Expand All @@ -69,7 +70,7 @@ def quickstart(self):
</w:p>
"""
).lstrip()
raw_zen = zen_encoded.decode('rot13')
raw_zen = codecs.decode(zen_encoded, 'rot13')
zen = "".join(trun % line for line in raw_zen.splitlines())

body = (
Expand All @@ -93,7 +94,7 @@ def quickstart(self):
% (sys.version, zen)
)
op = WordPackage()
op.start_part.data = body.decode('utf-8')
op.start_part.data = body
cp = CoreProperties(op, '/docProps/core.xml')
cp.encoding = 'utf-8'
op.add(cp)
Expand Down
12 changes: 6 additions & 6 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ def get_resource_stream(name):
return pkg_resources.resource_stream(__name__, os.path.join('resources', name))


sample_filename = 'sample.docx'
_sample_filename = 'sample.docx'


@pytest.fixture
def sample_stream(request):
return get_resource_stream(sample_filename)
def sample_stream():
return get_resource_stream(_sample_filename)


@pytest.fixture
def sample_filename(request):
return get_resource_filename(sample_filename)
def sample_filename():
return get_resource_filename(_sample_filename)


@pytest.fixture
def table_data(request):
def table_data():
data = [
['Name', 'Age'],
['Christian', 29],
Expand Down

0 comments on commit eba1021

Please sign in to comment.