Esempio n. 1
0
 def url_from_target(self, target):
     """Return the best URL for this target (a photo or dir)."""
     dir = basename(abspath(target))
     if not isdir(target):
         dirs_and_ids = [
             di
             for p in utils.paths_from_path_patterns(
                         [target], dirs="if-not-recursive",
                         recursive=False, on_error="yield")
             for di in self._local_photo_dirs_and_ids_from_target(p)
         ]
         if not dirs_and_ids:
             raise PicsError("`%s': no such photo or dir" % target)
         if len(dirs_and_ids) > 1:
             raise PicsError("`%s' ambiguous: identifies %d photos"
                             % (target, len(dirs_and_ids)))
         url = "http://www.flickr.com/photos/%s/%s/"\
               % (self.user, dirs_and_ids[0][1])
     elif not exists(join(target, ".pics")):
         raise PicsError("`%s' is not a pics working copy dir" % path)
     elif re.match(r"\d{4}-\d{2}", dir):
         year, month = dir.split("-")
         url = "http://www.flickr.com/photos/%s/archives/date-posted/%s/%s/calendar/"\
               % (self.user, year, month)
     else:
         url = "http://www.flickr.com/photos/%s/" % self.user
         #raise PicsError("`%s' isn't a pics date dir or photo file or id: "
         #                "can't yet handle that" % target)
     return url
Esempio n. 2
0
 def info(self, path):
     """Dump info (retrieved from flickr) about the identified photos."""
     for p in utils.paths_from_path_patterns([path],
                 dirs="if-not-recursive",
                 recursive=False,
                 on_error="yield"):
         for dir, id in self._local_photo_dirs_and_ids_from_target(p):
             log.debug("dump info for photo", id)
             info = self.api.photos_getInfo(photo_id=id)
             xpprint(info)
Esempio n. 3
0
 def _photo_data_from_paths(self, paths):
     for path in paths:
         if path.startswith("flickr://"):
             for d in self._photo_data_from_url(path):
                 yield d
         else:
             for p in utils.paths_from_path_patterns([path],
                         dirs="if-not-recursive",
                         recursive=False,
                         on_error="yield"):
                 for d in self._photo_data_from_local_path(p):
                     yield d