rs-parsepatch 0.3.0__tar.gz → 0.3.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Cargo.toml
CHANGED
PKG-INFO
CHANGED
src/init.rs
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
use parsepatch::PatchReader;
|
|
2
|
-
use pyo3::exceptions::TypeError;
|
|
1
|
+
use parsepatch::{ParsepatchError, PatchReader};
|
|
2
|
+
use pyo3::exceptions::{RuntimeError, TypeError};
|
|
3
3
|
use pyo3::prelude::*;
|
|
4
4
|
use pyo3::types::{PyBool, PyDict, PyModule};
|
|
5
|
-
use pyo3::Python;
|
|
5
|
+
use pyo3::{PyErr, Python};
|
|
6
|
+
|
|
7
|
+
struct PPError(ParsepatchError);
|
|
8
|
+
|
|
9
|
+
impl std::convert::From<PPError> for PyErr {
|
|
10
|
+
fn from(e: PPError) -> Self {
|
|
11
|
+
RuntimeError::py_err(e.0.to_string())
|
|
12
|
+
}
|
|
13
|
+
}
|
|
6
14
|
|
|
7
15
|
macro_rules! parse_patch {
|
|
8
16
|
($py:path, $bytes:path, $v:ident) => {{
|
|
@@ -10,8 +18,12 @@ macro_rules! parse_patch {
|
|
|
10
18
|
|
|
11
19
|
if let Some(bytes) = crate::common::get_bytes($py, &$bytes) {
|
|
12
20
|
match bytes {
|
|
13
|
-
crate::common::Bytes::Slice(bytes) =>
|
|
14
|
-
|
|
21
|
+
crate::common::Bytes::Slice(bytes) => {
|
|
22
|
+
PatchReader::by_buf(bytes, &mut patch).map_err(|e| PPError(e))?
|
|
23
|
+
}
|
|
24
|
+
crate::common::Bytes::Vec(bytes) => {
|
|
25
|
+
PatchReader::by_buf(&bytes, &mut patch).map_err(|e| PPError(e))?
|
|
26
|
+
}
|
|
15
27
|
}
|
|
16
28
|
} else {
|
|
17
29
|
return Err(TypeError::py_err("Invalid patch type"));
|
|
@@ -40,8 +52,12 @@ fn get_diffs(py: Python, bytes: PyObject, kwargs: Option<&PyDict>) -> PyResult<P
|
|
|
40
52
|
|
|
41
53
|
if let Some(bytes) = crate::common::get_bytes(py, &bytes) {
|
|
42
54
|
match bytes {
|
|
43
|
-
crate::common::Bytes::Slice(bytes) =>
|
|
44
|
-
|
|
55
|
+
crate::common::Bytes::Slice(bytes) => {
|
|
56
|
+
PatchReader::by_buf(bytes, &mut patch).map_err(|e| PPError(e))?
|
|
57
|
+
}
|
|
58
|
+
crate::common::Bytes::Vec(bytes) => {
|
|
59
|
+
PatchReader::by_buf(&bytes, &mut patch).map_err(|e| PPError(e))?
|
|
60
|
+
}
|
|
45
61
|
}
|
|
46
62
|
} else {
|
|
47
63
|
return Err(TypeError::py_err("Invalid patch type"));
|
|
Binary file
|
|
Binary file
|