35 lines
653 B
Python
Executable file
35 lines
653 B
Python
Executable file
import os
|
|
import sys
|
|
import pygame
|
|
|
|
def get_basedir():
|
|
execpath = sys.argv[0]
|
|
execpath = os.path.split(execpath)[0]
|
|
if not execpath:
|
|
return '.'
|
|
return execpath
|
|
|
|
class filemanager(object):
|
|
def __init__(self):
|
|
self.basepath = get_basedir()
|
|
self.datapath = "data"
|
|
|
|
def path(self, *args):
|
|
return os.path.join(self.basepath, self.datapath, *args)
|
|
|
|
def open(self, *args):
|
|
filename = self.path(*args)
|
|
return open(filename, 'rb')
|
|
|
|
def png(self, *args):
|
|
filename = self.path(*args)
|
|
return pygame.image.load(filename)
|
|
|
|
def canonize_path(self, path):
|
|
return path.lower()
|
|
|
|
def init():
|
|
global mgr
|
|
mgr = filemanager()
|
|
|
|
mgr = None
|