Beispiel #1
0
def getspecies(cat, typ):
    if cat == "Dog":
        return 1
    if cat == "Cat":
        return 2
    if typ != "":
        return asm.species_id_for_name(typ)
    else:
        return 1
def getspecies(cat, typ):
    if cat == "Dog":
        return 1
    if cat == "Cat":
        return 2
    if typ != "":
        return asm.species_id_for_name(typ)
    else:
        return 1
Beispiel #3
0
reader = csv.reader(open("cw0243.csv", "r"), dialect="excel")
for row in reader:

    # Not enough data for row
    if row[1].strip() == "": break

    a = asm.Animal(nextid)
    nextid += 1
    comments = ""
    a.ShelterCode = row[CODE]
    a.ShortCode = row[CODE]
    a.AnimalName = row[NAME]
    a.DateOfBirth = getdate(row[DOB])
    a.Sex = getsexmf(row[SEX])
    a.AnimalTypeID = type_id_for_name(row[TYPE])
    a.SpeciesID = asm.species_id_for_name(row[SPECIES])
    a.BreedID = asm.breed_id_for_name(row[BREED])
    if row[CROSSBREED].strip() == "":
        a.Breed2ID = a.BreedID
        a.BreedName = asm.breed_name_for_id(a.BreedID)
        a.CrossBreed = 0
    else:
        a.Breed2ID = asm.breed_id_for_name(row[CROSSBREED])
        a.BreedName = asm.breed_name_for_id(
            a.BreedID) + " / " + asm.breed_name_for_id(a.Breed2ID)
        a.CrossBreed = 1
    a.BaseColourID = asm.colour_id_for_name(row[BASE_COLOR], True)
    a.ShelterLocation = location_id_for_name(row[INTERNAL_LOCATION])
    a.Size = size_id_for_name(row[SIZE])
    a.DateBroughtIn = getdate(row[DATE_IN])
    comments += "Original owner: " + row[ORIGINAL_OWNER]
Beispiel #4
0
 a.AnimalName = d["ANIMALNAME"]
 if a.AnimalName.strip() == "":
     a.AnimalName = "(unknown)"
 if d["SPECIES"] == "Dog":
     # Canine
     a.SpeciesID = 1
     a.AnimalTypeID = 10
     a.EntryReasonID = 11
 elif d["SPECIES"] == "Cat":
     # Feline
     a.SpeciesID = 2
     a.EntryReasonID = 11
     a.AnimalTypeID = 12
 else:
     # Other species
     a.SpeciesID = asm.species_id_for_name(d["SPECIES"])
     a.AnimalTypeID = asm.type_id_for_name(d["SPECIES"])
 a.generateCode()
 a.ShortCode = d["ANIMALNO"]
 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
Beispiel #5
0
 ## type, breed and secondBreed cols that dereference the tables
 typecol = ""
 breedcol = ""
 breed2col = ""
 if row.has_key("type"):
     typecol = row["type"]
     breedcol = row["breed"]
     breed2col = row["secondBreed"]
 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
Beispiel #6
0
    # 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 = getdate(row[DATE])
    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 = strip(row, FORMNUM)
    ob = strip(row, BREEDID)
    a.CrossBreed = 0
    if ob.find("Mix") != -1:
        a.CrossBreed = 1
        a.Breed2ID = 442
        ob = ob.replace("Mix", "")
    a.BreedID = asm.breed_id_for_name(ob)
    a.BreedName = asm.breed_name(a.BreedID, a.Breed2ID)
    a.Sex = getsexmf(row[SEX])
    a.Size = getsize(row[RSIZE])
    a.Neutered = cint(row[SPAYED])
    a.NeuteredDate = getdate(row[SPAYDATE])
    a.DateOfBirth = getdate(row[DOB])
Beispiel #7
0
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"])
    if a.DateBroughtIn is None:
        a.DateBroughtIn = asm.today()
    a.CreatedDate = asm.getdate_mmddyyyy(d["Added On"])
Beispiel #8
0
     a = ppa[d["Animal #"]]
 else:
     a = asm.Animal()
     animals.append(a)
     ppa[d["Animal #"]] = a
     if d["Species"] == "Cat":
         a.AnimalTypeID = 11  # Unwanted Cat
         if d["Intake Type"] == "Stray":
             a.AnimalTypeID = 12  # Stray Cat
     elif d["Species"] == "Dog":
         a.AnimalTypeID = 2  # Unwanted Dog
         if d["Intake Type"] == "Stray":
             a.AnimalTypeID = 10  # Stray Dog
     else:
         a.AnimalTypeID = 40  # Misc
     a.SpeciesID = asm.species_id_for_name(d["Species"])
     a.AnimalName = d["Animal Name"]
     if a.AnimalName.strip() == "":
         a.AnimalName = "(unknown)"
     a.DateBroughtIn = getdate(d["Intake Date"]) or asm.today()
     if "Date Of Birth" in d and d["Date Of Birth"].strip() != "":
         a.DateOfBirth = getdate(d["Date Of Birth"])
     else:
         a.DateOfBirth = asm.subtract_days(a.DateBroughtIn, 365)
     a.CreatedDate = a.DateBroughtIn
     a.LastChangedDate = a.DateBroughtIn
     if d["Intake Type"] == "Transfer In":
         a.IsTransfer = 1
     a.generateCode()
     a.ShortCode = d["ARN"]
     if a.ShortCode.strip() == "": a.ShortCode = d["Animal #"]
ADOPTION_DATE = 22
ADOPTION_FEE = 23
CARD = 24

reader = csv.reader(open("he0272_adopted.csv", "r"), dialect="excel")
for row in reader:

    # Skip the header
    if row[NAME] == "Name": continue

    # Each row contains a new animal, owner and adoption
    a = asm.Animal(nextanimalid)
    animals.append(a)
    nextanimalid += 1
    a.AnimalTypeID = gettype(row[TYPE])
    a.SpeciesID = asm.species_id_for_name(row[TYPE])
    a.AnimalName = row[NAME]
    a.DateOfBirth = getdateage(row[AGE], row[ADOPTION_DATE])
    a.DateBroughtIn = getdate(row[RESCUE_DATE])
    if a.DateBroughtIn == None: a.DateBroughtIn = getdate(row[ADOPTION_DATE])
    if a.DateBroughtIn == None: a.DateBroughtIn = getdate("2012/12/01")
    a.generateCode(gettypeletter(a.AnimalTypeID))
    a.IsNotAvailableForAdoption = 0
    a.ShelterLocation = 1
    a.Sex = getsexmf(row[SEX])
    a.Size = getsize(row[SIZE])
    a.BaseColourID = asm.colour_id_for_name(row[COLOUR], True)
    comments = "Original breed: " + row[BREED] + ", original sex: " + row[
        SEX] + ", original age: " + row[AGE]
    a.BreedID = asm.breed_id_for_name(row[BREED])
    a.Breed2ID = a.BreedID
# 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:
        a = ppa[str(row.AnimalUid)]
    else:
        a = asm.Animal()
        animals.append(a)
        ppa[str(row.AnimalUid)] = a
    a.SpeciesID = asm.species_id_for_name(row.Species)
    if a.SpeciesID == 1 and row.IntakeReason.startswith("Stray"):
        a.AnimalTypeID = 10
    elif a.SpeciesID == 1:
        a.AnimalTypeID = 2
    elif a.SpeciesID == 2 and row.IntakeReason.startswith("Stray"):
        a.AnimalTypeID = 12
    else:
        a.AnimalTypeID = 11
    a.ReasonForEntry = "%s. %s" % (row.IntakeReason, row.IntakeComments)
    a.EntryReasonID = 7 # Stray
    if row.IntakeReason.startswith("Owner"): a.EntryReasonID = 17 # Owner
    asm.breed_ids(a, row.Breed1, row.Breed2)
    a.BaseColourID = asm.colour_id_for_name(row.ColorName, firstWordOnly=True)
    a.Sex = asm.getsex_mf(row.Sex)
    a.generateCode(gettypeletter(a.AnimalTypeID))
Beispiel #11
0
    if types.find("Volunteer") != -1: o.IsVolunteer = 1
    if types.find("Employee") != -1: o.IsStaff = 1
    if types.find("Member") != -1: o.IsMember = 1
    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"])
Beispiel #12
0
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)
Beispiel #13
0
     # Feline
     a.SpeciesID = 2
     if d["SURR_CODE"] == "STR":
         a.EntryReasonID = 11
         a.AnimalTypeID = 12
     else:
         a.AnimalTypeID = 11
 elif d["SPECIES"] == "R":
     # Rabbit
     a.SpeciesID = 7
     a.AnimalTypeID = 13
     if d["SURR_CODE"] == "STR":
         a.EntryReasonID = 11
 else:
     # SPECIES == "O" for other, BREED contains species instead
     a.SpeciesID = asm.species_id_for_name(d["BREED"])
     a.AnimalTypeID = 13  # Miscellaneous
     a.EntryReasonID = 11
 if d["SURR_ID"] != "":
     if d["SURR_ID"] in ppo:
         a.OriginalOwnerID = ppo[d["SURR_ID"]].ID
 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)
Beispiel #14
0
# animals.csv
for row in asm.csv_to_list(PATH + "animals.csv", remove_non_ascii=True):
    if row["name"] is None: continue
    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
Beispiel #15
0
    o.IsVolunteer = asm.cint(row["VOL_IND"])
    o.IsDonor = asm.cint(row["DONOR_IND"])
    o.IsMember = asm.cint(row["MEMBER_IND"])
    o.IsBanned = asm.cint(row["NOADOPT"] == "T" and "1" or "0")
    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"]
Beispiel #16
0
# build intakes map
for row in canimalintakes:
    if row["tblAnimalsID"] not in intakes: intakes[row["tblAnimalsID"]] = row

# animals
asm.stderr("Process 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.DateBroughtIn = DEFAULT_INTAKE_DATE
    irow = None
    if row["tblAnimalsID"] in intakes: irow = intakes[row["tblAnimalsID"]]
    if irow is not None and asm.getdate_mmddyy(
            irow["DateReceived"]) is not None:
        a.DateBroughtIn = asm.getdate_mmddyy(irow["DateReceived"])
    a.DateOfBirth = asm.getdate_mmddyy(row["DateOfBirth"])
    if a.DateOfBirth is None:
        a.DateOfBirth = a.DateBroughtIn
    a.CreatedDate = a.DateBroughtIn
    a.LastChangedDate = a.DateBroughtIn
    a.EntryReasonID = 1
# Load up data files
cadopt = asm.csv_to_list("%s/adoption_list.csv" % PATH, uppercasekeys=True)
cdisp = asm.csv_to_list("%s/disposition.csv" % PATH, uppercasekeys=True)
cmed = asm.csv_to_list("%s/medication_usage.csv" % PATH,
                       uppercasekeys=True,
                       unicodehtml=True)

# Dispositions/animals
for row in cdisp:
    if row["ANIMALUID"] in ppa:
        a = ppa[row["ANIMALUID"]]
    else:
        a = asm.Animal()
        animals.append(a)
        ppa[row["ANIMALUID"]] = a
    a.SpeciesID = asm.species_id_for_name(row["SPECIES"])
    if a.SpeciesID == 1 and row["INTAKE"].startswith("Stray"):
        a.AnimalTypeID = 10
    elif a.SpeciesID == 1:
        a.AnimalTypeID = 2
    elif a.SpeciesID == 2 and row["INTAKE"].startswith("Stray"):
        a.AnimalTypeID = 12
    else:
        a.AnimalTypeID = 11
    a.BreedID = asm.breed_id_for_name(row["PRIMARY BREED"])
    a.BreedName = asm.breed_name_for_id(a.BreedID)
    a.Sex = asm.getsex_mf(row["SEX"])
    a.CrossBreed = 0
    a.generateCode(gettypeletter(a.AnimalTypeID))
    a.ShortCode = row["ANIMALUID"]
    a.AnimalName = row["NAME"]
Beispiel #18
0
ADOPTION_DATE = 22
ADOPTION_FEE = 23
CARD = 24

reader = csv.reader(open("he0272_adopted.csv", "r"), dialect="excel")
for row in reader:

    # Skip the header
    if row[NAME] == "Name": continue

    # Each row contains a new animal, owner and adoption
    a = asm.Animal(nextanimalid)
    animals.append(a)
    nextanimalid += 1
    a.AnimalTypeID = gettype(row[TYPE])
    a.SpeciesID = asm.species_id_for_name(row[TYPE])
    a.AnimalName = row[NAME]
    a.DateOfBirth = getdateage(row[AGE], row[ADOPTION_DATE])
    a.DateBroughtIn = getdate(row[RESCUE_DATE])
    if a.DateBroughtIn == None: a.DateBroughtIn = getdate(row[ADOPTION_DATE])
    if a.DateBroughtIn == None: a.DateBroughtIn = getdate("2012/12/01")
    a.generateCode(gettypeletter(a.AnimalTypeID))
    a.IsNotAvailableForAdoption = 0
    a.ShelterLocation = 1
    a.Sex = getsexmf(row[SEX])
    a.Size = getsize(row[SIZE])
    a.BaseColourID = asm.colour_id_for_name(row[COLOUR], True)
    comments = "Original breed: " + row[BREED] + ", original sex: " + row[SEX] + ", original age: " + row[AGE]
    a.BreedID = asm.breed_id_for_name(row[BREED])
    a.Breed2ID = a.BreedID
    a.BreedName = asm.breed_name_for_id(a.BreedID)
Beispiel #19
0
for d in reversed(asm.csv_to_list("%s/animals.csv" % PATH)):
    if d["id"] == "id": continue  # skip repeated header rows
    if d["id"] in ppa: continue  # skip repeated rows
    a = asm.Animal()
    animals.append(a)
    ppa[d["id"]] = a
    # NB: only really seen dogs
    if d["as_animal_type"] == "Dog":
        animaltype = 2
        animalletter = "D"
    else:
        animaltype = 11
        animalletter = "U"
    a.AnimalTypeID = animaltype
    # There is a species column, but the last file I saw it seemed to be pretty optional and not filled in
    a.SpeciesID = asm.species_id_for_name(d["as_animal_type"])
    a.generateCode()
    a.ShortCode = d["id"]
    a.ShelterCode = d["id"]
    a.AnimalName = d["name"]
    a.AcceptanceNumber = d["litter_id"]
    a.DateBroughtIn = getdate(d["intake_date"])
    if a.DateBroughtIn is None: a.DateBroughtIn = getdate(d["created_at"])
    a.DateOfBirth = getdate(d["birthday"])
    if a.DateOfBirth is None: a.DateOfBirth = a.DateBroughtIn
    a.Sex = 1
    if d["gender"] == "1":  # They use 1 for female, 0 for male
        a.Sex = 0
    a.Size = asm.cint(d["size_when_grown"])
    primary = d["breed"]
    secondary = d["breed_secondary"]
Beispiel #20
0
# Animals
for row in canimal:
    a = asm.Animal()
    animals.append(a)
    ppa[row["ANIMALKEY"]] = a
    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"]
Beispiel #21
0
 ## type, breed and secondBreed cols that dereference the tables
 typecol = ""
 breedcol = ""
 breed2col = ""
 if row.has_key("type"):
     typecol = row["type"]
     breedcol = row["breed"]
     breed2col = row["secondBreed"]
 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:
             print "BOLLOCKS: " + str(row)
 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 < 2015:
         a.Archived = 1
Beispiel #22
0
             encoded = base64.b64encode(jpgdata)
             encodedjpgdata.append(encoded)
             sys.stderr.write("Got image from %s\n" % imageurl)
         except Exception,err:
             sys.stderr.write(str(err) + "\n")
 # Write our SQL
 a = asm.Animal(nextid)
 nextid += 1
 if species.lower().find("cat") != -1:
     animaltype = 11
     animalletter = "U"
 else:
     animaltype = 2
     animalletter = "D"
 a.AnimalTypeID = animaltype
 a.SpeciesID = asm.species_id_for_name(species)
 a.ShelterCode = "PF%s" % petid
 a.ShortCode = a.ShelterCode
 a.AnimalName = name
 dob = broughtin
 if age.find("Baby") != -1:
     dob -= datetime.timedelta(days = 91)
 elif age.find("Young") != -1:
     dob -= datetime.timedelta(days = 182)
 elif age.find("Adult") != -1:
     dob -= datetime.timedelta(days = 730)
 elif age.find("Senior") != -1:
     dob -= datetime.timedelta(days = 2555)
 a.DateOfBirth = dob
 a.EstimatedDOB = 1
 a.Sex = 1