Skip to content

Commit 78620b9

Browse files
committed
Fix #523: metadata:url was not allowed for base sets
1 parent bc77f89 commit 78620b9

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-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: 9 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):
@@ -62,7 +67,9 @@ def read(self, fp):
6267

6368
# Check entries we expected but are not there
6469
for key, key_type in keys.items():
65-
if not ini_parser.has_option(section, key):
70+
if key_type == Optional[str]:
71+
key_type = str
72+
elif not ini_parser.has_option(section, key):
6673
raise ValidationException(f"Option {section}:{key} is missing.")
6774
value = ini_parser.get(section, key)
6875
if not isinstance(value, key_type):
@@ -95,5 +102,6 @@ def read(self, fp):
95102
self.unique_id = ini_parser.get("metadata", "shortname").encode()
96103
self.version = ini_parser.get("metadata", "version")
97104
self.description = ini_parser.get("metadata", "description")
105+
self.url = ini_parser.get("metadata", "url")
98106
self.files = files
99107
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)