Skip to content

Commit dfaa8d5

Browse files
committed
authorisation -> authorization in header schema for compatibility
1 parent 93c2a4f commit dfaa8d5

11 files changed

Lines changed: 34 additions & 29 deletions

File tree

src/ifcopenshell-python/ifcopenshell/api/project/create_file.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ def create_file(version: ifcopenshell.util.schema.IFC_SCHEMA = "IFC4") -> ifcope
5151
# ... and off we go!
5252
"""
5353
file = ifcopenshell.file(schema=version)
54-
file.wrapped_data.header.file_name.name = "/dev/null" # Hehehe
55-
file.wrapped_data.header.file_name.time_stamp = (
54+
file.header.file_name.name = "/dev/null" # Hehehe
55+
file.header.file_name.time_stamp = (
5656
datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).astimezone().replace(microsecond=0).isoformat()
5757
)
58-
file.wrapped_data.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
59-
file.wrapped_data.header.file_name.originating_system = "IfcOpenShell {}".format(ifcopenshell.version)
60-
file.wrapped_data.header.file_name.authorization = "Nobody"
61-
file.wrapped_data.header.file_description.description = ("ViewDefinition[DesignTransferView]",)
58+
file.header.file_name.preprocessor_version = "IfcOpenShell {}".format(ifcopenshell.version)
59+
file.header.file_name.originating_system = "IfcOpenShell {}".format(ifcopenshell.version)
60+
file.header.file_name.authorization = "Nobody"
61+
file.header.file_description.description = ("ViewDefinition[DesignTransferView]",)
6262
return file

src/ifcopenshell-python/ifcopenshell/file.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,3 +793,9 @@ def from_pointer(address: int) -> file:
793793

794794
def to_string(self) -> str:
795795
return self.wrapped_data.to_string()
796+
797+
@property
798+
def header(self):
799+
h = self.wrapped_data.header()
800+
object.__setattr__(h, "file_ref", lambda inst: entity_instance.wrap_value(inst, file=self))
801+
return h

src/ifcopenshell-python/test/api/project/test_create_file.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def test_run(self):
2626
assert ifc.schema == "IFC4"
2727
ifc = ifcopenshell.api.project.create_file(version="IFC2X3")
2828
assert ifc.schema == "IFC2X3"
29-
assert ifc.wrapped_data.header.file_name.name == "/dev/null"
30-
assert ifc.wrapped_data.header.file_name.time_stamp
31-
assert "IfcOpenShell" in ifc.wrapped_data.header.file_name.preprocessor_version
32-
assert "IfcOpenShell" in ifc.wrapped_data.header.file_name.originating_system
33-
assert ifc.wrapped_data.header.file_name.authorization == "Nobody"
34-
assert ifc.wrapped_data.header.file_description.description == ("ViewDefinition[DesignTransferView]",)
29+
assert ifc.header.file_name.name == "/dev/null"
30+
assert ifc.header.file_name.time_stamp
31+
assert "IfcOpenShell" in ifc.header.file_name.preprocessor_version
32+
assert "IfcOpenShell" in ifc.header.file_name.originating_system
33+
assert ifc.header.file_name.authorization == "Nobody"
34+
assert ifc.header.file_description.description == ("ViewDefinition[DesignTransferView]",)

src/ifcopenshell-python/test/file_gc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def test_bug_2486_a():
111111

112112
def test_bug_2486_b():
113113
file = ifcopenshell.template.create()
114-
file.wrapped_data.header.file_name.name = "myfile.ifc"
114+
file.header.file_name.name = "myfile.ifc"
115115

116116

117117
if __name__ == "__main__":

src/ifcparse/Header_section_schema-schema.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class HEADER_SECTION_SCHEMA_instance_factory : public IfcParse::instance_factory
2424

2525
IfcParse::schema_definition* HEADER_SECTION_SCHEMA_populate_schema() {
2626

27-
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};
27+
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};
2828

2929
HEADER_SECTION_SCHEMA_types[3] = new type_declaration(strings[0], 3, new simple_type(simple_type::string_type));
3030
HEADER_SECTION_SCHEMA_types[4] = new type_declaration(strings[1], 4, new simple_type(simple_type::string_type));

src/ifcparse/Header_section_schema.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,14 @@ std::string Header_section_schema::file_name::preprocessor_version() const { st
5555
void Header_section_schema::file_name::setpreprocessor_version(std::string v) { set_attribute_value(4, v);if constexpr (false)unset_attribute_value(4); }
5656
std::string Header_section_schema::file_name::originating_system() const { std::string v = get_attribute_value(5); return v; }
5757
void Header_section_schema::file_name::setoriginating_system(std::string v) { set_attribute_value(5, v);if constexpr (false)unset_attribute_value(5); }
58-
std::string Header_section_schema::file_name::authorisation() const { std::string v = get_attribute_value(6); return v; }
59-
void Header_section_schema::file_name::setauthorisation(std::string v) { set_attribute_value(6, v);if constexpr (false)unset_attribute_value(6); }
58+
std::string Header_section_schema::file_name::authorization() const { std::string v = get_attribute_value(6); return v; }
59+
void Header_section_schema::file_name::setauthorization(std::string v) { set_attribute_value(6, v);if constexpr (false)unset_attribute_value(6); }
6060

6161

6262
const IfcParse::entity& Header_section_schema::file_name::declaration() const { return *((IfcParse::entity*)HEADER_SECTION_SCHEMA_types[1]); }
6363
const IfcParse::entity& Header_section_schema::file_name::Class() { return *((IfcParse::entity*)HEADER_SECTION_SCHEMA_types[1]); }
6464
Header_section_schema::file_name::file_name(IfcEntityInstanceData&& e) : IfcUtil::IfcBaseEntity(std::move(e)) { }
65-
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(); }
65+
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(); }
6666

6767
// Function implementations for file_schema
6868
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; }

src/ifcparse/Header_section_schema.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ class IFC_PARSE_API file_name : public IfcUtil::IfcBaseEntity {
7474
void setpreprocessor_version(std::string v);
7575
std::string originating_system() const;
7676
void setoriginating_system(std::string v);
77-
std::string authorisation() const;
78-
void setauthorisation(std::string v);
77+
std::string authorization() const;
78+
void setauthorization(std::string v);
7979
virtual const IfcParse::entity& declaration() const;
8080
static const IfcParse::entity& Class();
8181
file_name (IfcEntityInstanceData&& e);
82-
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);
82+
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);
8383
typedef aggregate_of< file_name > list;
8484
};
8585

src/ifcparse/IfcParse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,7 @@ void IfcFile::setDefaultHeaderValues() {
25902590
header().file_name()->setorganization(string_vector);
25912591
header().file_name()->setpreprocessor_version("IfcOpenShell " IFCOPENSHELL_VERSION);
25922592
header().file_name()->setoriginating_system("IfcOpenShell " IFCOPENSHELL_VERSION);
2593-
header().file_name()->setauthorisation(empty_string);
2593+
header().file_name()->setauthorization(empty_string);
25942594

25952595
header().file_schema()->setschema_identifiers(schema_identifiers);
25962596
}

src/ifcparse/parse_ifcxml.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static void process_characters(void* user, const xmlChar* character, int len) {
344344
} else if (tagname == "originating_system") {
345345
header.file_name()->setoriginating_system(txt);
346346
} else if (tagname == "authorization") {
347-
header.file_name()->setauthorisation(txt);
347+
header.file_name()->setauthorization(txt);
348348
} else if (tagname == "documentation") {
349349
header.file_description()->setdescription({txt});
350350
} else {

src/ifcwrap/IfcParseWrapper.i

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,7 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
229229
}
230230

231231
%pythoncode %{
232-
# Hide the getters with read-only property implementations
233-
header = property(header)
234-
schema = property(schema_name)
232+
schema = property(schema_name)
235233
%}
236234
}
237235

@@ -587,9 +585,10 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas
587585

588586
%pythoncode %{
589587
# Hide the getters with read-only property implementations
590-
file_description = property(file_description_py)
591-
file_name = property(file_name_py)
592-
file_schema = property(file_schema_py)
588+
# self.file_ref is set in ifcopenshell.file.header()
589+
file_description = property(lambda self: self.file_ref(self.file_description_py()))
590+
file_name = property(lambda self: self.file_ref(self.file_name_py()))
591+
file_schema = property(lambda self: self.file_ref(self.file_schema_py()))
593592
%}
594593
};
595594

0 commit comments

Comments
 (0)