Example #1
0
 def test_storage_properties(self):
     # Properties of the Storage as described in the ticket.
     storage = DummyStorage()
     self.assertEqual(storage.get_modified_time('name'),
                      datetime.datetime(1970, 1, 1, tzinfo=timezone.utc))
     with self.assertRaisesMessage(
             NotImplementedError,
             "This backend doesn't support absolute paths."):
         storage.path('name')
Example #2
0
    def collect(self):
        target = 'apps/nunjucks/static/nunjucks/js/compiled-templates.js'
        templates = []
        for finder in finders.get_finders():
            for path, storage in finder.list([]):


                # TOTO: find a correct way to get nj-paths
                if '/nj/' in path:
                    print(path)
                    compiled_template = self.compiler.compile_template(storage.path(path))
                    compiled_template = re.sub('/Users/ohrstrom/Documents/Code/openbroadcast.org/website/apps/(\w*)/static/', '', compiled_template)
                    templates.append( {
                        'path': path,
                        'inner': compiled_template
                        }
                    )

        print(templates)

        tpl = render_to_string('nunjucks/compile/templates.js', {'templates': templates})

        file = codecs.open(target, "w", "utf-8")
        file.write(tpl)
        file.close()

        return
Example #3
0
    def collect(self):
        target = 'apps/nunjucks/static/nunjucks/js/compiled-templates.js'
        templates = []
        for finder in finders.get_finders():
            for path, storage in finder.list([]):

                # TOTO: find a correct way to get nj-paths
                if '/nj/' in path:

                    compiled_template = self.compiler.compile_template(
                        storage.path(path))
                    compiled_template = re.sub(
                        '/Users/ohrstrom/Documents/Code/openbroadcast.org/website/apps/(\w*)/static/',
                        '', compiled_template)
                    templates.append({
                        'path': path,
                        'inner': compiled_template
                    })

        tpl = render_to_string('nunjucks/compile/templates.js',
                               {'templates': templates})
        file = codecs.open(target, "w", "utf-8")
        file.write(tpl)
        file.close()

        return
    def collect(self):
        target = 'apps/nunjucks/static/nunjucks/js/templates.js'
        templates = []
        for finder in finders.get_finders():
            for path, storage in finder.list(['*zinnia*']):

                if getattr(storage, 'prefix', None):
                    prefixed_path = os.path.join(storage.prefix, path)
                else:
                    prefixed_path = path

                # TOTO: find a correct way to get nj-paths
                if '/nj/' in path:
                    templates.append({
                        'path':
                        path,
                        'inner':
                        self.compiler.compile(storage.path(path))
                    })

        tpl = render_to_string('nunjucks/compile/templates.js',
                               {'templates': templates})

        open(target, "w").write(tpl)

        return
    def collect(self):
        target = 'apps/nunjucks/static/nunjucks/js/templates.js'
        templates = []
        for finder in finders.get_finders():
            for path, storage in finder.list(['*zinnia*']):

                if getattr(storage, 'prefix', None):
                    prefixed_path = os.path.join(storage.prefix, path)
                else:
                    prefixed_path = path

                # TOTO: find a correct way to get nj-paths
                if '/nj/' in path:
                    templates.append( {
                        'path': path,
                        'inner': self.compiler.compile(storage.path(path))
                        }
                    )


        tpl = render_to_string('nunjucks/compile/templates.js', {'templates': templates})

        open(target, "w").write(tpl)

        return
def copy_file(log, path, prefixed_path, source_storage, storage, dry_run=False):
    """
    Attempt to copy ``path`` with storage
    """
    # The full path of the source file
    copied_files = []
    source_path = source_storage.path(path)

    # Finally start copying
    if dry_run:
        log(u"Pretending to copy '%s'" % source_path, level=1)
    else:
        log(u"Copying '%s'" % source_path, level=1)
        full_path = storage.path(prefixed_path)
        try:
            os.makedirs(os.path.dirname(full_path))
        except OSError:
            pass
        with source_storage.open(path) as source_file:
            storage.save(prefixed_path, source_file)
    if not prefixed_path in copied_files:
        copied_files.append(prefixed_path)
Example #7
0
 def test_storage_properties(self):
     # Properties of the Storage as described in the ticket.
     storage = DummyStorage()
     self.assertEqual(storage.get_modified_time('name'), datetime.datetime(1970, 1, 1, tzinfo=timezone.utc))
     with self.assertRaisesMessage(NotImplementedError, "This backend doesn't support absolute paths."):
         storage.path('name')