7 templates = sys.argv[2:]
31 syntax_file = open('%s.sps' % fmt_name, 'w')
32 syntax_file.write('''\
33 DATA LIST NOTABLE FILE='%(fmt_name)s.input'/%(fmt_name)s 1-40 (%(fmt_name)s).
34 PRINT OUTFILE='%(fmt_name)s.output'/%(fmt_name)s (F16.2).
36 ''' % {'fmt_name': fmt_name})
39 expout_file = open('expout', 'w')
40 input_file = open('%s.input' % fmt_name, 'w')
42 def print_all_formats(d, h, m, s, template, formatted, expected, sign):
45 template = template[1:]
48 for new_sign in ('', '-', '+'):
49 print_all_formats(d, h, m, s, template,
50 formatted + new_sign, expected, new_sign)
52 for f in ('%d', '%02d'):
53 print_all_formats(0, h, m, s, template,
54 formatted + (f % d), expected + d * 86400,
57 for f in ('%d', '%02d'):
58 print_all_formats(0, 0, m, s, template,
59 formatted + (f % (h + d * 24)),
60 expected + h * 3600 + d * 86400,
63 for f in ('%d', '%02d'):
64 print_all_formats(0, 0, 0, s, template,
65 formatted + (f % (m + h * 60 + d * 1440)),
66 expected + m * 60 + h * 3600 + d * 86400,
69 for f in ('%.0f', '%02.0f', '%.1f', '%.2f'):
70 ns = s + m * 60 + h * 3600 + d * 86400
72 print_all_formats(0, 0, 0, 0, template,
73 formatted + formatted_s,
74 expected + float(formatted_s),
78 print_all_formats(d, h, m, s, template, formatted + f,
81 print_all_formats(d, h, m, s, template, formatted + ' ',
86 # Write the formatted value to fmt_name.input.
87 input_file.write('%s\n' % formatted)
89 # Write the expected value to 'expout'.
90 if sign == '-' and expected > 0:
92 expected_s = '%17.2f\n' % expected
93 expected_s = expected_s.replace(' 0.', ' .')
94 expout_file.write(expected_s)
97 for template in templates:
100 print_all_formats(d, h, m, s, template, '', 0, '')