From 78befa37b00844cba4aa2fb8adf74d487d02e017 Mon Sep 17 00:00:00 2001 From: James Troup Date: Sat, 19 Jan 2002 18:58:07 +0000 Subject: [PATCH] handle non-US non-main properly --- test/004/test.py | 12 +++++++++++- utils.py | 8 ++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/test/004/test.py b/test/004/test.py index e0a02d60..86aad8a6 100755 --- a/test/004/test.py +++ b/test/004/test.py @@ -2,7 +2,7 @@ # Check utils.extract_component_from_section() # Copyright (C) 2000 James Troup -# $Id: test.py,v 1.1 2001-06-10 16:35:04 troup Exp $ +# $Id: test.py,v 1.2 2002-01-19 18:58:07 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -107,6 +107,16 @@ def main (): input = "utIls"; output = ("utIls", "main"); test (input, output); + # Others.. + input = "non-US/libs"; output = ("non-US/libs", "non-US/main"); + test (input, output); + input = "non-US/main/libs"; output = ("non-US/main/libs", "non-US/main"); + test (input, output); + input = "non-US/contrib/libs"; output = ("non-US/contrib/libs", "non-US/contrib"); + test (input, output); + input = "non-US/non-free/libs"; output = ("non-US/non-free/libs", "non-US/non-free"); + test (input, output); + ################################################################################ if __name__ == '__main__': diff --git a/utils.py b/utils.py index 938134e8..ebe3f965 100644 --- a/utils.py +++ b/utils.py @@ -1,6 +1,6 @@ # Utility functions # Copyright (C) 2000, 2001 James Troup -# $Id: utils.py,v 1.36 2001-11-18 19:57:58 rmurray Exp $ +# $Id: utils.py,v 1.37 2002-01-19 18:58:07 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -import commands, os, pwd, re, socket, shutil, stat, string, sys, tempfile +import commands, os, pwd, re, socket, shutil, stat, string, sys, tempfile, traceback import apt_pkg re_comments = re.compile(r"\#.*") @@ -89,9 +89,9 @@ def extract_component_from_section(section): if string.find(section, '/') != -1: component = string.split(section, '/')[0]; if string.lower(component) == "non-us" and string.count(section, '/') > 0: - s = string.split(section, '/')[1]; + s = component + '/' + string.split(section, '/')[1]; if Cnf.has_key("Component::%s" % s): # Avoid e.g. non-US/libs - component = string.split(section, '/')[0]+ '/' + string.split(section, '/')[1]; + component = s; if string.lower(section) == "non-us": component = "non-US/main"; -- 2.39.5