def setUp(self): """Setup connection.""" self.session = db.connect(database=db.DEFAULT_DB)
def __init__(self, *args): """Setup connection.""" unittest.TestCase.__init__(self, *args) self.session = db.connect(database=db.DEFAULT_DB, debug=True) root = os.path.join('test', 'texts') TanachParser.parse(self.session, root, 'Index.xml')
def setUp(self): """Establish a database connection.""" self.session = db.connect(database=db.DEFAULT_DB, debug=True)
root_file (str): name of the "Tanach.xml" file Returns: dict. Dictionary of words parsed. """ logger.info(MSG_PARSING, 'tanach') logger.info(MSG_PARSING, 'index') path = os.path.join(root, root_file) xml_index = BeautifulSoup(open(path), 'xml') logger.info(MSG_PARSED, 'index') xml_books = xml_index.Tanach.find_all('index') # pylint: disable=E1101 xml_books = xml_books[0].books for xml_book in xml_books.find_all('names'): book_path = os.path.join(root, xml_book.filename.string + '.xml') with open(book_path) as stream: xml_soup = BeautifulSoup(stream, 'xml') book_name, book_counts = count(xml_soup) save(session, book_name, book_counts) logger.info(MSG_PARSED, 'tanach') if '__main__' == __name__: # pragma: no cover logger = logging.getLogger('hebphonics.parsers.TanachParser') logger.info('connecting...') parse(db.connect(database=os.path.join('db', 'hebphonics.db')), os.path.join('texts', 'tanach.us'))