diff --git a/config.ini-sample b/ordigi.conf similarity index 100% rename from config.ini-sample rename to ordigi.conf diff --git a/dozo.py b/ordigi.py similarity index 95% rename from dozo.py rename to ordigi.py index de65c23..cad0d3b 100755 --- a/dozo.py +++ b/ordigi.py @@ -9,12 +9,12 @@ from datetime import datetime import click from send2trash import send2trash -from dozo import constants -from dozo import config -from dozo.filesystem import FileSystem -from dozo.database import Db -from dozo.media.media import Media, get_all_subclasses -from dozo.summary import Summary +from ordigi import constants +from ordigi import config +from ordigi.filesystem import FileSystem +from ordigi.database import Db +from ordigi.media.media import Media, get_all_subclasses +from ordigi.summary import Summary FILESYSTEM = FileSystem() @@ -46,7 +46,7 @@ def get_logger(verbose, debug): logging.debug('This message should appear on the console') logging.info('So should this') logging.getLogger('asyncio').setLevel(level) - logger = logging.getLogger('dozo') + logger = logging.getLogger('ordigi') logger.level = level return logger @@ -82,7 +82,7 @@ def get_logger(verbose, debug): def _sort(debug, dry_run, destination, copy, exclude_regex, filter_by_ext, ignore_tags, max_deep, remove_duplicates, reset_cache, verbose, paths): """Sort files or directories by reading their EXIF and organizing them - according to config.ini preferences. + according to ordigi.conf preferences. """ if copy: @@ -148,7 +148,7 @@ def _sort(debug, dry_run, destination, copy, exclude_regex, filter_by_ext, ignor @click.option('--debug', default=False, is_flag=True, help='Override the value in constants.py with True.') def _generate_db(path, debug): - """Regenerate the hash.json database which contains all of the sha256 signatures of media files. The hash.json file is located at ~/.dozo/. + """Regenerate the hash.json database which contains all of the sha256 signatures of media files. """ constants.debug = debug result = Result() diff --git a/dozo/__init__.py b/ordigi/__init__.py similarity index 100% rename from dozo/__init__.py rename to ordigi/__init__.py diff --git a/dozo/config.py b/ordigi/config.py similarity index 97% rename from dozo/config.py rename to ordigi/config.py index c1f0feb..855e6e8 100644 --- a/dozo/config.py +++ b/ordigi/config.py @@ -1,7 +1,7 @@ """Load config file as a singleton.""" from configparser import RawConfigParser from os import path -from dozo import constants +from ordigi import constants def write(conf_file, config): diff --git a/dozo/constants.py b/ordigi/constants.py similarity index 69% rename from dozo/constants.py rename to ordigi/constants.py index 3bbd053..135a76f 100644 --- a/dozo/constants.py +++ b/ordigi/constants.py @@ -8,8 +8,15 @@ from sys import version_info #: If True, debug messages will be printed. debug = False -#: Directory in which to store Dozo settings. -application_directory = '{}/.dozo'.format(path.expanduser('~')) +#Ordigi settings directory. +if 'XDG_CONFIG_HOME' in environ: + confighome = environ['XDG_CONFIG_HOME'] +elif 'APPDATA' in environ: + confighome = environ['APPDATA'] +else: + confighome = path.join(environ['HOME'], '.config') +application_directory = path.join(confighome, 'ordigi') + default_path = '{%Y-%m-%b}/{album}|{city}|{"Unknown Location"}' default_name = '{%Y-%m-%d_%H-%M-%S}-{name}-{title}.%l{ext}' default_geocoder = 'Nominatim' @@ -23,7 +30,7 @@ location_db = 'location.json' # TODO will be removed eventualy later # location_db = '{}/location.json'.format(application_directory) -# Dozo installation directory. +# Ordigi installation directory. script_directory = path.dirname(path.dirname(path.abspath(__file__))) #: Accepted language in responses from MapQuest @@ -32,4 +39,4 @@ accepted_language = 'en' # check python version, required in filesystem.py to trigger appropriate method python_version = version_info.major -CONFIG_FILE = '%s/config.ini' % application_directory +CONFIG_FILE = f'{application_directory}/ordigi.conf' diff --git a/dozo/database.py b/ordigi/database.py similarity index 92% rename from dozo/database.py rename to ordigi/database.py index ddd2638..728904b 100644 --- a/dozo/database.py +++ b/ordigi/database.py @@ -1,5 +1,5 @@ """ -Methods for interacting with information Dozo caches about stored media. +Methods for interacting with database files """ from builtins import map from builtins import object @@ -12,23 +12,17 @@ from math import radians, cos, sqrt from shutil import copyfile from time import strftime -from dozo import constants +from ordigi import constants class Db(object): - """A class for interacting with the JSON files created by Dozo.""" + """A class for interacting with the JSON files database.""" def __init__(self, target_dir): - # verify that the application directory (~/.dozo) exists, - # else create it - # if not os.path.exists(constants.application_directory): - # os.makedirs(constants.application_directory) # Create dir for target database - dirname = os.path.join(target_dir, '.dozo') - # Legacy dir - # dirname = constants.application_directory + dirname = os.path.join(target_dir, '.ordigi') if not os.path.exists(dirname): try: diff --git a/dozo/exiftool.py b/ordigi/exiftool.py similarity index 100% rename from dozo/exiftool.py rename to ordigi/exiftool.py diff --git a/dozo/filesystem.py b/ordigi/filesystem.py similarity index 98% rename from dozo/filesystem.py rename to ordigi/filesystem.py index 46fe688..74f13bd 100644 --- a/dozo/filesystem.py +++ b/ordigi/filesystem.py @@ -14,12 +14,12 @@ import shutil import time from datetime import datetime, timedelta -from dozo import constants -from dozo import geolocation +from ordigi import constants +from ordigi import geolocation -from dozo.media.media import get_media_class, get_all_subclasses -from dozo.media.photo import Photo -from dozo.summary import Summary +from ordigi.media.media import get_media_class, get_all_subclasses +from ordigi.media.photo import Photo +from ordigi.summary import Summary class FileSystem(object): @@ -129,7 +129,7 @@ class FileSystem(object): # Create a list of compiled regular expressions to match against the file path compiled_regex_list = [re.compile(regex) for regex in exclude_regex_list] for dirname, dirnames, filenames in os.walk(path): - if dirname == os.path.join(path, '.dozo'): + if dirname == os.path.join(path, '.ordigi'): continue for filename in filenames: # If file extension is in `extensions` @@ -535,7 +535,7 @@ class FileSystem(object): subdirs = '' for dirname, dirnames, filenames, level in self.walklevel(path, self.max_deep): - if dirname == os.path.join(path, '.dozo'): + if dirname == os.path.join(path, '.ordigi'): continue subdirs = os.path.join(subdirs, os.path.basename(dirname)) @@ -675,7 +675,7 @@ class FileSystem(object): has_errors = False path = self.check_path(path) for dirname, dirnames, filenames, level in self.walklevel(path, None): - if dirname == os.path.join(path, '.dozo'): + if dirname == os.path.join(path, '.ordigi'): continue if dirname.find('similar_to') == 0: continue @@ -738,7 +738,7 @@ class FileSystem(object): has_errors = False path = self.check_path(path) for dirname, dirnames, filenames, level in self.walklevel(path, None): - if dirname == os.path.join(path, '.dozo'): + if dirname == os.path.join(path, '.ordigi'): continue if dirname.find('similar_to') == 0: continue diff --git a/dozo/geolocation.py b/ordigi/geolocation.py similarity index 98% rename from dozo/geolocation.py rename to ordigi/geolocation.py index 870ce0e..df867be 100644 --- a/dozo/geolocation.py +++ b/ordigi/geolocation.py @@ -8,8 +8,8 @@ import geopy from geopy.geocoders import Nominatim import logging -from dozo import constants -from dozo.config import load_config, get_geocoder +from ordigi import constants +from ordigi.config import load_config, get_geocoder __KEY__ = None __DEFAULT_LOCATION__ = 'Unknown Location' diff --git a/dozo/media/__init__.py b/ordigi/media/__init__.py similarity index 100% rename from dozo/media/__init__.py rename to ordigi/media/__init__.py diff --git a/dozo/media/audio.py b/ordigi/media/audio.py similarity index 91% rename from dozo/media/audio.py rename to ordigi/media/audio.py index c995648..788c1ea 100644 --- a/dozo/media/audio.py +++ b/ordigi/media/audio.py @@ -1,6 +1,6 @@ """ The audio module contains classes specifically for dealing with audio files. -The :class:`Audio` class inherits from the :class:`~dozo.media.Media` +The :class:`Audio` class inherits from the :class:`~ordigi.media.Media` class. .. moduleauthor:: Jaisen Mathai diff --git a/dozo/media/media.py b/ordigi/media/media.py similarity index 98% rename from dozo/media/media.py rename to ordigi/media/media.py index a7c7585..c9fe47f 100644 --- a/dozo/media/media.py +++ b/ordigi/media/media.py @@ -1,7 +1,7 @@ """ -Base :class:`Media` class for media objects that are tracked by Dozo. +Base :class:`Media` class for media objects The Media class provides some base functionality used by all the media types. -Sub-classes (:class:`~dozo.media.Audio`, :class:`~dozo.media.Photo`, and :class:`~dozo.media.Video`). +Sub-classes (:class:`~ordigi.media.Audio`, :class:`~ordigi.media.Photo`, and :class:`~ordigi.media.Video`). """ import mimetypes @@ -12,7 +12,7 @@ import logging # load modules from dateutil.parser import parse import re -from dozo.exiftool import ExifTool, ExifToolCaching +from ordigi.exiftool import ExifTool, ExifToolCaching class Media(): diff --git a/dozo/media/photo.py b/ordigi/media/photo.py similarity index 100% rename from dozo/media/photo.py rename to ordigi/media/photo.py diff --git a/dozo/media/video.py b/ordigi/media/video.py similarity index 100% rename from dozo/media/video.py rename to ordigi/media/video.py diff --git a/dozo/summary.py b/ordigi/summary.py similarity index 100% rename from dozo/summary.py rename to ordigi/summary.py