Skip to content

Commit 2eb7507

Browse files
committed
simplify bool conditions
1 parent d5d9cd3 commit 2eb7507

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tagstudio/src/core/library.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1367,17 +1367,17 @@ def search_library(self, query:str=None, entries=True, collations=True,
13671367
query: str = query.strip().lower()
13681368
query_words: list[str] = query.split(' ')
13691369
all_tag_terms: list[str] = []
1370-
only_untagged: bool = True if 'untagged' in query or 'no tags' in query else False
1371-
only_empty: bool = True if 'empty' in query or 'no fields' in query else False
1372-
only_missing: bool = True if 'missing' in query or 'no file' in query else False
1373-
allow_adv: bool = True if 'filename:' in query_words else False
1374-
tag_only: bool = True if 'tag_id:' in query_words else False
1370+
only_untagged: bool = ('untagged' in query or 'no tags' in query)
1371+
only_empty: bool = ('empty' in query or 'no fields' in query)
1372+
only_missing: bool = ('missing' in query or 'no file' in query)
1373+
allow_adv: bool = 'filename:' in query_words
1374+
tag_only: bool = 'tag_id:' in query_words
13751375
if allow_adv:
13761376
query_words.remove('filename:')
13771377
if tag_only:
13781378
query_words.remove('tag_id:')
13791379
# TODO: Expand this to allow for dynamic fields to work.
1380-
only_no_author: bool = True if 'no author' in query or 'no artist' in query else False
1380+
only_no_author: bool = ('no author' in query or 'no artist' in query)
13811381

13821382
# Preprocess the Tag terms.
13831383
if query_words:
@@ -1400,7 +1400,7 @@ def search_library(self, query:str=None, entries=True, collations=True,
14001400
# non_entry_count = 0
14011401
# Iterate over all Entries =============================================================
14021402
for entry in self.entries:
1403-
allowed_ext: bool = False if os.path.splitext(entry.filename)[1][1:].lower() in self.ignored_extensions else True
1403+
allowed_ext: bool = os.path.splitext(entry.filename)[1][1:].lower() not in self.ignored_extensions
14041404
# try:
14051405
# entry: Entry = self.entries[self.file_to_library_index_map[self._source_filenames[i]]]
14061406
# print(f'{entry}')
@@ -1522,7 +1522,7 @@ def search_library(self, query:str=None, entries=True, collations=True,
15221522

15231523
for entry in self.entries:
15241524
added = False
1525-
allowed_ext: bool = False if os.path.splitext(entry.filename)[1][1:].lower() in self.ignored_extensions else True
1525+
allowed_ext: bool = os.path.splitext(entry.filename)[1][1:].lower() not in self.ignored_extensions
15261526
if allowed_ext:
15271527
for f in entry.fields:
15281528
if self.get_field_attr(f, 'type') == 'collation':

0 commit comments

Comments
 (0)