Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
pyuci
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Turris
pyuci
Commits
786f2bbc
Verified
Commit
786f2bbc
authored
Mar 14, 2018
by
Karel Koci
🤘
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
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
Showing
1 changed file
with
14 additions
and
4 deletions
+14
-4
pyuci.c
pyuci.c
+14
-4
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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