]> git.proxmox.com Git - mirror_ovs.git/blame - build-aux/dpdkstrip.py
Recommend Sphinx from Python 3 in documentation and packaging.
[mirror_ovs.git] / build-aux / dpdkstrip.py
CommitLineData
ab451489 1#! /usr/bin/env python3
dd6f26a9
BP
2# Copyright (c) 2017 Red Hat, Inc.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at:
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16import getopt
17import sys
18
19
20def strip_dpdk(check_dpdk, src, dst):
21 disabled_print = False
22 while True:
23 line = src.readline()
24 if not line:
25 break
26 if '@begin_dpdk@' in line or '@end_dpdk@' in line:
27 if not check_dpdk:
28 disabled_print = not disabled_print
29 continue
30 if not disabled_print:
31 dst.write(line)
32
33
34if __name__ == '__main__':
35 check_dpdk = False
36 options, args = getopt.gnu_getopt(sys.argv[1:], '', ['dpdk', 'nodpdk'])
37 for key, value in options:
38 if key == '--dpdk':
39 check_dpdk = True
40 elif key == '--nodpdk':
41 check_dpdk = False
42 else:
43 assert False
44 if args:
45 for arg in args:
46 strip_dpdk(check_dpdk, open(arg), sys.stdout)
47 else:
48 strip_dpdk(check_dpdk, sys.stdin, sys.stdout)