Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
f77737b0
Commit
f77737b0
authored
2 years ago
by
Daniel Brötzmann
Browse files
Options
Downloads
Patches
Plain Diff
chore: Settings: Add type annotations for Contact settings
parent
646d1bf5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gajim/common/modules/contacts.py
+22
-2
22 additions, 2 deletions
gajim/common/modules/contacts.py
gajim/common/setting_values.py
+17
-0
17 additions, 0 deletions
gajim/common/setting_values.py
gajim/common/settings.py
+41
-4
41 additions, 4 deletions
gajim/common/settings.py
with
80 additions
and
6 deletions
gajim/common/modules/contacts.py
+
22
−
2
View file @
f77737b0
...
...
@@ -37,6 +37,8 @@
from
gajim.common
import
types
from
gajim.common.const
import
PresenceShowExt
from
gajim.common.const
import
SimpleClientState
from
gajim.common.setting_values
import
BoolContactSettings
from
gajim.common.setting_values
import
StringContactSettings
from
gajim.common.setting_values
import
BoolGroupChatSettings
from
gajim.common.setting_values
import
IntGroupChatSettings
from
gajim.common.setting_values
import
StringGroupChatSettings
...
...
@@ -52,8 +54,26 @@
class
ContactSettings
:
def
__init__
(
self
,
account
:
str
,
jid
:
JID
)
->
None
:
self
.
get
=
partial
(
app
.
settings
.
get_contact_setting
,
account
,
jid
)
self
.
set
=
partial
(
app
.
settings
.
set_contact_setting
,
account
,
jid
)
self
.
_account
=
account
self
.
_jid
=
jid
@overload
def
get
(
self
,
setting
:
StringContactSettings
)
->
str
:
...
# noqa: E704
@overload
def
get
(
self
,
setting
:
BoolContactSettings
)
->
bool
:
...
# noqa: E704
def
get
(
self
,
setting
:
Any
)
->
Any
:
return
app
.
settings
.
get_contact_setting
(
self
.
_account
,
self
.
_jid
,
setting
)
@overload
def
set
(
self
,
setting
:
StringContactSettings
,
value
:
str
)
->
None
:
...
# noqa: E501, E704
@overload
def
set
(
self
,
setting
:
BoolContactSettings
,
value
:
bool
)
->
None
:
...
# noqa: E501, E704
def
set
(
self
,
setting
:
Any
,
value
:
Any
)
->
None
:
app
.
settings
.
set_contact_setting
(
self
.
_account
,
self
.
_jid
,
setting
,
value
)
class
GroupChatSettings
:
...
...
This diff is collapsed.
Click to expand it.
gajim/common/setting_values.py
+
17
−
0
View file @
f77737b0
...
...
@@ -405,6 +405,23 @@ class _ACCOUNT_DEFAULT:
AllGroupChatSettingsT
=
Union
[
str
,
int
,
bool
]
BoolContactSettings
=
Literal
[
'
send_marker
'
,
]
StringContactSettings
=
Literal
[
'
encryption
'
,
'
speller_language
'
,
'
send_chatstate
'
,
]
AllContactSettings
=
Literal
[
BoolContactSettings
,
StringContactSettings
]
AllContactSettingsT
=
Union
[
str
,
bool
]
ACCOUNT_SETTINGS
=
{
'
account
'
:
{
'
account_color
'
:
'
rgb(85, 85, 85)
'
,
...
...
This diff is collapsed.
Click to expand it.
gajim/common/settings.py
+
41
−
4
View file @
f77737b0
...
...
@@ -45,6 +45,10 @@
from
gajim.common.storage.base
import
Encoder
from
gajim.common.storage.base
import
json_decoder
from
gajim.common.setting_values
import
APP_SETTINGS
from
gajim.common.setting_values
import
AllContactSettings
from
gajim.common.setting_values
import
AllContactSettingsT
from
gajim.common.setting_values
import
BoolContactSettings
from
gajim.common.setting_values
import
StringContactSettings
from
gajim.common.setting_values
import
AllGroupChatSettings
from
gajim.common.setting_values
import
AllGroupChatSettingsT
from
gajim.common.setting_values
import
BoolGroupChatSettings
...
...
@@ -923,10 +927,27 @@ def set_group_chat_settings(self,
continue
self
.
set_group_chat_setting
(
account
,
jid
,
setting
,
value
)
@overload
def
get_contact_setting
(
self
,
account
:
str
,
jid
:
JID
,
setting
:
str
)
->
SETTING_TYPE
:
setting
:
BoolContactSettings
)
->
bool
:
...
@overload
def
get_contact_setting
(
self
,
account
:
str
,
jid
:
JID
,
setting
:
StringContactSettings
)
->
str
:
...
def
get_contact_setting
(
self
,
account
:
str
,
jid
:
JID
,
setting
:
AllContactSettings
)
->
AllContactSettingsT
:
if
account
not
in
self
.
_account_settings
:
raise
ValueError
(
f
'
Account missing:
{
account
}
'
)
...
...
@@ -946,11 +967,27 @@ def get_contact_setting(self,
return
default
@overload
def
set_contact_setting
(
self
,
account
:
str
,
jid
:
JID
,
setting
:
str
,
value
:
SETTING_TYPE
)
->
None
:
setting
:
StringContactSettings
,
value
:
str
)
->
None
:
...
@overload
def
set_contact_setting
(
self
,
account
:
str
,
jid
:
JID
,
setting
:
BoolContactSettings
,
value
:
bool
)
->
None
:
...
def
set_contact_setting
(
self
,
account
:
str
,
jid
:
JID
,
setting
:
AllContactSettings
,
value
:
AllContactSettingsT
)
->
None
:
if
account
not
in
self
.
_account_settings
:
raise
ValueError
(
f
'
Account missing:
{
account
}
'
)
...
...
@@ -992,7 +1029,7 @@ def set_contact_setting(self,
def
set_contact_settings
(
self
,
setting
:
str
,
value
:
SETTING_TYPE
)
->
None
:
value
:
AllContactSettings
)
->
None
:
for
account
,
acc_settings
in
self
.
_account_settings
.
items
():
for
jid
in
acc_settings
[
'
contact
'
]:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment