scripts/get-developers: correct type of patches argument

Current type for 'patches' argument is str. It supposed to only
contain names of files.

If we specify FileType as type, then we don't need to open file ourself
and it allows script to read patch from standard input as well.

e.g.
$ git show -1 | ./support/scripts/get-developers -

Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
Rahul Bedarkar 2016-09-22 00:29:14 +05:30 committed by Thomas Petazzoni
parent 8513ffee43
commit 1b0df8f23c
2 changed files with 14 additions and 15 deletions

View File

@ -5,8 +5,8 @@ import getdeveloperlib
def parse_args(): def parse_args():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('patches', metavar='P', type=str, nargs='*', parser.add_argument('patches', metavar='P', type=argparse.FileType('r'), nargs='*',
help='list of patches') help='list of patches (use - to read patches from stdin)')
parser.add_argument('-a', dest='architecture', action='store', parser.add_argument('-a', dest='architecture', action='store',
help='find developers in charge of this architecture') help='find developers in charge of this architecture')
parser.add_argument('-p', dest='package', action='store', parser.add_argument('-p', dest='package', action='store',

View File

@ -16,19 +16,18 @@ def analyze_patch(patch):
removed by the patch.""" removed by the patch."""
files = set() files = set()
infras = set() infras = set()
with open(patch, "r") as f: for line in patch:
for line in f: # If the patch is adding a package, find which infra it is
# If the patch is adding a package, find which infra it is m = FIND_INFRA_IN_PATCH.match(line)
m = FIND_INFRA_IN_PATCH.match(line) if m:
if m: infras.add(m.group(2))
infras.add(m.group(2)) if not line.startswith("+++ "):
if not line.startswith("+++ "): continue
continue line.strip()
line.strip() fname = line[line.find("/") + 1 : ].strip()
fname = line[line.find("/") + 1 : ].strip() if fname == "dev/null":
if fname == "dev/null": continue
continue files.add(fname)
files.add(fname)
return (files, infras) return (files, infras)
FIND_INFRA_IN_MK = re.compile("^\$\(eval \$\((host-)?([^-]*)-package\)\)$") FIND_INFRA_IN_MK = re.compile("^\$\(eval \$\((host-)?([^-]*)-package\)\)$")