Пример #1
0
def chill():

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

    walk_directory(cfg['IMAGE_DIR'])
    freezer.freeze()
Пример #2
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
Пример #3
0
    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}
Пример #4
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'])
     )
Пример #5
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}
Пример #6
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",
             ]
         ),
     )
Пример #7
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)
Пример #8
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)
Пример #9
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')
Пример #10
0
def read_all(directory):
    return set(
        (filename, read_file(os.path.join(directory, *filename.split("/")))) for filename in walk_directory(directory)
    )
Пример #11
0
def asset():
    for filename in walk_directory(path.join(root_folder, "assets")):
        yield {'path': filename}
Пример #12
0
 def serve_static_packaged():
     for font in walk_directory(os.path.join(patternfly, 'fonts')):
         yield dict(
             module='patternfly',
             filename='fonts/%s' % font
         )
Пример #13
0
def without_dotted_folders(root):
    return [it for it in walk_directory(root) if not it.startswith('.')]
Пример #14
0
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})