def main() -> None: help_factory = (lambda prog: RawDescriptionHelpFormatter(prog=prog, max_help_position=32)) parser = ArgumentParser( prog='incremental_checker', description=__doc__, formatter_class=help_factory) parser.add_argument("range_type", metavar="START_TYPE", choices=["last", "commit"], help="must be one of 'last' or 'commit'") parser.add_argument("range_start", metavar="COMMIT_ID_OR_NUMBER", help="the commit id to start from, or the number of " "commits to move back (see above)") parser.add_argument("-r", "--repo_url", default=MYPY_REPO_URL, metavar="URL", help="the repo to clone and run tests on") parser.add_argument("-f", "--file-path", default=MYPY_TARGET_FILE, metavar="FILE", help="the name of the file or directory to typecheck") parser.add_argument("--cache-path", default=CACHE_PATH, metavar="DIR", help="sets a custom location to store cache data") parser.add_argument("--branch", default=None, metavar="NAME", help="check out and test a custom branch" "uses the default if not specified") if len(sys.argv[1:]) == 0: parser.print_help() parser.exit() params = parser.parse_args(sys.argv[1:]) # Make all paths absolute so we avoid having to worry about being in the right folder # The path to this specific script (incremental_checker.py). script_path = os.path.abspath(sys.argv[0]) # The path to the mypy repo. mypy_path = os.path.abspath(os.path.dirname(os.path.dirname(script_path))) # The folder the cloned repo will reside in. temp_repo_path = os.path.abspath(os.path.join(mypy_path, "tmp_repo")) # The particular file or package to typecheck inside the repo. target_file_path = os.path.abspath(os.path.join(temp_repo_path, params.file_path)) # The path to where the incremental checker cache data is stored. incremental_cache_path = os.path.abspath(params.cache_path) # The path to store the mypy incremental mode cache data mypy_cache_path = os.path.abspath(os.path.join(mypy_path, "misc", ".mypy_cache")) print("Assuming mypy is located at {0}".format(mypy_path)) print("Temp repo will be cloned at {0}".format(temp_repo_path)) print("Testing file/dir located at {0}".format(target_file_path)) print("Using cache data located at {0}".format(incremental_cache_path)) print() test_repo(params.repo_url, temp_repo_path, target_file_path, mypy_path, incremental_cache_path, mypy_cache_path, params.range_type, params.range_start, params.branch)
import os import sys from argparse import _SubParsersAction, RawDescriptionHelpFormatter, SUPPRESS sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..'))) from vee.package import requirement_parser as parser formatter = RawDescriptionHelpFormatter('manifest.txt') for action in parser._actions: if action.dest in ('url', ): continue if action.help == SUPPRESS: continue print('.. _requirement_arg_%s:' % action.dest) print() lines = formatter._format_action(action).splitlines() print('``%s``' % lines[0]) #print '~' * (4 + len(lines[0])) print() print('\n'.join(lines[1:])) print() #for line in parser.format_help().splitlines(): # print ' ' + line
# sleep until after end time time.sleep(2) except KeyboardInterrupt: # catch keyboard interrupt and simply exit pass fg.stop() # need to wait for the flowgraph to clean up, otherwise it won't exit fg.wait() print("done") sys.stdout.flush() if __name__ == "__main__": scriptname = os.path.basename(sys.argv[0]) formatter = RawDescriptionHelpFormatter(scriptname) width = formatter._width title = "tx.py" copyright = "Copyright (c) 2017 Massachusetts Institute of Technology" shortdesc = "Transmit a waveform on a loop using synchronized USRPs." desc = "\n".join(( "*" * width, "*{0:^{1}}*".format(title, width - 2), "*{0:^{1}}*".format(copyright, width - 2), "*{0:^{1}}*".format("", width - 2), "*{0:^{1}}*".format(shortdesc, width - 2), "*" * width, )) usage = ("%(prog)s [-m MBOARD] [-d SUBDEV] [-c CH] [-y ANT] [-f FREQ]"
def main() -> None: help_factory = (lambda prog: RawDescriptionHelpFormatter(prog=prog, max_help_position=32)) # type: Any parser = ArgumentParser( prog='incremental_checker', description=__doc__, formatter_class=help_factory) parser.add_argument("range_type", metavar="START_TYPE", choices=["last", "commit"], help="must be one of 'last' or 'commit'") parser.add_argument("range_start", metavar="COMMIT_ID_OR_NUMBER", help="the commit id to start from, or the number of " "commits to move back (see above)") parser.add_argument("-r", "--repo_url", default=MYPY_REPO_URL, metavar="URL", help="the repo to clone and run tests on") parser.add_argument("-f", "--file-path", default=MYPY_TARGET_FILE, metavar="FILE", help="the name of the file or directory to typecheck") parser.add_argument("-x", "--exit-on-error", action='store_true', help="Exits as soon as an error occurs") parser.add_argument("--keep-temporary-files", action='store_true', help="Keep temporary files on exit") parser.add_argument("--cache-path", default=CACHE_PATH, metavar="DIR", help="sets a custom location to store cache data") parser.add_argument("--branch", default=None, metavar="NAME", help="check out and test a custom branch" "uses the default if not specified") parser.add_argument("--sample", type=int, help="use a random sample of size SAMPLE") parser.add_argument("--seed", type=str, help="random seed") parser.add_argument("--limit", type=int, help="maximum number of commits to use (default until end)") parser.add_argument("--mypy-script", type=str, help="alternate mypy script to run") parser.add_argument("--daemon", action='store_true', help="use mypy daemon instead of incremental (highly experimental)") if len(sys.argv[1:]) == 0: parser.print_help() parser.exit() params = parser.parse_args(sys.argv[1:]) # Make all paths absolute so we avoid having to worry about being in the right folder # The path to this specific script (incremental_checker.py). script_path = os.path.abspath(sys.argv[0]) # The path to the mypy repo. mypy_path = os.path.abspath(os.path.dirname(os.path.dirname(script_path))) # The folder the cloned repo will reside in. temp_repo_path = os.path.abspath(os.path.join(mypy_path, "tmp_repo")) # The particular file or package to typecheck inside the repo. if params.file_path: target_file_path = os.path.abspath(os.path.join(temp_repo_path, params.file_path)) else: # Allow `-f ''` to clear target_file_path. target_file_path = None # The path to where the incremental checker cache data is stored. incremental_cache_path = os.path.abspath(params.cache_path) # The path to store the mypy incremental mode cache data mypy_cache_path = os.path.abspath(os.path.join(mypy_path, "misc", ".mypy_cache")) print(f"Assuming mypy is located at {mypy_path}") print(f"Temp repo will be cloned at {temp_repo_path}") print(f"Testing file/dir located at {target_file_path}") print(f"Using cache data located at {incremental_cache_path}") print() test_repo(params.repo_url, temp_repo_path, target_file_path, mypy_path, incremental_cache_path, mypy_cache_path, params.range_type, params.range_start, params.branch, params)
import os import sys from argparse import _SubParsersAction, RawDescriptionHelpFormatter, SUPPRESS sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..'))) from vee.package import requirement_parser as parser formatter = RawDescriptionHelpFormatter('requirements.txt') for action in parser._actions: if action.dest in ('url', ): continue if action.help == SUPPRESS: continue print '.. _requirement_arg_%s:' % action.dest print lines = formatter._format_action(action).splitlines() print '``%s``' % lines[0] #print '~' * (4 + len(lines[0])) print print '\n'.join(lines[1:]) print #for line in parser.format_help().splitlines(): # print ' ' + line