Changeset 47134ca in rattail


Ignore:
Timestamp:
07/19/2020 06:51:36 PM (3 years ago)
Author:
Lance Edgar <lance@…>
Branches:
master
Children:
3d85857e
Parents:
360f99a
Message:

Add can_delete_object() method for importers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rattail/importing/importers.py

    r360f99a r47134ca  
    597597        set, or an empty set if local data isn't cached.
    598598        """
    599         if self.caches_local_data and self.cached_local_data is not None:
    600             return set(self.cached_local_data)
    601         return set()
     599        if not self.caches_local_data:
     600            return set()
     601
     602        if self.cached_local_data is None:
     603            return set()
     604
     605        all_keys = set(self.cached_local_data)
     606        keys = set()
     607
     608        def check(key, i):
     609            data = self.cached_local_data[key]['data']
     610            obj = self.cached_local_data[key]['object']
     611            if self.can_delete_object(obj, data):
     612                keys.add(key)
     613
     614        self.progress_loop(check, all_keys,
     615                           message="Determining which objects can be deleted")
     616        return keys
     617
     618    def can_delete_object(self, obj, data):
     619        return True
    602620
    603621    def delete_object(self, obj):
Note: See TracChangeset for help on using the changeset viewer.