remove mode kwarg from Beatmap constructor
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
@@ -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<()> {
|
||||
|
||||
Reference in New Issue
Block a user