load data from a saved .lcopt file

def load(self, filename):
        """load data from a saved .lcopt file"""
        if filename[-6:] != ".lcopt":
            filename += ".lcopt"
        try:
            savedInstance = pickle.load(open("{}".format(filename), "rb"))
        except FileNotFoundError:
            savedInstance = pickle.load(open(fix_mac_path_escapes(os.path.join(storage.model_dir, "{}".format(filename))), "rb"))
        
        attributes = ['name',
                      'database',
                      'params',
                      'production_params',
                      'allocation_params',
                      'ext_params',
                      'matrix',
                      'names',
                      'parameter_sets',
                      'model_matrices',
                      'technosphere_matrices',
                      'leontif_matrices',
                      'external_databases',
                      'parameter_map',
                      'sandbox_positions',
                      'ecoinventName',
                      'biosphereName',
                      'forwastName',
                      'analysis_settings',
                      'technosphere_databases',
                      'biosphere_databases',
                      'result_set',
                      'evaluated_parameter_sets',
                      'useForwast',
                      'base_project_name',
                      'save_option',
                      'allow_allocation',
                      'ecoinvent_version',
                      'ecoinvent_system_model',
                      ]

        for attr in attributes:

            if hasattr(savedInstance, attr):
                setattr(self, attr, getattr(savedInstance, attr))
            else:
                pass
                #print ("can't set {}".format(attr))

        # use legacy save option if this is missing from the model
        if not hasattr(savedInstance, 'save_option'):
            setattr(self, 'save_option', LEGACY_SAVE_OPTION)

        # figure out ecoinvent version and system model if these are missing from the model
        if not hasattr(savedInstance, 'ecoinvent_version') or not hasattr(savedInstance, 'ecoinvent_system_model'):
            
            parts = savedInstance.ecoinventName.split("_")
            main_version = parts[0][-1]
            sub_version = parts[1]
            system_model = parts[2]

            #print(parts)

            setattr(self, 'ecoinvent_version', '{}.{}'.format(main_version, sub_version))
            setattr(self, 'ecoinvent_system_model', system_model)