Skip to content

Commit d5ce689

Browse files
author
direbearform
committed
conforming with new changes for README.md
1 parent 2464d93 commit d5ce689

File tree

1 file changed

+65
-61
lines changed

1 file changed

+65
-61
lines changed

README.md

Lines changed: 65 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,43 @@ https://pypi.python.org/pypi/object-mapper
2727

2828
**1.1.0 - 2019/07/13**
2929

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)
3131

3232
**1.0.7 - 2019/06/19**
3333

3434
* Fix type name inside mapper dict to avoid collision, thanks [@renanvieira](https://github.com/renanvieira)
3535

3636
**1.0.6 - 2018/10/28**
3737

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)
3939

4040
**1.0.5 - 2018/02/21**
4141

42-
- Support for dynamic properties [@nijm](https://github.com/nijm)
42+
* Support for dynamic properties [@nijm](https://github.com/nijm)
4343

4444
**1.0.4 - 2017/11/03**
4545

46-
- Migration to new Pypi.org deployment
46+
* Migration to new Pypi.org deployment
4747

4848
**1.0.3 - 2015/05/15**
4949

50-
- Added support for None mapping [@ramiabughazaleh](https://github.com/ramiabughazaleh)
50+
* Added support for None mapping [@ramiabughazaleh](https://github.com/ramiabughazaleh)
51+
5152

5253
**1.0.2 - 2015/05/06**
5354

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+
5557

5658
**1.0.1 - 2015/02/19**
5759

58-
- Fix of the package information
60+
* Fix of the package information
61+
5962

6063
**1.0.0 - 2015/02/19**
6164

62-
- Initial version
65+
* Initial version
66+
6367

6468
## About
6569

@@ -70,80 +74,80 @@ It helps you to create objects between project layers (data layer, service layer
7074

7175
1. **Mapping of the properties without mapping definition**
7276

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:
7882

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+
```
8488

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.
8690

8791
2. **Mapping with defined mapping functions**
8892

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:
9498

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})
99103

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+
```
103107

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`
106110

107111
3. **Mapping suppression**
108112

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:
115119

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})
119123

120-
instance_b = mapper.map(A(), B)
121-
```
124+
instance_b = mapper.map(A(), B)
125+
```
122126

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).
125129

126130
4. **Case insensitive mapping**
127131

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:
132136

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+
```
138142

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.
141145

142-
**Note:** You can find more examples in tests package
146+
**Note:** You can find more examples in tests package
143147

144148
## Installation
145149

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
148152

149-
### ENJOY IT!
153+
### ENJOY IT!

0 commit comments

Comments
 (0)