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
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
eta
gajim
Commits
b9f5755a
Commit
b9f5755a
authored
18 years ago
by
Liorithiel
Browse files
Options
Downloads
Patches
Plain Diff
Use iterators, better for memory usage.
parent
0e49ce38
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
src/common/dataforms.py
+7
-5
7 additions, 5 deletions
src/common/dataforms.py
src/common/xmpp/simplexml.py
+2
-2
2 additions, 2 deletions
src/common/xmpp/simplexml.py
src/dataforms_widget.py
+1
-1
1 addition, 1 deletion
src/dataforms_widget.py
with
10 additions
and
8 deletions
src/common/dataforms.py
+
7
−
5
View file @
b9f5755a
...
...
@@ -48,7 +48,9 @@ def Field(typ, **attrs):
def
ExtendField
(
node
):
'''
Helper function to extend a node to field of appropriate type.
'''
# TODO: move the dict out
# when validation (XEP-122) will go in, we could have another classes
# like DateTimeField - so that dicts in Field() and ExtendField() will
# be different...
typ
=
node
.
getAttr
(
'
type
'
)
f
=
{
'
boolean
'
:
BooleanField
,
...
...
@@ -216,7 +218,7 @@ class ListField(DataField):
return
locals
()
def
iter_options
(
self
):
for
element
in
self
.
get
Tags
(
'
option
'
):
# TODO: iter!
for
element
in
self
.
iter
Tags
(
'
option
'
):
v
=
element
.
getTagData
(
'
value
'
)
if
v
is
None
:
raise
WrongFieldValue
yield
(
v
,
element
.
getAttr
(
'
label
'
))
...
...
@@ -254,7 +256,7 @@ class TextMultiField(DataField):
'''
Value held in field.
'''
def
fget
(
self
):
value
=
u
''
for
element
in
self
.
get
Tags
(
'
value
'
):
# TODO: iter!
for
element
in
self
.
iter
Tags
(
'
value
'
):
value
+=
'
\n
'
+
element
.
getData
()
return
value
[
1
:]
def
fset
(
self
,
value
):
...
...
@@ -282,7 +284,7 @@ class DataRecord(ExtendedNode):
# we already have xmpp.Node inside - try to convert all
# fields into DataField objects
if
fields
is
None
:
for
field
in
self
.
get
Tags
(
'
field
'
):
# TODO: iter!
for
field
in
self
.
iter
Tags
(
'
field
'
):
if
not
isinstance
(
field
,
DataField
):
ExtendField
(
field
)
self
.
vars
[
field
.
var
]
=
field
...
...
@@ -310,7 +312,7 @@ class DataRecord(ExtendedNode):
def
iter_fields
(
self
):
'''
Iterate over fields in this record. Do not take associated
into account.
'''
for
field
in
self
.
get
Tags
(
'
field
'
):
# TODO: iter!
for
field
in
self
.
iter
Tags
(
'
field
'
):
yield
field
def
iter_with_associated
(
self
):
...
...
This diff is collapsed.
Click to expand it.
src/common/xmpp/simplexml.py
+
2
−
2
View file @
b9f5755a
...
...
@@ -200,8 +200,8 @@ class Node(object):
for
key
in
attrs
.
keys
():
if
not
node
.
attrs
.
has_key
(
key
)
or
\
node
.
attrs
[
key
]
!=
attrs
[
key
]:
break
else
:
yield
node
else
:
yield
node
def
setAttr
(
self
,
key
,
val
):
"""
Sets attribute
"
key
"
with the value
"
val
"
.
"""
...
...
This diff is collapsed.
Click to expand it.
src/dataforms_widget.py
+
1
−
1
View file @
b9f5755a
...
...
@@ -76,7 +76,7 @@ class DataFormWidget(gtk.Alignment, object):
# form is single
instructions
=
_
(
'
This is result of query.
'
)
else
:
# form is writable (TODO: move that to build_*_data_form()?
# form is writable (TODO: move that to build_*_data_form()?
)
if
isinstance
(
dataform
,
dataforms
.
SimpleDataForm
):
instructions
=
_
(
'
Fill in the form.
'
)
else
:
...
...
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