| @@ 213-240 (lines=28) @@ | ||
| 210 | return result, not_found |
|
| 211 | ||
| 212 | # a function to detect if crbanim species are in UID database or not |
|
| 213 | def check_species(self, country): |
|
| 214 | """Check if all species are defined in UID DictSpecies""" |
|
| 215 | ||
| 216 | # CRBAnim usually have species in the form required for UID |
|
| 217 | # However sometimes there could be a common name, not a DictSpecie one |
|
| 218 | column = 'species_latin_name' |
|
| 219 | ||
| 220 | check, not_found = self.__check_items( |
|
| 221 | self.items[column], DictSpecie, column) |
|
| 222 | ||
| 223 | if check is False: |
|
| 224 | # try to check in dictionary table |
|
| 225 | logger.info("Searching for %s in dictionary tables" % (not_found)) |
|
| 226 | ||
| 227 | # if this function return True, I found all synonyms |
|
| 228 | if check_species_synonyms(not_found, country) is True: |
|
| 229 | logger.info("Found %s in dictionary tables" % not_found) |
|
| 230 | ||
| 231 | # return True and an empty list for check and not found items |
|
| 232 | return True, [] |
|
| 233 | ||
| 234 | else: |
|
| 235 | # if I arrive here, there are species that I couldn't find |
|
| 236 | logger.error( |
|
| 237 | "Couldnt' find those species in dictionary tables:") |
|
| 238 | logger.error(not_found) |
|
| 239 | ||
| 240 | return check, not_found |
|
| 241 | ||
| 242 | # check that dict sex table contains data |
|
| 243 | def check_sex(self): |
|
| @@ 246-272 (lines=27) @@ | ||
| 243 | return result, not_found |
|
| 244 | ||
| 245 | # TODO: nearly identical to CRBanim move in a common mixin |
|
| 246 | def check_species(self, country): |
|
| 247 | """Check if all species are defined in UID DictSpecies""" |
|
| 248 | ||
| 249 | column = 'species' |
|
| 250 | item_set = set([breed.species for breed in self.get_breed_records()]) |
|
| 251 | ||
| 252 | check, not_found = self.__check_items( |
|
| 253 | item_set, DictSpecie, column) |
|
| 254 | ||
| 255 | if check is False: |
|
| 256 | # try to check in dictionary table |
|
| 257 | logger.info("Searching for %s in dictionary tables" % (not_found)) |
|
| 258 | ||
| 259 | # if this function return True, I found all synonyms |
|
| 260 | if check_species_synonyms(not_found, country) is True: |
|
| 261 | logger.info("Found %s in dictionary tables" % not_found) |
|
| 262 | ||
| 263 | # return True and an empty list for check and not found items |
|
| 264 | return True, [] |
|
| 265 | ||
| 266 | else: |
|
| 267 | # if I arrive here, there are species that I couldn't find |
|
| 268 | logger.error( |
|
| 269 | "Couldnt' find those species in dictionary tables:") |
|
| 270 | logger.error(not_found) |
|
| 271 | ||
| 272 | return check, not_found |
|
| 273 | ||
| 274 | # TODO: nearly identical to CRBanim move in a common mixin |
|
| 275 | def check_sex(self): |
|