aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPatrice Clement <monsieurp@gentoo.org>2017-06-02 22:17:38 +0200
committerPatrice Clement <monsieurp@gentoo.org>2017-06-02 22:17:38 +0200
commitb687cad439d50231fde35793f8c2ad4aa48b2a8e (patch)
tree4380ec8e41620ee317855e123d7ddb6772352da4 /src
parentheaders must go (diff)
downloadjava-config-b687cad439d50231fde35793f8c2ad4aa48b2a8e.tar.gz
java-config-b687cad439d50231fde35793f8c2ad4aa48b2a8e.tar.bz2
java-config-b687cad439d50231fde35793f8c2ad4aa48b2a8e.zip
remove a bunch of useless elses
Diffstat (limited to 'src')
-rwxr-xr-xsrc/java-config-278
1 files changed, 33 insertions, 45 deletions
diff --git a/src/java-config-2 b/src/java-config-2
index 8bcb821..bf7c48d 100755
--- a/src/java-config-2
+++ b/src/java-config-2
@@ -57,10 +57,9 @@ def tools(option, opt, value, parser):
except EnvironmentUndefinedError:
fatalError("JAVA_HOME not found in the active VM environment")
tools_jar = jh + '/lib/tools.jar'
- if os.path.exists(tools_jar):
- printer._print(tools_jar)
- else:
+ if not os.path.exists(tools_jar):
sys.exit(1);
+ printer._print(tools_jar)
def show_active_vm(option, opt, value, parser):
printer._print(manager.get_active_vm().name())
@@ -118,13 +117,13 @@ def query_pkg(option, opt, value, parser):
sys.exit(1)
def get_virtual_providers( option, opt, value, parser):
- if manager.get_virtual(value):
- output = manager.get_virtual(value).get_packages()
- printer._print(','.join(output))
- else:
+ if not manager.get_virtual(value):
printer._printError("Virtual package %s was not found" % value)
sys.exit(1)
+ output = manager.get_virtual(value).get_packages()
+ printer._print(','.join(output))
+
def get_env(option, opt, value, parser):
for env in value.split(','):
query_active_vm(env)
@@ -167,61 +166,50 @@ def list_available_vms(option, opt, value, parser):
def print_environment(option, opt, value, parser):
vm = manager.get_vm(value)
- if vm:
- manager.create_env_entry(vm, printer, "%s=%s")
- else:
+ if not vm:
fatalError("Could not find a vm matching: %s" % value)
+ manager.create_env_entry(vm, printer, "%s=%s")
def set_system_vm(option, opt, value, parser):
deprecation_notice()
-
vm = manager.get_vm(value)
-
if not vm:
fatalError("Could not find a vm matching: %s" % value)
- else:
- try:
- manager.set_system_vm(vm)
- printer._print("Now using %s as your generation-2 system JVM" % (vm) )
- if vm.is_build_only():
- printer._printWarning("%s is marked as a build-only JVM. Using this vm is not recommended. " % (vm))
- except PermissionError:
- fatalError("You do not have enough permissions to set the system VM!")
- except EnvironmentUndefinedError:
- fatalError("The selected VM is missing critical environment variables.")
- except InvalidConfigError as e:
- fatalError("Target file already exists and is not a symlink: %s" % e.file)
+ try:
+ manager.set_system_vm(vm)
+ printer._print("Now using %s as your generation-2 system JVM" % (vm) )
+ if vm.is_build_only():
+ printer._printWarning("%s is marked as a build-only JVM. Using this vm is not recommended. " % (vm))
+ except PermissionError:
+ fatalError("You do not have enough permissions to set the system VM!")
+ except EnvironmentUndefinedError:
+ fatalError("The selected VM is missing critical environment variables.")
+ except InvalidConfigError as e:
+ fatalError("Target file already exists and is not a symlink: %s" % e.file)
def set_user_vm(option, opt, value, parser):
deprecation_notice()
-
vm = manager.get_vm(value)
-
if not vm:
fatalError("Could not find a vm matching: %s" % value)
- else:
- if os.getuid() is 0:
- fatalError("The user 'root' should always use the System VM")
- else:
- try:
- manager.set_user_vm(vm)
- printer._print("Now using %s as your user JVM" % (vm))
- if vm.is_build_only():
- printer._printWarning("%s is marked as a build-only JVM. Using this vm is not recommended. " % (vm))
- except PermissionError:
- fatalError("You do not have enough permissions to set the VM!")
- except InvalidConfigError as e:
- fatalError("Target file already exists and is not a symlink: %s" % e.file)
+ if os.getuid() is 0:
+ fatalError("The user 'root' should always use the System VM")
+ try:
+ manager.set_user_vm(vm)
+ printer._print("Now using %s as your user JVM" % (vm))
+ if vm.is_build_only():
+ printer._printWarning("%s is marked as a build-only JVM. Using this vm is not recommended. " % (vm))
+ except PermissionError:
+ fatalError("You do not have enough permissions to set the VM!")
+ except InvalidConfigError as e:
+ fatalError("Target file already exists and is not a symlink: %s" % e.file)
def select_vm(option, opt, value, parser):
- if value == '':
- return
-
+ if not value: return
vm = manager.get_vm(value)
- if vm:
- manager.set_active_vm(manager.get_vm(value))
- else:
+ if not vm:
fatalError("The vm could not be found")
+ manager.set_active_vm(manager.get_vm(value))
def deprecation_notice():
printer._printWarning("Setting user and system vm using java-config is deprecated, use eselect java-vm instead.")