[asterisk-commits] russell: testsuite/asterisk/trunk r96 - /asterisk/trunk/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 17 22:15:04 CDT 2010
Author: russell
Date: Wed Mar 17 22:15:00 2010
New Revision: 96
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=96
Log:
reduce usage of unnecessary try/except blocks
Modified:
asterisk/trunk/asteriskversion.py
asterisk/trunk/run-tests.py
Modified: asterisk/trunk/asteriskversion.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asteriskversion.py?view=diff&rev=96&r1=95&r2=96
==============================================================================
--- asterisk/trunk/asteriskversion.py (original)
+++ asterisk/trunk/asteriskversion.py Wed Mar 17 22:15:00 2010
@@ -59,16 +59,12 @@
parts = self.version_str.split(".")
self.concept = parts[0]
self.major = parts[1]
- try:
+ self.minor = None
+ self.patch = None
+ if len(parts) >= 3:
self.minor = parts[2]
- except:
- self.minor = None
- self.patch = None
- if self.minor is not None:
- try:
- self.patch = parts[3]
- except:
- self.patch = None
+ if len(parts) >= 4:
+ self.patch = parts[3]
def __parse_svn_version(self):
self.svn = True
Modified: asterisk/trunk/run-tests.py
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/run-tests.py?view=diff&rev=96&r1=95&r2=96
==============================================================================
--- asterisk/trunk/run-tests.py (original)
+++ asterisk/trunk/run-tests.py Wed Mar 17 22:15:00 2010
@@ -64,6 +64,28 @@
self.__parse_config()
self.__check_deps(ast_version)
+ def __process_testinfo(self):
+ self.summary = "(none)"
+ self.description = "(none)"
+ if self.config.has_key("testinfo") is False:
+ return
+ testinfo = self.config["testinfo"]
+ if testinfo.has_key("summary"):
+ self.summary = testinfo["summary"]
+ if testinfo.has_key("description"):
+ self.description = testinfo["description"]
+
+ def __process_properties(self):
+ self.minversion = AsteriskVersion("1.4")
+ self.maxversion = None
+ if self.config.has_key("properties") is False:
+ return
+ properties = self.config["properties"]
+ if properties.has_key("minversion"):
+ self.minversion = AsteriskVersion(properties["minversion"])
+ if properties.has_key("maxversion"):
+ self.maxversion = AsteriskVersion(properties["maxversion"])
+
def __parse_config(self):
test_config = "tests/%s/test-config.yaml" % self.test_name
try:
@@ -73,28 +95,8 @@
except:
print "Failed to open %s, does it exist?" % test_config
- try:
- self.summary = self.config["testinfo"]["summary"]
- except:
- self.summary = ""
- try:
- self.description = self.config["testinfo"]["description"]
- except:
- self.description = ""
-
- try:
- self.minversion = \
- AsteriskVersion(self.config["properties"]["minversion"])
- except:
- self.minversion = AsteriskVersion("1.4")
- print "ERROR: No 'minversion' has been specified for %s" % \
- self.test_name
-
- try:
- self.maxversion = \
- AsteriskVersion(self.config["properties"]["maxversion"])
- except:
- self.maxversion = None
+ self.__process_testinfo()
+ self.__process_properties()
def __check_deps(self, ast_version):
self.deps = [
More information about the asterisk-commits
mailing list