remove mode kwarg from Beatmap constructor
This commit is contained in:
@@ -31,12 +31,11 @@ The library exposes multiple classes:
|
|||||||
```py
|
```py
|
||||||
import rosu_pp_py as rosu
|
import rosu_pp_py as rosu
|
||||||
|
|
||||||
map = rosu.Beatmap(
|
# either `path`, `bytes`, or `content` must be specified when parsing a map
|
||||||
path = "/path/to/file.osu", # either `path`, `bytes`, or `content` must be specified
|
map = rosu.Beatmap(path = "/path/to/file.osu")
|
||||||
mode = rosu.GameMode.Mania, # optionally convert to a specified mode
|
|
||||||
)
|
|
||||||
|
|
||||||
# Or convert afterwards like `map.convert(rosu.GameMode.Taiko)`
|
# Optionally convert to a specific mode
|
||||||
|
map.convert(rosu.GameMode.Mania)
|
||||||
|
|
||||||
perf = rosu.Performance(
|
perf = rosu.Performance(
|
||||||
# various kwargs available
|
# various kwargs available
|
||||||
|
|||||||
@@ -32,10 +32,6 @@ class Beatmap:
|
|||||||
`'bytes': bytearray`
|
`'bytes': bytearray`
|
||||||
The content of a .osu file as bytes
|
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
|
## Raises
|
||||||
|
|
||||||
Throws an exception if the map could not be parsed or the map's mode cannot be converted to
|
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 map_res = None;
|
||||||
let mut mode = None;
|
|
||||||
|
|
||||||
for (key, value) in kwargs.iter() {
|
for (key, value) in kwargs.iter() {
|
||||||
match key.extract()? {
|
match key.extract()? {
|
||||||
@@ -62,17 +61,10 @@ impl PyBeatmap {
|
|||||||
|
|
||||||
map_res = Some(Beatmap::from_bytes(bytes));
|
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 => {
|
kwarg => {
|
||||||
let err = format!(
|
let err = format!(
|
||||||
"unexpected kwarg '{kwarg}': expected 'path', \
|
"unexpected kwarg '{kwarg}': expected 'path', \
|
||||||
'content', 'bytes', or 'mode'"
|
'content', or 'bytes'"
|
||||||
);
|
);
|
||||||
|
|
||||||
return Err(ArgsError::new_err(err));
|
return Err(ArgsError::new_err(err));
|
||||||
@@ -100,13 +92,7 @@ impl PyBeatmap {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut this = Self { inner: map };
|
Ok(Self { inner: map })
|
||||||
|
|
||||||
if let Some(mode) = mode {
|
|
||||||
this.convert(mode)?;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert(&mut self, mode: PyGameMode) -> PyResult<()> {
|
fn convert(&mut self, mode: PyGameMode) -> PyResult<()> {
|
||||||
|
|||||||
Reference in New Issue
Block a user