loading file with filecache AttributeError: 'NoneType' object has no attribute 'writestr'
Closed this issue · 1 comments
I am trying to load a small PDF, however when i use the filecache option it crashes
pdf.load()
File "C:\Python37\lib\site-packages\pdfquery\pdfquery.py", line 385, in load
self.tree = self.get_tree(*_flatten(page_numbers))
File "C:\Python37\lib\site-packages\pdfquery\pdfquery.py", line 496, in get_tree
self._parse_tree_cacher.set(cache_key, tree)
File "C:\Python37\lib\site-packages\pdfquery\cache.py", line 55, in set
cache_file.writestr(self.get_cache_filename(page_range_key), xml)
AttributeError: 'NoneType' object has no attribute 'writestr'
pdf = pdfquery.PDFQuery("annual_reports/simple1.pdf", parse_tree_cacher=FileCache("/tmp/"))
pdf.load()
I used a full path to the tmp directory and it started working though. Do relative paths work, i expected it would be relative to the directory from which the script is running
It seems that trailing slashes are required. I run into the above error when using FileCache("/tmp")
but it works with FileCache("/tmp/")
.