Skip to content

Commit 2a4d65f

Browse files
committed
Fix #523: metadata:url was not allowed for base sets
1 parent d7ce798 commit 2a4d65f

File tree

5 files changed

+17
-1
lines changed

5 files changed

+17
-1
lines changed

bananas_api/new_upload/readers/base_graphics.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ...helpers.enums import PackageType
22
from .helpers.base_sets import BaseSet
3+
from typing import Optional
34

45

56
class BaseGraphics(BaseSet):
@@ -13,6 +14,7 @@ class BaseGraphics(BaseSet):
1314
"description": str,
1415
"palette": str,
1516
"blitter": str,
17+
"url": Optional[str],
1618
},
1719
"files": {
1820
"base": str,

bananas_api/new_upload/readers/base_music.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ...helpers.enums import PackageType
22
from .helpers.base_sets import BaseSet
3+
from typing import Optional
34

45

56
class BaseMusic(BaseSet):
@@ -11,6 +12,7 @@ class BaseMusic(BaseSet):
1112
"shortname": str,
1213
"version": str,
1314
"description": str,
15+
"url": Optional[str],
1416
},
1517
"files": {
1618
"theme": str,

bananas_api/new_upload/readers/base_sounds.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ...helpers.enums import PackageType
22
from .helpers.base_sets import BaseSet
3+
from typing import Optional
34

45

56
class BaseSounds(BaseSet):
@@ -11,6 +12,7 @@ class BaseSounds(BaseSet):
1112
"shortname": str,
1213
"version": str,
1314
"description": str,
15+
"url": Optional[str],
1416
},
1517
"files": {
1618
"samples": str,

bananas_api/new_upload/readers/helpers/base_sets.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from configparser import ConfigParser
2+
from typing import Optional
23

34
from ...exceptions import ValidationException
45

@@ -19,6 +20,9 @@ class BaseSet:
1920
@ivar description: Description of Base Set
2021
@type description: C{str}
2122
23+
@ivar url: URL of Base Set
24+
@type url: C{str}
25+
2226
@ivar files: Files included in Base Set, with their md5sum
2327
@type files: C{dict}
2428
"""
@@ -30,6 +34,7 @@ def __init__(self):
3034
self.unique_id = None
3135
self.version = None
3236
self.description = None
37+
self.url = None
3338
self.files = None
3439

3540
def read(self, fp):
@@ -63,9 +68,12 @@ def read(self, fp):
6368
# Check entries we expected but are not there
6469
for key, key_type in keys.items():
6570
if not ini_parser.has_option(section, key):
71+
if key_type == Optional[str]:
72+
continue
6673
raise ValidationException(f"Option {section}:{key} is missing.")
74+
6775
value = ini_parser.get(section, key)
68-
if not isinstance(value, key_type):
76+
if not isinstance(value, str if keytype == Optional[str] else key_type):
6977
raise ValidationException(f"Option {section}:{key} is not a {key_type}.")
7078

7179
# List the files, their md5sum, and the complete md5sum
@@ -95,5 +103,6 @@ def read(self, fp):
95103
self.unique_id = ini_parser.get("metadata", "shortname").encode()
96104
self.version = ini_parser.get("metadata", "version")
97105
self.description = ini_parser.get("metadata", "description")
106+
self.url = ini_parser.get("metadata", "url")
98107
self.files = files
99108
self.md5sum = md5sum

regression/nosound.obs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name = NoSound
33
shortname = NULL
44
version = 0
55
description = A sound pack without any sounds
6+
url = http://localhost
67

78
[files]
89
samples = nosound.cat

0 commit comments

Comments
 (0)