Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

create_import.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435
  1. from lib.helpers import (
  2. get_attachments_folder_path,
  3. get_document_space,
  4. get_document_space_title,
  5. write_csv,
  6. )
  7. import os
  8. import shutil
  9. def create_import(CONFIG):
  10. rows = []
  11. for current_path, folders, files in os.walk(CONFIG["absolute_starting_path"]):
  12. document_space = get_document_space(CONFIG, current_path)
  13. document_space_title = get_document_space_title(CONFIG, current_path)
  14. attachements_folder_path = get_attachments_folder_path(CONFIG, current_path)
  15. line = {
  16. "documentSpace": document_space,
  17. "documentName": "WebHome",
  18. "documentTitle": document_space_title,
  19. "attachmentsFolderPath": attachements_folder_path,
  20. "documentContent": "{{children/}}",
  21. "pilot": CONFIG["pilot"],
  22. }
  23. rows.append(line)
  24. path = os.path.join(CONFIG["export_directory"], attachements_folder_path)
  25. os.mkdir(path)
  26. if files:
  27. for file in files:
  28. shutil.copy(
  29. os.path.join(current_path, file),
  30. os.path.join(CONFIG["export_directory"], attachements_folder_path),
  31. )
  32. write_csv(f"{CONFIG['export_directory']}/export-pages.csv", CONFIG["fields"], rows)