コード例 #1
0
def findanimal(furrid=""):
    """ Looks for an animal with the given FuRR ID in the collection
        of animals. If one wasn't found, or the ID given was blank,
        a new animal is added to the collection and returned """

    if furrid.strip() == "":
        a = asm.Animal()
        animals.append(a)
        return a

    for a in animals:
        if a.ExtraID == furrid.strip():
            return a

    a = asm.Animal()
    a.ExtraID = furrid.strip()
    animals.append(a)
    return a
コード例 #2
0
    asm.setid("media", 100)
    asm.setid("dbfs", 200)
    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()
コード例 #3
0
PERS_NOTES = 100
PERS_SOURCE = 101
BEH_BEHAVIOR_INTAKE__DATE = 102
BEH_MADE_ADOPTABLE_DATE = 103

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

    # Skip the header
    if row[GUEST_PIN_ID].startswith("GUEST"): continue

    # Skip some blank rows with no intake date
    if strip(row, GUEST_PIN_INTAKE_DATE) == "": continue

    # Each row contains a new animal, owner, adoption and adoption donation
    a = asm.Animal(nextanimalid)
    animals.append(a)
    nextanimalid += 1
    if nextanimalid == 8151: nextanimalid = 8300 # Avoid manually added records
    a.DateBroughtIn = getdate(row[GUEST_PIN_INTAKE_DATE])
    if a.DateBroughtIn is None:
        a.DateBroughtIn = datetime.datetime.today()    
    a.SpeciesID = getspecies(row[GUEST_DOG])
    a.AnimalTypeID = gettype(row[GUEST_DOG])
    a.AnimalName = row[GUEST_SHELTER_GUEST_NAME]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    a.generateCode(gettypeletter(a.AnimalTypeID))
    a.ShortCode = row[GUEST_PIN_ID]
    a.Sex = getsexmf(row[GUEST_MALE])
    breed = row[GUEST_BREED]
コード例 #4
0
ファイル: org_cw0243_animals.py プロジェクト: wcmars16/asm3
RABIES_LOCATION = 25
HEALTH_PROBLEMS = 26

print "\\set ON_ERROR_STOP\nBEGIN;"

print "DELETE FROM animal WHERE ID >= 2;"
print "DELETE FROM additional WHERE LinkType = 0;"

nextid = 2
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:
コード例 #5
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)