survey-structure (Python)
English | Español
Python port of survey-structure, the TypeScript contract for source-independent survey definitions. It validates SurveyStructure and SurveyLoadResult documents (SurveyStructure 2.1.0) and reports the same issues as the TypeScript package: same path, code, params and message.
No dependencies beyond the Python standard library.
Origin and versions
| Python release | npm release it reproduces | surveyStructureVersion |
|---|---|---|
2.1.0 |
survey-structure@2.1.0 (commit 0148e3f) |
2.1.0 |
The Python version is the npm version it reproduces, which since 2.1.0 is also the contract version. A Python-only fix is published as a post-release (2.1.0.post1). survey_structure.UPSTREAM records the npm release and commit.
Parity is checked in limesurvey-connector, where the TypeScript package is built at its pinned commit to produce expected results: 234 contract cases with their Spanish and English messages, 73 language tags, 20,608 pattern, flag and value combinations, 107 image URLs, and the grading and numeric-text helpers. Every document this package accepts is also accepted by the TypeScript validator.
localize_survey_validation_issue(issue, locale) gives the Spanish or English text of any issue, as localizeSurveyValidationIssue does.
Installation
pip install survey-structure
Python 3.12 or later.
Usage
from survey_structure import parse_survey_structure, safe_parse_survey_structure
result = safe_parse_survey_structure(document)
if not result.success:
for issue in result.issues:
print(issue["path"], issue["code"], issue["message"])
survey = parse_survey_structure(document) # raises SurveyStructureValidationError
Other functions:
parse_survey_load_result/safe_parse_survey_load_result: import or load envelopes.get_survey_execution_issues(survey): what a valid draft still needs before publication.field_response_keys(field): response columns a field produces.to_python_pattern(pattern, flags)andtest_pattern(pattern, value, flags): use aresponseFormatPatternfrom Python.calculate_survey_scoreandgrade_survey_answer: automatic grading of normalized answers.parse_survey_response_record,is_numeric_text,number_character_length,is_month_day,month_day_countandvalidation_pattern_source.FIELD_WIDGET_COMPATIBILITY,SURVEY_STRUCTURE_VERSION, andTypedDictdefinitions insurvey_structure.types.
Patterns
responseFormatPattern is ECMAScript source, tested as written (without anchors), and patternFlags may hold i, m and s. The package translates the pattern to an equivalent re expression evaluated on UTF-16 code units, as ECMAScript does, including ECMAScript's case folding for i and its line terminators for m. Patterns Python cannot match identically (variable-width look-behind, a back-reference inside a repeated group that contains its capture, a back-reference with i, group names with $) are rejected, so every accepted pattern means the same in both languages.
Image URLs are checked as new URL() does (WHATWG URL Standard); internationalized domain names use Python's IDNA 2003 codec, so a few unusual non-ASCII hosts may be judged differently.
License
MIT. The original TypeScript package is by the survey-structure authors; see its repository.
Metadata
Release files for survey-structure 2.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| survey_structure-2.1.0.tar.gz | 45.5 kB | With provenance | Details for survey_structure-2.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| survey_structure-2.1.0-py3-none-any.whl | Python 3 | none | any | Details for survey_structure-2.1.0-py3-none-any.whl |
Total release size: 95.7 kB
Release files / survey_structure-2.1.0.tar.gz
| Download URL | survey_structure-2.1.0.tar.gz |
|---|---|
| Size | 45.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f787b226acee6e62f0dd021cb8f3f387f0462495e3967a6eec7e606e6453fdf
|
|
BLAKE2b-256 checksum How to use checksums |
ef09ed90621b291ef27acc4c5a100ec257d62e1d547de4920123b9fe2b9ec760
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logRelease files / survey_structure-2.1.0-py3-none-any.whl
| Download URL | survey_structure-2.1.0-py3-none-any.whl |
|---|---|
| Size | 50.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9d6913f15c3b38ba81b5dabd041167167f1b800edfea66caa8306c9445ce4df0
|
|
BLAKE2b-256 checksum How to use checksums |
7fce6ef4c34c3c9079ea7831de55223666558bc133de2328673df26d7637f020
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logSecurity for survey-structure 2.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for survey_structure-2.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.