示例#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
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
 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
 def test_get_link_target_non_exist(self):
     with self.assertRaises(WindowsError):
         windows.get_link_target(u"nopenope.lnk")
示例#6
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"))
示例#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
 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
 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))