/util.py
import pygame
import os.path

import config

def loadWAV(path,library=False):
	try:
		return pygame.mixer.Sound(path)
	except pygame.error:
		(dir,file) = os.path.split(path)
		try:
			return pygame.mixer.Sound(os.path.join(dir,file.lower()))
		except pygame.error:
			if library:
				return None
			else:
				# Ok, try the system sample library...
				return loadWAV(os.path.join(config.librarypath,file),True)

def loadMP3(path):
	pygame.mixer.music.load(path)
	return pygame.mixer.music

def loadBMP(path):
	try:
		return pygame.image.load(path).convert()
	except pygame.error:
		(dir,file) = os.path.split(path)
		try:
			return pygame.image.load(os.path.join(dir,file.lower())).convert()
		except pygame.error:
			return None