@@ -419,17 +419,17 @@ class PyRadioConfig(PyRadioStations):
419419 opts = collections .OrderedDict ()
420420 opts [ 'general_title' ] = [ 'General Options' , '' ]
421421 opts [ 'player' ] = [ 'Player: ' , '' ]
422- opts [ 'default_playlist' ] = [ 'Def. playlist ' , 'stations' ]
423- opts [ 'default_station' ] = [ 'Def station: ' , '-1 ' ]
422+ opts [ 'default_playlist' ] = [ 'Def. playlist: ' , 'stations' ]
423+ opts [ 'default_station' ] = [ 'Def station: ' , 'False ' ]
424424 opts [ 'default_encoding' ] = [ 'Def. encoding: ' , 'utf-8' ]
425425 opts [ 'connection_timeout' ] = [ 'Connection timeout: ' , '10' ]
426- opts [ 'theme_title' ] = [ 'Themes ' , '' ]
426+ opts [ 'theme_title' ] = [ 'Theme Options ' , '' ]
427427 opts [ 'theme' ] = [ 'Theme: ' , 'dark' ]
428428 opts [ 'use_transparency' ] = [ 'Use transparency: ' , False ]
429- opts [ 'playlist_manngement_title' ] = [ 'Playlist Management' , '' ]
429+ opts [ 'playlist_manngement_title' ] = [ 'Playlist Management Options ' , '' ]
430430 opts [ 'confirm_station_deletion' ] = [ 'Confirm station deletion: ' , True ]
431431 opts [ 'confirm_playlist_reload' ] = [ 'Confirm playlist reload: ' , True ]
432- opts [ 'auto_save_playlist' ] = [ 'Auto save playlist' , False ]
432+ opts [ 'auto_save_playlist' ] = [ 'Auto save playlist: ' , False ]
433433 opts [ 'requested_player' ] = [ '' , '' ]
434434 opts [ 'dirty_config' ] = [ '' , False ]
435435
@@ -440,7 +440,7 @@ def __init__(self):
440440 self .confirm_playlist_reload = True
441441 self .auto_save_playlist = False
442442 self .default_playlist = 'stations'
443- self .default_station = '-1 '
443+ self .default_station = 'False '
444444 self .default_encoding = 'utf-8'
445445 self .connection_timeout = '10'
446446 self .theme = 'dark'
@@ -455,112 +455,114 @@ def __init__(self):
455455
456456 @property
457457 def requested_player (self ):
458- return self .__requested_player
458+ return self .opts [ 'requested_player' ][ 1 ]
459459
460460 @requested_player .setter
461461 def requested_player (self , val ):
462- self .__requested_player = val .replace (' ' , '' )
463- if self .__player != self .__requested_player :
464- self .__player = self .requested_player
465- self .__dirty_config = True
462+ self .opts [ 'requested_player' ][ 1 ] = val .replace (' ' , '' )
463+ if self .opts [ 'player' ][ 1 ] != self .opts [ 'requested_player' ][ 1 ] :
464+ self .opts [ 'player' ][ 1 ] = self .requested_player
465+ self .opts [ 'dirty_config' ][ 1 ] = True
466466
467467 @property
468468 def player (self ):
469- return self .__player
469+ return self .opts [ 'player' ][ 1 ]
470470
471471 @player .setter
472472 def player (self , val ):
473- self .__player = val
474- self .__dirty_config = True
473+ self .opts [ 'player' ][ 1 ] = val
474+ self .opts [ 'dirty_config' ][ 1 ] = True
475475
476476 @property
477477 def use_transparency (self ):
478- return self .__use_transparency
478+ return self .opts [ 'use_transparency' ][ 1 ]
479479
480480 @use_transparency .setter
481481 def use_transparency (self , val ):
482- self .__use_transparency = val
483- self .__dirty_config = True
482+ self .opts [ 'use_transparency' ][ 1 ] = val
483+ self .opts [ 'dirty_config' ][ 1 ] = True
484484
485485 @property
486486 def default_encoding (self ):
487- return self .__default_encoding
487+ return self .opts [ 'default_encoding' ][ 1 ]
488488
489489 @default_encoding .setter
490490 def default_encoding (self , val ):
491- self .__default_encoding = val
492- self .__dirty_config = True
491+ self .opts [ 'default_encoding' ][ 1 ] = val
492+ self .opts [ 'dirty_config' ][ 1 ] = True
493493
494494 @property
495495 def default_playlist (self ):
496- return self .__default_playlist
496+ return self .opts [ 'default_playlist' ][ 1 ]
497497
498498 @default_playlist .setter
499499 def default_playlist (self , val ):
500- self .__default_playlist = val
501- self .__dirty_config = True
500+ self .opts [ 'default_playlist' ][ 1 ] = val
501+ self .opts [ 'dirty_config' ][ 1 ] = True
502502
503503 @property
504504 def default_station (self ):
505- return self .__default_station
505+ return self .opts [ 'default_station' ][ 1 ]
506506
507507 @default_station .setter
508508 def default_station (self , val ):
509- self .__default_station = val
510- self .__dirty_config = True
509+ self .opts [ 'default_station' ][ 1 ] = val
510+ self .opts [ 'dirty_config' ][ 1 ] = True
511511
512512 @property
513513 def confirm_station_deletion (self ):
514- return self .__confirm_station_deletion
514+ return self .opts [ 'confirm_station_deletion' ][ 1 ]
515515
516516 @confirm_station_deletion .setter
517517 def confirm_station_deletion (self , val ):
518- self .__confirm_station_deletion = val
519- self .__dirty_config = True
518+ self .opts [ 'confirm_station_deletion' ][ 1 ] = val
519+ self .opts [ 'dirty_config' ][ 1 ] = True
520520
521521 @property
522522 def confirm_playlist_reload (self ):
523- return self .__confirm_playlist_reload
523+ return self .opts [ 'confirm_playlist_reload' ][ 1 ]
524524
525525 @confirm_playlist_reload .setter
526526 def confirm_playlist_reload (self , val ):
527- self .__confirm_playlist_reload = val
528- self .__dirty_config = True
527+ self .opts [ 'confirm_playlist_reload' ][ 1 ] = val
528+ self .opts [ 'dirty_config' ][ 1 ] = True
529529
530530 @property
531531 def auto_save_playlist (self ):
532- return self .__auto_save_playlist
532+ return self .opts [ 'auto_save_playlist' ][ 1 ]
533533
534534 @auto_save_playlist .setter
535535 def auto_save_playlist (self , val ):
536- self .__auto_save_playlist = val
537- self .__dirty_config = True
536+ self .opts [ 'auto_save_playlist' ][ 1 ] = val
537+ self .opts [ 'dirty_config' ][ 1 ] = True
538538
539539 @property
540540 def connection_timeout (self ):
541- return self .__connection_timeout
541+ return self .opts [ 'connection_timeout' ][ 1 ]
542542
543543 @connection_timeout .setter
544544 def connection_timeout (self , val ):
545- self .__connection_timeout = val
546- self .__dirty_config = True
545+ self .opts [ 'connection_timeout' ][ 1 ] = val
546+ self .opts [ 'dirty_config' ][ 1 ] = True
547547
548548 @property
549549 def theme (self ):
550- return self .__theme
550+ return self .opts [ 'theme' ][ 1 ]
551551
552552 @theme .setter
553553 def theme (self , val ):
554- self .__theme = val
555- self .__dirty_config = True
554+ logger .info ('{}, {}' .format (self .opts ['theme' ], self .opts ['dirty_config' ]))
555+ self .opts ['theme' ][1 ] = val
556+ self .opts ['dirty_config' ][1 ] = True
557+ logger .info ('{}, {}' .format (self .opts ['theme' ], self .opts ['dirty_config' ]))
556558
557559 @property
558560 def dirty_config (self ):
559- return self .__dirty_config
561+ return self .opts [ 'dirty_config' ][ 1 ]
560562
561563 @dirty_config .setter
562564 def dirty_config (self , val ):
563- self .__dirty_config = val
565+ self .opts [ 'dirty_config' ][ 1 ] = val
564566
565567 def _check_config_file (self , usr ):
566568 ''' Make sure a config file exists in the config dir '''
@@ -595,48 +597,48 @@ def read_config(self):
595597 if sp [1 ] == '' :
596598 return - 2
597599 if sp [0 ] == 'player' :
598- self .__player = sp [1 ].lower ().strip ()
600+ self .opts [ 'player' ][ 1 ] = sp [1 ].lower ().strip ()
599601 elif sp [0 ] == 'connection_timeout' :
600- self .__connection_timeout = sp [1 ].strip ()
602+ self .opts [ 'connection_timeout' ][ 1 ] = sp [1 ].strip ()
601603 elif sp [0 ] == 'default_encoding' :
602- self .__default_encoding = sp [1 ].strip ()
604+ self .opts [ 'default_encoding' ][ 1 ] = sp [1 ].strip ()
603605 elif sp [0 ] == 'theme' :
604- self .__theme = sp [1 ].strip ()
606+ self .opts [ 'theme' ][ 1 ] = sp [1 ].strip ()
605607 elif sp [0 ] == 'default_playlist' :
606- self .__default_playlist = sp [1 ].strip ()
608+ self .opts [ 'default_playlist' ][ 1 ] = sp [1 ].strip ()
607609 elif sp [0 ] == 'default_station' :
608610 st = sp [1 ].strip ()
609- if st == '-1' :
610- self .__default_station = 'False'
611+ if st == '-1' or st . lower () == 'false' :
612+ self .opts [ 'default_station' ][ 1 ] = 'False'
611613 elif st == 'random' :
612- self .__default_station = None
614+ self .opts [ 'default_station' ][ 1 ] = None
613615 else :
614- self .__default_station = st
616+ self .opts [ 'default_station' ][ 1 ] = st
615617 elif sp [0 ] == 'confirm_station_deletion' :
616618 if sp [1 ].lower () == 'false' :
617- self .__confirm_station_deletion = False
619+ self .opts [ 'confirm_station_deletion' ][ 1 ] = False
618620 else :
619- self .__confirm_station_deletion = True
621+ self .opts [ 'confirm_station_deletion' ][ 1 ] = True
620622 elif sp [0 ] == 'confirm_playlist_reload' :
621623 if sp [1 ].lower () == 'false' :
622- self .__confirm_playlist_reload = False
624+ self .opts [ 'confirm_playlist_reload' ][ 1 ] = False
623625 else :
624- self .__confirm_playlist_reload = True
626+ self .opts [ 'confirm_playlist_reload' ][ 1 ] = True
625627 elif sp [0 ] == 'auto_save_playlist' :
626628 if sp [1 ].lower () == 'true' :
627- self .__auto_save_playlist = True
629+ self .opts [ 'auto_save_playlist' ][ 1 ] = True
628630 else :
629- self .__auto_save_playlist = False
631+ self .opts [ 'auto_save_playlist' ][ 1 ] = False
630632 elif sp [0 ] == 'use_transparency' :
631633 if sp [1 ].lower () == 'true' :
632- self .__use_transparency = True
634+ self .opts [ 'use_transparency' ][ 1 ] = True
633635 else :
634- self .__use_transparency = False
635- self .__dirty_config = False
636+ self .opts [ 'use_transparency' ][ 1 ] = False
637+ self .opts [ 'dirty_config' ][ 1 ] = False
636638 return 0
637639
638640 def _save_config (self ):
639- if not self .__dirty_config :
641+ if not self .opts [ 'dirty_config' ][ 1 ] :
640642 if logger .isEnabledFor (logging .INFO ):
641643 logger .info ('Config not saved (not modified)' )
642644 return 0
@@ -679,7 +681,7 @@ def _save_config(self):
679681# https://docs.python.org/2.5/lib/standard-encodings.html
680682# Or use this URL
681683# https://docs.python.org/2.6/library/codecs.html#standard-encodings
682- # replacing 2.6 with specific version:
684+ # replacing 2.6 with specific version:
683685# 2.7, 3.0 up to current python version.
684686#
685687# Default value: utf-8
@@ -711,7 +713,7 @@ def _save_config(self):
711713# Transparency setting
712714# If False, theme colors will be used.
713715# If True and a compositor is running, the stations' window
714- # background will be transparent. If True and a compositor is
716+ # background will be transparent. If True and a compositor is
715717# not running, the terminal's background color will be used.
716718# Valid values: True, true, False, false
717719# Default value: False
@@ -741,20 +743,20 @@ def _save_config(self):
741743
742744'''
743745 copyfile (self .config_file , self .config_file + '.restore' )
744- if self .__default_station is None :
745- self .__default_station = '-1'
746+ if self .opts [ 'default_station' ][ 1 ] is None :
747+ self .opts [ 'default_station' ][ 1 ] = '-1'
746748 try :
747749 with open (self .config_file , 'w' ) as cfgfile :
748- cfgfile .write (txt .format (self .__player ,
749- self .__default_playlist ,
750- self .__default_station ,
751- self .__default_encoding ,
752- self .__connection_timeout ,
753- self .__theme ,
754- self .__use_transparency ,
755- self .__confirm_station_deletion ,
756- self .__confirm_playlist_reload ,
757- self .__auto_save_playlist ))
750+ cfgfile .write (txt .format (self .opts [ 'player' ][ 1 ] ,
751+ self .opts [ 'default_playlist' ][ 1 ] ,
752+ self .opts [ 'default_station' ][ 1 ] ,
753+ self .opts [ 'default_encoding' ][ 1 ] ,
754+ self .opts [ 'connection_timeout' ][ 1 ] ,
755+ self .opts [ 'theme' ][ 1 ] ,
756+ self .opts [ 'use_transparency' ][ 1 ] ,
757+ self .opts [ 'confirm_station_deletion' ][ 1 ] ,
758+ self .opts [ 'confirm_playlist_reload' ][ 1 ] ,
759+ self .opts [ 'auto_save_playlist' ][ 1 ] ))
758760 except :
759761 if logger .isEnabledFor (logging .ERROR ):
760762 logger .error ('Error saving config' )
0 commit comments