Ejemplo n.º 1
0
def _generate_report(mask, output_file=None, conf=None, data=None):
    if conf is None:
        conf = get_conf()

    base_path = os.path.join(conf.paths.output, conf.git.branches.current, 'json')
    docs = expand_tree(base_path, '.json')

    if mask is not None:
        if mask.startswith('/'):
            mask = mask[1:]

        mask = os.path.join(base_path, mask)

    if data is None:
        output = runner( jobs=report_jobs(docs, mask),
                         retval='results')
    else:
        output = data

    if output_file is None:
        return output
    else:
        if output_file == 'print':
            print(json.dumps(output, indent=2))
        else:
            with open(output_file, 'w') as f:
                json.dump(output, f)
Ejemplo n.º 2
0
def htaccess(fn='.htaccess'):
    conf = lazy_conf()

    in_files = (i for i in expand_tree(conf.paths.builddata, 'yaml')
                if os.path.basename(i).startswith('htaccess'))

    sources = []
    for i in in_files:
        sources.extend(ingest_yaml_list(i))

    dirname = os.path.dirname(fn)
    if not dirname == '' and not os.path.exists(dirname):
        os.makedirs(dirname)

    lines = set([])

    for redir in sources:
        lines.add(
            generate_redirects(process_redirect(redir, conf),
                               conf=conf,
                               match=False))

    with open(fn, 'w') as f:
        f.writelines(lines)
        f.write('\n')
        f.writelines([
            '<FilesMatch "\.(ttf|otf|eot|woff)$">', '\n',
            '   Header set Access-Control-Allow-Origin "*"', '\n'
            '</FilesMatch>', '\n'
        ])

    logging.info(
        'redirect: regenerated {0} with {1} redirects ({2} lines)'.format(
            fn, len(sources), len(lines)))
Ejemplo n.º 3
0
def tags():
    "Uses 'etags' to generate a TAG index to aid navigation."

    conf = get_conf()

    regexp_fn = os.path.join(os.path.join(conf.paths.projectroot,
                                          conf.paths.tools, 'etags.regexp'))

    if not os.path.exists(regexp_fn):
        abort('[dev]: cannot regenerate TAGS: no {0} file'.format(regexp_fn))

    source = expand_tree(os.path.join(conf.paths.projectroot,
                                      conf.paths.source), 'txt')

    if len(source) == 0:
        abort('[dev]: no source files in {0}'.format(source))

    source = ' '.join(source)

    local('etags -I --language=none --regex=@{0} {1}'.format(regexp_fn, source))

    regexps = [
        (re.compile(r'\.\. (.*):: \$*(.*)'), r'\1.\2'),
        (re.compile(r'\.\. _(.*)'), r'ref.\1')
    ]

    munge_page(fn=os.path.join(conf.paths.projectroot, 'TAGS'),
               regex=regexps,
               tag='dev')
Ejemplo n.º 4
0
def htaccess(fn='.htaccess'):
    conf = lazy_conf()

    in_files = ( i
                 for i in expand_tree(conf.paths.builddata, 'yaml')
                 if os.path.basename(i).startswith('htaccess') )

    sources = []
    for i in in_files:
        sources.extend(ingest_yaml_list(i))

    dirname = os.path.dirname(fn)
    if not dirname == '' and not os.path.exists(dirname):
        os.makedirs(dirname)

    lines = set( [ ] )

    for redir in sources:
        lines.add(generate_redirects(process_redirect(redir, conf), conf=conf, match=False))

    with open(fn, 'w') as f:
        f.writelines(lines)
        f.write('\n')
        f.writelines( ['<FilesMatch "\.(ttf|otf|eot|woff)$">','\n',
                       '   Header set Access-Control-Allow-Origin "*"', '\n'
                       '</FilesMatch>', '\n'] )

    logging.info('redirect: regenerated {0} with {1} redirects ({2} lines)'.format(fn, len(sources), len(lines)))
Ejemplo n.º 5
0
def tags():
    "Uses 'etags' to generate a TAG index to aid navigation."

    conf = get_conf()

    regexp_fn = os.path.join(
        os.path.join(conf.paths.projectroot, conf.paths.tools, 'etags.regexp'))

    if not os.path.exists(regexp_fn):
        abort('[dev]: cannot regenerate TAGS: no {0} file'.format(regexp_fn))

    source = expand_tree(
        os.path.join(conf.paths.projectroot, conf.paths.source), 'txt')

    if len(source) == 0:
        abort('[dev]: no source files in {0}'.format(source))

    source = ' '.join(source)

    local('etags -I --language=none --regex=@{0} {1}'.format(
        regexp_fn, source))

    regexps = [(re.compile(r'\.\. (.*):: \$*(.*)'), r'\1.\2'),
               (re.compile(r'\.\. _(.*)'), r'ref.\1')]

    munge_page(fn=os.path.join(conf.paths.projectroot, 'TAGS'),
               regex=regexps,
               tag='dev')
Ejemplo n.º 6
0
def run():
    if env.regex is None:
        abort('must specify a regex')
    if env.replacement is None:
        abort('must specify a replacement')

    conf = lazy_conf()

    source_dir = os.path.join(conf.paths.projectroot, conf.paths.source)

    files = expand_tree(path=source_dir, input_extension=None)
    
    results = []
    with ProcessPool() as p:
        for fn in files:
            r = p.apply_async(munge_page, args=[fn, (env.regex, env.replacement), fn, 'editing' ])
            results.append(r)
Ejemplo n.º 7
0
def run():
    if env.regex is None:
        abort('must specify a regex')
    if env.replacement is None:
        abort('must specify a replacement')

    conf = lazy_conf()

    source_dir = os.path.join(conf.paths.projectroot, conf.paths.source)

    files = expand_tree(path=source_dir, input_extension=None)

    results = []
    with ProcessPool() as p:
        for fn in files:
            r = p.apply_async(
                munge_page,
                args=[fn, (env.regex, env.replacement), fn, 'editing'])
            results.append(r)
Ejemplo n.º 8
0
def get_migration_specifications(conf):
    return [ fn for fn in expand_tree(os.path.join(conf.paths.projectroot,
                                                   conf.paths.builddata))
             if 'primer' in fn and 'migrations' in fn ]
Ejemplo n.º 9
0
def get_migration_specifications(conf):
    return [
        fn for fn in expand_tree(
            os.path.join(conf.paths.projectroot, conf.paths.builddata))
        if 'primer' in fn and 'migrations' in fn
    ]