mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
maintain snake in api calls
there were only two methods using camel case for arguments
This commit is contained in:
@@ -67,6 +67,20 @@ def batching_argument_deprecation(
|
||||
return (replace_usecase or usecase_path, settings)
|
||||
|
||||
|
||||
def renamed_arguments_deprecation(
|
||||
usecase_path: str, settings: dict, arguments_remapped: dict[str, str]
|
||||
) -> tuple[str, dict]:
|
||||
for prev_argument, new_argument in arguments_remapped.items():
|
||||
if prev_argument in settings:
|
||||
print(
|
||||
f"WARNING. `{prev_argument}` argument is deprecated for API method "
|
||||
f'"{usecase_path}" and should be replaced with `{new_argument}`.'
|
||||
)
|
||||
settings = settings | {new_argument: settings[prev_argument]}
|
||||
settings.pop(prev_argument)
|
||||
return (usecase_path, settings)
|
||||
|
||||
|
||||
ARGUMENTS_DEPRECATION = {
|
||||
"spatial.assign_container": partial(
|
||||
batching_argument_deprecation, prev_argument="product", new_argument="products"
|
||||
@@ -143,6 +157,10 @@ ARGUMENTS_DEPRECATION = {
|
||||
"project.unassign_declaration": partial(
|
||||
batching_argument_deprecation, prev_argument="definition", new_argument="definitions"
|
||||
),
|
||||
"group.add_group": partial(
|
||||
renamed_arguments_deprecation, arguments_remapped={"Name": "name", "Description": "description"}
|
||||
),
|
||||
"layer.add_layer": partial(renamed_arguments_deprecation, arguments_remapped={"Name": "name"}),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ from typing import Optional
|
||||
|
||||
|
||||
def add_group(
|
||||
file: ifcopenshell.file, Name: str = "Unnamed", Description: Optional[str] = None
|
||||
file: ifcopenshell.file, name: str = "Unnamed", description: Optional[str] = None
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""Adds a new group
|
||||
|
||||
@@ -37,8 +37,8 @@ def add_group(
|
||||
|
||||
:param Name: The name of the group. Defaults to "Unnamed"
|
||||
:type Name: str, optional
|
||||
:param Description: The description of the purpose of the group.
|
||||
:type Description: str, optional
|
||||
:param description: The description of the purpose of the group.
|
||||
:type description: str, optional
|
||||
:return: The newly created IfcGroup
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
@@ -46,11 +46,11 @@ def add_group(
|
||||
|
||||
.. code:: python
|
||||
|
||||
ifcopenshell.api.run("group.add_group", model, Name="Unit 1A")
|
||||
ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
|
||||
"""
|
||||
settings = {
|
||||
"Name": Name or "Unnamed",
|
||||
"Description": Description,
|
||||
"name": name or "Unnamed",
|
||||
"description": description,
|
||||
}
|
||||
|
||||
return file.create_entity(
|
||||
@@ -58,7 +58,7 @@ def add_group(
|
||||
**{
|
||||
"GlobalId": ifcopenshell.guid.new(),
|
||||
"OwnerHistory": ifcopenshell.api.run("owner.create_owner_history", file),
|
||||
"Name": settings["Name"],
|
||||
"Description": settings["Description"],
|
||||
"Name": settings["name"],
|
||||
"Description": settings["description"],
|
||||
}
|
||||
)
|
||||
|
||||
@@ -42,7 +42,7 @@ def assign_group(
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, Name="Furniture")
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
|
||||
ifcopenshell.api.run("group.assign_group", model,
|
||||
products=model.by_type("IfcFurniture"), group=group)
|
||||
"""
|
||||
|
||||
@@ -36,7 +36,7 @@ def edit_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance, att
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, Name="Unit 1A")
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
|
||||
ifcopenshell.api.run("group.edit_group", model,
|
||||
group=group, attributes={"Description": "All furniture and joinery included in the unit"})
|
||||
"""
|
||||
|
||||
@@ -36,7 +36,7 @@ def remove_group(file: ifcopenshell.file, group: ifcopenshell.entity_instance) -
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, Name="Unit 1A")
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Unit 1A")
|
||||
ifcopenshell.api.run("group.remove_group", model, group=group)
|
||||
"""
|
||||
settings = {"group": group}
|
||||
|
||||
@@ -39,7 +39,7 @@ def unassign_group(
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, Name="Furniture")
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
|
||||
furniture = model.by_type("IfcFurniture")
|
||||
ifcopenshell.api.run("group.assign_group", model, products=furniture, group=group)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ def update_group_products(
|
||||
|
||||
.. code:: python
|
||||
|
||||
group = ifcopenshell.api.run("group.add_group", model, Name="Furniture")
|
||||
group = ifcopenshell.api.run("group.add_group", model, name="Furniture")
|
||||
ifcopenshell.api.run("group.update_group_products", model,
|
||||
products=model.by_type("IfcFurniture"), group=group)
|
||||
"""
|
||||
|
||||
@@ -19,7 +19,7 @@ import ifcopenshell
|
||||
from typing import Optional
|
||||
|
||||
|
||||
def add_layer(file: ifcopenshell.file, Name: Optional[str] = None) -> ifcopenshell.entity_instance:
|
||||
def add_layer(file: ifcopenshell.file, name: str = "Unnamed") -> ifcopenshell.entity_instance:
|
||||
"""Adds a new layer
|
||||
|
||||
An IFC layer is like a CAD layer. Portions of an object's geometry
|
||||
@@ -34,13 +34,13 @@ def add_layer(file: ifcopenshell.file, Name: Optional[str] = None) -> ifcopenshe
|
||||
Some software that are still based on layers, such as Tekla or ArchiCAD
|
||||
may also use this layer information for filtering.
|
||||
|
||||
:param Name: The name of the layer. Defaults to "Unnamed".
|
||||
:type Name: str, optional
|
||||
:param name: The name of the layer. Defaults to "Unnamed".
|
||||
:type name: str, optional
|
||||
:return: The newly created IfcPresentationLayerAssignment element
|
||||
:rtype: ifcopenshell.entity_instance
|
||||
|
||||
Example:
|
||||
|
||||
ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL-FULL-DIMS-N")
|
||||
ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL-FULL-DIMS-N")
|
||||
"""
|
||||
return file.create_entity("IfcPresentationLayerAssignment", Name=Name or "Unnamed")
|
||||
return file.create_entity("IfcPresentationLayerAssignment", Name=name)
|
||||
|
||||
@@ -59,7 +59,7 @@ def assign_layer(
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
|
||||
|
||||
# Now let's create a layer that contains walls
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
|
||||
|
||||
# And assign our wall representation item (in this example, there is
|
||||
# only one item) to the layer.
|
||||
|
||||
@@ -36,7 +36,7 @@ def edit_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance, att
|
||||
|
||||
.. code:: python
|
||||
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
|
||||
ifcopenshell.api.run("layer.edit_layer", model,
|
||||
layer=layer, attributes={"Description": "All walls, based on the AIA standard."})
|
||||
"""
|
||||
|
||||
@@ -33,7 +33,7 @@ def remove_layer(file: ifcopenshell.file, layer: ifcopenshell.entity_instance) -
|
||||
|
||||
.. code:: python
|
||||
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
|
||||
ifcopenshell.api.run("layer.remove_layer", model, layer=layer)
|
||||
"""
|
||||
file.remove(layer)
|
||||
|
||||
@@ -56,7 +56,7 @@ def unassign_layer(
|
||||
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
|
||||
|
||||
# Now let's create a layer that contains walls
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
|
||||
layer = ifcopenshell.api.run("layer.add_layer", model, name="AI-WALL")
|
||||
|
||||
# And assign our wall representation item (in this example, there is
|
||||
# only one item) to the layer.
|
||||
|
||||
Reference in New Issue
Block a user