author | Rodrigo Campos
<rodrigo@sdfg.com.ar> 2013-08-10 15:01:52 UTC |
committer | Rodrigo Campos
<rodrigo@sdfg.com.ar> 2013-08-13 08:59:22 UTC |
parent | 0d59a5b7b109b6215067d568ff9e58f3a3a795de |
galala | +36 | -30 |
diff --git a/galala b/galala index 1b7a25c..14e0912 100755 --- a/galala +++ b/galala @@ -109,6 +109,37 @@ def new_page(path): add_albums(p) common.page_save(p, path) +def _add_album(page, shortname, title, text): + a = common.Album(shortname) + + a.title = title + if not a.title: + a.title = a.shortname.decode('utf8') + a.text = text + + while True: + img_path = raw_input("Album images path: ") + if os.path.isdir(img_path): + fnames = (img_path + '/' + f + for f in os.listdir(img_path)) + else: + fnames = open(img_path).read().split('\n') + + c = 0 + for fname in sorted(set(fnames)): + fname = os.path.realpath(fname) + if fname.lower().endswith(".jpg"): + i = common.Image(a) + i.realpath = fname + a.images.append(i) + c += 1 + + if c > 0: + break + else: + print 'ERROR: invalid path' + + page.albums.append(a) def add_albums(page): while True: @@ -119,36 +150,11 @@ def add_albums(page): print "ERROR: shortname has invalid characters" continue - a = common.Album(shortname) - - a.title = raw_input("Album title: ").decode('utf8') - if not a.title: - a.title = a.shortname.decode('utf8') - a.text = raw_input("Album text: ").decode('utf8') - - while True: - img_path = raw_input("Album images path: ") - if os.path.isdir(img_path): - fnames = (img_path + '/' + f - for f in os.listdir(img_path)) - else: - fnames = open(img_path).read().split('\n') - - c = 0 - for fname in sorted(set(fnames)): - fname = os.path.realpath(fname) - if fname.lower().endswith(".jpg"): - i = common.Image(a) - i.realpath = fname - a.images.append(i) - c += 1 - - if c > 0: - break - else: - print 'ERROR: invalid path' - - page.albums.append(a) + title = raw_input("Album title: ").decode('utf8') + text = raw_input("Album text: ").decode('utf8') + + _add_album(page, shortname, title, text) + print