def test_from_file(self): config = Config.from_file("../test-data/config.test.yaml") self.assertEqual(config.year, "16-17") self.assertEqual(config.quarter, "spring") self.assertEqual(config.courses, [ { 'subject': "MATH", 'course': 201, 'types': ["lecture", "lab"], 'crns': [ { 'lecture': [ "!12345!" ] }, { 'lab': [ 54321, 21345 ] } ] }, { 'subject': "CS", 'course': 172 } ])
import os, sys, re, logging import yaml import urwid from models.config import Config from models.progress import Progress from models.db.database import engine, session # Get config config_file_path = "config.yaml" if len(sys.argv) > 1: # If custom path provided for courses file config_file_path = sys.argv[1] config = Config.from_file(config_file_path) # Make Progress file progress_file_path = os.path.join(os.getcwd(), "../progress.yaml") progress = Progress.from_path_or_defaults(config.hash(), progress_file_path) print(progress)
elif fname == 'googledrive': fetcher = Googledrive() else: raise ValueError('Bad message type {}'.format(message_type)) return fetcher if __name__ == "__main__": # set up argparse # parser.add_argument('-v', '--verbose', action='count', default=0) # set up logging loglevel = logging.INFO # default loglevel # if args.verbose == 1: # loglevel = logging.INFO # elif args.verbose >= 2: # loglevel = logging.DEBUG logging.basicConfig(level=loglevel) logger = logging.getLogger(__name__) logger.info("starting up") configfile = Config.from_file('./config.json') for source in configfile.get_sources(): logger.info("Checking source " + str(source)) fetcher = select_fetcher_for_source(source) fetcher.fetch(source)