Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Turris
pyuci
Commits
786f2bbc
Verified
Commit
786f2bbc
authored
Mar 14, 2018
by
Karel Koci
🤘
Browse files
Add get_all for getting whole section
parent
52826924
Pipeline
#34359
passed with stage
in 45 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
pyuci.c
View file @
786f2bbc
...
...
@@ -137,8 +137,7 @@ static bool lookup_ptr(uci_object *self, PyObject *args, struct uci_ptr *ptr) {
return
true
;
}
static
PyObject
*
pyuci_get
(
uci_object
*
self
,
PyObject
*
args
)
{
// TODO add support for listing all (see section type)
static
PyObject
*
pyuci_get_common
(
uci_object
*
self
,
PyObject
*
args
,
bool
all
)
{
struct
uci_ptr
ptr
;
if
(
!
lookup_ptr
(
self
,
args
,
&
ptr
))
...
...
@@ -154,8 +153,10 @@ static PyObject *pyuci_get(uci_object *self, PyObject *args) {
case
UCI_TYPE_PACKAGE
:
return
pyuci_package
(
ptr
.
p
);
case
UCI_TYPE_SECTION
:
// TODO for all push section from ptr.s
return
Py_BuildValue
(
"s"
,
ptr
.
s
->
type
);
if
(
all
)
return
pyuci_section
(
ptr
.
s
);
else
return
Py_BuildValue
(
"s"
,
ptr
.
s
->
type
);
case
UCI_TYPE_OPTION
:
return
pyuci_option
(
ptr
.
o
);
default:
...
...
@@ -168,6 +169,14 @@ static PyObject *pyuci_get(uci_object *self, PyObject *args) {
}
}
static
PyObject
*
pyuci_get
(
uci_object
*
self
,
PyObject
*
args
)
{
return
pyuci_get_common
(
self
,
args
,
false
);
}
static
PyObject
*
pyuci_get_all
(
uci_object
*
self
,
PyObject
*
args
)
{
return
pyuci_get_common
(
self
,
args
,
true
);
}
static
PyObject
*
pyuci_set
(
uci_object
*
self
,
PyObject
*
args
)
{
struct
uci_ptr
ptr
;
memset
(
&
ptr
,
0
,
sizeof
ptr
);
...
...
@@ -396,6 +405,7 @@ static PyObject *pyuci_set_savedir(uci_object *self, PyObject *args) {
static
PyMethodDef
uci_methods
[]
=
{
{
"get"
,
(
PyCFunction
)
pyuci_get
,
METH_VARARGS
,
"Get value"
},
{
"get_all"
,
(
PyCFunction
)
pyuci_get_all
,
METH_VARARGS
,
"Get all values even for sections"
},
{
"set"
,
(
PyCFunction
)
pyuci_set
,
METH_VARARGS
,
"Set value"
},
{
"delete"
,
(
PyCFunction
)
pyuci_delete
,
METH_VARARGS
,
"Delete option"
},
{
"add"
,
(
PyCFunction
)
pyuci_add
,
METH_VARARGS
,
"Add new anonymous section"
},
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment