Beispiel #1
0
 def _get_list_of_descrs(self):
     descrs = []
     for item in self._items:
         item_descrs = item.keys()
         sort_descrs(item_descrs)
         descrs.append(item_descrs)
     return descrs
Beispiel #2
0
 def _get_field_descr_list(self):
     _cached_sorted_fields = self._cached_sorted_fields
     if self._fields is None:
         nfields = 0
     else:
         nfields = len(self._fields)
     if (_cached_sorted_fields is not None
             and nfields == len(_cached_sorted_fields)):
         lst = self._cached_sorted_fields
     else:
         if self._fields is None:
             lst = []
         else:
             lst = self._fields.keys()
         sort_descrs(lst)
         cache = get_fielddescrlist_cache(self.cpu)
         result = cache.get(lst, None)
         if result is None:
             cache[lst] = lst
         else:
             lst = result
         # store on self, to not have to repeatedly get it from the global
         # cache, which involves sorting
         self._cached_sorted_fields = lst
     return lst
Beispiel #3
0
 def _get_list_of_descrs(self):
     descrs = []
     for item in self._items:
         item_descrs = item.keys()
         sort_descrs(item_descrs)
         descrs.append(item_descrs)
     return descrs
Beispiel #4
0
 def _get_field_descr_list(self):
     _cached_sorted_fields = self._cached_sorted_fields
     if self._fields is None:
         nfields = 0
     else:
         nfields = len(self._fields)
     if (_cached_sorted_fields is not None and
         nfields == len(_cached_sorted_fields)):
         lst = self._cached_sorted_fields
     else:
         if self._fields is None:
             lst = []
         else:
             lst = self._fields.keys()
         sort_descrs(lst)
         cache = get_fielddescrlist_cache(self.cpu)
         result = cache.get(lst, None)
         if result is None:
             cache[lst] = lst
         else:
             lst = result
         # store on self, to not have to repeatedly get it from the global
         # cache, which involves sorting
         self._cached_sorted_fields = lst
     return lst
Beispiel #5
0
def test_sort_descrs():
    class PseudoDescr(AbstractDescr):
        def __init__(self, n):
            self.n = n
        def sort_key(self):
            return self.n
    for i in range(17):
        lst = [PseudoDescr(j) for j in range(i)]
        lst2 = lst[:]
        random.shuffle(lst2)
        sort_descrs(lst2)
        assert lst2 == lst
Beispiel #6
0
def test_sort_descrs():
    class PseudoDescr(AbstractDescr):
        def __init__(self, n):
            self.n = n
        def sort_key(self):
            return self.n
    for i in range(17):
        lst = [PseudoDescr(j) for j in range(i)]
        lst2 = lst[:]
        random.shuffle(lst2)
        sort_descrs(lst2)
        assert lst2 == lst