def __init__(self, path, filename, mediatype) : self.path = path self.filename = filename self.key = os.path.join(path, filename) self.mediatype = mediatype if (cmp(self.mediatype, "image") == 0) : (self.imgtype, self.width, self.height) = ui.get_image_info(self.key) self.imgtype = self.imgtype["name"] self.size = os.path.getsize(self.key) self.size_light = "" self.width_light = "" self.height_light = "" filename_light = common.light_name(self.key) if (os.path.isfile(filename_light)) : self.size_light = os.path.getsize(filename_light) if (cmp(self.mediatype, "image") == 0) : (foo, self.width_light, self.height_light) = ui.get_image_info(filename_light)
def copy_files(light_mode, srcpath, destpath) : entries = os.listdir(srcpath) for entry in entries : entry_with_path = os.path.join(srcpath, entry) if (os.path.isdir(entry_with_path)) : if (entry not in ("tools", "website", ".svn")) : # we exclude tools, website and .svn directories if (cmp(entry[0], ".") != 0) : # we exclude any Linux hidden directory os.mkdir(destpath+"/"+entry) copy_files(light_mode, entry_with_path, destpath+"/"+entry+"/") elif (os.path.isfile(entry_with_path)) : if (cmp(entry[0], ".") != 0) : # we exclude hidden files # by default, we won't add the file copy_file = False (entry_nolast_ext, last_ext) = os.path.splitext(entry) (entry_noexts, ext_inside) = os.path.splitext(entry_nolast_ext) if (cmp(ext_inside, ".light") == 0) : if (light_mode == True) : # a light file is being added only in light mode copy_file = True else : # this is not a 'light' file if (light_mode == False) : copy_file = True else : # in case light mode is 'on' # we have to make sure this file does not have a light file if (os.path.isfile(common.light_name(os.path.join(srcpath, entry))) == False) : copy_file = True if (copy_file == True) : # print "Copying file : " + entry_with_path #print entry_with_path #print destpath+"/"+entry shutil.copy(entry_with_path, destpath+"/"+entry)