Exemplo n.º 1
0
def fileInfo(location, fileName):
	fileLocation = location + "/" + fileName
	fileInfo = basic.getFileInfo(fileLocation)
	string = list()
	for key, value in fileInfo.items():
		if key == "fileLength" : value = basic.humanSize(value)
		string.append(infoKey[key] + " : " + value)
	string = "\n".join(string)
	return string
Exemplo n.º 2
0
    def replace(self, file_name):
        # is it worth to move the result?
        original_size = os.path.getsize(file_name)
        reduced_size = os.path.getsize(self.temp_file)
        self.logCB.debug("Original file (%s) = %s\tReduced file (%s) = %s" %
                         (file_name, humanSize(original_size), self.temp_file,
                          humanSize(reduced_size)))

        if original_size - reduced_size > 0:
            self.msg_end += "Reduced file : %s\n" % (os.path.join(
                os.getcwd(), file_name))
            # move file
            if os.path.exists(file_name):
                os.remove(file_name)
            shutil.move(self.temp_file, file_name)
        else:
            self.msg_end += "Keep original file : %s\n" % (os.path.join(
                os.getcwd(), file_name))
            self.logCB.debug("Delete reduced file")
            # remove result file
            if os.path.exists(self.temp_file):
                os.remove(self.temp_file)
Exemplo n.º 3
0
def analysistr(location, files):
	analyser = rules.Analyser(location, files)
	bytypes = analyser.bytypes
	bylength = analyser.bylength
	types = analyser.types()
	sizeCount = basic.humanSize(analyser.sizeCount())
	fileCount = analyser.fileCount()
	typeCount = len(types)
	message = \
	"""
当前选中的文件共计{0}个;
文件共有{1}种类型,分别为:\n{2}
总大小为:{3}
	""".format(fileCount, typeCount, " ; ".join(types), sizeCount)
	return message.strip()