@@ -134,18 +134,18 @@ def get_parcel_info(
134134 params = {"format" : "json" },
135135 )
136136
137- contact = farm_info .get ("contactPerson" , {})
137+ contact = farm_info .get ("contactPerson" ) or {}
138138 farm = FarmInfo (
139- description = farm_info .get ("description" , "" ) ,
140- administrator = farm_info .get ("administrator" , "" ) ,
141- vatID = farm_info .get ("vatID" , "" ) ,
142- name = farm_info .get ("name" , "" ) ,
143- municipality = farm_info .get ("address" , {}).get ("municipality" , "" ) ,
139+ description = farm_info .get ("description" ) or "" ,
140+ administrator = farm_info .get ("administrator" ) or "" ,
141+ vatID = farm_info .get ("vatID" ) or "" ,
142+ name = farm_info .get ("name" ) or "" ,
143+ municipality = ( farm_info .get ("address" ) or {}).get ("municipality" ) or "" ,
144144 contactPerson = f"{ contact .get ('firstname' , '' )} { contact .get ('lastname' , '' )} " ,
145145 )
146146
147147 try :
148- identifier = farm_parcel_info .get ("identifier" )
148+ identifier = farm_parcel_info .get ("identifier" ) or ""
149149 if location :
150150 lat = location .get ('lat' )
151151 long = location .get ('long' )
@@ -154,9 +154,9 @@ def get_parcel_info(
154154 parcel_info .long = long
155155 l_info = geolocator .reverse (coordinates )
156156 address_details = l_info .raw .get ("address" , {})
157- city = address_details .get ("city" , "" )
158- country = address_details .get ("country" )
159- postcode = address_details .get ("postcode" )
157+ city = address_details .get ("city" ) or ""
158+ country = address_details .get ("country" ) or ""
159+ postcode = address_details .get ("postcode" ) or ""
160160 address = f"Country: { country } | City: { city } | Postcode: { postcode } "
161161 parcel_info .address = address
162162 except Exception as e :
0 commit comments