diff --git a/slixfeed/assets/selector.toml b/slixfeed/assets/selector.toml index 579d46d..977dc34 100644 --- a/slixfeed/assets/selector.toml +++ b/slixfeed/assets/selector.toml @@ -18,6 +18,7 @@ blacklist = [ "lana@redice.tv", "larken@larkenrose.com", "lee@oraclebroadcasting.com", + "mark@enclosedworld.com", "mark@marksargent.com", "nick@nightnationreview.com", "oliver@postmarketos.org", diff --git a/slixfeed/config.py b/slixfeed/config.py index 9ed74bc..374b154 100644 --- a/slixfeed/config.py +++ b/slixfeed/config.py @@ -45,12 +45,76 @@ except: logger = Logger(__name__) +class Cache: + + def get_default_cache_directory(): + """ + Determine the directory path where dbfile will be stored. + + * If $XDG_DATA_HOME is defined, use it; + * else if $HOME exists, use it; + * else if the platform is Windows, use %APPDATA%; + * else use the current directory. + + Returns + ------- + str + Path to cache directory. + """ +# data_home = xdg.BaseDirectory.xdg_data_home + data_home = os.environ.get('XDG_CACHE_HOME') + if data_home is None: + if os.environ.get('HOME') is None: + if sys.platform == 'win32': + data_home = os.environ.get('APPDATA') + if data_home is None: + return os.path.abspath('.slixfeed/cache') + else: + return os.path.abspath('.slixfeed/cache') + else: + data_home = os.path.join( + os.environ.get('HOME'), '.cache' + ) + return os.path.join(data_home, 'slixfeed') + # TODO Consider a class ConfigDefault for default values to be initiate at most # basic level possible and a class ConfigJID for each JID (i.e. db_file) to be # also initiated at same level or at least at event call, then check whether # setting_jid.setting_key has value, otherwise resort to setting_default.setting_key. class Config: + # TODO Write a similar function for file. + # NOTE the is a function of directory, noot file. + def get_default_config_directory(): + """ + Determine the directory path where configuration will be stored. + + * If $XDG_CONFIG_HOME is defined, use it; + * else if $HOME exists, use it; + * else if the platform is Windows, use %APPDATA%; + * else use the current directory. + + Returns + ------- + str + Path to configuration directory. + """ +# config_home = xdg.BaseDirectory.xdg_config_home + config_home = os.environ.get('XDG_CONFIG_HOME') + if config_home is None: + if os.environ.get('HOME') is None: + if sys.platform == 'win32': + config_home = os.environ.get('APPDATA') + if config_home is None: + return os.path.abspath('.') + else: + return os.path.abspath('.') + else: + config_home = os.path.join( + os.environ.get('HOME'), '.config' + ) + return os.path.join(config_home, 'slixfeed') + def update_toml_file(filename, data): with open(filename, 'w') as new_file: content = tomli_w.dumps(data) diff --git a/slixfeed/syndication.py b/slixfeed/syndication.py index a167437..a585d39 100644 --- a/slixfeed/syndication.py +++ b/slixfeed/syndication.py @@ -44,16 +44,15 @@ logger = Logger(__name__) class Feed: # NOTE Consider removal of MD (and any other option HTML and XBEL) - def export_feeds(jid_bare, ext): + def export_feeds(dir_cache, jid_bare, ext): function_name = sys._getframe().f_code.co_name logger.debug('{}: jid_bare: {}: ext: {}'.format(function_name, jid_bare, ext)) - cache_dir = config.get_default_cache_directory() - if not os.path.isdir(cache_dir): - os.mkdir(cache_dir) - if not os.path.isdir(cache_dir + '/' + ext): - os.mkdir(cache_dir + '/' + ext) + if not os.path.isdir(dir_cache): + os.mkdir(dir_cache) + if not os.path.isdir(dir_cache + '/' + ext): + os.mkdir(dir_cache + '/' + ext) filename = os.path.join( - cache_dir, ext, 'slixfeed_' + DateAndTime.timestamp() + '.' + ext) + dir_cache, ext, 'slixfeed_' + DateAndTime.timestamp() + '.' + ext) db_file = config.get_pathname_to_database(jid_bare) results = sqlite.get_feeds(db_file) match ext: diff --git a/slixfeed/version.py b/slixfeed/version.py index 29780fb..c388705 100644 --- a/slixfeed/version.py +++ b/slixfeed/version.py @@ -1,2 +1,2 @@ -__version__ = '0.1.100' -__version_info__ = (0, 1, 100) +__version__ = '0.1.101' +__version_info__ = (0, 1, 101) diff --git a/slixfeed/xmpp/chat.py b/slixfeed/xmpp/chat.py index e1ef8d6..f062e7f 100644 --- a/slixfeed/xmpp/chat.py +++ b/slixfeed/xmpp/chat.py @@ -225,14 +225,14 @@ class XmppChat: response = ('Invalid. Enter command key ' 'or command key & name') case 'info': - entries = XmppCommands.print_info_list() + entries = XmppCommands.print_info_list(self) response = ('Available command options:\n' '```\n{}\n```\n' 'Usage: `info