Merge lp:~encukou/picard/move-complete-album-only into lp:~musicbrainz-developers/picard/trunk
- move-complete-album-only
- Merge into trunk
Proposed by
Petr Viktorin
Status: | Needs review |
---|---|
Proposed branch: | lp:~encukou/picard/move-complete-album-only |
Merge into: | lp:~musicbrainz-developers/picard/trunk |
Diff against target: |
250 lines (+77/-37) 5 files modified
picard/file.py (+10/-1) picard/ui/options/moving.py (+3/-0) picard/ui/options/renaming.py (+1/-0) picard/ui/ui_options_moving.py (+19/-9) ui/options_moving.ui (+44/-27) |
To merge this branch: | bzr merge lp:~encukou/picard/move-complete-album-only |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
MusicBrainz Developers | Pending | ||
Review via email: mp+18651@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Unmerged revisions
- 1025. By Petr Viktorin
-
Add option to for move only those files that are in complete albums.
For non-complete albums, the metadata is saved into the file, but files are not moved to the "collection" (move_files_to) folder.
Also fixed tab order in options_moving.ui
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'picard/file.py' | |||
2 | --- picard/file.py 2010-01-11 22:53:17 +0000 | |||
3 | +++ picard/file.py 2010-02-04 23:38:12 +0000 | |||
4 | @@ -209,7 +209,16 @@ | |||
5 | 209 | 209 | ||
6 | 210 | def _make_filename(self, filename, metadata, settings): | 210 | def _make_filename(self, filename, metadata, settings): |
7 | 211 | """Constructs file name based on metadata and file naming formats.""" | 211 | """Constructs file name based on metadata and file naming formats.""" |
9 | 212 | if settings["move_files"]: | 212 | move_file = settings["move_files"] |
10 | 213 | if move_file and settings["move_complete_albums_only"]: | ||
11 | 214 | # Reset the move_file flag if if the album is not complete | ||
12 | 215 | try: | ||
13 | 216 | if not self.tagger.get_album_by_id(metadata['musicbrainz_albumid']).is_complete(): | ||
14 | 217 | move_file = False | ||
15 | 218 | except (IndexError, AttributeError): | ||
16 | 219 | # Something is missing; assume album is not complete | ||
17 | 220 | move_file = False | ||
18 | 221 | if move_file: | ||
19 | 213 | new_dirname = settings["move_files_to"] | 222 | new_dirname = settings["move_files_to"] |
20 | 214 | if not os.path.isabs(new_dirname): | 223 | if not os.path.isabs(new_dirname): |
21 | 215 | new_dirname = os.path.normpath(os.path.join(os.path.dirname(filename), new_dirname)) | 224 | new_dirname = os.path.normpath(os.path.join(os.path.dirname(filename), new_dirname)) |
22 | 216 | 225 | ||
23 | === modified file 'picard/ui/options/moving.py' | |||
24 | --- picard/ui/options/moving.py 2009-01-04 19:08:29 +0000 | |||
25 | +++ picard/ui/options/moving.py 2010-02-04 23:38:12 +0000 | |||
26 | @@ -41,6 +41,7 @@ | |||
27 | 41 | BoolOption("setting", "move_additional_files", False), | 41 | BoolOption("setting", "move_additional_files", False), |
28 | 42 | TextOption("setting", "move_additional_files_pattern", "*.jpg *.png"), | 42 | TextOption("setting", "move_additional_files_pattern", "*.jpg *.png"), |
29 | 43 | BoolOption("setting", "delete_empty_dirs", True), | 43 | BoolOption("setting", "delete_empty_dirs", True), |
30 | 44 | BoolOption("setting", "move_complete_albums_only", False), | ||
31 | 44 | ] | 45 | ] |
32 | 45 | 46 | ||
33 | 46 | def __init__(self, parent=None): | 47 | def __init__(self, parent=None): |
34 | @@ -58,6 +59,7 @@ | |||
35 | 58 | self.ui.move_additional_files_pattern.setText(self.config.setting["move_additional_files_pattern"]) | 59 | self.ui.move_additional_files_pattern.setText(self.config.setting["move_additional_files_pattern"]) |
36 | 59 | self.update_move_additional_files() | 60 | self.update_move_additional_files() |
37 | 60 | self.ui.delete_empty_dirs.setChecked(self.config.setting["delete_empty_dirs"]) | 61 | self.ui.delete_empty_dirs.setChecked(self.config.setting["delete_empty_dirs"]) |
38 | 62 | self.ui.move_complete_albums_only.setChecked(self.config.setting["move_complete_albums_only"]) | ||
39 | 61 | 63 | ||
40 | 62 | 64 | ||
41 | 63 | def check(self): | 65 | def check(self): |
42 | @@ -70,6 +72,7 @@ | |||
43 | 70 | self.config.setting["move_additional_files"] = self.ui.move_additional_files.isChecked() | 72 | self.config.setting["move_additional_files"] = self.ui.move_additional_files.isChecked() |
44 | 71 | self.config.setting["move_additional_files_pattern"] = unicode(self.ui.move_additional_files_pattern.text()) | 73 | self.config.setting["move_additional_files_pattern"] = unicode(self.ui.move_additional_files_pattern.text()) |
45 | 72 | self.config.setting["delete_empty_dirs"] = self.ui.delete_empty_dirs.isChecked() | 74 | self.config.setting["delete_empty_dirs"] = self.ui.delete_empty_dirs.isChecked() |
46 | 75 | self.config.setting["move_complete_albums_only"] = self.ui.move_complete_albums_only.isChecked() | ||
47 | 73 | self.tagger.window.enable_moving_action.setChecked(self.config.setting["move_files"]) | 76 | self.tagger.window.enable_moving_action.setChecked(self.config.setting["move_files"]) |
48 | 74 | 77 | ||
49 | 75 | def move_files_to_browse(self): | 78 | def move_files_to_browse(self): |
50 | 76 | 79 | ||
51 | === modified file 'picard/ui/options/renaming.py' | |||
52 | --- picard/ui/options/renaming.py 2009-10-03 22:28:16 +0000 | |||
53 | +++ picard/ui/options/renaming.py 2010-02-04 23:38:12 +0000 | |||
54 | @@ -80,6 +80,7 @@ | |||
55 | 80 | 'file_naming_format': unicode(self.ui.file_naming_format.toPlainText()), | 80 | 'file_naming_format': unicode(self.ui.file_naming_format.toPlainText()), |
56 | 81 | 'va_file_naming_format': unicode(self.ui.va_file_naming_format.toPlainText()), | 81 | 'va_file_naming_format': unicode(self.ui.va_file_naming_format.toPlainText()), |
57 | 82 | 'move_files_to': os.path.normpath(unicode(self.config.setting["move_files_to"])), | 82 | 'move_files_to': os.path.normpath(unicode(self.config.setting["move_files_to"])), |
58 | 83 | 'move_complete_albums_only': self.config.setting["move_complete_albums_only"], | ||
59 | 83 | } | 84 | } |
60 | 84 | try: | 85 | try: |
61 | 85 | if self.config.setting["enable_tagger_script"]: | 86 | if self.config.setting["enable_tagger_script"]: |
62 | 86 | 87 | ||
63 | === modified file 'picard/ui/ui_options_moving.py' | |||
64 | --- picard/ui/ui_options_moving.py 2009-01-30 20:46:55 +0000 | |||
65 | +++ picard/ui/ui_options_moving.py 2010-02-04 23:38:12 +0000 | |||
66 | @@ -2,8 +2,8 @@ | |||
67 | 2 | 2 | ||
68 | 3 | # Form implementation generated from reading ui file 'ui/options_moving.ui' | 3 | # Form implementation generated from reading ui file 'ui/options_moving.ui' |
69 | 4 | # | 4 | # |
72 | 5 | # Created: Fri Jan 30 21:45:34 2009 | 5 | # Created: Thu Feb 4 00:06:55 2010 |
73 | 6 | # by: PyQt4 UI code generator 4.4.3 | 6 | # by: PyQt4 UI code generator 4.6 |
74 | 7 | # | 7 | # |
75 | 8 | # WARNING! All changes made in this file will be lost! | 8 | # WARNING! All changes made in this file will be lost! |
76 | 9 | 9 | ||
77 | @@ -16,13 +16,13 @@ | |||
78 | 16 | self.gridlayout = QtGui.QGridLayout(MovingOptionsPage) | 16 | self.gridlayout = QtGui.QGridLayout(MovingOptionsPage) |
79 | 17 | self.gridlayout.setObjectName("gridlayout") | 17 | self.gridlayout.setObjectName("gridlayout") |
80 | 18 | spacerItem = QtGui.QSpacerItem(378, 16, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) | 18 | spacerItem = QtGui.QSpacerItem(378, 16, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) |
82 | 19 | self.gridlayout.addItem(spacerItem, 8, 0, 1, 1) | 19 | self.gridlayout.addItem(spacerItem, 9, 0, 1, 1) |
83 | 20 | self.move_additional_files_pattern = QtGui.QLineEdit(MovingOptionsPage) | 20 | self.move_additional_files_pattern = QtGui.QLineEdit(MovingOptionsPage) |
84 | 21 | self.move_additional_files_pattern.setObjectName("move_additional_files_pattern") | 21 | self.move_additional_files_pattern.setObjectName("move_additional_files_pattern") |
86 | 22 | self.gridlayout.addWidget(self.move_additional_files_pattern, 5, 0, 1, 1) | 22 | self.gridlayout.addWidget(self.move_additional_files_pattern, 6, 0, 1, 1) |
87 | 23 | self.move_additional_files = QtGui.QCheckBox(MovingOptionsPage) | 23 | self.move_additional_files = QtGui.QCheckBox(MovingOptionsPage) |
88 | 24 | self.move_additional_files.setObjectName("move_additional_files") | 24 | self.move_additional_files.setObjectName("move_additional_files") |
90 | 25 | self.gridlayout.addWidget(self.move_additional_files, 4, 0, 1, 1) | 25 | self.gridlayout.addWidget(self.move_additional_files, 5, 0, 1, 1) |
91 | 26 | self.hboxlayout = QtGui.QHBoxLayout() | 26 | self.hboxlayout = QtGui.QHBoxLayout() |
92 | 27 | self.hboxlayout.setSpacing(2) | 27 | self.hboxlayout.setSpacing(2) |
93 | 28 | self.hboxlayout.setMargin(0) | 28 | self.hboxlayout.setMargin(0) |
94 | @@ -45,13 +45,23 @@ | |||
95 | 45 | self.move_files.setSizePolicy(sizePolicy) | 45 | self.move_files.setSizePolicy(sizePolicy) |
96 | 46 | self.move_files.setObjectName("move_files") | 46 | self.move_files.setObjectName("move_files") |
97 | 47 | self.gridlayout.addWidget(self.move_files, 1, 0, 1, 1) | 47 | self.gridlayout.addWidget(self.move_files, 1, 0, 1, 1) |
98 | 48 | self.move_complete_albums_only = QtGui.QCheckBox(MovingOptionsPage) | ||
99 | 49 | self.move_complete_albums_only.setObjectName("move_complete_albums_only") | ||
100 | 50 | self.gridlayout.addWidget(self.move_complete_albums_only, 4, 0, 1, 1) | ||
101 | 48 | 51 | ||
102 | 49 | self.retranslateUi(MovingOptionsPage) | 52 | self.retranslateUi(MovingOptionsPage) |
103 | 50 | QtCore.QMetaObject.connectSlotsByName(MovingOptionsPage) | 53 | QtCore.QMetaObject.connectSlotsByName(MovingOptionsPage) |
104 | 54 | MovingOptionsPage.setTabOrder(self.move_files, self.move_files_to) | ||
105 | 55 | MovingOptionsPage.setTabOrder(self.move_files_to, self.move_files_to_browse) | ||
106 | 56 | MovingOptionsPage.setTabOrder(self.move_files_to_browse, self.delete_empty_dirs) | ||
107 | 57 | MovingOptionsPage.setTabOrder(self.delete_empty_dirs, self.move_complete_albums_only) | ||
108 | 58 | MovingOptionsPage.setTabOrder(self.move_complete_albums_only, self.move_additional_files) | ||
109 | 59 | MovingOptionsPage.setTabOrder(self.move_additional_files, self.move_additional_files_pattern) | ||
110 | 51 | 60 | ||
111 | 52 | def retranslateUi(self, MovingOptionsPage): | 61 | def retranslateUi(self, MovingOptionsPage): |
116 | 53 | self.move_additional_files.setText(_("Move additional files:")) | 62 | self.move_additional_files.setText(QtGui.QApplication.translate("MovingOptionsPage", "Move additional files:", None, QtGui.QApplication.UnicodeUTF8)) |
117 | 54 | self.move_files_to_browse.setText(_("Browse...")) | 63 | self.move_files_to_browse.setText(QtGui.QApplication.translate("MovingOptionsPage", "Browse...", None, QtGui.QApplication.UnicodeUTF8)) |
118 | 55 | self.delete_empty_dirs.setText(_("Delete empty directories")) | 64 | self.delete_empty_dirs.setText(QtGui.QApplication.translate("MovingOptionsPage", "Delete empty directories", None, QtGui.QApplication.UnicodeUTF8)) |
119 | 56 | self.move_files.setText(_("Move files to this directory when saving:")) | 65 | self.move_files.setText(QtGui.QApplication.translate("MovingOptionsPage", "Move files to this directory when saving:", None, QtGui.QApplication.UnicodeUTF8)) |
120 | 66 | self.move_complete_albums_only.setText(QtGui.QApplication.translate("MovingOptionsPage", "Move complete albums only", None, QtGui.QApplication.UnicodeUTF8)) | ||
121 | 57 | 67 | ||
122 | 58 | 68 | ||
123 | === modified file 'ui/options_moving.ui' | |||
124 | --- ui/options_moving.ui 2009-01-30 20:46:55 +0000 | |||
125 | +++ ui/options_moving.ui 2010-02-04 23:38:12 +0000 | |||
126 | @@ -1,7 +1,8 @@ | |||
128 | 1 | <ui version="4.0" > | 1 | <?xml version="1.0" encoding="UTF-8"?> |
129 | 2 | <ui version="4.0"> | ||
130 | 2 | <class>MovingOptionsPage</class> | 3 | <class>MovingOptionsPage</class> |
133 | 3 | <widget class="QWidget" name="MovingOptionsPage" > | 4 | <widget class="QWidget" name="MovingOptionsPage"> |
134 | 4 | <property name="geometry" > | 5 | <property name="geometry"> |
135 | 5 | <rect> | 6 | <rect> |
136 | 6 | <x>0</x> | 7 | <x>0</x> |
137 | 7 | <y>0</y> | 8 | <y>0</y> |
138 | @@ -9,13 +10,13 @@ | |||
139 | 9 | <height>563</height> | 10 | <height>563</height> |
140 | 10 | </rect> | 11 | </rect> |
141 | 11 | </property> | 12 | </property> |
144 | 12 | <layout class="QGridLayout" > | 13 | <layout class="QGridLayout"> |
145 | 13 | <item row="8" column="0" > | 14 | <item row="9" column="0"> |
146 | 14 | <spacer> | 15 | <spacer> |
148 | 15 | <property name="orientation" > | 16 | <property name="orientation"> |
149 | 16 | <enum>Qt::Vertical</enum> | 17 | <enum>Qt::Vertical</enum> |
150 | 17 | </property> | 18 | </property> |
152 | 18 | <property name="sizeHint" stdset="0" > | 19 | <property name="sizeHint" stdset="0"> |
153 | 19 | <size> | 20 | <size> |
154 | 20 | <width>378</width> | 21 | <width>378</width> |
155 | 21 | <height>16</height> | 22 | <height>16</height> |
156 | @@ -23,58 +24,74 @@ | |||
157 | 23 | </property> | 24 | </property> |
158 | 24 | </spacer> | 25 | </spacer> |
159 | 25 | </item> | 26 | </item> |
162 | 26 | <item row="5" column="0" > | 27 | <item row="6" column="0"> |
163 | 27 | <widget class="QLineEdit" name="move_additional_files_pattern" /> | 28 | <widget class="QLineEdit" name="move_additional_files_pattern"/> |
164 | 28 | </item> | 29 | </item> |
168 | 29 | <item row="4" column="0" > | 30 | <item row="5" column="0"> |
169 | 30 | <widget class="QCheckBox" name="move_additional_files" > | 31 | <widget class="QCheckBox" name="move_additional_files"> |
170 | 31 | <property name="text" > | 32 | <property name="text"> |
171 | 32 | <string>Move additional files:</string> | 33 | <string>Move additional files:</string> |
172 | 33 | </property> | 34 | </property> |
173 | 34 | </widget> | 35 | </widget> |
174 | 35 | </item> | 36 | </item> |
178 | 36 | <item row="2" column="0" > | 37 | <item row="2" column="0"> |
179 | 37 | <layout class="QHBoxLayout" > | 38 | <layout class="QHBoxLayout"> |
180 | 38 | <property name="spacing" > | 39 | <property name="spacing"> |
181 | 39 | <number>2</number> | 40 | <number>2</number> |
182 | 40 | </property> | 41 | </property> |
184 | 41 | <property name="margin" > | 42 | <property name="margin"> |
185 | 42 | <number>0</number> | 43 | <number>0</number> |
186 | 43 | </property> | 44 | </property> |
187 | 44 | <item> | 45 | <item> |
189 | 45 | <widget class="QLineEdit" name="move_files_to" /> | 46 | <widget class="QLineEdit" name="move_files_to"/> |
190 | 46 | </item> | 47 | </item> |
191 | 47 | <item> | 48 | <item> |
194 | 48 | <widget class="QPushButton" name="move_files_to_browse" > | 49 | <widget class="QPushButton" name="move_files_to_browse"> |
195 | 49 | <property name="text" > | 50 | <property name="text"> |
196 | 50 | <string>Browse...</string> | 51 | <string>Browse...</string> |
197 | 51 | </property> | 52 | </property> |
198 | 52 | </widget> | 53 | </widget> |
199 | 53 | </item> | 54 | </item> |
200 | 54 | </layout> | 55 | </layout> |
201 | 55 | </item> | 56 | </item> |
205 | 56 | <item row="3" column="0" > | 57 | <item row="3" column="0"> |
206 | 57 | <widget class="QCheckBox" name="delete_empty_dirs" > | 58 | <widget class="QCheckBox" name="delete_empty_dirs"> |
207 | 58 | <property name="text" > | 59 | <property name="text"> |
208 | 59 | <string>Delete empty directories</string> | 60 | <string>Delete empty directories</string> |
209 | 60 | </property> | 61 | </property> |
210 | 61 | </widget> | 62 | </widget> |
211 | 62 | </item> | 63 | </item> |
216 | 63 | <item row="1" column="0" > | 64 | <item row="1" column="0"> |
217 | 64 | <widget class="QCheckBox" name="move_files" > | 65 | <widget class="QCheckBox" name="move_files"> |
218 | 65 | <property name="sizePolicy" > | 66 | <property name="sizePolicy"> |
219 | 66 | <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > | 67 | <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> |
220 | 67 | <horstretch>0</horstretch> | 68 | <horstretch>0</horstretch> |
221 | 68 | <verstretch>0</verstretch> | 69 | <verstretch>0</verstretch> |
222 | 69 | </sizepolicy> | 70 | </sizepolicy> |
223 | 70 | </property> | 71 | </property> |
225 | 71 | <property name="text" > | 72 | <property name="text"> |
226 | 72 | <string>Move files to this directory when saving:</string> | 73 | <string>Move files to this directory when saving:</string> |
227 | 73 | </property> | 74 | </property> |
228 | 74 | </widget> | 75 | </widget> |
229 | 75 | </item> | 76 | </item> |
230 | 77 | <item row="4" column="0"> | ||
231 | 78 | <widget class="QCheckBox" name="move_complete_albums_only"> | ||
232 | 79 | <property name="text"> | ||
233 | 80 | <string>Move complete albums only</string> | ||
234 | 81 | </property> | ||
235 | 82 | </widget> | ||
236 | 83 | </item> | ||
237 | 76 | </layout> | 84 | </layout> |
238 | 77 | </widget> | 85 | </widget> |
239 | 86 | <tabstops> | ||
240 | 87 | <tabstop>move_files</tabstop> | ||
241 | 88 | <tabstop>move_files_to</tabstop> | ||
242 | 89 | <tabstop>move_files_to_browse</tabstop> | ||
243 | 90 | <tabstop>delete_empty_dirs</tabstop> | ||
244 | 91 | <tabstop>move_complete_albums_only</tabstop> | ||
245 | 92 | <tabstop>move_additional_files</tabstop> | ||
246 | 93 | <tabstop>move_additional_files_pattern</tabstop> | ||
247 | 94 | </tabstops> | ||
248 | 78 | <resources/> | 95 | <resources/> |
249 | 79 | <connections/> | 96 | <connections/> |
250 | 80 | </ui> | 97 | </ui> |
(as seen on mailing list:)
I've started using Picard, and I really like how I can make a clean collection
directory with the Move Files option. But then I clicked Save on an incomplete
album, which made a bit of a mess there. I think a "Move complete albums only"
option would be nice.
So here's a patch for it :)