Пример #1
0
"""
   Obtain GitHub username & password from config file
"""
parser = SafeConfigParser()
parser.read("orgman.conf")

githubUsername = parser.get("github", "username")
githubPassword = parser.get("github", "password")

"""
    Get commandline arguments
"""
parser = argparse.ArgumentParser()
parser.add_argument("org", help="name of GitHub organization", type=str) # Organization Name
subParser = parser.add_subparsers(help="commands")

# List Commands
listParser = subParser.add_parser("list", help="List details of specified attribute")
listParser.add_argument("-p", "--profile", help="generate an organization/team profile", action="store_true", dest="listProfile")
listParser.add_argument("-t", "--team", help="list team(s)", metavar="team_id", nargs="*", dest="listTeamID")
listParser.add_argument("-m", "--member", help="list member(s)", metavar="member_id", nargs="*", dest="listMemberID")
listParser.add_argument("-s", "--repos", help="list repos", action="store_true", dest="listRepos")

# Add Commands
addParser = subParser.add_parser("add", help="Add resources to specified organization")
addParser.add_argument("-p", "--profile", help="use an org profile to perform add operations", nargs=1, dest="addProfile")
addParser.add_argument("-r", "--repo", help="perform operations on repositories", nargs=1, dest="addRepo")
addParser.add_argument("-t", "--team", help="perform operations on teams", nargs=1, dest="addTeam")
addParser.add_argument("-e", "--perm", help="level of permission", choices=["pull", "push", "admin"], dest="addPerm", default="pull")
addParser.add_argument("-m", "--member", help="perform operations on members", nargs=1, dest="addMember")