text: """
  # QuickEOF_CleanUp.py
  # -------------------
  # Quick'n'Dirty way to parse a c-code repository and fix files to have only a
  # single newline at the end
  """
  
  import os
  
  def parse_folder(file_filter=None):
      """ Parse all filenames in folder recursively """
      if not file_filter:
          file_filter = [""]
  
      def filter_function(file_name):
          """Quick file extention filter helper function"""
          return any([(match in file_name[-4:]) for match in file_filter])
      file_names = []
      exclude = ['.git'] # Exclude .git directory
      for root, dirs, files in os.walk(os.getcwd()):
          dirs[:] = [d for d in dirs if d not in exclude]
          for name in [f for f in files if filter_function(f)]:
              file_names.append(os.path.join(root, name))
      return file_names
  
  def cleanup_file(path):
      """ Perform file cleanup operatoin """
      content = ""
      with open(path, "r") as f:
          content = f.read().rstrip()
      new_content = "\n".join([line.rstrip() for line in content.split("\n")])
      with open(path, "w") as f:
          f.write(new_content + "\n")
  
  
  def main():
      """ Main function"""
      list_of_files = [file_path for file_path in parse_folder([".c", ".h"])]
      print(list_of_files)
      for f in list_of_files:
          cleanup_file(f)
  
  if __name__ == '__main__':
      main()
  