Add support for retrieving repositories. Closes #1

This commit is contained in:
Jose Diaz-Gonzalez
2014-09-22 01:27:19 -04:00
parent aa4201d102
commit 3c5edb0700
2 changed files with 10 additions and 6 deletions

View File

@@ -24,7 +24,7 @@ CLI Usage is as follows::
[-o OUTPUT_DIRECTORY] [--starred] [--watched] [--all] [-o OUTPUT_DIRECTORY] [--starred] [--watched] [--all]
[--issues] [--issue-comments] [--issue-events] [--issues] [--issue-comments] [--issue-events]
[--repositories] [--wikis] [--skip-existing] [--repositories] [--wikis] [--skip-existing]
[-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX] [-L [LANGUAGES [LANGUAGES ...]]] [-N NAME_REGEX] [-O]
[-R REPOSITORY] [-P] [-F] [-v] [-R REPOSITORY] [-P] [-F] [-v]
USER USER
@@ -56,6 +56,7 @@ CLI Usage is as follows::
only allow these languages only allow these languages
-N NAME_REGEX, --name-regex NAME_REGEX -N NAME_REGEX, --name-regex NAME_REGEX
python regex to match names against python regex to match names against
-O, --organization whether or not this is a query for an organization
-R REPOSITORY, --repository REPOSITORY -R REPOSITORY, --repository REPOSITORY
name of repository to limit backup to name of repository to limit backup to
-P, --private include private repositories -P, --private include private repositories

View File

@@ -91,6 +91,7 @@ def parse_args():
parser.add_argument('--skip-existing', action='store_true', dest='skip_existing', help='skip project if a backup directory exists') parser.add_argument('--skip-existing', action='store_true', dest='skip_existing', help='skip project if a backup directory exists')
parser.add_argument('-L', '--languages', dest='languages', help='only allow these languages', nargs='*') parser.add_argument('-L', '--languages', dest='languages', help='only allow these languages', nargs='*')
parser.add_argument('-N', '--name-regex', dest='name_regex', help='python regex to match names against') parser.add_argument('-N', '--name-regex', dest='name_regex', help='python regex to match names against')
parser.add_argument('-O', '--organization', action='store_true', dest='organization', help='whether or not this is a query for an organization')
parser.add_argument('-R', '--repository', dest='repository', help='name of repository to limit backup to') parser.add_argument('-R', '--repository', dest='repository', help='name of repository to limit backup to')
parser.add_argument('-P', '--private', action='store_true', dest='private', help='include private repositories') parser.add_argument('-P', '--private', action='store_true', dest='private', help='include private repositories')
parser.add_argument('-F', '--fork', action='store_true', dest='fork', help='include forked repositories') parser.add_argument('-F', '--fork', action='store_true', dest='fork', help='include forked repositories')
@@ -168,6 +169,8 @@ def retrieve_repositories(args):
log_info('Retrieving repositories') log_info('Retrieving repositories')
single_request = False single_request = False
template = 'https://api.github.com/users/{0}/repos'.format(args.user) template = 'https://api.github.com/users/{0}/repos'.format(args.user)
if args.organization:
template = 'https://api.github.com/orgs/{0}/repos'.format(args.user)
if args.repository: if args.repository:
single_request = True single_request = True