-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_slideshow.py
44 lines (37 loc) · 1.09 KB
/
create_slideshow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class Photo:
"""
Our basic photo object
"""
def __init__(self, orientation=None, num=0, tags=[], ):
self.orientation = orientation
self.num = num
self.tags = tags
def __repr__(self):
return "Photo ({}): {}".format(self.orientation, self.tags)
class Slide:
"""
A collection of ordered photos
"""
def __init__(self, photo1=Photo(), photo2=None):
if photo2 is None:
self.num = [photo1.num]
self.tags = list(photo1.tags)
else:
self.num = [photo1.num, photo2.num]
self.tags = sorted(list(set(photo1.tags + photo2.tags)))
def sort_photos(photos):
"""
Sort photos so verticle photos are paired
"""
slides = []
last_vert = None
for photo in photos:
if photo.orientation == 'H':
slides.append(Slide(photo))
elif photo.orientation == 'V':
if last_vert is None:
last_vert = photo
else:
slides.append(Slide(last_vert, photo))
last_vert = None
return slides