CURA-5357 Search for license files

The old code had the problem that by definition it skipped the `files/` folder and any other dir which of course is where the licenses are.

Now, so long as the license is always just called `LICENSE` (which is the convention in open source software), it can be located anywhere.
This commit is contained in:
Ian Paschal 2018-05-16 15:16:16 +02:00
parent 310aee07ac
commit 1d8a405e86

View file

@ -338,13 +338,7 @@ class CuraPackageManager(QObject):
with zipfile.ZipFile(filename) as archive: with zipfile.ZipFile(filename) as archive:
# Go through all the files and use the first successful read as the result # Go through all the files and use the first successful read as the result
for file_info in archive.infolist(): for file_info in archive.infolist():
is_dir = lambda file_info: file_info.filename.endswith('/') if file_info.filename.endswith("LICENSE"):
if is_dir or not file_info.filename.startswith("files/"):
continue
filename_parts = os.path.basename(file_info.filename.lower()).split(".")
stripped_filename = filename_parts[0]
if stripped_filename in ("license", "licence"):
Logger.log("d", "Found potential license file '%s'", file_info.filename) Logger.log("d", "Found potential license file '%s'", file_info.filename)
try: try:
with archive.open(file_info.filename, "r") as f: with archive.open(file_info.filename, "r") as f: