コード例 #1
0
def _get_win_favorites():
    """Returns a list of paths for commonly used directories.

    e.g. My Music, Desktop etc.
    """

    assert os.name == "nt"

    folders = []

    funcs = [windows.get_desktop_dir, windows.get_personal_dir,
             windows.get_music_dir]

    for func in funcs:
        path = func()
        if path is not None:
            folders.append(path)

    # try to extract the favorites listed in explorer and add them
    # if not already present
    links = windows.get_links_dir()
    if links is not None:
        for entry in os.listdir(links):
            if entry.endswith(".lnk"):
                target = windows.get_link_target(os.path.join(links, entry))
                if target is not None:
                    folders.append(target)

    # remove duplicated entries
    filtered = []
    for path in folders:
        if path not in filtered:
            filtered.append(path)

    return filtered
コード例 #2
0
ファイル: filesel.py プロジェクト: Konzertheld/quodlibet
def _get_win_favorites():
    """Returns a list of paths for commonly used directories.

    e.g. My Music, Desktop etc.
    """

    assert os.name == "nt"

    folders = []

    funcs = [windows.get_desktop_dir, windows.get_personal_dir,
             windows.get_music_dir]

    for func in funcs:
        path = func()
        if path is not None:
            folders.append(path)

    # try to extract the favorites listed in explorer and add them
    # if not already present
    links = windows.get_links_dir()
    if links is not None:
        for entry in os.listdir(links):
            if entry.endswith(".lnk"):
                target = windows.get_link_target(os.path.join(links, entry))
                if target is not None:
                    folders.append(target)

    # remove duplicated entries
    filtered = []
    for path in folders:
        if path not in filtered:
            filtered.append(path)

    return filtered
コード例 #3
0
ファイル: test_windows.py プロジェクト: funkyfuture/quodlibet
 def test_get_link_target_unicode(self):
     path = os.path.join(DATA_DIR, "test2.lnk")
     d = windows.get_link_target(path)
     self.assertTrue(isinstance(d, unicode))
     if is_wine():
         # wine doesn't support unicode paths here..
         self.assertEqual(os.path.basename(d), u"\xe1??.txt")
     else:
         self.assertEqual(os.path.basename(d), u"\xe1\U00016826.txt")
コード例 #4
0
 def test_get_link_target_unicode(self):
     path = os.path.join(DATA_DIR, "test2.lnk")
     d = windows.get_link_target(path)
     self.assertTrue(isinstance(d, unicode))
     if is_wine():
         # wine doesn't support unicode paths here..
         self.assertEqual(os.path.basename(d), u"\xe1??.txt")
     else:
         self.assertEqual(os.path.basename(d), u"\xe1\U00016826.txt")
コード例 #5
0
ファイル: test_windows.py プロジェクト: funkyfuture/quodlibet
 def test_get_link_target_non_exist(self):
     with self.assertRaises(WindowsError):
         windows.get_link_target(u"nopenope.lnk")
コード例 #6
0
ファイル: test_windows.py プロジェクト: funkyfuture/quodlibet
 def test_get_link_target(self):
     path = os.path.join(DATA_DIR, "test.lnk")
     d = windows.get_link_target(path)
     self.assertTrue(isinstance(d, unicode))
     self.assertEqual(
         normalize_path(d), normalize_path(u"C:\Windows\explorer.exe"))
コード例 #7
0
 def test_get_link_target_non_exist(self):
     with self.assertRaises(WindowsError):
         windows.get_link_target(u"nopenope.lnk")
コード例 #8
0
 def test_get_link_target(self):
     path = os.path.join(DATA_DIR, "test.lnk")
     d = windows.get_link_target(path)
     self.assertTrue(isinstance(d, unicode))
     self.assertEqual(normalize_path(d),
                      normalize_path(u"C:\Windows\explorer.exe"))
コード例 #9
0
ファイル: test_windows.py プロジェクト: brunob/quodlibet
 def test_get_link_target_latin1(self):
     path = os.path.join(DATA_DIR, "test2.lnk")
     d = windows.get_link_target(path)
     # the second char is only not in latin-1
     self.assertEqual(os.path.basename(d), u"\xe1??.txt")
     self.assertTrue(isinstance(d, unicode))
コード例 #10
0
ファイル: test_windows.py プロジェクト: thisfred/quodlibet
 def test_get_link_target_latin1(self):
     path = os.path.join(DATA_DIR, "test2.lnk")
     d = windows.get_link_target(path)
     # the second char is only not in latin-1
     self.assertEqual(os.path.basename(d), u"\xe1??.txt")
     self.assertTrue(isinstance(d, unicode))