def get_results_info(self, filename=None):
        """
        Read pmag_results.txt file.
        Parse information into dictionaries for each item.
        Then add it to the item object as object.results_data.
        """
        if not filename:
            short_filename = "pmag_results.txt"
            magic_file = os.path.join(self.WD, short_filename)
        else:
            magic_file = filename
        if not os.path.isfile(magic_file):
            print('-W- Could not find {} in your working directory {}'.format(short_filename, self.WD))
            return False
        # get the data from the pmag_results.txt file
        data_dict = self.read_magic_file(magic_file, 'by_line_number')[0]

        def make_items_list(string, search_items_list):
            names = string.split(':')
            items = []
            for name in names:
                name = name.strip(' ')
                item = self.find_by_name(name, search_items_list)
                if item:
                    items.append(item)
            return items

        for num, result in list(data_dict.items()):
            name, specimens, samples, sites, locations = None, None, None, None, None
            for key, value in list(result.items()):
                #print key, ':', value
                if key == 'er_specimen_names':
                    specimens = make_items_list(value, self.specimens)
                if key == 'er_sample_names':
                    samples = make_items_list(value, self.samples)
                if key == 'er_site_names':
                    sites = make_items_list(value, self.sites)
                if key == 'er_location_names':
                    locations = make_items_list(value, self.locations)
                if key == 'pmag_result_name':
                    name = value
            for header_name in ['er_specimen_names', 'er_site_names',
                                'er_sample_names', 'er_location_names']:
                if header_name in list(result.keys()):
                    result.pop(header_name)
            if not name:
                name = num
            result_item = self.find_by_name(name, self.results)
            if not result_item:
                result_item = Result(name, specimens, samples, sites, locations, result, self.data_model)
            else:
                print('-W- Two or more results with name: {} found in your result file.\n    Taking only the first.'.format(name))
            if result_item and result_item not in self.results:
                self.results.append(result_item)
def get_results_info ( self , filename = None ) : if not filename : short_filename = "pmag_results.txt" magic_file = os . path . join ( self . WD , short_filename ) else : magic_file = filename if not os . path . isfile ( magic_file ) : print ( '-W- Could not find {} in your working directory {}' . format ( short_filename , self . WD ) ) return False data_dict = self . read_magic_file ( magic_file , 'by_line_number' ) [ 0 ] def make_items_list ( string , search_items_list ) : names = string . split ( ':' ) items = [ ] for name in names : name = name . strip ( ' ' ) item = self . find_by_name ( name , search_items_list ) if item : items . append ( item ) return items for num , result in list ( data_dict . items ( ) ) : name , specimens , samples , sites , locations = None , None , None , None , None for key , value in list ( result . items ( ) ) : if key == 'er_specimen_names' : specimens = make_items_list ( value , self . specimens ) if key == 'er_sample_names' : samples = make_items_list ( value , self . samples ) if key == 'er_site_names' : sites = make_items_list ( value , self . sites ) if key == 'er_location_names' : locations = make_items_list ( value , self . locations ) if key == 'pmag_result_name' : name = value for header_name in [ 'er_specimen_names' , 'er_site_names' , 'er_sample_names' , 'er_location_names' ] : if header_name in list ( result . keys ( ) ) : result . pop ( header_name ) if not name : name = num result_item = self . find_by_name ( name , self . results ) if not result_item : result_item = Result ( name , specimens , samples , sites , locations , result , self . data_model ) else : print ( '-W- Two or more results with name: {} found in your result file.\n    Taking only the first.' . format ( name ) ) if result_item and result_item not in self . results : self . results . append ( result_item )
Read pmag_results.txt file.
        Parse information into dictionaries for each item.
        Then add it to the item object as object.results_data.