cachier 3.0.0__tar.gz → 3.0.1__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 (31) hide show
  1. {cachier-3.0.0 → cachier-3.0.1}/MANIFEST.in +3 -3
  2. {cachier-3.0.0/cachier.egg-info → cachier-3.0.1}/PKG-INFO +33 -16
  3. {cachier-3.0.0 → cachier-3.0.1}/README.rst +2 -2
  4. cachier-3.0.1/pyproject.toml +176 -0
  5. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/__main__.py +1 -1
  6. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/config.py +2 -0
  7. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/core.py +14 -9
  8. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/cores/base.py +23 -14
  9. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/cores/mongo.py +3 -2
  10. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/cores/pickle.py +9 -9
  11. cachier-3.0.1/src/cachier/version.info +1 -0
  12. {cachier-3.0.0 → cachier-3.0.1/src/cachier.egg-info}/PKG-INFO +33 -16
  13. cachier-3.0.1/src/cachier.egg-info/SOURCES.txt +23 -0
  14. cachier-3.0.1/src/cachier.egg-info/entry_points.txt +2 -0
  15. {cachier-3.0.0 → cachier-3.0.1/src}/cachier.egg-info/requires.txt +1 -2
  16. cachier-3.0.0/cachier/version.info +0 -1
  17. cachier-3.0.0/cachier.egg-info/SOURCES.txt +0 -25
  18. cachier-3.0.0/cachier.egg-info/entry_points.txt +0 -2
  19. cachier-3.0.0/pyproject.toml +0 -78
  20. cachier-3.0.0/requirements.txt +0 -3
  21. cachier-3.0.0/setup.py +0 -84
  22. {cachier-3.0.0 → cachier-3.0.1}/LICENSE +0 -0
  23. {cachier-3.0.0 → cachier-3.0.1}/setup.cfg +0 -0
  24. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/__init__.py +0 -0
  25. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/_types.py +0 -0
  26. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/_version.py +0 -0
  27. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/cores/__init__.py +0 -0
  28. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/cores/memory.py +0 -0
  29. {cachier-3.0.0 → cachier-3.0.1/src}/cachier/py.typed +0 -0
  30. {cachier-3.0.0 → cachier-3.0.1/src}/cachier.egg-info/dependency_links.txt +0 -0
  31. {cachier-3.0.0 → cachier-3.0.1/src}/cachier.egg-info/top_level.txt +0 -0
@@ -1,9 +1,9 @@
1
1
  # Manifest syntax https://docs.python.org/2/distutils/sourcedist.html
2
2
  graft wheelhouse
3
3
 
4
- recursive-exclude __pycache__ *.py[cod] *.orig
5
- include cachier/version.info
4
+ recursive-include src *.info
6
5
  include README.rst
7
- include requirements.txt
6
+ include LICENSE
8
7
 
8
+ prune __pycache__
9
9
  prune tests
@@ -1,33 +1,50 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cachier
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: Persistent, stale-free, local and cross-machine caching for Python functions.
5
- Home-page: https://github.com/python-cachier/cachier
6
- Author: Shay Palachy & al.
7
- Author-email: shay.palachy@gmail.com
8
- License: MIT
9
- Keywords: cache,persistence,mongo,memoization,decorator
10
- Platform: linux
11
- Platform: osx
12
- Platform: windows
5
+ Author-email: Shay Palachy Affek <shay.palachy@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2016 Shay Palachy
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Source, https://github.com/python-cachier/cachier
29
+ Keywords: cache,caching,cross-machine,decorator,local,memoization,mongo,persistent
13
30
  Classifier: Development Status :: 4 - Beta
31
+ Classifier: Intended Audience :: Developers
14
32
  Classifier: License :: OSI Approved :: MIT License
15
33
  Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3 :: Only
17
35
  Classifier: Programming Language :: Python :: 3.8
18
36
  Classifier: Programming Language :: Python :: 3.9
19
37
  Classifier: Programming Language :: Python :: 3.10
20
38
  Classifier: Programming Language :: Python :: 3.11
21
39
  Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: Other/Nonlisted Topic
22
41
  Classifier: Topic :: Software Development :: Libraries
23
42
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
43
  Classifier: Topic :: Utilities
25
- Classifier: Topic :: Other/Nonlisted Topic
26
- Classifier: Intended Audience :: Developers
44
+ Description-Content-Type: text/x-rst
27
45
  License-File: LICENSE
28
- Requires-Dist: watchdog>=2.3.1
29
46
  Requires-Dist: portalocker>=2.3.2
30
- Requires-Dist: setuptools>=67.6.0
47
+ Requires-Dist: watchdog>=2.3.1
31
48
 
32
49
  Cachier
33
50
  #######
@@ -492,8 +509,8 @@ Notable bugfixers:
492
509
  .. |PyPI-Versions| image:: https://img.shields.io/pypi/pyversions/cachier.svg
493
510
  :target: https://pypi.python.org/pypi/cachier
494
511
 
495
- .. |Build-Status| image:: https://github.com/python-cachier/cachier/actions/workflows/test.yml/badge.svg
496
- :target: https://github.com/python-cachier/cachier/actions/workflows/test.yml
512
+ .. |Build-Status| image:: https://github.com/python-cachier/cachier/actions/workflows/ci-test.yml/badge.svg
513
+ :target: https://github.com/python-cachier/cachier/actions/workflows/ci-test.yml
497
514
 
498
515
  .. |LICENCE| image:: https://img.shields.io/pypi/l/cachier.svg
499
516
  :target: https://pypi.python.org/pypi/cachier
@@ -461,8 +461,8 @@ Notable bugfixers:
461
461
  .. |PyPI-Versions| image:: https://img.shields.io/pypi/pyversions/cachier.svg
462
462
  :target: https://pypi.python.org/pypi/cachier
463
463
 
464
- .. |Build-Status| image:: https://github.com/python-cachier/cachier/actions/workflows/test.yml/badge.svg
465
- :target: https://github.com/python-cachier/cachier/actions/workflows/test.yml
464
+ .. |Build-Status| image:: https://github.com/python-cachier/cachier/actions/workflows/ci-test.yml/badge.svg
465
+ :target: https://github.com/python-cachier/cachier/actions/workflows/ci-test.yml
466
466
 
467
467
  .. |LICENCE| image:: https://img.shields.io/pypi/l/cachier.svg
468
468
  :target: https://pypi.python.org/pypi/cachier
@@ -0,0 +1,176 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools",
4
+ "wheel",
5
+ ]
6
+
7
+ [project]
8
+ name = "cachier"
9
+ description = "Persistent, stale-free, local and cross-machine caching for Python functions."
10
+ readme = "README.rst"
11
+ keywords = [
12
+ "cache",
13
+ "caching",
14
+ "cross-machine",
15
+ "decorator",
16
+ "local",
17
+ "memoization",
18
+ "mongo",
19
+ "persistent",
20
+ ]
21
+ license = { file = "LICENSE" }
22
+ authors = [
23
+ { name = "Shay Palachy Affek", email = 'shay.palachy@gmail.com' },
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 4 - Beta",
27
+ "Intended Audience :: Developers",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Programming Language :: Python",
30
+ "Programming Language :: Python :: 3 :: Only",
31
+ "Programming Language :: Python :: 3.8",
32
+ "Programming Language :: Python :: 3.9",
33
+ "Programming Language :: Python :: 3.10",
34
+ "Programming Language :: Python :: 3.11",
35
+ "Programming Language :: Python :: 3.12",
36
+ "Topic :: Other/Nonlisted Topic",
37
+ "Topic :: Software Development :: Libraries",
38
+ "Topic :: Software Development :: Libraries :: Python Modules",
39
+ "Topic :: Utilities",
40
+ ]
41
+ dynamic = [
42
+ "version",
43
+ ]
44
+ dependencies = [
45
+ "portalocker>=2.3.2",
46
+ "watchdog>=2.3.1",
47
+ ]
48
+ urls.Source = "https://github.com/python-cachier/cachier"
49
+ scripts.cachier = "cachier.__main__:cli"
50
+
51
+ [tool.setuptools]
52
+ include-package-data = true
53
+
54
+ [tool.setuptools.dynamic]
55
+ version = { attr = "cachier._version.__version__" }
56
+
57
+ [tool.setuptools.packages.find]
58
+ where = [
59
+ "src",
60
+ ] # list of folders that contain the packages (["."] by default)
61
+ include = [
62
+ "cachier*",
63
+ ] # package names should match these glob patterns (["*"] by default)
64
+ namespaces = false # to disable scanning PEP 420 namespaces (true by default)
65
+
66
+ [tool.ruff]
67
+ target-version = "py38"
68
+ line-length = 79
69
+ # Exclude a variety of commonly ignored directories.
70
+ exclude = [
71
+ ".eggs",
72
+ ".git",
73
+ ".ruff_cache",
74
+ "__pypackages__",
75
+ "_build",
76
+ "build",
77
+ "dist",
78
+ ]
79
+ # Enable Pyflakes `E` and `F` codes by default.
80
+ lint.select = [
81
+ "D", # see: https://pypi.org/project/pydocstyle
82
+ "E",
83
+ "F", # see: https://pypi.org/project/pyflakes
84
+ "I", #see: https://pypi.org/project/isort/
85
+ "RUF100", # alternative to yesqa
86
+ #"N", # see: https://pypi.org/project/pep8-naming
87
+ "S", # see: https://pypi.org/project/flake8-bandit
88
+ "SIM",
89
+ "W", # see: https://pypi.org/project/pycodestyle
90
+ ]
91
+ lint.extend-select = [
92
+ "A", # see: https://pypi.org/project/flake8-builtins
93
+ "B", # see: https://pypi.org/project/flake8-bugbear
94
+ "C4", # see: https://pypi.org/project/flake8-comprehensions
95
+ ]
96
+ lint.ignore = [
97
+ "C901",
98
+ "E203",
99
+ ]
100
+ lint.per-file-ignores."src/**/__init__.py" = [
101
+ "D104",
102
+ ]
103
+ lint.per-file-ignores."src/cachier/config.py" = [
104
+ "D100",
105
+ ]
106
+ lint.per-file-ignores."tests/**" = [
107
+ "D100",
108
+ "D101",
109
+ "D103",
110
+ "D104",
111
+ "D401",
112
+ "S101",
113
+ "S105",
114
+ "S311",
115
+ "S603",
116
+ ]
117
+ lint.unfixable = [
118
+ "F401",
119
+ ]
120
+
121
+ #[tool.ruff.pydocstyle]
122
+ ## Use Google-style docstrings.
123
+ #convention = "google"
124
+ #[tool.ruff.pycodestyle]
125
+ #ignore-overlong-task-comments = true
126
+ # Unlike Flake8, default to a complexity level of 10.
127
+ lint.mccabe.max-complexity = 10
128
+
129
+ [tool.docformatter]
130
+ recursive = true
131
+ # some docstring start with r"""
132
+ wrap-summaries = 79
133
+ wrap-descriptions = 79
134
+ blank = true
135
+
136
+ [tool.pytest.ini_options]
137
+ testpaths = [
138
+ "cachier",
139
+ "tests",
140
+ ]
141
+ norecursedirs = [
142
+ "dist",
143
+ "build",
144
+ ]
145
+ addopts = [
146
+ "--color=yes",
147
+ "--cov=cachier",
148
+ "--cov-report=term",
149
+ "--cov-report=xml:cov.xml",
150
+ "-r a",
151
+ "-v",
152
+ "-s",
153
+ ]
154
+ markers = [
155
+ "mongo: test the MongoDB core",
156
+ "memory: test the memory core",
157
+ "pickle: test the pickle core",
158
+ ]
159
+
160
+ [tool.coverage.run]
161
+ branch = true
162
+ dynamic_context = "test_function"
163
+ omit = [
164
+ "tests/*",
165
+ "cachier/_version.py",
166
+ "cachier/__init__.py",
167
+ "**/scripts/**",
168
+ ]
169
+ [tool.coverage.report]
170
+ show_missing = true
171
+ # Regexes for lines to exclude from consideration
172
+ exclude_lines = [
173
+ "pragma: no cover", # Have to re-enable the standard pragma
174
+ "raise NotImplementedError", # Don't complain if tests don't hit defensive assertion code:
175
+ "if TYPE_CHECKING:", # Is only true when running mypy, not tests
176
+ ]
@@ -7,7 +7,7 @@ from cachier.core import _set_max_workers
7
7
 
8
8
  @click.group()
9
9
  def cli():
10
- """A command-line interface for cachier."""
10
+ """A command-line interface for cachier.""" # noqa: D401
11
11
 
12
12
 
13
13
  @cli.command("Limits the number of worker threads used by cachier.")
@@ -17,6 +17,8 @@ def _default_hash_func(args, kwds):
17
17
 
18
18
 
19
19
  class Params(TypedDict):
20
+ """Type definition for cachier parameters."""
21
+
20
22
  caching_enabled: bool
21
23
  hash_func: HashFunc
22
24
  backend: Backend
@@ -118,7 +118,7 @@ def cachier(
118
118
  wait_for_calc_timeout: Optional[int] = None,
119
119
  allow_none: Optional[bool] = None,
120
120
  ):
121
- """A persistent, stale-free memoization decorator.
121
+ """Wrap as a persistent, stale-free memoization decorator.
122
122
 
123
123
  The positional and keyword arguments to the wrapped function must be
124
124
  hashable (i.e. Python's immutable built-in objects, not mutable
@@ -127,13 +127,14 @@ def cachier(
127
127
  value is their id), equal objects across different sessions will not yield
128
128
  identical keys.
129
129
 
130
- Arguments
130
+ Arguments:
131
131
  ---------
132
132
  hash_func : callable, optional
133
133
  A callable that gets the args and kwargs from the decorated function
134
134
  and returns a hash key for them. This parameter can be used to enable
135
135
  the use of cachier with functions that get arguments that are not
136
136
  automatically hashable by Python.
137
+ hash_params : callable, optional
137
138
  backend : str, optional
138
139
  The name of the backend to use. Valid options currently include
139
140
  'pickle', 'mongo' and 'memory'. If not provided, defaults to
@@ -244,8 +245,12 @@ def cachier(
244
245
  if verbose:
245
246
  _print = print
246
247
  if ignore_cache or not _default_params["caching_enabled"]:
247
- return func(**kwargs)
248
- key, entry = core.get_entry(tuple(), kwargs)
248
+ return (
249
+ func(args[0], **kwargs)
250
+ if core.func_is_method
251
+ else func(**kwargs)
252
+ )
253
+ key, entry = core.get_entry((), kwargs)
249
254
  if overwrite_cache:
250
255
  return _calc_entry(core, key, func, args, kwds)
251
256
  if entry is None:
@@ -294,17 +299,17 @@ def cachier(
294
299
  core.clear_cache()
295
300
 
296
301
  def _clear_being_calculated():
297
- """Marks all entries in this cache as not being calculated."""
302
+ """Mark all entries in this cache as not being calculated."""
298
303
  core.clear_being_calculated()
299
304
 
300
305
  def _cache_dpath():
301
- """Returns the path to the cache dir, if exists; None if not."""
306
+ """Return the path to the cache dir, if exists; None if not."""
302
307
  return getattr(core, "cache_dir", None)
303
308
 
304
- def _precache_value(*args, value_to_cache, **kwds):
309
+ def _precache_value(*args, value_to_cache, **kwds): # noqa: D417
305
310
  """Add an initial value to the cache.
306
311
 
307
- Arguments
312
+ Arguments:
308
313
  ---------
309
314
  value_to_cache : any
310
315
  entry to be written into the cache
@@ -314,7 +319,7 @@ def cachier(
314
319
  kwargs = _convert_args_kwargs(
315
320
  func, _is_method=core.func_is_method, args=args, kwds=kwds
316
321
  )
317
- return core.precache_value(tuple(), kwargs, value_to_cache)
322
+ return core.precache_value((), kwargs, value_to_cache)
318
323
 
319
324
  func_wrapper.clear_cache = _clear_cache
320
325
  func_wrapper.clear_being_calculated = _clear_being_calculated
@@ -16,6 +16,8 @@ from ..config import _update_with_defaults
16
16
 
17
17
 
18
18
  class RecalculationNeeded(Exception):
19
+ """Exception raised when a recalculation is needed."""
20
+
19
21
  pass
20
22
 
21
23
 
@@ -32,7 +34,7 @@ class _BaseCore:
32
34
  self.lock = threading.RLock()
33
35
 
34
36
  def set_func(self, func):
35
- """Sets the function this core will use.
37
+ """Set the function this core will use.
36
38
 
37
39
  This has to be set before any method is called. Also determine if the
38
40
  function is an object method.
@@ -46,17 +48,21 @@ class _BaseCore:
46
48
  self.func = func
47
49
 
48
50
  def get_key(self, args, kwds):
49
- """Returns a unique key based on the arguments provided."""
51
+ """Return a unique key based on the arguments provided."""
50
52
  return self.hash_func(args, kwds)
51
53
 
52
54
  def get_entry(self, args, kwds):
53
- """Returns the result mapped to the given arguments in this core's
54
- cache, if such a mapping exists."""
55
+ """Get entry based on given arguments.
56
+
57
+ Return the result mapped to the given arguments in this core's cache,
58
+ if such a mapping exists.
59
+
60
+ """
55
61
  key = self.get_key(args, kwds)
56
62
  return self.get_entry_by_key(key)
57
63
 
58
64
  def precache_value(self, args, kwds, value_to_cache):
59
- """Writes a precomputed value into the cache."""
65
+ """Write a precomputed value into the cache."""
60
66
  key = self.get_key(args, kwds)
61
67
  self.set_entry(key, value_to_cache)
62
68
  return value_to_cache
@@ -71,30 +77,33 @@ class _BaseCore:
71
77
 
72
78
  @abc.abstractmethod
73
79
  def get_entry_by_key(self, key):
74
- """Returns the result mapped to the given key in this core's cache, if
75
- such a mapping exists."""
80
+ """Get entry based on given key.
81
+
82
+ Return the result mapped to the given key in this core's cache, if such
83
+ a mapping exists.
84
+
85
+ """
76
86
 
77
87
  @abc.abstractmethod
78
88
  def set_entry(self, key, func_res):
79
- """Maps the given result to the given key in this core's cache."""
89
+ """Map the given result to the given key in this core's cache."""
80
90
 
81
91
  @abc.abstractmethod
82
92
  def mark_entry_being_calculated(self, key):
83
- """Marks the entry mapped by the given key as being calculated."""
93
+ """Mark the entry mapped by the given key as being calculated."""
84
94
 
85
95
  @abc.abstractmethod
86
96
  def mark_entry_not_calculated(self, key):
87
- """Marks the entry mapped by the given key as not being calculated."""
97
+ """Mark the entry mapped by the given key as not being calculated."""
88
98
 
89
99
  @abc.abstractmethod
90
100
  def wait_on_entry_calc(self, key):
91
- """Waits on the entry mapped by key being calculated and returns
92
- result."""
101
+ """Wait on the entry with keys being calculated and returns result."""
93
102
 
94
103
  @abc.abstractmethod
95
104
  def clear_cache(self):
96
- """Clears the cache of this core."""
105
+ """Clear the cache of this core."""
97
106
 
98
107
  @abc.abstractmethod
99
108
  def clear_being_calculated(self):
100
- """Marks all entries in this cache as not being calculated."""
109
+ """Mark all entries in this cache as not being calculated."""
@@ -41,8 +41,9 @@ class _MongoCore(_BaseCore):
41
41
  ):
42
42
  if "pymongo" not in sys.modules:
43
43
  warnings.warn(
44
- "Cachier warning: pymongo was not found. "
45
- "MongoDB cores will not function."
44
+ "`pymongo` was not found. MongoDB cores will not function.",
45
+ ImportWarning,
46
+ stacklevel=2,
46
47
  ) # pragma: no cover
47
48
 
48
49
  super().__init__(hash_func, wait_for_calc_timeout)
@@ -62,11 +62,11 @@ class _PickleCore(_BaseCore):
62
62
  self.observer.stop()
63
63
 
64
64
  def on_created(self, event):
65
- """A Watchdog Event Handler method."""
65
+ """A Watchdog Event Handler method.""" # noqa: D401
66
66
  self._check_calculation() # pragma: no cover
67
67
 
68
68
  def on_modified(self, event):
69
- """A Watchdog Event Handler method."""
69
+ """A Watchdog Event Handler method.""" # noqa: D401
70
70
  self._check_calculation()
71
71
 
72
72
  def __init__(
@@ -115,9 +115,9 @@ class _PickleCore(_BaseCore):
115
115
  self._reload_cache()
116
116
  return self.cache
117
117
 
118
- def _get_cache_by_key(self, key=None, hash=None):
118
+ def _get_cache_by_key(self, key=None, hash_str=None):
119
119
  fpath = self.cache_fpath
120
- fpath += f"_{key}" if hash is None else f"_{hash}"
120
+ fpath += f"_{hash_str or key}"
121
121
  try:
122
122
  with portalocker.Lock(fpath, mode="rb") as cache_file:
123
123
  return pickle.load(cache_file) # noqa: S301
@@ -134,17 +134,17 @@ class _PickleCore(_BaseCore):
134
134
  path, name = os.path.split(self.cache_fpath)
135
135
  for subpath in os.listdir(path):
136
136
  if subpath.startswith(name):
137
- entry = self._get_cache_by_key(hash=subpath.split("_")[-1])
137
+ entry = self._get_cache_by_key(hash_str=subpath.split("_")[-1])
138
138
  if entry is not None:
139
139
  entry["being_calculated"] = False
140
- self._save_cache(entry, hash=subpath.split("_")[-1])
140
+ self._save_cache(entry, hash_str=subpath.split("_")[-1])
141
141
 
142
- def _save_cache(self, cache, key=None, hash=None):
142
+ def _save_cache(self, cache, key=None, hash_str=None):
143
143
  fpath = self.cache_fpath
144
144
  if key is not None:
145
145
  fpath += f"_{key}"
146
- elif hash is not None:
147
- fpath += f"_{hash}"
146
+ elif hash_str is not None:
147
+ fpath += f"_{hash_str}"
148
148
  with self.lock:
149
149
  self.cache = cache
150
150
  with portalocker.Lock(fpath, mode="wb") as cache_file:
@@ -0,0 +1 @@
1
+ 3.0.1
@@ -1,33 +1,50 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cachier
3
- Version: 3.0.0
3
+ Version: 3.0.1
4
4
  Summary: Persistent, stale-free, local and cross-machine caching for Python functions.
5
- Home-page: https://github.com/python-cachier/cachier
6
- Author: Shay Palachy & al.
7
- Author-email: shay.palachy@gmail.com
8
- License: MIT
9
- Keywords: cache,persistence,mongo,memoization,decorator
10
- Platform: linux
11
- Platform: osx
12
- Platform: windows
5
+ Author-email: Shay Palachy Affek <shay.palachy@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2016 Shay Palachy
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Source, https://github.com/python-cachier/cachier
29
+ Keywords: cache,caching,cross-machine,decorator,local,memoization,mongo,persistent
13
30
  Classifier: Development Status :: 4 - Beta
31
+ Classifier: Intended Audience :: Developers
14
32
  Classifier: License :: OSI Approved :: MIT License
15
33
  Classifier: Programming Language :: Python
16
- Classifier: Programming Language :: Python :: 3
34
+ Classifier: Programming Language :: Python :: 3 :: Only
17
35
  Classifier: Programming Language :: Python :: 3.8
18
36
  Classifier: Programming Language :: Python :: 3.9
19
37
  Classifier: Programming Language :: Python :: 3.10
20
38
  Classifier: Programming Language :: Python :: 3.11
21
39
  Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: Other/Nonlisted Topic
22
41
  Classifier: Topic :: Software Development :: Libraries
23
42
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
43
  Classifier: Topic :: Utilities
25
- Classifier: Topic :: Other/Nonlisted Topic
26
- Classifier: Intended Audience :: Developers
44
+ Description-Content-Type: text/x-rst
27
45
  License-File: LICENSE
28
- Requires-Dist: watchdog>=2.3.1
29
46
  Requires-Dist: portalocker>=2.3.2
30
- Requires-Dist: setuptools>=67.6.0
47
+ Requires-Dist: watchdog>=2.3.1
31
48
 
32
49
  Cachier
33
50
  #######
@@ -492,8 +509,8 @@ Notable bugfixers:
492
509
  .. |PyPI-Versions| image:: https://img.shields.io/pypi/pyversions/cachier.svg
493
510
  :target: https://pypi.python.org/pypi/cachier
494
511
 
495
- .. |Build-Status| image:: https://github.com/python-cachier/cachier/actions/workflows/test.yml/badge.svg
496
- :target: https://github.com/python-cachier/cachier/actions/workflows/test.yml
512
+ .. |Build-Status| image:: https://github.com/python-cachier/cachier/actions/workflows/ci-test.yml/badge.svg
513
+ :target: https://github.com/python-cachier/cachier/actions/workflows/ci-test.yml
497
514
 
498
515
  .. |LICENCE| image:: https://img.shields.io/pypi/l/cachier.svg
499
516
  :target: https://pypi.python.org/pypi/cachier
@@ -0,0 +1,23 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.rst
4
+ pyproject.toml
5
+ src/cachier/__init__.py
6
+ src/cachier/__main__.py
7
+ src/cachier/_types.py
8
+ src/cachier/_version.py
9
+ src/cachier/config.py
10
+ src/cachier/core.py
11
+ src/cachier/py.typed
12
+ src/cachier/version.info
13
+ src/cachier.egg-info/PKG-INFO
14
+ src/cachier.egg-info/SOURCES.txt
15
+ src/cachier.egg-info/dependency_links.txt
16
+ src/cachier.egg-info/entry_points.txt
17
+ src/cachier.egg-info/requires.txt
18
+ src/cachier.egg-info/top_level.txt
19
+ src/cachier/cores/__init__.py
20
+ src/cachier/cores/base.py
21
+ src/cachier/cores/memory.py
22
+ src/cachier/cores/mongo.py
23
+ src/cachier/cores/pickle.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cachier = cachier.__main__:cli
@@ -1,3 +1,2 @@
1
- watchdog>=2.3.1
2
1
  portalocker>=2.3.2
3
- setuptools>=67.6.0
2
+ watchdog>=2.3.1
@@ -1 +0,0 @@
1
- 3.0.0
@@ -1,25 +0,0 @@
1
- LICENSE
2
- MANIFEST.in
3
- README.rst
4
- pyproject.toml
5
- requirements.txt
6
- setup.py
7
- cachier/__init__.py
8
- cachier/__main__.py
9
- cachier/_types.py
10
- cachier/_version.py
11
- cachier/config.py
12
- cachier/core.py
13
- cachier/py.typed
14
- cachier/version.info
15
- cachier.egg-info/PKG-INFO
16
- cachier.egg-info/SOURCES.txt
17
- cachier.egg-info/dependency_links.txt
18
- cachier.egg-info/entry_points.txt
19
- cachier.egg-info/requires.txt
20
- cachier.egg-info/top_level.txt
21
- cachier/cores/__init__.py
22
- cachier/cores/base.py
23
- cachier/cores/memory.py
24
- cachier/cores/mongo.py
25
- cachier/cores/pickle.py
@@ -1,2 +0,0 @@
1
- [console_scripts]
2
- cachier = cachier.__naim__:cli
@@ -1,78 +0,0 @@
1
- [metadata]
2
- license_file = "LICENSE"
3
- description-file = "README.md"
4
-
5
- [build-system]
6
- requires = ["setuptools", "wheel"]
7
-
8
-
9
- [tool.pytest.ini_options]
10
- testpaths = ["cachier", "tests"]
11
- norecursedirs=["dist", "build"]
12
- addopts = [
13
- "--color=yes",
14
- "--cov=cachier",
15
- "--cov-report=term",
16
- "--cov-report=xml:cov.xml",
17
- "-r a",
18
- "-v",
19
- "-s",
20
- ]
21
- markers = [
22
- "mongo: test the MongoDB core",
23
- "memory: test the memory core",
24
- "pickle: test the pickle core",
25
- ]
26
-
27
-
28
- [tool.docformatter]
29
- recursive = true
30
- # some docstring start with r"""
31
- wrap-summaries = 79
32
- wrap-descriptions = 79
33
- blank = true
34
-
35
- [tool.ruff]
36
- target-version = "py38"
37
- line-length = 79
38
- # Enable Pyflakes `E` and `F` codes by default.
39
- lint.select = [
40
- "E",
41
- "W", # see: https://pypi.org/project/pycodestyle
42
- "F", # see: https://pypi.org/project/pyflakes
43
- "I", #see: https://pypi.org/project/isort/
44
- # "D", # see: https://pypi.org/project/pydocstyle
45
- # "N", # see: https://pypi.org/project/pep8-naming
46
- "S", # see: https://pypi.org/project/flake8-bandit
47
- "SIM",
48
- ]
49
- lint.ignore = [
50
- "E203",
51
- "C901",
52
- ]
53
- # Exclude a variety of commonly ignored directories.
54
- exclude = [
55
- ".eggs",
56
- ".git",
57
- ".ruff_cache",
58
- "__pypackages__",
59
- "_build",
60
- "build",
61
- "dist",
62
- ]
63
- lint.ignore-init-module-imports = true
64
- lint.unfixable = ["F401"]
65
-
66
- [tool.ruff.lint.per-file-ignores]
67
- "tests/**" = ["S101", "S311", "S105", "S603"]
68
-
69
- #[tool.ruff.pydocstyle]
70
- ## Use Google-style docstrings.
71
- #convention = "google"
72
-
73
- #[tool.ruff.pycodestyle]
74
- #ignore-overlong-task-comments = true
75
-
76
- [tool.ruff.lint.mccabe]
77
- # Unlike Flake8, default to a complexity level of 10.
78
- max-complexity = 10
@@ -1,3 +0,0 @@
1
- watchdog >=2.3.1
2
- portalocker >=2.3.2
3
- setuptools >=67.6.0 # to avoid vulnerability in 56.0.0
cachier-3.0.0/setup.py DELETED
@@ -1,84 +0,0 @@
1
- """Setup file for the Cachier package."""
2
-
3
- # This file is part of Cachier.
4
- # https://github.com/shaypal5/cachier
5
-
6
- # Licensed under the MIT license:
7
- # http://www.opensource.org/licenses/MIT-license
8
- # Copyright (c) 2016, Shay Palachy <shaypal5@gmail.com>
9
- # Copyright (c) 2024, Jirka Borovec <***@gmail.com>
10
-
11
- import os.path
12
- from importlib.util import module_from_spec, spec_from_file_location
13
-
14
- from pkg_resources import parse_requirements
15
- from setuptools import find_packages, setup
16
-
17
- _PATH_HERE = os.path.dirname(__file__)
18
-
19
-
20
- def _load_py_module(fname: str, pkg: str = "torchmetrics"):
21
- spec = spec_from_file_location(
22
- os.path.join("cachier", fname),
23
- os.path.join(_PATH_HERE, "cachier", fname),
24
- )
25
- py = module_from_spec(spec)
26
- spec.loader.exec_module(py)
27
- return py
28
-
29
-
30
- with open(os.path.join(_PATH_HERE, "README.rst")) as fp:
31
- README_RST = fp.read()
32
-
33
-
34
- _version = _load_py_module("_version.py")
35
-
36
-
37
- def _load_requirements(
38
- path_dir: str = _PATH_HERE, file_name: str = "requirements.txt"
39
- ) -> list:
40
- with open(os.path.join(path_dir, file_name)) as fp:
41
- reqs = parse_requirements(fp.readlines())
42
- return list(map(str, reqs))
43
-
44
-
45
- setup(
46
- name="cachier",
47
- version=_version.__version__,
48
- description=(
49
- "Persistent, stale-free, local and cross-machine caching for"
50
- " Python functions."
51
- ),
52
- long_description=README_RST,
53
- license="MIT",
54
- author="Shay Palachy & al.",
55
- author_email="shay.palachy@gmail.com",
56
- url="https://github.com/python-cachier/cachier",
57
- packages=find_packages(exclude=["tests"]),
58
- include_package_data=True,
59
- entry_points="""
60
- [console_scripts]
61
- cachier=cachier.__naim__:cli
62
- """,
63
- install_requires=_load_requirements(),
64
- platforms=["linux", "osx", "windows"],
65
- keywords=["cache", "persistence", "mongo", "memoization", "decorator"],
66
- classifiers=[
67
- # Trove classifiers
68
- # (https://pypi.python.org/pypi?%3Aaction=list_classifiers)
69
- "Development Status :: 4 - Beta",
70
- "License :: OSI Approved :: MIT License",
71
- "Programming Language :: Python",
72
- "Programming Language :: Python :: 3",
73
- "Programming Language :: Python :: 3.8",
74
- "Programming Language :: Python :: 3.9",
75
- "Programming Language :: Python :: 3.10",
76
- "Programming Language :: Python :: 3.11",
77
- "Programming Language :: Python :: 3.12",
78
- "Topic :: Software Development :: Libraries",
79
- "Topic :: Software Development :: Libraries :: Python Modules",
80
- "Topic :: Utilities",
81
- "Topic :: Other/Nonlisted Topic",
82
- "Intended Audience :: Developers",
83
- ],
84
- )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes