aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts/linux_system_error_list.py
blob: 43f1cb5ce4c94432ff6fc9161dac6004309c4662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/python

import re
from terminaltables  import DoubleTable

data = []
data.append(['Error', 'Code', 'Comment'])

def get_content(file):

    with open(file) as f:
        content = f.readlines()

    content = [x.strip() for x in content]

    for line in content:
        if re.search('define',line):
            line = re.sub('#define\t', '', line)
            line = re.sub('(?m)^#define .*\n?', '', line)
            line = re.sub('\t\t', '\t', line)
            line = re.sub('(/\*|\*/)', '', line)
            if line != '':
                data.append(re.split(r'\t',line))

get_content("/usr/include/asm-generic/errno-base.h")
get_content("/usr/include/asm-generic/errno.h")

table = DoubleTable(data, "Error code")
table.justify_columns = {0: 'right', 1: 'center', 2: 'left'}
print(table.table)