Skip to content

Instantly share code, notes, and snippets.

View rberaldo's full-sized avatar

Rafael Beraldo rberaldo

View GitHub Profile
@rberaldo
rberaldo / shellf.py
Created September 11, 2012 03:38
Ensaio para um gerenciador de coleções
#!/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)
@rberaldo
rberaldo / shellf.py
Created September 10, 2012 06:45
That's my first exercise on I/O!
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.")