-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathseries_conf
More file actions
executable file
·68 lines (60 loc) · 2.43 KB
/
series_conf
File metadata and controls
executable file
·68 lines (60 loc) · 2.43 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018 SUSE LLC
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
# USA.
# This script is used by the commit hook to detect if there are changes in the
# sorted section. Developers may commit to kernel-source without having changed
# the sorted section and used the git-sort tools, therefore without having the
# pygit2 module available. Therefore, this script should avoid a dependency on
# pygit2 since it's not present on a default python install and we don't want to
# force developers to install pygit2 just to commit unrelated changes to
# kernel-source.
import argparse
import sys
from git_sort.series_conf import split, filter_series
from suse_git.patch import Patch
from suse_git import exc
parser = argparse.ArgumentParser(
description="Extract the sorted patches section of a series.conf file.")
parser.add_argument("-n", "--name-only", action="store_true",
help="Print only patch names.")
parser.add_argument("series", nargs="?", metavar="series.conf",
help="series.conf file. Default: read input from stdin.")
args = parser.parse_args()
if args.series is not None:
f = open(args.series)
else:
f = sys.stdin
lines = f.readlines()
try:
before, inside, after = split(lines)
except exc.KSNotFound:
pass
else:
if args.name_only:
inside = filter_series(inside)
inside = [line + "\n" for line in inside]
try:
sys.stdout.writelines(inside)
# Avoid an unsightly error that may occur when not all output is
# read:
# Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
# BrokenPipeError: [Errno 32] Broken pipe
sys.stdout.flush()
except BrokenPipeError:
sys.stderr.close()
sys.exit()