forked from cms-dev/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ContestImporter.py to work with .zip files.
- Loading branch information
1 parent
774309a
commit d6b3dbb
Showing
1 changed file
with
3 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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: | ||
|
@@ -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) | ||
|