csonpath 0.2.0__tar.gz → 0.3.0__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.
- {csonpath-0.2.0/csonpath.egg-info → csonpath-0.3.0}/PKG-INFO +1 -1
- {csonpath-0.2.0 → csonpath-0.3.0/csonpath.egg-info}/PKG-INFO +1 -1
- {csonpath-0.2.0 → csonpath-0.3.0}/csonpath.h +16 -12
- {csonpath-0.2.0 → csonpath-0.3.0}/csonpath_python.c +21 -4
- {csonpath-0.2.0 → csonpath-0.3.0}/pyproject.toml +2 -2
- {csonpath-0.2.0 → csonpath-0.3.0}/LICENSE +0 -0
- {csonpath-0.2.0 → csonpath-0.3.0}/MANIFEST.in +0 -0
- {csonpath-0.2.0 → csonpath-0.3.0}/README.md +0 -0
- {csonpath-0.2.0 → csonpath-0.3.0}/csonpath.egg-info/SOURCES.txt +0 -0
- {csonpath-0.2.0 → csonpath-0.3.0}/csonpath.egg-info/dependency_links.txt +0 -0
- {csonpath-0.2.0 → csonpath-0.3.0}/csonpath.egg-info/requires.txt +0 -0
- {csonpath-0.2.0 → csonpath-0.3.0}/csonpath.egg-info/top_level.txt +0 -0
- {csonpath-0.2.0 → csonpath-0.3.0}/csonpath_do.h +0 -0
- {csonpath-0.2.0 → csonpath-0.3.0}/setup.cfg +0 -0
|
@@ -571,16 +571,20 @@ again:
|
|
|
571
571
|
}
|
|
572
572
|
|
|
573
573
|
/* helper use multiple times */
|
|
574
|
-
#define CSONPATH_DO_GET_NOTFOUND_UPDATER(this_idx)
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
574
|
+
#define CSONPATH_DO_GET_NOTFOUND_UPDATER(this_idx) \
|
|
575
|
+
do { \
|
|
576
|
+
int append_ret = 0; \
|
|
577
|
+
if (to_check == CSONPATH_INST_GET_OBJ) { \
|
|
578
|
+
tmp = CSONPATH_NEW_OBJECT(); \
|
|
579
|
+
append_ret = CSONPATH_APPEND_AT(ctx, this_idx, tmp); \
|
|
580
|
+
} else { \
|
|
581
|
+
tmp = CSONPATH_NEW_ARRAY(); \
|
|
582
|
+
append_ret = CSONPATH_APPEND_AT(ctx, this_idx, tmp); \
|
|
583
|
+
} \
|
|
584
|
+
walker += cjp->inst_lst[idx].next; \
|
|
585
|
+
if (append_ret < 0) return append_ret; \
|
|
586
|
+
goto next_inst; \
|
|
587
|
+
} while (0)
|
|
584
588
|
|
|
585
589
|
#define CSONPATH_GOTO_ON_RELOOP(where) \
|
|
586
590
|
nb_res += tret; if (need_reloop_in) goto where;
|
|
@@ -730,9 +734,9 @@ again:
|
|
|
730
734
|
if (tmp == value) { \
|
|
731
735
|
*need_reloop = 1; \
|
|
732
736
|
if (child_info->type == CSONPATH_INTEGER) \
|
|
733
|
-
CSONPATH_APPEND_AT(ctx, child_info->idx, to_update); \
|
|
737
|
+
return CSONPATH_APPEND_AT(ctx, child_info->idx, to_update); \
|
|
734
738
|
else \
|
|
735
|
-
CSONPATH_APPEND_AT(ctx, child_info->key, to_update); \
|
|
739
|
+
return CSONPATH_APPEND_AT(ctx, child_info->key, to_update); \
|
|
736
740
|
return 1; \
|
|
737
741
|
} \
|
|
738
742
|
return 0;
|
|
@@ -62,14 +62,29 @@
|
|
|
62
62
|
PyList_Append(array, el); \
|
|
63
63
|
})
|
|
64
64
|
|
|
65
|
-
static
|
|
65
|
+
static int pydict_try_setitemstring(PyObject *obj, const char * const at, PyObject *el)
|
|
66
66
|
{
|
|
67
|
+
if (!PyDict_Check(obj)) {
|
|
68
|
+
PyErr_Format(PyExc_ValueError, "Unable to follow path: Dict expected");
|
|
69
|
+
return -1;
|
|
70
|
+
}
|
|
71
|
+
PyDict_SetItemString(obj, at, el);
|
|
72
|
+
return 1;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static int python_set_or_insert_item(PyObject *array, Py_ssize_t at, PyObject *el)
|
|
76
|
+
{
|
|
77
|
+
if (!PyList_Check(array)) {
|
|
78
|
+
PyErr_Format(PyExc_ValueError, "Unable to follow path: List expected");
|
|
79
|
+
return -1;
|
|
80
|
+
}
|
|
67
81
|
if (at >= PyList_Size(array)) {
|
|
68
82
|
PyList_Insert(array, at, el);
|
|
69
83
|
} else {
|
|
70
84
|
Py_INCREF(el);
|
|
71
85
|
PyList_SetItem(array, at, el);
|
|
72
86
|
}
|
|
87
|
+
return 1;
|
|
73
88
|
}
|
|
74
89
|
|
|
75
90
|
#define CSONPATH_APPEND_AT(array, at, el) \
|
|
@@ -80,12 +95,12 @@ static void python_set_or_insert_item(PyObject *array, Py_ssize_t at, PyObject
|
|
|
80
95
|
unsigned long: python_set_or_insert_item, \
|
|
81
96
|
long long: python_set_or_insert_item, \
|
|
82
97
|
unsigned long long: python_set_or_insert_item, \
|
|
83
|
-
const char *:
|
|
84
|
-
char *:
|
|
98
|
+
const char *: pydict_try_setitemstring, \
|
|
99
|
+
char *: pydict_try_setitemstring \
|
|
85
100
|
) (array, at, el)
|
|
86
101
|
|
|
87
102
|
|
|
88
|
-
#define CSONPATH_FOREACH_EXT(obj, el, code, key_idx)
|
|
103
|
+
#define CSONPATH_FOREACH_EXT(obj, el, code, key_idx) \
|
|
89
104
|
if (PyDict_Check(obj)) { \
|
|
90
105
|
PyObject *key_; \
|
|
91
106
|
Py_ssize_t pos_ = 0; \
|
|
@@ -220,6 +235,8 @@ static PyObject *update_or_create(PyCsonPathObject *self, PyObject* args)
|
|
|
220
235
|
if (!PyArg_ParseTuple(args, "OO", &json, &value))
|
|
221
236
|
BAD_ARG();
|
|
222
237
|
int ret = csonpath_update_or_ceate(self->cp, json, value);
|
|
238
|
+
if (ret < 0)
|
|
239
|
+
return NULL;
|
|
223
240
|
return PyLong_FromLong(ret);
|
|
224
241
|
}
|
|
225
242
|
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "csonpath"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
readme = "README.md"
|
|
9
9
|
|
|
10
10
|
[tool.setuptools]
|
|
@@ -22,7 +22,7 @@ dev = [
|
|
|
22
22
|
testpaths = ["tests/python"]
|
|
23
23
|
|
|
24
24
|
[tool.bumpversion]
|
|
25
|
-
current_version = "0.
|
|
25
|
+
current_version = "0.3.0"
|
|
26
26
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)"
|
|
27
27
|
serialize = ["{major}.{minor}.{patch}"]
|
|
28
28
|
search = "{current_version}"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|