''' | tconf - TurtleConfig tests | © 2020, Mike Miller - Released under the LGPL, version 3+. ''' import os, sys import out # this script requires the out package from tconf import TurtleConfig out.configure(level='debug' if '-d' in sys.argv else 'info') class AppDefaults: # simple an_option = True a_null = None # hierarchy class main: jpeg_quality: int = 95 # sync_dates_to_filesystem: tristate = True sync_dates_to_filesystem = True work_in_place = False dict_annotation: dict(type=int, desc='percentage') = 95 foo = 'bar' class rotate: resample = 'BICUBIC' class sort:
basic_palette = color_tables.termapp_palette4 elif env.TERM_PROGRAM == 'iTerm.app': pal_name = 'iterm' basic_palette = color_tables.iterm_palette4 return pal_name, basic_palette elif os_name == 'posix': # Tron leotards pass else: # Amiga/Atari - The Wonder Computer of the 1980s :-D log.warn('Unexpected OS: os.name: %s', os_name) if __name__ == '__main__': # logs the detection information sequence print() # space from warnings :-/ print('about to import out') try: #~ raise ImportError() import out out.configure(level='debug') except ImportError: fmt = ' %(levelname)-7.7s %(module)s/%(funcName)s:%(lineno)s %(message)s' logging.basicConfig(level=logging.DEBUG, format=fmt) init() # run again so detection gets logged
if full: out.critical('critical message - *flatline*') out.fatal('fatal message - *flatline*') try: 1 / 0 except Exception: out.error('error message - Pow!') #~ out.exception('exception message - Kerblooey!') out.exc('exc message - Kerblooey!') out.warn('begin...') print('⏵⏵ print std config:') out.configure( level='trace', # needs to go before to allow console log to be viewed! ) out.log_config() print('---------------------------------') print('⏵⏵ change to stdout:') out.configure( #~ theme='interactive', stream=sys.stdout, # runs console.detection again ) out.log_config() print('---------------------------------') print('⏵⏵ log messages from module:') from out import test_mod test_mod # pyflakes