From 6c5f17e11a250632d33dace50830bbca5281ddd2 Mon Sep 17 00:00:00 2001 From: Schimon Jehudah Date: Thu, 2 Nov 2023 05:15:33 +0000 Subject: [PATCH] Update file confighandler.py --- slixfeed/confighandler.py | 106 +++++++++++++++++++++++++++++++++++++- 1 file changed, 105 insertions(+), 1 deletion(-) diff --git a/slixfeed/confighandler.py b/slixfeed/confighandler.py index 82b0f79..3263b23 100644 --- a/slixfeed/confighandler.py +++ b/slixfeed/confighandler.py @@ -37,10 +37,36 @@ def get_default_dbdir(): return os.path.join(data_home, 'slixfeed') +def get_default_confdir(): + """ + 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. + + :return: Path to configueation 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') + + async def get_value_default(key): """ Get settings default value. - + :param key: "enabled", "interval", "quantum". :return: Integer. """ @@ -51,3 +77,81 @@ async def get_value_default(key): elif key == "interval": result = 30 return result + + +# async def generate_dictionary(): +def get_default_list(): + """ + Generate a dictionary file. + + :return: List. + """ + paths = [ + ".atom", + ".rss", + ".xml", + "/?feed=atom", + "/?feed=rdf", + "/?feed=rss", + "/?feed=xml", # wordpress + "/?format=atom", + "/?format=rdf", + "/?format=rss", + "/?format=xml", # phpbb + "/app.php/feed", + "/atom", + "/atom.php", + "/atom.xml", + "/blog/feed/", + "/content-feeds/", + "/external.php?type=RSS2", + "/en/feed/", + "/feed", # good practice + "/feed.atom", + # "/feed.json", + "/feed.php", + "/feed.rdf", + "/feed.rss", + "/feed.xml", + "/feed/atom/", + "/feeds/news_feed", + "/feeds/posts/default", + "/feeds/posts/default?alt=atom", + "/feeds/posts/default?alt=rss", + "/feeds/rss/news.xml.php", + "/forum_rss.php", + "/index.atom", + "/index.php/feed", + "/index.php?type=atom;action=.xml", #smf + "/index.php?type=rss;action=.xml", #smf + "/index.rss", + "/jekyll/feed.xml", + "/latest.rss", + "/news", + "/news.xml", + "/news.xml.php", + "/news/feed", + "/posts.rss", # discourse + "/rdf", + "/rdf.php", + "/rdf.xml", + "/rss", + # "/rss.json", + "/rss.php", + "/rss.xml", + "/timeline.rss", + "/videos.atom", + # "/videos.json", + "/videos.xml", + "/xml/feed.rss" + ] + return paths + # cfg_dir = get_default_confdir() + # if not os.path.isdir(cfg_dir): + # os.mkdir(cfg_dir) + # cfg_file = os.path.join(cfg_dir, r"url_paths.txt") + # if not os.path.isfile(cfg_file): + # file = open(cfg_file, "w") + # file.writelines("\n".join(paths)) + # file.close() +