Skip to content

[FEATURE] get method for Feature attributes #130

@dshen109

Description

@dshen109

Currently, checking if features exist on an attribute involves a begin... rescue block. This can get pretty repetitive for checking single features and/or setting default values in mapper scripts:

Example of current pattern:

system_type = "Residential - furnace and central air conditioner"
begin
  system_type = feature.system_type
rescue
end

I think adding a get_property method to Feature objects which can take an optional default value would help make the code cleaner and be more object oriented.

Example proposed usage:

# Returns the second argument if `system_type` doesn't exist in the feature.
system_type = feature.get_property("system_type", "Residential - furnace and central air conditioner")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions