Skip to content

Commit

Permalink
Fix ContestImporter.py to work with .zip files.
Browse files Browse the repository at this point in the history
  • Loading branch information
artikz authored and stefano-maggiolo committed May 7, 2014
1 parent 774309a commit d6b3dbb
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmscontrib/ContestImporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Copyright © 2010-2012 Stefano Maggiolo <[email protected]>
# Copyright © 2010-2012 Matteo Boscariol <[email protected]>
# Copyright © 2013 Luca Wehrstedt <[email protected]>
# Copyright © 2014 Artem Iglikov <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
Expand Down Expand Up @@ -78,7 +79,7 @@ def find_root_of_archive(file_names):

current_root = None
for file_name in file_names:
if '/' not in file_name:
if '/' not in file_name or '/' not in file_name[0:-1]:
if current_root is None:
current_root = file_name
else:
Expand Down Expand Up @@ -116,7 +117,7 @@ def do_import(self):
if not os.path.isdir(self.import_source):
if self.import_source.endswith(".zip"):
archive = zipfile.ZipFile(self.import_source, "r")
file_names = archive.infolist()
file_names = archive.namelist()

self.import_dir = tempfile.mkdtemp()
archive.extractall(self.import_dir)
Expand Down

0 comments on commit d6b3dbb

Please sign in to comment.