#from ftplib import FTP def replace_line(file_name, line_num, text): lines = open(file_name, 'r') lines = lines.readlines() lines.insert( 30, "\n") lines[line_num] = text out = open(file_name, 'w') out.writelines(lines) out.close() def makemenuodkaz(odkaz, tag, name, iswww, opt): www = "" optional = "" if opt == "1": optional = 'target="_blank" ' if iswww == "1": www = "http://" elif iswww == "2": www = "https://" menufile = open("index.html","r+") ref = '
  • [' + tag + ']' + name + '
  • \n' replace_line("index.html", 31, ref) def makenewhtml(name, tag, description): sample = open('base.txt') sample = sample.readlines() newhtml = open(name, "w+") newhtml.writelines(sample) newhtml.close() makemenuodkaz(name, tag, description, 0, 0) def breaki(): for x in range(0, 5): print("") while True: print("####################################################################") print("this is a script to create new pages for j-a-r-e-k.wz.cz") print("1. create a new page with menu hyperlink") print("2. create just menu hyperlink") print("3. exit") print("####################################################################") try: choice = int(input("your choice: ")) if choice == 1: a = input("What name should your page have? ") b = input("What tag should your page have? ") c = input("How should the page be reffered to in the menu? ") breaki() makenewhtml(a, b, c) breaki() elif choice == 2: a = input("Where should your page point to? ") b = input("What tag should your hyperlink have? ") c = input("How should the hyperlink be reffered to in the menu? ") d = input("Is your hyperlink pointing to the web? (input 1 for http page and 2 for https)") e = input("Do you want your hyperlink to open in new tab? (1 for yes) ") breaki() makemenuodkaz(a, b, c, d, e) breaki() elif choice == 3: print("© Jarek 2018") raise SystemExit else: print("you have to choose one of the options.") except ValueError: print("You may only enter numbers")