Logo Search packages:      
Sourcecode: babiloo version File versions  Download package

def babiloo-2.0.11::core::dictionary::dictionary::DictionaryType::__init__ (   self,
  dictionary = None 
)

Initialize variables and load dictionary if requested

Definition at line 53 of file dictionary.py.

00053                                        :
        """Initialize variables and load dictionary if requested"""
        self.__keys = []
        self.__dict = {}
        self.encoding = 'UTF-8'
        self.version = 'unknown'
        self.__filepath = None
        self.__hash = None

        if dictionary is not None:
            if isinstance(dictionary, DictionaryType):
                self.__dict = dictionary.__dict.copy()
                self.__keys = dictionary.__keys[:]
            elif isinstance(dictionary, str) or isinstance(dictionary, unicode):
                #if os.path.isfile(dictionary):
                #if it points to a file, determine which format is encoded and load that file using the specific Dictionary subclass
                #print "Loading %s" % dictionary
                self.__filepath = dictionary
                self.load(self.__filepath)

                try:
                        self.__hash = new_hash(file(self.__filepath,mode='rb').read()).hexdigest()
                except:
                    traceback.print_exc()
                    pass
            else:
                self.__dict = dict(dictionary).copy()
                self.__keys = sorted(self.__dict.keys())

    def getAt(self, index):


Generated by  Doxygen 1.6.0   Back to index