def make_parser(): """ Takes ArgParse instance with default arguments and adds Positional Arguments: * module_name Flags: * -b (branch) Returns: :class:`argparse.ArgumentParser`: ArgParse instance """ parser = ArgParser(usage) parser.add_branch_flag( help_msg="Checkout a specific named branch rather than the default" " (master)") parser.add_argument("module_name", nargs="?", type=str, default="", help="Name of module") return parser
class AddBranchTest(unittest.TestCase): def setUp(self): self.parser = ArgParser("") self.parser.add_branch_flag() def test_branch_argument_has_correct_attributes(self): option = self.parser._option_string_actions['-b'] self.assertIsInstance(option, _StoreAction) self.assertEqual(option.type, str) self.assertEqual(option.dest, "branch") self.assertIn("--branch", option.option_strings)
def make_parser(): """ Takes ArgParse instance with default arguments and adds Positional Arguments: * module_name Flags: * -b (branch) Returns: :class:`argparse.ArgumentParser`: ArgParse instance """ parser = ArgParser(usage) parser.add_branch_flag( help_msg="Checkout a specific named branch rather than the default (master)") parser.add_argument("module_name", nargs="?", type=str, default="", help="Name of module") return parser
def make_parser(): """ Takes ArgParse instance with default arguments and adds Positional Arguments: * module_name * release Flags: * -b (branch) * -f (force) * -t (no-test-build) * -l (local-build-only) * -e (epics_version) * -T (test_build_only * -m (message) * -n (next_version) * -r (rhel_version) or --w (windows arguments) Returns: :class:`argparse.ArgumentParser`: ArgParse instance """ parser = ArgParser(usage) parser.add_module_name_arg() parser.add_release_arg() parser.add_branch_flag(help_msg="Release from a branch") parser.add_epics_version_flag( help_msg="Change the epics version. This will determine which build " "server your job is built on for epics modules. Default is " "from your environment" ) parser.add_argument( "-f", "--force", action="store_true", dest="force", default=None, help="force a release. If the release exists in prod it is removed. " "If the release exists in git it is exported to prod, otherwise " "the release is created in git and exported to prod", ) parser.add_argument( "-t", "--no-test-build", action="store_true", dest="skip_test", help="If set, this will skip the local test build " "and just do a release", ) parser.add_argument( "-l", "--local-build-only", action="store_true", dest="local_build", help="If set, this will only do the local test build and no more.", ) parser.add_argument( "-T", "--test_build-only", action="store_true", dest="test_only", help="If set, this will only do a test build on the build server", ) parser.add_argument( "-m", "--message", action="store", type=str, dest="message", default="", help="Add user message to the end of the default commit message. " "The message will be <module_name>: Released version <release>. <message>", ) parser.add_argument( "-n", "--next_version", action="store_true", dest="next_version", help="Use the next version number as the release version", ) title = "Build operating system arguments" desc = "Note: The following arguments are mutually exclusive - only use one" desc_group = parser.add_argument_group(title=title, description=desc) # Can only add description to group, so have group = desc_group.add_mutually_exclusive_group() # to nest inside ordinary group group.add_argument( "-r", "--rhel_version", action="store", type=str, dest="rhel_version", help="change the rhel version of the build. This will determine which " "build server your job is build on for non-epics modules. Default " "is from /etc/redhat-release. Can be 6", ) group.add_argument( "-w", "--windows", action="store", dest="windows", type=str, help="Release the module or IOC only for the Windows version. " "Note that the windows build server can not create a test build. " "A configure/RELEASE.win32-x86 or configure/RELEASE.windows64 file" " must exist in the module in order for the build to start. " "If the module has already been released with the same version " "the build server will rebuild that release for windows. " "Existing unix builds of the same module version will not be " "affected. Must specify 32 or 64 after the flag to choose 32/64-bit. " "Both 32 and 64 bit builds are built on the same 64-bit build server", ) return parser
def make_parser(): """ Takes ArgParse instance with default arguments and adds Positional Arguments: * module_name * release Flags: * -b (branch) * -f (force) * -t (no-test-build) * -l (local-build-only) * -e (epics_version) * -T (test_build_only * -m (message) * -n (next_version) * -r (rhel_version) or --w (windows arguments) * -g (redundant_argument) * -c (commit) Returns: :class:`argparse.ArgumentParser`: ArgParse instance """ parser = ArgParser(usage) parser.add_module_name_arg() parser.add_release_arg(optional=True) parser.add_branch_flag(help_msg="Release from a branch") parser.add_epics_version_flag( help_msg="Change the EPICS version. This will determine which build " "server your job is built on for EPICS modules. Default is " "from your environment") parser.add_argument( "-f", "--force", action="store_true", dest="force", default=None, help="Force a release. If the release exists in prod it is removed " "(otherwise in this case the default behaviour is to rebuild " "the existing release). Overrides some sanity checks and is " "therefore to be used with caution.") parser.add_argument("-t", "--no-test-build", action="store_true", dest="skip_test", help="If set, this will skip the local test build " "and just do a release") parser.add_argument( "-l", "--local-build-only", action="store_true", dest="local_build", help="If set, this will only do the local test build and no more.") parser.add_argument( "-T", "--test_build-only", action="store_true", dest="test_only", help="If set, this will only do a test build on the build server.") parser.add_argument( "-m", "--message", action="store", type=str, dest="message", default="", help="Add user message to the end of the default commit message. " "The message will be <module_name>: Released version <release>." "<message>") parser.add_argument( "-n", "--next_version", action="store_true", dest="next_version", help="Use the next version number as the release version") parser.add_argument( "-g", "--redundant_argument", action="store_true", dest="redundant_argument", help="Redundant argument to preserve backward compatibility") parser.add_argument( "-c", "--commit", action="store", type=str, dest="commit", help="If <release> is given, " "this option causes the tag to be created " "on the server, at the given COMMIT. The <release> is " "checked against the DLS naming convention. " "This option can also be used to execute only test builds " "at the given commit by omitting <release> and using " "either -T or -l. This avoids having to tag to do a test build.") title = "Build operating system arguments" desc = "Note: The following arguments are mutually exclusive - only use " \ "one" # Can only add description to group, so have to nest inside ordinary group desc_group = parser.add_argument_group(title=title, description=desc) group = desc_group.add_mutually_exclusive_group() group.add_argument( "-r", "--rhel_version", action="store", type=str, dest="rhel_version", help="change the rhel version of the build. This will determine which " "build server your job is build on for non-epics modules. Default " "is from /etc/redhat-release. Can be 6 or 7") group.add_argument( "-w", "--windows", action="store", dest="windows", type=str, help="Release the module or IOC only for the Windows version. " "If the module has already been released with the same version " "the build server will rebuild that release for Windows. " "Existing unix builds of the same module version will not be " "affected. If the EPICS version is different to the default " "it must be specified explicitly. Possible options are: " "32 (win32-x86, R3.14.12.3, Server 2008)," "64 (windows-x64, R3.14.12.3, Server 2008), " "64_2012 (windows-x64, R3.14.12.7, Server 2012)") return parser