All pastes #824081 Raw Edit

Meins

public python v1 · immutable
·published 2007-12-19 19:46 UTC
rendered paste body
# -*- coding: utf-8 -*-"""    tactics.lib.resources    =====================    Tactics resources management.    :copyright: 2007 by Manni    :license:   GNU GPL"""import os, sysfrom pygame.surface import Surfacefrom os.path import abspath, join as pathjoin, dirnamefrom tactics.lib.display import load_imageRESOURCE_DIR = abspath(pathjoin(dirname(__file__), '..', 'resources'))def resource_path(name, type=None):    return type is not None and pathjoin(RESOURCE_DIR, type.lower(), name) \                             or pathjoin(RESOURCE_DIR, name)class Resource(file):    def __init__(self, name, mode='r', type=None):        file.__init__(self, resource_path(name, type), mode)class ImageResource(Resource):    def __new__(cls, name):        return load_image(resource_path(name, 'images'))