()
The main function
The main function
The main function
def main():
    """
    The main function
    """
    args = get_args()
    if args.v > 4:
        args.v = 4
    level = 50 - args.v*10
    logging.basicConfig(stream=sys.stdout, level=level,
                        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    logger = logging.getLogger(__file__)

    patterns = []
    with open(args.c) as conf:
        for line in conf:
            pat = line.strip().split('---')
            if len(pat) == 2:
                patterns.append(pat)
            else:
                logger.error('Line in config file is improperly written: %s', line)
    if not patterns:
        logger.critical('No patterns specified in config file. Exiting...')
        sys.exit(1)

    sites = [Pastebin(patterns), Pastie(patterns), Slexy(patterns)]
    logger.debug('Created sites')
    threads = []
    for site in sites:
        thread = StopThread(site)
        threads.append((thread, site.__class__.__name__))
        logger.debug('Created thread for %s', site.__class__.__name__)
    try:
        for thread, name in threads:
            thread.start()
            logger.debug('Started thread for %s', name)
        while True:
            time.sleep(0.01)
    except KeyboardInterrupt:
        for thread, name in threads:
            thread.stop()
            thread.join()
            logger.debug('Stopped thread for %s', name)
def main ( ) : args = get_args ( ) if args . v > 4 : args . v = 4 level = 50 - args . v * 10 logging . basicConfig ( stream = sys . stdout , level = level , format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s' ) logger = logging . getLogger ( __file__ ) patterns = [ ] with open ( args . c ) as conf : for line in conf : pat = line . strip ( ) . split ( '---' ) if len ( pat ) == 2 : patterns . append ( pat ) else : logger . error ( 'Line in config file is improperly written: %s' , line ) if not patterns : logger . critical ( 'No patterns specified in config file. Exiting...' ) sys . exit ( 1 ) sites = [ Pastebin ( patterns ) , Pastie ( patterns ) , Slexy ( patterns ) ] logger . debug ( 'Created sites' ) threads = [ ] for site in sites : thread = StopThread ( site ) threads . append ( ( thread , site . __class__ . __name__ ) ) logger . debug ( 'Created thread for %s' , site . __class__ . __name__ ) try : for thread , name in threads : thread . start ( ) logger . debug ( 'Started thread for %s' , name ) while True : time . sleep ( 0.01 ) except KeyboardInterrupt : for thread , name in threads : thread . stop ( ) thread . join ( ) logger . debug ( 'Stopped thread for %s' , name )