Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tuneit
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ximper Linux
tuneit
Commits
52bd55f7
Commit
52bd55f7
authored
Jan 11, 2025
by
Roman Alifanov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
get_range implemented
if there is no map in module, it will be generated
parent
d0f54f64
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
2 deletions
+31
-2
__init__.py
src/settings/__init__.py
+16
-2
backends.py
src/settings/backends.py
+15
-0
No files found.
src/settings/__init__.py
View file @
52bd55f7
...
...
@@ -13,15 +13,24 @@ class Setting:
self
.
backend
=
setting_data
.
get
(
'backend'
)
self
.
key
=
setting_data
.
get
(
'key'
)
self
.
default
=
setting_data
.
get
(
'default'
)
self
.
map
=
setting_data
.
get
(
'map'
,
self
.
_default_map
())
if
setting_data
.
get
(
'gtype'
):
if
len
(
setting_data
.
get
(
'gtype'
))
>
2
:
self
.
gtype
=
setting_data
.
get
(
'gtype'
)[
0
]
self
.
map
=
setting_data
.
get
(
'map'
,
self
.
_default_map
())
self
.
data
=
setting_data
.
get
(
'data'
,
{})
def
_default_map
(
self
):
if
self
.
type
==
'boolean'
:
# Дефолтная карта для булевых настроек
return
{
True
:
True
,
False
:
False
}
if
self
.
type
==
'choice'
:
# Дефолтная карта для выборов
map
=
{}
range
=
self
.
_get_backend_range
()
for
var
in
range
:
print
(
var
)
map
[
var
[
0
]
.
upper
()
+
var
[
1
:]]
=
var
return
map
return
{}
def
create_row
(
self
):
...
...
@@ -38,6 +47,11 @@ class Setting:
return
backend
.
get_value
(
self
.
key
,
self
.
gtype
)
return
self
.
default
def
_get_backend_range
(
self
):
backend
=
self
.
_get_backend
()
if
backend
:
return
backend
.
get_range
(
self
.
key
,
self
.
gtype
)
def
_set_backend_value
(
self
,
value
):
backend
=
self
.
_get_backend
()
if
backend
:
...
...
src/settings/backends.py
View file @
52bd55f7
...
...
@@ -4,6 +4,9 @@ class Backend:
def
get_value
(
self
,
key
,
gtype
):
raise
NotImplementedError
(
"Метод get_value должен быть реализован"
)
def
get_range
(
self
,
key
,
gtype
):
raise
NotImplementedError
(
"Метод get_range должен быть реализован"
)
def
set_value
(
self
,
key
,
value
,
gtype
):
raise
NotImplementedError
(
"Метод set_value должен быть реализован"
)
...
...
@@ -21,6 +24,18 @@ class GSettingsBackend(Backend):
print
(
f
"[ERROR] Ошибка при получении значения {key}: {e}"
)
return
None
def
get_range
(
self
,
key
,
gtype
):
schema_name
,
key_name
=
key
.
rsplit
(
'.'
,
1
)
schema
=
Gio
.
Settings
.
new
(
schema_name
)
print
(
f
"[DEBUG] Получение значения: schema={schema_name}, key={key_name}, gtype={gtype}"
)
try
:
value
=
schema
.
get_range
(
key_name
)
return
value
.
unpack
()[
1
]
except
Exception
as
e
:
print
(
f
"[ERROR] Ошибка при получении значения {key}: {e}"
)
return
None
def
set_value
(
self
,
schema_key
,
value
,
gtype
):
schema_name
,
key_name
=
schema_key
.
rsplit
(
'.'
,
1
)
schema
=
Gio
.
Settings
.
new
(
schema_name
)
...
...
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