starts real configuration of backups by file extension
This commit is contained in:
@@ -4,12 +4,25 @@ from .config import BACKUP_PATH, TRASH_NAME
|
|||||||
from .utils import copy_files, get_content
|
from .utils import copy_files, get_content
|
||||||
|
|
||||||
|
|
||||||
def add(files):
|
class Backup:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
from .config import BACKUP_CONF
|
||||||
|
self.stores = BACKUP_CONF
|
||||||
|
|
||||||
|
def add(self, files):
|
||||||
""" Add a set of files to backup folder """
|
""" Add a set of files to backup folder """
|
||||||
copy_files(files, BACKUP_PATH)
|
|
||||||
|
def sort_by_ext(content):
|
||||||
|
# Returns separate sets of files with valid extensions
|
||||||
|
return {}
|
||||||
|
|
||||||
|
for ext, files in sort_by_ext(files):
|
||||||
|
backup_path = self.stores[ext]
|
||||||
|
copy_files(files, backup_path)
|
||||||
|
|
||||||
|
|
||||||
def list(exclude_trash=True):
|
def list(self, exclude_trash=True):
|
||||||
""" List files in backup folders """
|
""" List files in backup folders """
|
||||||
return get_content(
|
return get_content(
|
||||||
BACKUP_PATH,
|
BACKUP_PATH,
|
||||||
|
|||||||
9
photograb/config.ini
Normal file
9
photograb/config.ini
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[GLOBAL]
|
||||||
|
Import = /home/yunohost.app/lychee/import
|
||||||
|
Camera = /media/sdcard
|
||||||
|
|
||||||
|
[jpg]
|
||||||
|
Backup = /media/multimedia/artus/Multimedia/Picture/Camera/
|
||||||
|
|
||||||
|
[mp4]
|
||||||
|
Backup = /media/multimedia/artus/Multimedia/Video/Camera/
|
||||||
@@ -1,11 +1,19 @@
|
|||||||
# -*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
|
import configparser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
IMPORT_PATH = Path("/home/yunohost.app/lychee/import/")
|
config = configparser.ConfigParser()
|
||||||
BACKUP_PATH = Path("/media/multimedia/artus/Picture/Camera/original/")
|
config.read("config.ini")
|
||||||
CAMERA_PATH = Path("/media/sdcard/")
|
|
||||||
|
IMPORT_PATH = Path(config["GLOBAL"]["Import"])
|
||||||
|
CAMERA_PATH = Path(config["GLOBAL"]["Camera"])
|
||||||
|
BACKUP_CONF = dict()
|
||||||
|
for ext in config.sections():
|
||||||
|
if ext == "GLOBAL":
|
||||||
|
continue
|
||||||
|
path = config[ext].get("Backup", None)
|
||||||
|
if path:
|
||||||
|
BACKUP_CONF[ext] = Path(path)
|
||||||
|
|
||||||
TRASH_NAME = ".trash"
|
TRASH_NAME = ".trash"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user