def load(filename): root = et.parse(filename) gdata = root.find('./graphics').attrib result = SpriteSet() result.load_image(gdata['file'], gdata.get('transparent', False)) sprites = dict() for snode in root.findall('./sprite'): sprite = dict() sprites[snode.attrib['key']] = sprite for i, frame in enumerate(snode.findall('./img')): sprite[i] = pygame.Rect(evaluate(frame.attrib['rect'])) if 'key' in frame.attrib: sprite[frame.attrib['key']] = sprite[i] for alias in snode.findall('./alias'): sprite[alias.attrib['key']] = sprite[alias.attrib['means']] for alias in root.findall('./alias'): sprites[alias.attrib['key']] = sprites[alias.attrib['means']] cursors = SafeDict() for cnode in root.findall('./cursor'): rect = pygame.Rect(evaluate(cnode.attrib['rect'])) hotspot = Pt(evaluate(cnode.attrib.get('hotspot', (0, 0)))) cdata = (rect, hotspot) cursors[cnode.attrib['key']] = cdata if cnode.attrib.get('default', False): cursors.default = cdata result.rects = sprites result.cursors = cursors return result
def blacklister(): result = client.request('https://pastebin.com/raw/eh5pPA6K') kids_urls = [''.join([GM_BASE, i]) for i in evaluate(result)] return kids_urls
def get(table=control.bookmarksFile): try: control.makeFile(control.dataPath) dbcon = database.connect(table) dbcur = dbcon.cursor() dbcur.execute("SELECT * FROM bookmark") items = dbcur.fetchall() try: items = [evaluate(i[1].encode('utf-8')) for i in items] except Exception: items = [evaluate(i[1]) for i in items] return items except Exception: pass
def load_image(self, filename, transparency=None): img_file = path.join(sprite_dir, filename) self.graphics = pygame.image.load(img_file) self.graphic_file = filename self.transparency = False if transparency: if transparency in ['default', 'yes', 'True']: self.transparency = True elif transparency in ['no', 'False', 'None']: self.transparency = False elif transparency in ['top_left', 'topleft']: transparency = self.graphics.get_at((0, 0)) elif transparency.__class__ == str: transparency = evaluate(transparency) if transparency.__class__ in [tuple, pygame.Color]: self.graphics.set_colorkey(transparency) self.transparency = 'key' return self.graphics
def __eq__(self, line): try: self.__good = evaluate(self.__parser.parse(line)['r']) return True except: return False
def get(function_, duration, *args, **table): try: response = None f = repr(function_) f = re.sub(r'.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f) a = hashlib.md5() for i in args: a.update(str(i)) a = str(a.hexdigest()) except Exception: pass try: table = table['table'] except Exception: table = 'rel_list' try: control.makeFile(control.dataPath) dbcon = db.connect(control.cacheFile) dbcur = dbcon.cursor() dbcur.execute( "SELECT * FROM {tn} WHERE func = '{f}' AND args = '{a}'".format( tn=table, f=f, a=a)) match = dbcur.fetchone() try: response = evaluate(match[2].encode('utf-8')) except AttributeError: response = evaluate(match[2]) t1 = int(match[3]) t2 = int(time.time()) update = (abs(t2 - t1) / 3600) >= int(duration) if not update: return response except Exception: pass try: r = function_(*args) if (r is None or r == []) and response is not None: return response elif r is None or r == []: return r except Exception: return try: r = repr(r) t = int(time.time()) dbcur.execute("CREATE TABLE IF NOT EXISTS {} (" "func TEXT, " "args TEXT, " "response TEXT, " "added TEXT, " "UNIQUE(func, args)" ");".format(table)) dbcur.execute( "DELETE FROM {0} WHERE func = '{1}' AND args = '{2}'".format( table, f, a)) dbcur.execute("INSERT INTO {} Values (?, ?, ?, ?)".format(table), (f, a, r, t)) dbcon.commit() except Exception: pass try: return evaluate(r.encode('utf-8')) except Exception: return evaluate(r)
def __init__(self, attributes): self.stats = attributes self.stats['color'] = evaluate(attributes['color'])
def __init__(self, data): self.pos = Pt(evaluate(data['pos'])) self.sprite = data['sprite'] self.character_class = data['class'] self.range = float(data['range'])
def __init__(self, data): self.pos = Pt(evaluate(data['pos'])) self.key = data['key'] self.color = evaluate(data['color'])
def __init__(self, data): self.pos = Pt(evaluate(data['pos'])) self.type = data['type'] self.color = evaluate(data['color']) self.range = float(data['range'])