
import codecs
import sys

import jinja2

env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="."),
                         autoescape=True)

def myinclude(filename):
    with codecs.open(filename, 'r', 'utf-8') as f:
        return f.read()

env.globals['myinclude'] = myinclude

if len(sys.argv) != 3:
    sys.stderr.write("Usage: %s <filename.html.jinja> <output.html>\n" % sys.argv[0])
    sys.exit(1)

html = env.get_template(sys.argv[1]).render()
myfile = codecs.open(sys.argv[2], 'w', 'utf-8')
myfile.write(html)
myfile.close()



import codecs
import sys

import jinja2

env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="."),
                         autoescape=True)

def myinclude(filename):
    with codecs.open(filename, 'r', 'utf-8') as f:
        lines = f.readlines()
        # Strip copyright header, if it has one.
        if lines[1][0:10] == "Copyright ":
            lines = lines[16:]
    return "".join(lines)

env.globals['myinclude'] = myinclude

if len(sys.argv) != 3:
    sys.stderr.write("Usage: %s <filename.html.jinja> <output.html>\n" % sys.argv[0])
    sys.exit(1)

html = env.get_template(sys.argv[1]).render()
myfile = codecs.open(sys.argv[2], 'w', 'utf-8')
myfile.write(html)
myfile.close()


Make documentation generator strip copyright header from inline examples
Make documentation generator strip copyright header from inline examples

  
  import codecs
  import sys
  
  import jinja2
  
  env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="."),
                           autoescape=True)
  
  def myinclude(filename):
      with codecs.open(filename, 'r', 'utf-8') as f:
-         return f.read()
+         lines = f.readlines()
+         # Strip copyright header, if it has one.
+         if lines[1][0:10] == "Copyright ":
+             lines = lines[16:]
+     return "".join(lines)
  
  env.globals['myinclude'] = myinclude
  
  if len(sys.argv) != 3:
      sys.stderr.write("Usage: %s <filename.html.jinja> <output.html>\n" % sys.argv[0])
      sys.exit(1)
  
  html = env.get_template(sys.argv[1]).render()
  myfile = codecs.open(sys.argv[2], 'w', 'utf-8')
  myfile.write(html)
  myfile.close()
  
  
Make documentation generator strip copyright header from inline examples
## Code Before:

import codecs
import sys

import jinja2

env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="."),
                         autoescape=True)

def myinclude(filename):
    with codecs.open(filename, 'r', 'utf-8') as f:
        return f.read()

env.globals['myinclude'] = myinclude

if len(sys.argv) != 3:
    sys.stderr.write("Usage: %s <filename.html.jinja> <output.html>\n" % sys.argv[0])
    sys.exit(1)

html = env.get_template(sys.argv[1]).render()
myfile = codecs.open(sys.argv[2], 'w', 'utf-8')
myfile.write(html)
myfile.close()


## Instruction:
Make documentation generator strip copyright header from inline examples
## Code After:

import codecs
import sys

import jinja2

env = jinja2.Environment(loader=jinja2.FileSystemLoader(searchpath="."),
                         autoescape=True)

def myinclude(filename):
    with codecs.open(filename, 'r', 'utf-8') as f:
        lines = f.readlines()
        # Strip copyright header, if it has one.
        if lines[1][0:10] == "Copyright ":
            lines = lines[16:]
    return "".join(lines)

env.globals['myinclude'] = myinclude

if len(sys.argv) != 3:
    sys.stderr.write("Usage: %s <filename.html.jinja> <output.html>\n" % sys.argv[0])
    sys.exit(1)

html = env.get_template(sys.argv[1]).render()
myfile = codecs.open(sys.argv[2], 'w', 'utf-8')
myfile.write(html)
myfile.close()

