def translatefile(tinput, toutput): regix = rcomp(r'\s\s+') tmp = open(tinput, 'r', encoding="utf-8") f = tmp.read() kek = str(f) soup = BeautifulSoup(f, 'lxml') tags = sub(regix, '\n', soup.text) f = tags.split('\n') trns = [] trnsf = [] for pp in range(len(f)): trns = translator.translate(f[pp], dest='el') trnsf.append(str(trns.text)) print(f[pp]) print(trnsf[pp]) print(len(f), ' ', len(trnsf)) for i in range(len(f)): if f[i].startswith('@'): continue kek = kek.replace(str(f[i] + '<'), str(trnsf[i] + '<')) kek = kek.replace(str(f[i] + ' <'), str(trnsf[i] + ' <')) kek = kek.replace(str(f[i] + '\n'), str(trnsf[i] + '\n')) kek = kek.replace(str(f[i] + ' \n'), str(trnsf[i] + ' \n')) bitch = open(toutput, 'w', encoding="utf-8") bitch.write(kek) bitch.close()
# -*- coding: utf-8 -*- from re import compile as rcomp from re import IGNORECASE __all__ = ('mapfile', 'osu_ver', 'username', 'email', 'now_playing') mapfile = rcomp( r'^(?P<artist>.+) - (?P<title>.+)(?: \((?P<creator>.+)\))?(?: \[(?P<version>.+)\])?\.osu$' ) osu_ver = rcomp( r'^b(?P<ver>\d{8})(?:\.(?P<subver>\d))?(?:beta|cuttingedge|dev)?$') username = rcomp(r'^[\w \[\]-]{2,15}$') email = rcomp(r'^[^@\s]{1,200}@[^@\s\.]{1,30}\.[^@\.\s]{2,24}$') now_playing = rcomp( r'^\x01ACTION is (?:playing|editing|watching|listening to) ' r'\[https://osu.ppy.sh/b/(?P<bid>\d{1,7}) .+\]' r'(?: <(?P<mode_vn>Taiko|CatchTheBeat|osu!mania)>)?' r'(?P<mods>(?: (?:-|\+|~|\|)\w+(?:~|\|)?)+)?\x01$') silence_duration = rcomp(r'^(?P<duration>\d{1,6})' r'(?P<scale>s|m|h|d|w)$') tourney_matchname = rcomp( r'^(?P<name>[a-zA-Z0-9_ ]+): ' r'\((?P<T1>[a-zA-Z0-9_ ]+)\) vs\.? ' r'\((?P<T2>[a-zA-Z0-9_ ]+)\)$', flags=IGNORECASE) mappool_pick = rcomp(r'^([a-zA-Z]+)([0-9]+)$')
# -*- coding: utf-8 -*- from re import compile as rcomp __all__ = ('mapfile', 'osu_ver', 'username', 'email', 'now_playing') mapfile = rcomp(r'^(?P<artist>.+) - (?P<title>.+) \((?P<creator>.+)\) \[(?P<version>.+)\]\.osu$') osu_ver = rcomp(r'^b(?P<ver>\d{8})(?:\.(?P<subver>\d))?(?:beta|cuttingedge|dev)?$') username = rcomp(r'^[\w \[\]-]{2,15}$') email = rcomp(r'^[^@\s]{1,200}@[^@\s\.]{1,30}\.[^@\.\s]{2,24}$') now_playing = rcomp( r'^\x01ACTION is (?:playing|editing|watching|listening to) ' r'\[https://osu.ppy.sh/b/(?P<bid>\d{1,7}) .+\]' r'(?P<mods>(?: (?:-|\+|~|\|)\w+(?:~|\|)?)+)?\x01$' ) silence_duration = rcomp( r'^(?P<duration>\d{1,6})' r'(?P<scale>s|m|h|d|w)$' )
# -*- coding: utf-8 -*- from re import compile as rcomp __all__ = 'mapfile', 'now_playing' mapfile = rcomp(r'^(?P<artist>.+) - (?P<title>.+) \((?P<creator>.+)\) \[(?P<version>.+)\]\.osu$') now_playing = rcomp( r'^\x01ACTION is (?:playing|editing|watching|listening to) ' r'\[https://osu.ppy.sh/b/(?P<bid>\d{1,7}) .+\]' r'(?P<mods>(?: (?:-|\+|~|\|)\w+(?:~|\|)?)+)?\x01$' ) osu_version = rcomp(r'^b(?P<date>\d{8}(?:\.\d+)?)(?:beta|cuttingedge)?$')
import yaml import sys from pdb import set_trace as st from types import * from copy import deepcopy from re import compile as rcomp DEFAULT_FILE = 'structure.default.yaml' OUTPUT_FILE = 'structure.output.yaml' from create_home import (HOME_DIR_ENTRY_NAME, VAR_DIR_ENTRY_NAME, FS_ENTRY_NAME) from create_networks import (NETWORK_ENTRY_NAME) from create_globals import (GLOBAL_ENTRY_NAME) regex = rcomp("\((?P<var>\$\w+)(\*(?P<mul>\d+))?\+(?P<base>\d+)\)") def string_replace_vars(s, env): m = regex.search(s) if m: v = m.group('var') b = m.group('base') bi = int(b) mul = m.group('mul') if v not in env: print("no such variables") return s vi = int(env[v]) if mul: vi *= int(mul)
# return self.write(b"") # req = requests.get( # f'{glob.conf.config["osuapi"]["apiurl"]}/osu/{searchingBeatmap.beatmapID}', timeout=20) # req.encoding = "utf-8" # response = req.content # self.write(response) # glob.dog.increment(glob.DATADOG_PREFIX + # ".osu_api.osu_file_requests") # except exceptions.invalidArgumentsException: # self.set_status(500) # except exceptions.osuApiFailException: # self.set_status(500) MAPFILE_REGEX = rcomp( r'^(?P<artist>.+) - (?P<title>.+) \((?P<creator>.+)\) \[(?P<version>.+)\]\.osu$' ) class handler(requestsManager.asyncRequestHandler): @tornado.web.asynchronous @tornado.gen.engine @sentry.captureTornado def asyncGet(self, fileName=None): try: # Check arguments if fileName is None: raise exceptions.invalidArgumentsException(MODULE_NAME) if fileName == "": raise exceptions.invalidArgumentsException(MODULE_NAME)
# -*- coding: utf-8 -*- from re import compile as rcomp __all__ = ('bancho_domain', 'mapfile', 'now_playing') bancho_domain = rcomp(r'^c(?:e|[4-6])?\.ppy\.sh$') mapfile = rcomp( r'^(?P<artist>.+) - (?P<title>.+) \((?P<creator>.+)\) \[(?P<version>.+)\]\.osu$' ) now_playing = rcomp( r'^\x01ACTION is (?:playing|editing|watching|listening to) ' r'\[https://osu.ppy.sh/b/(?P<bid>\d{1,7}) .+\]' r'(?P<mods>(?: (?:-|\+|~|\|)\w+(?:~|\|)?)+)?\x01$')