aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrice Clement <monsieurp@gentoo.org>2017-06-26 17:22:59 +0200
committerPatrice Clement <monsieurp@gentoo.org>2017-06-26 17:22:59 +0200
commit804e4527673d52f0c67ee90cf3541c1f8f2de957 (patch)
treee63c94e73a14e7c2062f64b83dd7ac3e6e1406df
parentreformat documentation (diff)
downloadjava-config-804e4527673d52f0c67ee90cf3541c1f8f2de957.tar.gz
java-config-804e4527673d52f0c67ee90cf3541c1f8f2de957.tar.bz2
java-config-804e4527673d52f0c67ee90cf3541c1f8f2de957.zip
wrapped needed vars check logic in a variable
-rw-r--r--src/java_config_2/VM.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/java_config_2/VM.py b/src/java_config_2/VM.py
index 4709e37..6213be1 100644
--- a/src/java_config_2/VM.py
+++ b/src/java_config_2/VM.py
@@ -1,8 +1,6 @@
# -*- coding: UTF-8 -*-
-
# Copyright 2004-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: $
from .FileParser import *
from .Errors import *
@@ -12,13 +10,12 @@ import os
# Dont accept env files without these variables
NEEDED_VARS = [ "JAVA_HOME", "PROVIDES_TYPE", "PROVIDES_VERSION" ]
+
class VM:
def __init__(self, file):
self.file = file
self.config = EnvFileParser(file).get_config()
- for var in NEEDED_VARS:
- if var not in self.config:
- raise InvalidVMError("Missing: %s" % var)
+ self.check_for_needed_vars()
def __eq__(self, other):
return self.version() == other.version()
@@ -41,6 +38,11 @@ class VM:
def __str__(self):
return self.name()
+ def check_for_needed_vars(self):
+ for var in NEEDED_VARS:
+ if var not in self.config:
+ raise InvalidVMError("Missing: %s" % var)
+
def get_config(self):
return self.config
@@ -99,4 +101,4 @@ class VM:
raise PermissionError
return None
-# vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap:
+# vim:set expandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap: \ No newline at end of file