mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 20:00:02 +00:00
typing
This commit is contained in:
@@ -29,6 +29,7 @@ import ifcopenshell
|
|||||||
import bonsai.tool as tool
|
import bonsai.tool as tool
|
||||||
import bonsai.bim.handler
|
import bonsai.bim.handler
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from typing import Union
|
||||||
|
|
||||||
|
|
||||||
class ExecuteIfcTester(bpy.types.Operator):
|
class ExecuteIfcTester(bpy.types.Operator):
|
||||||
@@ -66,7 +67,7 @@ class ExecuteIfcTester(bpy.types.Operator):
|
|||||||
bonsai.bim.handler.refresh_ui_data()
|
bonsai.bim.handler.refresh_ui_data()
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
def execute_tester(self, ifc_data, ifc_path, specs_path):
|
def execute_tester(self, ifc_data: ifcopenshell.file, ifc_path: str, specs_path: str) -> Union[set[str], None]:
|
||||||
props = bpy.context.scene.IfcTesterProperties
|
props = bpy.context.scene.IfcTesterProperties
|
||||||
|
|
||||||
with tempfile.TemporaryDirectory() as dirpath:
|
with tempfile.TemporaryDirectory() as dirpath:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import ifcopenshell.util.selector
|
|||||||
import ifcopenshell.util.element
|
import ifcopenshell.util.element
|
||||||
import ifcopenshell.util.schema
|
import ifcopenshell.util.schema
|
||||||
from statistics import mean
|
from statistics import mean
|
||||||
from typing import Optional, Union, Literal
|
from typing import Optional, Union, Literal, Iterable
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from odf.namespaces import OFFICENS
|
from odf.namespaces import OFFICENS
|
||||||
@@ -65,6 +65,9 @@ FILE_FORMAT = Literal[
|
|||||||
|
|
||||||
|
|
||||||
class IfcCsv:
|
class IfcCsv:
|
||||||
|
attributes: list[str]
|
||||||
|
headers: list[str]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.headers = []
|
self.headers = []
|
||||||
self.results = []
|
self.results = []
|
||||||
@@ -73,9 +76,9 @@ class IfcCsv:
|
|||||||
def export(
|
def export(
|
||||||
self,
|
self,
|
||||||
ifc_file: ifcopenshell.file,
|
ifc_file: ifcopenshell.file,
|
||||||
elements: ifcopenshell.entity_instance,
|
elements: Iterable[ifcopenshell.entity_instance],
|
||||||
attributes,
|
attributes: Union[list[str], None],
|
||||||
headers=None,
|
headers: Optional[list[str]] = None,
|
||||||
output=None,
|
output=None,
|
||||||
format: FILE_FORMAT = None,
|
format: FILE_FORMAT = None,
|
||||||
should_preserve_existing: bool = False,
|
should_preserve_existing: bool = False,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ from functools import reduce
|
|||||||
chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + "_$"
|
chars = string.digits + string.ascii_uppercase + string.ascii_lowercase + "_$"
|
||||||
|
|
||||||
|
|
||||||
def compress(g):
|
def compress(g: str) -> str:
|
||||||
bs = [int(g[i : i + 2], 16) for i in range(0, len(g), 2)]
|
bs = [int(g[i : i + 2], 16) for i in range(0, len(g), 2)]
|
||||||
|
|
||||||
def b64(v, l=4):
|
def b64(v, l=4):
|
||||||
@@ -42,7 +42,7 @@ def compress(g):
|
|||||||
return "".join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)])
|
return "".join([b64(bs[0], 2)] + [b64((bs[i] << 16) + (bs[i + 1] << 8) + bs[i + 2]) for i in range(1, 16, 3)])
|
||||||
|
|
||||||
|
|
||||||
def expand(g):
|
def expand(g: str) -> str:
|
||||||
def b64(v):
|
def b64(v):
|
||||||
return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v))
|
return reduce(lambda a, b: a * 64 + b, map(lambda c: chars.index(c), v))
|
||||||
|
|
||||||
@@ -53,9 +53,9 @@ def expand(g):
|
|||||||
return "".join(["%02x" % b for b in bs])
|
return "".join(["%02x" % b for b in bs])
|
||||||
|
|
||||||
|
|
||||||
def split(g):
|
def split(g: str) -> str:
|
||||||
return "{%s-%s-%s-%s-%s}" % (g[:8], g[8:12], g[12:16], g[16:20], g[20:])
|
return "{%s-%s-%s-%s-%s}" % (g[:8], g[8:12], g[12:16], g[16:20], g[20:])
|
||||||
|
|
||||||
|
|
||||||
def new():
|
def new() -> str:
|
||||||
return compress(uuid.uuid4().hex)
|
return compress(uuid.uuid4().hex)
|
||||||
|
|||||||
@@ -23,15 +23,15 @@ import ifcopenshell.api.pset
|
|||||||
import ifcopenshell.api.geometry
|
import ifcopenshell.api.geometry
|
||||||
import ifcopenshell.util
|
import ifcopenshell.util
|
||||||
import ifcopenshell.util.attribute
|
import ifcopenshell.util.attribute
|
||||||
import ifcopenshell.util.fm
|
|
||||||
import ifcopenshell.util.unit
|
|
||||||
import ifcopenshell.util.element
|
|
||||||
import ifcopenshell.util.placement
|
|
||||||
import ifcopenshell.util.geolocation
|
|
||||||
import ifcopenshell.util.classification
|
import ifcopenshell.util.classification
|
||||||
|
import ifcopenshell.util.element
|
||||||
|
import ifcopenshell.util.fm
|
||||||
|
import ifcopenshell.util.geolocation
|
||||||
|
import ifcopenshell.util.placement
|
||||||
import ifcopenshell.util.schema
|
import ifcopenshell.util.schema
|
||||||
import ifcopenshell.util.shape
|
import ifcopenshell.util.shape
|
||||||
import ifcopenshell.util.system
|
import ifcopenshell.util.system
|
||||||
|
import ifcopenshell.util.unit
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Optional, Any, Union, Iterable
|
from typing import Optional, Any, Union, Iterable
|
||||||
|
|
||||||
|
|||||||
@@ -393,6 +393,7 @@ def validate(f: Union[ifcopenshell.file, str], logger: Logger, express_rules=Fal
|
|||||||
logger.error(f"Unsupported schema: {schema_name}")
|
logger.error(f"Unsupported schema: {schema_name}")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
assert isinstance(f, ifcopenshell.file)
|
||||||
log_internal_cpp_errors(f, filename, logger)
|
log_internal_cpp_errors(f, filename, logger)
|
||||||
|
|
||||||
validate_ifc_header(f, logger)
|
validate_ifc_header(f, logger)
|
||||||
|
|||||||
Reference in New Issue
Block a user