Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stable #3

Open
wants to merge 2 commits into
base: stable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions sx/pisa3/pisa_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ def _width(value=None):
return value
return getSize(value)

def _heigth(value=None):
if value is None:
return None
value = str(value)
if value.endswith("%"):
return value
return getSize(value)

class TableData:

def __init__(self):
Expand Down Expand Up @@ -202,10 +210,17 @@ def end(self, c):

for i, row in enumerate(data):
data[i] += [''] * (maxcols - len(row))

cols_with_no_width = len(filter(lambda col: col is None, tdata.colw))
if cols_with_no_width: # any col width not defined
bad_cols = filter(lambda tup: tup[1] is None, enumerate(tdata.colw))
fair_division = str(100/float(cols_with_no_width))+'%' # get fair %
for i,col in bad_cols:
tdata.colw[i] = fair_division # fix empty with fair %

try:
if tdata.data:
# log.debug("Table sryles %r", tdata.styles)
# log.debug("Table styles %r", tdata.styles)
t = PmlTable(
data,
colWidths=tdata.colw,
Expand Down Expand Up @@ -317,7 +332,7 @@ def start(self, c):
if not rspan:
height = None #self._getStyle(None, attrs, "height", "height", mode)
if height is not None:
tdata.rowh[row] = _width(height)
tdata.rowh[row] = _heigth(height)
tdata.add_style(('FONTSIZE', begin, end, 1.0))
tdata.add_style(('LEADING', begin, end, 1.0))

Expand Down Expand Up @@ -400,4 +415,4 @@ def end_keepinframe(self):
self.next_para()
self.keepinframe["content"] = self.story.pop()
self.add_story(KeepInFrame(**self.keepinframe))
'''
'''
2 changes: 1 addition & 1 deletion sx/pisa3/pisa_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def __init__(self, uri, basepath=None):
if r1.getheader("content-encoding") == "gzip":
# zbuf = cStringIO.StringIO(data)
import gzip
self.file = gzip.GzipFile(mode="rb", fileobj=r1)
self.file = gzip.GzipFile(mode="rb", fileobj=StringIO.StringIO(r1.read()))
#data = zfile.read()
#zfile.close()
else:
Expand Down