Skip to content

Commit c955fb1

Browse files
committed
Code Style Changes
1 parent 276cfaf commit c955fb1

File tree

3 files changed

+27
-27
lines changed

3 files changed

+27
-27
lines changed

tagstudio/src/core/json_typing.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
11
from typing import TypedDict
22

3-
class Json_Libary(TypedDict("",{"ts-version":str})):
3+
class JsonLibary(TypedDict("",{"ts-version":str})):
44
#"ts-version": str
5-
tags: "list[Json_Tag]"
6-
collations: "list[Json_Collation]"
5+
tags: "list[JsonTag]"
6+
collations: "list[JsonCollation]"
77
fields: list #TODO
8-
macros: "list[Json_Macro]"
9-
entries: "list[Json_Entry]"
8+
macros: "list[JsonMacro]"
9+
entries: "list[JsonEntry]"
1010

11-
class Json_Base(TypedDict):
11+
class JsonBase(TypedDict):
1212
id: int
1313

14-
class Json_Tag(Json_Base,total=False):
14+
class JsonTag(JsonBase,total=False):
1515
name: str
1616
aliases: list[str]
1717
color: str
1818
shorthand: str
1919
subtag_ids: list[int]
2020

21-
class Json_Collation(Json_Base,total=False):
21+
class JsonCollation(JsonBase,total=False):
2222
title: str
2323
e_ids_and_pages: list[list[int]]
2424
sort_order: str
2525
cover_id: int
2626

27-
class Json_Entry(Json_Base,total=False):
27+
class JsonEntry(JsonBase,total=False):
2828
filename: str
2929
path: str
3030
fields: list[dict] #TODO
3131

32-
class Json_Macro(Json_Base,total=False):
32+
class JsonMacro(JsonBase,total=False):
3333
... #TODO

tagstudio/src/core/library.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from enum import Enum
1717
import ujson
1818

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
2020
from src.core import ts_core
2121
from src.core.utils.str import strip_punctuation
2222
from src.core.utils.web import strip_web_protocol
@@ -84,12 +84,12 @@ def __eq__(self, __value: object) -> bool:
8484
and self.path == __value.path
8585
and self.fields == __value.fields)
8686

87-
def compressed_dict(self) -> Json_Entry:
87+
def compressed_dict(self) -> JsonEntry:
8888
"""
8989
An alternative to __dict__ that only includes fields containing
9090
non-default data.
9191
"""
92-
obj: Json_Entry = {
92+
obj: JsonEntry = {
9393
"id": self.id
9494
}
9595
if self.filename:
@@ -199,12 +199,12 @@ def display_name(self, library: 'Library') -> str:
199199
else:
200200
return (f'{self.name}')
201201

202-
def compressed_dict(self) -> Json_Tag:
202+
def compressed_dict(self) -> JsonTag:
203203
"""
204204
An alternative to __dict__ that only includes fields containing
205205
non-default data.
206206
"""
207-
obj: Json_Tag = {
207+
obj: JsonTag = {
208208
"id":self.id
209209
}
210210
if self.name:
@@ -264,12 +264,12 @@ def __eq__(self, __value: object) -> bool:
264264
and self.path == __value.path
265265
and self.fields == __value.fields)
266266

267-
def compressed_dict(self) -> Json_Collation:
267+
def compressed_dict(self) -> JsonCollation:
268268
"""
269269
An alternative to __dict__ that only includes fields containing
270270
non-default data.
271271
"""
272-
obj: Json_Collation = {
272+
obj: JsonCollation = {
273273
"id":self.id
274274
}
275275
if self.title:
@@ -352,7 +352,7 @@ def __init__(self) -> None:
352352
# Map of every Tag ID to the index of the Tag in self.tags.
353353
self._tag_id_to_index_map: dict[int, int] = {}
354354

355-
self.default_tags: list[Json_Tag] = [
355+
self.default_tags: list[JsonTag] = [
356356
{
357357
"id": 0,
358358
"name": "Archived",
@@ -580,12 +580,12 @@ def verify_ts_folders(self) -> None:
580580
if not os.path.isdir(full_collage_path):
581581
os.mkdir(full_collage_path)
582582

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]:
584584
"""
585585
Ensures that the default builtin tags are present in the Library's
586586
save file. Takes in and returns the tag dictionary from the JSON file.
587587
"""
588-
missing: list[Json_Tag] = []
588+
missing: list[JsonTag] = []
589589

590590
for dt in self.default_tags:
591591
if dt['id'] not in [t['id'] for t in tag_list]:
@@ -613,7 +613,7 @@ def open_library(self, path: str) -> int:
613613

614614
try:
615615
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)
617617
self.library_dir = str(path)
618618
self.verify_ts_folders()
619619
major, minor, patch = json_dump['ts-version'].split('.')
@@ -832,7 +832,7 @@ def to_json(self):
832832
Used in saving the library to disk.
833833
"""
834834

835-
file_to_save: Json_Libary = {"ts-version": ts_core.VERSION,
835+
file_to_save: JsonLibary = {"ts-version": ts_core.VERSION,
836836
"ignored_extensions": [],
837837
"tags": [],
838838
"collations": [],
@@ -843,7 +843,7 @@ def to_json(self):
843843

844844
print('[LIBRARY] Formatting Tags to JSON...')
845845

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]
847847

848848
for tag in self.tags:
849849
file_to_save["tags"].append(tag.compressed_dict())

tagstudio/src/qt/ts_qt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4917,15 +4917,15 @@ def __init__(self, library:'Library', driver:'QtDriver'):
49174917
self.scroll_area.setFrameShape(QFrame.Shape.NoFrame)
49184918
self.scroll_area.setWidget(self.scroll_contents)
49194919

4920-
self.Apply_button = QPushButton()
4921-
self.Apply_button.setText('&Apply')
4922-
self.Apply_button.clicked.connect(lambda: self.folders_to_tags(self.library))
4920+
self.apply_button = QPushButton()
4921+
self.apply_button.setText('&Apply')
4922+
self.apply_button.clicked.connect(lambda: self.folders_to_tags(self.library))
49234923

49244924
self.showEvent = self.on_open
49254925

49264926
self.root_layout.addWidget(self.desc_widget)
49274927
self.root_layout.addWidget(self.scroll_area)
4928-
self.root_layout.addWidget(self.Apply_button)
4928+
self.root_layout.addWidget(self.apply_button)
49294929

49304930
def on_open(self,event):
49314931
for i in reversed(range(self.scroll_layout.count())):

0 commit comments

Comments
 (0)