CacheControl 0.12.13__tar.gz → 0.12.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. {CacheControl-0.12.13 → CacheControl-0.12.14}/CacheControl.egg-info/PKG-INFO +1 -1
  2. {CacheControl-0.12.13 → CacheControl-0.12.14}/CacheControl.egg-info/requires.txt +1 -1
  3. {CacheControl-0.12.13 → CacheControl-0.12.14}/PKG-INFO +1 -1
  4. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/__init__.py +1 -1
  5. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/caches/file_cache.py +17 -7
  6. {CacheControl-0.12.13 → CacheControl-0.12.14}/setup.py +2 -2
  7. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/conftest.cpython-310-pytest-7.3.1.pyc +0 -0
  8. CacheControl-0.12.14/tests/__pycache__/test_adapter.cpython-310-pytest-7.3.1.pyc +0 -0
  9. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_adapter.cpython-311-pytest-7.3.1.pyc +0 -0
  10. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_cache_control.cpython-310-pytest-7.3.1.pyc +0 -0
  11. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_cache_control.cpython-311-pytest-7.3.1.pyc +0 -0
  12. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_chunked_response.cpython-310-pytest-7.3.1.pyc +0 -0
  13. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_etag.cpython-310-pytest-7.3.1.pyc +0 -0
  14. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_etag.cpython-311-pytest-7.3.1.pyc +0 -0
  15. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_expires_heuristics.cpython-310-pytest-7.3.1.pyc +0 -0
  16. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_expires_heuristics.cpython-311-pytest-7.3.1.pyc +0 -0
  17. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_max_age.cpython-310-pytest-7.3.1.pyc +0 -0
  18. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_redirects.cpython-310-pytest-7.3.1.pyc +0 -0
  19. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_redirects.cpython-311-pytest-7.3.1.pyc +0 -0
  20. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_regressions.cpython-310-pytest-7.3.1.pyc +0 -0
  21. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_serialization.cpython-310-pytest-7.3.1.pyc +0 -0
  22. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_serialization.cpython-311-pytest-7.3.1.pyc +0 -0
  23. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_server_http_version.cpython-310-pytest-7.3.1.pyc +0 -0
  24. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_storage_filecache.cpython-310-pytest-7.3.1.pyc +0 -0
  25. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_storage_filecache.cpython-311-pytest-7.3.1.pyc +0 -0
  26. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_storage_redis.cpython-310-pytest-7.3.1.pyc +0 -0
  27. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_storage_redis.cpython-311-pytest-7.3.1.pyc +0 -0
  28. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_vary.cpython-310-pytest-7.3.1.pyc +0 -0
  29. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_vary.cpython-311-pytest-7.3.1.pyc +0 -0
  30. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/utils.cpython-310.pyc +0 -0
  31. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/utils.cpython-311.pyc +0 -0
  32. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_storage_filecache.py +18 -6
  33. CacheControl-0.12.13/tests/__pycache__/test_adapter.cpython-310-pytest-7.3.1.pyc +0 -0
  34. {CacheControl-0.12.13 → CacheControl-0.12.14}/CacheControl.egg-info/SOURCES.txt +0 -0
  35. {CacheControl-0.12.13 → CacheControl-0.12.14}/CacheControl.egg-info/dependency_links.txt +0 -0
  36. {CacheControl-0.12.13 → CacheControl-0.12.14}/CacheControl.egg-info/entry_points.txt +0 -0
  37. {CacheControl-0.12.13 → CacheControl-0.12.14}/CacheControl.egg-info/top_level.txt +0 -0
  38. {CacheControl-0.12.13 → CacheControl-0.12.14}/LICENSE.txt +0 -0
  39. {CacheControl-0.12.13 → CacheControl-0.12.14}/MANIFEST.in +0 -0
  40. {CacheControl-0.12.13 → CacheControl-0.12.14}/README.rst +0 -0
  41. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/_cmd.py +0 -0
  42. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/adapter.py +0 -0
  43. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/cache.py +0 -0
  44. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/caches/__init__.py +0 -0
  45. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/caches/redis_cache.py +0 -0
  46. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/compat.py +0 -0
  47. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/controller.py +0 -0
  48. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/filewrapper.py +0 -0
  49. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/heuristics.py +0 -0
  50. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/serialize.py +0 -0
  51. {CacheControl-0.12.13 → CacheControl-0.12.14}/cachecontrol/wrapper.py +0 -0
  52. {CacheControl-0.12.13 → CacheControl-0.12.14}/setup.cfg +0 -0
  53. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__init__.py +0 -0
  54. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/__init__.cpython-310.pyc +0 -0
  55. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/__init__.cpython-311.pyc +0 -0
  56. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/__init__.cpython-39.pyc +0 -0
  57. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/conftest.cpython-311-pytest-7.3.1.pyc +0 -0
  58. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/conftest.cpython-39-pytest-7.3.1.pyc +0 -0
  59. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_adapter.cpython-39-pytest-7.3.1.pyc +0 -0
  60. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_cache_control.cpython-39-pytest-7.3.1.pyc +0 -0
  61. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_chunked_response.cpython-311-pytest-7.3.1.pyc +0 -0
  62. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_chunked_response.cpython-39-pytest-7.3.1.pyc +0 -0
  63. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_etag.cpython-39-pytest-7.3.1.pyc +0 -0
  64. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_expires_heuristics.cpython-39-pytest-7.3.1.pyc +0 -0
  65. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_max_age.cpython-311-pytest-7.3.1.pyc +0 -0
  66. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_max_age.cpython-39-pytest-7.3.1.pyc +0 -0
  67. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_redirects.cpython-39-pytest-7.3.1.pyc +0 -0
  68. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_regressions.cpython-311-pytest-7.3.1.pyc +0 -0
  69. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_regressions.cpython-39-pytest-7.3.1.pyc +0 -0
  70. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_serialization.cpython-39-pytest-7.3.1.pyc +0 -0
  71. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_server_http_version.cpython-311-pytest-7.3.1.pyc +0 -0
  72. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_server_http_version.cpython-39-pytest-7.3.1.pyc +0 -0
  73. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_storage_filecache.cpython-39-pytest-7.3.1.pyc +0 -0
  74. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_storage_redis.cpython-39-pytest-7.3.1.pyc +0 -0
  75. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/test_vary.cpython-39-pytest-7.3.1.pyc +0 -0
  76. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/__pycache__/utils.cpython-39.pyc +0 -0
  77. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/conftest.py +0 -0
  78. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/issue_263.py +0 -0
  79. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_adapter.py +0 -0
  80. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_cache_control.py +0 -0
  81. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_chunked_response.py +0 -0
  82. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_etag.py +0 -0
  83. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_expires_heuristics.py +0 -0
  84. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_max_age.py +0 -0
  85. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_redirects.py +0 -0
  86. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_regressions.py +0 -0
  87. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_serialization.py +0 -0
  88. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_server_http_version.py +0 -0
  89. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_storage_redis.py +0 -0
  90. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/test_vary.py +0 -0
  91. {CacheControl-0.12.13 → CacheControl-0.12.14}/tests/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CacheControl
3
- Version: 0.12.13
3
+ Version: 0.12.14
4
4
  Summary: httplib2 caching for requests
5
5
  Home-page: https://github.com/ionrock/cachecontrol
6
6
  Author: Eric Larson
@@ -2,7 +2,7 @@ requests
2
2
  msgpack>=0.5.2
3
3
 
4
4
  [filecache]
5
- filelock>=3.8.0
5
+ lockfile>=0.9
6
6
 
7
7
  [redis]
8
8
  redis>=2.10.5
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: CacheControl
3
- Version: 0.12.13
3
+ Version: 0.12.14
4
4
  Summary: httplib2 caching for requests
5
5
  Home-page: https://github.com/ionrock/cachecontrol
6
6
  Author: Eric Larson
@@ -8,7 +8,7 @@ Make it easy to import from cachecontrol without long namespaces.
8
8
  """
9
9
  __author__ = "Eric Larson"
10
10
  __email__ = "eric@ionrock.org"
11
- __version__ = "0.12.13"
11
+ __version__ = "0.12.14"
12
12
 
13
13
  from .wrapper import CacheControl
14
14
  from .adapter import CacheControlAdapter
@@ -66,23 +66,33 @@ class _FileCacheMixin:
66
66
  forever=False,
67
67
  filemode=0o0600,
68
68
  dirmode=0o0700,
69
+ use_dir_lock=None,
69
70
  lock_class=None,
70
71
  ):
71
72
 
73
+ if use_dir_lock is not None and lock_class is not None:
74
+ raise ValueError("Cannot use use_dir_lock and lock_class together")
75
+
72
76
  try:
73
- if lock_class is None:
74
- from filelock import FileLock
75
- lock_class = FileLock
77
+ from lockfile import LockFile
78
+ from lockfile.mkdirlockfile import MkdirLockFile
76
79
  except ImportError:
77
80
  notice = dedent(
78
81
  """
79
82
  NOTE: In order to use the FileCache you must have
80
- filelock installed. You can install it via pip:
81
- pip install filelock
83
+ lockfile installed. You can install it via pip:
84
+ pip install lockfile
82
85
  """
83
86
  )
84
87
  raise ImportError(notice)
85
88
 
89
+ else:
90
+ if use_dir_lock:
91
+ lock_class = MkdirLockFile
92
+
93
+ elif lock_class is None:
94
+ lock_class = LockFile
95
+
86
96
  self.directory = directory
87
97
  self.forever = forever
88
98
  self.filemode = filemode
@@ -123,9 +133,9 @@ class _FileCacheMixin:
123
133
  except (IOError, OSError):
124
134
  pass
125
135
 
126
- with self.lock_class(path + ".lock"):
136
+ with self.lock_class(path) as lock:
127
137
  # Write our actual file
128
- with _secure_open_write(path, self.filemode) as fh:
138
+ with _secure_open_write(lock.path, self.filemode) as fh:
129
139
  fh.write(data)
130
140
 
131
141
  def _delete(self, key, suffix):
@@ -6,7 +6,7 @@ import setuptools
6
6
 
7
7
  long_description = open("README.rst").read()
8
8
 
9
- VERSION = "0.12.13"
9
+ VERSION = "0.12.14"
10
10
 
11
11
  setup_params = dict(
12
12
  name="CacheControl",
@@ -22,7 +22,7 @@ setup_params = dict(
22
22
  description="httplib2 caching for requests",
23
23
  long_description=long_description,
24
24
  install_requires=["requests", "msgpack>=0.5.2"],
25
- extras_require={"filecache": ["filelock>=3.8.0"], "redis": ["redis>=2.10.5"]},
25
+ extras_require={"filecache": ["lockfile>=0.9"], "redis": ["redis>=2.10.5"]},
26
26
  entry_points={"console_scripts": ["doesitcache = cachecontrol._cmd:main"]},
27
27
  python_requires=">=3.6",
28
28
  classifiers=[
@@ -14,7 +14,8 @@ import pytest
14
14
  import requests
15
15
  from cachecontrol import CacheControl
16
16
  from cachecontrol.caches import FileCache, SeparateBodyFileCache
17
- from filelock import FileLock
17
+ from lockfile import LockFile
18
+ from lockfile.mkdirlockfile import MkdirLockFile
18
19
 
19
20
 
20
21
  def randomdata():
@@ -93,10 +94,21 @@ class FileCacheTestsMixin(object):
93
94
  assert len(self.cache.encode(url0)) < 200
94
95
  assert len(self.cache.encode(url0)) == len(self.cache.encode(url1))
95
96
 
96
- def test_simple_lockfile_arg(self, tmpdir):
97
- cache = self.FileCacheClass(str(tmpdir))
98
-
99
- assert issubclass(cache.lock_class, FileLock)
97
+ def test_cant_use_dir_and_lock_class(self, tmpdir):
98
+ with pytest.raises(ValueError):
99
+ self.FileCacheClass(str(tmpdir), use_dir_lock=True, lock_class=object())
100
+
101
+ @pytest.mark.parametrize(
102
+ ("value", "expected"),
103
+ [(None, LockFile), (True, MkdirLockFile), (False, LockFile)],
104
+ )
105
+ def test_simple_lockfile_arg(self, tmpdir, value, expected):
106
+ if value is not None:
107
+ cache = self.FileCacheClass(str(tmpdir), use_dir_lock=value)
108
+ else:
109
+ cache = self.FileCacheClass(str(tmpdir))
110
+
111
+ assert issubclass(cache.lock_class, expected)
100
112
  cache.close()
101
113
 
102
114
  def test_lock_class(self, tmpdir):
@@ -122,7 +134,7 @@ class TestFileCache(FileCacheTestsMixin):
122
134
  """
123
135
  Tests for ``FileCache``.
124
136
  """
125
-
137
+
126
138
  FileCacheClass = FileCache
127
139
 
128
140
  def test_body_stored_inline(self, sess):
File without changes