mirror of
				https://github.com/em-squared/5e-drs.git
				synced 2025-10-31 05:24:20 +00:00 
			
		
		
		
	Cleaning id
This commit is contained in:
		
							parent
							
								
									1aa2a16289
								
							
						
					
					
						commit
						952d9b3a45
					
				
					 1 changed files with 8 additions and 5 deletions
				
			
		|  | @ -10,7 +10,7 @@ from meilisearch import Client | |||
| 
 | ||||
| def pages(): | ||||
|     "return all pages" | ||||
|     for readme in Path('.').glob('**/README.md'): | ||||
|     for readme in Path('../..').glob('**/README.md'): | ||||
|         if readme == Path("README.md"): # it's the home | ||||
|             continue | ||||
|         with open(readme, 'r') as file: | ||||
|  | @ -34,7 +34,8 @@ def pages(): | |||
|             head = yaml.safe_load(head) | ||||
|             body.seek(0) | ||||
|             txt = markdown(body.read()) | ||||
|             yield str(readme), head['title'], txt | ||||
|             # removing ../../, README.md and replace / with _ | ||||
|             yield str(readme)[11:-10].replace("/", "_"), head['title'], txt | ||||
| 
 | ||||
| 
 | ||||
| if __name__ == "__main__": | ||||
|  | @ -43,7 +44,9 @@ if __name__ == "__main__": | |||
|         idx = client.get_index('pages') | ||||
|     except Exception: | ||||
|         client.create_index('pages', dict(primaryKey='path')) | ||||
|     print(idx) | ||||
|         print("the index is created") | ||||
|     else: | ||||
|         print("the index is already here") | ||||
| 
 | ||||
|     for path, title, body in pages(): | ||||
|         client.index('pages').add_documents([{ | ||||
|  | @ -51,4 +54,4 @@ if __name__ == "__main__": | |||
|             'title': title, | ||||
|             'body': body, | ||||
|         }]) | ||||
|         print(title) | ||||
|         print(title, path) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Mathieu Lecarme
						Mathieu Lecarme