wuttafarm.importing.farmos

Data import for farmOS -> WuttaFarm

class wuttafarm.importing.farmos.ActivityLogImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Activity Logs

model_class

alias of ActivityLog

class wuttafarm.importing.farmos.AnimalAssetImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Animals

model_class

alias of AnimalAsset

setup()[source]

Perform any setup needed before starting the import/export job.

This is called from within process_data(). Default logic does nothing.

class wuttafarm.importing.farmos.AnimalTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Animal Types

model_class

alias of AnimalType

class wuttafarm.importing.farmos.AssetImporterBase(config, **kwargs)[source]

Base class for farmOS API → WuttaFarm asset importers

normalize_target_object(asset)[source]

This should return a “normalized” data record for the given raw object from the target side.

Subclass will often need to override this, to “convert” target object into the shared format required for import/export. The default logic is only able to handle “simple” fields; cf. get_simple_fields().

It’s possible to optimize this somewhat, by checking get_fields() and then normalization may be skipped for any fields which aren’t “effective” for the current job.

Note that if this method returns None then the object is ignored, treated like it does not exist on the target side.

Parameters:

obj – Raw object from data target.

Returns:

Dict of normalized data fields, or None.

update_target_object(asset, source_data, target_data=None)[source]

Update the target object with the given source data, and return the updated object.

This method may be called from do_create_update() for a normal update, or create_target_object() when creating a new record.

It should update the object for any of get_fields() which appear to differ. However it need not bother for the get_keys() fields, since those will already be accurate.

Parameters:
  • obj – Raw target object.

  • source_data – Dict of normalized data for source record.

  • target_data – Dict of normalized data for existing target record, if a typical update. Will be missing for a new object.

Returns:

The final updated object. In most/all cases this will be the same instance as the original obj provided by the caller.

class wuttafarm.importing.farmos.AssetTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Asset Types

model_class

alias of AssetType

class wuttafarm.importing.farmos.EquipmentAssetImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Equipment Assets

model_class

alias of EquipmentAsset

normalize_target_object(equipment)[source]

This should return a “normalized” data record for the given raw object from the target side.

Subclass will often need to override this, to “convert” target object into the shared format required for import/export. The default logic is only able to handle “simple” fields; cf. get_simple_fields().

It’s possible to optimize this somewhat, by checking get_fields() and then normalization may be skipped for any fields which aren’t “effective” for the current job.

Note that if this method returns None then the object is ignored, treated like it does not exist on the target side.

Parameters:

obj – Raw object from data target.

Returns:

Dict of normalized data fields, or None.

setup()[source]

Perform any setup needed before starting the import/export job.

This is called from within process_data(). Default logic does nothing.

update_target_object(equipment, source_data, target_data=None)[source]

Update the target object with the given source data, and return the updated object.

This method may be called from do_create_update() for a normal update, or create_target_object() when creating a new record.

It should update the object for any of get_fields() which appear to differ. However it need not bother for the get_keys() fields, since those will already be accurate.

Parameters:
  • obj – Raw target object.

  • source_data – Dict of normalized data for source record.

  • target_data – Dict of normalized data for existing target record, if a typical update. Will be missing for a new object.

Returns:

The final updated object. In most/all cases this will be the same instance as the original obj provided by the caller.

class wuttafarm.importing.farmos.EquipmentTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Equipment Types

model_class

alias of EquipmentType

class wuttafarm.importing.farmos.FromFarmOS(config, **kwargs)[source]

Base class for importers using farmOS API as data source.

get_supported_fields()[source]

Auto-remove the uuid field, since we use farmos_uuid instead for the importer key.

normalize_datetime(dt)[source]

Convert a farmOS datetime value to naive UTC used by WuttaFarm.

Parameters:

dt – Date/time string value “as-is” from the farmOS API.

Returns:

Equivalent naive UTC datetime

class wuttafarm.importing.farmos.FromFarmOSHandler(config, **kwargs)[source]

Base class for import handler using farmOS API as data source.

begin_source_transaction(client=None)[source]

Establish the farmOS API client.

get_importer_kwargs(key, **kwargs)[source]

Returns a dict of kwargs to be used when construcing an importer/exporter with the given key. This is normally called from get_importer().

Parameters:
  • key – Model key for the desired importer/exporter, e.g. 'Widget'

  • **kwargs – Any kwargs we have so collected far.

Returns:

Final kwargs dict for new importer/exporter.

source_key = 'farmos'

Key identifier for the data source.

This should “uniquely” identify the data source, within the context of the data target. For instance in the case of CSV → Wutta, csv is the source key.

Among other things, this value is used in get_key().

class wuttafarm.importing.farmos.FromFarmOSToWuttaFarm(config, **kwargs)[source]

Handler for farmOS → WuttaFarm import.

class wuttafarm.importing.farmos.GroupAssetImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Group Assets

model_class

alias of GroupAsset

class wuttafarm.importing.farmos.HarvestLogImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Harvest Logs

model_class

alias of HarvestLog

class wuttafarm.importing.farmos.LandAssetImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Land Assets

model_class

alias of LandAsset

class wuttafarm.importing.farmos.LandTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Land Types

model_class

alias of LandType

class wuttafarm.importing.farmos.LogImporterBase(config, **kwargs)[source]

Base class for farmOS API → WuttaFarm log importers

normalize_target_object(log)[source]

This should return a “normalized” data record for the given raw object from the target side.

Subclass will often need to override this, to “convert” target object into the shared format required for import/export. The default logic is only able to handle “simple” fields; cf. get_simple_fields().

It’s possible to optimize this somewhat, by checking get_fields() and then normalization may be skipped for any fields which aren’t “effective” for the current job.

Note that if this method returns None then the object is ignored, treated like it does not exist on the target side.

Parameters:

obj – Raw object from data target.

Returns:

Dict of normalized data fields, or None.

update_target_object(log, source_data, target_data=None)[source]

Update the target object with the given source data, and return the updated object.

This method may be called from do_create_update() for a normal update, or create_target_object() when creating a new record.

It should update the object for any of get_fields() which appear to differ. However it need not bother for the get_keys() fields, since those will already be accurate.

Parameters:
  • obj – Raw target object.

  • source_data – Dict of normalized data for source record.

  • target_data – Dict of normalized data for existing target record, if a typical update. Will be missing for a new object.

Returns:

The final updated object. In most/all cases this will be the same instance as the original obj provided by the caller.

class wuttafarm.importing.farmos.LogTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Log Types

model_class

alias of LogType

class wuttafarm.importing.farmos.MaterialQuantityImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Material Quantities

get_supported_fields()[source]

Auto-remove the uuid field, since we use farmos_uuid instead for the importer key.

model_class

alias of MaterialQuantity

normalize_target_object(quantity)[source]

This should return a “normalized” data record for the given raw object from the target side.

Subclass will often need to override this, to “convert” target object into the shared format required for import/export. The default logic is only able to handle “simple” fields; cf. get_simple_fields().

It’s possible to optimize this somewhat, by checking get_fields() and then normalization may be skipped for any fields which aren’t “effective” for the current job.

Note that if this method returns None then the object is ignored, treated like it does not exist on the target side.

Parameters:

obj – Raw object from data target.

Returns:

Dict of normalized data fields, or None.

update_target_object(quantity, source_data, target_data=None)[source]

Update the target object with the given source data, and return the updated object.

This method may be called from do_create_update() for a normal update, or create_target_object() when creating a new record.

It should update the object for any of get_fields() which appear to differ. However it need not bother for the get_keys() fields, since those will already be accurate.

Parameters:
  • obj – Raw target object.

  • source_data – Dict of normalized data for source record.

  • target_data – Dict of normalized data for existing target record, if a typical update. Will be missing for a new object.

Returns:

The final updated object. In most/all cases this will be the same instance as the original obj provided by the caller.

class wuttafarm.importing.farmos.MaterialTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Material Types

model_class

alias of MaterialType

class wuttafarm.importing.farmos.MeasureImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Measures

model_class

alias of Measure

class wuttafarm.importing.farmos.MedicalLogImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Medical Logs

model_class

alias of MedicalLog

class wuttafarm.importing.farmos.ObservationLogImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Observation Logs

model_class

alias of ObservationLog

class wuttafarm.importing.farmos.PlantAssetImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Plant Assets

model_class

alias of PlantAsset

normalize_target_object(plant)[source]

This should return a “normalized” data record for the given raw object from the target side.

Subclass will often need to override this, to “convert” target object into the shared format required for import/export. The default logic is only able to handle “simple” fields; cf. get_simple_fields().

It’s possible to optimize this somewhat, by checking get_fields() and then normalization may be skipped for any fields which aren’t “effective” for the current job.

Note that if this method returns None then the object is ignored, treated like it does not exist on the target side.

Parameters:

obj – Raw object from data target.

Returns:

Dict of normalized data fields, or None.

setup()[source]

Perform any setup needed before starting the import/export job.

This is called from within process_data(). Default logic does nothing.

update_target_object(plant, source_data, target_data=None)[source]

Update the target object with the given source data, and return the updated object.

This method may be called from do_create_update() for a normal update, or create_target_object() when creating a new record.

It should update the object for any of get_fields() which appear to differ. However it need not bother for the get_keys() fields, since those will already be accurate.

Parameters:
  • obj – Raw target object.

  • source_data – Dict of normalized data for source record.

  • target_data – Dict of normalized data for existing target record, if a typical update. Will be missing for a new object.

Returns:

The final updated object. In most/all cases this will be the same instance as the original obj provided by the caller.

class wuttafarm.importing.farmos.PlantTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Plant Types

model_class

alias of PlantType

class wuttafarm.importing.farmos.QuantityImporterBase(config, **kwargs)[source]

Base class for farmOS API → WuttaFarm quantity importers

setup()[source]

Perform any setup needed before starting the import/export job.

This is called from within process_data(). Default logic does nothing.

class wuttafarm.importing.farmos.QuantityTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Quantity Types

model_class

alias of QuantityType

class wuttafarm.importing.farmos.SeasonImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Seasons

model_class

alias of Season

class wuttafarm.importing.farmos.SeedingLogImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Seeding Logs

model_class

alias of SeedingLog

class wuttafarm.importing.farmos.StandardQuantityImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Standard Quantities

model_class

alias of StandardQuantity

class wuttafarm.importing.farmos.StructureAssetImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Structure Assets

model_class

alias of StructureAsset

setup()[source]

Perform any setup needed before starting the import/export job.

This is called from within process_data(). Default logic does nothing.

class wuttafarm.importing.farmos.StructureTypeImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Structure Types

model_class

alias of StructureType

class wuttafarm.importing.farmos.TaxonomyImporterBase(config, **kwargs)[source]

farmOS API → WuttaFarm importer for taxonomy terms

class wuttafarm.importing.farmos.ToWuttaFarmHandler(config, **kwargs)[source]

Base class for import handler targeting WuttaFarm

class wuttafarm.importing.farmos.UnitImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Units

model_class

alias of Unit

class wuttafarm.importing.farmos.UserImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Users

can_delete_object(user, data=None)[source]

Prevent delete for users which do not exist in farmOS.

model_class

alias of User

class wuttafarm.importing.farmos.WaterAssetImporter(config, **kwargs)[source]

farmOS API → WuttaFarm importer for Water Assets

model_class

alias of WaterAsset