Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
gajim
python-nbxmpp
Commits
1b11aaf7
Commit
1b11aaf7
authored
Dec 28, 2020
by
Philipp Hörist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
VCard4: Add copy()
parent
6b441d7f
Pipeline
#6900
passed with stages
in 4 minutes and 57 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
0 deletions
+74
-0
nbxmpp/modules/vcard4.py
nbxmpp/modules/vcard4.py
+74
-0
No files found.
nbxmpp/modules/vcard4.py
View file @
1b11aaf7
...
...
@@ -173,6 +173,9 @@ class Parameter:
node
.
addChild
(
self
.
type
,
payload
=
self
.
value
)
return
node
def
copy
(
self
):
return
self
.
__class__
(
value
=
self
.
value
)
@
dataclass
class
MultiParameter
:
...
...
@@ -208,6 +211,9 @@ class MultiParameter:
node
.
addChild
(
self
.
type
,
payload
=
value
)
return
node
def
copy
(
self
):
return
self
.
__class__
(
values
=
set
(
self
.
values
))
@
dataclass
class
LanguageParameter
(
Parameter
):
...
...
@@ -293,6 +299,10 @@ class TzParameter:
node
.
addChild
(
self
.
value_type
,
payload
=
self
.
value
)
return
node
def
copy
(
self
):
return
self
.
__class__
(
value_type
=
self
.
value_type
,
value
=
self
.
value
)
class
Parameters
:
def
__init__
(
self
,
parameters
=
None
):
...
...
@@ -330,6 +340,12 @@ class Parameters:
parameter
.
values
.
update
(
types
)
def
copy
(
self
):
parameters
=
{}
for
name
,
parameter
in
self
.
_parameters
.
items
():
parameters
[
name
]
=
parameter
.
copy
()
return
self
.
__class__
(
parameters
=
parameters
)
PARAMETER_CLASSES
=
{
'language'
:
LanguageParameter
,
...
...
@@ -377,6 +393,10 @@ class UriProperty:
def
is_empty
(
self
):
return
not
self
.
value
def
copy
(
self
):
return
self
.
__class__
(
value
=
self
.
value
,
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
TextProperty
:
...
...
@@ -410,6 +430,10 @@ class TextProperty:
def
is_empty
(
self
):
return
not
self
.
value
def
copy
(
self
):
return
self
.
__class__
(
value
=
self
.
value
,
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
TextListProperty
:
...
...
@@ -447,6 +471,10 @@ class TextListProperty:
def
is_empty
(
self
):
return
not
self
.
values
def
copy
(
self
):
return
self
.
__class__
(
values
=
list
(
self
.
values
),
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
MultipleValueProperty
:
...
...
@@ -480,6 +508,11 @@ class MultipleValueProperty:
def
is_empty
(
self
):
return
not
self
.
value
def
copy
(
self
):
return
self
.
__class__
(
value_type
=
self
.
value_type
,
value
=
self
.
value
,
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
SourceProperty
(
UriProperty
):
...
...
@@ -564,6 +597,13 @@ class NProperty:
return
False
return
True
def
copy
(
self
):
return
self
.
__class__
(
surname
=
list
(
self
.
surname
),
given
=
list
(
self
.
given
),
additional
=
list
(
self
.
additional
),
prefix
=
list
(
self
.
prefix
),
suffix
=
list
(
self
.
suffix
),
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
NicknameProperty
(
TextListProperty
):
...
...
@@ -631,6 +671,11 @@ class GenderProperty:
return
False
return
True
def
copy
(
self
):
return
self
.
__class__
(
sex
=
self
.
sex
,
identity
=
self
.
identity
,
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
AdrProperty
:
...
...
@@ -690,6 +735,16 @@ class AdrProperty:
return
False
return
True
def
copy
(
self
):
return
self
.
__class__
(
pobox
=
list
(
self
.
pobox
),
ext
=
list
(
self
.
ext
),
street
=
list
(
self
.
street
),
locality
=
list
(
self
.
locality
),
region
=
list
(
self
.
region
),
code
=
list
(
self
.
code
),
country
=
list
(
self
.
country
),
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
TelProperty
(
MultipleValueProperty
):
...
...
@@ -741,6 +796,10 @@ class LangProperty:
def
is_empty
(
self
):
return
not
self
.
value
def
copy
(
self
):
return
self
.
__class__
(
value
=
self
.
value
,
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
TzProperty
(
MultipleValueProperty
):
...
...
@@ -885,6 +944,11 @@ class ClientpidmapProperty:
def
is_empty
(
self
):
return
not
self
.
uri
def
copy
(
self
):
return
self
.
__class__
(
sourceid
=
self
.
sourceid
,
uri
=
self
.
uri
,
parameters
=
self
.
parameters
.
copy
())
@
dataclass
class
UrlProperty
(
UriProperty
):
...
...
@@ -1042,6 +1106,16 @@ class VCard:
raise
ValueError
(
'prop not found in vcard'
)
def
copy
(
self
):
properties
=
[]
for
group_name
,
props
in
self
.
_properties
:
if
group_name
is
None
:
properties
.
append
((
None
,
props
.
copy
()))
else
:
group_properties
=
[
prop
.
copy
()
for
prop
in
props
]
properties
.
append
((
group_name
,
group_properties
))
return
self
.
__class__
(
properties
=
properties
)
class
VCard4
(
BaseModule
):
...
...
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