Skip to content

Commit

Permalink
Documentation updates
Browse files Browse the repository at this point in the history
  • Loading branch information
cdgriffith committed Dec 18, 2019
1 parent ec33d38 commit 466d440
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ Install

.. code:: bash
pip install python-box
pip install --upgrade python-box
Box is tested on python 3.6+
Box 4 is tested on python 3.6+

If you have any issues please open a github issue with the error you are experiencing!

Overview
========

Box 4 is out, check out the `changes and updates <_docs/4.0_changes.md>`_ !

`Box` is designed to be an easy drop in transparently replacements for
dictionaries, thanks to Python's
duck typing capabilities, which adds dot notation access. Any sub
Expand Down Expand Up @@ -156,7 +158,6 @@ Box's parameters
default_box False Act like a recursive default dict
default_box_attr Box Can overwrite with a different (non-recursive) default attribute to return
camel_killer_box False CamelCaseKeys become attribute accessible like snake case (camel_case_keys)
box_it_up False Recursively create all Boxes from the start (like previous versions)
box_safe_prefix "x" Character or prefix to prepend to otherwise invalid attributes
box_duplicates "ignore" When conversion duplicates are spotted, either ignore, warn or error
box_intact_types () Tuple of objects to preserve and not convert to a Box object
Expand Down
2 changes: 0 additions & 2 deletions box/from_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ def _to_toml(data):
return Box.from_toml(data)
except TomlDecodeError:
raise BoxError('File is not TOML as expected')
except BoxError:
raise BoxError('Could not convert TOML to Box object') from None


def box_from_file(file: Union[str, Path], file_type: str = None,
Expand Down
34 changes: 34 additions & 0 deletions docs/4.0_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

Box 4.0 has brought a lot of great new features, but also some breaking changes. They are documented here to help you upgrade.

To install the latest 4.x you will need at least Python 3.6 (or current supported python 3.x version)

```shell script
pip install --upgrade python-box>=4
```


If your application is no longer working, and need a quick fix:

```shell script
pip install --upgrade python-box<4
```


## Dot notation access by keys!

Expand All @@ -21,6 +34,27 @@ del my_box['a.b.c.d']

## Adding merge_update as its own function, update now works like the default dictionary update

Traditional update is destructive to nested dictionaries.

```python
from box import Box
box_one = Box(inside_dict={'data': 5})
box_two = Box(inside_dict={'folly': True})
box_one.update(box_two)
repr(box_one)
# <Box: {'inside_dict': {'folly': True}}>
```

Merge update takes existing sub dictionaries into consideration

```python
from box import Box
box_one = Box(inside_dict={'data': 5})
box_two = Box(inside_dict={'folly': True})
box_one.merge_update(box_two)
repr(box_one)
"<Box: {'inside_dict': {'data': 5, 'folly': True}}>"
```


## Support for adding two Boxes together
Expand Down
4 changes: 3 additions & 1 deletion test/data/bad_file.txt
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Nothing good in here
Nothing good in here
# bad data
test/

0 comments on commit 466d440

Please sign in to comment.