remove mode kwarg from Beatmap constructor

This commit is contained in:
MaxOhn
2024-03-28 17:24:40 +01:00
parent 757b807f54
commit 0ce07c0e6c
3 changed files with 6 additions and 25 deletions
+4 -5
View File
@@ -31,12 +31,11 @@ The library exposes multiple classes:
```py
import rosu_pp_py as rosu
map = rosu.Beatmap(
path = "/path/to/file.osu", # either `path`, `bytes`, or `content` must be specified
mode = rosu.GameMode.Mania, # optionally convert to a specified mode
)
# either `path`, `bytes`, or `content` must be specified when parsing a map
map = rosu.Beatmap(path = "/path/to/file.osu")
# Or convert afterwards like `map.convert(rosu.GameMode.Taiko)`
# Optionally convert to a specific mode
map.convert(rosu.GameMode.Mania)
perf = rosu.Performance(
# various kwargs available
-4
View File
@@ -32,10 +32,6 @@ class Beatmap:
`'bytes': bytearray`
The content of a .osu file as bytes
The kwargs may include any of the following:
`'mode': GameMode`
Immediately convert the beatmap to the given mode
## Raises
Throws an exception if the map could not be parsed or the map's mode cannot be converted to
+2 -16
View File
@@ -31,7 +31,6 @@ impl PyBeatmap {
};
let mut map_res = None;
let mut mode = None;
for (key, value) in kwargs.iter() {
match key.extract()? {
@@ -62,17 +61,10 @@ impl PyBeatmap {
map_res = Some(Beatmap::from_bytes(bytes));
}
"mode" => {
let value = value
.extract()
.map_err(|_| PyTypeError::new_err("kwarg 'mode': must be a GameMode"))?;
mode = Some(value);
}
kwarg => {
let err = format!(
"unexpected kwarg '{kwarg}': expected 'path', \
'content', 'bytes', or 'mode'"
'content', or 'bytes'"
);
return Err(ArgsError::new_err(err));
@@ -100,13 +92,7 @@ impl PyBeatmap {
}
};
let mut this = Self { inner: map };
if let Some(mode) = mode {
this.convert(mode)?;
}
Ok(this)
Ok(Self { inner: map })
}
fn convert(&mut self, mode: PyGameMode) -> PyResult<()> {