def getdateage(arrivaldate, age, period): """ Returns a date adjusted for age. age is a number, period is YEARS, MONTHS or WEEKS """ d = getdate(arrivaldate) if d is None: d = asm.now() if period == "YEARS": d = asm.subtract_days(d, 365 * asm.cfloat(age)) if period == "MONTHS": d = asm.subtract_days(d, 31 * asm.cfloat(age)) if period == "WEEKS": d = asm.subtract_days(d, 7 * asm.cfloat(age)) return d
def getdateage(age, arrivaldate): """ Returns a date adjusted for age. Age can be one of ADULT, PUPPY, KITTEN, SENIOR """ d = asm.getdate_mmddyy(arrivaldate) if d == None: d = asm.now() if age == "ADULT": d = d - datetime.timedelta(days = 365 * 2) if age == "SENIOR": d = d - datetime.timedelta(days = 365 * 7) if age == "KITTEN": d = d - datetime.timedelta(days = 60) if age == "PUPPY": d = d - datetime.timedelta(days = 60) return d
def create_vacc(vaccname, vaccdate, vaccrenew): vacctypes = { "Rabies": 4, "Distemper": 1, "Lepto": 3, "Bordetella": 6, "Influenza": 10 } given = getdate(vaccdate) if given is not None: av = asm.AnimalVaccination() animalvaccinations.append(av) av.AnimalID = a.ID av.VaccinationID = vacctypes[vaccname] av.DateRequired = given av.DateOfVaccination = given nx = getdate(vaccrenew) if nx is not None and nx > asm.now(): av = asm.AnimalVaccination() animalvaccinations.append(av) av.AnimalID = a.ID av.VaccinationID = vacctypes[vaccname] av.DateRequired = nx av.DateOfVaccination = None
asm.additional_field("DriversLicense", 1, o.ID, row["Code"]) # animals for row in canimals: if row["PrimaryIDString"] == "": continue a = asm.Animal() animals.append(a) ppa[row["tblAnimalsID"]] = a species = asm.find_value(cspecies, "sysSpeciesID", row["sysSpeciesID"], "CommonName") a.AnimalTypeID = 2 a.SpeciesID = asm.species_id_for_name(asm.fw(species)) a.AnimalName = row["Name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.DateOfBirth = asm.getdate_mmddyy(row["DateOfBirth"]) if a.DateOfBirth is None: a.DateOfBirth = asm.now() a.DateBroughtIn = asm.now() irow = asm.find_row(canimalintakes, "tblAnimalsID", row["tblAnimalsID"]) if irow is not None: a.DateBroughtIn = asm.getdate_mmddyy(irow["DateReceived"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.EntryReasonID = 1 #a.generateCode(gettypeletter(a.AnimalTypeID)) code = "MO" + asm.padleft(row["tblAnimalsID"], 6) a.ShelterCode = code a.ShortCode = code a.NeuteredDate = asm.getdate_mmddyy(row["SpayNeuterPerformedDate"]) if a.NeuteredDate is not None: a.Neutered = 1 # 1 = neutered, 2 = spayed, 3 = entire, 5 = unknown
# o.ExcludeFromBulkEmail = asm.cint(row["MAILINGSAM"]) # Not sure this is correct # Animals for row in canimal: if not IMPORT_ANIMALS_WITH_NO_NAME and row["PETNAME"].strip() == "": continue a = asm.Animal() animals.append(a) ppa[row["ANIMALKEY"]] = a a.AnimalTypeID = gettype(row["ANIMLDES"]) a.SpeciesID = asm.species_id_for_name(row["ANIMLDES"].split(" ")[0]) a.AnimalName = asm.strip(row["PETNAME"]) if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" age = row["AGE"].split(" ")[0] added = asm.now() if "ADDEDDATET" in row: added = row["ADDEDDATET"] if "DOB" in row: a.DateOfBirth = row["DOB"] if a.DateOfBirth is None: a.DateOfBirth = getdateage(age, added) a.DateBroughtIn = added a.LastChangedDate = a.DateBroughtIn a.CreatedDate = a.DateBroughtIn a.EntryReasonID = 4 a.generateCode(gettypeletter(a.AnimalTypeID)) a.ShortCode = row["ANIMALKEY"] a.Neutered = asm.cint(row["FIX"]) a.Declawed = asm.cint(row["DECLAWED"]) a.IsNotAvailableForAdoption = 0 a.ShelterLocation = 1 a.Sex = asm.getsex_mf(asm.strip(row["GENDER"])) a.Size = getsize(asm.strip(row["WEIGHT"]))
if ppo.has_key(d["SURR_ID"]): a.OriginalOwnerID = ppo[d["SURR_ID"]].ID a.generateCode() a.ShortCode = d["ID_NUM"] a.Sex = asm.getsex_mf(d["SEX"]) a.ShelterLocationUnit = d["LOCATION"] a.BreedID = asm.breed_id_for_name(d["BREED"]) a.BaseColourID = asm.colour_id_for_name(d["COLOR"]) a.BreedName = asm.breed_name_for_id(a.BreedID) if d["BREED"].find("MIX") != -1: a.CrossBreed = 1 a.Breed2ID = 442 a.BreedName = asm.breed_name_for_id( a.BreedID) + " / " + asm.breed_name_for_id(a.Breed2ID) a.DateBroughtIn = d["DATE_SURR"] if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.NeuteredDate = d["NEUTER_DAT"] if a.NeuteredDate is not None: a.Neutered = 1 a.EstimatedDOB = 1 dob = a.DateBroughtIn if d["AGE"] != "": if d["AGE"].find("YR") != -1: dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 365) elif d["AGE"].find("M") != -1: dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 30) a.DateOfBirth = dob if d["EUTH_USD"] > 0: a.PutToSleep = 1 a.Archived = 1 a.DeceasedDate = d["DATE_DISPO"]
if row["AlternatePhone"] != "": o.Comments = "Alternate: %s %s" % (row["AlternateName"], row["AlternatePhone"]) # Now animals for row in canimal: a = asm.Animal() animals.append(a) ppa[row["PetId"]] = a a.AnimalTypeID = gettype(row["Species"]) a.SpeciesID = asm.species_id_for_name(row["Species"]) a.AnimalName = row["Name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.DateOfBirth = getdateage(row["ArrivalDate"], row["Age"], row["Period"]) if a.DateOfBirth is None: a.DateOfBirth = asm.now() a.DateBroughtIn = getdate(row["ArrivalDate"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.generateCode(gettypeletter(a.AnimalTypeID)) a.ShortCode = row["EntryNo"] a.RabiesTag = row["DiscNo"] a.BreedID = asm.breed_id_for_name(row["Breed"]) # If we've got the default dog breed with a cat, switch to DSH if a.SpeciesID == 2 and a.BreedID == 1: a.BreedID = 261 if row["Breed"].find("X") != -1: a.CrossBreed = 1 a.Breed2ID = 442 a.BreedName = asm.breed_name(a.BreedID, a.Breed2ID) a.BaseColourID = asm.colour_id_for_name(row["Color"]) a.AnimalComments = row["Notes"]
else: # We're going to have to look them up from the speciesID and # secondarySpeciesID fields typecol = getsbtypenamefromspeciesid(row["speciesID"]) breedcol = getsbbreednamefromspeciesid(row["speciesID"]) breed2col = getsbbreednamefromspeciesid(row["secondarySpeciesID"]) a.AnimalTypeID = asm.type_id_for_name(typecol) a.SpeciesID = asm.species_id_for_name(typecol) a.BreedID = asm.breed_id_for_name(breedcol) a.Breed2ID = asm.breed_id_for_name(breed2col) if row["DateIN"].strip() != "": a.DateBroughtIn = getdate(row["DateIN"]) if a.DateBroughtIn is None: a.DateBroughtIn = getdate(row["AddDateTime"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() if row["DateOUT"].strip() != "": a.ActiveMovementDate = getdate(row["DateOUT"]) if a.ActiveMovementDate is not None: a.ActiveMovementType = 1 a.Archived = 1 elif a.DateBroughtIn.year < asm.now().year - 1: a.Archived = 1 a.Neutered = row["desexdate"].strip() != "" and 1 or 0 a.NeuteredDate = getdate(row["desexdate"]) a.BreedName = asm.breed_name_for_id(a.BreedID) a.CrossBreed = row["crossbreed"] == "TRUE" and 1 or 0 if a.CrossBreed == 1: a.Breed2ID = 442 if row["dob"].strip() != "": a.DateOfBirth = getdate(row["dob"])
a.Sex = asm.getsex_mf(d["SEX"]) a.BreedID = asm.breed_id_for_name(d["BREED1"]) if d["BREED2"] == "Unspecified": a.Breed2ID = a.BreedID a.CrossBreed = 0 else: a.CrossBreed = 1 a.Breed2ID = asm.breed_id_for_name(d["BREED2"]) a.BreedName = asm.breed_name(a.BreedID, a.Breed2ID) if d["BREED2"].find("Mix") != -1: a.CrossBreed = 1 a.Breed2ID = 442 a.BreedName = asm.breed_name_for_id(a.BreedID) + " / " + asm.breed_name_for_id(a.Breed2ID) a.BaseColourID = asm.colour_id_for_name(d["COLOR1"]) a.DateBroughtIn = d["FOUNDDATE"] if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.Neutered = asm.iif(d["ALTERED"] == "Yes", 1, 0) a.DateOfBirth = d["BIRTHDATE"] if a.DateOfBirth is None: a.EstimatedDOB = 1 a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365) a.PickupAddress = d["CITY"] a.AnimalComments = d["NOTES"] a.Markings = d["MARKINGS"] comments = "Status: %s" % d["STATUS"] comments += "\nOriginal breed: %s / %s" % (d["BREED1"], d["BREED2"]) comments += "\nColor: %s / %s" % (d["COLOR1"], d["COLOR2"]) comments += "\nPattern: %s" % d["PATTERN"] comments += "\nAge Group: %s" % d["AGEGROUP"] comments += "\nWeight Group: %s" % d["WEIGHTGRP"] comments += "\nCoat: %s" % d["COAT"]
def getdate(d, noblanks=False): rv = asm.getdate_guess(d) if noblanks and rv is None: rv = asm.now() return rv
ol.LicenceTypeID = 2 # Unaltered dog #if row["LICENSEFIX"] == "1": # Not always present # ol.LicenceTypeID = 1 # Altered dog # Incident notes for row in cnote: if row["EVENTTYPE"] == 2: notes[row["EVENTKEY"]] = row["NOTEMEMO"] # Incidents for row in cincident: ac = asm.AnimalControl() animalcontrol.append(ac) calldate = row["DATETIMEAS"] if calldate is None: calldate = row["DATETIMEOR"] if calldate is None: calldate = asm.now() ac.CallDateTime = calldate ac.IncidentDateTime = calldate ac.DispatchDateTime = calldate ac.CompletedDate = row["DATETIMEOU"] if ac.CompletedDate is None: ac.CompletedDate = calldate if ppo.has_key(row["CITIZENMAK"]): ac.CallerID = ppo[row["CITIZENMAK"]].ID if ppo.has_key(row["OWNERATORI"]): ac.OwnerID = ppo[row["OWNERATORI"]].ID ac.IncidentCompletedID = 2 if row["FINALOUTCO"] == "ANIMAL PICKED UP": ac.IncidentCompletedID = 2 elif row["FINALOUTCO"] == "OTHER": ac.IncidentCompletedID = 6 # Does not exist in default data ac.IncidentTypeID = 1
# o.ExcludeFromBulkEmail = asm.cint(row["MAILINGSAM"]) # Not sure this is correct # Animals for row in canimal: if not IMPORT_ANIMALS_WITH_NO_NAME and row["PETNAME"].strip() == "": continue a = asm.Animal() animals.append(a) ppa[row["ANIMALKEY"]] = a a.AnimalTypeID = gettype(row["ANIMLDES"]) a.SpeciesID = asm.species_id_for_name(row["ANIMLDES"].split(" ")[0]) a.AnimalName = asm.strip(row["PETNAME"]) if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" age = row["AGE"].split(" ")[0] added = asm.now() if "ADDEDDATET" in row and row["ADDEDDATET"] is not None: added = row["ADDEDDATET"] if "DOB" in row: a.DateOfBirth = row["DOB"] if a.DateOfBirth is None: a.DateOfBirth = getdateage(age, added) a.DateBroughtIn = added a.LastChangedDate = a.DateBroughtIn a.CreatedDate = a.DateBroughtIn a.EntryReasonID = 4 a.generateCode(gettypeletter(a.AnimalTypeID)) a.ShortCode = row["ANIMALKEY"] a.Neutered = asm.cint(row["FIX"]) a.Declawed = asm.cint(row["DECLAWED"]) a.IsNotAvailableForAdoption = 0 a.ShelterLocation = 1 a.Sex = asm.getsex_mf(asm.strip(row["GENDER"]))
idfield = "AnimalID" for d in asm.csv_to_list(MEMO_FILENAME): if "textbox20" not in d: continue # Can't do anything without our field if d["textbox20"] == "textbox20": continue # Ignore repeated headers if not d.has_key(idfield): idfield = "Name" if ppa.has_key(d[idfield]): a = ppa[d[idfield]] l = asm.Log() logs.append(l) l.LogTypeID = 3 # History l.LinkID = a.ID l.LinkType = 0 l.Date = asm.getdate_mmddyyyy(d["textbox20"]) if l.Date is None: l.Date = asm.now() l.Comments = d["Textbox131"] if CASES_FILENAME != "" and asm.file_exists(CASES_FILENAME): ctmap = { "Neglect/ Cruelty": 7, "Bite": 5, "Nuisance": 8, "Stray": 3, "wildlife": 3, "Assist Police/Fire": 3, "Feral Cat": 3, "Injured": 10, "TNR": 10 } for d in asm.csv_to_list(CASES_FILENAME):
a = asm.Animal() animals.append(a) ppa[row["ANIMALKEY"]] = a a.AnimalTypeID = gettype(row["ANIMLDES"]) a.SpeciesID = asm.species_id_for_name(row["ANIMLDES"].split(" ")[0]) a.AnimalName = row["PETNAME"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" age = row["AGE"].split(" ")[0] a.DateOfBirth = getdateage(age, row["ADDEDDATETIME"]) # TODO: some have DOB # a.DateOfBirth = asm.getdate_yyyymmdd(row["DOB"]) a.DateBroughtIn = asm.getdate_mmddyy(row["ADDEDDATETIME"]) if a.DateBroughtIn is None: asm.stderr("Bad datebroughtin: '%s'" % row["ADDEDDATET"]) a.DateBroughtIn = asm.now() a.EntryReasonID = 4 #a.generateCode(gettypeletter(a.AnimalTypeID)) a.ShelterCode = "SP%s" % row["ANIMALKEY"] a.ShortCode = a.ShelterCode a.Neutered = asm.cint(row["FIX"]) a.Declawed = asm.cint(row["DECLAWED"]) a.IsNotAvailableForAdoption = 0 a.ShelterLocation = 1 a.Sex = asm.getsex_mf(asm.fw(row["GENDER"])) a.Size = getsize(asm.fw(row["WEIGHT"])) a.BaseColourID = asm.colour_id_for_names(asm.fw(row["FURCOLR1"]), asm.fw(row["FURCOLR2"])) a.IdentichipNumber = row["MICROCHIP"] comments = "Original breed: " + row["BREED1"] + "/" + row["CROSSBREED"] + ", age: " + age comments += "\nLicense: " + row["LICENSE"] comments += "\nColor: " + asm.fw(row["FURCOLR1"]) + "/" + asm.fw(row["FURCOLR2"])
animalmedicals.append( asm.animal_regimen_single(a.ID, sdate, tname, "", row["Note"])) # animal notes asm.stderr("Process animal notes") for row in canimalsnotes: if not ppa.has_key(row["tblAnimalsID"]): continue a = ppa[row["tblAnimalsID"]] l = asm.Log() logs.append(l) l.LogTypeID = 3 l.LinkID = a.ID l.LinkType = 0 l.Date = asm.getdate_mmddyy(row["NoteDate"]) if l.Date is None: l.Date = asm.now() l.Comments = row["Note"] # person notes asm.stderr("Process person notes") for row in cpersonsnotes: if not ppo.has_key(row["tblKnownPersonsID"]): continue a = ppo[row["tblKnownPersonsID"]] l = asm.Log() logs.append(l) l.LogTypeID = 3 l.LinkID = a.ID l.LinkType = 1 l.Date = asm.now() l.Comments = row["Note"]
d["TreatmentName"], d["Vaccinator"], d["Vet"], d["VetLicenseNumber"], d["VaccineTagNbr"], d["Comments"]) else: animalmedicals.append( asm.animal_regimen_single( aid, meddate, d["TreatmentName"], "", "%s %s" % (d["VaccineTagNbr"], d["Comments"]))) # Incidents for d in asm.csv_to_list(COMPLAINTS_FILENAME): if d["Complaint"].strip() == "" or d["ComplaintType"].strip() == "": continue ac = asm.AnimalControl() animalcontrols.append(ac) calldate = getdate(d["ComplaintDate"]) if calldate is None: calldate = asm.now() ac.CallDateTime = calldate ac.IncidentDateTime = calldate ac.DispatchDateTime = calldate ac.CompletedDate = calldate ac.CallerID = d["CallerPersonID"] in ppo and ppo[ d["CallerPersonID"]].ID or 0 ac.OwnerID = d["OwnerPersonID"] in ppo and ppo[d["OwnerPersonID"]].ID or 0 if d["AnimalID"] in ppa: animalcontrolanimals.append( "INSERT INTO animalcontrolanimal (AnimalID, AnimalControlID) VALUES (%s, %s);\n" % (ppa[d["AnimalID"]].ID, ac.ID)) ac.IncidentCompletedID = 2 # Picked up ac.IncidentTypeID = 7 # Neglect if d["ComplaintType"] == "Loose" or d[ "ComplaintType"] == "Running At Large":
if d["SURR_ID"] != "": if d["SURR_ID"] in ppo: a.OriginalOwnerID = ppo[d["SURR_ID"]].ID a.generateCode() a.ShortCode = d["ID_NUM"] a.Sex = asm.getsex_mf(d["SEX"]) a.ShelterLocationUnit = d["LOCATION"] a.BreedID = asm.breed_id_for_name(d["BREED"]) a.BaseColourID = asm.colour_id_for_name(d["COLOR"]) a.BreedName = asm.breed_name_for_id(a.BreedID) if d["BREED"].find("MIX") != -1: a.CrossBreed = 1 a.Breed2ID = 442 a.BreedName = asm.breed_name_for_id(a.BreedID) + " / " + asm.breed_name_for_id(a.Breed2ID) a.DateBroughtIn = asm.todatetime(d["DATE_SURR"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.NeuteredDate = d["NEUTER_DAT"] if a.NeuteredDate is not None: a.Neutered = 1 a.EstimatedDOB = 1 dob = a.DateBroughtIn if "DOB" in d and d["DOB"] is not None: dob = d["DOB"] elif type(d["AGE"]) == int: dob = asm.subtract_days(dob, d["AGE"] * 365) elif type(d["AGE"]) == str and d["AGE"] != "": if d["AGE"].find("YR") != -1: dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 365) elif d["AGE"].find("M") != -1: dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 30) a.DateOfBirth = dob
o.EmailAddress = row["Email"] if row["AlternatePhone"] != "": o.Comments = "Alternate: %s %s" % (row["AlternateName"], row["AlternatePhone"]) # Now animals for row in canimal: a = asm.Animal() animals.append(a) ppa[row["PetId"]] = a a.AnimalTypeID = gettype(row["Species"]) a.SpeciesID = asm.species_id_for_name(row["Species"]) a.AnimalName = row["Name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.DateOfBirth = getdateage(row["ArrivalDate"], row["Age"], row["Period"]) if a.DateOfBirth is None: a.DateOfBirth = asm.now() a.DateBroughtIn = getdate(row["ArrivalDate"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.generateCode(gettypeletter(a.AnimalTypeID)) a.ShortCode = row["EntryNo"] a.RabiesTag = row["DiscNo"] a.BreedID = asm.breed_id_for_name(row["Breed"]) # If we've got the default dog breed with a cat, switch to DSH if a.SpeciesID == 2 and a.BreedID == 1: a.BreedID = 261 if row["Breed"].find("X") != -1: a.CrossBreed = 1 a.Breed2ID = 442 a.BreedName = asm.breed_name(a.BreedID, a.Breed2ID) a.BaseColourID = asm.colour_id_for_name(row["Color"]) a.AnimalComments = row["Notes"]
animalvaccinations.append(av) av.DateRequired = date av.DateOfVaccination = date av.VaccinationID = 6 if row["MED"].startswith("FelV"): av.VaccinationID = 12 if row["MED"].startswith("FVRCP"): av.VaccinationID = 9 if row["MED"].startswith("DA2PP"): av.VaccinationID = 8 if row["MED"].startswith("Bord"): av.VaccinationID = 6 if row["MED"].startswith("Rabies"): av.VaccinationID = 4 if row["MED"].startswith("Lepto"): av.VaccinationID = 3 av.Comments = "%s %s" % (row["MED"], row["NOTES"]) # Run back through the animals, if we have any that are still # on shelter after 1 year, add an adoption to an unknown owner for a in animals: if a.Archived == 0 and a.DateBroughtIn < asm.subtract_days(asm.now(), 365): m = asm.Movement() m.AnimalID = a.ID m.OwnerID = uo.ID m.MovementType = 1 m.MovementDate = a.DateBroughtIn a.Archived = 1 a.ActiveMovementID = m.ID a.ActiveMovementDate = a.DateBroughtIn a.ActiveMovementType = 1 movements.append(m) # Now that everything else is done, output stored records for k, v in asm.locations.iteritems(): print v for a in animals:
ownermapbykey[o.OwnerForeNames + " " + o.OwnerSurname + " " + asm.fw(o.OwnerAddress)] = o # On shelter animals are kept in a separate database table called RECORD # with a slightly different layout to animalhistory for row in asm.csv_to_list(PATH + "record.csv", strip=True): # Each row contains a new animal a = asm.Animal(nextanimalid) animals.append(a) animalmap[row["RECORDNUMBER"]] = a nextanimalid += 1 a.ExtraID = row["RECORDNUMBER"] a.DateBroughtIn = asm.getdate_mmddyy(row["DATE"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.AnimalTypeID = gettype(row["SPECIES"]) if row["SPECIES"] == "Kitten": a.SpeciesID = 1 elif row["SPECIES"] == "Puppy": a.SpeciesID = 2 else: a.SpeciesID = asm.species_id_for_name(row["SPECIES"]) a.generateCode(gettypeletter(a.AnimalTypeID)) a.ShortCode = row["FORMNUM"] ob = row["BREEDID"] a.CrossBreed = 0 if ob.find("Mix") != -1: a.CrossBreed = 1 a.Breed2ID = 442 ob = ob.replace("Mix", "")
def getdatetime(d, noblanks=False): rv = asm.parse_date(d, "%Y/%m/%d %H:%M:%S") if noblanks and rv is None: rv = asm.now() return rv
a.DateBroughtIn = asm.getdate_yyyymmdd(row["ADDEDDATET"]) if a.DateBroughtIn is None: asm.stderr("Bad datebroughtin: '%s'" % row["ADDEDDATET"]) a.DateBroughtIn = datetime.datetime.today() a.AnimalTypeID = gettype(row["ANIMLDES"]) a.generateCode(gettypeletter(a.AnimalTypeID)) if row["REGISTRATI"] != "": a.ShelterCode = "%s (%s)" % (row["REGISTRATI"], row["ANIMALKEY"]) a.ShortCode = row["REGISTRATI"] a.SpeciesID = asm.species_id_for_name(row["ANIMLDES"].split(" ")[0]) a.AnimalName = row["PETNAME"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" age = row["AGE"].split(" ")[0] a.DateOfBirth = asm.getdate_yyyymmdd(row["DOB"]) if a.DateOfBirth is None: a.DateOfBirth = asm.now() a.EntryReasonID = 4 a.Neutered = asm.cint(row["FIX"]) a.Declawed = asm.cint(row["DECLAWED"]) a.IsNotAvailableForAdoption = 0 a.ShelterLocation = 1 a.Sex = asm.getsex_mf(asm.fw(row["GENDER"])) a.Size = getsize(asm.fw(row["WEIGHT"])) a.BaseColourID = asm.colour_id_for_names(asm.fw(row["FURCOLR1"]), asm.fw(row["FURCOLR2"])) a.IdentichipNumber = row["MICROCHIP"] if a.IdentichipNumber != "": a.Identichipped = 1 if len(a.IdentichipNumber) == 8: a.IdentichipNumber = "0" + a.IdentichipNumber comments = "Original breed: " + row["BREED1"] + "/" + row["CROSSBREED"] + ", age: " + age comments += ",Color: " + asm.fw(row["FURCOLR1"]) + "/" + asm.fw(row["FURCOLR2"]) comments += ", Coat: " + row["COAT"] comments += ", Collar: " + row["COLLRTYP"]
if d["SURR_ID"] != "": if ppo.has_key(d["SURR_ID"]): a.OriginalOwnerID = ppo[d["SURR_ID"]].ID a.generateCode() a.ShortCode = d["ID_NUM"] a.Sex = asm.getsex_mf(d["SEX"]) a.ShelterLocationUnit = d["LOCATION"] a.BreedID = asm.breed_id_for_name(d["BREED"]) a.BaseColourID = asm.colour_id_for_name(d["COLOR"]) a.BreedName = asm.breed_name_for_id(a.BreedID) if d["BREED"].find("MIX") != -1: a.CrossBreed = 1 a.Breed2ID = 442 a.BreedName = asm.breed_name_for_id(a.BreedID) + " / " + asm.breed_name_for_id(a.Breed2ID) a.DateBroughtIn = d["DATE_SURR"] if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.NeuteredDate = d["NEUTER_DAT"] if a.NeuteredDate is not None: a.Neutered = 1 a.EstimatedDOB = 1 dob = a.DateBroughtIn if d["AGE"] != "": if d["AGE"].find("YR") != -1: dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 365) elif d["AGE"].find("M") != -1: dob = asm.subtract_days(dob, asm.atoi(d["AGE"]) * 30) a.DateOfBirth = dob if d["EUTH_USD"] > 0: a.PutToSleep = 1 a.Archived = 1 a.DeceasedDate = d["DATE_DISPO"]
if "FOSTERS" in row: o.IsFosterer = asm.cint(row["FOSTERS"]) # o.ExcludeFromBulkEmail = asm.cint(row["MAILINGSAM"]) # Not sure this is correct # Animals for row in canimal: if not IMPORT_ANIMALS_WITH_NO_NAME and row["PETNAME"].strip() == "": continue a = asm.Animal() animals.append(a) ppa[row["ANIMALKEY"]] = a a.AnimalTypeID = gettype(row["ANIMLDES"]) a.SpeciesID = asm.species_id_for_name(row["ANIMLDES"].split(" ")[0]) a.AnimalName = asm.strip(row["PETNAME"]) if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" age = row["AGE"].split(" ")[0] added = asm.now() if "ADDEDDATET" in row and row["ADDEDDATET"] is not None: added = row["ADDEDDATET"] if "DOB" in row: a.DateOfBirth = row["DOB"] if a.DateOfBirth is None: a.DateOfBirth = getdateage(age, added) a.DateBroughtIn = added a.LastChangedDate = a.DateBroughtIn a.CreatedDate = a.DateBroughtIn a.EntryReasonID = 4 a.generateCode(gettypeletter(a.AnimalTypeID)) a.ShortCode = row["ANIMALKEY"] a.Neutered = asm.cint(row["FIX"]) a.Declawed = asm.cint(row["DECLAWED"]) a.IsNotAvailableForAdoption = 0 a.ShelterLocation = 1 a.Sex = asm.getsex_mf(asm.strip(row["GENDER"])) a.Size = getsize(asm.strip(row["WEIGHT"]))