Skip to content

Commit

Permalink
Fix various warnings about unclosed files etc. There's still hundreds…
Browse files Browse the repository at this point in the history
… of warnings coming from inside ReportLab and PIL
  • Loading branch information
kylemacfarlane committed Oct 11, 2014
1 parent 1eeff04 commit 1ad92f1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/z3c/rml/attr.py
Expand Up @@ -92,7 +92,7 @@ def get(self):
if (interfaces.IDeprecated.providedBy(self) and
self.deprecatedName in self.context.element.attrib):
name = self.deprecatedName
logger.warn(
logger.warning(
u'Deprecated attribute "%s": %s %s' % (
name, self.deprecatedReason, getFileInfo(self.context)))
else:
Expand Down
2 changes: 1 addition & 1 deletion src/z3c/rml/directive.py
Expand Up @@ -108,7 +108,7 @@ def processSubDirectives(self, select=None, ignore=None):
msg = "Directive %r could not be processed and was " \
"ignored. %s" %(element.tag, getFileInfo(self, element))
# Record any tags/elements that could not be processed.
logger.warn(msg)
logger.warning(msg)
if ABORT_ON_INVALID_DIRECTIVE:
raise ValueError(msg)
continue
Expand Down
4 changes: 3 additions & 1 deletion src/z3c/rml/pagetemplate.txt
Expand Up @@ -13,7 +13,8 @@ The first step is to create a page template:

>>> import tempfile
>>> ptFileName = tempfile.mktemp('.pt')
>>> open(ptFileName, 'w').write('''\
>>> file_ = open(ptFileName, 'w')
>>> file_.write('''\
... <?xml version="1.0" encoding="UTF-8" ?>
... <!DOCTYPE document SYSTEM "rml.dtd">
... <document filename="template.pdf"
Expand All @@ -35,6 +36,7 @@ The first step is to create a page template:
... </document>
... ''')
463
>>> file_.close()

The ``context`` namespace will be created during rendering. I get back to this
later. In th enext step we instantiate the page template:
Expand Down
6 changes: 5 additions & 1 deletion src/z3c/rml/reference.py
Expand Up @@ -226,6 +226,8 @@ def extractExamples(directory):
xml = highlightRML(xml)
example['code'] = xml

rmlFile.close()

return examples


Expand All @@ -239,4 +241,6 @@ def main(outPath=None):
directives = sorted(directives.values(), key=lambda d: d['name'])

pdf = template(types=getAttributeTypes(), directives=directives)
open(outPath or 'rml-reference.pdf', 'wb').write(pdf)
file_ = open(outPath or 'rml-reference.pdf', 'wb')
file_.write(pdf)
file_.close()
4 changes: 4 additions & 0 deletions src/z3c/rml/rml2pdf.py
Expand Up @@ -60,6 +60,10 @@ def go(xmlInputName, outputFileName=None, outDir=None, dtdDir=None):
# Create a Reportlab canvas by processing the document
doc.process(outputFile)

if outputFile:
outputFile.close()
xmlFile.close()


def main(args=None):
if args is None:
Expand Down

0 comments on commit 1ad92f1

Please sign in to comment.