Skip to content

Commit

Permalink
format with black
Browse files Browse the repository at this point in the history
  • Loading branch information
NiNiyas committed Oct 30, 2023
1 parent c3ec62b commit 0e99763
Show file tree
Hide file tree
Showing 9 changed files with 1,461 additions and 818 deletions.
392 changes: 214 additions & 178 deletions config.py

Large diffs are not rendered by default.

35 changes: 23 additions & 12 deletions db.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Config
conf = config.Config()

db_path = conf.settings['queuefile']
db_path = conf.settings["queuefile"]
database = SqliteDatabase(db_path)


Expand Down Expand Up @@ -55,14 +55,14 @@ def get_next_item():

def exists_file_root_path(file_path):
items = get_all_items()
if '.' in file_path:
if "." in file_path:
dir_path = os.path.dirname(file_path)
else:
dir_path = file_path

for item in items:
if dir_path.lower() in item['scan_path'].lower():
return True, item['scan_path']
if dir_path.lower() in item["scan_path"].lower():
return True, item["scan_path"]
return False, None


Expand All @@ -72,10 +72,10 @@ def get_all_items():
for item in QueueItemModel.select():
items.append(
{
'scan_path': item.scan_path,
'scan_for': item.scan_for,
'scan_type': item.scan_type,
'scan_section': item.scan_section,
"scan_path": item.scan_path,
"scan_for": item.scan_for,
"scan_type": item.scan_type,
"scan_section": item.scan_section,
}
)
except Exception:
Expand All @@ -89,23 +89,34 @@ def get_queue_count():
try:
count = QueueItemModel.select().count()
except Exception:
logger.exception("Exception getting queued item count from Plex Autoscan database: ")
logger.exception(
"Exception getting queued item count from Plex Autoscan database: "
)
return count


def remove_item(scan_path):
try:
return (QueueItemModel.delete()).where(QueueItemModel.scan_path == scan_path).execute()
return (
(QueueItemModel.delete())
.where(QueueItemModel.scan_path == scan_path)
.execute()
)
except Exception:
logger.exception("Exception deleting %r from Plex Autoscan database: ", scan_path)
logger.exception(
"Exception deleting %r from Plex Autoscan database: ", scan_path
)
return False


def add_item(scan_path, scan_for, scan_section, scan_type):
item = None
try:
return QueueItemModel.create(
scan_path=scan_path, scan_for=scan_for, scan_section=scan_section, scan_type=scan_type
scan_path=scan_path,
scan_for=scan_for,
scan_section=scan_section,
scan_type=scan_type,
)
except AttributeError as ex:
return item
Expand Down
6 changes: 5 additions & 1 deletion google/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def __init__(self, cache_file_path):
def get_cache(self, cache_name, autocommit=False):
if cache_name not in self.caches:
self.caches[cache_name] = SqliteDict(
self.cache_file_path, tablename=cache_name, encode=json.dumps, decode=json.loads, autocommit=autocommit
self.cache_file_path,
tablename=cache_name,
encode=json.dumps,
decode=json.loads,
autocommit=autocommit,
)
return self.caches[cache_name]
Loading

0 comments on commit 0e99763

Please sign in to comment.