Exemplo n.º 1
0
    def _get_file_list(self):
        '''Populate the inst_list with the values
        '''
        # walk through the directories and read the
        # values
        #
        print('file list', self.dir)
        for root, sub_folders, files in os.walk(self.dir):
            for folder in sub_folders:
                ex_type_file = os.path.join(root, folder, 'ex_type.cls')
                if os.path.exists(ex_type_file):

                    # check if the class specification coincides with
                    # the klass trait of this table
                    #
                    f = open(ex_type_file, 'r')
                    ex_type_klass = f.read().split('\n')[0]  # use trim here
                    f.close()

                    klass = _find_class(ex_type_klass)

                    if klass and klass.__name__ == self.klass.__name__:

                        file_ext = klass().file_ext
                        ex_type_dir = os.path.join(root, folder)
                        ex_type_files = os.listdir(ex_type_dir)
                        for filename in fnmatch.filter(ex_type_files,
                                                       '*.%s' % file_ext):
                            yield os.path.join(ex_type_dir, filename)
Exemplo n.º 2
0
    def _get_file_list(self):
        '''Populate the inst_list with the values
        '''
        # walk through the directories and read the
        # values
        #
        print 'file list', self.dir
        for root, sub_folders, files in os.walk(self.dir):
            for folder in sub_folders:
                ex_type_file = os.path.join(root, folder, 'ex_type.cls')
                if os.path.exists(ex_type_file):

                    # check if the class specification coincides with
                    # the klass trait of this table
                    #
                    f = open(ex_type_file, 'r')
                    ex_type_klass = f.read().split('\n')[0]  # use trim here
                    f.close()

                    klass = _find_class(ex_type_klass)

                    if klass and klass.__name__ == self.klass.__name__:

                        file_ext = klass().file_ext
                        ex_type_dir = os.path.join(root, folder)
                        ex_type_files = os.listdir(ex_type_dir)
                        for filename in fnmatch.filter(ex_type_files, '*.%s' % file_ext):
                            yield os.path.join(ex_type_dir, filename)
Exemplo n.º 3
0
    def __init__(self, data_file, **kw):
        '''Initialization: the ex_run is defined by the
        data_file. The additional data - inputs and derived outputs
        are stored in the data_file.pickle. If this file exists,
        the exrun is constructed from this data file.
        '''
        super(ExRun, self).__init__(**kw)
        self.data_file = data_file
        read_ok = False

        if os.path.exists(self.pickle_file_name):
            print 'PICKLE FILE EXISTS %s' % self.pickle_file_name
            file_ = open(self.pickle_file_name, 'r')
            try:
                self.ex_type = self.pickle_['load'](file_)
                self.unsaved = False
                read_ok = True
            except EOFError:
                read_ok = False

            file_.close()
            self.ex_type.data_file = self.data_file

            # In case that the code for processing data
            # has changed since the last dump - run
            # the processing anew. This can be skipped
            # if the code is finished.
            #
            # @todo - the refreshing of the process data
            # should be possible for all instances at once
            # this would avoid the - on-click-based refreshing
            # of the data performed here.
            #
            self.ex_type.process_source_data()
            self.ex_type.derived_data_available = True
            print '*** derived data available ***'

        if not read_ok and os.path.exists(self.ex_type_file_name):

            print 'PICKLE FILE DOES NOT EXIST'

            f = open(self.ex_type_file_name, 'r')
            ex_type_klass = f.read().split('\n')[0]  # use trim here
            f.close()
            theClass = _find_class(ex_type_klass)
            if theClass is None:
                raise TypeError, 'class %s not found for file %s' % (
                    ex_type_klass, self.ex_type_file_name)
            self.ex_type = theClass(data_file=self.data_file)
            self.unsaved = True
            read_ok = True

            self.ex_type.process_source_data()

        if not read_ok:
            raise ValueError, 'Cannot instantiate ExType using %s' % data_file
Exemplo n.º 4
0
    def __init__(self, data_file, **kw):
        '''Initialization: the ex_run is defined by the
        data_file. The additional data - inputs and derived outputs
        are stored in the data_file.pickle. If this file exists,
        the exrun is constructed from this data file.
        '''
        super(ExRun, self).__init__(**kw)
        self.data_file = data_file
        read_ok = False

        if os.path.exists(self.pickle_file_name):
            print 'PICKLE FILE EXISTS %s' % self.pickle_file_name
            file_ = open(self.pickle_file_name, 'r')
            try:
                self.ex_type = self.pickle_['load'](file_)
                self.unsaved = False
                read_ok = True
            except EOFError:
                read_ok = False

            file_.close()
            self.ex_type.data_file = self.data_file

            # In case that the code for processing data
            # has changed since the last dump - run
            # the processing anew. This can be skipped
            # if the code is finished.
            #
            # @todo - the refreshing of the process data
            # should be possible for all instances at once
            # this would avoid the - on-click-based refreshing
            # of the data performed here.
            #
            self.ex_type.process_source_data()
            self.ex_type.derived_data_available = True
            print '*** derived data available ***'

        if not read_ok and os.path.exists(self.ex_type_file_name):

            print 'PICKLE FILE DOES NOT EXIST'

            f = open(self.ex_type_file_name, 'r')
            ex_type_klass = f.read().split('\n')[0]  # use trim here
            f.close()
            theClass = _find_class(ex_type_klass)
            if theClass is None:
                raise TypeError, 'class %s not found for file %s' % (ex_type_klass, self.ex_type_file_name)
            self.ex_type = theClass(data_file=self.data_file)
            self.unsaved = True
            read_ok = True

            self.ex_type.process_source_data()

        if not read_ok:
            raise ValueError, 'Cannot instantiate ExType using %s' % data_file