def test_diff(): current = files.open_lines('current.txt') new = files.open_lines('new.txt') current_dict = dict() for line in current: if 'maptype' in line.lower(): type = re.split(r'\s+', line)[1] current_dict[type] = list() continue elif '//' in line: continue else: current_dict[type].append(line) for key, value in current_dict.items(): current_dict[key] = sorted(value) new_dict = dict() for line in new: if 'maptype' in line.lower(): type = re.split(r'\s+', line)[1] new_dict[type] = list() continue elif '//' in line: continue else: new_dict[type].append(line) for key, value in new_dict.items(): new_dict[key] = sorted(value) assert new_dict == current_dict
import Ragnarok.module.files as files import Ragnarok.module.db as db ids = files.open_lines('ids.txt') id_dbname = list() for line in ids: table, dict = db.find_table('ropru', int(line)) print(line) try: new = line +'\t'+ dict['NAME'] id_dbname.append(new) except: new = line id_dbname.append(new) files.write_lines(id_dbname, 'ids_dbnames.txt')
import Ragnarok.module.files as files all_consumable = files.open_lines("consumable.txt") consumable = list() for line in all_consumable: if line.strip() not in consumable: consumable.append(line.strip()) consumable = sorted(consumable) all_important = files.open_lines("important.txt") important = list() for line in all_important: if line.strip() not in important: important.append(line.strip()) important = sorted(important) files.write_lines(important, 'all_important_items.txt') important_consumable = list() for line in important: if line in consumable: important_consumable.append(line) important_consumable = sorted(important_consumable) files.write_lines(important_consumable, 'all_important_consumable_items.txt')
import Ragnarok.module.google as google import Ragnarok.module.files as files import Ragnarok.module.find as find import re import openpyxl wb = openpyxl.load_workbook('desc.xlsx') sheet = wb['database'] worksheet = google.open_sheet('1HchGulIn5IHlQYJCg9y4XI-IkLqzUhW05rnVsizUoEw', 1) worksheet.update_cell(1, 2, 'DB name') # строка столбец что iteminfo_ru = files.open_lines(files.get_path('ropru', 'iteminfo.lua'), codirovka='Windows-1251', errors='ignore') iteminfo_en = files.open_lines(files.get_path('ropeu', 'iteminfo.lua'), codirovka='EUC-KR', errors='ignore') print('открываю desc.xlsx') old_table = files.open_table('desc.xlsx', 'database') for row in old_table: if row[0] is None: current_row = old_table.index(row) + 1 break ids = list() print('Ищу id в iteminfo ru') for line in iteminfo_ru: if re.search(r'\s*\[(.*)\]\s*=', line):
import re import Ragnarok.module.files as files lines = files.open_lines('2021_halloween_ru.sc', 'Windows-1251') npcs = list() names = list() for line in lines: if line.strip().startswith('npc '): npcs.append(line.strip().replace(' ', '\t')) names.append(line.split('\"')[3].split('#')[0]) files.write_lines(npcs, 'npcs.txt', 'Windows-1251') files.write_lines(names, 'names.txt', 'Windows-1251')
import re import Ragnarok.module.files as files import Ragnarok.module.patterns as pattern obb_filtered1 = files.open_lines('obb_filtered1.txt') ovb_filtered1 = files.open_lines('ovb_filtered1.txt') cashitems_ru = files.open_lines('D:/RO/rot/zone/CashItemList.txt') cashitems_eu = files.open_lines('D:/RO/roteu/zone/CashItemList.txt') cashitemlist = list() for line in cashitems_ru: if line.strip().startswith('\"'): if line.split('\"')[1] not in cashitemlist: cashitemlist.append(line.split('\"')[1]) for line in cashitems_eu: if line.strip().startswith('\"'): if line.split('\"')[1] not in cashitemlist: cashitemlist.append(line.split('\"')[1]) obb_filtered2 = list() ovb_filtered2 = list() for line in obb_filtered1: if re.split(r'\s+', line)[1] in cashitemlist: obb_filtered2.append('удалить\t'+re.split(r'\s+', line)[1]) else: obb_filtered2.append(line) for line in ovb_filtered1: if re.split(r'\s+', line)[1] in cashitemlist: ovb_filtered2.append('удалить\t'+re.split(r'\s+', line)[1]) else: ovb_filtered2.append(line) files.write_lines(obb_filtered2, 'obb_filtered2.txt') files.write_lines(ovb_filtered2, 'ovb_filtered2.txt')
import re import Ragnarok.module.files as files exist_maps = files.open_lines('exist_map.txt') all_maps = files.open_lines('map.txt') not_exist = list() for line in all_maps: map = line.split()[1] type = line.split()[3] not_exist.append(type + '\t' + map) exist = list() exist_mapss = list() for i in range(len(not_exist)): for exist_map in exist_maps: not_map = not_exist[i].split()[1].replace('.gat', '') if not_map == exist_map: exist.append(not_exist[i]) not_exist[i] = '' exist_mapss.append(not_map) break files.write_lines(exist, 'exist_result.txt') files.write_lines(not_exist, 'not_exist_result.txt') for exist_map in exist_maps: if exist_map not in exist_mapss: print(exist_map)
import re import Ragnarok.module.files as files codirovka = 'utf-8' lines = files.open_lines('msgstringtable.txt', codirovka=codirovka, errors='ignore') new_lines = list() counter = 1 for line in lines: if line.replace('#', '').isspace() or len(line.replace('#', '')) == 0: line = 'missing_line' + str(counter) + '#' counter += 1 new_lines.append(line) files.write_lines(new_lines, 'msgstringtable2.txt', codirovka=codirovka)
import re import Ragnarok.module.files as files import Ragnarok.module.db as db import Ragnarok.module.find as find alph = ('й', 'ц', 'у', 'к', 'е', 'н', 'г', 'ш', 'щ', 'з', 'х', 'ъ', 'ф', 'ы', 'в', 'а', 'п', 'р', 'о', 'л', 'д', 'ж', 'э', 'я', 'ч', 'с', 'м', 'и', 'т', 'ь', 'б', 'ю', 'ё') obb_filtered2 = files.open_lines('obb_filtered2.txt') ovb_filtered2 = files.open_lines('ovb_filtered2.txt') obb_filtered3 = list() ovb_filtered3 = list() for line in obb_filtered2: print(re.split(r'\s+', line)[1]) exist = 0 table, db_dict = db.find_table('ropru', re.split(r'\s+', line)[1], 'NAME') if db_dict is not None: info = find.iteminfo('ropru', db_dict['ID']).split('identifiedDisplayName')[1] for letter in alph: if letter in info: exist = 1 break if exist == 0: obb_filtered3.append('удалить\t' + re.split(r'\s+', line)[1]) else: obb_filtered3.append(line) for line in ovb_filtered2:
import re import Ragnarok.module.files as files import Ragnarok.module.patterns as patterns list_txt = files.open_lines('D:/RO/rot/zone/npcdata/list.txt') active_scripts = list() for line in list_txt: if line.startswith('./npcdata'): active_scripts.append(line) maps = set() for script in active_scripts: print(script) path = script.replace('.', 'D:/RO/rot/zone/', 1) script_lines = files.open_lines(path, codirovka='Windows-1251', errors='ignore') for line in script_lines: if re.search(patterns.callmonster, line): map = re.search(patterns.callmonster, line).group(1) maps.add(map) if re.search(patterns.moveto, line): map = re.search(patterns.moveto, line).group(1) maps.add(map) if re.search(patterns.npc, line): map = re.search(patterns.npc, line).group(1) maps.add(map) if re.search(patterns.trader, line): map = re.search(patterns.trader, line).group(1) maps.add(map) maps = sorted(list(maps))
import re import Ragnarok.module.files as files import Ragnarok.module.db as db item_lines = files.open_lines('ItemSummonList.txt') ids = set() for line in item_lines: if re.split(r'\s+', line)[0] == 'Old_Blue_Box': if re.split(r'\s+', line)[1] not in ids: ids.add(re.split(r'\s+', line)[1]) print(len(ids)) obb_classic = list() for id in ids: table, db_dict = db.find_table('ropru', id) obb_classic.append(db_dict['NAME']) files.write_lines(obb_classic, 'obb_classic.txt')
import re import Ragnarok.module.files as files import Ragnarok.module.patterns as pattern obb_lines = files.open_lines('obb_kRO.txt') ovb_lines = files.open_lines('ovb_kRO.txt') obb_classic_lines = files.open_lines('obb_classic.txt') ovb_classic_lines = files.open_lines('ovb_classic.txt') obb_filtered1 = list() ovb_filtered1 = list() for line in obb_lines: if line in obb_classic_lines: obb_filtered1.append('добавить\t' + line) else: obb_filtered1.append('\t' + line) for line in ovb_lines: if line in ovb_classic_lines: ovb_filtered1.append('добавить\t' + line) else: ovb_filtered1.append('\t' + line) files.write_lines(obb_filtered1, 'obb_filtered1.txt') files.write_lines(ovb_filtered1, 'ovb_filtered1.txt')
import Ragnarok.module.files as files for maptype in [ 0, 1, 2, 3, 4, 6, 8, 9, 10, 12, 13, 14, 15, 16, 18, 19, 21, 23, 24, 25, 27, 28, 29, 31, 39, 40, 41 ]: maps = files.open_lines('maps_' + str(maptype) + '.txt') new_maps = set() old_maps = set() new = False old = False for line in maps: map = line.strip() if '[new]' in line: new = True continue if '[old]' in line: new = False old = True continue if new == True: new_maps.add(map) elif old == True: old_maps.add(map) added = new_maps.difference(old_maps) deleted = old_maps.difference(new_maps) differ = ['Добавлены'] + sorted(list(added)) + ['Удалены'] + sorted( list(deleted)) files.write_lines(differ, 'differ_' + str(maptype) + '.txt')