|
@@ -1,15 +1,16 @@
|
|
-import logging
|
|
|
|
from ycast import generic
|
|
from ycast import generic
|
|
|
|
|
|
MAX_ENTRIES = 15
|
|
MAX_ENTRIES = 15
|
|
DIRECTORY_NAME = "recently used"
|
|
DIRECTORY_NAME = "recently used"
|
|
|
|
|
|
recently_file = generic.get_var_path() + '/recently.yml'
|
|
recently_file = generic.get_var_path() + '/recently.yml'
|
|
|
|
+is_yml_file_loadable = True
|
|
|
|
|
|
|
|
|
|
def signal_station_selected(name, url, icon):
|
|
def signal_station_selected(name, url, icon):
|
|
list_heard_stations = get_stations_list()
|
|
list_heard_stations = get_stations_list()
|
|
- if len(list_heard_stations) == 0:
|
|
|
|
|
|
+ if not list_heard_stations:
|
|
|
|
+ list_heard_stations = []
|
|
list_heard_stations.append(DIRECTORY_NAME + ":\n")
|
|
list_heard_stations.append(DIRECTORY_NAME + ":\n")
|
|
# make name yaml - like
|
|
# make name yaml - like
|
|
name = name.replace(":", " -")
|
|
name = name.replace(":", " -")
|
|
@@ -31,7 +32,8 @@ def signal_station_selected(name, url, icon):
|
|
|
|
|
|
|
|
|
|
def set_stations_yaml(heard_stations):
|
|
def set_stations_yaml(heard_stations):
|
|
- generic.writelns_txt_file(recently_file, heard_stations)
|
|
|
|
|
|
+ global is_yml_file_loadable
|
|
|
|
+ is_yml_file_loadable = generic.writelns_txt_file(recently_file, heard_stations)
|
|
|
|
|
|
|
|
|
|
def get_stations_list():
|
|
def get_stations_list():
|
|
@@ -39,9 +41,17 @@ def get_stations_list():
|
|
|
|
|
|
|
|
|
|
def get_recently_stations_yaml():
|
|
def get_recently_stations_yaml():
|
|
- return generic.read_yaml_file(recently_file)
|
|
|
|
|
|
+ global is_yml_file_loadable
|
|
|
|
+ dict_stations = None
|
|
|
|
+ if is_yml_file_loadable:
|
|
|
|
+ dict_stations = generic.read_yaml_file(recently_file)
|
|
|
|
+ if not dict_stations:
|
|
|
|
+ is_yml_file_loadable = False
|
|
|
|
+ return dict_stations
|
|
|
|
|
|
|
|
|
|
def directory_name():
|
|
def directory_name():
|
|
dir = generic.read_yaml_file(recently_file)
|
|
dir = generic.read_yaml_file(recently_file)
|
|
- return list(dir.keys())[0]
|
|
|
|
|
|
+ if dir:
|
|
|
|
+ return list(dir.keys())[0]
|
|
|
|
+ return None
|