Skip to content

Commit

Permalink
Formatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
grzesiek2010 committed Sep 21, 2023
1 parent 57cc033 commit 5469ae6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
16 changes: 11 additions & 5 deletions pyxform/xls2json.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,13 @@ def workbook_to_json(

if row.get("default"):
new_dict["default"] = process_image_default(row["default"])
parameters_generic.validate(parameters=parameters, allowed=("max-pixels","app",))
parameters_generic.validate(
parameters=parameters,
allowed=(
"max-pixels",
"app",
),
)
if "max-pixels" in parameters.keys():
try:
int(parameters["max-pixels"])
Expand All @@ -1326,13 +1332,13 @@ def workbook_to_json(
)

if "app" in parameters.keys():
android_package_regex_pattern = "^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$"
android_package_regex_pattern = (
"^[a-z][a-z0-9_]*(\.[a-z0-9_]+)+[0-9a-z_]$"
)
app_package_name = str(parameters["app"])
if re.fullmatch(android_package_regex_pattern, app_package_name):
new_dict["control"] = new_dict.get("control", {})
new_dict["control"].update(
{"intent": app_package_name}
)
new_dict["control"].update({"intent": app_package_name})
else:
raise PyXFormError("Invalid Android package name format")

Expand Down
15 changes: 6 additions & 9 deletions tests/test_image_app_parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@


class ImageAppParameterTest(PyxformTestCase):

def test_valid_android_package_name(self):
self.assertPyxformXform(
name="data",
md="""
| survey | | | | |
| | type | name | label | parameters |
| survey | | | | |
| | type | name | label | parameters |
| | image | my_image | Image | app=com.jeyluta.timestampcamerafree |
""",
xml__xpath_match=[
Expand All @@ -25,11 +24,9 @@ def test_invalid_android_package_name(self):
name="data",
errored=True,
md="""
| survey | | | | |
| | type | name | label | parameters |
| survey | | | | |
| | type | name | label | parameters |
| | image | my_image | Image | app=something |
""",
error__contains=[
"Invalid Android package name format"
],
)
error__contains=["Invalid Android package name format"],
)

0 comments on commit 5469ae6

Please sign in to comment.