diff options
author | Nathan Fritz <fritzy@netflint.net> | 2009-10-19 05:16:43 +0000 |
---|---|---|
committer | Nathan Fritz <fritzy@netflint.net> | 2009-10-19 05:16:43 +0000 |
commit | 349b1c0b283cc417fe4a51da4d111a7118416cde (patch) | |
tree | f6591fa3f4fd60095c2c8b875853f0da8e9dd013 /sleekxmpp/plugins/xep_0004.py | |
parent | a18051c1649bb4cef8b6d0b82f798051d6b21215 (diff) | |
download | slixmpp-349b1c0b283cc417fe4a51da4d111a7118416cde.tar.gz slixmpp-349b1c0b283cc417fe4a51da4d111a7118416cde.tar.bz2 slixmpp-349b1c0b283cc417fe4a51da4d111a7118416cde.tar.xz slixmpp-349b1c0b283cc417fe4a51da4d111a7118416cde.zip |
* added form merging
Diffstat (limited to 'sleekxmpp/plugins/xep_0004.py')
-rw-r--r-- | sleekxmpp/plugins/xep_0004.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sleekxmpp/plugins/xep_0004.py b/sleekxmpp/plugins/xep_0004.py index c85b09a5..ee6646fa 100644 --- a/sleekxmpp/plugins/xep_0004.py +++ b/sleekxmpp/plugins/xep_0004.py @@ -95,6 +95,19 @@ class Form(FieldContainer): self.reported = [] self.items = [] + def merge(self, form2): + form1 = Form(self.xmpp, self.type, self.title, self.instructions) + form1.fromXML(self.getXML(self.type)) + for field in form2.fields: + if not field.var in form1.fields: + form1.addField(field.var, field.type, field.label, field.desc, field.required, field.value): + else: + form1.fields[field.var].value = field.value + for option, label in field.options: + if (option, label) not in form1.fields[field.var].options: + form1.fields[field.var].addOption(option, label) + return form1 + def getValues(self): result = {} for field in self.fields: |