Example #1
0
    def search_asset(self, filter_values: Any) -> List[str]:
        """
            :param dict filter_values: can be a dict or a mongo type query
            :returns: a list of asset_ids found
        """

        if not isinstance(filter_values, dict):
            raise TypeError('Filter values must be a type dict')

        asset_list = self.get_metadata_list()
        filter_query = Query(filter_values)
        result = []
        if asset_list:
            for asset_id, metadata in asset_list.items():
                if filter_query.match(metadata):
                    result.append(asset_id)
        return result
Example #2
0
 def match(obj, query):
     """Returns True if object matches the mongo query, else False"""
     if not isinstance(obj, Sequence) and not isinstance(obj, Mapping):
         return False
     query = Query(query)
     return query.match(obj)