Reformat using black
This commit is contained in:
parent
efee4ad081
commit
a87fb49918
221 changed files with 19127 additions and 7310 deletions
|
@ -6,42 +6,50 @@ from judge.models import Contest, ContestParticipation, Submission
|
|||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Checks for duplicate code using MOSS'
|
||||
help = "Checks for duplicate code using MOSS"
|
||||
|
||||
LANG_MAPPING = {
|
||||
('C++', MOSS_LANG_CC),
|
||||
('C', MOSS_LANG_C),
|
||||
('Java', MOSS_LANG_JAVA),
|
||||
('Python', MOSS_LANG_PYTHON),
|
||||
('Pascal', MOSS_LANG_PASCAL),
|
||||
("C++", MOSS_LANG_CC),
|
||||
("C", MOSS_LANG_C),
|
||||
("Java", MOSS_LANG_JAVA),
|
||||
("Python", MOSS_LANG_PYTHON),
|
||||
("Pascal", MOSS_LANG_PASCAL),
|
||||
}
|
||||
|
||||
def add_arguments(self, parser):
|
||||
parser.add_argument('contest', help='the id of the contest')
|
||||
parser.add_argument("contest", help="the id of the contest")
|
||||
|
||||
def handle(self, *args, **options):
|
||||
moss_api_key = settings.MOSS_API_KEY
|
||||
if moss_api_key is None:
|
||||
print('No MOSS API Key supplied')
|
||||
print("No MOSS API Key supplied")
|
||||
return
|
||||
contest = options['contest']
|
||||
contest = options["contest"]
|
||||
|
||||
for problem in Contest.objects.get(key=contest).problems.order_by('code'):
|
||||
print('========== %s / %s ==========' % (problem.code, problem.name))
|
||||
for problem in Contest.objects.get(key=contest).problems.order_by("code"):
|
||||
print("========== %s / %s ==========" % (problem.code, problem.name))
|
||||
for dmoj_lang, moss_lang in self.LANG_MAPPING:
|
||||
print("%s: " % dmoj_lang, end=' ')
|
||||
print("%s: " % dmoj_lang, end=" ")
|
||||
subs = Submission.objects.filter(
|
||||
contest__participation__virtual__in=(ContestParticipation.LIVE, ContestParticipation.SPECTATE),
|
||||
contest__participation__virtual__in=(
|
||||
ContestParticipation.LIVE,
|
||||
ContestParticipation.SPECTATE,
|
||||
),
|
||||
contest__participation__contest__key=contest,
|
||||
result='AC', problem__id=problem.id,
|
||||
result="AC",
|
||||
problem__id=problem.id,
|
||||
language__common_name=dmoj_lang,
|
||||
).values_list('user__user__username', 'source__source')
|
||||
).values_list("user__user__username", "source__source")
|
||||
if not subs:
|
||||
print('<no submissions>')
|
||||
print("<no submissions>")
|
||||
continue
|
||||
|
||||
moss_call = MOSS(moss_api_key, language=moss_lang, matching_file_limit=100,
|
||||
comment='%s - %s' % (contest, problem.code))
|
||||
moss_call = MOSS(
|
||||
moss_api_key,
|
||||
language=moss_lang,
|
||||
matching_file_limit=100,
|
||||
comment="%s - %s" % (contest, problem.code),
|
||||
)
|
||||
|
||||
users = set()
|
||||
|
||||
|
@ -49,6 +57,6 @@ class Command(BaseCommand):
|
|||
if username in users:
|
||||
continue
|
||||
users.add(username)
|
||||
moss_call.add_file_from_memory(username, source.encode('utf-8'))
|
||||
moss_call.add_file_from_memory(username, source.encode("utf-8"))
|
||||
|
||||
print('(%d): %s' % (subs.count(), moss_call.process()))
|
||||
print("(%d): %s" % (subs.count(), moss_call.process()))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue