Skip to content
This repository has been archived by the owner on Apr 5, 2019. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master' into spss_labels
Browse files Browse the repository at this point in the history
Conflicts:
	pyxform/aliases.py
	pyxform/section.py
	pyxform/survey.py
  • Loading branch information
Esmail committed Jun 1, 2015
2 parents 524440f + a19ab15 commit 1ecd2c0
Show file tree
Hide file tree
Showing 4 changed files with 183 additions and 9 deletions.
1 change: 0 additions & 1 deletion pyxform/aliases.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
C.SUBMISSION_URL: C.SUBMISSION_URL
}


# TODO: Check on bind prefix approach in json.
# Conversion dictionary from user friendly column names to meaningful values
survey_header = {
Expand Down
6 changes: 0 additions & 6 deletions pyxform/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class Survey(Section):
}
)


def validate(self):
if self.id_string in [None, 'None']:
raise PyXFormError('Survey cannot have an empty id_string')
Expand Down Expand Up @@ -473,14 +472,12 @@ def to_xform(self, path=None, warnings=None):
'''
Convert the survey to a XML XForm.
:param str path: Optional filesystem path to the desired output file.
:param list warnings: Optional list into which any warnings generated during export will be appended.
:returns: If the 'path' parameter was omitted, nothing. Otherwise, a buffer containing the exported form.
:rtype: NoneType or 'StringIO.StringIO'
'''


if path:
self.print_xform_to_file(path, warnings=warnings)
else:
Expand All @@ -493,7 +490,6 @@ def to_xls(self, path=None, warnings=None):
documentation.
'''


return pyxform.survey_to_xlsform.to_xls(self, path, warnings=warnings)


Expand All @@ -503,7 +499,6 @@ def to_csv(self, path=None, warnings=None, koboform=False):
documentation.
'''


return pyxform.survey_to_xlsform.to_csv(self, path, warnings=warnings, koboform=koboform)


Expand All @@ -513,5 +508,4 @@ def to_ssjson(self, path=None, warnings=None):
documentation.
'''


return pyxform.survey_to_xlsform.to_ssjson(self, path, warnings=warnings)
183 changes: 183 additions & 0 deletions pyxform/tests/example_xforms/new_cascading_select_from_xls.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<?xml version="1.0"?>
<h:html xmlns="http://www.w3.org/2002/xforms" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:jr="http://openrosa.org/javarosa" xmlns:orx="http://openrosa.org/xforms/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<h:head>
<h:title>cascading select test</h:title>
<model>
<itext>
<translation default="true()" lang="default">
<text id="static_instance-cities-3">
<value>harlingen</value>
</text>
<text id="static_instance-cities-2">
<value>brownsville</value>
</text>
<text id="static_instance-cities-1">
<value>Finney</value>
</text>
<text id="static_instance-cities-0">
<value>Dumont</value>
</text>
<text id="static_instance-states-0">
<value>Texas</value>
</text>
<text id="static_instance-states-1">
<value>Washington</value>
</text>
<text id="static_instance-cities-5">
<value>Redmond</value>
</text>
<text id="static_instance-cities-4">
<value>Seattle</value>
</text>
<text id="static_instance-cities-7">
<value>Puyallup</value>
</text>
<text id="static_instance-counties-1">
<value>Pierce</value>
</text>
<text id="static_instance-counties-2">
<value>King</value>
</text>
<text id="static_instance-counties-3">
<value>Cameron</value>
</text>
<text id="static_instance-counties-0">
<value>King</value>
</text>
<text id="static_instance-cities-6">
<value>Tacoma</value>
</text>
</translation>
</itext>
<instance>
<cascading_select_test_name id="cascading_select_test">
<state/>
<county/>
<city/>
<meta>
<instanceID/>
</meta>
</cascading_select_test_name>
</instance>
<instance id="states">
<root>
<item>
<itextId>static_instance-states-0</itextId>
<name>texas</name>
</item>
<item>
<itextId>static_instance-states-1</itextId>
<name>washington</name>
</item>
</root>
</instance>
<instance id="cities">
<root>
<item>
<itextId>static_instance-cities-0</itextId>
<county>king</county>
<state>texas</state>
<name>dumont</name>
</item>
<item>
<itextId>static_instance-cities-1</itextId>
<county>king</county>
<state>texas</state>
<name>finney</name>
</item>
<item>
<itextId>static_instance-cities-2</itextId>
<county>cameron</county>
<state>texas</state>
<name>brownsville</name>
</item>
<item>
<itextId>static_instance-cities-3</itextId>
<county>cameron</county>
<state>texas</state>
<name>harlingen</name>
</item>
<item>
<itextId>static_instance-cities-4</itextId>
<county>king</county>
<state>washington</state>
<name>seattle</name>
</item>
<item>
<itextId>static_instance-cities-5</itextId>
<county>king</county>
<state>washington</state>
<name>redmond</name>
</item>
<item>
<itextId>static_instance-cities-6</itextId>
<county>pierce</county>
<state>washington</state>
<name>tacoma</name>
</item>
<item>
<itextId>static_instance-cities-7</itextId>
<county>pierce</county>
<state>washington</state>
<name>puyallup</name>
</item>
</root>
</instance>
<instance id="counties">
<root>
<item>
<itextId>static_instance-counties-0</itextId>
<state>washington</state>
<name>king</name>
</item>
<item>
<itextId>static_instance-counties-1</itextId>
<state>washington</state>
<name>pierce</name>
</item>
<item>
<itextId>static_instance-counties-2</itextId>
<state>texas</state>
<name>king</name>
</item>
<item>
<itextId>static_instance-counties-3</itextId>
<state>texas</state>
<name>cameron</name>
</item>
</root>
</instance>
<bind nodeset="/cascading_select_test_name/state" type="select1"/>
<bind nodeset="/cascading_select_test_name/county" type="select1"/>
<bind nodeset="/cascading_select_test_name/city" type="select1"/>
<bind calculate="concat('uuid:', uuid())" nodeset="/cascading_select_test_name/meta/instanceID" readonly="true()" type="string"/>
</model>
</h:head>
<h:body>
<select1 ref="/cascading_select_test_name/state">
<label>state</label>
<item>
<label>Texas</label>
<value>texas</value>
</item>
<item>
<label>Washington</label>
<value>washington</value>
</item>
</select1>
<select1 ref="/cascading_select_test_name/county">
<label>county</label>
<itemset nodeset="instance('counties')/root/item[state= /cascading_select_test_name/state ]">
<value ref="name"/>
<label ref="jr:itext(itextId)"/>
</itemset>
</select1>
<select1 ref="/cascading_select_test_name/city">
<label>city</label>
<itemset nodeset="instance('cities')/root/item[state= /cascading_select_test_name/state and county= /cascading_select_test_name/county ]">
<value ref="name"/>
<label ref="jr:itext(itextId)"/>
</itemset>
</select1>
</h:body>
</h:html>
2 changes: 0 additions & 2 deletions pyxform/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,11 @@ def get_pyobj_from_json(str_or_path):
doc = json.loads(str_or_path)
return doc


def flatten(li):
for subli in li:
for it in subli:
yield it


def sheet_to_csv(workbook_path, csv_path, sheet_name):
wb = xlrd.open_workbook(workbook_path)
try:
Expand Down

0 comments on commit 1ecd2c0

Please sign in to comment.