aboutsummaryrefslogtreecommitdiffstats
path: root/src/extract
diff options
context:
space:
mode:
Diffstat (limited to 'src/extract')
-rwxr-xr-xsrc/extract/cut46
-rwxr-xr-xsrc/extract/libgamma-error-extract26
-rwxr-xr-xsrc/extract/libgamma-method-extract120
3 files changed, 0 insertions, 192 deletions
diff --git a/src/extract/cut b/src/extract/cut
deleted file mode 100755
index ad7c81a..0000000
--- a/src/extract/cut
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/env python
-# -*- mode: python, encoding: utf-8 -*-
-# See LICENSE file for copyright and license details.
-
-# Very limited GNU cut.
-
-
-import sys
-
-
-delimiter = '\t'
-fields = []
-complement = False
-
-
-i, n = 1, len(sys.argv)
-while i < n:
- arg = sys.argv[i]
- if arg == '-d':
- i += 1
- delimiter = sys.argv[i]
- elif arg == '-f':
- i += 1
- fields += [int(f) - 1 for f in sys.argv[i].split(',')]
- elif arg == '--complement':
- complement = True
- i += 1
-
-
-fields = set(fields)
-
-
-def modify(line):
- line = line.split(delimiter)
- if complement:
- line = [line[i] for i in range(len(line)) if i not in fields]
- else:
- line = [line[i] for i in range(len(line)) if i in fields]
- return delimiter.join(line)
-
-
-data = sys.stdin.read()
-data = '\n'.join(modify(line) for line in data.split('\n'))
-sys.stdout.write(data)
-sys.stdout.flush()
-
diff --git a/src/extract/libgamma-error-extract b/src/extract/libgamma-error-extract
deleted file mode 100755
index cbfb93a..0000000
--- a/src/extract/libgamma-error-extract
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-# -*- mode: python, encoding: utf-8 -*-
-# See LICENSE file for copyright and license details.
-
-import sys
-import os
-
-with open(os.path.dirname(sys.argv[0]) + '/../lib/libgamma-error.h', 'rb') as file:
- data = file.read()
-data = data.decode('utf-8')
-
-if sys.argv[1] == '--list':
- defs = [line for line in data.split('\n') if line.startswith('#define') and not line.endswith('_H')]
- defs = [line.split(' ')[1] for line in defs if 'LIBGAMMA_ERROR_MIN' not in line]
- print('\n'.join(defs))
-
-else:
- i = data.find('\n#define ' + sys.argv[1])
- data = data[:i]
- i = data.rfind('\n */')
- data = data[:i]
- i = data.rfind('/**\n')
- data = data[i + len('/**\n'):]
- data = [line[3:] for line in data.split('\n')]
- print('\n'.join(data))
-
diff --git a/src/extract/libgamma-method-extract b/src/extract/libgamma-method-extract
deleted file mode 100755
index b967ab3..0000000
--- a/src/extract/libgamma-method-extract
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python
-# -*- mode: python, encoding: utf-8 -*-
-# See LICENSE file for copyright and license details.
-
-import sys
-import os
-
-with open(os.path.dirname(sys.argv[0]) + '/../lib/libgamma-method.h', 'rb') as file:
- data = file.read()
-data = data.decode('utf-8')
-
-
-def list_define(prefix, *blacklist):
- global data
- test1 = lambda line : line.startswith('#define ' + prefix)
- test2 = lambda line : line.split(' ')[1] not in [prefix + b for b in list(blacklist)]
- test3 = lambda line : not line.endswith('_H')
- defs = [line for line in data.split('\n') if test1(line) and test2(line) and test3(line)]
- print('\n'.join([d.split(' ')[1] for d in defs]))
-
-def list_enum(prefix, *blacklist):
- global data
- test1 = lambda line : line.strip().startswith(prefix)
- test2 = lambda line : line.split(' ')[1] not in [prefix + b for b in list(blacklist)]
- defs = [line for line in data.split('\n') if test1(line) and test2(line)]
- print('\n'.join([d.strip().split(' ')[0].rstrip(',') for d in defs]))
-
-def list_struct(name):
- global data
- data = data[data.find('\ntypedef struct ' + name + '\n'):]
- data = data[:data.find('\n}')]
- test1 = lambda line : line.startswith(' ') and line.endswith(';')
- test2 = lambda line : ' * ' not in line
- defs = [line for line in data.split('\n') if test1(line) and test2(line)]
- print('\n'.join([d.strip().split(' : ')[0].split(' ')[-1].rstrip(';') for d in defs]))
-
-
-def type_struct(name):
- global data
- data = data[data.find('\ntypedef struct ' + name + '\n'):]
- data = data[:data.find('\n}')]
- test1 = lambda line : line.startswith(' ')
- test2 = lambda line : ' * ' not in line
- test3 = lambda line : line.strip().split(' : ')[0].split(' ')[-1].rstrip(';') == sys.argv[3]
- defs = [line for line in data.split('\n') if test1(line) and test2(line) and test3(line)]
- line = defs[0].strip().rstrip(';')
- if ' : ' in line:
- line = line.split(' : ')
- line[0] = ' '.join(line[0].split(' ')[:-1])
- print(':'.join(line))
- else:
- print(' '.join(line.split(' ')[:-1]))
-
-
-def doc_typedef(name):
- global data
- data = data[:data.find('\ntypedef ' + name + '\n'):]
- data = data[:data.rfind('\n */')]
- data = data[data.rfind('/**\n') + len('/**\n'):]
- data = [line[3:] for line in data.split('\n')]
- print('\n'.join(data))
-
-
-def doc_define():
- global data
- data = data[:data.find('\n#define ' + sys.argv[2] + ' ')]
- data = data[:data.rfind('\n */')]
- data = data[data.rfind('/**\n') + len('/**\n'):]
- data = [line[3:] for line in data.split('\n')]
- print('\n'.join(data))
-
-def doc_enum():
- global data
- while '\n ' in data:
- data = data.replace('\n ', '\n')
- data = data[:data.find('\n' + sys.argv[2])]
- data = data[:data.rfind('\n*/')]
- data = data[data.rfind('/**\n') + len('/**\n'):]
- data = [line[2:] for line in data.split('\n')]
- print('\n'.join(data))
-
-def doc_struct(name):
- global data
- data = data[data.find('\ntypedef struct ' + name + '\n'):]
- data = data[:data.find('\n}')]
- test1 = lambda line : line.startswith(' ')
- test2 = lambda line : ' * ' not in line
- test3 = lambda line : line.strip().split(' : ')[0].split(' ')[-1].rstrip(';') == sys.argv[2]
- defs = [line for line in data.split('\n') if test1(line) and test2(line) and test3(line)]
- line = defs[0]
- data = data[:data.find('\n' + line)]
- while '\n ' in data:
- data = data.replace('\n ', '\n')
- data = data[:data.rfind('\n*/')]
- data = data[data.rfind('/**\n') + len('/**\n'):]
- data = [line[2:] for line in data.split('\n')]
- print('\n'.join(data))
-
-
-struct_map = {'--info-t' : 'libgamma_crtc_information',
- '--cap-t' : 'libgamma_method_capabilities',
- '--site-t' : 'libgamma_site_state',
- '--part-t' : 'libgamma_partition_state',
- '--crtc-t' : 'libgamma_crtc_state'}
-
-if sys.argv[1] == '--list':
- if sys.argv[2] == '--method': list_define('LIBGAMMA_METHOD_', 'MAX', 'COUNT')
- elif sys.argv[2] == '--info': list_define('LIBGAMMA_CRTC_INFO_', 'COUNT')
- elif sys.argv[2] == '--connector': list_enum('LIBGAMMA_CONNECTOR_TYPE_', 'COUNT')
- elif sys.argv[2] == '--subpixel': list_enum('LIBGAMMA_SUBPIXEL_ORDER_', 'COUNT')
- elif sys.argv[2] in struct_map: list_struct(struct_map[sys.argv[2]])
-elif sys.argv[1] == '--type':
- if sys.argv[2] in struct_map: type_struct(struct_map[sys.argv[2]])
-elif sys.argv[1] == '--doc':
- if sys.argv[2] in struct_map: doc_typedef('struct ' + struct_map[sys.argv[2]])
-else:
- if sys.argv[1] in ('--method', '--info'): doc_define()
- elif sys.argv[1] in ('--connector', '--subpixel'): doc_enum()
- elif sys.argv[1] in struct_map: doc_struct(struct_map[sys.argv[1]])
-