Commits

Jason R. Coombs  committed 7aad91e

Cleaned up indentation and whitespace and removed unused imports

  • Participants
  • Parent commits 6ea2ce9

Comments (0)

Files changed (3)

 <https://bitbucket.org/yougov/paradocx/src/66c96e2251e6/paradocx/package.py?at=default>`_
 for a trivial example of usage.
 
-
-
 Changes
 -------
 

File paradocx/document.py

+from lxml.etree import fromstring
 from openpack.basepack import Part
 from openpack.officepack import OfficePackage
-from lxml.etree import tostring, fromstring
-from util import w, expand_namespace as EN
+
+from .util import w, expand_namespace as EN
 
 class DocumentPart(Part):
 	content_type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"
 
 	def append(self, xml_element):
 		self.body.append(xml_element)
-

File paradocx/package.py

-from openpack.basepack import ContentType, Part, Relationship
+from openpack.basepack import ContentType
 from openpack.officepack import OfficePackage
 
 # these modules must be imported for their Parts to be properly recognized
 	import sys
 	from textwrap import dedent
 	from this import s as zen_encoded
-	from openpack.basepack import Relationships, CoreProperties
-	
-	trun = """\
-	<w:p>
-	  <w:r>
-		<w:t>%s</w:t>
-	  </w:r>
-	</w:p>
-"""
+	from openpack.basepack import CoreProperties
+
+	trun = dedent("""
+		<w:p>
+			<w:r>
+				<w:t>%s</w:t>
+			</w:r>
+		</w:p>
+		""").lstrip()
 	raw_zen = zen_encoded.decode('rot13')
 	zen = "".join(trun % line for line in raw_zen.splitlines())
 
 	body = dedent("""
 		<?xml version="1.0" encoding="utf-8"?>
 		<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
-		  <w:body>
-			<w:p>
-			  <w:r><w:t>Generated by:</w:t></w:r>
-			</w:p>
-			<w:p>
-			  <w:r><w:t>Python %s</w:t></w:r>
-			</w:p>
-		%s
-		  </w:body>
+			<w:body>
+				<w:p>
+					<w:r><w:t>Generated by:</w:t></w:r>
+				</w:p>
+				<w:p>
+					<w:r><w:t>Python %s</w:t></w:r>
+				</w:p>
+				%s
+			</w:body>
 		</w:document>
 		""").lstrip() % (sys.version, zen)
 	op = WordPackage()
 	op.relate(cp)
 	cp.creator = "Testy McTest"
 	op.save('test.docx')
-