Skip to content

Commit

Permalink
Merge ad9de5b into 27d89ea
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed May 20, 2019
2 parents 27d89ea + ad9de5b commit 950863d
Show file tree
Hide file tree
Showing 16 changed files with 638 additions and 532 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,5 +1,6 @@
# 0.3 (unreleased)

- Added ORM method: `all()`
- Added ORM method: `get_or_none()`.
- Added ORM method: `get_or_create()`.

Expand Down
43 changes: 0 additions & 43 deletions datafiles/builders.py

This file was deleted.

12 changes: 9 additions & 3 deletions datafiles/meta.py → datafiles/config.py
@@ -1,11 +1,17 @@
"""Configuration defaults for each model."""

from __future__ import annotations

from dataclasses import dataclass
from typing import Dict, Optional
from typing import TYPE_CHECKING, Dict, Optional


from .converters import Converter
if TYPE_CHECKING:
from .converters import Converter


@dataclass
class ModelMeta:
class Meta:
datafile_attrs: Optional[Dict[str, Converter]] = None
datafile_pattern: Optional[str] = None

Expand Down
22 changes: 14 additions & 8 deletions datafiles/decorators.py
@@ -1,19 +1,25 @@
from __future__ import annotations

import dataclasses
from pathlib import Path
from typing import Dict, Optional
from typing import TYPE_CHECKING, Dict, Optional

from .config import Meta
from .models import create_model


from .converters import Converter
from .models import ModelMeta, create_model
if TYPE_CHECKING:
from .converters import Converter


def datafile(
pattern: str,
attrs: Optional[Dict[str, Converter]] = None,
manual: bool = ModelMeta.datafile_manual,
defaults: bool = ModelMeta.datafile_defaults,
auto_load: bool = ModelMeta.datafile_auto_load,
auto_save: bool = ModelMeta.datafile_auto_save,
auto_attr: bool = ModelMeta.datafile_auto_attr,
manual: bool = Meta.datafile_manual,
defaults: bool = Meta.datafile_defaults,
auto_load: bool = Meta.datafile_auto_load,
auto_save: bool = Meta.datafile_auto_save,
auto_attr: bool = Meta.datafile_auto_attr,
):
"""Synchronize a data class to the specified path."""

Expand Down
4 changes: 2 additions & 2 deletions datafiles/hooks.py
Expand Up @@ -5,7 +5,7 @@
import log

from . import settings
from .builders import build_datafile
from .mappers import create_mapper


LOAD_BEFORE_METHODS = ['__getattribute__', '__getitem__', '__iter__']
Expand Down Expand Up @@ -65,7 +65,7 @@ def apply(instance, datafile):
setattr(instance, attr_name, attr)
else:
continue
attr.datafile = build_datafile(attr, root=datafile)
attr.datafile = create_mapper(attr, root=datafile)
apply(attr, datafile)


Expand Down

0 comments on commit 950863d

Please sign in to comment.