Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Argifying

  • Loading branch information...
commit 7e6da81742feda144fd61d45f1b7ec878e64a557 1 parent baa6b81
Rich Jones authored August 14, 2011

Showing 2 changed files with 27 additions and 12 deletions. Show diff stats Hide diff stats

  1. 38  robot.py
  2. 1  users.txt
38  robot.py
@@ -2,16 +2,26 @@
2 2
 import settings
3 3
 import simplejson
4 4
 import subprocess
  5
+import sys
  6
+import argparse
5 7
 
6  
-auth = (settings.username, settings.password)
7  
-user = 'Miserlou'
8  
-repos = 'https://api.github.com/users/' + user + '/repos'
9  
-r = requests.get (repos, auth = auth) 
  8
+def main():
  9
+    parser = argparse.ArgumentParser(description='Whitespace annihilating GitHub robot.')
  10
+    parser.add_argument('-u', '--users', help='A text file with usernames.', default='users.txt')
  11
+    parser.add_argument('-c', '--count', help='The maximum number of total requests to make.', default=999999)
10 12
 
11  
-if (r.status_code == 200):
12  
-    resp = simplejson.loads (r.content) 
13  
-    for repo in resp:
14  
-        print "clonged"
  13
+    args = parser.parse_args()
  14
+    print args
  15
+
  16
+    auth = (settings.username, settings.password)
  17
+    user = 'Miserlou'
  18
+    repos = 'https://api.github.com/users/' + user + '/repos'
  19
+    r = requests.get (repos, auth = auth) 
  20
+
  21
+    if (r.status_code == 200):
  22
+        resp = simplejson.loads (r.content) 
  23
+        for repo in resp:
  24
+            print "clonged"
15 25
 
16 26
 def fork_repo(user, repo):
17 27
     url = 'https://api.github.com/repos/' + user + '/' + repo + '/forks'
@@ -44,7 +54,7 @@ def change_branch(repo):
44 54
     except Exception, e:
45 55
         return False
46 56
 
47  
-def fix_repo (repo):
  57
+#def fix_repo (repo):
48 58
     #TODO
49 59
 
50 60
 def commit_repo(repo):
@@ -69,14 +79,18 @@ def push_commit(repo):
69 79
 
70 80
 def submit_pull_request(user, repo):
71 81
     url = 'https://api.github.com/repos/' + user + '/' + repo + '/pulls'
72  
-    params = {'title': 'Hi! We cleaned up your code for you!', 'body': 'Hi
73  
-            there!\n\nThis is WhitespaceBot from Gun.io. I\'m a robot that
74  
-            removes white space in your code! Blah blah blah.'}
  82
+    params = {'title': 'Hi! We cleaned up your code for you!', 'body': 'Hi'
  83
+            + 'there!\n\nThis is WhitespaceBot from Gun.io. I\'m a robot that'
  84
+            + 'removes white space in your code! Blah blah blah.'}
75 85
     r = requests.post(url, auth = auth, params=params)
76 86
     if (r.status_code == 201):
77 87
         return True
78 88
     else:
79 89
 	return None
  90
+
  91
+if __name__ == '__main__':
  92
+        sys.exit(main())
  93
+
80 94
 #pseudo
81 95
 #    take name from list
82 96
 #    scan names for most names most popular repo
1  users.txt
... ...
@@ -0,0 +1 @@
  1
+Miserlou

0 notes on commit 7e6da81

Please sign in to comment.
Something went wrong with that request. Please try again.