From da21a7219ee5ff56f6ee2d71f9b84a49a702402b Mon Sep 17 00:00:00 2001 From: Thomas Matthijs Date: Sun, 3 Jul 2005 13:41:45 +0000 Subject: remove some code duplication svn path=/java-config-ng/branches/axxo/; revision=301 --- src/java_config/EnvironmentManager.py | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/java_config/EnvironmentManager.py b/src/java_config/EnvironmentManager.py index 377fcca..725fa49 100644 --- a/src/java_config/EnvironmentManager.py +++ b/src/java_config/EnvironmentManager.py @@ -217,19 +217,9 @@ class EnvironmentManager: classpath = re.sub(':+', ':', classpath) classpath.strip(':') - if os.path.isfile(env_file): - try: - os.remove(env_file) - except IOError: - raise PermissionError - - try: - stream = open(env_file, 'w') - except IOError: - raise PermissionError + self.clean_classpath(env_file) - stream.write("CLASSPATH=%s\n" % (classpath)) - stream.close() + self_write_classpath(env_file, classpath) def append_classpath(self, env_file, pkgs): classpath = self.query_packages(pkgs, "CLASSPATH") @@ -255,12 +245,11 @@ class EnvironmentManager: classpath = oldClasspath + ':' + classpath - if os.path.isfile(env_file): - try: - os.remove(env_file) - except IOError: - raise PermissionError + self.clean_classpath(env_file) + + self_write_classpath(env_file, classpath) + def write_classpath(self, env_file, classpath): try: stream = open(env_file, 'w') except IOError: -- cgit v1.2.3