示例#1
0
def chill():

    """
    Function responsible for generating static files
    """

    walk_directory(cfg['IMAGE_DIR'])
    freezer.freeze()
示例#2
0
文件: app.py 项目: ubiquitin/tarbell
    def find_files(self):
        """
        Find all file paths for publishing, yield (urlname, kwargs)
        """
        # yield blueprint paths first
        if getattr(self, 'blueprint_name', None):
            for path in walk_directory(os.path.join(self.path, self.blueprint_name), ignore=self.project.EXCLUDES):
                yield 'preview', {'path': path}

        # then yield project paths
        for path in walk_directory(self.path, ignore=self.project.EXCLUDES):
            yield 'preview', {'path': path}
示例#3
0
def diff(dir1, dir2):
    """Return the set of filenames that are not identical in dir1 and dir2"""
    files1 = set(walk_directory(dir1))
    files2 = set(walk_directory(dir2))
    # Files that are in 2 but not in 1
    different = set(files2 - files1)
    for filename in files1:
        name1 = os.path.join(dir1, *filename.split('/'))
        name2 = os.path.join(dir2, *filename.split('/'))
        if filename not in files2 or read_file(name1) != read_file(name2):
            different.add(filename)
    return different
示例#4
0
文件: app.py 项目: jheasly/tarbell
    def find_files(self):
        """
        Find all file paths for publishing, yield (urlname, kwargs)
        """
        # yield blueprint paths first
        if getattr(self, 'blueprint_name', None):
            for path in walk_directory(os.path.join(self.path, self.blueprint_name), ignore=self.project.EXCLUDES):
                yield 'preview', {'path': path}

        # then yield project paths
        for path in walk_directory(self.path, ignore=self.project.EXCLUDES):
            yield 'preview', {'path': path}
示例#5
0
def diff(dir1, dir2):
    """Return the set of filenames that are not identical in dir1 and dir2"""
    files1 = set(walk_directory(dir1))
    files2 = set(walk_directory(dir2))
    # Files that are in 2 but not in 1
    different = set(files2 - files1)
    for filename in files1:
        name1 = os.path.join(dir1, *filename.split('/'))
        name2 = os.path.join(dir2, *filename.split('/'))
        if filename not in files2 or read_file(name1) != read_file(name2):
            different.add(filename)
    return different
示例#6
0
def static_in_pages():
    for year in Page.years():
        for name in os.listdir(os.path.join(Page.root, year)):
            directory = os.path.join(Page.root, year, name)
            if os.path.isdir(directory):
                for path in walk_directory(directory):
                    yield {'year': int(year), 'name': name, 'path': path}
示例#7
0
 def test_walk_directory(self):
     self.assertEquals(
         set(f for f in walk_directory(os.path.dirname(test_app.__file__))
             if not f.endswith(('.pyc', '.pyo'))),
         set(['__init__.py', 'static/style.css', 'static/favicon.ico',
              'admin/__init__.py', 'admin/admin_static/style.css'])
     )
示例#8
0
文件: generators.py 项目: pib/piblog
def theme_static():
    for theme in get_themes_list():

        for static_file in walk_directory(theme.static_path):
            yield ('_themes.static', {
                'themeid': theme.identifier,
                'filename': static_file
            })
示例#9
0
 def test_walk_directory(self):
     self.assertEquals(
         set(f for f in walk_directory(os.path.dirname(test_app.__file__))
             if not f.endswith(('.pyc', '.pyo'))),
         set([
             '__init__.py', 'static/style.css', 'admin/__init__.py',
             'admin/admin_static/style.css'
         ]))
示例#10
0
 def test_walk_directory(self):
     self.assertEqual(
         set(f for f in walk_directory(os.path.dirname(test_app.__file__))
             if not f.endswith(('.pyc', '.pyo'))),
         set(['__init__.py', 'static/style.css', 'static/favicon.ico',
              'static/main.js', 'admin/__init__.py',
              'admin/admin_static/style.css', 'admin/templates/admin.html'])
     )
示例#11
0
 def test_walk_directory(self):
     self.assertEquals(
         set(f for f in walk_directory(os.path.dirname(test_app.__file__)) if not f.endswith((".pyc", ".pyo"))),
         set(
             [
                 "__init__.py",
                 "static/style.css",
                 "static/favicon.ico",
                 "admin/__init__.py",
                 "admin/admin_static/style.css",
                 "admin/templates/admin.html",
             ]
         ),
     )
示例#12
0
    def _extra_files(self, remove):
        with self.built_app() as (temp, app, freezer, urls):
            app.config["FREEZER_REMOVE_EXTRA_FILES"] = remove
            dest = unicode(app.config["FREEZER_DESTINATION"])
            expected_files = set(self.filenames.itervalues())

            # No other files
            self.assertFilenamesEqual(walk_directory(dest), expected_files)

            # create an empty file
            os.mkdir(os.path.join(dest, "extra"))
            open(os.path.join(dest, "extra", "extra.txt"), "wb").close()
            if not remove:
                expected_files.add(u"extra/extra.txt")

            # Verify that files in destination persist.
            freezer.freeze()
            self.assertFilenamesEqual(walk_directory(dest), expected_files)

            exists = os.path.exists(os.path.join(dest, "extra"))
            if remove:
                self.assert_(not exists)
            else:
                self.assert_(exists)
示例#13
0
    def _extra_files(self, removed, remove_extra=True, ignore=()):
        with self.built_app() as (temp, app, freezer, urls):
            app.config['FREEZER_REMOVE_EXTRA_FILES'] = remove_extra
            app.config['FREEZER_DESTINATION_IGNORE'] = ignore
            dest = unicode(app.config['FREEZER_DESTINATION'])
            expected_files = set(self.filenames.values())

            # No other files
            self.assertFilenamesEqual(walk_directory(dest), expected_files)

            # create an empty file
            os.mkdir(os.path.join(dest, 'extra'))
            open(os.path.join(dest, 'extra', 'extra.txt'), 'wb').close()

            # Verify that files in destination persist.
            freezer.freeze()

            exists = os.path.exists(os.path.join(dest, 'extra'))
            if removed:
                self.assertTrue(not exists)
            else:
                self.assertTrue(exists)
                expected_files.add(u'extra/extra.txt')
            self.assertFilenamesEqual(walk_directory(dest), expected_files)
示例#14
0
    def _extra_files(self, removed, remove_extra=True, ignore=()):
        with self.built_app() as (temp, app, freezer, urls):
            app.config['FREEZER_REMOVE_EXTRA_FILES'] = remove_extra
            app.config['FREEZER_DESTINATION_IGNORE'] = ignore
            dest = unicode(app.config['FREEZER_DESTINATION'])
            expected_files = set(self.filenames.values())

            # No other files
            self.assertFilenamesEqual(walk_directory(dest), expected_files)

            # create an empty file
            os.mkdir(os.path.join(dest, 'extra'))
            open(os.path.join(dest, 'extra', 'extra.txt'), 'wb').close()

            # Verify that files in destination persist.
            freezer.freeze()

            exists = os.path.exists(os.path.join(dest, 'extra'))
            if removed:
                self.assertTrue(not exists)
            else:
                self.assertTrue(exists)
                expected_files.add(u'extra/extra.txt')
            self.assertFilenamesEqual(walk_directory(dest), expected_files)
def copy_files(site, git):
    """
    Copy the files
    """
    puts('\nCopying files from blueprint\n')
    source_root = '{0}/_blueprint'.format(site.path)
    dest_root = site.path
    for path in walk_directory(source_root, ignore=IGNORE_PATTERNS):
        source = os.path.join(source_root, path)
        dest = os.path.join(dest_root, path)
        dest_dir = os.path.dirname(dest)
        if not os.path.isdir(dest_dir):
            os.makedirs(dest_dir)
        shutil.copy2(source, dest)
    git.add('.')
    git.commit(m='Add all AJAM\'s files')
示例#16
0
def copy_files(site, git):
    """
    Copy the files
    """
    puts('\nCopying files from blueprint\n')
    source_root = '{0}/_blueprint'.format(site.path)
    dest_root = site.path
    for path in walk_directory(source_root, ignore=IGNORE_PATTERNS):
        source = os.path.join(source_root, path)
        dest = os.path.join(dest_root, path)
        dest_dir = os.path.dirname(dest)
        if not os.path.isdir(dest_dir):
            os.makedirs(dest_dir)
        shutil.copy2(source, dest)
    git.add('.')
    git.commit(m='Add all AJAM\'s files')
def asset():
    for filename in walk_directory(path.join(root_folder, "assets")):
        yield {'path': filename}
示例#18
0
def read_all(directory):
    return set(
        (filename, read_file(os.path.join(directory, *filename.split("/")))) for filename in walk_directory(directory)
    )
示例#19
0
def asset():
    for filename in walk_directory(path.join(root_folder, "assets")):
        yield {'path': filename}
示例#20
0
 def serve_static_packaged():
     for font in walk_directory(os.path.join(patternfly, 'fonts')):
         yield dict(module='patternfly', filename='fonts/%s' % font)
示例#21
0
文件: generators.py 项目: pib/piblog
def theme_static():
    for theme in get_themes_list():

        for static_file in walk_directory(theme.static_path):
            yield ('_themes.static', {'themeid': theme.identifier,
                                      'filename': static_file})
示例#22
0
文件: flaskyll.py 项目: vaus/Flaskyll
def without_dotted_folders(root):
    return [it for it in walk_directory(root) if not it.startswith('.')]
示例#23
0
def read_all(directory):
    return set(
        (filename, read_file(os.path.join(directory, *filename.split('/'))))
        for filename in walk_directory(directory))
示例#24
0
文件: generate.py 项目: dmsimard/ara
 def serve_static_packaged():
     for font in walk_directory(os.path.join(patternfly, 'fonts')):
         yield dict(
             module='patternfly',
             filename='fonts/%s' % font
         )