mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 22:11:36 +00:00
Valid template header default (#6610)
* Valid template header default * consistent version in tempalte file * schema-dependent mvd
This commit is contained in:
@@ -30,7 +30,7 @@ from typing import Optional
|
|||||||
# http://academy.ifcopenshell.org/creating-a-simple-wall-with-property-set-and-quantity-information/
|
# http://academy.ifcopenshell.org/creating-a-simple-wall-with-property-set-and-quantity-information/
|
||||||
TEMPLATE = """ISO-10303-21;
|
TEMPLATE = """ISO-10303-21;
|
||||||
HEADER;
|
HEADER;
|
||||||
FILE_DESCRIPTION(('ViewDefinition [CoordinationView]'),'2;1');
|
FILE_DESCRIPTION(('ViewDefinition [%(mvd)s]'),'2;1');
|
||||||
FILE_NAME('%(filename)s','%(timestring)s',('%(creator)s'),('%(organization)s'),'%(application)s','%(application)s','');
|
FILE_NAME('%(filename)s','%(timestring)s',('%(creator)s'),('%(organization)s'),'%(application)s','%(application)s','');
|
||||||
FILE_SCHEMA(('%(schema_identifier)s'));
|
FILE_SCHEMA(('%(schema_identifier)s'));
|
||||||
ENDSEC;
|
ENDSEC;
|
||||||
@@ -60,14 +60,26 @@ END-ISO-10303-21;
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
DEFAULTS = {
|
DEFAULTS = {
|
||||||
"application": lambda d: "IfcOpenShell-%s" % version(),
|
"application": lambda d: "IfcOpenShell contributors - IfcOpenShell - v%s" % get_pep440_version(version()),
|
||||||
"application_version": lambda d: version(),
|
"application_version": lambda d: get_pep440_version(version()),
|
||||||
"project_globalid": lambda d: compress(uuid.uuid4().hex),
|
"project_globalid": lambda d: compress(uuid.uuid4().hex),
|
||||||
"schema_identifier": lambda d: "IFC4",
|
"schema_identifier": lambda d: "IFC4",
|
||||||
"timestamp": lambda d: int(time.time()),
|
"timestamp": lambda d: int(time.time()),
|
||||||
"timestring": lambda d: time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(d.get("timestamp") or time.time())),
|
"timestring": lambda d: time.strftime("%Y-%m-%dT%H:%M:%S", time.gmtime(d.get("timestamp") or time.time())),
|
||||||
|
"mvd": lambda d: (
|
||||||
|
"ReferenceView_V1.2" if d.get("schema_identifier") == "IFC4"
|
||||||
|
else "CoordinationView_V2.0" if d.get("schema_identifier") == "IFC2X3"
|
||||||
|
else "ReferenceView" if d.get("schema_identifier") == "IFC4X3_ADD2"
|
||||||
|
else "ReferenceView_V1.2"
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_pep440_version(ifcopenshell_wrapper_version):
|
||||||
|
"""
|
||||||
|
Returns a PEP 440-compliant version string, valid for use with
|
||||||
|
`packaging.version.parse()` and compliant with the Validation Service header policy.
|
||||||
|
"""
|
||||||
|
return ifcopenshell_wrapper_version.replace("-", "+", 1)
|
||||||
|
|
||||||
def create(
|
def create(
|
||||||
filename: Optional[str] = None,
|
filename: Optional[str] = None,
|
||||||
@@ -80,6 +92,7 @@ def create(
|
|||||||
application: Optional[str] = None,
|
application: Optional[str] = None,
|
||||||
project_globalid: Optional[str] = None,
|
project_globalid: Optional[str] = None,
|
||||||
project_name: Optional[str] = None,
|
project_name: Optional[str] = None,
|
||||||
|
mvd: Optional[str] = None
|
||||||
) -> file:
|
) -> file:
|
||||||
d = dict(locals())
|
d = dict(locals())
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user