diff --git a/get_spec_file.py b/get_spec_file.py index 83f22c9..87767c9 100644 --- a/get_spec_file.py +++ b/get_spec_file.py @@ -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)