ladybug_rhino.versioning.diff module

Functions for managing components differences and syncing component versions.

ladybug_rhino.versioning.diff.current_userobject_version(component)[source]

Get the current installed version of a component.

Parameters:

component – A Grasshopper Python component with the same name as an installed user object. If no matching user object is found, this method returns None.

ladybug_rhino.versioning.diff.has_version_changed(user_object, component)[source]

Check if the version of a component has changed from a corresponding user object.

Note that this method only works for user objects that have been dropped on the canvas. For comparing the version with a user object that hasn’t been loaded from the component server by dropping it on the canvas, the current_userobject_version method should be used.

Parameters:
  • user_object – A Grasshopper user object component instance.

  • component – The Grasshopper component object for which the version is being checked.

ladybug_rhino.versioning.diff.input_output_changed(user_object, component)[source]

Check if any of inputs or outputs have changed between two components.

Parameters:
  • user_object – A Grasshopper user object component instance.

  • component – The Grasshopper component object for which the version is being checked.

ladybug_rhino.versioning.diff.insert_new_user_object(user_object, component, doc)[source]

Insert a new user object next to an existing component in the Grasshopper doc.

Parameters:
  • user_object – A Grasshopper user object component instance.

  • component – The outdated component where the userobject will be inserted next to.

  • doc – The Grasshopper document object.

ladybug_rhino.versioning.diff.mark_component(doc, component, note=None)[source]

Put a circular red group around a component and label it with a note.

Parameters:
  • doc – The Grasshopper document object.

  • component – A Grasshopper component object on the canvas to be circled.

  • note – Text for the message to be displayed on the circle. If None, a default message about input/output change wil be used.

ladybug_rhino.versioning.diff.parse_version(semver_str)[source]

Parse semantic version string into (major, minor, patch) tuple.

Parameters:

semver_str – Text for a component version (eg. “1.0.1”).

ladybug_rhino.versioning.diff.sync_component(component, syncing_component)[source]

Sync a component on the canvas with its corresponding installed version.

This includes identifying if the component by name in the user object folder, injecting the code from that user object into the component, and (if the component inputs or outputs have changed) circling the component in red + dropping the new user object next to the component.

Parameters:
  • component – A Grasshopper component object on the canvas to be synced.

  • syncing_component – An object for the component that is doing the syncing. This will be used to give warnings and access the Grasshopper doc. Typically, this can be accessed through the ghenv.Component call.

ladybug_rhino.versioning.diff.update_port(p1, p2)[source]

Update one port based on another.

Parameters:
  • p1 – The first port object, which is the one used for updating.

  • p2 – The second port object, which will be updated base on p1.

ladybug_rhino.versioning.diff.update_ports(c1, c2)[source]

Update all of the ports of one component based on another.

Parameters:
  • c1 – The first component object, which is the one used for updating.

  • c2 – The second component object, which will be updated base on c1.

ladybug_rhino.versioning.diff.validate_change_type(change_type)[source]

Check that a change type is a valid tag.

ladybug_rhino.versioning.diff.validate_version(current_version, new_version, change_type)[source]

Validate that a version tag conforms to currently-installed version difference.

Parameters:
  • current_version – Semantic version string for the currently installed version.

  • new_version – Semantic version string for the new component version.

  • change_type – Text tag for the change type (eg. “fix”).