def get_name_of_file_part(filename, part):
filename, ext = os.path.splitext(filename)
return '__{}_{}{}_part'.format(filename, part, ext)
def split_file_to_parts(filename, parts):
part_size = os.path.getsize(filename) / parts
with open(filename, 'rb') as init_file:
for part in range(parts):
with open('%s%s' % (FILE, part), 'wb') as file_part:
file_part.write(init_file.read(part_size))
ZGVmIGdldF9uYW1lX29mX2ZpbGVfcGFydChmaWxlbmFtZSwgcGFydCk6CiAgICBmaWxlbmFtZSwgZXh0ID0gb3MucGF0aC5zcGxpdGV4dChmaWxlbmFtZSkKICAgIHJldHVybiAnX197fV97fXt9X3BhcnQnLmZvcm1hdChmaWxlbmFtZSwgcGFydCwgZXh0KQoKCmRlZiBzcGxpdF9maWxlX3RvX3BhcnRzKGZpbGVuYW1lLCBwYXJ0cyk6CiAgICBwYXJ0X3NpemUgPSBvcy5wYXRoLmdldHNpemUoZmlsZW5hbWUpIC8gcGFydHMKICAgIHdpdGggb3BlbihmaWxlbmFtZSwgJ3JiJykgYXMgaW5pdF9maWxlOgogICAgICAgIGZvciBwYXJ0IGluIHJhbmdlKHBhcnRzKToKICAgICAgICAgICAgd2l0aCBvcGVuKCclcyVzJyAlIChGSUxFLCBwYXJ0KSwgJ3diJykgYXMgZmlsZV9wYXJ0OgogICAgICAgICAgICAgICAgZmlsZV9wYXJ0LndyaXRlKGluaXRfZmlsZS5yZWFkKHBhcnRfc2l6ZSkp