diff --git a/libs/CodernityDB3/database.py b/libs/CodernityDB3/database.py index f3493128..8de12d54 100644 --- a/libs/CodernityDB3/database.py +++ b/libs/CodernityDB3/database.py @@ -232,7 +232,7 @@ class Database(object): name = s[0][2:] c = s[1][2:] comented = ['\n\n#SIMPLIFIED CODE'] - list(map(lambda x: comented.append("#" + x), new_index.splitlines())) + list([comented.append("#" + x) for x in new_index.splitlines()]) comented.append('#SIMPLIFIED CODE END\n\n') s = header_for_indexes( @@ -1198,7 +1198,7 @@ you should check index code.""" % (index.name, ex), RuntimeWarning) raise IndexNotFoundException("Index doesn't exist") props = {} - for key, value in db_index.__dict__.items(): + for key, value in list(db_index.__dict__.items()): if not isinstance(value, collections.Callable): # not using inspect etc... props[key] = value diff --git a/libs/CodernityDB3/database_safe_shared.py b/libs/CodernityDB3/database_safe_shared.py index ec239eec..30611095 100644 --- a/libs/CodernityDB3/database_safe_shared.py +++ b/libs/CodernityDB3/database_safe_shared.py @@ -96,14 +96,14 @@ class SafeDatabase(Database): with self.close_open_lock: self.close_open_lock.acquire() res = super(SafeDatabase, self).initialize(*args, **kwargs) - for name in self.indexes_names.keys(): + for name in list(self.indexes_names.keys()): self.indexes_locks[name] = cdb_environment['rlock_obj']() return res def open(self, *args, **kwargs): with self.close_open_lock: res = super(SafeDatabase, self).open(*args, **kwargs) - for name in self.indexes_names.keys(): + for name in list(self.indexes_names.keys()): self.indexes_locks[name] = cdb_environment['rlock_obj']() self.__patch_index(name) return res @@ -111,7 +111,7 @@ class SafeDatabase(Database): def create(self, *args, **kwargs): with self.close_open_lock: res = super(SafeDatabase, self).create(*args, **kwargs) - for name in self.indexes_names.keys(): + for name in list(self.indexes_names.keys()): self.indexes_locks[name] = cdb_environment['rlock_obj']() self.__patch_index(name) return res diff --git a/libs/CodernityDB3/database_super_thread_safe.py b/libs/CodernityDB3/database_super_thread_safe.py index d909f85d..1a315c77 100644 --- a/libs/CodernityDB3/database_super_thread_safe.py +++ b/libs/CodernityDB3/database_super_thread_safe.py @@ -58,7 +58,7 @@ class SuperLock(type): else: # setattr(base, b_attr, SuperLock.wrapper(a)) new_attr[b_attr] = SuperLock.wrapper(a) - for attr_name, attr_value in attr.items(): + for attr_name, attr_value in list(attr.items()): if isinstance(attr_value, FunctionType) and not attr_name.startswith('_'): attr_value = SuperLock.wrapper(attr_value) new_attr[attr_name] = attr_value @@ -89,13 +89,13 @@ class SuperThreadSafeDatabase(Database, metaclass=SuperLock): def open(self, *args, **kwargs): res = super(SuperThreadSafeDatabase, self).open(*args, **kwargs) - for name in self.indexes_names.keys(): + for name in list(self.indexes_names.keys()): self.__patch_index_gens(name) return res def create(self, *args, **kwargs): res = super(SuperThreadSafeDatabase, self).create(*args, **kwargs) - for name in self.indexes_names.keys(): + for name in list(self.indexes_names.keys()): self.__patch_index_gens(name) return res diff --git a/libs/CodernityDB3/debug_stuff.py b/libs/CodernityDB3/debug_stuff.py index de03a7db..8cef68a2 100644 --- a/libs/CodernityDB3/debug_stuff.py +++ b/libs/CodernityDB3/debug_stuff.py @@ -30,15 +30,15 @@ class DebugTreeBasedIndex(TreeBasedIndex): super(DebugTreeBasedIndex, self).__init__(*args, **kwargs) def print_tree(self): - print '-----CURRENT TREE-----' - print self.root_flag + print('-----CURRENT TREE-----') + print(self.root_flag) if self.root_flag == 'l': - print '---ROOT---' + print('---ROOT---') self._print_leaf_data(self.data_start) return else: - print '---ROOT---' + print('---ROOT---') self._print_node_data(self.data_start) nr_of_el, children_flag = self._read_node_nr_of_elements_and_children_flag( self.data_start) @@ -48,7 +48,7 @@ class DebugTreeBasedIndex(TreeBasedIndex): self.data_start, index) nodes.append(l_pointer) nodes.append(r_pointer) - print 'ROOT NODES', nodes + print('ROOT NODES', nodes) while children_flag == 'n': self._print_level(nodes, 'n') new_nodes = [] @@ -64,7 +64,7 @@ class DebugTreeBasedIndex(TreeBasedIndex): self._print_level(nodes, 'l') def _print_level(self, nodes, flag): - print '---NEXT LVL---' + print('---NEXT LVL---') if flag == 'n': for node in nodes: self._print_node_data(node) @@ -73,18 +73,18 @@ class DebugTreeBasedIndex(TreeBasedIndex): self._print_leaf_data(node) def _print_leaf_data(self, leaf_start_position): - print 'printing data of leaf at', leaf_start_position + print('printing data of leaf at', leaf_start_position) nr_of_elements = self._read_leaf_nr_of_elements(leaf_start_position) self.buckets.seek(leaf_start_position) data = self.buckets.read(self.leaf_heading_size + nr_of_elements * self.single_leaf_record_size) leaf = struct.unpack('<' + self.leaf_heading_format + nr_of_elements * self.single_leaf_record_format, data) - print leaf - print + print(leaf) + print() def _print_node_data(self, node_start_position): - print 'printing data of node at', node_start_position + print('printing data of node at', node_start_position) nr_of_elements = self._read_node_nr_of_elements_and_children_flag( node_start_position)[0] self.buckets.seek(node_start_position) @@ -94,8 +94,8 @@ class DebugTreeBasedIndex(TreeBasedIndex): + nr_of_elements * ( self.key_format + self.pointer_format), data) - print node - print + print(node) + print() # ------------------> diff --git a/libs/CodernityDB3/index.py b/libs/CodernityDB3/index.py index 104d543b..037fe5ce 100644 --- a/libs/CodernityDB3/index.py +++ b/libs/CodernityDB3/index.py @@ -106,7 +106,7 @@ class Index(object): def _fix_params(self): self.buckets.seek(0) props = marshal.loads(self.buckets.read(self._start_ind)) - for k, v in props.items(): + for k, v in list(props.items()): self.__dict__[k] = v self.buckets.seek(0, 2) diff --git a/libs/CodernityDB3/lfu_cache.py b/libs/CodernityDB3/lfu_cache.py index 5b784808..dd2a2768 100644 --- a/libs/CodernityDB3/lfu_cache.py +++ b/libs/CodernityDB3/lfu_cache.py @@ -45,7 +45,7 @@ def cache1lvl(maxsize=100): except KeyError: if len(cache) == maxsize: for k, _ in nsmallest(maxsize // 10 or 1, - iter(use_count.items()), + iter(list(use_count.items())), key=itemgetter(1)): del cache[k], use_count[k] cache[key] = user_function(key, *args, **kwargs) @@ -76,8 +76,8 @@ def cache1lvl(maxsize=100): def twolvl_iterator(dict): - for k, v in dict.items(): - for kk, vv in v.items(): + for k, v in list(dict.items()): + for kk, vv in list(v.items()): yield k, kk, vv diff --git a/libs/CodernityDB3/lfu_cache_with_lock.py b/libs/CodernityDB3/lfu_cache_with_lock.py index 15150071..7703db0f 100644 --- a/libs/CodernityDB3/lfu_cache_with_lock.py +++ b/libs/CodernityDB3/lfu_cache_with_lock.py @@ -32,8 +32,8 @@ except ImportError: def twolvl_iterator(dict): - for k, v in dict.items(): - for kk, vv in v.items(): + for k, v in list(dict.items()): + for kk, vv in list(v.items()): yield k, kk, vv @@ -55,7 +55,7 @@ def create_cache1lvl(lock_obj): with lock: if len(cache) == maxsize: for k, _ in nsmallest(maxsize // 10 or 1, - iter(use_count.items()), + iter(list(use_count.items())), key=itemgetter(1)): del cache[k], use_count[k] cache[key] = user_function(key, *args, **kwargs) diff --git a/libs/CodernityDB3/sharded_index.py b/libs/CodernityDB3/sharded_index.py index d2fb2234..1c688d4d 100644 --- a/libs/CodernityDB3/sharded_index.py +++ b/libs/CodernityDB3/sharded_index.py @@ -82,31 +82,31 @@ class ShardedIndex(Index): return getattr(self.shards[self.last_used], name) def open_index(self): - for curr in self.shards.values(): + for curr in list(self.shards.values()): curr.open_index() def create_index(self): - for curr in self.shards.values(): + for curr in list(self.shards.values()): curr.create_index() def destroy(self): - for curr in self.shards.values(): + for curr in list(self.shards.values()): curr.destroy() def compact(self): - for curr in self.shards.values(): + for curr in list(self.shards.values()): curr.compact() def reindex(self): - for curr in self.shards.values(): + for curr in list(self.shards.values()): curr.reindex() def all(self, *args, **kwargs): - for curr in self.shards.values(): + for curr in list(self.shards.values()): for now in curr.all(*args, **kwargs): yield now def get_many(self, *args, **kwargs): - for curr in self.shards.values(): + for curr in list(self.shards.values()): for now in curr.get_many(*args, **kwargs): yield now diff --git a/libs/CodernityDB3/tree_index.py b/libs/CodernityDB3/tree_index.py index f8236c57..1e116bdd 100644 --- a/libs/CodernityDB3/tree_index.py +++ b/libs/CodernityDB3/tree_index.py @@ -1646,7 +1646,7 @@ class IU_TreeBasedIndex(Index): def delete(self, doc_id, key, start=0, size=0): containing_leaf_start, element_index = self._find_key_to_update( key, doc_id)[:2] - print(containing_leaf_start, element_index) + print((containing_leaf_start, element_index)) self._delete_element(containing_leaf_start, element_index) self._find_key.delete(key)