@@ -27,39 +27,43 @@ https://pypi.python.org/pypi/object-mapper
27
27
28
28
** 1.1.0 - 2019/07/13**
29
29
30
- - Add basic support for nested object, thanks [ @direbearform ] ( https://github.com/direbearform )
30
+ * Add basic support for nested object, thanks [ @direbearform ] ( https://github.com/direbearform )
31
31
32
32
** 1.0.7 - 2019/06/19**
33
33
34
34
* Fix type name inside mapper dict to avoid collision, thanks [ @renanvieira ] ( https://github.com/renanvieira )
35
35
36
36
** 1.0.6 - 2018/10/28**
37
37
38
- - Added ability to specify excluded fields, thanks [ @uralov ] ( https://github.com/uralov )
38
+ * Added ability to specify excluded fields, thanks [ @uralov ] ( https://github.com/uralov )
39
39
40
40
** 1.0.5 - 2018/02/21**
41
41
42
- - Support for dynamic properties [ @nijm ] ( https://github.com/nijm )
42
+ * Support for dynamic properties [ @nijm ] ( https://github.com/nijm )
43
43
44
44
** 1.0.4 - 2017/11/03**
45
45
46
- - Migration to new Pypi.org deployment
46
+ * Migration to new Pypi.org deployment
47
47
48
48
** 1.0.3 - 2015/05/15**
49
49
50
- - Added support for None mapping [ @ramiabughazaleh ] ( https://github.com/ramiabughazaleh )
50
+ * Added support for None mapping [ @ramiabughazaleh ] ( https://github.com/ramiabughazaleh )
51
+
51
52
52
53
** 1.0.2 - 2015/05/06**
53
54
54
- - Added support for case insensitivity mapping [ @ramiabughazaleh ] ( https://github.com/ramiabughazaleh )
55
+ * Added support for case insensitivity mapping [ @ramiabughazaleh ] ( https://github.com/ramiabughazaleh )
56
+
55
57
56
58
** 1.0.1 - 2015/02/19**
57
59
58
- - Fix of the package information
60
+ * Fix of the package information
61
+
59
62
60
63
** 1.0.0 - 2015/02/19**
61
64
62
- - Initial version
65
+ * Initial version
66
+
63
67
64
68
## About
65
69
@@ -70,80 +74,80 @@ It helps you to create objects between project layers (data layer, service layer
70
74
71
75
1 . ** Mapping of the properties without mapping definition**
72
76
73
- In this case are mapped only these properties of the target class which
74
- are in target and source classes. Other properties are not mapped.
75
- Suppose we have class ` A ` with attributes ` name ` and ` last_name `
76
- and class ` B ` with attribute ` name ` .
77
- Initialization of the ObjectMapper will be:
77
+ In this case are mapped only these properties of the target class which
78
+ are in target and source classes. Other properties are not mapped.
79
+ Suppose we have class ` A ` with attributes ` name ` and ` last_name `
80
+ and class ` B ` with attribute ` name ` .
81
+ Initialization of the ObjectMapper will be:
78
82
79
- ``` python
80
- mapper = ObjectMapper()
81
- mapper.create_map(A, B)
82
- instance_b = mapper.map(A(), B)
83
- ```
83
+ ``` python
84
+ mapper = ObjectMapper()
85
+ mapper.create_map(A, B)
86
+ instance_b = mapper.map(A(), B)
87
+ ```
84
88
85
- In this case, value of A.name will be copied into B.name.
89
+ In this case, value of A.name will be copied into B.name.
86
90
87
91
2 . ** Mapping with defined mapping functions**
88
92
89
- Suppose we have class ` A ` with attributes ` first_name ` and ` last_name `
90
- , class ` B ` with attribute ` full_name ` and class ` C ` with attribute reverse_name.
91
- And want to map it in a way ` B.full_name = A.first_name + A.last_name ` and
92
- ` C.reverse_name = A.last_name + A.first_name `
93
- Initialization of the ObjectMapper will be:
93
+ Suppose we have class ` A ` with attributes ` first_name ` and ` last_name `
94
+ , class ` B ` with attribute ` full_name ` and class ` C ` with attribute reverse_name.
95
+ And want to map it in a way ` B.full_name = A.first_name + A.last_name ` and
96
+ ` C.reverse_name = A.last_name + A.first_name `
97
+ Initialization of the ObjectMapper will be:
94
98
95
- ``` python
96
- mapper = ObjectMapper()
97
- mapper.create_map(A, B, {' name' : lambda a : a.first_name + " " + a.last_name})
98
- mapper.create_map(A, C, {' name' : lambda a : a.last_name + " " + a.first_name})
99
+ ``` python
100
+ mapper = ObjectMapper()
101
+ mapper.create_map(A, B, {' name' : lambda a : a.first_name + " " + a.last_name})
102
+ mapper.create_map(A, C, {' name' : lambda a : a.last_name + " " + a.first_name})
99
103
100
- instance_b = mapper.map(A(), B)
101
- instance_c = mapper.map(A(), C)
102
- ```
104
+ instance_b = mapper.map(A(), B)
105
+ instance_c = mapper.map(A(), C)
106
+ ```
103
107
104
- In this case, to the ` B.name ` will be mapped ` A.first_name + " " + A.last_name `
105
- In this case, to the ` C.name ` will be mapped ` A.last_name + " " + A.first_name `
108
+ In this case, to the ` B.name ` will be mapped ` A.first_name + " " + A.last_name `
109
+ In this case, to the ` C.name ` will be mapped ` A.last_name + " " + A.first_name `
106
110
107
111
3 . ** Mapping suppression**
108
112
109
- For some purposes, it can be needed to suppress some mapping.
110
- Suppose we have class ` A ` with attributes ` name ` and ` last_name `
111
- and class ` B ` with attributes ` name ` and ` last_name ` .
112
- And we want to map only the ` A.name ` into ` B.name ` , but not ` A.last_name ` to
113
- ` B.last_name `
114
- Initialization of the ObjectMapper will be:
113
+ For some purposes, it can be needed to suppress some mapping.
114
+ Suppose we have class ` A ` with attributes ` name ` and ` last_name `
115
+ and class ` B ` with attributes ` name ` and ` last_name ` .
116
+ And we want to map only the ` A.name ` into ` B.name ` , but not ` A.last_name ` to
117
+ ` B.last_name `
118
+ Initialization of the ObjectMapper will be:
115
119
116
- ``` python
117
- mapper = ObjectMapper()
118
- mapper.create_map(A, B, {' last_name' : None })
120
+ ``` python
121
+ mapper = ObjectMapper()
122
+ mapper.create_map(A, B, {' last_name' : None })
119
123
120
- instance_b = mapper.map(A(), B)
121
- ```
124
+ instance_b = mapper.map(A(), B)
125
+ ```
122
126
123
- In this case, value of A.name will be copied into ` B.name ` automatically by the attribute name ` name ` .
124
- Attribute ` A.last_name ` will be not mapped thanks the suppression (lambda function is None).
127
+ In this case, value of A.name will be copied into ` B.name ` automatically by the attribute name ` name ` .
128
+ Attribute ` A.last_name ` will be not mapped thanks the suppression (lambda function is None).
125
129
126
130
4 . ** Case insensitive mapping**
127
131
128
- Suppose we have class ` A ` with attributes ` Name ` and ` Age ` and
129
- class ` B ` with attributes ` name ` and ` age ` and we want to map ` A ` to ` B ` in a way
130
- ` B.name ` = ` A.Name ` and ` B.age ` = ` A.Age `
131
- Initialization of the ObjectMapper will be:
132
+ Suppose we have class ` A ` with attributes ` Name ` and ` Age ` and
133
+ class ` B ` with attributes ` name ` and ` age ` and we want to map ` A ` to ` B ` in a way
134
+ ` B.name ` = ` A.Name ` and ` B.age ` = ` A.Age `
135
+ Initialization of the ObjectMapper will be:
132
136
133
- ``` python
134
- mapper = ObjectMapper()
135
- mapper.create_map(A, B)
136
- instance_b = mapper.map(A(), B, ignore_case = True )
137
- ```
137
+ ``` python
138
+ mapper = ObjectMapper()
139
+ mapper.create_map(A, B)
140
+ instance_b = mapper.map(A(), B, ignore_case = True )
141
+ ```
138
142
139
- In this case, the value of A.Name will be copied into B.name and
140
- the value of A.Age will be copied into B.age.
143
+ In this case, the value of A.Name will be copied into B.name and
144
+ the value of A.Age will be copied into B.age.
141
145
142
- ** Note:** You can find more examples in tests package
146
+ ** Note:** You can find more examples in tests package
143
147
144
148
## Installation
145
149
146
- - Download this project
147
- - Download from Pypi: https://pypi.python.org/pypi/object-mapper
150
+ * Download this project
151
+ * Download from Pypi: https://pypi.python.org/pypi/object-mapper
148
152
149
- ### ENJOY IT!
153
+ ### ENJOY IT!
0 commit comments