def source(self, new_source): # Attempt to fetch source from source manager if passed object # is not instance of source class if not isinstance(new_source, Source) and new_source is not None: new_source = SourceManager.get(new_source) old_source = self.source # Do not update anything if sources are the same if new_source is old_source: return self.__source = new_source # Update eos model with new data self._eos_fit.source = getattr(new_source, 'eos', None) # Update pyfa model with new data # Unlike fit, character represents EVE item, thus we need # to update it too self._update_source() for src_child in self._src_children: src_child._update_source()
def _set_source(self, new_source): """ Set fit's source. Source represents EVE data to be used. Required arguments: new_source -- source to use, can be None """ # Attempt to fetch source from source manager if passed object # is not instance of source class if not isinstance(new_source, Source) and new_source is not None: new_source = SourceManager.get(new_source) old_source = self.source # Do not update anything if sources are the same if new_source is old_source: return self.__source = new_source # Update eos model with new data self._eos_fit.source = getattr(new_source, 'eos', None) # Update pyfa model with new data for src_child in self._src_children: src_child._update_source()
script_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.append(os.path.realpath(os.path.join(script_dir, 'external'))) import os from service.data.eve_data.query import * from service.data.pyfa_data import * from service.data.pyfa_data import PyfaDataManager from service.source_mgr import SourceManager eve_dbpath_tq = os.path.join(script_dir, 'staticdata', 'tranquility.db') pyfa_dbpath = os.path.join(script_dir, 'userdata', 'pyfadata.db') # Initialize databases with eve data SourceManager.add('tq', eve_dbpath_tq, make_default=True) SourceManager.add('sisi', eve_dbpath_tq) # (Re-)Initialize database for pyfa save data if os.path.isfile(pyfa_dbpath): os.remove(pyfa_dbpath) PyfaDataManager.set_pyfadb_path(pyfa_dbpath) session_pyfadata = PyfaDataManager.session def print_attrs(item): print(item.eve_name) for k in sorted(item.attributes, key=lambda i: i.name): print(' {}: {}'.format(k.name, item.attributes[k])) CRUSADER = 11184