def main(): """qtsass's cli entry point.""" args = create_parser().parse_args() file_mode = os.path.isfile(args.input) dir_mode = os.path.isdir(args.input) if file_mode and not args.output: with open(args.input, 'r') as f: string = f.read() css = compile( string, include_paths=os.path.abspath(os.path.dirname(args.input)) ) print(css) sys.exit(0) elif file_mode: compile_filename(args.input, args.output) elif dir_mode and not args.output: print('Error: missing required option: -o/--output') sys.exit(1) elif dir_mode: compile_dirname(args.input, args.output) else: print('Error: input must be a file or a directory') sys.exit(1) if args.watch: _log.info('qtsass is watching {}...'.format(args.input)) observer = watch(args.input, args.output) observer.start() try: while True: time.sleep(1) except KeyboardInterrupt: observer.stop() observer.join() sys.exit(0)
def compile_scss(self, str): # NOTE: revise for better future compatibility wstr = '*{{t: {0};}}'.format(str) res = compile(wstr) return res.replace('* {\n t: ', '').replace('; }\n', '')
def main(): """CLI entry point.""" args = create_parser().parse_args() # Setup CLI logging debug = os.environ.get('QTSASS_DEBUG', args.debug) if debug in ('1', 'true', 'True', 'TRUE', 'on', 'On', 'ON', True): level = logging.DEBUG else: level = logging.INFO enable_logging(level) # Add a StreamHandler handler = logging.StreamHandler() if level == logging.DEBUG: fmt = '%(levelname)-8s: %(name)s> %(message)s' handler.setFormatter(logging.Formatter(fmt)) logging.root.addHandler(handler) logging.root.setLevel(level) file_mode = os.path.isfile(args.input) dir_mode = os.path.isdir(args.input) if file_mode and not args.output: with open(args.input, 'r') as f: string = f.read() css = compile( string, include_paths=os.path.abspath(os.path.dirname(args.input)), ) print(css) sys.exit(0) elif file_mode: _log.debug('compile_filename({}, {})'.format(args.input, args.output)) compile_filename(args.input, args.output) elif dir_mode and not args.output: print('Error: missing required option: -o/--output') sys.exit(1) elif dir_mode: _log.debug('compile_dirname({}, {})'.format(args.input, args.output)) compile_dirname(args.input, args.output) else: print('Error: input must be a file or a directory') sys.exit(1) if args.watch: _log.info('qtsass is watching {}...'.format(args.input)) watcher = watch(args.input, args.output) watcher.start() try: while True: time.sleep(0.5) except KeyboardInterrupt: watcher.stop() watcher.join() sys.exit(0)