本文整理汇总了Python中util.Util.getFileName方法的典型用法代码示例。如果您正苦于以下问题:Python Util.getFileName方法的具体用法?Python Util.getFileName怎么用?Python Util.getFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Util
的用法示例。
在下文中一共展示了Util.getFileName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: optimizeSubdirectory
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import getFileName [as 别名]
def optimizeSubdirectory(self, path, callback, new_path, extension = "", minimize = False):
"""optimizes a subdirectory within a directory being optimized
Arguments:
path -- path to directory
callback -- function to run the file through
new_path -- path to optimized parent directory
extension -- extension to search for in the directory
minimize -- whether or not we should minimize the file contents (html)
Returns:
void
"""
subdir_path = new_path + "/" + path.split("/").pop()
skip = self.prepareDirectory(subdir_path)
if skip is True:
return
for dir_file in Util.getFilesFromDir(path, extension):
if Util.isDir(dir_file):
self.optimizeSubdirectory(dir_file, callback, subdir_path, extension, minimize)
continue
new_file_path = subdir_path + "/" + Util.getFileName(dir_file)
self.optimizeFile(dir_file, callback, minimize, new_file_path)
示例2: optimizeDirectory
# 需要导入模块: from util import Util [as 别名]
# 或者: from util.Util import getFileName [as 别名]
def optimizeDirectory(self, path, callback, extension = "", minimize = False):
"""optimizes a directory
Arguments:
path -- path to directory
callback -- function to run the file through
extension -- extension to search for in the directory
minimize -- whether or not we should minimize the file contents (html)
Returns:
void
"""
directory = path + "_opt"
skip = self.prepareDirectory(directory)
if skip is True:
return
for dir_file in Util.getFilesFromDir(path, extension):
if Util.isDir(dir_file):
self.optimizeSubdirectory(dir_file, callback, directory, extension, minimize)
continue
new_path = directory + "/" + Util.getFileName(dir_file)
self.optimizeFile(dir_file, callback, minimize, new_path)