Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
language: python
python:
- "3.6"
- "3.7"
- "3.8"
- "3.9"
- "3.11"
env: CFLAGS="-O0"

cache:
directories:
- $HOME/.cache/pip

install:
- pip install -r requirements.txt
script:
python setup.py test
- pip install -e .
script: python setup.py test
after_success:
- coveralls

# See: http://docs.travis-ci.com/user/migrating-from-legacy/
sudo: false
sudo: false
2 changes: 1 addition & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ v0.5.0, 2021-05-03 --
0.5.1 (unreleased)


- Nothing changed yet.
- Make pdfquery compatible with Python 3.9 and 3.11


0.5.0 (2021-05-04)
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Installation as a package
Installation for development
============================

``pip install -e .[test,flake8,docs,release]``
``pip install -e ".[test,flake8,docs,release]"``

Quick Start
===========
Expand Down
6 changes: 2 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
environment:
matrix:
- PYTHON: "C:\\Python36"
- PYTHON: "C:\\Python37"
- PYTHON: "C:\\Python38"
- PYTHON: "C:\\Python39"
- PYTHON: "C:\\Python311"

build: off

test_script:
- "%PYTHON%\\python.exe setup.py test"
- "%PYTHON%\\python.exe setup.py test"
2 changes: 1 addition & 1 deletion pdfquery/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .pdfquery import PDFQuery
from .pdfquery import PDFQuery
23 changes: 13 additions & 10 deletions pdfquery/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class BaseCache(object):

def __init__(self):
self.hash_key = None

Expand Down Expand Up @@ -34,30 +33,34 @@ class DummyCache(BaseCache):


class FileCache(BaseCache):

def __init__(self, directory='/tmp/'):
def __init__(self, directory="/tmp/"):
self.directory = directory
super(FileCache, self).__init__()

def get_cache_filename(self, page_range_key):
return "pdfquery_{hash_key}{page_range_key}.xml".format(
hash_key=self.hash_key,
page_range_key=page_range_key
hash_key=self.hash_key, page_range_key=page_range_key
)

def get_cache_file(self, page_range_key, mode):
try:
return zipfile.ZipFile(self.directory+self.get_cache_filename(page_range_key)+".zip", mode)
return zipfile.ZipFile(
self.directory + self.get_cache_filename(page_range_key) + ".zip", mode
)
except IOError:
return None

def set(self, page_range_key, tree):
xml = etree.tostring(tree, encoding='utf-8', pretty_print=False, xml_declaration=True)
cache_file = self.get_cache_file(page_range_key, 'w')
xml = etree.tostring(
tree, encoding="utf-8", pretty_print=False, xml_declaration=True
)
cache_file = self.get_cache_file(page_range_key, "w")
cache_file.writestr(self.get_cache_filename(page_range_key), xml)
cache_file.close()

def get(self, page_range_key):
cache_file = self.get_cache_file(page_range_key, 'r')
cache_file = self.get_cache_file(page_range_key, "r")
if cache_file:
return etree.fromstring(cache_file.read(self.get_cache_filename(page_range_key)))
return etree.fromstring(
cache_file.read(self.get_cache_filename(page_range_key))
)
Loading