Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into 2.0
  • Loading branch information
redruin1 committed Jan 2, 2025
2 parents 54bbf2d + 27a38ab commit a27ce7c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
8 changes: 4 additions & 4 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@
* Renamed `data` member to `_root` member on `EntityList` and `TileList` (Internal reasons)
* Fixed issue #119

## 1.1.1
* Updated factorio-data to version 1.1.103
# 1.1.1
* Updated `factorio-data` to version `1.1.103`
* Merged RosieBaish's pull request:
* Added an extend() function to EntityList along with notes about it's performance
* Added an `extend()` function to `EntityList` along with notes about it's performance
* Fixed issue #101 (finally)

## 1.1.0
# 1.1.1
* Added a number of missing prototype objects that are blueprintable:
* `SimpleEntityWithOwner`
* `SimpleEntityWithForce`
Expand Down
26 changes: 26 additions & 0 deletions draftsman/classes/entity_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,32 @@ def append(
"""
return self.insert(idx=len(self), name=name, copy=copy, merge=merge, **kwargs)

@utils.reissue_warnings
def extend(self, entities, copy=True, merge=False):
# type: (List[Union[str, EntityLike]], bool, bool) -> None
"""
Extends this list with the list provided. Computationally the same
as appending one element at a time.
:param copy: Whether or not to insert a copy of each element.
:param merge: Whether or not to merge each element, if possible.
:example:
.. code-block :: python
blueprint = Blueprint()
assert isinstance(blueprint.entities, EntityList)
# Append Entity instance
blueprint.entities.extend([Container("steel-chest"), Container("wooden-chest", tile_position=(1, 1)])
assert blueprint.entities[-2].name == "steel-chest"
assert blueprint.entities[-1].name == "wooden-chest"
assert blueprint.entities[-1].tile_position == {"x": 1, "y": 1}
"""
for entity in entities:
self.append(entity, copy=copy, merge=merge)

@reissue_warnings
def insert(
self,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ def package_files(*directories):
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License"
]
)
)

0 comments on commit a27ce7c

Please sign in to comment.