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
Link Mauve
python-nbxmpp
Commits
6b5e7f87
Commit
6b5e7f87
authored
Apr 20, 2020
by
Emmanuel Gil Peyrot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Util: Fix circular import by moving get_form() to the dataforms module
parent
355cfbac
Pipeline
#5444
passed with stages
in 33 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
18 deletions
+17
-18
nbxmpp/modules/dataforms.py
nbxmpp/modules/dataforms.py
+16
-0
nbxmpp/modules/register.py
nbxmpp/modules/register.py
+1
-1
nbxmpp/util.py
nbxmpp/util.py
+0
-17
No files found.
nbxmpp/modules/dataforms.py
View file @
6b5e7f87
...
...
@@ -105,6 +105,22 @@ def extend_form(node):
return
SimpleDataForm
(
extend
=
node
)
def
get_form
(
node
,
form_type
):
forms
=
node
.
getTags
(
'x'
,
namespace
=
Namespace
.
DATA
)
if
not
forms
:
return
None
for
form
in
forms
:
form
=
extend_form
(
node
=
form
)
field
=
form
.
vars
.
get
(
'FORM_TYPE'
)
if
field
is
None
:
continue
if
field
.
value
==
form_type
:
return
form
return
None
class
DataField
(
ExtendedNode
):
"""
Keeps data about one field - var, field type, labels, instructions... Base
...
...
nbxmpp/modules/register.py
View file @
6b5e7f87
...
...
@@ -25,9 +25,9 @@ from nbxmpp.structs import ChangePasswordResult
from
nbxmpp.util
import
call_on_response
from
nbxmpp.util
import
callback
from
nbxmpp.util
import
raise_error
from
nbxmpp.util
import
get_form
from
nbxmpp.const
import
REGISTER_FIELDS
from
nbxmpp.modules.bits_of_binary
import
parse_bob_data
from
nbxmpp.modules.dataforms
import
get_form
from
nbxmpp.modules.dataforms
import
extend_form
from
nbxmpp.modules.dataforms
import
create_field
from
nbxmpp.modules.dataforms
import
SimpleDataForm
...
...
nbxmpp/util.py
View file @
6b5e7f87
...
...
@@ -46,7 +46,6 @@ from nbxmpp.structs import PresenceProperties
from
nbxmpp.structs
import
CommonError
from
nbxmpp.structs
import
HTTPUploadError
from
nbxmpp.structs
import
StanzaMalformedError
from
nbxmpp.modules.dataforms
import
extend_form
from
nbxmpp.third_party.hsluv
import
hsluv_to_rgb
log
=
logging
.
getLogger
(
'nbxmpp.util'
)
...
...
@@ -342,22 +341,6 @@ def generate_id():
return
str
(
uuid
.
uuid4
())
def
get_form
(
stanza
,
form_type
):
forms
=
stanza
.
getTags
(
'x'
,
namespace
=
Namespace
.
DATA
)
if
not
forms
:
return
None
for
form
in
forms
:
form
=
extend_form
(
node
=
form
)
field
=
form
.
vars
.
get
(
'FORM_TYPE'
)
if
field
is
None
:
continue
if
field
.
value
==
form_type
:
return
form
return
None
def
validate_stream_header
(
stanza
,
domain
,
is_websocket
):
attrs
=
stanza
.
getAttrs
()
if
attrs
.
get
(
'from'
)
!=
domain
:
...
...
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