def handle(self, **options):

        if not options["watch"] and not options["initial_scan"]:
            sys.exit("--no-initial-scan option should be used with --watch.")

        scanned_dirs = get_scanned_dirs()
        verbosity = int(options["verbosity"])
        compilers = utils.get_compilers().values()

        if not options["watch"] or options["initial_scan"]:
            # Scan the watched directories and compile everything
            for path in sorted(set(list_files(scanned_dirs))):
                for compiler in compilers:
                    if compiler.is_supported(path):
                        break
                else:
                    compiler = None

                if not compiler:
                    continue

                try:
                    compiler.handle_changed_file(path, verbosity=verbosity)
                except (exceptions.StaticCompilationError, ValueError) as e:
                    print(e)

        if options["watch"]:
            from static_precompiler.watch import watch_dirs
            watch_dirs(scanned_dirs, verbosity)
    def handle_noargs(self, **options):

        if not options["watch"] and not options["initial_scan"]:
            sys.exit("--no-initial-scan option should be used with --watch.")

        scanned_dirs = get_scanned_dirs()

        verbosity = int(options["verbosity"])

        compilers = utils.get_compilers().values()

        if not options["watch"] or options["initial_scan"]:
            # Scan the watched directories and compile everything
            for scanned_dir in scanned_dirs:
                for dirname, dirnames, filenames in os.walk(scanned_dir):
                    for filename in filenames:
                        path = os.path.join(dirname, filename)[len(scanned_dir):]
                        if path.startswith("/"):
                            path = path[1:]
                        for compiler in compilers:
                            if compiler.is_supported(path):
                                try:
                                    compiler.handle_changed_file(path, verbosity=options["verbosity"])
                                except (exceptions.StaticCompilationError, ValueError) as e:
                                    print(e)
                                break

        if options["watch"]:
            from static_precompiler.watch import watch_dirs
            watch_dirs(scanned_dirs, verbosity)
    def handle(self, **options):

        if not options["watch"] and not options["initial_scan"]:
            sys.exit("--no-initial-scan option should be used with --watch.")

        scanned_dirs = get_scanned_dirs()

        verbosity = int(options["verbosity"])

        compilers = utils.get_compilers().values()

        if not options["watch"] or options["initial_scan"]:
            # Scan the watched directories and compile everything
            for scanned_dir in scanned_dirs:
                for dirname, dirnames, filenames in os.walk(scanned_dir):
                    for filename in filenames:
                        path = os.path.join(dirname,
                                            filename)[len(scanned_dir):]
                        if path.startswith("/"):
                            path = path[1:]
                        for compiler in compilers:
                            if compiler.is_supported(path):
                                try:
                                    compiler.handle_changed_file(
                                        path, verbosity=verbosity)
                                except (exceptions.StaticCompilationError,
                                        ValueError) as e:
                                    print(e)
                                break

        if options["watch"]:
            from static_precompiler.watch import watch_dirs
            watch_dirs(scanned_dirs, verbosity)
示例#4
0
    def handle(self, **options):

        if not options["watch"] and not options["initial_scan"]:
            sys.exit("--no-initial-scan option should be used with --watch.")

        scanned_dirs = get_scanned_dirs()
        verbosity = int(options["verbosity"])
        compilers = registry.get_compilers().values()

        if options["ignore_dependencies"]:
            for compiler in compilers:
                compiler.supports_dependencies = False

        if not options["watch"] or options["initial_scan"]:
            # Scan the watched directories and compile everything
            compiled_files = set()
            for path in sorted(set(list_files(scanned_dirs))):
                for compiler in compilers:
                    if compiler.is_supported(path):
                        break
                else:
                    compiler = None

                if not compiler:
                    continue

                try:
                    compiled_files.add(
                        compiler.compile(path, from_management=True, verbosity=verbosity)
                    )
                except (exceptions.StaticCompilationError, ValueError) as e:
                    print(e)

            if options["delete_stale_files"]:
                delete_stale_files(compiled_files)

        if options["watch"]:
            from static_precompiler.watch import watch_dirs
            watch_dirs(scanned_dirs, verbosity)