Skip to content

Commit

Permalink
All imports seem to be linked, now the real (testing) fun can begin!
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Glass committed May 20, 2011
1 parent c2b3eaa commit 239bbfb
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 50 deletions.
22 changes: 11 additions & 11 deletions xhtml2pdf/context.py
Expand Up @@ -7,15 +7,15 @@
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.platypus.frames import Frame
from reportlab.platypus.paraparser import ParaFrag, ps2tt, tt2ps
from xhtml2pdf.reportlab import PmlPageTemplate, PmlTableOfContents, \
from xhtml2pdf.xhtml2pdf_reportlab import PmlPageTemplate, PmlTableOfContents, \
PmlParagraph, PmlParagraphAndImage
from xhtml2pdf.util import getSize, getCoords, getFile, pisaFileObject
from xhtml2pdf.w3c import css
import copy
import logging
import os
import default
import parser
import xhtml2pdf.default
import xhtml2pdf.parser
import re
import reportlab
import types
Expand Down Expand Up @@ -256,7 +256,7 @@ def atPage(self, name, pseudopage, declarations):
log.warn(self.c.warning("template '%s' has already been defined", name))

if data.has_key("-pdf-page-size"):
c.pageSize = pisa_default.PML_PAGESIZES.get(str(data["-pdf-page-size"]).lower(), c.pageSize)
c.pageSize = xhtml2pdf.default.PML_PAGESIZES.get(str(data["-pdf-page-size"]).lower(), c.pageSize)

if data.has_key("size"):
size = data["size"]
Expand All @@ -271,8 +271,8 @@ def atPage(self, name, pseudopage, declarations):
sizeList.append(getSize(value))
elif valueStr == "landscape":
isLandscape = True
elif pisa_default.PML_PAGESIZES.has_key(valueStr):
c.pageSize = pisa_default.PML_PAGESIZES[valueStr]
elif xhtml2pdf.default.PML_PAGESIZES.has_key(valueStr):
c.pageSize = xhtml2pdf.default.PML_PAGESIZES[valueStr]
else:
log.warn(c.warning("Unknown size value for @page"))

Expand Down Expand Up @@ -415,7 +415,7 @@ class pisaContext:
"""

def __init__(self, path, debug=0, capacity=-1):
self.fontList = copy.copy(pisa_default.DEFAULT_FONT)
self.fontList = copy.copy(xhtml2pdf.default.DEFAULT_FONT)
self.path = []
self.capacity=capacity

Expand Down Expand Up @@ -628,8 +628,8 @@ def addTOC(self):
self.node.attributes["class"] = "pdftoclevel%d" % i
#self.node.cssAttrs = copy.deepcopy(cssAttrs)
#self.frag = copy.deepcopy(frag)
self.cssAttr = pisa_parser.CSSCollect(self.node, self)
pisa_parser.CSS2Frag(self, {
self.cssAttr = xhtml2pdf.parser.CSSCollect(self.node, self)
xhtml2pdf.parser.CSS2Frag(self, {
"margin-top": 0,
"margin-bottom": 0,
"margin-left": 0,
Expand Down Expand Up @@ -892,15 +892,15 @@ def context(self, msg):

def warning(self, msg, *args):
self.warn += 1
self.log.append((pisa_default.PML_WARNING, self._getLineNumber(), str(msg), self._getFragment(50)))
self.log.append((xhtml2pdf.default.PML_WARNING, self._getLineNumber(), str(msg), self._getFragment(50)))
try:
return self.context(msg % args)
except:
return self.context(msg)

def error(self, msg, *args):
self.err += 1
self.log.append((pisa_default.PML_ERROR, self._getLineNumber(), str(msg), self._getFragment(50)))
self.log.append((xhtml2pdf.default.PML_ERROR, self._getLineNumber(), str(msg), self._getFragment(50)))
try:
return self.context(msg % args)
except:
Expand Down
2 changes: 1 addition & 1 deletion xhtml2pdf/document.py
Expand Up @@ -4,7 +4,7 @@
from xhtml2pdf.parser import pisaParser
from reportlab.platypus.flowables import Spacer
from reportlab.platypus.frames import Frame
from xhtml2pdf.reportlab import PmlBaseDoc, PmlPageTemplate
from xhtml2pdf.xhtml2pdf_reportlab import PmlBaseDoc, PmlPageTemplate
from xhtml2pdf.util import pisaTempFile, getBox, pyPdf
import cgi
import logging
Expand Down
34 changes: 17 additions & 17 deletions xhtml2pdf/parser.py
Expand Up @@ -14,27 +14,28 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pprint
from html5lib import treebuilders, serializer, treewalkers, inputstream
from xhtml2pdf.default import * # TODO: Kill wild import!
from xhtml2pdf.tables import * # TODO: Kill wild import!
from xhtml2pdf.tags import * # TODO: Kill wild import!
from xhtml2pdf.util import * # TODO: Kill wild import!
from xhtml2pdf.xhtml2pdf_reportlab import PmlRightPageBreak, PmlLeftPageBreak
from xml.dom import Node
import copy
import types
import re
import html5lib
import logging
import os
import os.path

import html5lib
from html5lib import treebuilders, serializer, treewalkers, inputstream
from xml.dom import Node
import pprint
import re
import types
import xhtml2pdf.w3c.css as css
import xhtml2pdf.w3c.cssDOMElementInterface as cssDOMElementInterface
import xml.dom.minidom

from xhtml2pdf.default import * # TODO: Kill wild import!
from xhtml2pdf.util import * # TODO: Kill wild import!
from xhtml2pdf.tags import * # TODO: Kill wild import!
from xhtml2pdf.tables import * # TODO: Kill wild import!

import xhtml2pdf.w3c.css as css
import xhtml2pdf.w3c.cssDOMElementInterface as cssDOMElementInterface

import logging

log = logging.getLogger("ho.pisa")

rxhttpstrip = re.compile("https?://[^/]+(.*)", re.M | re.I)
Expand Down Expand Up @@ -608,9 +609,8 @@ def pisaParser(src, c, default_css="", xhtml=False, encoding=None, xml_output=No
if not inputstream.isValidEncoding(encoding):
log.error("%r is not a valid encoding e.g. 'utf8' is not valid but 'utf-8' is!", encoding)
else:
if inputstream.codecName(encoding) is None:
log.error("%r is not a valid encoding", encoding)
import ipdb; ipdb.set_trace()
if inputstream.codecName(encoding) is None:
log.error("%r is not a valid encoding", encoding)
document = parser.parse(
src,
encoding=encoding)
Expand Down
3 changes: 1 addition & 2 deletions xhtml2pdf/pisa.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from xhtml2pdf.default import DEFAULT_CSS
from xhtml2pdf.document import * # TODO: Kill wild import
from xhtml2pdf.document import pisaDocument
from xhtml2pdf.util import getFile
from xhtml2pdf.version import VERSION, VERSION_STR
import getopt
Expand Down Expand Up @@ -282,7 +282,6 @@ def execute():
print "--------------------------------------------"
print "OS: ", sys.platform
print "Python: ", sys.version
import html5lib
print "html5lib: ", "?"
import reportlab
print "Reportlab: ", reportlab.Version
Expand Down
5 changes: 3 additions & 2 deletions xhtml2pdf/tables.py
@@ -1,7 +1,8 @@
# -*- coding: utf-8 -*-
from xhtml2pdf.reportlab import PmlTable, TableStyle, PmlKeepInFrame
from xhtml2pdf.tags import pisaTag
from reportlab.platypus.tables import TableStyle
from sx.pisa3.pisa_util import getSize, getBorderStyle, getAlign
from xhtml2pdf.tags import pisaTag
from xhtml2pdf.xhtml2pdf_reportlab import PmlTable, PmlKeepInFrame
import copy
import logging

Expand Down
10 changes: 5 additions & 5 deletions xhtml2pdf/tags.py
Expand Up @@ -6,11 +6,11 @@
from reportlab.platypus.flowables import Spacer, HRFlowable, PageBreak, Flowable
from reportlab.platypus.frames import Frame
from reportlab.platypus.paraparser import tt2ps, ABag
from xhtml2pdf.reportlab import PmlImage, PmlPageTemplate
from xhtml2pdf import xhtml2pdf_reportlab
from xhtml2pdf.util import getColor, getSize, getAlign, dpi96
from xhtml2pdf.xhtml2pdf_reportlab import PmlImage, PmlPageTemplate
import copy
import logging
from xhtml2pdf import reportlab
import re
import warnings

Expand Down Expand Up @@ -379,7 +379,7 @@ def _render(self, c, attr):
if attr.type == "text":
width = 100
height = 12
c.addStory(pisa_reportlab.PmlInput(attr.name,
c.addStory(xhtml2pdf_reportlab.PmlInput(attr.name,
type=attr.type,
default=attr.value,
width=width,
Expand All @@ -396,7 +396,7 @@ def end(self, c):
class pisaTagTEXTAREA(pisaTagINPUT):

def _render(self, c, attr):
c.addStory(pisa_reportlab.PmlInput(attr.name,
c.addStory(xhtml2pdf_reportlab.PmlInput(attr.name,
default="",
width=100,
height=100))
Expand All @@ -407,7 +407,7 @@ def start(self, c):
c.select_options = ["One", "Two", "Three"]

def _render(self, c, attr):
c.addStory(pisa_reportlab.PmlInput(attr.name,
c.addStory(xhtml2pdf_reportlab.PmlInput(attr.name,
type="select",
default=c.select_options[0],
options=c.select_options,
Expand Down
29 changes: 17 additions & 12 deletions xhtml2pdf/reportlab.py → xhtml2pdf/xhtml2pdf_reportlab.py
Expand Up @@ -14,15 +14,26 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from reportlab.platypus.doctemplate import BaseDocTemplate, PageTemplate, FrameBreak, NextPageTemplate
from reportlab.platypus.tables import Table, TableStyle
from reportlab.platypus.flowables import Flowable, Image, CondPageBreak, KeepInFrame, ParagraphAndImage
from reportlab.platypus.frames import Frame
from hashlib import md5
from reportlab.lib.enums import TA_RIGHT
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.utils import flatten, open_for_read, getStringIO, \
LazyImageReader, haveImages
from reportlab.platypus.doctemplate import BaseDocTemplate, PageTemplate
from reportlab.platypus.flowables import Flowable, Image, CondPageBreak, \
KeepInFrame, ParagraphAndImage
from reportlab.platypus.tableofcontents import TableOfContents
from reportlab.platypus.tables import Table, TableStyle
from xhtml2pdf.reportlab_paragraph import Paragraph
from xhtml2pdf.util import getUID, getBorderStyle
import StringIO
import cgi
import copy
import logging
import reportlab.pdfbase.pdfform as pdfform
import sys

from reportlab_paragraph import Paragraph

from reportlab.lib.utils import * # TODO: Kill the wild import!

try:
import PIL.Image as PILImage
Expand All @@ -32,13 +43,8 @@
except:
PILImage = None

from xhtml2pdf.util import * # TODO: Kill the wild import!
from xhtml2pdf.default import TAGS, STRING

import copy
import cgi

import logging
log = logging.getLogger("ho.pisa")

MAX_IMAGE_RATIO = 0.95
Expand Down Expand Up @@ -776,7 +782,6 @@ def wrap(self, availWidth, availHeight):

# --- Pdf Form

import reportlab.pdfbase.pdfform as pdfform

class PmlInput(Flowable):

Expand Down

0 comments on commit 239bbfb

Please sign in to comment.