def add_logging_arguments(parser): parser.add_argument('--verbose', '-v', dest='verbose', action='count', help='display some extra information') parser.add_argument('--quiet', '-q', dest='quiet', action='count', help='the inverse of --verbose') parser.add_argument('--log-file', '-l', dest='log_files', nargs='*', type=argparse.FileType('w'), default=[sys.stderr], help='The files to log output to. Use - for stdout.')
def add_libname_arguments(parser): parser.add_argument('--topname', metavar='TOPNAME', dest='topname', type=str, default='Top', action=DeprecatedAction, replacement='-R', help='The name to bind to the current directory using -R .') parser.add_argument('-R', metavar=('DIR', 'COQDIR'), dest='libnames', type=str, default=[], nargs=2, action=CoqLibnameAction, help='recursively map physical DIR to logical COQDIR, as in the -R argument to coqc') parser.add_argument('-Q', metavar=('DIR', 'COQDIR'), dest='non_recursive_libnames', type=str, default=[], nargs=2, action=CoqLibnameAction, help='(nonrecursively) map physical DIR to logical COQDIR, as in the -Q argument to coqc') parser.add_argument('-I', metavar='DIR', dest='ocaml_dirnames', type=str, default=[], action='append', help='Look for ML files in DIR, as in the -I argument to coqc') parser.add_argument('--arg', metavar='ARG', dest='coq_args', type=str, action=ArgAppendWithWarningAction, help='Arguments to pass to coqc and coqtop; e.g., " -indices-matter" (leading and trailing spaces are stripped)') parser.add_argument('-f', metavar='FILE', dest='CoqProjectFile', nargs=1, type=argparse.FileType('r'), default=None, help=("A _CoqProject file"))
from custom_arguments import add_libname_arguments, update_env_with_libnames, add_logging_arguments, process_logging_arguments from memoize import memoize from file_util import read_from_file, write_to_file # TODO: # - handle fake ambiguities from [Definition foo] in a comment # - handle theorems inside proof blocks # - do the right thing for [Theorem foo. Theorem bar. Proof. Qed. Qed.] (we do the wrong thing right now) # - make use of glob file? parser = argparse.ArgumentParser( description='Implement the suggestions of [Set Suggest Proof Using.]') parser.add_argument( 'source', metavar='SOURCE_FILE', type=argparse.FileType('r'), nargs='?', default=sys.stdin, help='the source of set suggest proof using messages; use - for stdin.') parser.add_argument( '--hide', dest='hide_reg', nargs='*', type=str, default=['.*_subproof[0-9]*$'], #, '.*_Proper$'], help=( 'Regular expressions to not display warnings about on low verbosity. ' + '[Set Suggest Proof Using] can give suggestions about hard-to-find ' + 'identifiers, and we might want to surpress them.')) parser.add_argument('--no-hide',
def add_libname_arguments_gen(parser, passing): passing_dash = passing + '-' if passing else '' twodash_passing_dash = '--' + passing_dash onedash_passing_dash = '-' + ('-' + passing + '-' if passing else '') passing_underscore = passing + '_' if passing else '' passing_for = ', for --' + passing + 'coqc' if passing else '' parser.add_argument(twodash_passing_dash + 'topname', metavar='TOPNAME', dest=passing_underscore+'topname', type=str, default='Top', action=DeprecatedAction, replacement='-R', help='The name to bind to the current directory using -R .') parser.add_argument(onedash_passing_dash + 'R', metavar=('DIR', 'COQDIR'), dest=passing_underscore+'libnames', type=str, default=[], nargs=2, action=CoqLibnameAction, help='recursively map physical DIR to logical COQDIR, as in the -R argument to coqc' + passing_for) parser.add_argument(onedash_passing_dash + 'Q', metavar=('DIR', 'COQDIR'), dest=passing_underscore+'non_recursive_libnames', type=str, default=[], nargs=2, action=CoqLibnameAction, help='(nonrecursively) map physical DIR to logical COQDIR, as in the -Q argument to coqc' + passing_for) parser.add_argument(onedash_passing_dash + 'I', metavar='DIR', dest=passing_underscore+'ocaml_dirnames', type=str, default=[], action='append', help='Look for ML files in DIR, as in the -I argument to coqc' + passing_for) parser.add_argument(twodash_passing_dash + 'arg', metavar='ARG', dest=passing_underscore+'coq_args', type=str, action=ArgAppendWithWarningAction, help='Arguments to pass to coqc and coqtop; e.g., " -indices-matter" (leading and trailing spaces are stripped)' + passing_for) parser.add_argument(onedash_passing_dash + 'f', metavar='FILE', dest=passing_underscore+'CoqProjectFile', nargs=1, type=argparse.FileType('r'), default=None, help=('A _CoqProject file' + passing_for))
from custom_arguments import add_libname_arguments, update_env_with_libnames, add_logging_arguments, process_logging_arguments from split_file import get_coq_statement_ranges, UnsupportedCoqVersionError from import_util import get_references_for, get_file, sort_files_by_dependency from file_util import write_to_file from memoize import memoize from minimizer_drivers import run_binary_search import diagnose_error # {Windows,Python,coqtop} is terrible; we fail to write to (or read # from?) coqtop. But we can wrap it in a batch scrip, and it works # fine. SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) DEFAULT_COQTOP = 'coqtop' if os.name != 'nt' else os.path.join(SCRIPT_DIRECTORY, 'coqtop.bat') parser = argparse.ArgumentParser(description='Remove useless Requires in a file') parser.add_argument('input_files', metavar='INFILE', nargs='*', type=argparse.FileType('r'), help='.v files to update') parser.add_argument('--in-place', '-i', metavar='SUFFIX', dest='suffix', nargs='?', type=str, default='', help='update files in place (makes backup if SUFFIX supplied)') parser.add_argument('--all', dest='update_all', action='store_const', default=False, const=True, help=("also update all .v files listed in any _CoqProject file passed to -f (implies --in-place, requires -f)")) parser.add_argument('--absolutize', dest='absolutize', action='store_const', default=False, const=True, help=("Replace Requires with fully qualified versions.")) parser.add_argument('--timeout', dest='timeout', metavar='SECONDS', type=int, default=-1, help=("Use a timeout; make sure Coq is " + "killed after running for this many seconds. " + "If 0, there is no timeout. If negative, then " + "twice the initial run of the script is used.\n\n" + "Default: -1"))
help='update files in place (makes backup if SUFFIX supplied)') parser.add_argument('--verbose', '-v', dest='verbose', action='count', help='display some extra information') parser.add_argument('--quiet', '-q', dest='quiet', action='count', help='the inverse of --verbose') parser.add_argument('--log-file', '-l', dest='log_files', nargs='*', type=argparse.FileType('w'), default=[sys.stderr], help='The files to log output to. Use - for stdout.') DEFAULT_VERBOSITY = 1 def make_logger(log_files): def log(text): for i in log_files: i.write(str(text) + '\n') i.flush() if i.fileno() > 2: # stderr os.fsync(i.fileno()) return log
#!/usr/bin/env python import shutil, os, os.path, sys from argparse_compat import argparse from import_util import IMPORT_ABSOLUTIZE_TUPLE, ALL_ABSOLUTIZE_TUPLE from custom_arguments import add_libname_arguments, update_env_with_libnames, add_logging_arguments, process_logging_arguments from replace_imports import include_imports # {Windows,Python,coqtop} is terrible; we fail to write to (or read # from?) coqtop. But we can wrap it in a batch scrip, and it works # fine. SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) DEFAULT_COQTOP = 'coqtop' if os.name != 'nt' else os.path.join(SCRIPT_DIRECTORY, 'coqtop.bat') parser = argparse.ArgumentParser(description='Inline the imports of a file') parser.add_argument('input_file', metavar='IN_FILE', type=argparse.FileType('r'), help='a .v file to inline the imports of') parser.add_argument('output_file', metavar='OUT_FILE', type=argparse.FileType('w'), help='a .v file to write to') parser.add_argument('--fast-merge-imports', dest='fast_merge_imports', action='store_const', const=True, default=False, help='Use a faster method for combining imports') parser.add_argument('--no-deps', dest='walk_tree', action='store_const', const=False, default=True, help=("Don't do dependency analysis on all files in the current " + "file tree.")) parser.add_argument('--no-wrap-modules', dest='wrap_modules', action='store_const', const=False, default=True, help=("Don't wrap imports in Modules. By default, the " + "contents of each file is wrapped in its own " + "module to deal with renaming issues. This " + "can cause issues with subdirectories."))