Created
May 25, 2012 12:58
-
-
Save acrymble/2787986 to your computer and use it in GitHub Desktop.
Wrap String in HTML Mac.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Given name of calling program, a url and a string to wrap, | |
| # output string in html body with basic metadata and open in Firefox tab. | |
| def wrapStringInHTML(program, url, body): | |
| import datetime | |
| from webbrowser import open_new_tab | |
| now = datetime.datetime.today().strftime("%Y%m%d-%H%M%S") | |
| filename = program + '.html' | |
| f = open(filename,'w') | |
| wrapper = """<html> | |
| <head> | |
| <title>%s output - %s</title> | |
| </head> | |
| <body><p>URL: <a href=\"%s\">%s</a></p><p>%s</p></body> | |
| </html>""" | |
| whole = wrapper % (program, now, url, url, body) | |
| f.write(whole) | |
| f.close() | |
| #Change the filepath variable below to match the location of your directory | |
| filename = 'file:///Users/username/Desktop/programming-historian/' + filename | |
| open_new_tab(filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment