You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
4.5 KiB
173 lines
4.5 KiB
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
Stashr - [description]
|
|
"""
|
|
|
|
"""
|
|
MIT License
|
|
|
|
Copyright (c) 2020 Andrew Vanderbye
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
SOFTWARE.
|
|
"""
|
|
|
|
"""-------------------------------------------------------------------------------------------
|
|
-- IMPORTS
|
|
-------------------------------------------------------------------------------------------"""
|
|
|
|
""" --- HUEY IMPORT --- """
|
|
""" --- PYTHON IMPORTS --- """
|
|
import os
|
|
""" --- STASHR DEPENDENCY IMPORTS --- """
|
|
""" --- STASHR CORE IMPORTS --- """
|
|
from stashr import log
|
|
|
|
""" --- CREATE LOGGER --- """
|
|
logger = log.stashr_logger(__name__)
|
|
|
|
from stashr.config import stashrconfig
|
|
|
|
"""-------------------------------------------------------------------------------------------
|
|
-- PATHS
|
|
-------------------------------------------------------------------------------------------"""
|
|
|
|
class StashrPaths:
|
|
|
|
|
|
def base_path(self):
|
|
return os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + os.sep + '..' + os.sep)
|
|
|
|
|
|
def db_path(self):
|
|
return os.path.join(
|
|
self.base_path(),
|
|
'database.db'
|
|
)
|
|
|
|
# base_path = os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + os.sep + '..' + os.sep)
|
|
# db_path = os.path.join(base_path, 'database.db')
|
|
|
|
"""-------------------------------------------------------------------------------------------
|
|
-- FOLDERS
|
|
-------------------------------------------------------------------------------------------"""
|
|
|
|
|
|
class StashrFolders:
|
|
|
|
|
|
def temp_folder(self):
|
|
|
|
folder = os.path.join(
|
|
StashrPaths().base_path(),
|
|
stashrconfig['DIRECTORY']['temp']
|
|
)
|
|
|
|
if not os.path.isdir(folder):
|
|
logger.debug('Creating Temp Folder')
|
|
os.mkdir(folder)
|
|
|
|
return folder
|
|
|
|
|
|
def comic_folder(self):
|
|
|
|
folder = os.path.join(
|
|
StashrPaths().base_path(),
|
|
stashrconfig['DIRECTORY']['comics']
|
|
)
|
|
|
|
logger.debug(folder)
|
|
|
|
if not os.path.isdir(folder):
|
|
logger.info('Creating Volumes Folder')
|
|
os.mkdir(folder)
|
|
|
|
return folder
|
|
|
|
|
|
def log_folder(self):
|
|
|
|
folder = os.path.join(
|
|
StashrPaths().base_path(),
|
|
stashrconfig['DIRECTORY']['log']
|
|
)
|
|
|
|
if not os.path.isdir(folder):
|
|
logger.info('Creating Log Folder')
|
|
os.mkdir(folder)
|
|
|
|
return folder
|
|
|
|
|
|
def backup_folder(self):
|
|
|
|
folder = os.path.join(
|
|
StashrPaths().base_path(),
|
|
stashrconfig['DIRECTORY']['backup']
|
|
)
|
|
|
|
if not os.path.isdir(folder):
|
|
logger.info('Creating Backup Folder')
|
|
os.mkdir(folder)
|
|
|
|
return folder
|
|
|
|
|
|
def plugins_folder(self):
|
|
|
|
folder = os.path.join(
|
|
StashrPaths().base_path(),
|
|
stashrconfig['DIRECTORY']['plugins']
|
|
)
|
|
|
|
if not os.path.isdir(folder):
|
|
logger.info('Creating Plugins Folder')
|
|
os.mkdir(folder)
|
|
|
|
return folder
|
|
|
|
|
|
def images_folder(self):
|
|
|
|
folder = os.path.join(
|
|
StashrPaths().base_path(),
|
|
stashrconfig['DIRECTORY']['images']
|
|
)
|
|
|
|
if not os.path.isdir(folder):
|
|
logger.info('Creating Images Folder')
|
|
os.mkdir(folder)
|
|
|
|
return folder
|
|
|
|
|
|
def covers_folder(self):
|
|
|
|
folder = os.path.join(
|
|
StashrPaths().base_path(),
|
|
stashrconfig['DIRECTORY']['covers']
|
|
)
|
|
|
|
if not os.path.isdir(folder):
|
|
logger.info('Creating Covers Folder')
|
|
os.mkdir(folder)
|
|
|
|
return folder |