| Conditions | 4 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 4 |
| 1 | """Functions to interact with mapped classes and instances.""" |
||
| 8 | 1 | def new(cls, *args): |
|
| 9 | """Create a new mapped object.""" |
||
| 10 | 1 | instance = cls(*args) |
|
| 11 | 1 | mapper = _ensure_mapped(instance) |
|
| 12 | |||
| 13 | 1 | if mapper.exists: |
|
| 14 | 1 | msg = "{!r} already exists".format(mapper.path) |
|
| 15 | 1 | raise exceptions.DuplicateMappingError(msg) |
|
| 16 | |||
| 17 | 1 | return save(instance) |
|
| 18 | |||
| 19 | |||
| 20 | 1 | def find(cls, *args, create=False): |
|
| 21 | """Find a matching mapped object or return None.""" |
||
| 22 | 1 | instance = cls(*args) |
|
| 23 | 1 | mapper = _ensure_mapped(instance) |
|
| 24 | |||
| 25 | 1 | if mapper.exists: |
|
| 76 |