Merge lp://qastaging/~nataliabidart/ubuntuone-control-panel/default-folders into lp://qastaging/ubuntuone-control-panel

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 290
Merged at revision: 287
Proposed branch: lp://qastaging/~nataliabidart/ubuntuone-control-panel/default-folders
Merge into: lp://qastaging/ubuntuone-control-panel
Diff against target: 339 lines (+235/-8)
6 files modified
ubuntuone/controlpanel/logger.py (+2/-4)
ubuntuone/controlpanel/utils/__init__.py (+5/-2)
ubuntuone/controlpanel/utils/linux.py (+59/-0)
ubuntuone/controlpanel/utils/tests/test_linux.py (+101/-1)
ubuntuone/controlpanel/utils/tests/test_windows.py (+41/-0)
ubuntuone/controlpanel/utils/windows.py (+27/-1)
To merge this branch: bzr merge lp://qastaging/~nataliabidart/ubuntuone-control-panel/default-folders
Reviewer Review Type Date Requested Status
dobey (community) Approve
Diego Sarmentero (community) Approve
Brian Curtin (community) Approve
Review via email: mp+97949@code.qastaging.launchpad.net

Commit message

- Implemented a method to list the user's default folders in every platform (part of LP: #933697).

To post a comment you must log in.
Revision history for this message
Brian Curtin (brian.curtin) wrote :

94 + with open(dirs_path) as f:
95 + while True:
96 + line = f.readline()

The file object you get back (f) is already iterable, so you could replace the "while True" with "for line in f"

Other than this it looks alright.

review: Needs Fixing
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

> 94 + with open(dirs_path) as f:
> 95 + while True:
> 96 + line = f.readline()
>
> The file object you get back (f) is already iterable, so you could replace the
> "while True" with "for line in f"
>
> Other than this it looks alright.

Fixed and pushed, great catch! thanks

289. By Natalia Bidart

- Inprove default_folders file content iteration (thanks brian.curtin).

Revision history for this message
dobey (dobey) wrote :

86 + if dirs_path is None:
87 + dirs_path = os.path.join(user_home, '.config', 'user-dirs.dirs')

We probably want to use xdg_config_home from dirspec.basedir here, instead of assuming ~/.config/.

With the suggestion from Brian, you can also drop the if line is None: break check.

Do we need to check that translated names for directories get handled correctly as well here, and ensure that unicode handling doesn't break again? I don't see a test for that case in your tests.

Also, on Windows, for the special folders you check for, which aren't supported on XP for example, how is that error handled? I suppose there should be a test which causes and checks for the error when that happens, to ensure we handle it properly? The linked MSDN page seems to suggest that _MYVIDEO doesn't exist on 5.0 (XP) for example. It might also be worth noting in the comment that if/when we drop XP support, we probably want to switch to _MYDOCUMENTS instead of _PERSONAL for that folder; as the documentation seems to suggest we should do.

review: Needs Fixing
Revision history for this message
Brian Curtin (brian.curtin) wrote :

+1

review: Approve
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
Natalia Bidart (nataliabidart) wrote :

> 86 + if dirs_path is None:
> 87 + dirs_path = os.path.join(user_home, '.config', 'user-dirs.dirs')
>
> We probably want to use xdg_config_home from dirspec.basedir here, instead of
> assuming ~/.config/.

Added.

> With the suggestion from Brian, you can also drop the if line is None: break
> check.

Done already.

> Do we need to check that translated names for directories get handled
> correctly as well here, and ensure that unicode handling doesn't break again?
> I don't see a test for that case in your tests.

Added tests for this.

> Also, on Windows, for the special folders you check for, which aren't
> supported on XP for example, how is that error handled? I suppose there should
> be a test which causes and checks for the error when that happens, to ensure
> we handle it properly? The linked MSDN page seems to suggest that _MYVIDEO
> doesn't exist on 5.0 (XP) for example. It might also be worth noting in the
> comment that if/when we drop XP support, we probably want to switch to
> _MYDOCUMENTS instead of _PERSONAL for that folder; as the documentation seems
> to suggest we should do.

Good catch, made the code more robust and added tests for it.

290. By Natalia Bidart

Better unicode management, and non existent folders.

Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches