Skip to content

Commit 8d021fe

Browse files
committed
update PR from master branch
2 parents 1a7c359 + a2bbc81 commit 8d021fe

31 files changed

+1887
-447
lines changed

.coveragerc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[run]
2-
branch = true
2+
branch = True
33
source = formpack
4+
relative_files = True
45

56
[report]
67
fail_under = 60
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
2+
3+
name: pytest
4+
5+
on:
6+
push:
7+
branches: [ master ]
8+
pull_request:
9+
branches: [ master ]
10+
11+
jobs:
12+
build:
13+
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
python-version: ['3.7', '3.8']
18+
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: Set up Python ${{ matrix.python-version }}
22+
uses: actions/setup-python@v2
23+
with:
24+
python-version: ${{ matrix.python-version }}
25+
- name: Upgrade pip
26+
run: python -m pip install --upgrade pip
27+
- name: Install Python 3 dependencies
28+
run: pip install -r dev-requirements-py3.txt
29+
- name: Run pytest
30+
run: pytest --cov=src -vv
31+
- name: Run coveralls
32+
uses: AndreMiras/coveralls-python-action@develop

.travis.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
formpack: machinery to build and export reports for xlsform data
22
================================================================
33

4-
.. image:: https://travis-ci.org/kobotoolbox/formpack.svg?branch=master
5-
:target: https://travis-ci.org/kobotoolbox/formpack
4+
.. image:: https://github.com/kobotoolbox/formpack/workflows/pytest/badge.svg
5+
:target: https://github.com/kobotoolbox/formpack/actions?query=workflow%3Apytest
66
.. image:: https://coveralls.io/repos/github/kobotoolbox/formpack/badge.svg?branch=master
77
:target: https://coveralls.io/github/kobotoolbox/formpack?branch=master
88

dev-requirements-py3.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
-e .
66

77
# Install testing / development requirements
8-
coverage==4.5.2
8+
coverage==5.3
99
nose==1.3.7
1010
tox==3.7.0
1111
flake8==3.6.0
@@ -14,3 +14,4 @@ funcsigs==1.0.2
1414
pytest-cov==2.6.1
1515
coveralls==1.5.1
1616
geojson-rewind==0.2.0
17+
xlwt==1.3.0

dev-requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@
88
# Install this package
99
-e .
1010

11+
# Python 2 compatibility
12+
pyquery<1.4.2
13+
pyxform<1.0.0
14+
1115
# Install testing / development requirements
12-
coverage==4.5.2
16+
coverage==5.3
1317
nose==1.3.7
1418
tox==3.7.0
1519
flake8==3.6.0

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353

5454
setup(name='formpack',
55-
version='2.0.1',
55+
version='2.1.0',
5656
description='Manipulation tools for KoBo forms',
5757
author='the formpack contributors (https://github.com/kobotoolbox/formpack/graphs/contributors)',
5858
url='https://github.com/kobotoolbox/formpack/',

src/formpack/constants.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# thus should never the boolean `False`.
1313
# When formpack cannot find a label for the requested translation, it returns the XML name instead.
1414
UNSPECIFIED_TRANSLATION = False
15+
UNSPECIFIED_HEADER_LANG = "UNSPECIFIED_HEADER_LANG"
1516

1617
# This `UNTRANSLATED` will correspond to `null` in the schema where
1718
# [{"label": ["X", "En", "Fr"]}]
@@ -52,3 +53,98 @@
5253
# column names, values are separators.
5354
'hxl': '',
5455
}
56+
57+
GEO_QUESTION_TYPES = ('geopoint', 'geotrace', 'geoshape')
58+
59+
# Export Settings
60+
EXPORT_SETTING_FIELDS = 'fields'
61+
EXPORT_SETTING_FIELDS_FROM_ALL_VERSIONS = 'fields_from_all_versions'
62+
EXPORT_SETTING_FLATTEN = 'flatten'
63+
EXPORT_SETTING_GROUP_SEP = 'group_sep'
64+
EXPORT_SETTING_HIERARCHY_IN_LABELS = 'hierarchy_in_labels'
65+
EXPORT_SETTING_LANG = 'lang'
66+
EXPORT_SETTING_NAME = 'name'
67+
EXPORT_SETTING_MULTIPLE_SELECT = 'multiple_select'
68+
EXPORT_SETTING_SOURCE = 'source'
69+
EXPORT_SETTING_TYPE = 'type'
70+
OPTIONAL_EXPORT_SETTINGS = [
71+
EXPORT_SETTING_FIELDS,
72+
EXPORT_SETTING_FLATTEN,
73+
EXPORT_SETTING_NAME,
74+
]
75+
REQUIRED_EXPORT_SETTINGS = [
76+
EXPORT_SETTING_FIELDS_FROM_ALL_VERSIONS,
77+
EXPORT_SETTING_GROUP_SEP,
78+
EXPORT_SETTING_HIERARCHY_IN_LABELS,
79+
EXPORT_SETTING_LANG,
80+
EXPORT_SETTING_MULTIPLE_SELECT,
81+
EXPORT_SETTING_TYPE,
82+
]
83+
VALID_EXPORT_SETTINGS = OPTIONAL_EXPORT_SETTINGS + REQUIRED_EXPORT_SETTINGS
84+
85+
MULTIPLE_SELECT_BOTH = 'both'
86+
MULTIPLE_SELECT_DETAILS = 'details'
87+
MULTIPLE_SELECT_SUMMARY = 'summary'
88+
VALID_MULTIPLE_SELECTS = [
89+
MULTIPLE_SELECT_BOTH,
90+
MULTIPLE_SELECT_DETAILS,
91+
MULTIPLE_SELECT_SUMMARY,
92+
]
93+
94+
EXPORT_TYPE_CSV = 'csv'
95+
EXPORT_TYPE_GEOJSON = 'geojson'
96+
EXPORT_TYPE_SPSS = 'spss_labels'
97+
EXPORT_TYPE_XLS = 'xls'
98+
VALID_EXPORT_TYPES = [
99+
EXPORT_TYPE_CSV,
100+
EXPORT_TYPE_GEOJSON,
101+
EXPORT_TYPE_SPSS,
102+
EXPORT_TYPE_XLS,
103+
]
104+
105+
DEFAULT_LANG = '_default'
106+
DEFAULT_LANG_XML = '_xml'
107+
VALID_DEFAULT_LANGUAGES = [
108+
DEFAULT_LANG,
109+
DEFAULT_LANG_XML,
110+
]
111+
112+
FALSE = 'false'
113+
TRUE = 'true'
114+
VALID_BOOLEANS = [
115+
FALSE,
116+
TRUE,
117+
]
118+
119+
# Kobo locking constants
120+
KOBO_LOCK_ALL = 'kobo--lock_all'
121+
KOBO_LOCK_COLUMN = 'kobo--locking-profile'
122+
KOBO_LOCK_KEY = 'locked'
123+
KOBO_LOCK_SHEET = 'kobo--locking-profiles'
124+
KOBO_LOCKING_RESTRICTIONS = [
125+
'choice_add',
126+
'choice_delete',
127+
'choice_label_edit',
128+
'choice_value_edit',
129+
'choice_order_edit',
130+
'question_delete',
131+
'question_label_edit',
132+
'question_settings_edit',
133+
'question_skip_logic_edit',
134+
'question_validation_edit',
135+
'group_delete',
136+
'group_label_edit',
137+
'group_question_add',
138+
'group_question_delete',
139+
'group_question_order_edit',
140+
'group_settings_edit',
141+
'group_skip_logic_edit',
142+
'group_split',
143+
'form_replace',
144+
'group_add',
145+
'question_add',
146+
'question_order_edit',
147+
'language_edit',
148+
'form_appearance',
149+
'form_meta_edit',
150+
]

src/formpack/pack.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .utils.future import OrderedDict
1414
from .utils.replace_aliases import replace_aliases
1515
from .constants import UNSPECIFIED_TRANSLATION
16+
from .constants import UNSPECIFIED_HEADER_LANG
1617
from formpack.schema.fields import CopyField
1718

1819

@@ -337,8 +338,7 @@ def to_json(self, **kwargs):
337338
def export(self, lang=UNSPECIFIED_TRANSLATION, group_sep='/', hierarchy_in_labels=False,
338339
versions=-1, multiple_select="both",
339340
force_index=False, copy_fields=(), title=None,
340-
header_lang=-1,
341-
tag_cols_for_header=None):
341+
header_lang=UNSPECIFIED_HEADER_LANG, tag_cols_for_header=None, filter_fields=()):
342342
"""
343343
Create an export for given versions of the form
344344
"""
@@ -349,8 +349,9 @@ def export(self, lang=UNSPECIFIED_TRANSLATION, group_sep='/', hierarchy_in_label
349349
version_id_keys=self.version_id_keys(versions),
350350
title=title, multiple_select=multiple_select,
351351
force_index=force_index, copy_fields=copy_fields,
352-
header_lang=header_lang,
353-
tag_cols_for_header=tag_cols_for_header)
352+
header_lang=header_lang,
353+
tag_cols_for_header=tag_cols_for_header,
354+
filter_fields=filter_fields,)
354355

355356
def autoreport(self, versions=-1):
356357
"""

0 commit comments

Comments
 (0)