diff --git a/ostap/io/compress_shelve.py b/ostap/io/compress_shelve.py index b6efc7a1..8415606c 100755 --- a/ostap/io/compress_shelve.py +++ b/ostap/io/compress_shelve.py @@ -54,10 +54,10 @@ 'ENCODING' ) # ============================================================================= -import os, abc, shelve, shutil, glob, datetime, collections +import os, abc, shelve, shutil, glob, datetime from sys import version_info as python_version from ostap.io.dbase import dbopen, whichdb, Item -from ostap.core.meta_info import meta_info +from ostap.core.meta_info import meta_info, from ostap.io.pickling import ( Pickler , Unpickler, BytesIO, PROTOCOL, HIGHEST_PROTOCOL, DEFAULT_PROTOCOL ) @@ -66,6 +66,11 @@ if '__main__' == __name__ : logger = getLogger ( 'ostap.io.compress_shelve' ) else : logger = getLogger ( __name__ ) # ============================================================================= +## ordered dict type to be used a +ordered_dict = dict +if python_version < (3.7) : + from collections import OrderedDict as ordered_dict +# ============================================================================= ## encoding ENCODING = 'utf-8' # ============================================================================= @@ -269,7 +274,7 @@ def __init__( elif 'sqlite3' != self.dbtype and self.mode in ( 'c' , 'n' ) : write = True else : write = False if write : - dct = collections.OrderedDict() + dct = ordered_dict() dct [ 'Created by' ] = meta_info.User dct [ 'Created at' ] = datetime.datetime.now ().strftime( '%Y-%m-%d %H:%M:%S' ) dct [ 'Created with Ostap version' ] = meta_info.Ostap diff --git a/ostap/io/sqliteshelve.py b/ostap/io/sqliteshelve.py index 8c225b39..4eb40933 100755 --- a/ostap/io/sqliteshelve.py +++ b/ostap/io/sqliteshelve.py @@ -134,7 +134,7 @@ import sqlite3 from ostap.io.sqlitedict import SqliteDict from ostap.io.dbase import Item, TmpDB -from ostap.core.meta_info import meta_info +from ostap.core.meta_info import meta_info, python_info from ostap.io.pickling import ( Pickler, Unpickler, BytesIO , PROTOCOL, HIGHEST_PROTOCOL, DEFAULT_PROTOCOL ) @@ -143,6 +143,11 @@ if '__main__' == __name__ : logger = getLogger ( 'ostap.io.sqliteshelve' ) else : logger = getLogger ( __name__ ) # ============================================================================= +## ordered dict type to be used +ordered_dict = dict +if python_info < (3.7) : + from collections import OrderedDict as ordered_dict +# ============================================================================= _modes_ = { # ========================================================================= # 'r' Open existing database for reading only @@ -291,7 +296,7 @@ def __init__ ( self , self.__sizes = {} if self.flag in ( 'w' , 'n' ) : - dct = collections.OrderedDict() + dct = ordered_dict() dct [ 'Created by' ] = meta_info.User dct [ 'Created at' ] = datetime.datetime.now ().strftime( '%Y-%m-%d %H:%M:%S' ) dct [ 'Created with Ostap version' ] = meta_info.Ostap diff --git a/ostap/plotting/canvas.py b/ostap/plotting/canvas.py index d71a3019..5d310832 100755 --- a/ostap/plotting/canvas.py +++ b/ostap/plotting/canvas.py @@ -32,6 +32,7 @@ ) # ============================================================================= from sys import version_info as python_version +from ostap.core.ostap_types import ordered_dict from ostap.utils.cidict import cidict from ostap.utils.utils import KeepCanvas, keepCanvas from ostap.core.core import cidict_fun @@ -668,11 +669,7 @@ def _cnv_pads_ ( self ) : """`pads' : get (an ordered) dict of pads for the given canvas partition (if prepared) """ if not hasattr ( self , '__pads' ) : - if (3,7) <= python_version : - self.__pads = {} - else : - from collections import OrderedDict - self.__pads = OrderedDict () + self.__pads = ordered_dict () return self.__pads # ============================================================================= def _cnv_del_pads_ ( self ) :