# -*- coding: utf-8 -*-
# Copyright Brett Paufler 7-12-13
# txt file, need to rename as a py to be of use
# Python 2.7.5
#No warranty, as is, but not really even that, as I'm not actually granting you any rights
#Note: it can be really dangerous if you don't change the file name, though
#Overwrigting an existing file being a possibility
#Place this program in File Location where HTML page is desired
# Programe creates HTML file with image src based on relative path
# Alternative (alt=) value is set to file name
# Spaces are converted %20
# Any other special Characters (brackets, commas, etc)
# will (likely)result in garbage
import os
import fileinput
# Default variables for Name, Title, etc
# Change these, comment out the raw_input lines below
# and having to type in your name each time will be eliminated
PageTitle = 'Brett Food - Brett Paufler\'s Guide to Cooking'
PageAuthor = 'Brett Paufler'
#Input Output area for user defined varialbes
#Easy enough to comment out
#PageTitle = raw_input("Desired Page Title: ")
#PageAuthor = raw_input("Page Author (for Meta Tag):")
PictureDirectory = raw_input("""
Path To Pictures
Enter a Period (single dot: ./ )if in Same Directory (./)
If in sub folder named Images Enter: Images/
(Ending Forwardk Slash "/" is required)
I use this 2 layers deep, other conditions not tested
(images/ThisImageFile/ works for me)
ENTER THE RELATIVE PATH TO THE PICTURES (with ending forward /)
""")
#Get DirectoryList String
DirectoryList = os.listdir(PictureDirectory)
DirectoryList = str(DirectoryList)
# Opens and closed various files which are subsequently removed to
# caconate the Directory List string correctly
IsOpen = open('TempText.txt', 'w+')
IsOpen.write(DirectoryList)
IsOpen.close()
#images/
F1 = open('SecondTemp.txt', 'w+')
for line in fileinput.input('TempText.txt'):
line = line.replace(', ', '\"\n')
line = line.replace('\'', '')
line = line.replace('[', '')
line = line.replace(']', '\"\n')
F1.write(line)
F1.close()
F2 = open('ThirdText.txt', 'w+')
for line in fileinput.input('SecondTemp.txt'):
F2.write('\n\n
\n\n')
F2.close()
# if this file is Temp changed to txt, editing/trouble shooting is way easier
F3 = open('Z - BrettFoodWebPageCreator.html', 'w+')
# Head of File write area
F3.write('\n\n\n\n