コード例 #1
0
ファイル: design.py プロジェクト: hsoft/musicguru
    def MoveConflicts(self,with_original = False):
        def do_move(song):
            dest_path = 'conflicts' + song.path[1:-1]
            dest = self.ignore_box.add_path(dest_path)
            song.move(dest, conflict.get_conflicted_name(dest,song.name))

        result = 0
        for song in self.allconflicts:
            try:
                original = song.parent[conflict.get_unconflicted_name(song.name)]
            except KeyError:
                original = None
            if with_original:
                do_move(song)
                result += 1
                if original is not None:
                    do_move(original)
                    result += 1
            else:
                if original is not None:
                    do_move(song)
                    result += 1
                else:
                    song.name = conflict.get_unconflicted_name(song.name)
        return result
コード例 #2
0
ファイル: app.py プロジェクト: hsoft/musicguru
 def SwitchConflictAndOriginal(self, node):
     original_name = get_unconflicted_name(node.name)
     try:
         original = node.parent[original_name]
         old_name = node.name
         original.name = '__switching__'
         node.name = original_name
         original.name = old_name
     except KeyError:
         node.name = original_name
     return original
コード例 #3
0
ファイル: app.py プロジェクト: hsoft/musicguru
 def SwitchConflictAndOriginal(self,node):
     original_name = get_unconflicted_name(node.name)
     try:
         original = node.parent[original_name]
         old_name = node.name
         original.name = '__switching__'
         node.name = original_name
         original.name = old_name
     except KeyError:
         node.name = original_name
     return original
コード例 #4
0
ファイル: design.py プロジェクト: hsoft/musicguru
 def PriorizeConflicts(self):
     #Go through all conflicts and see if their original has a lower priority than theirs
     #If yes, switch them.
     for file in self.allconflicts:
         original_name = conflict.get_unconflicted_name(file.name)
         try:
             original = file.parent[original_name]
             if self.locations.index(original.original.parent_volume) > self.locations.index(file.original.parent_volume):
                 #original has a lower priority
                 old_name = file.name
                 original.name = '__switching__'
                 file.name = original_name
                 original.name = old_name
         except KeyError:
             file.name = original_name
コード例 #5
0
ファイル: fs_utils.py プロジェクト: hsoft/musicguru
def smart_move(items, dest, allow_merge=True):
    """move items into dest by taking care of name conflicts.
    
    It is assumed that every item has an assigned parent.
    Don't include root items in items.
    """
    items = [item for item in items if item.parent not in items]
    for item in [item for item in items if item not in dest]:
        try:
            item.move(dest)
        except fs.AlreadyExistsError:
            merged = False
            if allow_merge:
                dest_item = dest[item.name]
                if dest_item.is_container and item.is_container:
                    smart_move(item, dest_item, True)
                    merged = True
            if not merged:
                item_name = conflict.get_unconflicted_name(item.name)
                item.move(dest, conflict.get_conflicted_name(dest, item_name))