本文整理汇总了Python中picard.cluster.Cluster.cluster方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.cluster方法的具体用法?Python Cluster.cluster怎么用?Python Cluster.cluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类picard.cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.cluster方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cluster
# 需要导入模块: from picard.cluster import Cluster [as 别名]
# 或者: from picard.cluster.Cluster import cluster [as 别名]
def cluster(self, objs):
"""Group files with similar metadata to 'clusters'."""
log.debug("Clustering %r", objs)
if len(objs) <= 1 or self.unclustered_files in objs:
files = list(self.unclustered_files.files)
else:
files = self.get_files_from_objects(objs)
for name, artist, files in Cluster.cluster(files, 1.0):
QtCore.QCoreApplication.processEvents()
cluster = self.load_cluster(name, artist)
for file in sorted(files, key=attrgetter('discnumber', 'tracknumber', 'base_filename')):
file.move(cluster)
示例2: cluster
# 需要导入模块: from picard.cluster import Cluster [as 别名]
# 或者: from picard.cluster.Cluster import cluster [as 别名]
def cluster(self, objs):
"""Group files with similar metadata to 'clusters'."""
log.debug("Clustering %r", objs)
if len(objs) <= 1 or self.unmatched_files in objs:
files = list(self.unmatched_files.files)
else:
files = self.get_files_from_objects(objs)
fcmp = lambda a, b: (
cmp(a.discnumber, b.discnumber) or
cmp(a.tracknumber, b.tracknumber) or
cmp(a.base_filename, b.base_filename))
for name, artist, files in Cluster.cluster(files, 1.0):
QtCore.QCoreApplication.processEvents()
cluster = self.load_cluster(name, artist)
for file in sorted(files, fcmp):
file.move(cluster)