Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bananas_api/new_upload/readers/base_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class BaseGraphics(BaseSet):
"description": str,
"palette": str,
"blitter": str,
"url": str | None,
},
"files": {
"base": str,
Expand Down
1 change: 1 addition & 0 deletions bananas_api/new_upload/readers/base_music.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BaseMusic(BaseSet):
"shortname": str,
"version": str,
"description": str,
"url": str | None,
},
"files": {
"theme": str,
Expand Down
1 change: 1 addition & 0 deletions bananas_api/new_upload/readers/base_sounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BaseSounds(BaseSet):
"shortname": str,
"version": str,
"description": str,
"url": str | None,
},
"files": {
"samples": str,
Expand Down
10 changes: 9 additions & 1 deletion bananas_api/new_upload/readers/helpers/base_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ class BaseSet:
@ivar description: Description of Base Set
@type description: C{str}

@ivar url: URL of Base Set
@type url: C{str}

@ivar files: Files included in Base Set, with their md5sum
@type files: C{dict}
"""
Expand All @@ -30,6 +33,7 @@ def __init__(self):
self.unique_id = None
self.version = None
self.description = None
self.url = None
self.files = None

def read(self, fp):
Expand Down Expand Up @@ -63,9 +67,12 @@ def read(self, fp):
# Check entries we expected but are not there
for key, key_type in keys.items():
if not ini_parser.has_option(section, key):
if key_type == str | None:
continue
raise ValidationException(f"Option {section}:{key} is missing.")

value = ini_parser.get(section, key)
if not isinstance(value, key_type):
if not isinstance(value, str if key_type == str | None else key_type):
raise ValidationException(f"Option {section}:{key} is not a {key_type}.")

# List the files, their md5sum, and the complete md5sum
Expand Down Expand Up @@ -95,5 +102,6 @@ def read(self, fp):
self.unique_id = ini_parser.get("metadata", "shortname").encode()
self.version = ini_parser.get("metadata", "version")
self.description = ini_parser.get("metadata", "description")
self.url = ini_parser.get("metadata", "url", fallback=None)
self.files = files
self.md5sum = md5sum
9 changes: 5 additions & 4 deletions bananas_api/new_upload/session_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ def validate_license(session):
session["errors"].append("License is not yet set for this package.")
elif session["license"] == License.CUSTOM:
for file_info in session["files"]:
if file_info["filename"] == "license.txt":
if file_info["filename"] in ("license.txt", "license.md"):
break
else:
session["errors"].append("License is set to custom, but no license.txt is uploaded.")
session["errors"].append("License is set to custom, but no 'license.txt' or 'license.md' is uploaded.")
else:
for file_info in session["files"]:
if file_info["filename"] == "license.txt":
if file_info["filename"] in ("license.txt", "license.md"):
session["errors"].append(
f"License is set to {session['license'].value}; this does not require uploading 'license.txt'."
f"License is set to {session['license'].value}; "
"this does not require uploading 'license.txt' or 'license.md'."
)


Expand Down
20 changes: 10 additions & 10 deletions bananas_api/new_upload/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@

# readme.txt and changelog.txt can have translations. This can be with the
# first part of the ISO code, or with the full. For example:
# readme.txt, readme_nl.txt, readme_nl_NL.txt
# readme.txt, readme_nl.txt, readme_nl_NL.txt, readme.md
# All other variantions are not valid.
txt_regexp = re.compile(r"(readme|changelog)(_[a-z]{2}(_[A-Z]{2})?)?\.txt$")
txt_regexp = re.compile(r"(readme|changelog)(_[a-z]{2}(_[A-Z]{2})?)?\.(txt|md)$")


def _validate_textfile_encoding(fp):
Expand All @@ -111,14 +111,14 @@ def _validate_textfile_encoding(fp):

def _read_object(filename, fp):
lfilename = filename.lower()
if lfilename.endswith(".txt"):
if filename == "license.txt":
_validate_textfile_encoding(fp)
return None
elif txt_regexp.match(filename):
_validate_textfile_encoding(fp)
return None
elif filename.startswith("lang/"):
if filename in ("license.txt", "license.md"):
_validate_textfile_encoding(fp)
return None
elif txt_regexp.match(filename):
_validate_textfile_encoding(fp)
return None
elif lfilename.endswith(".txt"):
if filename.startswith("lang/"):
_validate_textfile_encoding(fp)
return None
else:
Expand Down
5 changes: 3 additions & 2 deletions regression/100_success_base_sounds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ steps:
- file-upload: nosound.obs
- file-upload: nosound.cat
- file-upload: license.txt
name: license.md
- file-upload: readme.txt
name: readme_nl.txt
name: readme_nl.md
- file-upload: changelog.txt
name: changelog_nl.txt
name: changelog_nl.md
- api: new-package/update
name: "test"
version: "v1"
Expand Down
2 changes: 1 addition & 1 deletion regression/921_missing_custom_license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ steps:
version: "test"
license: "Custom"
- api: new-package/publish
error: "License is set to custom, but no license.txt is uploaded."
error: "License is set to custom, but no 'license.txt' or 'license.md' is uploaded."
2 changes: 1 addition & 1 deletion regression/923_custom_and_defined_license.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ steps:
version: "test"
license: "GPL v2"
- api: new-package/publish
error: "License is set to GPL v2; this does not require uploading 'license.txt'."
error: "License is set to GPL v2; this does not require uploading 'license.txt' or 'license.md'."
1 change: 1 addition & 0 deletions regression/nosound.obs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name = NoSound
shortname = NULL
version = 0
description = A sound pack without any sounds
url = http://localhost

[files]
samples = nosound.cat
Expand Down
Loading