6 os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
8 sys.path.append("../sommitrealweird")
10 from django.conf import settings
11 from photo.models import Album, Photo
13 # OK - so we'll name the "album" by the directory name, and that'll be that.
14 # The albums are just going to be straight imports of the directories for now
16 root, dirs, files = os.walk("../media/photos/").next()
19 if Album.objects.filter(slug__exact=dir):
20 print "Already have a %s album, not importing" %(dir,)
25 if os.path.exists("../media/photos/%s/description.txt" %(dir)):
26 album.caption = open("../media/photos/%s/description.txt" %(dir)).read()
29 if os.path.exists("../media/photos/%s/captions.txt" %(dir)):
30 capfh = open("../media/photos/%s/captions.txt" %(dir))
31 line = capfh.readline()
33 fname, value = line.split("\t", 1)
34 captions[fname] = value
35 line = capfh.readline()
36 for file in os.walk("../media/photos/%s/" %(dir)).next()[2]:
37 if file[-4:] == ".jpg":
41 photo.caption = captions[file]
44 photo.image = "photos/%s/%s" %(dir, file)