16
16
from enum import Enum
17
17
import ujson
18
18
19
- from src .core .json_typing import Json_Collation , Json_Entry , Json_Libary , Json_Tag
19
+ from src .core .json_typing import JsonCollation , JsonEntry , JsonLibary , JsonTag
20
20
from src .core import ts_core
21
21
from src .core .utils .str import strip_punctuation
22
22
from src .core .utils .web import strip_web_protocol
@@ -84,12 +84,12 @@ def __eq__(self, __value: object) -> bool:
84
84
and self .path == __value .path
85
85
and self .fields == __value .fields )
86
86
87
- def compressed_dict (self ) -> Json_Entry :
87
+ def compressed_dict (self ) -> JsonEntry :
88
88
"""
89
89
An alternative to __dict__ that only includes fields containing
90
90
non-default data.
91
91
"""
92
- obj : Json_Entry = {
92
+ obj : JsonEntry = {
93
93
"id" : self .id
94
94
}
95
95
if self .filename :
@@ -199,12 +199,12 @@ def display_name(self, library: 'Library') -> str:
199
199
else :
200
200
return (f'{ self .name } ' )
201
201
202
- def compressed_dict (self ) -> Json_Tag :
202
+ def compressed_dict (self ) -> JsonTag :
203
203
"""
204
204
An alternative to __dict__ that only includes fields containing
205
205
non-default data.
206
206
"""
207
- obj : Json_Tag = {
207
+ obj : JsonTag = {
208
208
"id" :self .id
209
209
}
210
210
if self .name :
@@ -264,12 +264,12 @@ def __eq__(self, __value: object) -> bool:
264
264
and self .path == __value .path
265
265
and self .fields == __value .fields )
266
266
267
- def compressed_dict (self ) -> Json_Collation :
267
+ def compressed_dict (self ) -> JsonCollation :
268
268
"""
269
269
An alternative to __dict__ that only includes fields containing
270
270
non-default data.
271
271
"""
272
- obj : Json_Collation = {
272
+ obj : JsonCollation = {
273
273
"id" :self .id
274
274
}
275
275
if self .title :
@@ -352,7 +352,7 @@ def __init__(self) -> None:
352
352
# Map of every Tag ID to the index of the Tag in self.tags.
353
353
self ._tag_id_to_index_map : dict [int , int ] = {}
354
354
355
- self .default_tags : list [Json_Tag ] = [
355
+ self .default_tags : list [JsonTag ] = [
356
356
{
357
357
"id" : 0 ,
358
358
"name" : "Archived" ,
@@ -580,12 +580,12 @@ def verify_ts_folders(self) -> None:
580
580
if not os .path .isdir (full_collage_path ):
581
581
os .mkdir (full_collage_path )
582
582
583
- def verify_default_tags (self , tag_list : list [Json_Tag ]) -> list [Json_Tag ]:
583
+ def verify_default_tags (self , tag_list : list [JsonTag ]) -> list [JsonTag ]:
584
584
"""
585
585
Ensures that the default builtin tags are present in the Library's
586
586
save file. Takes in and returns the tag dictionary from the JSON file.
587
587
"""
588
- missing : list [Json_Tag ] = []
588
+ missing : list [JsonTag ] = []
589
589
590
590
for dt in self .default_tags :
591
591
if dt ['id' ] not in [t ['id' ] for t in tag_list ]:
@@ -613,7 +613,7 @@ def open_library(self, path: str) -> int:
613
613
614
614
try :
615
615
with open (os .path .normpath (f'{ path } /{ ts_core .TS_FOLDER_NAME } /ts_library.json' ), 'r' , encoding = 'utf-8' ) as f :
616
- json_dump : Json_Libary = ujson .load (f )
616
+ json_dump : JsonLibary = ujson .load (f )
617
617
self .library_dir = str (path )
618
618
self .verify_ts_folders ()
619
619
major , minor , patch = json_dump ['ts-version' ].split ('.' )
@@ -832,7 +832,7 @@ def to_json(self):
832
832
Used in saving the library to disk.
833
833
"""
834
834
835
- file_to_save : Json_Libary = {"ts-version" : ts_core .VERSION ,
835
+ file_to_save : JsonLibary = {"ts-version" : ts_core .VERSION ,
836
836
"ignored_extensions" : [],
837
837
"tags" : [],
838
838
"collations" : [],
@@ -843,7 +843,7 @@ def to_json(self):
843
843
844
844
print ('[LIBRARY] Formatting Tags to JSON...' )
845
845
846
- file_to_save ['ignored_extensions' ] = [i for i in self .ignored_extensions if i is not '' ]
846
+ file_to_save ['ignored_extensions' ] = [i for i in self .ignored_extensions if i ]
847
847
848
848
for tag in self .tags :
849
849
file_to_save ["tags" ].append (tag .compressed_dict ())
0 commit comments