Source

codeaide / codeaide / modes / __init__.py

Full commit
import sys
import os
import re

# XXX: importing from a zip package does not work

module_names = []

def find():
    global module_names
    module_names = []
    #path = os.path.dirname(os.path.abspath(__file__))
    for path in __path__:
        for name in os.listdir(path):
            if re.match("^[A-Za-z][A-ZA-z0-9]*\.py$", name):
                module_names.append(os.path.splitext(name)[0])

                
def add_path(path):
    global module_names
    module_names = [] 
    __path__.insert(0, path)

    
        
def load(name):
    mod = __import__("codeaide.modes.%s" % name, {}, {}, [])
    globals()[name] = mod
    return mod


def load_all(verbose=False):
    if not module_names:
        find()
    for name in module_names:
        if verbose:
            print >> sys.stderr, "Loading modes from codeaide.modes.%s" % name
        load(name)