-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3351a36
Showing
33 changed files
with
1,410 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
indent_size = 4 | ||
indent_style = space | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.bat] | ||
charset = latin1 | ||
end_of_line = crlf | ||
indent_style = tab | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[LICENSE] | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
* text=auto eol=lf | ||
|
||
*.py text diff=python | ||
*.md text diff=markdown | ||
*.bat text eol=crlf | ||
|
||
|
||
tests export-ignore | ||
.editorconfig export-ignore | ||
.gitattributes export-ignore | ||
.gitignore export-ignore | ||
*.md export-ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.pytest_cache/ | ||
__pycache__/ | ||
.mypy_cache/ | ||
*.egg-info/ | ||
**/models/ | ||
.py[cod] | ||
.eggs/ | ||
build/ | ||
*.log | ||
data/ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Copyright (c) 2021, Nuno André Novo | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
* Neither the name of the <copyright holder> nor the names of its contributors | ||
may be used to endorse or promote products derived from this software without | ||
specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | ||
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | ||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = source | ||
BUILDDIR = build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=source | ||
set BUILDDIR=build | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.http://sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Pydentic | ||
======== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
.. automodule:: pydentic | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
import sphinx_automodapi | ||
|
||
# -- Path setup -------------------------------------------------------- | ||
|
||
# Add to sys.path the absolute paths of extensions (or modules to | ||
# document with autodoc) that are in another directory. | ||
import os | ||
import sys | ||
sys.path.insert(0, os.path.abspath('../../src')) | ||
|
||
|
||
# -- Project information ----------------------------------------------- | ||
|
||
project = 'Pydentic' | ||
copyright = '2021, Nuno André Novo' | ||
author = 'Nuno André Novo' | ||
release = '0.0.1' | ||
|
||
# -- General configuration --------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = ['sphinx.ext.autodoc', | ||
'sphinx_automodapi.automodapi'] | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
source_suffix = '.rst' | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = [] | ||
|
||
# Cross-reference to Python objects marked up `like this` | ||
default_role = 'py:obj' | ||
|
||
# For debugging: warns about not found ref targets. | ||
# nitpicky = True | ||
|
||
# -- Options for HTML output ------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. | ||
html_theme = 'alabaster' | ||
|
||
# Paths (relative to this directory) that contain custom static files. | ||
# They are copied after the builtin static files, so a file named | ||
# "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ['_static'] | ||
|
||
# -- ext.extlinks options ---------------------------------------------- | ||
|
||
extlinks = {'rfc': ('https://tools.ietf.org/html/rfc%s', 'rfc:')} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Welcome to Pydentic's documentation! | ||
==================================== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
Pydentic | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Pydentic | ||
|
||
**_Pydentic_** is a thin wrapper over _[python-stdnum]_ to facilitate the use | ||
of its extensive collection of validators and formatters in _[Pydantic]_ models. | ||
|
||
``` | ||
pip install pydentic | ||
``` | ||
|
||
## Features | ||
|
||
Automatic validation and formatting. | ||
|
||
```python | ||
from pydentic.strings import Iban | ||
from pydantic import BaseModel | ||
|
||
class User(BaseModel): | ||
name: str | ||
iban: Iban | ||
|
||
user = User(name='John Doe', iban='es1000750080110600658108') | ||
print(user) | ||
|
||
#> name='John Doe' iban='ES10 0075 0080 1106 0065 8108' | ||
``` | ||
|
||
```python | ||
# note the extra last character | ||
user = User(name='John Doe', iban='es1000750080110600658108Ñ') | ||
|
||
# raises | ||
... | ||
pydantic.error_wrappers.ValidationError: 1 validation error for User | ||
iban | ||
es1000750080110600658108Ñ (type=value_error.format; error=invalid literal for int() with base 36: 'Ñ') | ||
``` | ||
|
||
Title and description in the JSON Schema. | ||
```json | ||
{ | ||
"title": "User", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"title": "Name", | ||
"type": "string" | ||
}, | ||
"iban": { | ||
"title": "IBAN", | ||
"description": "International Bank Account Number", | ||
"type": "string" | ||
} | ||
}, | ||
"required": ["user", "iban"] | ||
} | ||
``` | ||
|
||
## Identifiers | ||
|
||
The list below contains some available common identifiers. There are around 200 | ||
more included (see [the python-stdnum docs] for the complete list.) | ||
|
||
### Information and documentation | ||
|
||
| identifier | spec | description | | ||
| ------------ | ---------- | ----------- | | ||
| DOI | ISO 26324 | [Digital Object Identifier][DOI] | ||
| GRid | | [Global Release Identifier][GRid] | ||
| ISAN | ISO 15706 | [International Standard Audiovisual Number][ISAN] | ||
| ISBN | ISO 2108 | [International Standard Book Number][ISBN] | ||
| ISIL | ISO 15511 | [International Standard Identifier for Libraries][ISIL] | ||
| ISMN | ISO 10957 | [International Standard Music Number][ISMN] for notated music | ||
| ISSN | ISO 3297 | [International Standard Serial Number][ISSN] | ||
|
||
### Technology | ||
|
||
| identifier | spec | description | | ||
| ------------ | ------------- | ----------- | | ||
| IMEI | | International Mobile Equipment Identity | ||
| IMSI | [ITU E.212] | [International Mobile Subscriber Identity][IMSI] | ||
| MAC address | IEEE 802 | [Media Access Control address][MAC] | ||
| MEID | 3GPP2 S.R0048 | Mobile Equipment Identifier | ||
|
||
### Other | ||
|
||
| identifier | spec | description | | ||
| ------------ | ---------- | ----------- | | ||
| BIC | [ISO 9362] | [Business Identifier Code][BIC] | ||
| BIC-Code | ISO 6346 | [International standard for container identification][BIC-Code] | ||
| Bitcoin address | | | ||
| CAS RN | | [Chemical Abstracts Service Registry Number][CASRN] | ||
| CUSIP number | | [financial security identification number ][CUSIP] | ||
| EAN | | [International Article Number][EAN] | ||
| FIGI | [OMG FIGI] | [Financial Instrument Global Identifier][FIGI] | ||
| GS1-128 | | GS-1 (product information) using [Code 128 barcodes][C128] | ||
| IBAN | ISO 13616 | [International Bank Account Number][IBAN] | ||
| IMO number | | [International Maritime Organization number][IMO] | ||
| ISIN | ISO 6166 | International Securities Identification Number | ||
| LEI | ISO 17442 | [Legal Entity Identifier][LEI] | ||
| | ISO 11649 | Structured Creditor Reference | ||
|
||
[Pydantic]: https://github.com/samuelcolvin/pydantic | ||
[python-stdnum]: https://github.com/arthurdejong/python-stdnum | ||
[the python-stdnum docs]: https://arthurdejong.org/python-stdnum/formats | ||
|
||
[BIC]: https://www.swift.com/standards/data-standards/bic-business-identifier-code "(SWIFT) Society for Worldwide Interbank Financial Telecommunication" | ||
[BIC-Code]: https://www.bic-code.org/ "Bureau International des Containers et du Transport Intermodal" | ||
[CASRN]: https://www.cas.org/support/documentation/chemical-substances/faqs "(CAS) Chemical Abstracts Service" | ||
[CUSIP]: https://www.cusip.com/identifiers.html#/CUSIP "CUSIP Global Services" | ||
[C128]: https://en.wikipedia.org/wiki/Code_128 | ||
[DOI]: https://www.doi.org/hb.html "DOI handbook" | ||
[EAN]: https://www.gs1.org/standards/barcodes/ean-upc "GS1 - EAN/UPC" | ||
[FIGI]: https://www.openfigi.com/ "Open FIGI" | ||
[GRid]: https://www.ifpi.org/resource/grid/ "(IFPI) International Federation of the Phonographic Industry. I've said \"pho-no-gra-phic\"" | ||
[IBAN]: https://www.swift.com/standards/data-standards/iban-international-bank-account-number "(SWIFT) Society for Worldwide Interbank Financial Telecommunication" | ||
[IMO]: https://www.imo.org/en/OurWork/MSAS/Pages/IMO-identification-number-scheme.aspx "(IMO) International Maritime Organization" | ||
[IMSI]: https://imsiadmin.com/ | ||
[ISAN]: https://www.isan.org/ "ISAN International Agency" | ||
[ISBN]: https://www.isbn-international.org/content/what-isbn "International ISBN Agency" | ||
[ISIL]: https://english.slks.dk/libraries/library-standards/isil/ "Danish Agency for Culture and Palaces (ISIL international authority)" | ||
[ISMN]: https://www.ismn-international.org/ "International ISMN Agency" | ||
[ISSN]: https://portal.issn.org/ "ISSN International Centre" | ||
[LEI]: https://www.gleif.org/en/about-lei/introducing-the-legal-entity-identifier-lei "(GLEIF) Global Legal Entity Identifier Foundation" | ||
[MAC]: https://standards.ieee.org/content/ieee-standards/en/products-services/regauth/index.html | ||
|
||
<!-- standard specs --> | ||
[ISO 9362]: https://www.iso9362.org/isobic/overview.html | ||
[ITU E.212]: https://www.itu.int/rec/T-REC-E.212 | ||
[OMG FIGI]: https://www.omg.org/spec/FIGI/1.0 |
Oops, something went wrong.