From 804e4527673d52f0c67ee90cf3541c1f8f2de957 Mon Sep 17 00:00:00 2001 From: Patrice Clement Date: Mon, 26 Jun 2017 17:22:59 +0200 Subject: wrapped needed vars check logic in a variable --- src/java_config_2/VM.py | 14 ++++++++------ 1 file 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 -- cgit v1.2.3-65-gdbad