[DCS] Split By First Line
The components is part of Content Settings Family and allows you to put a multiple values in one setting using a splitter defined in the first line of the
Overview
SplitByFirstLine
Split a given text value into multiple values using a splitter that is defined inside of the value. The result of splitting will be converted using type inside of the split_type attribute. Each value can be given under the same name suffix (but lowercased), but also the returned value can be chosen by the function split_default_chooser attribute. The first line will be used as a splitter if the value from the split_default_key attribute is in this line. It may sound confusing, but let me show you an example:
from content_settings.types.array import SplitByFirstLine
MY_VAR = SplitByFirstLine(
split_default_key="MAIN",
split_type=SimpleDecimal()
)
# now the variable will work as simple Decimal, with the extra suffix __main that returns the same value
# but if you update the value in admin to:
"""=== MAIN ===
10.67
=== SECOND ===
4.12
"""
# your variable will work a bit different
content_settings.MY_VAR == Decimal("10.67")
content_settings.MY_VAR__main == Decimal("10.67")
content_settings.MY_VAR__second == Decimal("4.12")
# the first line in the value === MAIN === defines the splitter rule, which means the following value will work the same
"""!!! MAIN !!!
10.67
!!! SECOND !!!
4.12
"""
It has a wide variety of attributes:
- split_type - the type which will be used for each value. You can use a dict to set a specific type for each key
- split_default_key - the key which will be used for the first line
- split_default_chooser - the function which will be used for choosing default value
- split_not_found - what should be done if the required key is not found.
NOT_FOUND.DEFAULT- return default value,NOT_FOUND.KEY_ERRORraise an exception andNOT_FOUND.VALUEreturn value from split_not_found_value - split_key_validator - a function that validates a key. You can use a function
split_validator_infor the validator value - split_key_validator_failed - two passible values
SPLIT_FAIL.IGNORE(default) andSPLIT_FAIL.RAISE. What should the system do if validation is failed.SPLIT_FAIL.IGNORE- just use the line with an invalid key as a value for the previous key.SPLIT_FAIL.RAISE- raiseValidationError
SplitTranslation
same as SplitByFirstLine but the default value will be chosen based on current django translation django.utils.translation.get_language
Metadata
Release files for dcs-split-by-first-line 0.1.1
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 | |
|---|---|---|---|---|
| dcs_split_by_first_line-0.1.1.tar.gz | 4.3 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dcs_split_by_first_line-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.1 kB
Release files / dcs_split_by_first_line-0.1.1.tar.gz
| Download URL | dcs_split_by_first_line-0.1.1.tar.gz |
|---|---|
| Size | 4.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b038af9f2db63a7af6c7a407139f5c7460fee13c947c63f5f1dd72962b3b14a7
|
|
BLAKE2b-256 checksum How to use checksums |
6ed0d1215ee8702488ae9bf1d37651474cea1c4f3526cb769ffb59c95c1ba89b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.0 CPython/3.11.3 Darwin/23.6.0
|
Release files / dcs_split_by_first_line-0.1.1-py3-none-any.whl
| Download URL | dcs_split_by_first_line-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d39c944edb3975d733d3063692cace32dbc02c1c4ca7ad7748db9d7290b3a353
|
|
BLAKE2b-256 checksum How to use checksums |
f31e10856645bd78b061bc6739f66d52e602117422e22e640d3f1b85e91aae84
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.0 CPython/3.11.3 Darwin/23.6.0
|
Security for dcs-split-by-first-line 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.