aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/py/findclass')
-rwxr-xr-xsrc/py/findclass32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/py/findclass b/src/py/findclass
index 15802c9..0581acc 100755
--- a/src/py/findclass
+++ b/src/py/findclass
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
#
# Copyright (c) Karl Trygve Kalleberg <karltk@gentoo.org>
# Copyright (c) Fabio Lessa <flessa@gmail.com>
@@ -15,16 +15,17 @@ import re
import sys
import glob
from optparse import OptionParser
-from commands import getstatusoutput
+from subprocess import getstatusoutput
from java_config.jc_util import find_exec, collect_packages
+
__author__ = "Karl Trygve Kalleberg <karltk@gentoo.org> and Fabio Lessa <flessa@gmail.com>"
__version__ = "0.1.0"
__productname__ = "findclass"
__description__ = "Gentoo Java Class Query Tool"
-def parse_args():
+def parse_args():
usage = 'findclass [options] class.or.package.Name'
about = __productname__ + " : " + __description__ + "\n" + \
"Authors : " + __author__ + \
@@ -40,39 +41,36 @@ def parse_args():
return opt, files
+
def main():
-
opt, files = parse_args()
jarcmd = find_exec('jar')
-
+
javapaths = [ f.replace('.', '/') for f in files ]
matchers = [ re.compile(p) for p in javapaths ]
for pkg in get_all_packages():
- if opt.verbose: print "Searching package %s" % pkg
-
+ if opt.verbose: print("Searching package %s" % pkg)
for jar in collect_packages(pkg).split(':'):
- if opt.verbose: print "Searching jar %s" % jar
-
+ if opt.verbose: print("Searching jar %s" % jar)
status, out = getstatusoutput("%s tvf %s" % (jarcmd, jar))
-
for m in matchers:
if m.search(out):
- if opt.verbose: print "Found in %s" % pkg,
- print jar
+ if opt.verbose: print("Found in %s" % pkg, end=' ')
+ print(jar)
-def get_all_packages():
+def get_all_packages():
pkg = glob.glob('/usr/share/*/package.env')
pkg = [os.path.basename(os.path.dirname(i)) for i in pkg]
-
+
classpath = glob.glob('/usr/share/*/classpath.env')
classpath = [os.path.basename(os.path.dirname(i)) for i in classpath]
-
+
dir = glob.glob('/usr/share/java/packages/*')
dir = [os.path.basename(i) for i in dir]
-
+
pkg.extend(classpath)
pkg.extend(dir)
return pkg
@@ -82,4 +80,4 @@ if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
- print "Interrupted by user, aborting."
+ print("Interrupted by user, aborting.")