当前位置: 首页>>代码示例>>Python>>正文


Python Photo.tags方法代码示例

本文整理汇总了Python中photo.Photo.tags方法的典型用法代码示例。如果您正苦于以下问题:Python Photo.tags方法的具体用法?Python Photo.tags怎么用?Python Photo.tags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在photo.Photo的用法示例。


在下文中一共展示了Photo.tags方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_photo_from_file

# 需要导入模块: from photo import Photo [as 别名]
# 或者: from photo.Photo import tags [as 别名]
	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
开发者ID:Asperado,项目名称:iconic,代码行数:58,代码来源:photo_builder.py

示例2: getPhotoFromFile

# 需要导入模块: from photo import Photo [as 别名]
# 或者: from photo.Photo import tags [as 别名]
    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
开发者ID:Asperado,项目名称:iconic,代码行数:50,代码来源:photo_dao.py


注:本文中的photo.Photo.tags方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。