def main():

    parser = PromptParser()
    parser.add_argument('-p',
                        '--path',
                        metavar='',
                        help='{path} - path of the directory to organize ')
    parser1 = PromptParser()
    parser1.add_argument(
        '-o',
        '--order',
        default='type',
        help='{extension,size,date,type} - the way you need to organize',
        metavar='',
        choices=['extension', 'size', 'date', 'type'],
    )

    path = parser.parse_args().path
    organizeBy = parser1.parse_args().order

    if organizeBy == 'extension':
        organize_by_extension(path)
    elif organizeBy == 'size':
        organize_by_size(path)
    elif organizeBy == 'date':
        organize_by_date(path)
    elif organizeBy == 'type':
        organize_by_type(path)
    else:
        print('Wrong Choice for Organizing')
Exemplo n.º 2
0
def test_mismatched_default(input_mock):
    """Test a parser which has a default which isn't the same type as the type"""
    input_mock.return_value = ""
    parser = PromptParser()
    parser.add_argument("--argument", type=str, default=None)
    args = parser.parse_args([])
    assert args.argument is None
    input_mock.assert_called()
Exemplo n.º 3
0
def test_auto_parser():
    """Test a basic parser when the enviroment variable is set to disable prompts"""
    parser = PromptParser()
    parser.add_argument(
        "--argument", "-a", help="An argument you could provide", default="foo"
    )
    args = parser.parse_args([])
    assert args.argument == "foo"
Exemplo n.º 4
0
def test_default_parser(input_mock):
    """Test a basic parser with a default value"""
    input_mock.side_effect = mock_input("")

    parser = PromptParser()
    parser.add_argument(
        "--argument", "-a", help="An argument you could provide", default="foo"
    )
    args = parser.parse_args([])
    assert args.argument == "foo"
def main():
    parser = PromptParser()
    parser.add_argument('--sequence_number',
                        help='Enter Sequence Number',
                        type=int,
                        default=None)
    parser.add_argument('--start_num',
                        help='Enter first number in sequence',
                        type=int,
                        default=1)
    parser.add_argument('--end_num',
                        help='Enter last number in sequence',
                        type=int,
                        default=None)
    parser.add_argument(
        '--block_interval',
        help='After how many samples would you like a control block',
        type=int,
        default=None)
    parser.add_argument(
        '--beginning_blanks',
        help='How many blanks would you like at the top of the run',
        type=int,
        default=1)
    parser.add_argument(
        '--standard_format',
        help='Is this a pHILIC, lipid, or ZIC run (input 1, 2, or 3)',
        type=int,
        default=None)
    parser.add_argument('--directory',
                        help='Enter directory to save files',
                        default='C:\\Users\\ASHL01\\Desktop')
    parser.add_argument('--filename1',
                        help='Enter filename1 (LC)',
                        default='SQtestLC.csv')
    parser.add_argument('--filename2',
                        help='Enter filename2 (MS)',
                        default='SQtestMS.csv')
    #print(parser.parse_args().argument)
    args = parser.parse_args()
    trays = Trays(args.start_num, args.end_num)
    trays.print_placement()
    standard_string = 'ISTD' if args.standard_format == 1 else 'LQC' if args.standard_format == 2 else 'QC' if args.standard_format == 3 else None
    if standard_string is None:
        raise ValueError('enter 1 for pHILIC, 2 for lipid, or 3 for ZIC')
    seqgen = SequenceGenerator(trays, args.sequence_number,
                               args.block_interval, standard_string,
                               args.beginning_blanks)
    seqgen.directory(args.directory)
    if os.path.exists('.\\' + args.filename1):
        raise ValueError('This file already exists')
    if os.path.exists('.\\' + args.filename2):
        raise ValueError('This file already exists')
    seqgen.export_format_1(args.filename2)
    seqgen.export_format_2(args.filename1)
Exemplo n.º 6
0
def test_invalid_type(input_mock):
    """Test a parser with a type argument. Check that it fails when the type is wrong"""
    input_mock.side_effect = mock_input("abc")

    with pytest.raises(SystemExit):
        parser = PromptParser()
        parser.add_argument(
            "--argument", "-a", help="An argument you could provide", type=int
        )
        args = parser.parse_args([])
    input_mock.assert_called()
Exemplo n.º 7
0
def test_valid_type(input_mock):
    """Test a parser with a type argument. Check that it succeeds when the type is correct"""
    input_mock.side_effect = mock_input("123")

    parser = PromptParser()
    parser.add_argument(
        "--argument", "-a", help="An argument you could provide", type=int
    )
    args = parser.parse_args([])
    assert args.argument == 123
    input_mock.assert_called()
Exemplo n.º 8
0
def test_no_default(input_mock, capsys, monkeypatch):
    """If a flag has no default, the prompt should still say ``None``"""
    # Mock the input function
    input_mock.side_effect = mock_input("abc")

    # Create the parser
    parser = PromptParser()
    parser.add_argument("--argument", "-a", help="An argument you could provide")
    args = parser.parse_args([])

    captured = capsys.readouterr()
    assert "None" in captured.out
def main():
    parser = PromptParser()
    parser.add_argument('--pcap',
                        '-p',
                        help='PCAP file to analyze',
                        default='foo')
    pcap_file = parser.parse_args().pcap

    run_bro(pcap_file)
    for file in get_files('extract_files'):
        scan_file(file)
        ha_sandbox(file)
Exemplo n.º 10
0
def test_secure_parser(getpass_mock):
    """Test a secure parser, which shouldn't echo the user's input to stdout"""
    getpass_mock.return_value = "abc"
    parser = PromptParser()
    parser.add_argument(
        "--argument",
        "-a",
        help="An argument you could provide",
        secure=True,
        default="foo",
    )
    args = parser.parse_args([])
    assert args.argument == "abc"
    getpass_mock.assert_called()
Exemplo n.º 11
0
def test_basic_parser(input_mock, capsys):
    """Test a basic parser with no type argument"""
    # Mock the input function
    input_mock.side_effect = mock_input("abc")

    parser = PromptParser()
    parser.add_argument(
        "--argument", "-a", help="An argument you could provide", default="foo"
    )
    args = parser.parse_args([])

    # If the user inputs "abc", that should be the value of the argument
    assert args.argument == "abc"

    # The default value "foo" should be shown to the user
    captured = capsys.readouterr()
    assert "foo" in captured.out
Exemplo n.º 12
0
def main():
    print("Artifactory Token Generator %s" % version)
    parser = PromptParser(
        description='A command line tool to help with generating API Key to Artifactory with SAML access.')
    subparsers = parser.add_subparsers(help="", dest="action")
    subparsers.required = True
    login_args(subparsers)
    configure_args(subparsers)
    args = parser.parse_args()
    if args.action == "login":
        config = SAML2ArtConfig()
        config.load(DEFAULT_CONFIG_FILE_PATH)
        login_saml2art(config, args)
    elif args.action == "configure":
        configure_saml2art(args, DEFAULT_CONFIG_FILE_PATH)
    else:
        parser.print_help()
Exemplo n.º 13
0
def main():
    parser = PromptParser()
    add_arguments(parser)
    args = parser.parse_args()

    if ".txt" in args.path:
        files = args.path
    else:
        files = glob.glob(f"{args.path}/*.txt")
        assert len(files) > 1, "Warning not '.txt' files found in directory."

    procobj = nd.ProcessingObject(files,
                                  args.bead_radius,
                                  opt_kwargs={'baseline_percentage': 0.2})

    models = [x.strip() for x in args.models.split(',')]

    procobj.fit_models(*models, save_plot=args.save_plot)
    procobj.to_csv(f"results.csv")
Exemplo n.º 14
0
def main():
    parser = PromptParser()
    add_arguments(parser)
    args = parser.parse_args()

    PATH = "data"  # OR IT TAKES A .TXT FILE
    BEAD_RADIUS = 18.5e-6
    MODELS = "hertz_model, line"
    SAVE = False

    if ".txt" in args.path:
        files = args.path
    else:
        files = glob.glob(f"{args.path}/*.txt")

    obj = nd.ProcessingObject(files, args.bead_radius)

    models = [x.strip() for x in args.models.split(",")]

    obj.fit_models(*models, save_plot=args.save_plot)

    obj.to_csv("results_demo2.csv", index=None)
Exemplo n.º 15
0
def parse_args():
    parser = PromptParser(description='Create gn3 databags')
    parser.add_argument('-i',
                        '--instance',
                        dest='geonetwork_instance',
                        help='geonetwork 2 instance '
                        'e.g. https://catalogue-imos.aodn.org.au')
    parser.add_argument('-u',
                        '--username',
                        dest='username',
                        help='username for basic auth')
    parser.add_argument('-p',
                        '--password',
                        dest='password',
                        help='password for basic auth. '
                        'If a username is given but not a password, the '
                        'password will be prompted for.',
                        secure=True)
    parser.add_argument('-o',
                        '--output-directory',
                        default='.',
                        dest='output_directory',
                        help='directory at which to backup the repositories')
    return parser.parse_args()
Exemplo n.º 16
0
from argparse_prompt import PromptParser

parser = PromptParser()
parser.add_argument('--argument',
                    '-a',
                    help='An argument you could provide',
                    type=int)
print(parser.parse_args().argument)
Exemplo n.º 17
0
    required=False,
    help=
    "List of tag IDs which are to be merged and removed on the Omero server")

parser.add_argument(
    '-d',
    '--dry-run',
    type=bool,
    dest='dry_run',
    required=False,
    help=
    "Instructs the tag manager to report intended changes rather than actually perform the merge "
    "and tag deletion process. Non-destructive and allows you to see what will be changed without "
    "actually doing so.")

args = parser.parse_args()
target_tag_id = args.target_tag_id
tags_to_remove = args.tags_to_remove
target_tag_label = args.target_tag_label
tag_labels_to_remove = args.tag_labels_to_remove

username = args.username
server = args.server
USERNAME, PASSWORD, HOST, PORT = '', '', '', 0

if username is not None and server is not None:
    # validate args
    if username.strip() is "":
        print("Username is empty")
        quit()
Exemplo n.º 18
0
from argparse_prompt import PromptParser

parser = PromptParser()
parser.add_argument('--argument',
                    '-a',
                    help='Choose either Ansible or Terraform',
                    default='Ansible or Terraform?')
parser.add_argument('--filepath',
                    '-fp',
                    help='Specify file path',
                    default='Whats the file path?')

argument = parser.parse_args().argument
filepath = parser.parse_args().filepath
if (argument == 'Terraform' or argument == 'Ansible'):
    print("You chose: " + argument)
else:
    print(
        "Incorrect input. Must choose either Ansible or Terraform. Please try again."
    )
print("Selected file path is: " + filepath)