Skip to content

Commit

Permalink
Merge pull request #39 from gkreitz/contest_and_assignment_arguments
Browse files Browse the repository at this point in the history
Add --assignment and --contest command line options
  • Loading branch information
gkreitz authored Dec 16, 2023
2 parents 624fe94 + 68f1f8c commit e5d30f8
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def login_from_config(cfg):
return login(loginurl, username, password, token)


def submit(submit_url, cookies, problem, language, files, mainclass='', tag=''):
def submit(submit_url, cookies, problem, language, files, mainclass='', tag='', assignment=None, contest=None):
"""Make a submission.
The url_opener argument is an OpenerDirector object to use (as
Expand All @@ -255,6 +255,10 @@ def submit(submit_url, cookies, problem, language, files, mainclass='', tag=''):
'tag': tag,
'script': 'true'}

if assignment is not None:
data['assignment'] = assignment
if contest is not None:
data['contest'] = contest
sub_files = []
for f in files:
with open(f, 'rb') as sub_file:
Expand Down Expand Up @@ -367,6 +371,13 @@ def show_judgement(submission_url, cfg):

def main():
parser = argparse.ArgumentParser(prog='kattis', description='Submit a solution to Kattis')
group = parser.add_mutually_exclusive_group()
group.add_argument('-a', '--assignment',
help='''Short name of assignment you want to submit to
Overrides default guess (server guesses based on assignments you are in)''')
group.add_argument('-c', '--contest',
help='''Short name of contest you want to submit to
Overrides default guess (server guesses based on contests you are in)''')
parser.add_argument('-p', '--problem',
help=''''Which problem to submit to.
Overrides default guess (first part of first filename)''')
Expand Down Expand Up @@ -447,7 +458,9 @@ def main():
language,
files,
mainclass,
tag)
tag,
args.assignment,
args.contest)
except requests.exceptions.RequestException as err:
print('Submit connection failed:', err)
sys.exit(1)
Expand Down

0 comments on commit e5d30f8

Please sign in to comment.