Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added documentation

  • Loading branch information...
commit c8bee15feaac10f3e5ccf0f71984fc9570629f80 1 parent 0274f69
@ik5 authored
Showing with 9 additions and 8 deletions.
  1. +9 −8 convert_quotes.py
View
17 convert_quotes.py
@@ -110,6 +110,7 @@ def iter_quotes(quotes_file = QUOTES_FILE, logger = LOGGER) :
quote = []
def insert_to_db(con, quote, author, logger=LOGGER) :
+ """Insert quotes to the database"""
cursor = con.cursor()
author_id = None
if author :
@@ -149,6 +150,7 @@ def insert_to_db(con, quote, author, logger=LOGGER) :
return True
def run(con, logger = LOGGER) :
+ """The main execution loop"""
LOGGER.debug('Starting to parse file:')
for quote, author in iter_quotes():
insert_to_db(con, quote, author)
@@ -167,12 +169,11 @@ def run(con, logger = LOGGER) :
con = init_db()
atexit.register(finalize, con)
- run(con)
- #try :
- # run(con)
- #except :
- # LOGGER.critical('Unexpected exception was raised: %s',
- # sys.exc_info()[0])
- # finalize(con)
- # sys.exit()
+ try :
+ run(con)
+ except :
+ LOGGER.critical('Unexpected exception was raised: %s',
+ sys.exc_info()[0])
+ finalize(con)
+ sys.exit()
Please sign in to comment.
Something went wrong with that request. Please try again.