comparison roundup/configuration.py @ 8433:de1dac9abcb6

feat: change comment in dictConfig json file to // from # Emacs json mode at least will properly indent when using // as a comment character and not #.
author John Rouillard <rouilj@ieee.org>
date Tue, 26 Aug 2025 22:24:00 -0400
parents 94eed885e958
children 66284037142e
comparison
equal deleted inserted replaced
8432:7f7749d86da8 8433:de1dac9abcb6
2341 self.init_logging() 2341 self.init_logging()
2342 2342
2343 def load_config_dict_from_json_file(self, filename): 2343 def load_config_dict_from_json_file(self, filename):
2344 import json 2344 import json
2345 comment_re = re.compile( 2345 comment_re = re.compile(
2346 r"""^\s*\#.* # comment at beginning of line possibly indented. 2346 r"""^\s*//#.* # comment at beginning of line possibly indented.
2347 | # or 2347 | # or
2348 ^(.*)\s\s\s\#.* # comment char preceeded by at least three spaces. 2348 ^(.*)\s\s\s\//.* # comment char preceeded by at least three spaces.
2349 """, re.VERBOSE) 2349 """, re.VERBOSE)
2350 2350
2351 config_list = [] 2351 config_list = []
2352 with open(filename) as config_file: 2352 with open(filename) as config_file:
2353 for line in config_file: 2353 for line in config_file:
2369 # subtract 1 - zero index on config_list 2369 # subtract 1 - zero index on config_list
2370 # remove '\n' for display 2370 # remove '\n' for display
2371 line = config_list[error_at_doc_line - 1][:-1] 2371 line = config_list[error_at_doc_line - 1][:-1]
2372 2372
2373 hint = "" 2373 hint = ""
2374 if line.find('#') != -1: 2374 if line.find('//') != -1:
2375 hint = "\nMaybe bad inline comment, 3 spaces needed before #." 2375 hint = "\nMaybe bad inline comment, 3 spaces needed before //."
2376 2376
2377 raise LoggingConfigError( 2377 raise LoggingConfigError(
2378 'Error parsing json logging dict (%(file)s) ' 2378 'Error parsing json logging dict (%(file)s) '
2379 'near \n\n %(line)s\n\n' 2379 'near \n\n %(line)s\n\n'
2380 '%(msg)s: line %(lineno)s column %(colno)s.%(hint)s' % 2380 '%(msg)s: line %(lineno)s column %(colno)s.%(hint)s' %

Roundup Issue Tracker: http://roundup-tracker.org/