updating file script
This commit is contained in:
parent
72d26cd834
commit
6e822bf64b
@ -95,21 +95,28 @@ def get_file(vcs_link, commit_hash, is_readme):
|
|||||||
shutil.rmtree(other_temp_path, ignore_errors=True)
|
shutil.rmtree(other_temp_path, ignore_errors=True)
|
||||||
return "KeyError -- the file is not in the commit tree"
|
return "KeyError -- the file is not in the commit tree"
|
||||||
'''
|
'''
|
||||||
print(target_filename)
|
targetfile = ""
|
||||||
for blob in commit0.tree.blobs:
|
for blob in commit0.tree.blobs:
|
||||||
|
#print(type(blob.path))
|
||||||
if "README" in blob.path:
|
if "README" in blob.path:
|
||||||
targetfile = blob
|
targetfile = blob
|
||||||
print(blob.path)
|
#print(blob.path)
|
||||||
# why would a file not be in the commit tree? but would be in the directory?
|
# why would a file not be in the commit tree? but would be in the directory?
|
||||||
#shutil.rmtree(full_temp_path, ignore_errors=True)
|
#shutil.rmtree(full_temp_path, ignore_errors=True)
|
||||||
# return "KeyError -- the file is not in the commit tree"
|
# return "KeyError -- the file is not in the commit tree"
|
||||||
|
if targetfile == "":
|
||||||
|
shutil.rmtree(full_temp_path, ignore_errors=True)
|
||||||
|
shutil.rmtree(other_temp_path, ignore_errors=True)
|
||||||
|
return "KeyError -- the file is not in the commit tree"
|
||||||
|
|
||||||
if is_readme:
|
if is_readme:
|
||||||
last_path = "readme"
|
last_path = "readme"
|
||||||
else:
|
else:
|
||||||
last_path = "contributing"
|
last_path = "contributing"
|
||||||
with open("/data/users/mgaughan/kkex/time_specific_files/" + last_path + "/" + full_temp_path[len(temp_dir):-4] + "_" + last_path + ".md", "w") as file:
|
with open("/data/users/mgaughan/kkex/time_specific_files/" + last_path + "/" + full_temp_path[len(temp_dir):-4] + "_" + targetfile.path , "w") as file:
|
||||||
with io.BytesIO(targetfile.data_stream.read()) as f:
|
with io.BytesIO(targetfile.data_stream.read()) as f:
|
||||||
file.write(f.read().decode('utf-8'))
|
file.write(f.read().decode('utf-8', errors='ignore'))
|
||||||
|
#file.write(f.read())
|
||||||
file.close()
|
file.close()
|
||||||
shutil.rmtree(full_temp_path, ignore_errors=True)
|
shutil.rmtree(full_temp_path, ignore_errors=True)
|
||||||
shutil.rmtree(other_temp_path, ignore_errors=True)
|
shutil.rmtree(other_temp_path, ignore_errors=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user