Esempio n. 1
0
	def get_photo_from_file(self,filepath):
		fin = open(filepath,'r')
		photos = []
		photo = Photo()
		for line in fin:
			items = line.split(':', 1)
			key = items[0].strip()
			if(len(items)>1):
			    value = items[1].strip()				
			if(key=='ID'):
			    photo = Photo()
			    photo.photoId = value
			if(key=='owner'):
			    photo.ownerId = value
			if(key=='tags'):
			    value = value.split(',')
			    photo.tags = []
			    for v in value:
				    v = v.strip()
				    keep = 0
				    for c in v:
					    if(c>='a' and c<='z' or c>='A' and c<='Z'):
						    keep = 1
					    else:
						    keep = 0
						    break
				    if (keep):
					    photo.tags.append(v)
			if(key=='url'):
				photo.url = value;
			if(key=='datetaken'):
				value = value.split(' ')
				photo.datetaken = value[0].strip();
				if (len(value) > 1):
					photo.timetaken = value[1].strip();
			if(key=='secret'):
				photo.secret = value
			if(key=='farm'):
				photo.farm = value
			if(key=='url_s'):
				photo.url_s = value
			if(key=='url_q'):
				photo.url_q = value
			if(key=='url_t'):
				photo.url_t = value
			if(key=='url_m'):
				photo.url_m = value
			if(key=='url_z'):
				photo.url_z = value
			if(key=='url_b'):
				photo.url_b = value
			
			if(len(key)==0):
			    if(self.is_valid_photo(photo)):
				    photos.append(photo)
		return photos
Esempio n. 2
0
    def getPhotoFromFile(self,filepath):
        fin = open(filepath,'r')
        photo = Photo()
        for line in fin:
            items = line.split(':', 1)
            key = items[0].strip()
            if(len(items)>1):
                value = items[1].strip()				
            if(key=='ID'):
                photo = Photo()
                photo.photoId = value
            if(key=='owner'):
                photo.ownerId = value
            if(key=='tags'):
                value = value.split(',')
                photo.tags = []
                for v in value:
                    v = v.strip()
                    if(len(v)>30):
                        continue;
                    if(v>='a' and v<='z' or v>='A' and v<='Z'):
                        photo.tags.append(v)
            if(key=='url'):
                photo.url = value;
            if(key=='datetaken'):
                value = value.split(' ');
                photo.datetaken = value[0].strip();
                if (len(value) > 1):
                    photo.timetaken = value[1].strip();
                
            if(key=='secret'):
                photo.secret = value
            if(key=='farm'):
                photo.farm = value
            if(key=='url_s'):
                photo.url_s = value
            if(key=='url_q'):
                photo.url_q = value
            if(key=='url_t'):
                photo.url_t = value
            if(key=='url_m'):
                photo.url_m = value
            if(key=='url_z'):
                photo.url_z = value
            if(key=='url_b'):
                photo.url_b = value

        return photo
Esempio n. 3
0
    image_owner_id = gen_owner_id(photos)
    import scipy
    import scipy.io
    data = {}
    data['owners'] = scipy.reshape(scipy.array(image_owner_id), (len(image_owner_id), 1))
    scipy.io.savemat(output_path, data)

def gen_user_list(root, query, photos):
    output_path = "%s/data/extra_info/%s_owners.mat" % (root, query)
    file_io = FileIO()
    file_io.create_folders_for_path(output_path)

    task_gen_image_user_id(query, photos, output_path)
    
if __name__ == "__main__":
    photos = []

    photo = Photo()
    photo.ownerId = 'test_owner_1'
    photos.append(photo)

    photo = Photo()
    photo.ownerId = 'test_owner_2'
    photos.append(photo)

    photo = Photo()
    photo.ownerId = 'test_owner_3'
    photos.append(photo)

    gen_user_list('../../../../test_dir/debug', 'test', photos)