@@ -1492,6 +1492,11 @@ def _load_config_file(self) -> None:
1492
1492
1493
1493
# Check for config file
1494
1494
config_path = os .path .join (self .root_path , self .config )
1495
+ # NOTE: it would be better if we could distinguish between a user-defined
1496
+ # and a default config file. If not user-defined then we can check for
1497
+ # default names, currently only .fortls. If None are found return None
1498
+ # if user-defined config we would want to throw an error if the file
1499
+ # cannot be found
1495
1500
if not os .path .isfile (config_path ):
1496
1501
return None
1497
1502
@@ -1521,14 +1526,12 @@ def _load_config_file(self) -> None:
1521
1526
self .debug_log = True
1522
1527
1523
1528
except FileNotFoundError :
1524
- self .post_messages (
1525
- [Severity .error , f"Error settings file '{ self .config } ' not found" ]
1526
- )
1529
+ self .post_message (f"Configuration file '{ self .config } ' not found" )
1527
1530
1528
- except ValueError :
1529
- self . post_messages (
1530
- [ Severity . error , f"Error while parsing '{ self .config } ' settings file" ]
1531
- )
1531
+ # Erroneous json file syntax
1532
+ except ValueError as e :
1533
+ msg = f"Error: ' { e } ' while reading '{ self .config } ' Configuration file"
1534
+ self . post_message ( msg )
1532
1535
1533
1536
def _load_config_file_dirs (self , config_dict : dict ) -> None :
1534
1537
# Exclude paths (directories & files)
@@ -1540,12 +1543,10 @@ def _load_config_file_dirs(self, config_dict: dict) -> None:
1540
1543
# with glob resolution
1541
1544
source_dirs = config_dict .get ("source_dirs" , [])
1542
1545
for path in source_dirs :
1543
- try :
1544
- dirs = only_dirs (resolve_globs (path , self .root_path ))
1545
- self .source_dirs .update (set (dirs ))
1546
- except FileNotFoundError as e :
1547
- err = f"Directories input in Configuration file do not exit:\n { e } "
1548
- self .post_messages ([Severity .warn , err ])
1546
+ # resolve_globs filters any nonexisting directories so FileNotFoundError
1547
+ # found inside only_dirs can never be raised
1548
+ dirs = only_dirs (resolve_globs (path , self .root_path ))
1549
+ self .source_dirs .update (set (dirs ))
1549
1550
1550
1551
# Keep all directories present in source_dirs but not excl_paths
1551
1552
self .source_dirs = {i for i in self .source_dirs if i not in self .excl_paths }
@@ -1606,18 +1607,16 @@ def _load_config_file_general(self, config_dict: dict) -> None:
1606
1607
)
1607
1608
1608
1609
def _load_config_file_preproc (self , config_dict : dict ) -> None :
1609
- self .pp_suffixes = config_dict .get ("pp_suffixes" , None ) # TODO: set def
1610
- self .pp_defs = config_dict .get ("pp_defs" , {}) # TODO: set other dif?
1610
+ self .pp_suffixes = config_dict .get ("pp_suffixes" , None )
1611
+ self .pp_defs = config_dict .get ("pp_defs" , {})
1611
1612
if isinstance (self .pp_defs , list ):
1612
1613
self .pp_defs = {key : "" for key in self .pp_defs }
1613
1614
1614
1615
for path in config_dict .get ("include_dirs" , set ()):
1615
- try :
1616
- dirs = only_dirs (resolve_globs (path , self .root_path ))
1617
- self .include_dirs .update (set (dirs ))
1618
- except FileNotFoundError as e :
1619
- err = f"Directories input in Configuration file do not exit:\n { e } "
1620
- self .post_messages ([Severity .warn , err ])
1616
+ # resolve_globs filters any nonexisting directories so FileNotFoundError
1617
+ # found inside only_dirs can never be raised
1618
+ dirs = only_dirs (resolve_globs (path , self .root_path ))
1619
+ self .include_dirs .update (set (dirs ))
1621
1620
1622
1621
def _add_source_dirs (self ) -> None :
1623
1622
"""Will recursively add all subdirectories that contain Fortran
0 commit comments