Beispiel #1
0
def generate(d, overwrite=True, silent=False):
    '''Borrowed from Sphinx 1.3b3'''

    """Generate project based on values in *d*."""

    texescape.init()

    if 'mastertoctree' not in d:
        d['mastertoctree'] = ''
    if 'mastertocmaxdepth' not in d:
        d['mastertocmaxdepth'] = 2

    d['project_fn'] = make_filename(d['project'])
    d['project_manpage'] = d['project_fn'].lower()
    d['now'] = time.asctime()
    d['project_underline'] = column_width(d['project']) * '='

    d['copyright'] = time.strftime('%Y') + ', ' + d['author']
    d['author_texescaped'] = text_type(d['author']
        ).translate(texescape.tex_escape_map)
    d['project_doc'] = d['project'] + ' Documentation'
    d['project_doc_texescaped'] = text_type(d['project'] + ' Documentation'
        ).translate(texescape.tex_escape_map)

    # escape backslashes and single quotes in strings that are put into
    # a Python string literal
    for key in ('project', 'project_doc', 'project_doc_texescaped',
                'author', 'author_texescaped', 'copyright',
                'version', 'release', 'master'):
        d[key + '_str'] = d[key].replace('\\', '\\\\').replace("'", "\\'")

    if not path.isdir(d['path']):
        mkdir_p(d['path'])

    srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']

    mkdir_p(srcdir)
    d['exclude_patterns'] = ''
    #if d['sep']:
    #    builddir = path.join(d['path'], 'build')
    #
    #else:
    #    builddir = path.join(srcdir, d['dot'] + 'build')
    #    d['exclude_patterns'] = repr(d['dot'] + 'build')
    #mkdir_p(builddir)
    mkdir_p(path.join(srcdir, d['dot'] + 'templates'))
    mkdir_p(path.join(srcdir, d['dot'] + 'static'))

    def write_file(fpath, content, newline=None):
        if overwrite or not path.isfile(fpath):
            print('Creating file %s.' % fpath)
            f = open(fpath, 'wt', encoding='utf-8', newline=newline)
            try:
                f.write(content)
            finally:
                f.close()
        else:
            print('File %s already exists, skipping.' % fpath)

    conf_text = ABLOG_CONF % d
    write_file(path.join(srcdir, 'conf.py'), conf_text)

    masterfile = path.join(srcdir, d['master'] + d['suffix'])
    write_file(masterfile, ABLOG_INDEX % d)

    about = path.join(srcdir, 'about' + d['suffix'])
    write_file(about, ABLOG_ABOUT % d)

    d['post_date'] = datetime.datetime.today().strftime('%b %d, %Y')
    firstpost = path.join(srcdir, 'first-post' + d['suffix'])
    write_file(firstpost, ABLOG_POST % d)

    if silent:
        return

    print(bold('Finished: An initial directory structure has been created.'))
Beispiel #2
0
from matplotlib import pylab as plt
import cPickle as pickle
import itertools
from matplotlib.path import Path
import matplotlib.patches as patches



from fuel.datasets.hdf5 import H5PYDataset
import fuel
from sphinx.quickstart import mkdir_p
datasource = 'handwriting'
datasource_dir = os.path.join(fuel.config.data_path[0], datasource)
datasource_fname = os.path.join(datasource_dir , datasource+'.hdf5')
mkdir_p(datasource_dir)
print datasource_dir, datasource_fname



import xml.etree.ElementTree as ET

def readPoints(fname):
    tree = ET.parse(fname)
    root = tree.getroot()
    points = []
    sets = 0
    for strokeSet in root.iter('StrokeSet'):
        assert sets == 0
        sets += 1
        for stroke in strokeSet.iter('Stroke'):
Beispiel #3
0
def make_path(path):
    if not os.path.isdir(path):
        mkdir_p(path)
Beispiel #4
0
def generate(d, overwrite=True, silent=False):
    '''Borrowed from Sphinx 1.3b3'''
    """Generate project based on values in *d*."""

    texescape.init()
    indent = ' ' * 4

    if 'mastertoctree' not in d:
        d['mastertoctree'] = ''
    if 'mastertocmaxdepth' not in d:
        d['mastertocmaxdepth'] = 2

    d['project_fn'] = make_filename(d['project'])
    d['project_manpage'] = d['project_fn'].lower()
    d['now'] = time.asctime()
    d['project_underline'] = column_width(d['project']) * '='

    d['copyright'] = time.strftime('%Y') + ', ' + d['author']
    d['author_texescaped'] = text_type(d['author']).translate(
        texescape.tex_escape_map)
    d['project_doc'] = d['project'] + ' Documentation'
    d['project_doc_texescaped'] = text_type(d['project'] +
                                            ' Documentation').translate(
                                                texescape.tex_escape_map)

    # escape backslashes and single quotes in strings that are put into
    # a Python string literal
    for key in ('project', 'project_doc', 'project_doc_texescaped', 'author',
                'author_texescaped', 'copyright', 'version', 'release',
                'master'):
        d[key + '_str'] = d[key].replace('\\', '\\\\').replace("'", "\\'")

    if not path.isdir(d['path']):
        mkdir_p(d['path'])

    srcdir = d['sep'] and path.join(d['path'], 'source') or d['path']

    mkdir_p(srcdir)
    d['exclude_patterns'] = ''
    #if d['sep']:
    #    builddir = path.join(d['path'], 'build')
    #
    #else:
    #    builddir = path.join(srcdir, d['dot'] + 'build')
    #    d['exclude_patterns'] = repr(d['dot'] + 'build')
    #mkdir_p(builddir)
    mkdir_p(path.join(srcdir, d['dot'] + 'templates'))
    mkdir_p(path.join(srcdir, d['dot'] + 'static'))

    def write_file(fpath, content, newline=None):
        if overwrite or not path.isfile(fpath):
            print('Creating file %s.' % fpath)
            f = open(fpath, 'wt', encoding='utf-8', newline=newline)
            try:
                f.write(content)
            finally:
                f.close()
        else:
            print('File %s already exists, skipping.' % fpath)

    conf_text = ABLOG_CONF % d
    write_file(path.join(srcdir, 'conf.py'), conf_text)

    masterfile = path.join(srcdir, d['master'] + d['suffix'])
    write_file(masterfile, ABLOG_INDEX % d)

    about = path.join(srcdir, 'about' + d['suffix'])
    write_file(about, ABLOG_ABOUT % d)

    d['post_date'] = datetime.datetime.today().strftime('%b %d, %Y')
    firstpost = path.join(srcdir, 'first-post' + d['suffix'])
    write_file(firstpost, ABLOG_POST % d)

    if silent:
        return

    print(bold('Finished: An initial directory structure has been created.'))