mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 14:41:25 +00:00
file.ctor: use swig shadowing
This commit is contained in:
@@ -898,7 +898,7 @@ class file_mixin:
|
|||||||
def _determine_schema_identifier(
|
def _determine_schema_identifier(
|
||||||
schema: Optional[ifcopenshell.util.schema.IFC_SCHEMA] = None,
|
schema: Optional[ifcopenshell.util.schema.IFC_SCHEMA] = None,
|
||||||
schema_version: Optional[tuple[int, int, int, int]] = None,
|
schema_version: Optional[tuple[int, int, int, int]] = None,
|
||||||
):
|
) -> str:
|
||||||
if schema_version:
|
if schema_version:
|
||||||
prefixes = ("IFC", "X", "_ADD", "_TC")
|
prefixes = ("IFC", "X", "_ADD", "_TC")
|
||||||
schema = "".join("".join(map(str, t)) if t[1] else "" for t in zip(prefixes, schema_version))
|
schema = "".join("".join(map(str, t)) if t[1] else "" for t in zip(prefixes, schema_version))
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ from typing import Any, Literal, Sequence, Union
|
|||||||
from typing_extensions import Self
|
from typing_extensions import Self
|
||||||
|
|
||||||
import ifcopenshell
|
import ifcopenshell
|
||||||
|
import ifcopenshell.util.schema
|
||||||
from ifcopenshell.entity_instance import entity_instance_mixin
|
from ifcopenshell.entity_instance import entity_instance_mixin
|
||||||
from ifcopenshell.file import file_mixin
|
from ifcopenshell.file import file_mixin
|
||||||
|
|
||||||
@@ -830,7 +831,12 @@ class face:
|
|||||||
|
|
||||||
class file(file_mixin):
|
class file(file_mixin):
|
||||||
def fresh_id(self) -> int: ...
|
def fresh_id(self) -> int: ...
|
||||||
def __init__(self, *args): ...
|
def __init__(
|
||||||
|
self,
|
||||||
|
schema: ifcopenshell.util.schema.IFC_SCHEMA | None = None,
|
||||||
|
schema_identifier: str | None = None,
|
||||||
|
schema_version: tuple[int, int, int, int] | None = None,
|
||||||
|
): ...
|
||||||
def _add(self, entity: entity_instance, id: int = -1) -> entity_instance: ...
|
def _add(self, entity: entity_instance, id: int = -1) -> entity_instance: ...
|
||||||
def add_type_ref(self, new_entity): ...
|
def add_type_ref(self, new_entity): ...
|
||||||
def batch(self) -> None:
|
def batch(self) -> None:
|
||||||
|
|||||||
@@ -38,6 +38,16 @@
|
|||||||
%ignore ifcopenshell::file::byref_excl_;
|
%ignore ifcopenshell::file::byref_excl_;
|
||||||
%ignore ifcopenshell::file::types_to_bypass_loading_;
|
%ignore ifcopenshell::file::types_to_bypass_loading_;
|
||||||
|
|
||||||
|
// Replaces the raw multi-overload ctor with a friendlier keyword-based signature.
|
||||||
|
%feature("shadow") ifcopenshell::file::file %{
|
||||||
|
def __init__(self, schema=None, schema_identifier=None, schema_version=None):
|
||||||
|
if schema_identifier is not None:
|
||||||
|
identifier = schema_identifier
|
||||||
|
else:
|
||||||
|
identifier = self._determine_schema_identifier(schema=schema, schema_version=schema_version)
|
||||||
|
$action(self, identifier)
|
||||||
|
%}
|
||||||
|
|
||||||
%ignore ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>>::read_instance;
|
%ignore ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>>::read_instance;
|
||||||
%ignore ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>>::steal_instances;
|
%ignore ifcopenshell::instance_streamer<ifcopenshell::file_reader<ifcopenshell::full_buffer_impl>>::steal_instances;
|
||||||
|
|
||||||
@@ -392,10 +402,6 @@ private:
|
|||||||
header = property(header)
|
header = property(header)
|
||||||
_registry = {}
|
_registry = {}
|
||||||
|
|
||||||
_old_init = __init__
|
|
||||||
def __init__(self, schema=None, schema_identifier=None, schema_version=None):
|
|
||||||
self._old_init(schema_identifier if schema_identifier else self._determine_schema_identifier(schema=schema, schema_version=schema_version))
|
|
||||||
|
|
||||||
def __setattr__(self, k, v):
|
def __setattr__(self, k, v):
|
||||||
object.__setattr__(self, k, v)
|
object.__setattr__(self, k, v)
|
||||||
if k == 'this':
|
if k == 'this':
|
||||||
|
|||||||
Reference in New Issue
Block a user