diff --git a/src/z3c/rml/attr.py b/src/z3c/rml/attr.py index abf8d18..5bbc80c 100644 --- a/src/z3c/rml/attr.py +++ b/src/z3c/rml/attr.py @@ -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: diff --git a/src/z3c/rml/directive.py b/src/z3c/rml/directive.py index 8e27027..14847df 100644 --- a/src/z3c/rml/directive.py +++ b/src/z3c/rml/directive.py @@ -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 diff --git a/src/z3c/rml/pagetemplate.txt b/src/z3c/rml/pagetemplate.txt index e99cf02..9c886d4 100644 --- a/src/z3c/rml/pagetemplate.txt +++ b/src/z3c/rml/pagetemplate.txt @@ -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('''\ ... ... ... ... ''') 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: diff --git a/src/z3c/rml/reference.py b/src/z3c/rml/reference.py index 9227c64..01a2617 100644 --- a/src/z3c/rml/reference.py +++ b/src/z3c/rml/reference.py @@ -226,6 +226,8 @@ def extractExamples(directory): xml = highlightRML(xml) example['code'] = xml + rmlFile.close() + return examples @@ -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() diff --git a/src/z3c/rml/rml2pdf.py b/src/z3c/rml/rml2pdf.py index 5c6e88c..e6dfcfd 100644 --- a/src/z3c/rml/rml2pdf.py +++ b/src/z3c/rml/rml2pdf.py @@ -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: diff --git a/src/z3c/rml/tests/test_rml.py b/src/z3c/rml/tests/test_rml.py index 53c0676..128d3a9 100644 --- a/src/z3c/rml/tests/test_rml.py +++ b/src/z3c/rml/tests/test_rml.py @@ -84,13 +84,17 @@ def __init__(self, basePath, testPath): unittest.TestCase.__init__(self) def assertSameImage(self, baseImage, testImage): - base = Image.open(baseImage).getdata() - test = Image.open(testImage).getdata() + base_file = open(baseImage, 'rb') + test_file = open(testImage, 'rb') + base = Image.open(base_file).getdata() + test = Image.open(test_file).getdata() for i in range(len(base)): if (base[i] - test[i]) != 0: self.fail( 'Image is not the same: %s' % os.path.basename(baseImage) ) + base_file.close() + test_file.close() def runTest(self): # Convert the base PDF to image(s)