Exemple #1
0
def getdateage(age, arrivaldate):
    """ Returns a date adjusted for age. Age can be one of
        ADULT, PUPPY, KITTEN, SENIOR """
    d = asm.getdate_yyyymmdd(arrivaldate)
    if d == None: d = datetime.datetime.today()
    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
Exemple #2
0
#!/usr/bin/python

import asm
"""
Import script for Multiple Options SQL Server databases exported to MDB and then CSV

7th September, 2015 - 8th Feb, 2018
"""

PATH = "data/multiops_dm1807"
START_ID = 500
IMPORT_IMAGES = False
ADOPT_LONGER_THAN_DAYS = 0  # All animals on shelter longer than this, auto adopt to unknown owner (default 365)
DEFAULT_INTAKE_DATE = asm.getdate_yyyymmdd("2017/12/31")

owners = []
ownerlicences = []
logs = []
movements = []
animals = []
animalmedicals = []
animalcontrol = []
animalcontrolanimals = []
animalvaccinations = []

ppa = {}
ppo = {}
ppac = {}

intakes = {
}  # map of tblAnimalsID -> tblAnimalIntakesDisposition row for speed processing large tblAnimals
Exemple #3
0
    o.MobileTelephone = row["THIRD_PH"]
    o.IsACO = asm.cint(row["ACO_IND"])
    o.IsStaff = asm.cint(row["STAFF_IND"])
    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")
    o.IsFosterer = asm.cint(row["FOSTERS"])
    o.ExcludeFromBulkEmail = asm.cint(row["MAILINGSAM"])

# 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()
Exemple #4
0
def getdate(s):
    return asm.getdate_yyyymmdd(s)
Exemple #5
0
        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)


# Process licence files
LICENCE_FILES = [
    "20082009", "20102011", "20122013", "20142015", "2016", "2018", "2019"
]
for s in LICENCE_FILES:
    fname = PATH + s + ".csv"
    fdate = asm.getdate_yyyymmdd("%s/01/01" % s[:4])
    asm.stderr("%s / %s" % (fname, fdate))
    for d in asm.csv_to_list(fname):
        process_licence(d, fdate)

# Process impound files
IMPOUND_FILES = ["impound2017", "impound2018", "impound2019"]
for s in IMPOUND_FILES:
    fname = PATH + s + ".csv"
    fdate = asm.getdate_yyyymmdd("%s/01/01" % s[7:])
    asm.stderr("%s / %s" % (fname, fdate))
    for d in asm.csv_to_list(fname):
        process_impound(d, fdate)

# Now that everything else is done, output stored records
for a in animals:
# Set up animal records first
for ca in canimal:
    a = asm.Animal()
    a.Archived = 1
    a.DateBroughtIn = datetime.datetime.today() - datetime.timedelta(days=365)
    animals[ca["animalID"]] = a
    if ca["animalType"] == "C":
        a.SpeciesID = 2
    elif ca["animalType"] == "D":
        a.SpeciesID = 1
    else:
        a.SpeciesID = 7  # X - assume rabbit/misc
    a.AnimalName = ca["nameIfKnown"]
    if a.AnimalName.strip() == "":
        a.AnimalName = "(unknown)"
    a.DateOfBirth = asm.getdate_yyyymmdd(ca["DOB"])
    if a.DateOfBirth is None:
        a.DateOfBirth = asm.getdate_iso(ca["dateEntered"])
    a.EstimatedDOB = ca["DOBisActual"] == "0" and 1 or 0
    a.Sex = 1
    if ca["sex"] == "F": a.Sex = 0
    a.Neutered = 1
    if ca["altered"] == "U": a.Neuteured = 0
    # Find the breed
    if ca["animalType"] == "C":
        b = findin(cacat, "animalID", ca["animalID"], "felineBreedLUID")
        b = findin(clucat, "luid", b, "hoverText")
        if b != "":
            a.BreedID = asm.breed_id_for_name(b)
            a.BreedName = asm.breed_name_for_id(a.BreedID)
    elif ca["animalType"] == "D":
Exemple #7
0
#!/usr/bin/python

import asm
"""
Import script for Multiple Options SQL Server databases exported to MDB and then CSV

7th September, 2015 - 8th Feb, 2018
"""

PATH = "data/multiops_zz1094"
START_ID = 50000
ADOPT_LONGER_THAN_DAYS = 0  # All animals on shelter longer than this, auto adopt to unknown owner (default 365)
DEFAULT_INTAKE_DATE = asm.getdate_yyyymmdd("2017/10/23")

owners = []
ownerlicences = []
logs = []
movements = []
animals = []
animalmedicals = []
animalcontrol = []
animalcontrolanimals = []
animalvaccinations = []

ppa = {}
ppo = {}
ppac = {}
addresses = {}
addrlink = {}

asm.setid("animal", START_ID)
    # next the animal, use name, sex and breed as a triplet key
    animalkey = row["Name"] + row["Specie"] + row["Breed"] + row["Sex"] + row[
        "Surname"] + row["Forename"] + row["Address #"]
    if ppa.has_key(animalkey):
        a = ppa[animalkey]
    else:
        a = asm.Animal()
        animals.append(a)
        ppa[animalkey] = a
        a.AnimalTypeID = 13  # Autre/Other
        a.SpeciesID = asm.species_from_db(row["Specie"])
        a.AnimalName = row["Name"]
        if a.AnimalName.strip() == "":
            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