Utility function that creates the default patterns for an app
540632
def dmp_paths_for_app(app_name, pattern_kwargs=None, pretty_app_name=None):
    ''''''
    dmp = apps.get_app_config('django_mako_plus')
    # Because these patterns are subpatterns within the app's resolver,
    # we don't include the /app/ in the pattern -- it's already been
    # handled by the app's resolver.
    #
    # Also note how the each pattern below defines the four kwargs--
    # either as 1) a regex named group or 2) in kwargs.
    return [
        # page.function/urlparams
        dmp_path(
            r'^(?P<dmp_page>[_a-zA-Z0-9\-]+)\.(?P<dmp_function>[_a-zA-Z0-9\.\-]+)/(?P<dmp_urlparams>.+?)/?$',
            merge_dicts({
                'dmp_app': app_name or dmp.options['DEFAULT_APP'],
            }, pattern_kwargs),
            'DMP /{}/page.function/urlparams'.format(pretty_app_name),
            app_name,
        ),

        # page.function
        dmp_path(
            r'^(?P<dmp_page>[_a-zA-Z0-9\-]+)\.(?P<dmp_function>[_a-zA-Z0-9\.\-]+)/?$',
            merge_dicts({
                'dmp_app': app_name or dmp.options['DEFAULT_APP'],
                'dmp_urlparams': '',
            }, pattern_kwargs),
            'DMP /{}/page.function'.format(pretty_app_name),
            app_name,
        ),

        # page/urlparams
        dmp_path(
            r'^(?P<dmp_page>[_a-zA-Z0-9\-]+)/(?P<dmp_urlparams>.+?)/?$',
            merge_dicts({
                'dmp_app': app_name or dmp.options['DEFAULT_APP'],
                'dmp_function': 'process_request',
            }, pattern_kwargs),
            'DMP /{}/page/urlparams'.format(pretty_app_name),
            app_name,
        ),

        # page
        dmp_path(
            r'^(?P<dmp_page>[_a-zA-Z0-9\-]+)/?$',
            merge_dicts({
                'dmp_app': app_name or dmp.options['DEFAULT_APP'],
                'dmp_function': 'process_request',
                'dmp_urlparams': '',
            }, pattern_kwargs),
            'DMP /{}/page'.format(pretty_app_name),
            app_name,
        ),

        # empty
        dmp_path(
            r'^$',
            merge_dicts({
                'dmp_app': app_name or dmp.options['DEFAULT_APP'],
                'dmp_function': 'process_request',
                'dmp_urlparams': '',
                'dmp_page': dmp.options['DEFAULT_PAGE'],
            }, pattern_kwargs),
            'DMP /{}'.format(pretty_app_name),
            app_name,
        ),
    ]
260030
function createPatternVariations(pattern) {
    var lastCharIdx = pattern.length - 1,
        patternVariations = [pattern, '!' + pattern];

    if (pattern[lastCharIdx] === '/') {
        var unslashed = pattern.substring(0, lastCharIdx);

        patternVariations.push(unslashed);
        patternVariations.push('!' + unslashed);
    }

    return patternVariations;
}
903574
function lintStyles() {
  // Pass all command line flags to Stylelint.
  const options = minimist( process.argv.slice( 2 ) );
  const willFix = options.fix || false;
  return gulp.src( [
    'packages/**/*.less',
    '!packages/cf-*/node_modules/**/*.less',
    '!packages/cf-grid/src-generated/*.less'
  ] )
    .pipe( gulpStylelint( {
      failAfterError: true,
      fix: willFix,
      reporters: [ { formatter: 'string', console: true } ]
    } ) )
    .pipe( gulp.dest( 'packages' ) );
}
276599
private function generatePatterns()
    {
        foreach ($this->builders as $uri => $builder) {
            $pattern = '/' . ltrim($uri, '/');

            if (preg_match_all('/{[\w]+}/i', $uri, $matches)) {
                foreach (array_unique($matches[0]) as $match) {
                    $pattern = str_replace($match, '[\w\d\@_~\-\.]+', $pattern);
                }
            }

            $this->patterns['#^' . $pattern . '$#i'] = $uri;
        }

        // Sort patterns to ensure that longer more precisely pattern comes first
        krsort($this->patterns);
    }
477473
private static synchronized String getDefaultPattern() {
        ULocale defaultLocale = ULocale.getDefault(Category.FORMAT);
        if (!defaultLocale.equals(cachedDefaultLocale)) {
            cachedDefaultLocale = defaultLocale;
            Calendar cal = Calendar.getInstance(cachedDefaultLocale);

            try {
                // Load the calendar data directly.
                ICUResourceBundle rb = (ICUResourceBundle) UResourceBundle.getBundleInstance(
                        ICUData.ICU_BASE_NAME, cachedDefaultLocale);
                String resourcePath = "calendar/" + cal.getType() + "/DateTimePatterns";
                ICUResourceBundle patternsRb= rb.findWithFallback(resourcePath);

                if (patternsRb == null) {
                    patternsRb = rb.findWithFallback("calendar/gregorian/DateTimePatterns");
                }
                if (patternsRb == null || patternsRb.getSize() < 9) {
                    cachedDefaultPattern = FALLBACKPATTERN;
                } else {
                    int defaultIndex = 8;
                    if (patternsRb.getSize() >= 13) {
                        defaultIndex += (SHORT + 1);
                    }
                    String basePattern = patternsRb.getString(defaultIndex);

                    cachedDefaultPattern = SimpleFormatterImpl.formatRawPattern(
                            basePattern, 2, 2,
                            patternsRb.getString(SHORT), patternsRb.getString(SHORT + 4));
                }
            } catch (MissingResourceException e) {
                cachedDefaultPattern = FALLBACKPATTERN;
            }
        }
        return cachedDefaultPattern;
    }
1006133
def make_default_app_wrapper(name):
    '''  '''
    @functools.wraps(getattr(Bottle, name))
    def wrapper(*a, **ka):
        return getattr(app(), name)(*a, **ka)
    return wrapper
542163
def GetPatternIdTripDict(self):
    """"""
    d = {}
    for t in self._trips:
      d.setdefault(t.pattern_id, []).append(t)
    return d
1040142
def make_urldispatch_application(_, **settings):
    
    patterns = [p.split("=", 1)
                for p in settings['patterns'].split('\n')
                if p]
    application = URLDispatcher()

    for pattern, app in patterns:
        pattern = pattern.strip()
        app = app.strip()
        mod, obj = app.split(":", 1)
        if mod not in sys.modules:
            __import__(mod)
        mod = sys.modules[mod]
        obj = getattr(mod, obj)
        application.add_url(app, pattern, obj)

    return application
118234
function collections(config) {
  config = config || {};

  return function plugin(app, base) {
    if (!utils.isValid(app, 'generate-collections')) return;
    app.define('home', path.resolve.bind(path, os.homedir()));

    /**
     * Options
     */

    app.option(config);

    // add default view collections
    if (!app.files) app.create('files', { viewType: 'renderable'});
    if (!app.includes) app.create('includes', { viewType: 'partial' });
    if (!app.layouts) app.create('layouts', { viewType: 'layout' });
    if (!app.templates) app.create('templates', { viewType: 'renderable' });

    /**
     * Middleware for collections created by this generator
     */

    app.preLayout(/./, function(view, next) {
      if (utils.falsey(view.layout) && !view.isType('partial')) {
        // use the empty layout created above, to ensure that all
        // pre-and post-layout middleware are still triggered
        view.layout = app.resolveLayout(view);
        if (utils.falsey(view.layout)) {
          view.layout = 'empty';
        }
        next();
        return;
      }

      if (view.isType('partial')) {
        view.options.layout = null;
        view.data.layout = null;
        view.layout = null;
        if (typeof view.partialLayout === 'string') {
          view.layout = view.partialLayout;
        }
      }
      next();
    });

    // remove or rename template prefixes before writing files to the file system
    var regex = app.options.templatePathRegex || /./;
    app.templates.preWrite(regex, utils.renameFile(app));
    app.templates.onLoad(regex, function(view, next) {
      var userDefined = app.home('templates', view.basename);
      if (fs.existsSync(userDefined)) {
        view.contents = fs.readFileSync(userDefined);
      }
      utils.stripPrefixes(view);
      utils.parser.parse(view, next);
    });

    // "noop" layout
    app.layout('empty', {content: '{% body %}'});

    // create collections defined on the options
    if (utils.isObject(app.options.create)) {
      for (var key in app.options.create) {
        if (!app[key]) {
          app.create(key, app.options.create[key]);
        } else {
          app[key].option(app.options.create[key]);
        }
      }
    }

    // pass the plugin to sub-generators
    return plugin;
  };
}
166013
function parsePatterns(options) {
  return readFileTree(
    options.src.patterns,
    options.keys.patterns,
    options
  ).then(patternObj => {
    return Promise.all(buildCollections(patternObj, options)).then(
      () => patternObj,
      error => DrizzleError.error(error, options.debug)
    );
  });
}
400782
function copyPattern (pattern) {
  return Object.assign(
    function (context) {
      return function (prevConfig) {
        context.copyPlugin = context.copyPlugin || {patterns: []}

        // Merge the provided advanced pattern into the config
        context.copyPlugin = _extends({}, context.copyPlugin, {
          patterns: [].concat(context.copyPlugin.patterns, [pattern]),
        })

        // Don't alter the config yet
        return prevConfig
      }
    },
    {post: postConfig}
  )
}
412418
def _create_default_tiles(self):
        """"""
        for value, background, text in self.DEFAULT_TILES:
            self.tiles[value] = self._make_tile(value, background, text)
645371
function build_ext_define_patterns(namespaces) {
  var mappedNamespaced = _.map(namespaces, function(ns) {
    [ns + ".define", ns + ".ClassManager.create"]
  });
  return _.flatten(mappedNamespaced);
}
1302261
def decorate(self, app):
		
		from functools import wraps

		@wraps(app)
		def decorated(environ, start_response):
			# capture any start_response from the app
			app_response = {}
			app_response['status'] = "200 OK"
			app_response['headers'] = []
			app_response['written'] = BytesIO()
			def custom_start_response(status, headers, *args, **kwargs):
				app_response['status'] = status
				app_response['headers'] = headers
				app_response['args'] = args
				app_response['kwargs'] = kwargs
				return app_response['written'].write
			returned = app(environ, custom_start_response)

			# callbacks from the serialization
			def set_http_code(status):
				app_response['status'] = str(status)
			def set_header(header, value):
				app_response['headers'] = [(h,v) for (h,v) in app_response['headers'] if h.lower() != header.lower()]
				app_response['headers'].append((header, value))
			def set_content_type(content_type):
				set_header('Content-Type', content_type)

			# do the serialization
			accept = environ.get('HTTP_ACCEPT', '')
			new_return = self.output(returned, accept, set_http_code, set_content_type)

			# set the Vary header
			vary_headers = (v for (h,v) in app_response['headers'] if h.lower() == 'vary')
			vary_elements = list(itertools.chain(*[v.split(',') for v in vary_headers]))
			vary_elements = list(set([v.strip() for v in vary_elements]))
			if '*' not in vary_elements and 'accept' not in (v.lower() for v in vary_elements):
				vary_elements.append('Accept')
				set_header('Vary', ', '.join(vary_elements))

			# pass on the result to the parent WSGI server
			parent_writer = start_response(app_response['status'],
			                               app_response['headers'],
			                               *app_response.get('args', []),
			                               **app_response.get('kwargs', {}))
			written = app_response['written'].getvalue()
			if len(written) > 0:
				parent_writer(written)
			return new_return
		return decorated
484606
def defaults(default=None):
    
    def _f(func):
        @functools.wraps(func)
        def __f(self, *args, **kwargs):
            try:
                return func(self, *args, **kwargs)
            except Exception:
                return default
        return __f
    return _f
190239
function pugPlugin(options) {
    // prepare extensions to match with the extname() result
    const filter = makeFilter(options, ['.pug', '.jade']);
    // Shallow copy of user options & defaults
    const config = parseOptions(options);
    /** Is this a static file? */
    function matchStaticPattern(file) {
        return config.staticPattern && config.staticPattern.test(file);
    }
    return {
        name: 'rollup-plugin-pug',
        options(opts) {
            if (!config.basedir) {
                const basedir = opts.input;
                // istanbul ignore else
                if (basedir && typeof basedir == 'string') {
                    config.basedir = path.dirname(path.resolve(basedir));
                }
                else {
                    config.basedir = path.resolve('.');
                }
            }
        },
        /**
         * Avoid the inclusion of the runtime
         * @param id
         */
        resolveId(id) {
            return id === config._runtimeImport && config.pugRuntime || null;
        },
        transform(code, id) {
            if (!filter(id)) {
                return null;
            }
            const isStatic = matchStaticPattern(id);
            const pugOpts = clonePugOpts(config, id);
            let body;
            let map;
            let fn;
            if (isStatic) {
                /*
                  This template is executed now and, at runtime, will be loaded through
                  `import` so it will not have access to runtime variables or methods.
                  Instead, we use here the `local` variables and the compile-time options.
                */
                const staticOpts = Object.assign({}, config.locals, config, { filename: id });
                fn = pug.compile(code, pugOpts);
                body = fn(staticOpts);
                body = `export default ${JSON.stringify(body)};\n`;
            }
            else {
                /*
                  This template will generate a module with a function to be executed at
                  runtime. It will be user responsibility to pass the correct parameters
                  to the function, here we only take care of the `imports`, incluiding the
                  pug runtime.
                */
                const imports = [];
                if (config.sourceMap) {
                    pugOpts.compileDebug = map = true;
                }
                // move the imports from the template to the top of the output queue
                code = moveImports(code, imports);
                // get function body and dependencies
                fn = pug.compileClientWithDependenciesTracked(code, pugOpts);
                body = fn.body.replace('function template(', '\nexport default function(');
                // put the pung-runtime import as the first of the queue, if neccesary
                if (config._runtimeImport && /\bpug\./.test(body)) {
                    imports.unshift(`import pug from '${config._runtimeImport}';`);
                }
                // convert imports into string and add the template function
                body = imports.join('\n') + `${body};\n`;
            }
            const dependencies = arrIfDeps(fn.dependencies);
            if (map) {
                const bundle = genPugSourceMap(id, body, {
                    basedir: config.basedir,
                    keepDebugLines: config.compileDebug,
                });
                // HACK: 'as any' to avoid conflict with wrong rollup 6.6 typings
                return { code: bundle.data, map: bundle.map, dependencies };
            }
            return { code: body, map: null, dependencies };
        },
    };
}
1247293
def build_string(self, *pattern, **kwargs):
        
        set_defaults(self._string_defaults, kwargs)
        set_defaults(self._defaults, kwargs)
        return StringPattern(*pattern, **kwargs)