fix: tag export functionality
This commit is contained in:
		
							parent
							
								
									2209fbeb54
								
							
						
					
					
						commit
						c42ee2eb28
					
				
					 4 changed files with 18 additions and 17 deletions
				
			
		
							
								
								
									
										
											BIN
										
									
								
								db/eolas.db
									
										
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								db/eolas.db
									
										
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										26
									
								
								setup.py
									
										
									
									
									
								
							
							
						
						
									
										26
									
								
								setup.py
									
										
									
									
									
								
							|  | @ -1,14 +1,14 @@ | |||
| from setuptools import find_packages, setup | ||||
| # from setuptools import find_packages, setup | ||||
| 
 | ||||
| setup( | ||||
|     name="eolas-db", | ||||
|     version="0.1", | ||||
|     packages=find_packages(where="src"), | ||||
|     package_dir={"": "src"}, | ||||
|     install_requires=["python-frontmatter", "termcolor"], | ||||
|     entry_points={ | ||||
|         "console_scripts": [ | ||||
|             "eolas-db=cli:main", | ||||
|         ], | ||||
|     }, | ||||
| ) | ||||
| # setup( | ||||
| #     name="eolas-db", | ||||
| #     version="0.1", | ||||
| #     packages=find_packages(where="src"), | ||||
| #     package_dir={"": "src"}, | ||||
| #     install_requires=["python-frontmatter", "termcolor"], | ||||
| #     entry_points={ | ||||
| #         "console_scripts": [ | ||||
| #             "eolas-db=cli:main", | ||||
| #         ], | ||||
| #     }, | ||||
| # ) | ||||
|  |  | |||
|  | @ -21,7 +21,6 @@ class DatabaseService: | |||
|                 print(colored("INFO Created database directory", "blue")) | ||||
|             self.connection = sqlite3.connect(f"{self.db_path}/{self.db_name}.db") | ||||
|             self.connection.execute("PRAGMA foreign_keys = ON") | ||||
|             print(colored("INFO Database connection established", "blue")) | ||||
|             return self.connection | ||||
| 
 | ||||
|         except Exception as e: | ||||
|  |  | |||
|  | @ -1,3 +1,5 @@ | |||
| import json | ||||
| 
 | ||||
| from services.sqlite_service import SqliteService | ||||
| 
 | ||||
| 
 | ||||
|  | @ -7,12 +9,12 @@ class TagService(SqliteService): | |||
| 
 | ||||
|     def __retrieve_entries_for_tag(self, tag): | ||||
|         entries = self._query("SELECT * FROM entries_tags WHERE tag_name = ?", (tag,)) | ||||
|         return sorted([entry[0] for entry in entries]) | ||||
|         return sorted([entry[0] for entry in entries], key=str.lower) | ||||
| 
 | ||||
|     def export_tags(self): | ||||
|         tags = self._query("SELECT * FROM tags") | ||||
|         tags = sorted([tag[0] for tag in tags]) | ||||
|         tags = sorted([tag[0] for tag in tags], key=str.lower) | ||||
|         tag_dict = {} | ||||
|         for tag in tags: | ||||
|             tag_dict[tag] = self.__retrieve_entries_for_tag(tag) | ||||
|         return tag_dict | ||||
|         print(json.dumps(tag_dict)) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 thomasabishop
						thomasabishop