MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / guess_format

Function guess_format

src/ifcopenshell-python/ifcopenshell/__init__.py:297–324  ·  view source on GitHub ↗

Guesses the IFC format using file extension IFCs may be serialised as different formats. The most common is a ``.ifc`` file, which is plaintext and stores data using the STEP Physical File format. IFC can also be stored as a Zipfile, XML, JSON, or SQL. This will return the canonica

(path: Path)

Source from the content-addressed store, hash-verified

295
296
297def guess_format(path: Path) -> SupportedFormat:
298 """Guesses the IFC format using file extension
299
300 IFCs may be serialised as different formats. The most common is a ``.ifc``
301 file, which is plaintext and stores data using the STEP Physical File
302 format. IFC can also be stored as a Zipfile, XML, JSON, or SQL.
303
304 This will return the canonical form of the format. For example, if a path
305 has the extension of .xml or .ifcxml (case insensitive), it will return
306 .ifcXML.
307
308 Users generally won't call this function. The :func:`open` function uses
309 this internally to guess the file format.
310 """
311 suffix = path.suffix.lower()
312 if path.is_dir():
313 return "rocksdb"
314 elif suffix == ".ifc":
315 return ".ifc"
316 elif suffix in (".ifczip", ".zip"):
317 return ".ifcZIP"
318 elif suffix in (".ifcxml", ".xml"):
319 return ".ifcXML"
320 elif suffix in (".ifcjson", ".json"):
321 return ".ifcJSON"
322 elif suffix in (".ifcsqlite", ".sqlite", ".db"):
323 return ".ifcSQLite"
324 return None
325
326
327def stream2(path: Union[Path, str], mmap: bool = False, page_size: int = 0):

Callers 1

openFunction · 0.85

Calls 1

lowerMethod · 0.80

Tested by

no test coverage detected