@@ -737,7 +737,9 @@ def request(
737737 )
738738
739739 try :
740- logging .error (f"doing { method } towards { str (url_obj )} through { self .session .request } " )
740+ logging .error (
741+ f"doing { method } towards { str (url_obj )} through { self .session .request } "
742+ )
741743 r = self .session .request (
742744 method ,
743745 str (url_obj ),
@@ -918,9 +920,10 @@ def auto_conn(*largs, config_data: dict = None, **kwargs):
918920
919921
920922def get_davclient (
921- config_file : str = f"{ os .environ .get ('HOME' )} /.config/calendar.conf" ,
922- config_section = "default" ,
923- testconfig = False ,
923+ check_config_file : bool = True ,
924+ config_file : str = None ,
925+ config_section : str = None ,
926+ testconfig : bool = False ,
924927 environment : bool = True ,
925928 name : str = None ,
926929 ** config_data ,
@@ -967,7 +970,11 @@ def get_davclient(
967970
968971 if environment :
969972 conf = {}
970- for conf_key in (x for x in os .environ if x .startswith ("CALDAV_" ) and not x .startswith ("CALDAV_CONFIG" ):
973+ for conf_key in (
974+ x
975+ for x in os .environ
976+ if x .startswith ("CALDAV_" ) and not x .startswith ("CALDAV_CONFIG" )
977+ ):
971978 conf [conf_key [7 :].lower ()] = os .environ [conf_key ]
972979 if conf :
973980 return DAVClient (** conf )
@@ -976,11 +983,30 @@ def get_davclient(
976983 if not config_section :
977984 config_section = os .enviorn .get ("CALDAV_CONFIG_SECTION" )
978985
979- if config_file :
986+ if check_config_file :
980987 ## late import in 2.0, as the config stuff isn't properly tested
981988 from . import config
982989
983- cfg = config .read_config (config_file )
990+ if not config_section :
991+ config_section = "default"
992+
993+ if not config_file :
994+ cfgdir = f"{ os .environ .get ('HOME' , '/' )} /.config/"
995+ for config_file in (
996+ f"{ cfgdir } /caldav/calendar.conf" ,
997+ f"{ cfgdir } /caldav/calendar.yaml"
998+ f"{ cfgdir } /caldav/calendar.json"
999+ f"{ cfgdir } /calendar.conf" ,
1000+ "/etc/calendar.conf" ,
1001+ "/etc/caldav/calendar.conf" ,
1002+ ):
1003+ try :
1004+ cfg = config .read_config (config_file )
1005+ break
1006+ except FileNotFoundError :
1007+ pass
1008+ else :
1009+ cfg = config .read_config (config_file )
9841010 if cfg :
9851011 section = config .config_section (cfg , config_section )
9861012 conn_params = {}
0 commit comments