authorisation -> authorization in header schema for compatibility

This commit is contained in:
Thomas Krijnen
2025-08-29 16:06:24 +02:00
parent 93c2a4fe66
commit dfaa8d510c
11 changed files with 34 additions and 29 deletions
@@ -51,12 +51,12 @@ def create_file(version: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4") -> ifcope
# ... and off we go!
"""
file = ifcopenshell.file(schema=version)
file.wrapped_data.header.file_name.name = "/dev/null" # Hehehe
file.wrapped_data.header.file_name.time_stamp = (
file.header.file_name.name = "/dev/null" # Hehehe
file.header.file_name.time_stamp = (
datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).astimezone().replace(microsecond=0).isoformat()
)
file.wrapped_data.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
file.wrapped_data.header.file_name.originating_system = "IfcOpenShell {}".format(ifcopenshell.version)
file.wrapped_data.header.file_name.authorization = "Nobody"
file.wrapped_data.header.file_description.description = ("ViewDefinition[DesignTransferView]",)
file.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
file.header.file_name.originating_system = "IfcOpenShell {}".format(ifcopenshell.version)
file.header.file_name.authorization = "Nobody"
file.header.file_description.description = ("ViewDefinition[DesignTransferView]",)
return file
@@ -793,3 +793,9 @@ class file:
def to_string(self) -> str:
return self.wrapped_data.to_string()
@property
def header(self):
h = self.wrapped_data.header()
object.__setattr__(h, "file_ref", lambda inst: entity_instance.wrap_value(inst, file=self))
return h
@@ -26,9 +26,9 @@ class TestCreateFile(test.bootstrap.IFC4):
assert ifc.schema == "IFC4"
ifc = ifcopenshell.api.project.create_file(version="IFC2X3")
assert ifc.schema == "IFC2X3"
assert ifc.wrapped_data.header.file_name.name == "/dev/null"
assert ifc.wrapped_data.header.file_name.time_stamp
assert "IfcOpenShell" in ifc.wrapped_data.header.file_name.preprocessor_version
assert "IfcOpenShell" in ifc.wrapped_data.header.file_name.originating_system
assert ifc.wrapped_data.header.file_name.authorization == "Nobody"
assert ifc.wrapped_data.header.file_description.description == ("ViewDefinition[DesignTransferView]",)
assert ifc.header.file_name.name == "/dev/null"
assert ifc.header.file_name.time_stamp
assert "IfcOpenShell" in ifc.header.file_name.preprocessor_version
assert "IfcOpenShell" in ifc.header.file_name.originating_system
assert ifc.header.file_name.authorization == "Nobody"
assert ifc.header.file_description.description == ("ViewDefinition[DesignTransferView]",)
+1 -1
View File
@@ -111,7 +111,7 @@ def test_bug_2486_a():
def test_bug_2486_b():
file = ifcopenshell.template.create()
file.wrapped_data.header.file_name.name = "myfile.ifc"
file.header.file_name.name = "myfile.ifc"
if __name__ == "__main__":
@@ -24,7 +24,7 @@ class HEADER_SECTION_SCHEMA_instance_factory : public IfcParse::instance_factory
IfcParse::schema_definition* HEADER_SECTION_SCHEMA_populate_schema() {
const std::string strings[] = {"schema_name"s,"time_stamp_text"s,"file_description"s,"file_name"s,"file_schema"s,"description"s,"implementation_level"s,"name"s,"time_stamp"s,"author"s,"organization"s,"preprocessor_version"s,"originating_system"s,"authorisation"s,"schema_identifiers"s,"HEADER_SECTION_SCHEMA"s};
const std::string strings[] = {"schema_name"s,"time_stamp_text"s,"file_description"s,"file_name"s,"file_schema"s,"description"s,"implementation_level"s,"name"s,"time_stamp"s,"author"s,"organization"s,"preprocessor_version"s,"originating_system"s,"authorization"s,"schema_identifiers"s,"HEADER_SECTION_SCHEMA"s};
HEADER_SECTION_SCHEMA_types[3] = new type_declaration(strings[0], 3, new simple_type(simple_type::string_type));
HEADER_SECTION_SCHEMA_types[4] = new type_declaration(strings[1], 4, new simple_type(simple_type::string_type));
+3 -3
View File
@@ -55,14 +55,14 @@ std::string Header_section_schema::file_name::preprocessor_version() const { st
void Header_section_schema::file_name::setpreprocessor_version(std::string v) { set_attribute_value(4, v);if constexpr (false)unset_attribute_value(4); }
std::string Header_section_schema::file_name::originating_system() const { std::string v = get_attribute_value(5); return v; }
void Header_section_schema::file_name::setoriginating_system(std::string v) { set_attribute_value(5, v);if constexpr (false)unset_attribute_value(5); }
std::string Header_section_schema::file_name::authorisation() const { std::string v = get_attribute_value(6); return v; }
void Header_section_schema::file_name::setauthorisation(std::string v) { set_attribute_value(6, v);if constexpr (false)unset_attribute_value(6); }
std::string Header_section_schema::file_name::authorization() const { std::string v = get_attribute_value(6); return v; }
void Header_section_schema::file_name::setauthorization(std::string v) { set_attribute_value(6, v);if constexpr (false)unset_attribute_value(6); }
const IfcParse::entity& Header_section_schema::file_name::declaration() const { return *((IfcParse::entity*)HEADER_SECTION_SCHEMA_types[1]); }
const IfcParse::entity& Header_section_schema::file_name::Class() { return *((IfcParse::entity*)HEADER_SECTION_SCHEMA_types[1]); }
Header_section_schema::file_name::file_name(IfcEntityInstanceData&& e) : IfcUtil::IfcBaseEntity(std::move(e)) { }
Header_section_schema::file_name::file_name(std::string v1_name, std::string v2_time_stamp, std::vector< std::string > /*[1:?]*/ v3_author, std::vector< std::string > /*[1:?]*/ v4_organization, std::string v5_preprocessor_version, std::string v6_originating_system, std::string v7_authorisation) : IfcUtil::IfcBaseEntity(IfcEntityInstanceData(in_memory_attribute_storage(7))) { set_attribute_value(0, (v1_name));set_attribute_value(1, (v2_time_stamp));set_attribute_value(2, (v3_author));set_attribute_value(3, (v4_organization));set_attribute_value(4, (v5_preprocessor_version));set_attribute_value(5, (v6_originating_system));set_attribute_value(6, (v7_authorisation));; populate_derived(); }
Header_section_schema::file_name::file_name(std::string v1_name, std::string v2_time_stamp, std::vector< std::string > /*[1:?]*/ v3_author, std::vector< std::string > /*[1:?]*/ v4_organization, std::string v5_preprocessor_version, std::string v6_originating_system, std::string v7_authorization) : IfcUtil::IfcBaseEntity(IfcEntityInstanceData(in_memory_attribute_storage(7))) { set_attribute_value(0, (v1_name));set_attribute_value(1, (v2_time_stamp));set_attribute_value(2, (v3_author));set_attribute_value(3, (v4_organization));set_attribute_value(4, (v5_preprocessor_version));set_attribute_value(5, (v6_originating_system));set_attribute_value(6, (v7_authorization));; populate_derived(); }
// Function implementations for file_schema
std::vector< std::string > /*[1:?]*/ Header_section_schema::file_schema::schema_identifiers() const { std::vector< std::string > /*[1:?]*/ v = get_attribute_value(0); return v; }
+3 -3
View File
@@ -74,12 +74,12 @@ public:
void setpreprocessor_version(std::string v);
std::string originating_system() const;
void setoriginating_system(std::string v);
std::string authorisation() const;
void setauthorisation(std::string v);
std::string authorization() const;
void setauthorization(std::string v);
virtual const IfcParse::entity& declaration() const;
static const IfcParse::entity& Class();
file_name (IfcEntityInstanceData&& e);
file_name (std::string v1_name, std::string v2_time_stamp, std::vector< std::string > /*[1:?]*/ v3_author, std::vector< std::string > /*[1:?]*/ v4_organization, std::string v5_preprocessor_version, std::string v6_originating_system, std::string v7_authorisation);
file_name (std::string v1_name, std::string v2_time_stamp, std::vector< std::string > /*[1:?]*/ v3_author, std::vector< std::string > /*[1:?]*/ v4_organization, std::string v5_preprocessor_version, std::string v6_originating_system, std::string v7_authorization);
typedef aggregate_of< file_name > list;
};
+1 -1
View File
@@ -2590,7 +2590,7 @@ void IfcFile::setDefaultHeaderValues() {
header().file_name()->setorganization(string_vector);
header().file_name()->setpreprocessor_version("IfcOpenShell " IFCOPENSHELL_VERSION);
header().file_name()->setoriginating_system("IfcOpenShell " IFCOPENSHELL_VERSION);
header().file_name()->setauthorisation(empty_string);
header().file_name()->setauthorization(empty_string);
header().file_schema()->setschema_identifiers(schema_identifiers);
}
+1 -1
View File
@@ -344,7 +344,7 @@ static void process_characters(void* user, const xmlChar* character, int len) {
} else if (tagname == "originating_system") {
header.file_name()->setoriginating_system(txt);
} else if (tagname == "authorization") {
header.file_name()->setauthorisation(txt);
header.file_name()->setauthorization(txt);
} else if (tagname == "documentation") {
header.file_description()->setdescription({txt});
} else {
+5 -6
View File
@@ -229,9 +229,7 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
}
%pythoncode %{
# Hide the getters with read-only property implementations
header = property(header)
schema = property(schema_name)
schema = property(schema_name)
%}
}
@@ -587,9 +585,10 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
%pythoncode %{
# Hide the getters with read-only property implementations
file_description = property(file_description_py)
file_name = property(file_name_py)
file_schema = property(file_schema_py)
# self.file_ref is set in ifcopenshell.file.header()
file_description = property(lambda self: self.file_ref(self.file_description_py()))
file_name = property(lambda self: self.file_ref(self.file_name_py()))
file_schema = property(lambda self: self.file_ref(self.file_schema_py()))
%}
};
@@ -624,7 +624,7 @@ void POSTFIX_SCHEMA(XmlSerializer)::finalize() {
}
try {
// @nb inconsistent spelling
header.put("file_name.authorization", file->header().file_name()->authorisation());
header.put("file_name.authorization", file->header().file_name()->authorization());
}
catch (const IfcParse::IfcException& ex) {
std::stringstream ss;