def _gen(parent, src_dir): for f in sos.expanded_globs(pjoin(src_dir, "*.txt")): info = _page_info(f) if info: n = info.get("name", f) info["perma_name"] = base = Filename(n).base info["name"] = name = "%s.html" % (base, ) yield GTW.RST.TOP.Page_ReST \ (parent = parent, src_dir = src_dir, ** info)
def _gen (parent, src_dir) : for f in sos.expanded_globs (pjoin (src_dir, "*.txt")) : info = _page_info (f) if info : n = info.get ("name", f) info ["perma_name"] = base = Filename (n).base info ["name"] = name = "%s.html" % (base, ) yield GTW.RST.TOP.Page_ReST \ (parent = parent, src_dir = src_dir, ** info)
def _main (cmd) : font = ImageFont.load_default () color = cmd.color fmt = cmd.format ext = fmt.lower () if ext == "jpeg" : ext = "jpg" holder = cmd.photographer x_off = cmd.x_off y_off = cmd.y_off year = cmd.year i_size = cmd.i_size, cmd.i_size t_size = cmd.t_size, cmd.t_size td = sos.expanded_path (cmd.target_dir) with TFL.temp_dir () as temp_dir : if cmd.add_to_dir : if not sos.path.isdir (td) : print ("Making directory %s" % (td, )) sos.mkdir_p (td) for src in cmd.argv [1:] : src, name = src.split ("=") if not name : name = src name = Filename (name).base imp = sos.path.join (td, "%s_im.%s" % (name, ext)) thp = sos.path.join (td, "%s_th.%s" % (name, ext)) convert_one \ ( src, name, i_size, t_size, holder, year, font, imp, thp , fmt, color, x_off, y_off , temp_dir ) else : td_im = sos.path.join (td, "im") td_th = sos.path.join (td, "th") for x in td_im, td_th : if not sos.path.isdir (x) : print ("Making directory %s" % (x, )) sos.mkdir_p (x) pid = cmd.start_pid for src in sorted (sos.expanded_globs (* cmd.argv [1:])) : pid += 1 name = "%04d.%s" % (pid, ext) imp = sos.path.join (td_im, name) thp = sos.path.join (td_th, name) convert_one \ ( src, name, i_size, t_size, holder, year, font, imp, thp , fmt, color, x_off, y_off , temp_dir )
def _read_entries(self): result = [] images = sorted(sos.expanded_globs(pjoin(self.im_dir, "*.jpg"))) i = 0 for im in images: name = Filename(im).base th = pjoin(self.th_dir, "%s.jpg" % name) if sos.path.exists(th): i += 1 photo = Photo \ ( name = name , number = i , parent = self , src = im ) thumb = photo.thumb = Thumbnail \ ( name = name , number = i , parent = self , photo = photo , src = th ) result.append(photo) self.add_entries(*result)
def _read_entries (self) : result = [] images = sorted (sos.expanded_globs (pjoin (self.im_dir, "*.jpg"))) i = 0 for im in images : name = Filename (im).base th = pjoin (self.th_dir, "%s.jpg" % name) if sos.path.exists (th) : i += 1 photo = Photo \ ( name = name , number = i , parent = self , src = im ) thumb = photo.thumb = Thumbnail \ ( name = name , number = i , parent = self , photo = photo , src = th ) result.append (photo) self.add_entries (* result)