load and decorate urls from all modules
        then store it as cached property for less loading
481865
def urlpatterns(self):
        '''
        '''
        if not hasattr(self, '_urlspatterns'):
            urlpatterns = []
            # load all urls
            # support .urls file and urls_conf = 'elephantblog.urls' on default module
            # decorate all url patterns if is not explicitly excluded
            for mod in leonardo.modules:
                # TODO this not work
                if is_leonardo_module(mod):

                    conf = get_conf_from_module(mod)

                    if module_has_submodule(mod, 'urls'):
                        urls_mod = import_module('.urls', mod.__name__)
                        if hasattr(urls_mod, 'urlpatterns'):
                            # if not public decorate all

                            if conf['public']:
                                urlpatterns += urls_mod.urlpatterns
                            else:
                                _decorate_urlconf(urls_mod.urlpatterns,
                                                  require_auth)
                                urlpatterns += urls_mod.urlpatterns
            # avoid circural dependency
            # TODO use our loaded modules instead this property
            from django.conf import settings
            for urls_conf, conf in six.iteritems(getattr(settings, 'MODULE_URLS', {})):
                # is public ?
                try:
                    if conf['is_public']:
                        urlpatterns += \
                            patterns('',
                                     url(r'', include(urls_conf)),
                                     )
                    else:
                        _decorate_urlconf(
                            url(r'', include(urls_conf)),
                            require_auth)
                        urlpatterns += patterns('',
                                                url(r'', include(urls_conf)))
                except Exception as e:
                    raise Exception('raised %s during loading %s' %
                                    (str(e), urls_conf))

            self._urlpatterns = urlpatterns

        return self._urlpatterns
906328
def cache(opts, serial):
    '''
    
    '''
    return LazyLoader(
        _module_dirs(opts, 'cache', 'cache'),
        opts,
        tag='cache',
        pack={'__opts__': opts, '__context__': {'serial': serial}},
    )
439373
def cache_script(script, text, opts={}):
    """"""
    global script_cache
    if script not in script_cache:
        update_script_cache(script, text, opts)
        pass
    return script
483188
function(request, modules_root, options){
        var [path, analysis] = normalize_path(request, modules_root, options.relative_path_root);
        var cache_path = path; // define cachepath as path to file with content. For modules, defines path to package.json
        if(analysis.is_a_module) cache_path = "module:" + cache_path; // since modules return package.json request, distinguish between module requests and actual requests to package.json
        return cache_path;
    }
936324
def _load_formatters(module_name):
    """"""
    mod = __import__(module_name, None, None, ['__all__'])
    for formatter_name in mod.__all__:
        cls = getattr(mod, formatter_name)
        _formatter_cache[cls.name] = cls
879349
function normalizeModules(modules) {
    var normalized = {};

    Object.keys(modules).forEach(function (key) {
        var module = modules[key];

        // make sure each vuex module has all keys defined
        normalized[key] = {
            actions: module.actions || {},
            getters: module.getters || {},
            modules: module.modules ? normalizeModules(module.modules) : {},
            mutations: module.mutations || {},
            namespaced: module.namespaced || false,
            state: {}
        };

        // make sure our state is a fresh object
        if (typeof module.state === 'function') {
            normalized[key].state = module.state();
        } else if (_typeof(module.state) === 'object') {
            normalized[key].state = JSON.parse(JSON.stringify(module.state));
        }
    });

    return normalized;
}
265940
function reload(moduleName) {
    var id = require.resolve(moduleName);
    var mod = require.cache[id];
    if (mod) {
        var base = path.dirname(mod.filename);
        // expunge each module cache entry beneath this folder
        var stack = [mod];
        while (stack.length) {
            var mod = stack.pop();
            if (beneathBase(mod.filename)) {
                delete require.cache[mod.id];
            }
            stack.push.apply(stack, mod.children);
        }
    }

    // expunge each path cache entry beneath the folder
    for (var cacheKey in module.constructor._pathCache) {
        if (cacheKey.indexOf(moduleName) > 0 && beneathBase(cacheKey)) {
            delete module.constructor._pathCache[cacheKey];
        }
    }

    // re-require the module
    return require(moduleName);

    function beneathBase(file) {
        return base === undefined
            || (file.length > base.length
                && file.substr(0, base.length + 1) === base + path.sep);
    }
}
359705
def cached_get(timeout, *params):
    """"""

    def decorator(view_func):
        @wraps(view_func, assigned=available_attrs(view_func))
        def _wrapped_view(view_or_request, *args, **kwargs):

            # The type of the request gets muddled when using a function based
            # decorator. We must use a function based decorator so it can be
            # used in urls.py.
            request = getattr(view_or_request, "request", view_or_request)

            if not hasattr(_thread_locals, "ultracache_request"):
                setattr(_thread_locals, "ultracache_request", request)

            # If request not GET or HEAD never cache
            if request.method.lower() not in ("get", "head"):
                return view_func(view_or_request, *args, **kwargs)

            # If request contains messages never cache
            l = 0
            try:
                l = len(request._messages)
            except (AttributeError, TypeError):
                pass
            if l:
                return view_func(view_or_request, *args, **kwargs)

            # Compute a cache key
            li = [str(view_or_request.__class__), view_func.__name__]

            # request.get_full_path is implicitly added it no other request
            # path is provided. get_full_path includes the querystring and is
            # the more conservative approach but makes it trivially easy for a
            # request to bust through the cache.
            if not set(params).intersection(set((
                "request.get_full_path()", "request.path", "request.path_info"
            ))):
                li.append(request.get_full_path())

            if "django.contrib.sites" in settings.INSTALLED_APPS:
                li.append(get_current_site_pk(request))

            # Pre-sort kwargs
            keys = list(kwargs.keys())
            keys.sort()
            for key in keys:
                li.append("%s,%s" % (key, kwargs[key]))

            # Extend cache key with custom variables
            for param in params:
                if not isinstance(param, str):
                    param = str(param)
                li.append(eval(param))

            s = ":".join([str(l) for l in li])
            hashed = hashlib.md5(s.encode("utf-8")).hexdigest()
            cache_key = "ucache-get-%s" % hashed
            cached = cache.get(cache_key, None)
            if cached is None:
                # The get view as outermost caller may bluntly set _ultracache
                request._ultracache = []
                response = view_func(view_or_request, *args, **kwargs)
                content = None
                if isinstance(response, TemplateResponse):
                    content = response.render().rendered_content
                elif isinstance(response, HttpResponse):
                    content = response.content
                if content is not None:
                    headers = getattr(response, "_headers", {})
                    cache.set(
                        cache_key,
                        {"content": content, "headers": headers},
                        timeout
                    )
                    cache_meta(request, cache_key)
            else:
                response = HttpResponse(cached["content"])
                # Headers has a non-obvious format
                for k, v in cached["headers"].items():
                    response[v[0]] = v[1]

            return response

        return _wrapped_view
    return decorator
1358171
function purgeCache(moduleName) {
    // Traverse the cache looking for the files
    // loaded by the specified module name
    searchCache(moduleName, function (mod) {
        delete require.cache[mod.id];
    });

    // Remove cached paths to the module.
    // Thanks to @bentael for pointing this out.
    Object.keys(module.constructor._pathCache).forEach(function(cacheKey) {
        if (cacheKey.indexOf(moduleName)>0) {
            delete module.constructor._pathCache[cacheKey];
        }
    });
  }
722323
function(paths, callback, results, cached) {
        results = results || [];

        if(!paths.length) {
            callback.apply(null, results);
            return results;
        }

        var path = paths.shift();

        //what do we do if it's not a string ?
        if(typeof path !== 'string') {
            results.push(null);
            //um skip it?
            loadArray(paths, callback, results, cached);
            return;
        }

        acquire.loadPath(path, function(result) {
            results.push(result);
            loadArray(paths, callback, results, cached);
        }, cached);
    }
92975
function loadModules(rootDir, paths) {
        var serverModules = {};
        var me = this;

        // return empty object if no rootDir or paths
        if (!rootDir || !paths) { return serverModules; }

        // loop through paths and load all modules in those directories
        _.each(paths, function (relativePath) {
            var fullPath = path.normalize(rootDir + delim + relativePath);

            // if the directory doesn't exist, then skip to the next loop iteration
            if (fs.existsSync(fullPath)) {

                _.each(fs.readdirSync(fullPath), function (fileName) {

                    // if it is a javascript file and it DOES NOT end in .service.js, then save the mapping
                    if (utils.isJavaScript(fileName) && !fileName.match(/^.*\.service\.js$/)) {
                        var nameLower = utils.getCamelCase(fileName).toLowerCase();
                        var fullFilePath = path.normalize(fullPath + '/' + fileName);

                        // there are 2 diff potential aliases for any given server module
                        serverModules[nameLower + 'fromplugin'] = serverModules[nameLower] = require(fullFilePath);
                    }

                    // else if we are dealing   with a directory, recurse down into the folder
                    else if (fs.lstatSync(path.join(fullPath, fileName)).isDirectory()) {
                        _.extend(serverModules, me.loadModules(rootDir, [relativePath + '/' + fileName]));
                    }

                });
            }
        });

        return serverModules;
    }
285407
def cache_page(*args, **kwargs):
    '''
    
    '''
    decorator = _django_cache_page(*args, **kwargs)
    def flavoured_decorator(func):
        return vary_on_flavour_fetch(decorator(vary_on_flavour_update(func)))
    return flavoured_decorator
1000807
function cacheModule(config) {
    config = utilities.parseConfig(config);
    var moduleCache = utilities.getCachePath();
    console.log('Module cache at ' + moduleCache);

    var version = getModuleVersionFromConfig(config);

    var pkgStr = config.nodePackageName + (version ? '@' + version : '');
    return utilities.getVersionForNpmPackage(pkgStr).then(function (versionString) {
        // Install correct cordova version if not available
        var packagePath = path.join(moduleCache, config.nodePackageName || CORDOVA);
        var versionPath = path.join(packagePath, version ? version : versionString);
        var targetModulePath = path.join(versionPath, 'node_modules', config.nodePackageName)
        if (!utilities.fileExistsSync(targetModulePath)) {  // Fix: Check module is there not just root path
            if (!utilities.fileExistsSync(packagePath)) {
                fs.mkdirSync(packagePath);
            }
            
            if (!utilities.fileExistsSync(versionPath)) {
                fs.mkdirSync(versionPath);
                fs.mkdirSync(path.join(versionPath, 'node_modules')); // node_modules being present ensures correct install loc
            }

            console.log('Installing ' + pkgStr + ' to ' + versionPath + '. (This may take a few minutes.)');
            var cmd = 'npm install --force ' + pkgStr + ' 2>&1';
            return exec(cmd, { cwd: versionPath })
                .then(utilities.handleExecReturn)
                .then(function () {
                return {
                    version: version,
                    path: targetModulePath
                };
            });
        } else {
            console.log(pkgStr + ' already installed.');
            return Q({
                version: version,
                path: targetModulePath
            });
        }
    });
}
415235
function getStandardModule(url) {
  if (!(url in standardModuleCache)) {
    var symbol = new ModuleSymbol(null, null, null, url);
    var moduleInstance = traceur.runtime.modules[url];
    Object.keys(moduleInstance).forEach((name) => {
      symbol.addExport(name, new ExportSymbol(null, name, null));
    });
    standardModuleCache[url] = symbol;
  }
  return standardModuleCache[url];
}
488775
function getModule(name, loader) {
    var exports;
    var entry = loader.defined[name];

    if (!entry) {
      exports = loader.get(name);
      if (!exports)
        throw new Error('Unable to load dependency ' + name + '.');
    }

    else {
      if (entry.declarative)
        ensureEvaluated(name, entry, [], loader);
    
      else if (!entry.evaluated)
        linkDynamicModule(entry, loader);

      exports = entry.module.exports;
    }

    if ((!entry || entry.declarative) && exports && exports.__useDefault)
      return exports['default'];
    
    return exports;
  }
603892
function init(){
    self.caches = [];
    if(isEmpty(cacheModules)){
      log(false, 'No cacheModules array provided--using the default configuration.');
      getDefaultConfiguration();
    }
    else{
      log(false, 'cacheModules array provided--using a custom configuration.');
      getCustomConfiguration();
      if(self.caches.length < 1){
        throw new Exception('NoCacheException', 'No caches were succesfully initialized.');
      }
    }
  }
242435
function (name, prop) {
    if (mod._destroy) throw new ModHasBeenDestroyedError();

    let c = mod._cache[name];
    if (c && c.data) {
      let m = c.data;
      if (prop) {
        if (prop in m) {
          return m[prop];
        } else {
          throw new ModuleHasNoPropertyError(`module "${name}" has no property names "${prop}"`);
        }
      } else {
        return m;
      }
    } else {
      throw new RequireModuleError(`cannot require module "${name}"`);
    }
  }