Gitlab - Argos ALM by PALO IT
Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dict-mapper
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
pit-libs
python
dict-mapper
Commits
abbfb773
Commit
abbfb773
authored
Apr 15, 2024
by
Miguel Galindo Rodriguez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: Change root package to pit
parent
e9a167c6
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
24 additions
and
42 deletions
+24
-42
README.md
README.md
+2
-2
poetry.lock
poetry.lock
+18
-23
pyproject.toml
pyproject.toml
+3
-3
src/pit/__init__.py
src/pit/__init__.py
+0
-0
src/pit/dict_mapper/mapping.py
src/pit/dict_mapper/mapping.py
+0
-0
tests/pit/__init__.py
tests/pit/__init__.py
+0
-0
tests/pit/dit_mapper/__init__.py
tests/pit/dit_mapper/__init__.py
+0
-0
tests/pit/dit_mapper/test_mapping.py
tests/pit/dit_mapper/test_mapping.py
+1
-14
No files found.
README.md
View file @
abbfb773
...
...
@@ -21,7 +21,7 @@ dictionary, and its values can be:
````
python
import
uuid
from
dict_mapper.mapping
import
map_dict
,
calculate_from_original
,
factory
,
skip
from
pit.
dict_mapper.mapping
import
map_dict
,
calculate_from_original
,
factory
,
skip
original
=
{
"first_name"
:
"Mac"
,
"last_name"
:
"Doe"
,
"age"
:
30
,
"dob"
:
"1990-01-01"
}
specification
=
{
...
...
@@ -51,7 +51,7 @@ print(result)
```
python
import
uuid
from
datetime
import
date
,
datetime
from
dict_mapper.mapping
import
(
from
pit.
dict_mapper.mapping
import
(
calculate_from_key
,
calculate_from_original
,
constant
,
...
...
poetry.lock
View file @
abbfb773
...
...
@@ -2,33 +2,28 @@
[[package]]
name = "black"
version = "24.
3
.0"
version = "24.
4
.0"
description = "The uncompromising code formatter."
optional = false
python-versions = ">=3.8"
files = [
{file = "black-24.3.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:7d5e026f8da0322b5662fa7a8e752b3fa2dac1c1cbc213c3d7ff9bdd0ab12395"},
{file = "black-24.3.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:9f50ea1132e2189d8dff0115ab75b65590a3e97de1e143795adb4ce317934995"},
{file = "black-24.3.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e2af80566f43c85f5797365077fb64a393861a3730bd110971ab7a0c94e873e7"},
{file = "black-24.3.0-cp310-cp310-win_amd64.whl", hash = "sha256:4be5bb28e090456adfc1255e03967fb67ca846a03be7aadf6249096100ee32d0"},
{file = "black-24.3.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:4f1373a7808a8f135b774039f61d59e4be7eb56b2513d3d2f02a8b9365b8a8a9"},
{file = "black-24.3.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:aadf7a02d947936ee418777e0247ea114f78aff0d0959461057cae8a04f20597"},
{file = "black-24.3.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65c02e4ea2ae09d16314d30912a58ada9a5c4fdfedf9512d23326128ac08ac3d"},
{file = "black-24.3.0-cp311-cp311-win_amd64.whl", hash = "sha256:bf21b7b230718a5f08bd32d5e4f1db7fc8788345c8aea1d155fc17852b3410f5"},
{file = "black-24.3.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:2818cf72dfd5d289e48f37ccfa08b460bf469e67fb7c4abb07edc2e9f16fb63f"},
{file = "black-24.3.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:4acf672def7eb1725f41f38bf6bf425c8237248bb0804faa3965c036f7672d11"},
{file = "black-24.3.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c7ed6668cbbfcd231fa0dc1b137d3e40c04c7f786e626b405c62bcd5db5857e4"},
{file = "black-24.3.0-cp312-cp312-win_amd64.whl", hash = "sha256:56f52cfbd3dabe2798d76dbdd299faa046a901041faf2cf33288bc4e6dae57b5"},
{file = "black-24.3.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:79dcf34b33e38ed1b17434693763301d7ccbd1c5860674a8f871bd15139e7837"},
{file = "black-24.3.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:e19cb1c6365fd6dc38a6eae2dcb691d7d83935c10215aef8e6c38edee3f77abd"},
{file = "black-24.3.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:65b76c275e4c1c5ce6e9870911384bff5ca31ab63d19c76811cb1fb162678213"},
{file = "black-24.3.0-cp38-cp38-win_amd64.whl", hash = "sha256:b5991d523eee14756f3c8d5df5231550ae8993e2286b8014e2fdea7156ed0959"},
{file = "black-24.3.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:c45f8dff244b3c431b36e3224b6be4a127c6aca780853574c00faf99258041eb"},
{file = "black-24.3.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:6905238a754ceb7788a73f02b45637d820b2f5478b20fec82ea865e4f5d4d9f7"},
{file = "black-24.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:d7de8d330763c66663661a1ffd432274a2f92f07feeddd89ffd085b5744f85e7"},
{file = "black-24.3.0-cp39-cp39-win_amd64.whl", hash = "sha256:7bb041dca0d784697af4646d3b62ba4a6b028276ae878e53f6b4f74ddd6db99f"},
{file = "black-24.3.0-py3-none-any.whl", hash = "sha256:41622020d7120e01d377f74249e677039d20e6344ff5851de8a10f11f513bf93"},
{file = "black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f"},
{file = "black-24.4.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6ad001a9ddd9b8dfd1b434d566be39b1cd502802c8d38bbb1ba612afda2ef436"},
{file = "black-24.4.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:e3a3a092b8b756c643fe45f4624dbd5a389f770a4ac294cf4d0fce6af86addaf"},
{file = "black-24.4.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:dae79397f367ac8d7adb6c779813328f6d690943f64b32983e896bcccd18cbad"},
{file = "black-24.4.0-cp310-cp310-win_amd64.whl", hash = "sha256:71d998b73c957444fb7c52096c3843875f4b6b47a54972598741fe9a7f737fcb"},
{file = "black-24.4.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:8e5537f456a22cf5cfcb2707803431d2feeb82ab3748ade280d6ccd0b40ed2e8"},
{file = "black-24.4.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:64e60a7edd71fd542a10a9643bf369bfd2644de95ec71e86790b063aa02ff745"},
{file = "black-24.4.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:5cd5b4f76056cecce3e69b0d4c228326d2595f506797f40b9233424e2524c070"},
{file = "black-24.4.0-cp311-cp311-win_amd64.whl", hash = "sha256:64578cf99b6b46a6301bc28bdb89f9d6f9b592b1c5837818a177c98525dbe397"},
{file = "black-24.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:44d99dfdf37a2a00a6f7a8dcbd19edf361d056ee51093b2445de7ca09adac965"},
{file = "black-24.4.0-cp312-cp312-win_amd64.whl", hash = "sha256:21f9407063ec71c5580b8ad975653c66508d6a9f57bd008bb8691d273705adcd"},
{file = "black-24.4.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7f2966b9b2b3b7104fca9d75b2ee856fe3fdd7ed9e47c753a4bb1a675f2caab8"},
{file = "black-24.4.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1bb9ca06e556a09f7f7177bc7cb604e5ed2d2df1e9119e4f7d2f1f7071c32e5d"},
{file = "black-24.4.0-cp38-cp38-win_amd64.whl", hash = "sha256:d4e71cdebdc8efeb6deaf5f2deb28325f8614d48426bed118ecc2dcaefb9ebf3"},
{file = "black-24.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eb949f56a63c5e134dfdca12091e98ffb5fd446293ebae123d10fc1abad00b9e"},
{file = "black-24.4.0-cp39-cp39-win_amd64.whl", hash = "sha256:7852b05d02b5b9a8c893ab95863ef8986e4dda29af80bbbda94d7aee1abf8702"},
{file = "black-24.4.0-py3-none-any.whl", hash = "sha256:74eb9b5420e26b42c00a3ff470dc0cd144b80a766128b1771d07643165e08d0e"},
{file = "black-24.4.0.tar.gz", hash = "sha256:f07b69fda20578367eaebbd670ff8fc653ab181e1ff95d84497f9fa20e7d0641"},
]
[package.dependencies]
...
...
pyproject.toml
View file @
abbfb773
[tool.poetry]
name
=
"dict-mapper"
version
=
"
1
.0.0"
version
=
"
2
.0.0"
description
=
"dict to dict mapping, allow transform the original structure given a specification"
authors
=
[
"Miguel Galindo Rodriguez <mgalindo@palo-it.com>"
]
readme
=
"README.md"
packages
=
[
{
include
=
"dict_mapper"
,
from
=
"src"
}
]
packages
=
[
{
include
=
"pit"
,
from
=
"src"
}
]
[tool.poetry.dependencies]
python
=
"^3.11"
...
...
@@ -29,7 +29,7 @@ log_cli_date_format = "%Y-%m-%d %H:%M:%S"
[tool.coverage.run]
branch
=
true
source
=
['src
/dict_mapper
']
source
=
['src']
[tool.coverage.report]
skip_empty
=
true
...
...
src/
dict_mapper
/__init__.py
→
src/
pit
/__init__.py
View file @
abbfb773
File moved
src/dict_mapper/mapping.py
→
src/
pit/
dict_mapper/mapping.py
View file @
abbfb773
File moved
tests/pit/__init__.py
0 → 100644
View file @
abbfb773
tests/pit/dit_mapper/__init__.py
0 → 100644
View file @
abbfb773
tests/test_mapping.py
→
tests/
pit/dit_mapper/
test_mapping.py
View file @
abbfb773
import
logging
import
uuid
from
datetime
import
date
,
datetime
import
pytest
from
dict_mapper.mapping
import
(
from
pit.
dict_mapper.mapping
import
(
calculate_from_key
,
calculate_from_original
,
constant
,
...
...
@@ -155,24 +154,12 @@ def test_map_no_correct_key_type():
def
test_map_with_keep_unmapped
():
original
=
{
"first_name"
:
"Mac"
,
"last_name"
:
"Doe"
,
"age"
:
30
,
"dob"
:
"1990-01-01"
}
specification
=
{
"id"
:
factory
(
lambda
:
str
(
uuid
.
uuid4
())),
"first_name"
:
skip
(),
"last_name"
:
skip
(),
"full_name"
:
calculate_from_original
(
lambda
d
:
d
[
"first_name"
]
+
" "
+
d
[
"last_name"
]
),
}
result
=
map_dict
(
original
,
specification
,
keep_unmapped
=
True
)
print
(
result
)
"""
{
"age": 30,
"dob": "1990-01-01",
"id": "160281d4-a243-46b1-b3ac-23e7de7eb178",
"full_name": "Mac Doe",
}
"""
assert
result
[
"first_name"
]
==
"Mac"
assert
result
[
"last_name"
]
==
"Doe"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment