# Ignore repeated headers if d["Person ID"] == "Person ID": continue # Each row contains a person o = asm.Owner() owners.append(o) ppo[d["Person ID"]] = o o.OwnerForeNames = d["Name First"] o.OwnerSurname = d["Name Last"] o.OwnerName = o.OwnerForeNames + " " + o.OwnerSurname o.OwnerAddress = d["Street Address"] o.OwnerTown = d["City"] o.OwnerCounty = d["Province"] o.OwnerPostcode = d["Postal Code"] o.EmailAddress = d["Email"] o.HomeTelephone = d["Phone Number"] o.IsBanned = asm.iif(d["Association"] == "Do Not Adopt", 1, 0) o.IsDonor = asm.iif(d["Association"] == "Donor", 1, 0) o.IsMember = asm.iif(d["Association"] == "Mailing List", 1, 0) o.IsFosterer = asm.iif(d["Association"] == "Foster", 1, 0) o.IsStaff = asm.iif(d["Association"] == "Employee", 1, 0) o.IsVet = asm.iif( d["Association"] == "Operation by" or d["Association"] == "Medical Personnel", 1, 0) o.IsVolunteer = asm.iif(d["Association"] == "Volunteer", 1, 0) o.ExcludeFromBulkEmail = asm.iif(d["Contact By Email"] == "Yes", 1, 0) # Sort the data on intake date ascending for d in sorted(asm.csv_to_list(INTAKE_FILENAME), key=lambda k: getdate(k["Intake Date"], True)): # If it's a repeat of the header row, skip if d["Animal #"] == "Animal #": continue
addresses[a["ADDRESSNO"]] = a residences = {} for r in DBF("%s/RESIDENC.DBF" % PATH): residences[r["PERSONNO"]] = r for p in DBF("%s/PERSON.DBF" % PATH): if p["PERSONNO"] == "New": continue o = asm.Owner() owners.append(o) ppo[p["PERSONNO"]] = o o.OwnerForeNames = p["FIRSTNAME"] o.OwnerSurname = p["LASTNAME"] if p["AGENCY"] != "" and o.OwnerSurname == "": o.OwnerSurname = p["AGENCY"] o.ExcludeFromBulkEmail = asm.iif(p["SENDMAIL"] == "FALSE", 1, 0) if residences.has_key(p["PERSONNO"]): res = residences[p["PERSONNO"]] if addresses.has_key(res["ADDRESSNO"]): ad = addresses[res["ADDRESSNO"]] o.OwnerAddress = "%s %s %s %s" % (ad["STREETNO"], ad["STREETDIR"], ad["STREETNAME"], ad["STREETTYPE"]) o.OwnerTown = ad["CITY"] o.OwnerCounty = ad["STATE"] o.OwnerPostcode = ad["ZIP"].replace("-", "") o.HomeTelephone = p["WORKPHONE"] comments = "No: %s" % p["PERSONNO"] if p["IDTYPE"] != "Unspecified": comments += "\n%s %s" % (p["IDTYPE"], p["IDNUM"]) if p["DOB"] is not None: comments += "\nDOB: %s" % p["DOB"] o.Comments = comments
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"] a.IdentichipNumber = row["ChipId"] if a.IdentichipNumber != "": a.Identichipped = 1 a.Neutered = asm.iif(row["Desex"] == "YES", 1, 0) a.NeuteredDate = getdate(row["DesexDate"]) a.HealthProblems = row["VetNotes"] a.EntryReasonID = 4 a.IsNotAvailableForAdoption = 0 a.ShelterLocation = 1 a.Sex = asm.getsex_mf(row["Sex"]) a.CoatType = getcoattype(row["Hair"]) a.HiddenAnimalDetails = "Breed: %s\nColor: %s\nCollarNo: %s\nHair: %s\nStatus: %s" % ( row["Breed"], row["Color"], row["CollarNo"], row["Hair"], row["Status"]) a.Archived = 0 # Deal with shelter status exitdate = getdate(row["StatusDate"]) if exitdate is None: exitdate = getdate(row["DepartureDate"]) if exitdate is None: exitdate = getdate(row["ArrivalDate"])
a.BreedID = 101 # Greyhound a.Breed2ID = a.BreedID a.BreedName = "Greyhound" a.AnimalName = note_fix(d.dogCallName) if a.AnimalName.strip() == "": a.AnimalName = note_fix(d.dogRegisteredName) if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.DateBroughtIn = d.dogIntakeDate or d.dateAdded a.DateOfBirth = d.dogDateBorn or a.DateBroughtIn a.CreatedDate = d.dateAdded or a.DateBroughtIn a.CreatedBy = d.addedBy or "conversion" a.LastChangedBy = d.modifiedBy or "conversion" a.LastChangedDate = d.dateModified or a.CreatedDate a.generateCode() if d.dogSerialNum and asm.nulltostr(d.dogSerialNum) != "": a.ShortCode = d.dogSerialNum a.Sex = asm.iif(d.dogSex.lower().startswith("m"), 1, 0) a.Neutered = asm.iif( d.dogSex.lower().find("s") != -1 or d.dogSex.lower().find("n") != -1, 1, 0) a.Size = 2 a.Weight = asm.cint(d.dogWeight) a.NeuteredDate = d.dogDateNeutered a.IsGoodWithCats = asm.iif(d.dogWithCats == 1, 0, 1) a.IsGoodWithDogs = asm.iif(d.dogWithDogs == 1, 0, 1) a.IsGoodWithChildren = asm.iif(d.dogWithKids == 1, 0, 1) a.IsHouseTrained = asm.iif(d.dogHousebroken == 1, 0, 1) if d.dogLeftEarNum != "" or d.dogRightEarNum != "": a.Tattoo = 1 a.TattooNumber = "L:%s R:%s" % (d.dogLeftEarNum, d.dogRightEarNum) a.RabiesTag = d.dogRabiesTag a.HeartwormTestDate = d.dogHWTDate
a.AnimalTypeID = 40 # Misc a.SpeciesID = asm.species_id_for_name(d["Species"]) a.AnimalName = d["Name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.DateBroughtIn = getdate(d["Date of Well Check"]) or getdate(d["Adopted Date"]) or getdate(d["Birthday"]) or asm.today() a.DateOfBirth = getdate(d["Birthday"]) or a.DateBroughtIn a.CreatedDate = a.DateBroughtIn a.LastChangedDate = a.DateBroughtIn a.ShelterCode = d["ID"][d["ID"].rfind("-")+1:] a.ShortCode = a.ShelterCode a.BaseColourID = asm.colour_id_for_name(d["Animal Color"]) a.IsNotAvailableForAdoption = 0 a.Sex = asm.getsex_mf(d["Sex"]) a.Size = 2 a.Neutered = asm.iif(d["Spay / Neuter"] == "Yes", 1, 0) a.EntryReasonID = 17 # Surrender a.Archived = 0 a.HiddenAnimalDetails = "Color: %s\nPrevious Name: %s\nBiter: %s\nDiet: %s\n%s" % (d["Animal Color"], d["Previous Name"], d["Biter"], d["Diet"], d["Special Needs"]) a.SourceAdoptedDate = getdate(d["Adopted Date"]) if d["Deceased Date"] != "": a.PutToSleep = 0 a.DeceasedDate = getdate(d["Deceased Date"]) a.Archived = 1 a.PTSReason = d["Deceased Reason"] for d in asm.csv_to_list("%s/relinquishment_contacts.csv" % PATH): o = asm.Owner() owners.append(o) ppo[d["ID"]] = o
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"] a.IdentichipNumber = row["ChipId"] if a.IdentichipNumber != "": a.Identichipped = 1 a.Neutered = asm.iif(row["Desex"] == "YES", 1, 0) a.NeuteredDate = getdate(row["DesexDate"]) a.HealthProblems = row["VetNotes"] a.EntryReasonID = 4 a.IsNotAvailableForAdoption = 0 a.ShelterLocation = 1 a.Sex = asm.getsex_mf(row["Sex"]) a.CoatType = getcoattype(row["Hair"]) a.HiddenAnimalDetails = "Breed: %s\nColor: %s\nCollarNo: %s\nHair: %s\nStatus: %s" % (row["Breed"], row["Color"], row["CollarNo"], row["Hair"], row["Status"]) a.Archived = 0 # Deal with shelter status exitdate = getdate(row["StatusDate"]) if exitdate is None: exitdate = getdate(row["DepartureDate"]) if exitdate is None: exitdate = getdate(row["ArrivalDate"]) if row["Status"] == "PTS": a.PutToSleep = 1
if d.dob is not None: a.DateOfBirth = d.dob elif d.date_of_entry is not None and d.approx_age is not None: a.DateOfBirth = asm.subtract_days(d.date_of_entry, d.approx_age * 365) elif a.DateBroughtIn != DEFAULT_INTAKE_DATE: a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365 * 2) else: a.DateOfBirth = DEFAULT_DATE_OF_BIRTH a.CreatedDate = a.DateBroughtIn a.LastChangedDate = a.DateBroughtIn if d.relinquishment_ownership == 0: a.IsTransfer = 1 a.generateCode() a.IsNotAvailableForAdoption = 0 a.ShelterLocation = asm.location_id_for_name(d.locationname) a.Sex = asm.iif(d.sex == "Dog", 1, 0) a.Size = 2 a.Neutered = 1 a.NeuteredDate = d.neutering_date a.IdentichipNumber = d.microchip_no if a.IdentichipNumber != "": a.Identichipped = 1 if d.left_ear_tattoo != "": a.Tattoo = 1 a.TattooNumber = "L:%s R:%s" % (d.left_ear_tattoo, d.right_ear_tattoo) a.IsGoodWithCats = 2 a.IsGoodWithDogs = 2 a.IsGoodWithChildren = 2 a.HouseTrained = 0 a.Archived = 0 a.EntryReasonID = asm.iif(a.IsTransfer == 1, 15, 17)
if types.find("Foster") != -1: o.IsFosterer = 1 # animals.csv for row in asm.csv_to_list(PATH + "animals.csv"): a = asm.Animal() animals.append(a) ppa[row["id"]] = a a.AnimalName = row["name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.ShortCode = row["code"] a.AnimalTypeID = asm.type_id_for_name(row["species"]) a.SpeciesID = asm.species_id_for_name(row["species"]) a.BreedID = asm.breed_id_for_name(row["primary breed"]) a.Breed2ID = asm.breed_id_for_name(row["secondary breed"]) a.CrossBreed = asm.iif(row["secondary breed"] != "", 1, 0) a.BreedName = asm.breed_name_for_id(a.BreedID) a.BaseColourID = asm.colour_id_for_name(row["primary color"]) a.Sex = asm.getsex_mf(row["sex"]) a.DateBroughtIn = asm.getdate_iso(row["time entered"]) a.DateOfBirth = asm.getdate_iso(row["birth date"]) if a.DateOfBirth is None: a.DateOfBirth = asm.getdate_iso(row["time entered"]) a.NeuteredDate = asm.getdate_iso(row["neutered/spayed date"]) if a.NeuteredDate is not None: a.Neutered = 1 a.Archived = 0 a.IdentichipNumber = row["microchip #"] if a.IdentichipNumber != "": a.Identichipped = 1 a.HiddenAnimalDetails = "Original Breed: %s/%s, Color: %s\n%s" % (row["primary breed"], row["secondary breed"], row["primary color"], row["hidden comments"]) a.AnimalComments = row["general comments"] a.Markings = row["distinctive features"] a.DeceasedDate = asm.getdate_iso(row["date of death"])
ppo[str(row.CustUid)] = o o.OwnerTitle = row.Title o.OwnerSurname = row.LastName if o.OwnerSurname == "": o.OwnerSurname = row.OrgName o.OwnerType = 2 o.OwnerForeNames = row.FirstName o.OwnerAddress = row.Addr1 + " " + row.Addr2 o.OwnerTown = row.City o.OwnerCounty = row.State o.OwnerPostcode = row.Zip o.HomeTelephone = row.Phone1 o.WorkTelephone = row.Phone2 o.MobileTelephone = row.Phone3 o.Comments = row.Comments o.IsACO = asm.iif(row.ACOFlag == "Y", 1, 0) o.IsShelter = asm.iif(row.RescueFlag == "Y", 1, 0) o.IsFosterer = asm.iif(row.FosterFlag == "Y", 1, 0) o.IsMember = asm.iif(row.MailingList == "Y", 1, 0) o.EmailAddress = row.Email # Animals/intake for row in db.query("select animals.*, intake.Comments as IntakeComments, intake.CustUid as IntakeCustUid, " \ "IntakeDTL1, IntakeDTL2, " \ "coalesce((select descr from lookup where value = intake.ReasonCode limit 1), '') AS IntakeReason, " \ "coalesce((select descr from lookup where value = animals.Color limit 1), '') AS ColorName " \ "from animals " \ "left outer join intake on intake.RefUID = animals.IntakeRefUID " \ "order by IntakeDTL1").list(): if str(row.AnimalUid) in ppa:
for d in asm.csv_to_list(PERSON_FILENAME, remove_non_ascii=True): # Each row contains a person o = asm.Owner() owners.append(o) ppo[d["People_Ctr"]] = o o.OwnerForeNames = d["PERSONFIRSTNAME"] o.OwnerSurname = d["PERSONLASTNAME"] o.OwnerName = o.OwnerForeNames + " " + o.OwnerSurname o.OwnerAddress = d["PERSONADDRESS"] o.OwnerTown = d["PERSONCITY"] o.OwnerCounty = d["PERSONSTATE"] o.OwnerPostcode = d["PERSONZIPCODE"] o.EmailAddress = d["PERSONEMAIL"] o.WorkTelephone = d["PERSONWORKPHONE"] o.MobileTelephone = d["PERSONCELLPHONE"] o.IsBanned = asm.iif(d["PERSONFLAGS"].find("Banned") != -1, 1, 0) o.IsDonor = asm.iif(d["PERSONDONOR"] == "1", 1, 0) o.IsFosterer = asm.iif(d["PERSONFOSTERER"] == "1", 1, 0) o.Comments = d["PERSONCOMMENTS"] o.JurisdictionID = asm.jurisdiction_from_db( d["PERSONADDITIONALCOUNCILNAME"]) # Animal intake records for d in asm.csv_to_list(ANIMAL_FILENAME, remove_non_ascii=True): # Each row contains an animal with intake info: a = asm.Animal() animals.append(a) ppa[d["Animal_Identifier"]] = a a.SpeciesID = asm.species_id_for_name(d["Species"]) a.AnimalTypeID = asm.type_id_for_species_id(a.SpeciesID) a.AnimalName = d["Name"]
def process_impound(d, dt): a = asm.Animal() animals.append(a) a.EntryReasonID = 7 # Stray if d["Species"].lower() == "cat": a.AnimalTypeID = 12 # Stray Cat elif d["Species"].lower() == "dog": a.AnimalTypeID = 10 # Stray Dog else: a.AnimalTypeID = 40 # Misc a.SpeciesID = asm.species_id_for_name(d["Species"]) a.AnimalName = d["Animal's Name"].replace("\n", " ") if a.AnimalName == "?" or a.AnimalName.strip() == "": a.AnimalName = "(unknown)" releasedate = getdate(d["Date of Release"]) intakedate = getdate(d["Date of P/U"]) if intakedate is None and releasedate is not None: intakedate = releasedate if intakedate is None: intakedate = dt a.DateBroughtIn = intakedate a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365) a.CreatedDate = a.DateBroughtIn a.LastChangedDate = a.DateBroughtIn a.generateCode() a.Sex = asm.getsex_mf(d["Sex-Altered?"]) a.Size = 2 a.Neutered = asm.iif( d["Sex-Altered?"].lower() == "mn" or d["Sex-Altered?"].lower() == "fs", 1, 0) a.IdentichipNumber = d["Microchip"] if a.IdentichipNumber != "no chip found" and a.IdentichipNumber != "Unable to scan" and a.IdentichipNumber != "no" and a.IdentichipNumber != "": a.Identichipped = 1 asm.breed_ids(a, d["Breed"], default=442) if d["Breed"].lower().find("mix") != -1 or d["Breed"].find("X") != -1: a.CrossBreed = 1 a.Breed2ID = 442 a.HiddenDetails = "Breed: %s\nColor: %s\nCollar: %s\nTags: %s\nMicrochip: %s\n" % ( d["Breed"], d["Color"], d["Collar"], d["Tags"], d["Microchip"]) a.Comments = d["Comments"] # Now create the owner if d["Owner's Name"] != "n/a" and d["Owner's Name"] != "" and d[ "Owner's Name"] != "?" and d[ "Owner's Name"] != "Went to Rescue" and d[ "Owner's Name"] != "unknown" and d["Address"] != "" and d[ "Address"] != "n/a": o = asm.Owner() owners.append(o) name = d["Owner's Name"] lastname = name firstname = "" if name.find(" ") != -1: firstname, lastname = name.split(" ", 1) ppo[name] = o o.OwnerForeNames = firstname o.OwnerSurname = lastname o.OwnerName = "%s, %s" % (lastname, firstname) o.OwnerAddress = d["Address"] o.OwnerTown = "Burnsville" o.OwnerCounty = "MN" o.HomeTelephone = d["Phone #"] # Reclaim if there's a date if releasedate is not None: m = asm.Movement() m.AnimalID = a.ID m.OwnerID = o.ID m.MovementType = 5 m.MovementDate = releasedate a.Archived = 1 a.ActiveMovementID = m.ID a.ActiveMovementType = 5 a.LastChangedDate = m.MovementDate movements.append(m) # Was the animal euthanised? if "Euthanized" in d and d["Euthanized"] == "1": a.DeceasedDate = releasedate or intakedate a.PutToSleep = 1 a.PTSReasonID = 4 a.PTSReason = d["If Euthanized, Why?"] a.Archived = 1 # Is this animal still on shelter? If so, we need to get it off with a fake reclaim if a.Archived == 0: m = asm.Movement() m.AnimalID = a.ID m.OwnerID = uo.ID m.MovementType = 5 m.MovementDate = releasedate or intakedate a.Archived = 1 a.ActiveMovementID = m.ID a.ActiveMovementType = 5 a.LastChangedDate = m.MovementDate movements.append(m)
if row["code"] is None or row["code"] == "": continue if row["primary breed"] is None or row["primary breed"] == "": continue if row["species"] is None or row["species"] == "": continue if row["primary color"] is None or row["primary color"] == "": continue a = asm.Animal() animals.append(a) ppa[row["id"]] = a a.AnimalName = row["name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.ShortCode = row["code"] a.AnimalTypeID = asm.type_id_for_name(row["species"]) a.SpeciesID = asm.species_id_for_name(row["species"]) a.BreedID = asm.breed_id_for_name(row["primary breed"]) a.Breed2ID = asm.breed_id_for_name(row["secondary breed"]) a.CrossBreed = asm.iif(row["secondary breed"] != "", 1, 0) a.BreedName = asm.breed_name_for_id(a.BreedID) a.BaseColourID = asm.colour_id_for_name(row["primary color"]) a.Sex = asm.getsex_mf(row["sex"]) a.DateBroughtIn = asm.getdate_iso(row["time entered"]) if a.DateBroughtIn is None: a.DateBroughtIn = asm.now() a.DateOfBirth = asm.getdate_iso(row["birth date"]) if a.DateOfBirth is None: a.DateOfBirth = asm.getdate_iso(row["time entered"]) if a.DateOfBirth is None: a.DateOfBirth = a.DateBroughtIn a.NeuteredDate = asm.getdate_iso(row["neutered/spayed date"]) if a.NeuteredDate is not None: a.Neutered = 1 a.Archived = 0 a.IdentichipNumber = row["microchip #"] if a.IdentichipNumber != "": a.Identichipped = 1 a.HiddenAnimalDetails = "Original Breed: %s/%s, Color: %s\n%s" % (
for d in asm.csv_to_list(PERSON_FILENAME, remove_non_ascii=True): # Each row contains a person o = asm.Owner() owners.append(o) ppo[d["People_Ctr"]] = o o.OwnerForeNames = d["PERSONFIRSTNAME"] o.OwnerSurname = d["PERSONLASTNAME"] o.OwnerName = o.OwnerForeNames + " " + o.OwnerSurname o.OwnerAddress = d["PERSONADDRESS"] o.OwnerTown = d["PERSONCITY"] o.OwnerCounty = d["PERSONSTATE"] o.OwnerPostcode = d["PERSONZIPCODE"] o.EmailAddress = d["PERSONEMAIL"] o.WorkTelephone = d["PERSONWORKPHONE"] o.MobileTelephone = d["PERSONCELLPHONE"] o.IsBanned = asm.iif(d["PERSONFLAGS"].find("Banned") != -1, 1, 0) o.IsDonor = asm.iif(d["PERSONDONOR"] == "1", 1, 0) o.IsFosterer = asm.iif(d["PERSONFOSTERER"] == "1", 1, 0) o.Comments = d["PERSONCOMMENTS"] o.JurisdictionID = asm.jurisdiction_from_db( d["PERSONADDITIONALCOUNCILNAME"]) # Animal intake records for d in asm.csv_to_list(ANIMAL_FILENAME, remove_non_ascii=True): # Each row contains an animal with intake info: a = asm.Animal() animals.append(a) ppa[d["Animal_Identifier"]] = a a.AnimalTypeID = asm.type_from_db(d["Pound_Reason"]) a.SpeciesID = asm.species_id_for_name(d["Species"]) a.AnimalName = d["Name"]
lastbroughtin = None for d in ccats: # Each row contains an animal with intake info and sometimes outcome a = asm.Animal() animals[d["CatId"]] = a a.AnimalName = d["Name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.DateBroughtIn = asm.getdate_mmddyy(d["IntakeDate"]) if a.DateBroughtIn is None: a.DateBroughtIn = lastbroughtin else: lastbroughtin = a.DateBroughtIn a.BreedID = asm.breed_id_for_name(d["CatBreed"], 261) a.BaseColourID = asm.colour_id_for_name(d["CatColor"]) a.AnimalTypeID = asm.iif(d["OwnerSurrender"] == "1", 11, 12) a.SpeciesID = 2 a.Sex = asm.getsex_mf(d["Sex"]) a.DateOfBirth = asm.getdate_mmddyy(d["DOB"]) if a.DateOfBirth is None: dy = 365 * asm.cint(d["AgeYrs"]) dy += 30 * asm.cint(d["AgeMos"]) dy += 7 * asm.cint(d["AgeWks"]) dy += asm.cint(d["AgeDays"]) a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, dy) a.Neutered = asm.iif(d["SpayOrNeuteredPreviously"] == "1", 1, 0) if a.Neutered == 0: a.Neutered = asm.iif(d["Spay/NeuterDate"] != "", 1, 0) a.NeuteredDate = asm.getdate_mmddyy(d["Spay/NeuterDate"]) a.AnimalComments = d["Comments"] a.IdentichipDate = asm.getdate_mmddyy(d["MicrochipDate"])
lastbroughtin = None for d in ccats: # Each row contains an animal with intake info and sometimes outcome a = asm.Animal() animals[d["CatId"]] = a a.AnimalName = d["Name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" a.DateBroughtIn = asm.getdate_mmddyy(d["IntakeDate"]) if a.DateBroughtIn is None: a.DateBroughtIn = lastbroughtin else: lastbroughtin = a.DateBroughtIn a.BreedID = asm.breed_id_for_name(d["CatBreed"], 261) a.BaseColourID = asm.colour_id_for_name(d["CatColor"]) a.AnimalTypeID = asm.iif(d["OwnerSurrender"] == "1", 11, 12) a.SpeciesID = 2 a.Sex = asm.getsex_mf(d["Sex"]) a.DateOfBirth = asm.getdate_mmddyy(d["DOB"]) if a.DateOfBirth is None: dy = 365 * asm.cint(d["AgeYrs"]) dy += 30 * asm.cint(d["AgeMos"]) dy += 7 * asm.cint(d["AgeWks"]) dy += asm.cint(d["AgeDays"]) a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, dy) a.Neutered = asm.iif(d["SpayOrNeuteredPreviously"] == "1", 1, 0) if a.Neutered == 0: a.Neutered = asm.iif(d["Spay/NeuterDate"] != "", 1, 0) a.NeuteredDate = asm.getdate_mmddyy(d["Spay/NeuterDate"]) a.AnimalComments = d["Comments"] a.IdentichipDate = asm.getdate_mmddyy(d["MicrochipDate"])
for d in asm.csv_to_list(PERSON_FILENAME): # Each row contains a person o = asm.Owner() owners.append(o) ppo[d["ID"]] = o o.OwnerForeNames = d["FirstName"] o.OwnerSurname = d["LastName"] o.OwnerName = o.OwnerForeNames + " " + o.OwnerSurname o.OwnerAddress = "%s %s" % (d["Address1"], d["Address2"]) o.OwnerTown = d["City"] o.OwnerCounty = d["State"] o.OwnerPostcode = d["ZipCode"] o.EmailAddress = d["Email"] o.HomeTelephone = d["Phone1"] o.MobileTelephone = d["Phone2"] o.IsShelter = asm.iif(d["AnimalControlOffice"] == "TRUE", 1, 0) # Animals for d in asm.csv_to_list(ANIMAL_FILENAME): # Each row contains an animal, intake and outcome if ppa.has_key(d["ID"]): a = ppa[d["ID"]] else: a = asm.Animal() animals.append(a) ppa[d["ID"]] = a activeowner = 0 a.EntryReasonID = 17 # Surrender if d["Ownership"] == "Stray": a.EntryReasonID = 7 # Stray if d["Species"] == "Cat": a.AnimalTypeID = 11 # Unwanted Cat
print("DELETE FROM media WHERE ID >= 100;") print("DELETE FROM dbfs WHERE ID >= 200;") pf = asm.petfinder_get_adoptable(PETFINDER_ID) data = asm.csv_to_list(PATH) uo = asm.Owner() uo.OwnerSurname = "Unknown Owner" uo.OwnerName = uo.OwnerSurname owners.append(uo) # petpal files are newest first order for d in reversed(data): a = asm.Animal() animals.append(a) a.AnimalTypeID = asm.iif(d["Pet Type"] == "Cat", 11, 2) if a.AnimalTypeID == 11 and d["Intake Type"] == "Stray": a.AnimalTypeID = 12 a.SpeciesID = asm.species_id_for_name(d["Pet Type"]) a.AnimalName = d["Pet Name"] if a.AnimalName.strip() == "": a.AnimalName = "(unknown)" if d["DOB"].strip() == "": a.DateOfBirth = asm.getdate_mmddyyyy(d["Intake Date"]) a.EstimatedDOB = 1 else: a.DateOfBirth = asm.getdate_mmddyyyy(d["DOB"]) if a.DateOfBirth is None: a.DateOfBirth = asm.today() a.EstimatedDOB = 1 a.DateBroughtIn = asm.getdate_mmddyyyy(d["Intake Date"])
a.AnimalName = "(unknown)" a.DateOfBirth = asm.getdate_yyyymmdd("1900/01/01") a.DateBroughtIn = a.DateOfBirth a.NonShelterAnimal = 1 a.generateCode("A") a.BreedID = asm.breed_from_db(row["Breed"]) a.Breed2ID = asm.breed_from_db(row["Crossbreed type"], 0) a.BreedName = row["Breed"] if row["Crossbreed type"] != "": a.BreedName += " / " + row["Crossbreed type"] a.BaseColourID = asm.colour_from_db(row["Colour"]) a.IdentichipNumber = row["Microchipped Number"] if a.IdentichipNumber != "": a.Identichipped = 1 a.TattooNumber = row["Tattoo Number"] if a.TattooNumber != "": a.Tattoo = 1 a.Neutered = asm.iif(row["Neutered/Spayed"] != "No", 1, 0) a.ShelterLocation = 1 a.Markings = row["Marking"] a.Weight = asm.cint(row["Weight"]) a.Sex = asm.getsex_mf(row["Sex"]) a.Size = asm.size_from_db(row["Size"]) a.CoatType = asm.coattype_from_db(row["Coat Type"]) a.Archived = 1 # the licence ol = asm.OwnerLicence() ownerlicences.append(ol) lt = row["Licence Type"] ol.OwnerID = o.ID ol.AnimalID = a.ID ol.LicenceTypeID = asm.licencetype_from_db(lt)