本文整理汇总了Python中File.File.RelDir方法的典型用法代码示例。如果您正苦于以下问题:Python File.RelDir方法的具体用法?Python File.RelDir怎么用?Python File.RelDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类File.File
的用法示例。
在下文中一共展示了File.RelDir方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Run
# 需要导入模块: from File import File [as 别名]
# 或者: from File.File import RelDir [as 别名]
def Run(self):
print()
filled_tracks = []
unfilled_tracks = []
##
## Handle Directories (Release Search)
##
if self.Settings.HasDirs():
# here we only link the files to specific dirs
# the next loop then cares about and first makes
# a search in a release cache
idx = 0
for folder in self.Settings.DirList:
#
# figure out the directory entries
#
file_list = os.listdir(folder)
if not file_list:
ePrint(1, self.__ClassName, "Skipping directory " + folder)
continue
ePrint(2, folder, "<-- Linking files")
ePrint(2, "Containing: ", str(file_list) + "\n")
# append them to the FileList
for file_path in file_list:
f = File(os.path.join(folder, file_path))
f.RelDir = folder
f.RelDirIdx = idx
#ePrint(2, "Fileending: ", str(file_list) + "\n")
if f.Type in ["mp3", "flac", "wav", "wave", "ogg"]:
self.Settings.FileList.append(f)
idx += 1
##
## Handle the FileList if existent
##
if self.Settings.HasFiles():
track_list = []
for f in self.Settings.FileList:
#
# at first try to gather some data from the tags, so
# create a track object
#
new_track = Track()
# associate the track with its file and try to read
# some info from the tags
new_track.FileInstance = f
new_track.FillFromFile()
ePrint(1, ColorString(str(new_track.FileInstance.NameBody), "green"), "<-- Try to determine info")
# if a track is fully filled continue with the next
if (new_track.FilledEnough(self.Settings.Pattern)):
ePrint(1, self.__ClassName, "Track is filled enough: " + str(new_track) + "\n")
filled_tracks.append(new_track)
continue
#
# Look in the cache
#
rel_page = None
for t in filled_tracks:
if new_track.FileInstance.RelDir != "" and \
new_track.FileInstance.RelDir == t.FileInstance.RelDir and \
t.Release:
ePrint(2, self.__ClassName, "Using cache")
rel_page = t.Release
break
if not rel_page:
#
# look at chemical if nothing is found in tags or cache
#
# first we check for an explicit searchterm
idx = new_track.FileInstance.RelDirIdx
if idx < len(self.Settings.SearchTermList):
search_term = self.Settings.SearchTermList[idx]
else:
# if we have artist and filename availible set this as searchterm
if new_track.Artist and new_track.Title:
#.........这里部分代码省略.........