Skip to content

Instantly share code, notes, and snippets.

@mahmoud
Last active May 1, 2019 00:56
Show Gist options
  • Save mahmoud/8f60dd54c4729a71b5c3f7d0e64fe37a to your computer and use it in GitHub Desktop.
Save mahmoud/8f60dd54c4729a71b5c3f7d0e64fe37a to your computer and use it in GitHub Desktop.

Revisions

  1. mahmoud revised this gist May 1, 2019. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions import_gist_cmd.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    $ python tools/admin.py import-gist --help
    Usage: tools/admin.py import_gist [FLAGS]

    import round entries from a csv list


    Flags:

    --help / -h show this help message and exit
    --debug get extra output, enable debug console before db commit
    --round-id ROUND_ID integer (required)
    --url URL str (required)
  2. mahmoud revised this gist May 1, 2019. 1 changed file with 32 additions and 0 deletions.
    32 changes: 32 additions & 0 deletions montage_face_help.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    $ python tools/admin.py -h
    Usage: tools/admin.py subcommand [FLAGS]

    CLI tools for administrating Montage.


    Subcommands:

    add-organizer Add a top-level organizer to the system, capable of creating campaigns and adding
    coordinators.
    add-coordinator add specified user as coordinator of a given campaign
    create-campaign interactively create a campaign
    cancel-campaign cancel the specified campaign
    create-round interactively create a round in the specified campaign
    import-gist import round entries from a csv list
    activate-round activate a round to start or resume voting
    pause-round pause a round to make edits and perform other maintenance
    advance-round finalize the specified round and start the next
    edit-round-quorum change the quorum of a given round, assigning and reassigning tasks as need be
    check-round-dupes check for double-assigned tasks or ratings in a specified round
    apply-round-ratings apply ratings to a round based on an input file
    retask-duplicate-ratings reassign all ratings that were duplicated
    shuffle-round-assignments randomly reassign all the rating tasks in a round
    cancel-round set a round as cancelled, cancel related tasks and remove it from the campaign's active
    rounds.
    list-campaigns list details about all campaigns
    rdb-console Load a developer console for interacting with database objects.


    Flags:

    --help / -h show this help message and exit
  3. mahmoud revised this gist Apr 30, 2019. 2 changed files with 31 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions example_argparse_help.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    $ chert -h
    usage: chert [-h] {init,version,serve,render,publish,clean} ...

    positional arguments:
    {init,version,serve,render,publish,clean}
    chert supports init, serve, and publish subcommands
    init create a new Chert site
    version display the version and other metadata
    serve work on a Chert site using the local server
    render generate a local copy of the site
    publish upload a Chert site to the remote server
    clean clean Chert output site directory

    optional arguments:
    -h, --help show this help message and exit
    16 changes: 16 additions & 0 deletions example_face_help.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    $ chert -h
    Usage: /home/mahmoud/virtualenvs/chert/bin/chert subcommand [FLAGS]

    Subcommands:

    init create a new Chert site
    serve work on a Chert site using the local server
    render generate a local copy of the site
    publish upload a Chert site to the remote server
    clean clean Chert output site directory
    version display the version and other metadata


    Flags:

    --help / -h show this help message and exit
  4. mahmoud revised this gist Apr 30, 2019. No changes.
  5. mahmoud renamed this gist Apr 30, 2019. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions tmp.py → basic_argparse_framework.py
    Original file line number Diff line number Diff line change
    @@ -12,11 +12,12 @@ def add_subparsers(subparsers):
    parser_list.set_defaults(func=get_list)
    ...

    def main():
    def main(argv=None):
    parser = create_parser()
    args = parser.parse_args()
    args = parser.parse_args(argv)
    kwargs = dict(args._get_kwargs())
    args.func(**kwargs)
    return

    if __name__ == '__main__':
    main()
    sys.exit(main())
  6. mahmoud revised this gist Apr 30, 2019. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion tmp.py
    Original file line number Diff line number Diff line change
    @@ -16,4 +16,7 @@ def main():
    parser = create_parser()
    args = parser.parse_args()
    kwargs = dict(args._get_kwargs())
    args.func(**kwargs)
    args.func(**kwargs)

    if __name__ == '__main__':
    main()
  7. mahmoud revised this gist Apr 30, 2019. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion tmp.py
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,11 @@ def add_subparsers(subparsers):
    parser_list = subparsers.add_parser('list')
    parser_list.add_argument('target_list', nargs='?',
    help='Name of the list or list file')
    parser_list.set_defaults(func=get_list)
    parser_list.set_defaults(func=get_list)
    ...

    def main():
    parser = create_parser()
    args = parser.parse_args()
    kwargs = dict(args._get_kwargs())
    args.func(**kwargs)
  8. mahmoud created this gist Apr 30, 2019.
    12 changes: 12 additions & 0 deletions tmp.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    def create_parser():
    root_parser = ArgumentParser(description='article fetch operations')
    root_parser.add_argument('--list_home', help='list lookup directory')
    add_subparsers(root_parser.add_subparsers())
    return root_parser


    def add_subparsers(subparsers):
    parser_list = subparsers.add_parser('list')
    parser_list.add_argument('target_list', nargs='?',
    help='Name of the list or list file')
    parser_list.set_defaults(func=get_list)