MCPcopy Create free account
hub / github.com/apache/trafficserver / parse_records_file

Function parse_records_file

contrib/python/compare_records_config.py:25–49  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

23
24
25def parse_records_file(filename):
26 fh = open(filename)
27 settings = {}
28 for line in fh:
29 line = line.strip()
30 if line.startswith('CONFIG') or line.startswith('LOCAL'):
31 parts = line.split()
32 if parts[2] == 'FLOAT':
33 parts[3] = parts[3].rstrip('0')
34 if parts[2] == 'INT' and parts[3][-1] in 'KMG':
35 unit = parts[3][-1]
36 val = parts[3][:-1]
37 if unit == 'K':
38 val = int(val) * 1024
39 if unit == 'M':
40 val = int(val) * 1048576
41 if unit == 'G':
42 val = int(val) * 1073741824
43 parts[3] = str(val)
44 try:
45 settings[parts[1]] = parts[3]
46 except IndexError:
47 sys.stderr.write(f"Skipping malformed line: {line}\n")
48 continue
49 return settings
50
51
52def compare_settings(old, new):

Callers 1

Calls 3

strFunction · 0.85
splitMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected