# Path: core/config.py
# def get_sprite(frame):
# def load_image(name):
# def load_sound(name):
# def load_text(name, lang):
# def loop_sound(sound):
# def on_off(condition):
# def percent_str(var):
# def play_music(name):
# def set_volume():
# def init_music_volume():
# def show_fps():
# def take_screenshot():
# def toggle_frame_limit():
# def toggle_fullscreen():
# def toggle_pause():
#     def __init__(self, *keys):
# APP_DATA_WIN = 'APPDATA'
# APP_DATA_LIN = 'HOME'
# BLIT_FLAGS    = HWSURFACE | HWACCEL | ASYNCBLIT | RLEACCEL
# CURSOR_BEEP   = load_sound('cursor.wav')
# CURSOR_SELECT = load_sound('select.wav')
# DATA_STORE    = join(environ[APP_DATA_WIN if 'win' in sys.platform else APP_DATA_LIN], 'Invasodado')
# DEBUG         =  __debug__ and not hasattr(sys, 'frozen') #cx_freeze adds 'frozen' to the sys module
# DEPTH         = 8
# EARTH         = load_image('earth.png')
# ENCODING      = 'utf-8'
# EVENTS_OK     = (KEYDOWN, MOUSEBUTTONDOWN, QUIT)
# FONT          = pygame.font.Font(join('gfx', 'font.ttf'), 18)
# FULL_FLAGS    = FULLSCREEN | HWSURFACE | DOUBLEBUF
# GRID_BG       = load_image('bg.png')
# ON_OFF        = {
#                  'en' : ("Off", "On"),
#                  'es' : ("No" , "Sí"),
#                 }
# PAUSE         = load_sound('pause.wav')
# SCREEN_DIMS   = tuple(pygame.display.list_modes())
# SCREEN_HEIGHT = screen.get_height()
# SCREEN_RECT   = Rect((0, 0), screen.get_size())
# SCREEN_WIDTH  = screen.get_width()
# SPRITES       = load_image('sprites.png')
# EARTH = EARTH.subsurface(Rect(0, 0, EARTH.get_width(), EARTH.get_height() / 2))
# class Enum:


from contextlib import closing
from datetime   import datetime
from functools  import lru_cache
from json       import dumps, load, loads
from sys        import platform
from os         import mkdir
from os.path    import isdir, join
from core import config
import shelve


### Constants ##################################################################
PATTERN      = '%Y-%m-%d %H:%M:%S'
SCORE_FORMAT = '{0.name}|{0.score}|{0.mode}|{0.platform}|{0.time}'
################################################################################

### Functions ##################################################################
def load_defaults(scores):
    '''
    @param scores: Either a file-like object or a string, either of which must
                   hold JSON-formatted data.

    Takes in a JSON file and loads default scores from there.
    This is meant to be used for default high score tables, and NOT for storage.
    '''
    if isinstance(scores, str):
        return load(open(scores))
    else:
        return loads(dumps(scores))

################################################################################

### Preparation ###############################################################
try:
#Let's try to make a directory...

# Path: core/config.py
# def get_sprite(frame):
# def load_image(name):
# def load_sound(name):
# def load_text(name, lang):
# def loop_sound(sound):
# def on_off(condition):
# def percent_str(var):
# def play_music(name):
# def set_volume():
# def init_music_volume():
# def show_fps():
# def take_screenshot():
# def toggle_frame_limit():
# def toggle_fullscreen():
# def toggle_pause():
#     def __init__(self, *keys):
# APP_DATA_WIN = 'APPDATA'
# APP_DATA_LIN = 'HOME'
# BLIT_FLAGS    = HWSURFACE | HWACCEL | ASYNCBLIT | RLEACCEL
# CURSOR_BEEP   = load_sound('cursor.wav')
# CURSOR_SELECT = load_sound('select.wav')
# DATA_STORE    = join(environ[APP_DATA_WIN if 'win' in sys.platform else APP_DATA_LIN], 'Invasodado')
# DEBUG         =  __debug__ and not hasattr(sys, 'frozen') #cx_freeze adds 'frozen' to the sys module
# DEPTH         = 8
# EARTH         = load_image('earth.png')
# ENCODING      = 'utf-8'
# EVENTS_OK     = (KEYDOWN, MOUSEBUTTONDOWN, QUIT)
# FONT          = pygame.font.Font(join('gfx', 'font.ttf'), 18)
# FULL_FLAGS    = FULLSCREEN | HWSURFACE | DOUBLEBUF
# GRID_BG       = load_image('bg.png')
# ON_OFF        = {
#                  'en' : ("Off", "On"),
#                  'es' : ("No" , "Sí"),
#                 }
# PAUSE         = load_sound('pause.wav')
# SCREEN_DIMS   = tuple(pygame.display.list_modes())
# SCREEN_HEIGHT = screen.get_height()
# SCREEN_RECT   = Rect((0, 0), screen.get_size())
# SCREEN_WIDTH  = screen.get_width()
# SPRITES       = load_image('sprites.png')
# EARTH = EARTH.subsurface(Rect(0, 0, EARTH.get_width(), EARTH.get_height() / 2))
# class Enum:


# Path: core/highscoretable.py
from contextlib import closing
from datetime   import datetime
from functools  import lru_cache
from json       import dumps, load, loads
from sys        import platform
from os         import mkdir
from os.path    import isdir, join
from core import config
import shelve



### Constants ##################################################################
PATTERN      = '%Y-%m-%d %H:%M:%S'
SCORE_FORMAT = '{0.name}|{0.score}|{0.mode}|{0.platform}|{0.time}'
################################################################################

### Functions ##################################################################
def load_defaults(scores):
    '''
    @param scores: Either a file-like object or a string, either of which must
                   hold JSON-formatted data.

    Takes in a JSON file and loads default scores from there.
    This is meant to be used for default high score tables, and NOT for storage.
    '''
    if isinstance(scores, str):
        return load(open(scores))
    else:
        return loads(dumps(scores))

################################################################################

### Preparation ###############################################################
try:
#Let's try to make a directory...

    mkdir(config.DATA_STORE)