Skip to content

Commit

Permalink
Resolve #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Lattyware committed Oct 7, 2017
1 parent ca490f0 commit fee87ef
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions unrpa
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ class UnRPA:

index = self.get_index()
total_files = len(index)
for file_number, (item, data) in enumerate(index.items()):
for file_number, (path, data) in enumerate(index.items()):
try:
item_path = item.decode("utf-8")
self.make_directory_structure(os.path.join(self.path, os.path.split(item_path)[0]))
raw_file = self.extract_file(item_path, data, file_number, total_files)
with open(os.path.join(self.path, item_path), "wb") as f:
self.make_directory_structure(os.path.join(self.path, os.path.split(path)[0]))
raw_file = self.extract_file(path, data, file_number, total_files)
with open(os.path.join(self.path, path), "wb") as f:
f.write(raw_file)
except BaseException as e:
if self.continue_on_error:
Expand Down Expand Up @@ -112,10 +111,13 @@ class UnRPA:
if self.version == 3:
index = self.deobfuscate_index(index, key)

if "/" != os.sep:
return {item.replace("/", os.sep): data for item, data in index.items()}
else:
return index
return {self.ensure_str_path(path).replace("/", os.sep): data for path, data in index.items()}

def ensure_str_path(self, key):
try:
return key.decode("utf-8")
except AttributeError:
return key

def detect_version(self):
ext = os.path.splitext(self.archive)[1].lower()
Expand Down

0 comments on commit fee87ef

Please sign in to comment.