# Path: procgame/config.py
# def value_for_key_path(keypath, default=None):
# def load():


import os
import struct
import yaml
import sqlite3
import bz2
import time
import dmd 
import logging
import re
import colorsys
import zipfile
    import cv2
    import cv2.cv as cv
                import pdb; pdb.set_trace()
            import animgif
    from cStringIO import StringIO
    from StringIO import StringIO
from PIL import Image 
from dmd import Frame
from sdl2_displaymanager import sdl2_DisplayManager
from procgame import config

# import pygame
# from pygame import movie
try:
    OpenCV_avail = True
except ImportError:
    OpenCV_avail = False

# Global reference; use AnimationCacheManager.shared_manager() to create and reference.
shared_cache_manager = None

warned_cache_disabled = False

class AnimationCacheManager(object):
    def __init__(self, path):
        self.path = os.path.expanduser(path)
        if not os.path.exists(self.path):
            os.makedirs(self.path)
        self.load()
        # TODO: Check cache for deleted files?
    
    def __del__(self):
        self.conn.close()
        del self.conn
    
    def shared_manager():
        """Returns a reference to the global, shared manager, if configured by the
        ``dmd_cache_path`` in :mod:`procgame.config`."""
        global shared_cache_manager
        if not shared_cache_manager:

# Path: procgame/config.py
# def value_for_key_path(keypath, default=None):
# def load():


# Path: procgame/dmd/animation.py
import os
import struct
import yaml
import sqlite3
import bz2
import time
import dmd 
import logging
import re
import colorsys
import zipfile
    import cv2
    import cv2.cv as cv
                import pdb; pdb.set_trace()
            import animgif
    from cStringIO import StringIO
    from StringIO import StringIO
from PIL import Image 
from dmd import Frame
from sdl2_displaymanager import sdl2_DisplayManager
from procgame import config


# import pygame
# from pygame import movie
try:
    OpenCV_avail = True
except ImportError:
    OpenCV_avail = False

# Global reference; use AnimationCacheManager.shared_manager() to create and reference.
shared_cache_manager = None

warned_cache_disabled = False

class AnimationCacheManager(object):
    def __init__(self, path):
        self.path = os.path.expanduser(path)
        if not os.path.exists(self.path):
            os.makedirs(self.path)
        self.load()
        # TODO: Check cache for deleted files?
    
    def __del__(self):
        self.conn.close()
        del self.conn
    
    def shared_manager():
        """Returns a reference to the global, shared manager, if configured by the
        ``dmd_cache_path`` in :mod:`procgame.config`."""
        global shared_cache_manager
        if not shared_cache_manager:

            path = config.value_for_key_path('dmd_cache_path')