def rr(ggpkfile): return dat.RelationalReader( path_or_ggpk=ggpkfile, read_options={ # When we use this, speed > dat value features 'use_dat_value': False }, raise_error_on_missing_relation=False, )
def rr(file_system: FileSystem) -> dat.RelationalReader: return dat.RelationalReader( path_or_file_system=file_system, read_options={ # When we use this, speed > dat value features 'use_dat_value': False }, raise_error_on_missing_relation=False, )
def rr_instance(rr_temp_dir): return dat.RelationalReader( path_or_file_system=rr_temp_dir, read_options={ 'specification': load(os.path.join( spec_dir, 'rr_test.py' )), 'use_dat_value': False, }, )
def test_enums(self, rr_temp_dir, use_dat_value): rr = dat.RelationalReader( path_or_file_system=rr_temp_dir, read_options={ 'specification': load(os.path.join( spec_dir, 'rr_test.py' )), 'use_dat_value': use_dat_value, }, ) for column, values in self.enums_expected.items(): for i, row in enumerate(rr['Main.dat']): assert row[column] == values[i], 'Testing against expected enum'
def test_runtime_missing_foreign_key(self, rr_temp_dir, spec_name): rr = dat.RelationalReader( path_or_file_system=rr_temp_dir, raise_error_on_missing_relation=True, read_options={ 'specification': load(os.path.join( spec_dir, spec_name )), 'use_dat_value': False, }, ) with pytest.raises(dat.SpecificationError) as e: rr.get_file('Data/Main.dat') assert e.value.code == \ dat.SpecificationError.ERRORS.RUNTIME_MISSING_FOREIGN_KEY
def test_relations(self, rr_temp_dir, use_dat_value): rr = dat.RelationalReader( path_or_file_system=rr_temp_dir, read_options={ 'specification': load(os.path.join( spec_dir, 'rr_test.py' )), 'use_dat_value': use_dat_value, }, ) for column, values in self.relations_expected.items(): for i, row in enumerate(rr['Main.dat']): expected = values[i] if expected is not None: expected = rr['Other.dat'][expected] else: expected = None assert row[column] == expected, 'Testing against expected row'
def rr(files=['BaseItemTypes.dat']): rr = dat.RelationalReader(path_or_ggpk=dir, files=files)
def rr(files=['BaseItemTypes.dat']): rr = dat.RelationalReader(path_or_ggpk=dir, files=files) # ============================================================================= # Init # ============================================================================= if __name__ == '__main__': profiler = LineProfiler() #profiler.add_function(dat.DatValue.__init__) #profiler.add_function(dat.DatReader._cast_from_spec) #profiler.add_function(dat.DatReader._process_row) #profiler.add_function(dat.DatRecord.__getitem__) #profiler.run("d = read_dat()") #profiler.run("for i in range(0, 10000): d.reader[0]['Data1']") #print(d.reader[0]) #profiler.add_function(dat.RelationalReader._set_value) #profiler.add_function(dat.RelationalReader._dv_set_value) #profiler.add_function(dat.RelationalReader._simple_set_value) #profiler.add_function(dat.RelationalReader.read_file) #profiler.run("rr = dat.RelationalReader(path_or_ggpk=dir, files=['Data/BaseItemTypes.dat'], read_options={'use_dat_value': False})") #profiler.print_stats() rr = dat.RelationalReader(path_or_ggpk=dir, files=['Data/MonsterVarieties.dat'], read_options={'use_dat_value': False})