File: diff-to-bytes-output

package info (click to toggle)
broctl 1.4-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 2,220 kB
  • sloc: python: 4,931; sh: 1,188; makefile: 70; awk: 24
file content (23 lines) | stat: -rwxr-xr-x 538 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /usr/bin/env python
#
# Convert large integers in the to-bytes.awk output to floating point
# exponential format, because some versions of awk output large integers in
# that format.

from __future__ import print_function
import sys

for line in sys.stdin:
    outstr = ""
    for field in line.split():
        try:
            num = float(field)
        except ValueError:
            num = 0

        if num > 2147483647:
            outstr += "%.5e " % num
        else:
            outstr += "%s " % field

    print(outstr[:-1])