File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -75,8 +75,10 @@ def prepare_procedure(argv):
75
75
print ("prepared %s!" % pid )
76
76
77
77
78
- def prepare_workspace (contestid ):
79
- atcoder = AtCoder (AccountInformation .username , AccountInformation .password )
78
+ def prepare_workspace (contestid , without_login ):
79
+ atcoder = AtCoder ()
80
+ if not without_login :
81
+ atcoder .login (AccountInformation .username , AccountInformation .password )
80
82
81
83
while True :
82
84
plist = atcoder .get_problem_list (contestid )
@@ -90,9 +92,14 @@ def prepare_workspace(contestid):
90
92
91
93
92
94
if __name__ == "__main__" :
93
- import sys
94
- if len (sys .argv ) == 2 :
95
- contestid = sys .argv [1 ]
96
- prepare_workspace (contestid )
97
- else :
98
- print ("%s [contest_id]" % sys .argv [0 ])
95
+ import argparse
96
+ parser = argparse .ArgumentParser ()
97
+ parser .add_argument ("contestid" ,
98
+ help = "contest ID" )
99
+ parser .add_argument ("--without-login" ,
100
+ action = "store_true" ,
101
+ help = "download testdata without login" )
102
+ args = parser .parse_args ()
103
+ contestid = args .contestid
104
+ without_login = args .without_login
105
+ prepare_workspace (args .contestid , without_login )
Original file line number Diff line number Diff line change @@ -21,16 +21,18 @@ class InputParseError(Exception):
21
21
class AtCoder :
22
22
23
23
def __init__ (self , username = None , password = None ):
24
+ self .cj = http .cookiejar .CookieJar ()
25
+
26
+ self .opener = urllib .request .build_opener (
27
+ urllib .request .HTTPCookieProcessor (self .cj ))
28
+
29
+ def login (self , username = None , password = None ):
24
30
if username is None :
25
31
username = input ('AtCoder username: ' )
26
32
27
33
if password is None :
28
34
password = getpass .getpass ('AtCoder password: ' )
29
35
30
- self .cj = http .cookiejar .CookieJar ()
31
-
32
- self .opener = urllib .request .build_opener (
33
- urllib .request .HTTPCookieProcessor (self .cj ))
34
36
postdata = {
35
37
'name' : username ,
36
38
'password' : password
You can’t perform that action at this time.
0 commit comments