
Fixes #315. This PR aims to address the [recent changes](https://www.blog.google/products/photos/simplifying-google-photos-and-google-drive/) in Google Photos + Google Drive where syncing between the two is no longer supported. It works by uploading photos as part of the import process to add a copy of every photo in your library to Google Photos. Google Drive is not required for this plugin to work. This plugin lets you have all your photos in Google Photos without relying on Google Drive. You can use another cloud storage service like iCloud or Dropbox or no cloud storage at all. - [x] Add tests for `after()` plugin methods. - [x] Add support for storage/async support. - [x] Include plugins into code coverage. - [x] Sweep code and clean up and add comments.
40 lines
970 B
Python
40 lines
970 B
Python
"""Load config file as a singleton."""
|
|
from configparser import RawConfigParser
|
|
from os import path
|
|
|
|
from elodie import constants
|
|
|
|
config_file = '%s/config.ini' % constants.application_directory
|
|
|
|
|
|
def load_config():
|
|
if hasattr(load_config, "config"):
|
|
return load_config.config
|
|
|
|
if not path.exists(config_file):
|
|
return {}
|
|
|
|
load_config.config = RawConfigParser()
|
|
load_config.config.read(config_file)
|
|
return load_config.config
|
|
|
|
def load_plugin_config():
|
|
config = load_config()
|
|
|
|
# If plugins are defined in the config we return them as a list
|
|
# Else we return an empty list
|
|
if 'Plugins' in config and 'plugins' in config['Plugins']:
|
|
return config['Plugins']['plugins'].split(',')
|
|
|
|
return []
|
|
|
|
def load_config_for_plugin(name):
|
|
# Plugins store data using Plugin%PluginName% format.
|
|
key = 'Plugin{}'.format(name)
|
|
config = load_config()
|
|
|
|
if key in config:
|
|
return config[key]
|
|
|
|
return {}
|