Permalink
Browse files

add option '--output' for image uploading.

Just use it as

./yaploader -a 5 -o XL ~/Desktop/1.jpg | pbcopy

realy useful!
  • Loading branch information...
1 parent 9d4ee10 commit cd40c4a8c245d6f804aaf7ca2919e2e41baa4e08 @bobuk bobuk committed Jun 3, 2012
Showing with 13 additions and 2 deletions.
  1. +13 −2 yaploader
View
15 yaploader
@@ -168,6 +168,9 @@ class CommandUpload:
option_list = [
Option('-a', '--album', type='int', dest='album',
help='Album\'s number (required).', required=True),
+ Option('-o', '--output', type = 'str', dest='output', default='alternate',
+ help="Link output format.", required=False)
+
] + _photo_options
usage = _build_usage(name, option_list, 'files')
@@ -191,8 +194,16 @@ class CommandUpload:
hide_orig=uploader.config.hide_original,
storage_private=uploader.config.storage_private,
)
-
- print 'Photo uploaded: %r' % photo.links['alternate']
+ if not uploader.config.output or uploader.config.output == 'alternate':
+ print 'Photo uploaded: %r' % photo.links['alternate']
@svetlyak40wt
svetlyak40wt Jun 3, 2012

Ok, но лучше тогда и в случае alternate выдавать только URL, без "Photo uploaded:".

+ else:
+ if uploader.config.output in photo.img:
+ print photo.img[uploader.config.output]['href']
+ else:
+ logging.error("This image cannot work with output format `%s'.\nOnly %s." %
@svetlyak40wt
svetlyak40wt Jun 3, 2012

И да, в случае если урла такого нет, то может лучше выводить все что есть, а не только список ключей? Ведь после загрузки хочется хоть какой-то урл получить.

+ (uploader.config.output, ', '.join(photo.img.keys()))
+ )
+ sys.exit(1)
class CommandGetAlbums:

2 comments on commit cd40c4a

@bobuk

This is ask for @svetlyak40wt code-review ;)

@bobuk

Щас всё сделаем :)

Please sign in to comment.