Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions prelude_parser/_prelude_parser.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ from prelude_parser._prelude_parser import ( # type: ignore[attr-defined]
from prelude_parser.types import FlatFormInfo

def _parse_flat_file_to_dict(
xml_file: str | Path, short_names: bool
xml_file: str | Path, *, short_names: bool = False
) -> dict[str, FlatFormInfo]: ...
def _parse_flat_file_to_pandas_dict(
xml_file: str | Path, short_names: bool
xml_file: str | Path, *, short_names: bool = False
) -> dict[str, FlatFormInfo]: ...
def parse_site_native_file(xml_file: str | Path) -> SiteNative: ...
def parse_site_native_string(xml_str: str) -> SiteNative: ...
Expand Down
2 changes: 1 addition & 1 deletion prelude_parser/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def to_dataframe(xml_file: str | Path, *, short_names: bool = False) -> pd.DataF
>>> from prelude_parser.pandas import to_dataframe
>>> df = to_dataframe("physical_examination.xml")
"""
data = _parse_flat_file_to_pandas_dict(xml_file, short_names)
data = _parse_flat_file_to_pandas_dict(xml_file, short_names=short_names)
return pd.DataFrame.from_dict(data)
2 changes: 1 addition & 1 deletion prelude_parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def parse_to_dict(xml_file: str | Path, *, short_names: bool = False) -> dict[st
>>> from prelude_parser import parse_to_dict
>>> data = parse_to_dict("physical_examination.xml")
"""
return _parse_flat_file_to_dict(xml_file, short_names)
return _parse_flat_file_to_dict(xml_file, short_names=short_names)


def parse_to_classes(xml_file: str | Path, short_names: bool = False) -> list[Any]:
Expand Down
2 changes: 1 addition & 1 deletion prelude_parser/polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ def to_dataframe(xml_file: str | Path, *, short_names: bool = False) -> pl.DataF
>>> from prelude_parser.polars import to_dataframe
>>> df = to_dataframe("physical_examination.xml")
"""
data = _parse_flat_file_to_pandas_dict(xml_file, short_names)
data = _parse_flat_file_to_pandas_dict(xml_file, short_names=short_names)
return pl.from_dict(data)
8 changes: 8 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ fn parse_xml_pandas<'py>(
}

#[pyfunction]
#[pyo3(signature = (xml_file, *, short_names=false))]
fn _parse_flat_file_to_dict(
py: Python,
xml_file: PathBuf,
Expand All @@ -225,6 +226,7 @@ fn _parse_flat_file_to_dict(
}

#[pyfunction]
#[pyo3(signature = (xml_file, *, short_names=false))]
fn _parse_flat_file_to_pandas_dict(
py: Python,
xml_file: PathBuf,
Expand All @@ -237,6 +239,7 @@ fn _parse_flat_file_to_pandas_dict(
}

#[pyfunction]
#[pyo3(signature = (xml_file))]
fn parse_site_native_file(_py: Python, xml_file: PathBuf) -> PyResult<SiteNative> {
match parse_site_native_file_rs(&xml_file) {
Ok(native) => Ok(native),
Expand All @@ -248,6 +251,7 @@ fn parse_site_native_file(_py: Python, xml_file: PathBuf) -> PyResult<SiteNative
}

#[pyfunction]
#[pyo3(signature = (xml_str))]
fn parse_site_native_string(_py: Python, xml_str: &str) -> PyResult<SiteNative> {
match parse_site_native_string_rs(xml_str) {
Ok(native) => Ok(native),
Expand All @@ -256,6 +260,7 @@ fn parse_site_native_string(_py: Python, xml_str: &str) -> PyResult<SiteNative>
}

#[pyfunction]
#[pyo3(signature = (xml_file))]
fn parse_subject_native_file(_py: Python, xml_file: PathBuf) -> PyResult<SubjectNative> {
match parse_subject_native_file_rs(&xml_file) {
Ok(native) => Ok(native),
Expand All @@ -267,6 +272,7 @@ fn parse_subject_native_file(_py: Python, xml_file: PathBuf) -> PyResult<Subject
}

#[pyfunction]
#[pyo3(signature = (xml_str))]
fn parse_subject_native_string(_py: Python, xml_str: &str) -> PyResult<SubjectNative> {
match parse_subject_native_string_rs(xml_str) {
Ok(native) => Ok(native),
Expand All @@ -275,6 +281,7 @@ fn parse_subject_native_string(_py: Python, xml_str: &str) -> PyResult<SubjectNa
}

#[pyfunction]
#[pyo3(signature = (xml_file))]
fn parse_user_native_file(_py: Python, xml_file: PathBuf) -> PyResult<UserNative> {
match parse_user_native_file_rs(&xml_file) {
Ok(native) => Ok(native),
Expand All @@ -286,6 +293,7 @@ fn parse_user_native_file(_py: Python, xml_file: PathBuf) -> PyResult<UserNative
}

#[pyfunction]
#[pyo3(signature = (xml_str))]
fn parse_user_native_string(_py: Python, xml_str: &str) -> PyResult<UserNative> {
match parse_user_native_string_rs(xml_str) {
Ok(native) => Ok(native),
Expand Down
Loading