Skip to content

Commit

Permalink
Merge pull request #420 from yanokwa/revert-394
Browse files Browse the repository at this point in the history
Remove support for generated-by reverting #394
  • Loading branch information
lognaturel authored Feb 6, 2020
2 parents 5921c00 + 06fc51c commit 7198f5c
Show file tree
Hide file tree
Showing 11 changed files with 7 additions and 58 deletions.
1 change: 0 additions & 1 deletion pyxform/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
COMPACT_TAG = "compact_tag"

VERSION = "version"
GENERATED_BY = "generated_by"
PUBLIC_KEY = "public_key"
SUBMISSION_URL = "submission_url"
AUTO_SEND = "auto_send"
Expand Down
4 changes: 0 additions & 4 deletions pyxform/survey.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ class Survey(Section):
"public_key": unicode,
"instance_xmlns": unicode,
"version": unicode,
"generated_by": unicode,
"choices": dict,
"style": unicode,
"attribute": dict,
Expand Down Expand Up @@ -527,9 +526,6 @@ def xml_instance(self, **kwargs):
if self.version:
result.setAttribute("version", self.version)

if self.generated_by:
result.setAttribute("odk:generated-by", self.generated_by)

if self.prefix:
result.setAttribute("odk:prefix", self.prefix)

Expand Down
20 changes: 5 additions & 15 deletions pyxform/tests/builder_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,8 @@ def test_specify_other(self):
},
],
}
actual_dict = survey.to_json_dict()
actual_dict.pop("generated_by", None)
self.maxDiff = None
self.assertEqual(actual_dict, expected_dict)
self.assertEqual(survey.to_json_dict(), expected_dict)

def test_select_one_question_with_identical_choice_name(self):
"""
Expand Down Expand Up @@ -201,10 +199,8 @@ def test_select_one_question_with_identical_choice_name(self):
},
],
}
actual_dict = survey.to_json_dict()
actual_dict.pop("generated_by", None)
self.maxDiff = None
self.assertEqual(actual_dict, expected_dict)
self.assertEqual(survey.to_json_dict(), expected_dict)

def test_loop(self):
survey = utils.create_survey_from_fixture("loop", filetype=FIXTURE_FILETYPE)
Expand Down Expand Up @@ -316,10 +312,8 @@ def test_loop(self):
},
],
}
actual_dict = survey.to_json_dict()
actual_dict.pop("generated_by", None)
self.maxDiff = None
self.assertEqual(actual_dict, expected_dict)
self.assertEqual(survey.to_json_dict(), expected_dict)

def test_sms_columns(self):
survey = utils.create_survey_from_fixture("sms_info", filetype=FIXTURE_FILETYPE)
Expand Down Expand Up @@ -455,9 +449,7 @@ def test_sms_columns(self):
"title": "SMS Example",
"type": "survey",
}
actual_dict = survey.to_json_dict()
actual_dict.pop("generated_by", None)
self.assertEqual(actual_dict, expected_dict)
self.assertEqual(survey.to_json_dict(), expected_dict)

def test_style_column(self):
survey = utils.create_survey_from_fixture(
Expand Down Expand Up @@ -496,9 +488,7 @@ def test_style_column(self):
"title": "My Survey",
"type": "survey",
}
actual_dict = survey.to_json_dict()
actual_dict.pop("generated_by", None)
self.assertEqual(actual_dict, expected_dict)
self.assertEqual(survey.to_json_dict(), expected_dict)

STRIP_NS_FROM_TAG_RE = re.compile(r"\{.+\}")

Expand Down
1 change: 0 additions & 1 deletion pyxform/tests/group_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def test_json(self):
},
],
}
x_results.pop("generated_by", None)
self.maxDiff = None
self.assertEqual(x_results, expected_dict)

Expand Down
4 changes: 1 addition & 3 deletions pyxform/tests/loop_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,4 @@ def test_loop(self):
},
],
}
actual_dict = survey.to_json_dict()
actual_dict.pop("generated_by", None)
self.assertEquals(actual_dict, expected_dict)
self.assertEquals(survey.to_json_dict(), expected_dict)
4 changes: 1 addition & 3 deletions pyxform/tests/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ def test_survey_reader(self):
},
],
}
actual_dict = survey_reader.to_json_dict()
actual_dict.pop("generated_by", None)
self.assertEqual(actual_dict, expected_dict)
self.assertEqual(survey_reader.to_json_dict(), expected_dict)

def test_settings(self):
survey = create_survey_from_path(self.path)
Expand Down
1 change: 0 additions & 1 deletion pyxform/tests/tests_by_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def runTest(self):
path_to_excel_file, default_name=root_filename
)
survey = pyxform.create_survey_element_from_dict(json_survey)
survey.generated_by = ""
survey.print_xform_to_file(path_to_output_xform)

# Compare with the expected output:
Expand Down
13 changes: 0 additions & 13 deletions pyxform/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ def assertXFormEqual(self, xform1, xform2):
xform1 = ETree.fromstring(xform1.encode("utf-8"))
xform2 = ETree.fromstring(xform2.encode("utf-8"))

# Remove the odk:generated-by attribute from the primary instance child
self.remove_generated_by_attribute(xform1)
self.remove_generated_by_attribute(xform2)

# Sort tags under <model> section in each form
self.sort_model(xform1)
self.sort_model(xform2)
Expand Down Expand Up @@ -97,15 +93,6 @@ def elem_get_tag(elem):
key = elem_get_tag
elems[:] = sorted(elems, key=key)

def remove_generated_by_attribute(self, xform):
xforms_ns = "{http://www.w3.org/2002/xforms}"
odk_ns = "{http://www.opendatakit.org/xforms}"
primary_instance = xform.find(".//" + xforms_ns + "instance")

# Remove the generated-by attribute
if primary_instance is not None:
primary_instance[0].attrib.pop(odk_ns + "generated-by", None)

def sort_model(self, xform):
ns = "{http://www.w3.org/2002/xforms}"
model = xform.find(".//" + ns + "model")
Expand Down
2 changes: 0 additions & 2 deletions pyxform/tests/xls2json_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def test_simple_yes_or_no_question(self):
with codecs.open(output_path, "rb", encoding="utf-8") as actual_file:
expected_json = json.load(expected_file)
actual_json = json.load(actual_file)
actual_json.pop("generated_by", None)
self.assertEqual(expected_json, actual_json)

def test_hidden(self):
Expand Down Expand Up @@ -141,7 +140,6 @@ def test_table(self):
with codecs.open(output_path, "rb", encoding="utf-8") as actual_file:
expected_json = json.load(expected_file)
actual_json = json.load(actual_file)
actual_json.pop("generated_by", None)
self.assertEqual(expected_json, actual_json)

def test_choice_filter_choice_fields(self):
Expand Down
4 changes: 0 additions & 4 deletions pyxform/tests_v1/pyxform_test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,6 @@ def assertPyxformXform(self, **kwargs):
else:
survey = kwargs.get("survey")

# Remove the generated-by attribute
if survey:
survey.generated_by = ""

xml = survey._to_pretty_xml()
root = ETree.fromstring(xml.encode("utf-8"))

Expand Down
11 changes: 0 additions & 11 deletions pyxform/xls2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import os
import re
import sys
import subprocess
from collections import Counter

from pyxform import aliases, constants
Expand Down Expand Up @@ -407,7 +406,6 @@ def workbook_to_json(
# problems for formhub.
# constants.VERSION : datetime.datetime.now().strftime("%Y%m%d%H"),
constants.CHILDREN: [],
constants.GENERATED_BY: ("pyxform " + get_git_describe_tags()).strip(),
}
# Here the default settings are overridden by those in the settings sheet
json_dict.update(settings)
Expand Down Expand Up @@ -1432,15 +1430,6 @@ def get_parameters(raw_parameters, allowed_parameters):
return params


def get_git_describe_tags():
try:
return subprocess.check_output(
["git", "describe", "--tags", "HEAD"], universal_newlines=True
).strip()
except:
return ""


class SpreadsheetReader(object):
def __init__(self, path_or_file):
path = path_or_file
Expand Down

0 comments on commit 7198f5c

Please sign in to comment.