本文整理匯總了Python中fsbc.paths.Paths.str方法的典型用法代碼示例。如果您正苦於以下問題:Python Paths.str方法的具體用法?Python Paths.str怎麽用?Python Paths.str使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類fsbc.paths.Paths
的用法示例。
在下文中一共展示了Paths.str方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: unpack_game_hard_drive
# 需要導入模塊: from fsbc.paths import Paths [as 別名]
# 或者: from fsbc.paths.Paths import str [as 別名]
def unpack_game_hard_drive(self, drive_index, src):
print("unpack_game_hard_drive", drive_index, src)
scheme, dummy, dummy, game_uuid, drive = src.split("/")
drive_prefix = drive + "/"
dir_name = "DH{0}".format(drive_index)
dir_path = os.path.join(self.temp_dir, dir_name)
file_list = self.get_file_list_for_game_uuid(game_uuid)
for file_entry in file_list:
if self.stop_flag:
return
name = file_entry["name"]
if not name.startswith(drive_prefix):
continue
# extract Amiga relative path and convert each path component
# to host file name (where needed).
amiga_rel_path = name[len(drive_prefix):]
print("amiga_rel_path", amiga_rel_path)
amiga_rel_parts = amiga_rel_path.split("/")
for i, part in enumerate(amiga_rel_parts):
# part can be blank if amiga_rel_parts is a directory
# (ending with /)
if part:
amiga_rel_parts[i] = amiga_filename_to_host_filename(part)
amiga_rel_path = "/".join(amiga_rel_parts)
dst_file = os.path.join(dir_path, amiga_rel_path)
print(repr(dst_file))
if name.endswith("/"):
os.makedirs(Paths.str(dst_file))
continue
if not os.path.exists(os.path.dirname(dst_file)):
os.makedirs(os.path.dirname(dst_file))
sha1 = file_entry["sha1"]
# current_task.set_progress(os.path.basename(dst_file))
current_task.set_progress(amiga_rel_path)
self.fsgs.file.copy_game_file("sha1://{0}".format(sha1), dst_file)
# src_file = self.fsgs.file.find_by_sha1(sha1)
# if not os.path.exists(os.path.dirname(dst_file)):
# os.makedirs(os.path.dirname(dst_file))
# stream = self.fsgs.file.open(src_file)
# # archive = Archive(src_file)
# # f = archive.open(src_file)
# data = stream.read()
# assert hashlib.sha1(data).hexdigest() == sha1
# with open(dst_file, "wb") as out_file:
# out_file.write(data)
metadata = ["----rwed", " ", "2000-01-01 00:00:00.00", " ", "",
"\n"]
if "comment" in file_entry:
metadata[4] = self.encode_file_comment(file_entry["comment"])
with open(dst_file + ".uaem", "wb") as out_file:
out_file.write("".join(metadata).encode("UTF-8"))
self.config["hard_drive_{0}".format(drive_index)] = dir_path