def _report_original_location(self, trashinfo_path): trashinfo = self.file_reader.contents_of(trashinfo_path) try: path = parse_path(trashinfo) except ParseError: self.unable_to_parse_path(trashinfo_path) else: complete_path = os.path.join(self.volume, path) self.out(complete_path, trashinfo_path)
def list_from_volume_trashdir(self, trashdir_path, volume): trashdir = TrashDirReader(self.file_reader) for trashinfo_path in trashdir.list_trashinfo(trashdir_path): trashinfo = self.file_reader.contents_of(trashinfo_path) try: path = parse_path(trashinfo) except ParseError: yield 'unable_to_parse_path', trashinfo_path else: complete_path = os.path.join(volume, path) yield 'trashed_file', (complete_path, trashinfo_path)
def test_how_to_parse_original_path(): assert_equals('foo.txt', parse_path('Path=foo.txt')) assert_equals('/path/to/be/escaped', parse_path('Path=%2Fpath%2Fto%2Fbe%2Fescaped'))
def _report_original_location(self, trashinfo_path): file_reader = FileSystemReader() trashinfo = file_reader.contents_of(trashinfo_path) path = parse_path(trashinfo) complete_path = os.path.join(self.volume, path) self.out(complete_path, trashinfo_path)
def test_how_to_parse_original_path(): assert 'foo.txt' == parse_path('Path=foo.txt') assert '/path/to/be/escaped' == parse_path( 'Path=%2Fpath%2Fto%2Fbe%2Fescaped')