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
#!/usr/bin/python | |
import os # To check if database.txt exists | |
import argparse # Happily handles arguments and options | |
# My lovely arguments (working on them) | |
parser = argparse.ArgumentParser() | |
parser.add_argument("-a", "--author", help="the author of the book", action="store", required=True) | |
parser.add_argument("-t", "--title", help="the title of the book", action="store", required=True) | |
parser.add_argument("-y", "--year", help="the year the book was published", action="store", required=True) | |
parser.add_argument("-p", "--publisher", help="the company that published the book", action="store", required=True) |
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
def createBook(title,author,year): | |
outFile = open('database.txt', 'wt') | |
outFile.write("[book]\n") | |
outFile.write("title: " + title + "\n") | |
outFile.write("author: " + author + "\n") | |
outFile.write("year: " + year + "\n") | |
outFile.close() | |
print("Welcome to Shellf!") | |
print("Answer the questions to add your book do the database.") |
NewerOlder