Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 132548 | Differences between
and this patch

Collapse All | Expand All

(-)esearch-0.7.1/esearch.py (-37 / +47 lines)
Lines 64-79 Link Here
64
    if fatal:
64
    if fatal:
65
        sys.exit(1)
65
        sys.exit(1)
66
66
67
def searchEbuilds(path, portdir = True, searchdef = ""):
67
def searchEbuilds(path, portdir = True, searchdef = "", repo_num = ""):
68
    global ebuilds, output, defebuild
68
    global ebuilds, output, defebuild
69
    pv = ""
69
    pv = ""
70
    pkgs = []
70
    pkgs = []
71
    nr = len(ebuilds) + 1
71
    nr = len(ebuilds) + 1
72
72
73
    if portdir:
73
    if portdir:
74
        rep = darkgreen("Portage")
74
        rep = darkgreen("Portage    ")
75
    else:
75
    else:
76
        rep = red("Overlay")
76
        rep = red("Overlay "+str(repo_num)+"  ")
77
77
78
    if isdir(path):
78
    if isdir(path):
79
        list = listdir(path)
79
        list = listdir(path)
Lines 82-88 Link Here
82
            if file[-7:] == ".ebuild":
82
            if file[-7:] == ".ebuild":
83
                pv = file[:-7]
83
                pv = file[:-7]
84
                pkgs.append(pkgsplit(pv))
84
                pkgs.append(pkgsplit(pv))
85
                pkgs[-1].append(path + "/" + file)
85
                pkgs[-1].append(path + file)
86
                if searchdef != "" and pv == searchdef:
86
                if searchdef != "" and pv == searchdef:
87
                    defebuild = (searchdef, pkgs[-1][3])
87
                    defebuild = (searchdef, pkgs[-1][3])
88
        pkgs.sort(pkgcmp)
88
        pkgs.sort(pkgcmp)
Lines 91-99 Link Here
91
            if pkg[2] != "r0":
91
            if pkg[2] != "r0":
92
                rev = "-" + pkg[2]
92
                rev = "-" + pkg[2]
93
            output.append(" " + rep + " [" + bold(str(nr)) + "] " + pkg[0] + "-" + pkg[1] + rev + "\n")
93
            output.append(" " + rep + " [" + bold(str(nr)) + "] " + pkg[0] + "-" + pkg[1] + rev + "\n")
94
            ebuilds.append(pkg[3])
94
            ebuilds.append(pkg[len(pkg)-1])
95
            nr += 1
95
            nr += 1
96
96
 
97
NORMAL =  1
97
NORMAL =  1
98
COMPACT = 2
98
COMPACT = 2
99
VERBOSE = 3
99
VERBOSE = 3
Lines 128-134 Link Here
128
        from output import blue
128
        from output import blue
129
        from common import version
129
        from common import version
130
        outputm = VERBOSE
130
        outputm = VERBOSE
131
    elif arg in ("-e", "--ebuilds"):
131
    elif arg in ("-e", "--ebuild"):
132
        from os import listdir, getenv, system
132
        from os import listdir, getenv, system
133
        from os.path import isdir
133
        from os.path import isdir
134
        from portage import settings, pkgcmp, pkgsplit
134
        from portage import settings, pkgcmp, pkgsplit
Lines 313-324 Link Here
313
                else:
313
                else:
314
                    searchdef = ""
314
                    searchdef = ""
315
315
316
                searchEbuilds("%s/%s/" % (portdir, pkg[1]), True, searchdef)
316
                searchEbuilds("%s/%s/" % (portdir, pkg[1]), True, searchdef, "")
317
                if overlay:
317
                if overlay:
318
                    searchEbuilds("%s/%s/" % (overlay, pkg[1]), False, searchdef)
318
                    repo_num=1
319
                    for repo in overlay.split():
320
                        searchEbuilds("%s/%s/" % ( repo, pkg[1]), False, searchdef,repo_num)
321
                        repo_num += 1
319
322
320
                output.append("\n")
323
                output.append("\n")
321
322
            count += 1
324
            count += 1
323
325
324
    regexlist[i][2] = "".join(output)
326
    regexlist[i][2] = "".join(output)
Lines 338-371 Link Here
338
    if outputm == NORMAL:
340
    if outputm == NORMAL:
339
        print ""
341
        print ""
340
342
341
if outputm == EBUILDS and count != 0:
342
    if count > 1:
343
        defebuild = (0, 0)
344
343
345
    if len(ebuilds) == 1:
344
if outputm == EBUILDS:
346
        nr = 1
345
    if overlay:
347
    else:
346
        repo_num=1
348
        if defebuild[0] != 0:
347
        for repo in overlay.split():
349
            print bold("Show Ebuild"), " (" + darkgreen(defebuild[0]) + "): ",
348
            print red("Overlay "+str(repo_num)+" : "+repo)
349
            repo_num += 1
350
    
351
    if count != 0:
352
        if count > 1:
353
            defebuild = (0, 0)
354
355
        if len(ebuilds) == 1:
356
            nr = 1
350
        else:
357
        else:
351
            print bold("Show Ebuild: "),
358
            if defebuild[0] != 0:
359
                print bold("\nShow Ebuild"), " (" + darkgreen(defebuild[0]) + "): ",
360
            else:
361
                print bold("\nShow Ebuild: "),
362
            try:
363
                nr = sys.stdin.readline()
364
            except KeyboardInterrupt:
365
                sys.exit(1)
352
        try:
366
        try:
353
            nr = sys.stdin.readline()
367
            editor = getenv("EDITOR")
354
        except KeyboardInterrupt:
368
            if editor:
355
            sys.exit(1)
369
                system(editor + " " + ebuilds[int(nr) - 1])
356
    try:
370
            else:
357
        editor = getenv("EDITOR")
371
                print ""
358
        if editor:
372
                error("Please set EDITOR", False)
359
            system(editor + " " + ebuilds[int(nr) - 1])
373
        except IndexError:
360
        else:
361
            print ""
362
            error("Please set EDITOR", False)
363
    except IndexError:
364
        print ""
365
        error("No such ebuild", False)
366
    except ValueError:
367
        if defebuild[0] != 0:
368
            system(editor + " " + defebuild[1])
369
        else:
370
            print ""
374
            print ""
371
            error("Please enter a valid number", False)
375
            error("No such ebuild", False)
376
        except ValueError:
377
            if defebuild[0] != 0:
378
                system(editor + " " + defebuild[1])
379
            else:
380
                print ""
381
                error("Please enter a valid number", False)

Return to bug 132548