Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ $ pip install git+https://github.com/networktocode/diffsync.git@main
# Contributing
Pull requests are welcomed and automatically built and tested against multiple versions of Python through GitHub Actions.

The project is following Network to Code software development guidelines and are leveraging the following:
The project is following Network to Code software development guidelines and is leveraging the following:

- Black, Pylint, Bandit, flake8, and pydocstyle, mypy for Python linting, formatting and type hint checking.
- pytest, coverage, and unittest for unit tests.
Expand Down
2 changes: 1 addition & 1 deletion diffsync/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
class DiffSyncModel(BaseModel):
"""Base class for all DiffSync object models.

Note that read-only APIs of this class are implemented as `get_*()` functions rather than as properties;
Note that read-only APIs of this class are implemented as `get_*()` methods rather than as properties;
this is intentional as specific model classes may want to use these names (`type`, `keys`, `attrs`, etc.)
as model attributes and we want to avoid any ambiguity or collisions.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/core_engine/02-customize-diff-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ To use your own diff class, you need to provide it at runtime when calling one o
<class 'AlphabeticalOrderDiff'>
```

## Change the order in which the element are being processed
## Change the order in which the elements are being processed

By default, all objects of the same type will be stored in a dictionary and as such the order in which they will be processed during a diff or a sync operation is not guaranteed (although in most cases, it will match the order in which they were initially loaded and added to the adapter). When the order in which a given group of object should be processed is important, it's possible to define your own ordering inside a custom Diff class.
By default, all objects of the same type will be stored in a dictionary and as such the order in which they will be processed during a diff or a sync operation is not guaranteed (although in most cases, it will match the order in which they were initially loaded and added to the adapter). When the order in which a given group of objects should be processed is important, it's possible to define your own ordering inside a custom Diff class.

When iterating over a list of objects, either at the top level or as a group of children of a given object, the core engine is looking for a function named after the type of the object `order_children_<type>` and if none is found it will rely on the default function `order_children_default`. Either function need to be present and need to return an Iterator of DiffElement.

Expand Down
4 changes: 2 additions & 2 deletions docs/source/getting_started/01-getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Nautobot(Adapter):

```

Would result in processing in the following order for each element until there is no elements left:
Would result in processing in the following order for each element until there are no elements left:

- site
- vlan
Expand Down Expand Up @@ -145,7 +145,7 @@ NetworkImporterAdapter
>>>
```

# Store data in a `Adapter` object
# Store data in an `Adapter` object

To add a site to the local cache/store, you need to pass a valid `DiffSyncModel` object to the `add()` function.

Expand Down
6 changes: 3 additions & 3 deletions examples/03-remote-system/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ This is a simple example to show how DiffSync can be used to compare and synchro
For this example, we have a shared model for Region and Country defined in `models.py`.
A country must be part of a region and has an attribute to capture its population.

The comparison and synchronization of dataset is done between a local JSON file and the [public instance of Nautobot](https://demo.nautobot.com).
The comparison and synchronization of datasets is done between a local JSON file and the [public instance of Nautobot](https://demo.nautobot.com).

Also, this example is showing :
- How to set a Global Flags to ignore object that are not matching
- How to provide a custom Diff class to change the ordering of a group of object
- How to set Global Flags to ignore objects that are not matching
- How to provide a custom Diff class to change the ordering of a group of objects

> The source code for this example is in Github in the [examples/03-remote-system/](https://github.com/networktocode/diffsync/tree/main/examples/03-remote-system) directory.

Expand Down
2 changes: 1 addition & 1 deletion examples/05-nautobot-peeringdb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Context

The goal of this example is to synchronize some data from [PeeringDB](https://www.peeringdb.com/), that as the name suggests is a DB where peering entities define their facilities and presence to facilitate peering, towards [Nautobot Demo](https://demo.nautobot.com/) that is a always on demo service for [Nautobot](https://nautobot.readthedocs.io/), an open source Source of Truth.
The goal of this example is to synchronize some data from [PeeringDB](https://www.peeringdb.com/), as the name suggests that is a DB where peering entities define their facilities and presence to facilitate peering, towards [Nautobot Demo](https://demo.nautobot.com/) that is an always on demo service for [Nautobot](https://nautobot.readthedocs.io/), an open source Source of Truth.

In Peering DB there is a model that defines a `Facility` and you can get information about the actual data center and the city where it is placed. In Nautobot, this information could be mapped to the `Region` and `Site` models, where `Region` can depend from other `Region` and also contain `Site` as children. For instance, Barcelona is in Spain and Spain is in Europe, and all of them are `Regions`. And, finally, the actual datacenter will refer to the `Region` where it is placed.

Expand Down