Beispiel #1
0
def ItemMoveInfo(region, id):
    if region == 'roeu': path = files.get_path(region, 'ItemMoveInfoV4.txt')
    else: path = files.get_path(region, 'ItemMoveInfoV5.txt')
    lines = files.open_lines(path)
    for line in lines:
        if line.strip().startswith(str(id)):
            if region == 'roeu': return ''.join(re.split(r'\s+', line)[1:8])
            else: return ''.join(re.split(r'\s+', line)[1:9])
Beispiel #2
0
def cuetools_verify(album):
    paths = []
    ids = []
    for i in range(len(album.tracks)):
        track = album.tracks[i]
        if track.file_flac:
            paths.append(files.get_path(track.file_flac))
        else:
            paths.append(files.get_path(track.file))
            ids.append(track.track)
    if ids == []:
        ids = None
    res = cuetools.verify(paths, ids)
    update_extra('albums', album.id, 'cuetools', res)
Beispiel #3
0
def special(text, region):
    path = files.get_path(region, 'special.sc')
    if region == 'ropru': codirovka = 'Windows-1251'
    else: codirovka = 'utf-8'

    pattern = r'^\s*item\s+(\S+)\s*'
    new_items = list()
    for line in text.splitlines():
        if re.search(pattern, line):
            new_items.append(re.search(pattern, line).group(1))

    old_lines = files.open_lines(path, codirovka)
    skip = False
    old_lines_fixed = list()
    for line in old_lines:
        if re.search(pattern, line): skip = False
        if re.search(pattern, line) is not None and re.search(pattern, line).group(1) in new_items: skip = True
        if skip == True: pass
        else: old_lines_fixed.append(line)
    old_text_fixed = '\n'.join(old_lines_fixed)

    begin = old_text_fixed.rsplit('return', 1)[0] + '\n\n'
    end = old_text_fixed.rsplit('return', 1)[1]
    new_text = begin + text.strip() + end
    files.write_text(new_text, path, codirovka, errors='ignore')
Beispiel #4
0
def PackageItem(text, region):
    path = files.get_path(region, 'PackageItem.lua')

    pattern = r'^\s*\[(.*)\]\s*='
    new_items = list()
    for line in text.splitlines():
        if re.search(pattern, line):
            name = re.search(pattern, line).group(1).replace('[[', '\"').replace(']]', '\"').strip().replace('\"', '')
            new_items.append(name)

    old_lines = files.open_lines(path)
    skip = False
    lines = list()
    for line in old_lines:
        if re.search(pattern, line):
            name = re.search(pattern, line).group(1).replace('[[', '\"').replace(']]', '\"').strip().replace('\"', '')
            skip = False
        if re.search(pattern, line) is not None and name in new_items: skip = True
        if 'function' in line: break
        elif skip == True: pass
        else: lines.append(line)
    old_text = '\n'.join(lines).rsplit('};', 1)[0]
    function_block = list()
    block_write = False
    for line in old_lines:
        if 'function' in line: block_write = True
        if block_write == True: function_block.append(line)
    function_block = '\n'.join(function_block).rsplit('};', 1)[0]
    new_text = old_text + text + '};\n\n\n' + function_block
    files.write_text(new_text, path)
Beispiel #5
0
def match_acoustid(album):
    paths = []
    for i in range(len(album.tracks)):
        track = album.tracks[i]
        paths.append(files.get_path(track.file))
    resa, res = match_albums(paths)
    update_extra('albums', album.id, 'musicbrainz', resa)
    for i in range(len(album.tracks)):
        track = album.tracks[i]
        update_extra('songs', track.id, 'musicbrainz', res[i])
Beispiel #6
0
def script_sql(text, region, date):
    path = files.get_path(region, 'script.sql')
    if region == 'ropru': path = path.replace('script.sql', date+'_script_prime.sql')
    elif region == 'ropeu': path = path.replace('script.sql', date+'_script_euprime.sql')
    elif region == 'roeu': path = path.replace('script.sql', date+'_script_chaos.sql')
    try:
        old_text = files.open_text(path)
        new_text = old_text.rstrip() + '\n\n' + text
        files.write_text(new_text, path)
    except FileNotFoundError:
        files.write_text(text, path)
    print('Прогнать SQL скрипт в базе данных? (да/нет)')
    choice = input('Выбор: ')
    if 'да' in choice.lower(): db.execute(text)
Beispiel #7
0
def special(region, dbname):
    path = files.get_path(region, 'special.sc')
    if region == 'ropru': codirovka = 'Windows-1251'
    else: codirovka = 'EUC-KR'
    lines = files.open_lines(path, codirovka)
    result = list()
    writing = False
    for line in lines:
        if re.search(r'^\s*item\s+(\S+)', line):
            if dbname == re.search(r'\s*item\s+(\S+)', line).group(1):
                writing = True
            else:
                writing = False
        if writing == True: result.append(line)
    result = '\n'.join(result)
    return result.strip()
Beispiel #8
0
def PackageItem(region, dbname):
    path = files.get_path(region, 'PackageItem.lua')
    lines = files.open_lines(path)
    pattern = r'^\s*\[(.*)\]\s*='  # боксы
    result = ''
    writing = False
    for line in lines:
        if re.search(pattern, line):
            fixed_line = line.replace(']]', '\"').replace('[[', '\"')
            if re.search(pattern,
                         fixed_line).group(1).replace('\"',
                                                      '').strip() == dbname:
                writing = True
            elif writing == True:
                break
        if writing == True: result += line + '\n'
    return result.strip()
Beispiel #9
0
def ItemMoveInfoV(text, region, version=5):
    path = files.get_path(region, 'ItemMoveInfoV{}.txt'.format(version))

    pattern = r'^\s*(\S+)\s*'
    new_items = list()
    for line in text.splitlines():
        if re.search(pattern, line):
            new_items.append(re.search(pattern, line).group(1))

    old_lines = files.open_lines(path)
    old_lines_fixed = list()
    for line in old_lines:
        if re.search(pattern, line) is not None and re.search(pattern, line).group(1) in new_items: pass
        else: old_lines_fixed.append(line)
    old_text_fixed = '\n'.join(old_lines_fixed)

    new_text = old_text_fixed + '\n' + text
    files.write_text(new_text, path)
Beispiel #10
0
def CashItemList(text, region):
    path = files.get_path(region, 'CashItemList.txt')

    pattern = r'^\s*("\S+")\s*'
    new_items = list()
    for line in text.splitlines():
        if re.search(pattern, line):
            new_items.append(re.search(pattern, line).group(1))

    old_lines = files.open_lines(path)
    old_lines_fixed = list()
    for line in old_lines:
        if re.search(pattern, line) is not None and re.search(pattern, line).group(1) in new_items: pass
        else: old_lines_fixed.append(line)
    old_text_fixed = '\n'.join(old_lines_fixed)

    new_text = old_text_fixed + '\n' + text
    files.write_text(new_text, path)
Beispiel #11
0
def combiItem(text, region):
    path = files.get_path(region, 'combiItem.sc')

    pattern = r'^\s*COMBIITEM(\S+)\s*'
    new_combiitems = list()
    for line in text.splitlines():
        if re.search(pattern, line):
            new_combiitems.append(re.search(pattern, line).group(1))

    old_lines = files.open_lines(path)
    skip = False
    old_lines_fixed = list()
    for line in old_lines:
        if re.search(pattern, line): skip = False
        if re.search(pattern, line) is not None and re.search(pattern, line).group(1) in new_combiitems: skip = True
        if skip == True: pass
        else: old_lines_fixed.append(line)
    old_text_fixed = '\n'.join(old_lines_fixed)

    new_text = old_text_fixed + '\n' + text
    files.write_text(new_text, path)
Beispiel #12
0
def BuffSpecial(text, region):
    path = files.get_path(region, 'BuffSpecial.sc')

    pattern = r'^\s*Buff\s+(\S+)\s*'
    new_buffs = list()
    for line in text.splitlines():
        if re.search(pattern, line):
            new_buffs.append(re.search(pattern, line).group(1))

    old_lines = files.open_lines(path, codirovka='EUC-KR')
    skip = False
    old_lines_fixed = list()
    for line in old_lines:
        if re.search(pattern, line): skip = False
        if re.search(pattern, line) is not None and re.search(pattern, line).group(1) in new_buffs: skip = True
        if skip == True: pass
        else: old_lines_fixed.append(line)
    old_text_fixed = '\n'.join(old_lines_fixed)

    begin = old_text_fixed.rsplit('return', 1)[0] + '\n\n'
    end = old_text_fixed.rsplit('return', 1)[1]
    new_text = begin + text.strip() + end
    files.write_text(new_text, path, codirovka='EUC-KR')
Beispiel #13
0
def Importantitem(region, id):
    path = files.get_path(region, 'Importantitem.txt')
    lines = files.open_lines(path)
    for line in lines:
        if line.strip().startswith(str(id)): return True
    return False
Beispiel #14
0
def CashItemList(region, dbname):
    path = files.get_path(region, 'CashItemList.txt')
    lines = files.open_lines(path)
    for line in lines:
        if "\"" + dbname + "\"" in line: return True
    return False