Skip to content

Instantly share code, notes, and snippets.

Created August 8, 2022 04:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
AMPTools-Gen is basically a Python script that you can use to instantly generate AMP code from any HTML.
import argparse
from amp_tools import TransformHtmlToAmp
import codecs
arg_parser = argparse.ArgumentParser( description = "Copy source_file as target_file." )
arg_parser.add_argument( "source_file" )
arg_parser.add_argument( "target_file" )
arguments = arg_parser.parse_args()
source = arguments.source_file
target = arguments.target_file
html = ""
with, encoding='utf-8', mode='r+') as f:
for line in f:
html = html + line.rstrip()
valid_amp = TransformHtmlToAmp(html)().decode("utf-8")
with, encoding='utf-8', mode='w+') as f:
print( target, "successfully created !!" )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment