updating file script

This commit is contained in:
Matthew Gaughan 2024-03-29 13:25:52 -05:00
parent 72d26cd834
commit 6e822bf64b

View File

@ -95,21 +95,28 @@ def get_file(vcs_link, commit_hash, is_readme):
shutil.rmtree(other_temp_path, ignore_errors=True)
return "KeyError -- the file is not in the commit tree"
'''
print(target_filename)
targetfile = ""
for blob in commit0.tree.blobs:
#print(type(blob.path))
if "README" in blob.path:
targetfile = blob
print(blob.path)
#print(blob.path)
# why would a file not be in the commit tree? but would be in the directory?
#shutil.rmtree(full_temp_path, ignore_errors=True)
# 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:
last_path = "readme"
else:
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:
file.write(f.read().decode('utf-8'))
file.write(f.read().decode('utf-8', errors='ignore'))
#file.write(f.read())
file.close()
shutil.rmtree(full_temp_path, ignore_errors=True)
shutil.rmtree(other_temp_path, ignore_errors=True)