|
@@ -0,0 +1,19 @@
|
|
|
+import os
|
|
|
+import sys
|
|
|
+from service.trunks_service import TrunksService
|
|
|
+
|
|
|
+class FileReader:
|
|
|
+ @staticmethod
|
|
|
+ def find_and_print_split_files(directory):
|
|
|
+ for root, dirs, files in os.walk(directory):
|
|
|
+ for file in files:
|
|
|
+ if file.endswith('.md'):
|
|
|
+ file_path = os.path.join(root, file)
|
|
|
+ relative_path = '\\report\\' + os.path.relpath(file_path, directory)
|
|
|
+ with open(file_path, 'r', encoding='utf-8') as f:
|
|
|
+ content = f.read()
|
|
|
+ TrunksService().create_trunk({'file_path': relative_path, 'content': content,'type':'community_report'})
|
|
|
+
|
|
|
+if __name__ == '__main__':
|
|
|
+ directory = 'e:\\project\\knowledge\\utils\\report'
|
|
|
+ FileReader.find_and_print_split_files(directory)
|