Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-tinydb for openSUSE:Factory checked in at 2021-04-10 15:27:04 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-tinydb (Old) and /work/SRC/openSUSE:Factory/.python-tinydb.new.2401 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-tinydb" Sat Apr 10 15:27:04 2021 rev:9 rq:883213 version:4.4.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-tinydb/python-tinydb.changes 2020-10-13 15:43:35.345396444 +0200 +++ /work/SRC/openSUSE:Factory/.python-tinydb.new.2401/python-tinydb.changes 2021-04-10 15:28:06.322429842 +0200 @@ -1,0 +2,19 @@ +Sun Apr 4 23:28:01 UTC 2021 - Arun Persaud <[email protected]> + +- specfile: + * update copyright year + +- update to version 4.4.0: + * Feature: Add operation for searching for all documents that match + a dict fragment (see issue 300) + * Fix: Correctly handle queries that use fields that are also Query + methods, e.g. Query()['test'] for searching for documents with a + test field (see issue 373) + +- changes from version 4.3.0: + * Feature: Add operation for updating multiple documents: + update_multiple (see issue 346) + * Improvement: Expose type information for MyPy typechecking (PEP + 561) (see pull request 352) + +------------------------------------------------------------------- Old: ---- tinydb-4.2.0.tar.gz New: ---- tinydb-4.4.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-tinydb.spec ++++++ --- /var/tmp/diff_new_pack.JDeiS8/_old 2021-04-10 15:28:06.814430421 +0200 +++ /var/tmp/diff_new_pack.JDeiS8/_new 2021-04-10 15:28:06.814430421 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-tinydb # -# Copyright (c) 2020 SUSE LLC +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} %define skip_python2 1 Name: python-tinydb -Version: 4.2.0 +Version: 4.4.0 Release: 0 Summary: A document-oriented database License: MIT ++++++ tinydb-4.2.0.tar.gz -> tinydb-4.4.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tinydb-4.2.0/PKG-INFO new/tinydb-4.4.0/PKG-INFO --- old/tinydb-4.2.0/PKG-INFO 2020-10-03 16:59:35.037635000 +0200 +++ new/tinydb-4.4.0/PKG-INFO 2021-02-11 20:31:23.965108600 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: tinydb -Version: 4.2.0 +Version: 4.4.0 Summary: TinyDB is a tiny, document oriented database optimized for your happiness :) Home-page: https://github.com/msiemens/tinydb License: MIT @@ -24,6 +24,7 @@ Classifier: Topic :: Database Classifier: Topic :: Database :: Database Engines/Servers Classifier: Topic :: Utilities +Classifier: Typing :: Typed Project-URL: Changelog, https://github.com/msiemens/tinydb/en/latest/changelog.html Project-URL: Documentation, https://tinydb.readthedocs.org/ Project-URL: Issues, https://github.com/msiemens/tinydb/issues diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tinydb-4.2.0/pyproject.toml new/tinydb-4.4.0/pyproject.toml --- old/tinydb-4.2.0/pyproject.toml 2020-10-03 16:59:11.345498000 +0200 +++ new/tinydb-4.4.0/pyproject.toml 2021-02-11 20:30:49.629945300 +0100 @@ -1,6 +1,6 @@ [tool.poetry] name = "tinydb" -version = "4.2.0" +version = "4.4.0" description = "TinyDB is a tiny, document oriented database optimized for your happiness :)" authors = ["Markus Siemens <[email protected]>"] license = "MIT" @@ -24,9 +24,12 @@ "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Operating System :: OS Independent", + "Typing :: Typed", ] packages = [ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tinydb-4.2.0/setup.py new/tinydb-4.4.0/setup.py --- old/tinydb-4.2.0/setup.py 2020-10-03 16:59:35.037083600 +0200 +++ new/tinydb-4.4.0/setup.py 2021-02-11 20:31:23.964544000 +0100 @@ -9,7 +9,7 @@ setup_kwargs = { 'name': 'tinydb', - 'version': '4.2.0', + 'version': '4.4.0', 'description': 'TinyDB is a tiny, document oriented database optimized for your happiness :)', 'long_description': ".. image:: https://raw.githubusercontent.com/msiemens/tinydb/master/artwork/logo.png\n :scale: 100%\n :height: 150px\n\n|Build Status| |Coverage| |Version|\n\nQuick Links\n***********\n\n- `Example Code`_\n- `Supported Python Versions`_\n- `Documentation <http://tinydb.readthedocs.org/>`_\n- `Changelog <https://tinydb.readthedocs.io/en/latest/changelog.html>`_\n- `Extensions <https://tinydb.readthedocs.io/en/latest/extensions.html>`_\n- `Contributing`_\n\nIntroduction\n************\n\nTinyDB is a lightweight document oriented database optimized for your happiness :)\nIt's written in pure Python and has no external dependencies. The target are\nsmall apps that would be blown away by a SQL-DB or an external database server.\n\nTinyDB is:\n\n- **tiny:** The current source code has 1800 lines of code (with about 40%\n documentation) and 1600 lines tests.\n\n- **document oriented:** Like MongoDB_, you can store any document\n (represented as ``dict``) in TinyDB.\n\n- **optimized for your happiness:** TinyDB is designed to be simple and\n fun to use by providing a simple and clean API.\n\n- **written in pure Python:** TinyDB neither needs an external server (as\n e.g. `PyMongo <https://api.mongodb.org/python/current/>`_) nor any dependencies\n from PyPI.\n\n- **works on Python 3.5+ and PyPy:** TinyDB works on all modern versions of Python\n and PyPy.\n\n- **powerfully extensible:** You can easily extend TinyDB by writing new\n storages or modify the behaviour of storages with Middlewares.\n\n- **100% test coverage:** No explanation needed.\n\nTo dive straight into all the details, head over to the `TinyDB docs\n<https://tinydb.readthedocs.io/>`_. You can also discuss everything related\nto TinyDB like general development, extensions or showcase your TinyDB-based\nprojects on the `discussion forum <http://forum.m-siemens.de/.>`_.\n\nSupported Python Versions\n*************************\n\nTinyDB has been tested with Python 3.5 - 3 .8 and PyPy.\n\nExample Code\n************\n\n.. code-block:: python\n\n >>> from tinydb import TinyDB, Query\n >>> db = TinyDB('/path/to/db.json')\n >>> db.insert({'int': 1, 'char': 'a'})\n >>> db.insert({'int': 1, 'char': 'b'})\n\nQuery Language\n==============\n\n.. code-block:: python\n\n >>> User = Query()\n >>> # Search for a field value\n >>> db.search(User.name == 'John')\n [{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}]\n\n >>> # Combine two queries with logical and\n >>> db.search((User.name == 'John') & (User.age <= 30))\n [{'name': 'John', 'age': 22}]\n\n >>> # Combine two queries with logical or\n >>> db.search((User.name == 'John') | (User.name == 'Bob'))\n [{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}, {'name': 'Bob', 'age': 42}]\n\n >>> # More possible comparisons: != < > <= >=\n >>> # More possible checks: where(...).matches(regex), where(...).test(your_test_func)\n\nTables\n======\n\n.. cod e-block:: python\n\n >>> table = db.table('name')\n >>> table.insert({'value': True})\n >>> table.all()\n [{'value': True}]\n\nUsing Middlewares\n=================\n\n.. code-block:: python\n\n >>> from tinydb.storages import JSONStorage\n >>> from tinydb.middlewares import CachingMiddleware\n >>> db = TinyDB('/path/to/db.json', storage=CachingMiddleware(JSONStorage))\n\n\nContributing\n************\n\nWhether reporting bugs, discussing improvements and new ideas or writing\nextensions: Contributions to TinyDB are welcome! Here's how to get started:\n\n1. Check for open issues or open a fresh issue to start a discussion around\n a feature idea or a bug\n2. Fork `the repository <https://github.com/msiemens/tinydb/>`_ on Github,\n create a new branch off the `master` branch and start making your changes\n (known as `GitHub Flow <https://guides.github.com/introduction/flow/index.html>`_)\n3. Write a test which shows that the bug was fixed or that the feature works\n as expected\n4. Send a pull request and bug the maintainer until it gets merged and\n published ???\n\n.. |Build Status| image:: https://img.shields.io/azure-devops/build/msiemens/3e5baa75-12ec-43ac-9728-89823ee8c7e2/2.svg?style=flat-square\n :target: https://dev.azure.com/msiemens/github/_build?definitionId=2\n.. |Coverage| image:: http://img.shields.io/coveralls/msiemens/tinydb.svg?style=flat-square\n :target: https://coveralls.io/r/msiemens/tinydb\n.. |Version| image:: http://img.shields.io/pypi/v/tinydb.svg?style=flat-square\n :target: https://pypi.python.org/pypi/tinydb/\n.. _Buzhug: http://buzhug.sourceforge.net/\n.. _CodernityDB: https://github.com/perchouli/codernitydb\n.. _MongoDB: http://mongodb.org/\n", 'author': 'Markus Siemens', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tinydb-4.2.0/tinydb/database.py new/tinydb-4.4.0/tinydb/database.py --- old/tinydb-4.2.0/tinydb/database.py 2020-10-03 16:59:11.345498000 +0200 +++ new/tinydb-4.4.0/tinydb/database.py 2021-02-11 20:30:49.633945200 +0100 @@ -25,7 +25,7 @@ When creating a new instance, all arguments and keyword arguments (except for ``storage``) will be passed to the storage class that is provided. If - no storage class is specified, :class:`~tinydb.storages.JSONStorage` wil be + no storage class is specified, :class:`~tinydb.storages.JSONStorage` will be used. .. admonition:: Customization @@ -78,7 +78,7 @@ #: .. versionadded:: 4.0 default_storage_class = JSONStorage - def __init__(self, *args, **kwargs): + def __init__(self, *args, **kwargs) -> None: """ Create a new instance of TinyDB. """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tinydb-4.2.0/tinydb/queries.py new/tinydb-4.4.0/tinydb/queries.py --- old/tinydb-4.2.0/tinydb/queries.py 2020-10-03 16:59:11.345498000 +0200 +++ new/tinydb-4.4.0/tinydb/queries.py 2021-02-11 20:30:49.633945200 +0100 @@ -127,9 +127,9 @@ ``False`` depending on whether the documents matches the query or not. """ - def __init__(self): + def __init__(self) -> None: # The current path of fields to access when evaluating the object - self._path = () + self._path = () # type: Tuple[str, ...] # Prevent empty queries to be evaluated def notest(_): @@ -162,12 +162,20 @@ def __getitem__(self, item: str): # A different syntax for ``__getattr__`` - return getattr(self, item) + + # We cannot call ``getattr(item)`` here as it would try to resolve + # the name as a method name first, only then call our ``__getattr__`` + # method. By calling ``__getattr__`` directly, we make sure that + # calling e.g. ``Query()['test']`` will always generate a query for a + # document's ``test`` field instead of returning a reference to the + # ``Query.test`` method + return self.__getattr__(item) def _generate_test( self, test: Callable[[Any], bool], hashval: Tuple, + allow_empty_path: bool = False ) -> QueryInstance: """ Generate a query based on a test function that first resolves the query @@ -177,7 +185,7 @@ :param hashval: The hash of the query. :return: A :class:`~tinydb.queries.QueryInstance` object """ - if not self._path: + if not self._path and not allow_empty_path: raise ValueError('Query has no path') def runner(value): @@ -427,6 +435,20 @@ ('one_of', self._path, freeze(items)) ) + def fragment(self, document: Mapping) -> QueryInstance: + def test(value): + for key in document: + if key not in value or value[key] != document[key]: + return False + + return True + + return self._generate_test( + lambda value: test(value), + ('fragment', freeze(document)), + allow_empty_path=True + ) + def noop(self) -> QueryInstance: """ Always evaluate to ``True``. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tinydb-4.2.0/tinydb/table.py new/tinydb-4.4.0/tinydb/table.py --- old/tinydb-4.2.0/tinydb/table.py 2020-10-03 16:59:11.345498000 +0200 +++ new/tinydb-4.4.0/tinydb/table.py 2021-02-11 20:30:49.633945200 +0100 @@ -12,7 +12,8 @@ Mapping, Optional, Union, - cast + cast, + Tuple ) from .storages import Storage @@ -224,10 +225,9 @@ # First, we check the query cache to see if it has results for this # query - if cond in self._query_cache: - docs = self._query_cache.get(cond) - if docs is not None: - return docs[:] + cached_results = self._query_cache.get(cond) + if cached_results is not None: + return cached_results[:] # Perform the search by applying the query to all documents docs = [doc for doc in self if cond(doc)] @@ -389,6 +389,58 @@ return updated_ids + def update_multiple( + self, + updates: Iterable[ + Tuple[Union[Mapping, Callable[[Mapping], None]], Query] + ], + ) -> List[int]: + """ + Update all matching documents to have a given set of fields. + + :returns: a list containing the updated document's ID + """ + + # Define the function that will perform the update + def perform_update(fields, table, doc_id): + if callable(fields): + # Update documents by calling the update function provided + # by the user + fields(table[doc_id]) + else: + # Update documents by setting all fields from the provided + # data + table[doc_id].update(fields) + + # Perform the update operation for documents specified by a query + + # Collect affected doc_ids + updated_ids = [] + + def updater(table: dict): + # We need to convert the keys iterator to a list because + # we may remove entries from the ``table`` dict during + # iteration and doing this without the list conversion would + # result in an exception (RuntimeError: dictionary changed size + # during iteration) + for doc_id in list(table.keys()): + for fields, cond in updates: + _cond = cast('Query', cond) + + # Pass through all documents to find documents matching the + # query. Call the processing callback with the document ID + if _cond(table[doc_id]): + # Add ID to list of updated documents + updated_ids.append(doc_id) + + # Perform the update (see above) + perform_update(fields, table, doc_id) + + # Perform the update operation (see _update_table for details) + self._update_table(updater) + + return updated_ids + def upsert(self, document: Mapping, cond: Query) -> List[int]: """ Update a document, if it exist, insert it otherwise. @@ -423,9 +475,6 @@ :param doc_ids: a list of document IDs :returns: a list containing the removed documents' ID """ - if cond is None and doc_ids is None: - raise RuntimeError('Use truncate() to remove all documents') - if cond is not None: removed_ids = [] @@ -475,7 +524,7 @@ return removed_ids - raise RuntimeError('This should never happen') + raise RuntimeError('Use truncate() to remove all documents') def truncate(self) -> None: """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/tinydb-4.2.0/tinydb/version.py new/tinydb-4.4.0/tinydb/version.py --- old/tinydb-4.2.0/tinydb/version.py 2020-10-03 16:59:11.345498000 +0200 +++ new/tinydb-4.4.0/tinydb/version.py 2021-02-11 20:30:49.633945200 +0100 @@ -1 +1 @@ -__version__ = '4.2.0' +__version__ = '4.4.0'
