Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
loadPhoto(), renamePatient(patient,fN,lN), renamePhoto partially done
Browse files Browse the repository at this point in the history
  • Loading branch information
James Cline committed Apr 16, 2012
1 parent 0bd16df commit e2d6b31
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 6 deletions.
54 changes: 54 additions & 0 deletions src/database/fs.py
Expand Up @@ -633,3 +633,57 @@ def loadPhotosetTreatments(self, photoset):
# TODO: error codes
print("could not access: " + directory)
return None

def loadPhoto(self, photo):
"""
Loads the actual photo.
Arguments:
photo: The photo object who's data we want.
Returns:
The image data for the photo.
Throws:
IOError
?
"""
directory = self.generatePhotosetDir(photo.photoset)
if os.path.isdir(directory):
f = open(directory + photo.name)
data = f.read()

return data

def renamePatient(self, patient, firstName, lastName):
uid = patient.uid
fromDirectory = self.generatePatientDir(patient)
toDirectory = self.root + "/" + lastName + ", " + firstName + "#" + str(uid)

if os.path.isdir(toDirectory):
raise Exception

shutil.copytree(fromDirectory, toDirectory)

shutil.rmtree(fromDirectory)


def renamePhoto(self, photo, name):
"""
Renames a photo in the filesystem.
Arguments:
photo: The photo object we want to rename.
name: The new name.
Returns:
N/A
Throws:
Error
"""
directory = self.generatePhotosetDir(photo.photoset)
if os.path.isdir(directory):
shutil.copy(directory + "/" + photo.name, directory + "/" + name)
#shutil.rm

5 changes: 3 additions & 2 deletions src/database/patientstorage.py
Expand Up @@ -142,11 +142,12 @@ def createPatient(self, firstName, lastName, physicians):
self.fsm.addPhysicians(patient, physicians)
return patient

def editName(self, firstName, lastName):
def editName(self, patient, firstName, lastName):
"""
Changes the name of a patient and adjusts it's database entries.
Arguments:
firstName: The first name of the patient.
lastName: The last name of the patient.
Expand All @@ -157,7 +158,7 @@ def editName(self, firstName, lastName):
?
"""
if not self.checkNewFS():
pass
self.fsm.renamePatient(patient, firstName, lastName)

def editPhysicians(self, patient, physicians):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/database/photostorage.py
Expand Up @@ -21,12 +21,12 @@ def __init__(self, dbm, fsm):
self.dbm = dbm
self.fsm = fsm

def getPhotoData(self, phot):
pass
def getPhotoData(self, photo):
return self.fsm.getPhoto(photo)

def renamePhoto(self, phot, toName):
def renamePhoto(self, photo, toName):
pass

def movePhoto(self, phot, toPhotoset):
def movePhoto(self, photo, toPhotoset):
pass

0 comments on commit e2d6b31

Please sign in to comment.