def test_get_link_target_unicode(self): path = get_data_path("test2.lnk") d = windows.get_link_target(path) self.assertTrue(isinstance(d, text_type)) 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")
def test_get_link_target_unicode(self): path = get_data_path("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")
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: try: link_entries = os.listdir(links) except OSError: link_entries = [] for entry in link_entries: if entry.endswith(".lnk"): try: target = windows.get_link_target(os.path.join( links, entry)) except WindowsError: pass else: if target: # RecentPlaces.lnk resolves # to an empty string for example folders.append(target) # remove duplicated entries filtered = [] for path in folders: if path not in filtered: filtered.append(path) return filtered
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: try: link_entries = os.listdir(links) except OSError: link_entries = [] for entry in link_entries: if entry.endswith(".lnk"): try: target = windows.get_link_target( os.path.join(links, entry)) except WindowsError: pass else: if target: # RecentPlaces.lnk resolves # to an empty string for example folders.append(target) # remove duplicated entries filtered = [] for path in folders: if path not in filtered: filtered.append(path) return filtered
def test_get_link_target_non_exist(self): with self.assertRaises(WindowsError): windows.get_link_target(u"nopenope.lnk")
def test_get_link_target(self): path = get_data_path("test.lnk") d = windows.get_link_target(path) self.assertTrue(isinstance(d, text_type)) self.assertEqual(normalize_path(d), normalize_path(u"C:\Windows\explorer.exe"))
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"))
def test_get_link_target(self): path = get_data_path("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"))