Exemple #1
0
 def make_pancakes(self, template_dirs, output_dir):
     templates = TemplateDirectories(template_dirs)
     for template_name in set(templates.list()):
         outfile = os.path.join(output_dir, template_name)
         print "'%s' -> '%s'" % (template_name, outfile)
         pancake = flatten(template_name, templates)
         try:
             os.makedirs(os.path.dirname(outfile))
         except OSError:  # Already exists.
             pass
         with codecs.open(outfile, 'w', 'utf-8') as fp:
             fp.write(pancake)
def make_pancakes(input_dir, output_dir):
    templates = TemplateDirectory(input_dir)
    for template_name in template_names(input_dir):
        print "Writing %s" % template_name
        pancake = flatten(template_name, templates)
        outfile = os.path.join(output_dir, template_name)
        try:
            os.makedirs(os.path.dirname(outfile))
        except OSError: # Already exists.
            pass
        with open(outfile, 'w') as fp:
            fp.write(pancake)
Exemple #3
0
 def make_pancakes(self, template_dirs, output_dir):
     templates = TemplateDirectories(template_dirs)
     for template_name in set(templates.list()):
         outfile = os.path.join(output_dir, template_name)
         print "'%s' -> '%s'" % (template_name, outfile)
         pancake = flatten(template_name, templates)
         try:
             os.makedirs(os.path.dirname(outfile))
         except OSError: # Already exists.
             pass
         with codecs.open(outfile, 'w', 'utf-8') as fp:
             fp.write(pancake)
Exemple #4
0
    def handle(self, *args, **options):
        template = args[0]
        template_path = os.path.abspath(template)

        for template_dir in settings.TEMPLATE_DIRS:
            if template_dir in template_path:
                relative_template_path = template_path.replace("%s/" % template_dir, '')
                flatten_template = flatten(relative_template_path, TemplateDirectory(template_dir))
                if len(args) > 1:
                    target_flatten = args[1]
                else:
                    target_flatten = template_path.split(".")
                    target_flatten.insert(-1, "_flatten.")
                    target_flatten = "".join(target_flatten)
                print "Write %s" % target_flatten
                f = open(target_flatten, "w")
                f.write(flatten_template)
                f.close()
Exemple #5
0
    def handle(self, *args, **options):
        template = args[0]
        template_path = os.path.abspath(template)

        for template_dir in settings.TEMPLATE_DIRS:
            if template_dir in template_path:
                relative_template_path = template_path.replace(
                    "%s/" % template_dir, '')
                flatten_template = flatten(relative_template_path,
                                           TemplateDirectory(template_dir))
                if len(args) > 1:
                    target_flatten = args[1]
                else:
                    target_flatten = template_path.split(".")
                    target_flatten.insert(-1, INLINER_OUTPUT)
                    target_flatten = "".join(target_flatten)
                print "Write %s" % target_flatten
                data = {'html': flatten_template, 'strip': 'checked'}
                response = requests.post(
                    'http://beaker.mailchimp.com/inline-css', data)
                soup = BeautifulSoup(response.content)
                f = open(target_flatten, "w")
                f.write(soup.find('textarea', {'name': 'text'}).text)
                f.close()
Exemple #6
0
    def handle(self, *args, **options):
        template = args[0]
        template_path = os.path.abspath(template)

        for template_dir in settings.TEMPLATE_DIRS:
            if template_dir in template_path:
                relative_template_path = template_path.replace("%s/" % template_dir, '')
                flatten_template = flatten(relative_template_path, TemplateDirectory(template_dir))
                if len(args) > 1:
                    target_flatten = args[1]
                else:
                    target_flatten = template_path.split(".")
                    target_flatten.insert(-1, INLINER_OUTPUT)
                    target_flatten = "".join(target_flatten)
                print "Write %s" % target_flatten
                data = {
                    'html': flatten_template,
                    'strip': 'checked'
                }
                response = requests.post('http://beaker.mailchimp.com/inline-css', data)
                soup = BeautifulSoup(response.content)
                f = open(target_flatten, "w")
                f.write(soup.find('textarea', {'name': 'text'}).text)
                f.close()
def check_flatten(template_name, expected):
    result = flatten(template_name, TEMPLATES)
    assert result == expected, 'expected %r, got %r' % (expected, result)
Exemple #8
0
def check_flatten(template_name, expected):
    result = flatten(template_name, TEMPLATES)
    assert result == expected, 'expected %r, got %r' % (expected, result)