write all source codes of blob into a folder

This commit is contained in:
zy 2022-08-02 16:53:32 +08:00
parent c1805e16c3
commit b03ef849db
1 changed files with 7 additions and 6 deletions

View File

@ -30,24 +30,25 @@ def writeSourceCode(dir, code):
file = open(dir, "wb")
file.write(code)
file.close()
return 0
def loadSourceFiles(dir, list):
def writeSourceFiles(dir, list):
"""
function: Write all source code to a new folder
input: the directory of a new folder, the code list in type byte
output: a folder with source files
"""
os.mkdir(dir + "/sourceFiles")
folderpath = os.path.join(dir, "sourceFiles")
os.mkdir(folderpath)
i = 0
for code in list:
writeSourceCode(dir + "/sourceFiles/" + str(i) + ".txt", code)
filepath = os.path.join(folderpath, str(i) + ".java")
writeSourceCode(filepath, code)
i = i + 1
# a test for local repo
list = loadBlobObjects("C:/Users/Administrator/redis")
# list = loadBlobObjects("C:/Users/Administrator/redis")
# print(list[0])
# writeSourceCode("C:/Users/Administrator/redis/1.txt", list[0])
# loadSourceFiles("C:/Users/Administrator/redis", list)
# writeSourceFiles("C:/Users/Administrator/redis", list)