change to lowercase method names wip
authorRichard Taylor <richard.i.taylor@nokia.com>
Fri, 30 Apr 2010 13:26:13 +0100
branchwip
changeset 504 ea75c3a64a17
parent 503 e182c2a8794d
child 505 ed08f3d1e6b9
change to lowercase method names
sbsv2/raptor/python/raptor.py
sbsv2/raptor/python/raptor_api.py
sbsv2/raptor/python/raptor_data.py
sbsv2/raptor/test/smoke_suite/query_cli.py
sbsv2/raptor/test/unit_suite/raptor_api_unit.py
--- a/sbsv2/raptor/python/raptor.py	Thu Apr 29 13:50:38 2010 +0100
+++ b/sbsv2/raptor/python/raptor.py	Fri Apr 30 13:26:13 2010 +0100
@@ -1239,11 +1239,11 @@
 		import raptor_api
 		api = raptor_api.Context(self)
 		
-		print "<sbs version='%s'>" % raptor_version.fullversion()
+		print "<sbs version='%s'>" % raptor_version.numericversion()
 		
 		for q in self.queries:
 			try:
-				print api.StringQuery(q)
+				print api.stringquery(q)
 				
 			except Exception, e:
 				self.Error("exception '%s' with query '%s'", str(e), q)
--- a/sbsv2/raptor/python/raptor_api.py	Thu Apr 29 13:50:38 2010 +0100
+++ b/sbsv2/raptor/python/raptor_api.py	Fri Apr 30 13:26:13 2010 +0100
@@ -60,13 +60,21 @@
 		return string
 
 class Alias(Reply):
-	pass
+	def __init__(self, name, meaning):
+		super(Alias,self).__init__()
+		self.name = name
+		self.meaning = meaning
 
 class Config(Reply):
-	pass
+	def __init__(self, fullname, outputpath):
+		super(Config,self).__init__()
+		self.fullname = fullname
+		self.outputpath = outputpath
 
 class Product(Reply):
-	pass
+	def __init__(self, name):
+		super(Product,self).__init__()
+		self.name = name
 
 import generic_path
 import raptor
@@ -79,7 +87,7 @@
 	For example,
 	
 	api = raptor_api.Context()
-	val = api.get(X)
+	val = api.getaliases("X")
 	"""
 	def __init__(self, initialiser=None):
 		# this object has a private Raptor object that can either be
@@ -90,7 +98,7 @@
 		else:
 			self.__raptor = initialiser
 			
-	def StringQuery(self, query):
+	def stringquery(self, query):
 		"""turn a string into an API call and execute it.
 		
 		This is a convenience method for "lazy" callers.
@@ -99,24 +107,24 @@
 		"""
 		
 		if query == "aliases":
-			aliases = self.GetAliases()
+			aliases = self.getaliases()
 			return "".join(map(str, aliases)).strip()
 		
 		elif query == "products":
-			variants = self.GetProducts()
+			variants = self.getproducts()
 			return "".join(map(str, variants)).strip()
 		
 		elif query.startswith("config"):
 			match = re.match("config\[(.*)\]", query)
 			if match:
-				config = self.GetConfig(match.group(1))
+				config = self.getconfig(match.group(1))
 				return str(config).strip()
 			else:
 				raise BadQuery("syntax error")
 		
 		raise BadQuery("unknown query")
 
-	def GetAliases(self, type=""):
+	def getaliases(self, type=""):
 		"""extract all aliases of a given type.
 		
 		the default type is "".
@@ -126,15 +134,12 @@
 		
 		for a in self.__raptor.cache.aliases.values():
 			if a.type == type or type == None:
-				r = Alias()
 				# copy the members we want to expose
-				r.name = a.name
-				r.meaning = a.meaning
-				aliases.append(r)
+				aliases.append( Alias(a.name, a.meaning) )
 			
 		return aliases
 	
-	def GetConfig(self, name):
+	def getconfig(self, name):
 		"""extract the values for a given configuration.
 		
 		'name' should be an alias or variant followed optionally by a
@@ -191,22 +196,17 @@
 			
 			outputpath = str(generic_path.Join(releasepath, variantplatform, varianttype))
 		
-		r = Config()
-		r.fullname = fullname
-		r.outputpath = outputpath
-		return r
+		return Config(fullname, outputpath)
 		
-	def GetProducts(self):
+	def getproducts(self):
 		"""extract all product variants."""
 		
 		variants = []
 		
 		for v in self.__raptor.cache.variants.values():
 			if v.type == "product":
-				r = Product()
 				# copy the members we want to expose
-				r.name = v.name
-				variants.append(r)
+				variants.append( Product(v.name) )
 			
 		return variants
 	
--- a/sbsv2/raptor/python/raptor_data.py	Thu Apr 29 13:50:38 2010 +0100
+++ b/sbsv2/raptor/python/raptor_data.py	Fri Apr 30 13:26:13 2010 +0100
@@ -829,7 +829,7 @@
 
 class Variant(Model, Config):
 
-	__slots__ = ('cache','name','host','extends','ops','variantRefs','allOperations')
+	__slots__ = ('cache','name','type','host','extends','ops','variantRefs','allOperations')
 
 	def __init__(self, name = ""):
 		Model.__init__(self)
--- a/sbsv2/raptor/test/smoke_suite/query_cli.py	Thu Apr 29 13:50:38 2010 +0100
+++ b/sbsv2/raptor/test/smoke_suite/query_cli.py	Fri Apr 30 13:26:13 2010 +0100
@@ -24,7 +24,7 @@
 	t.name = "query_cli_alias"
 	t.command = "sbs --query=aliases"
 	t.mustmatch_singleline = [
-		"<sbs version='2.*'>",
+		"<sbs version='2\.\d+\.\d+'>",
 		"<alias.*name='armv5_urel'.*/>",
 		"<alias.*name='armv5_udeb'.*/>",
 		"<alias.*name='winscw_urel'.*/>",
@@ -42,7 +42,7 @@
 	t.name = "query_cli_product"
 	t.command = "sbs --query=products --configpath=test/smoke_suite/test_resources/bv"
 	t.mustmatch_singleline = [
-		"<sbs version='2.*'>",
+		"<sbs version='2\.\d+\.\d+'>",
 		"<product.*name='test_bv_1'.*/>",
 		"<product.*name='test_bv_2'.*/>",
 		"<product.*name='test_bv_3'.*/>",
@@ -57,7 +57,7 @@
 	t.name = "query_cli_config"
 	t.command = "sbs --query=config[armv5_urel]"
 	t.mustmatch_singleline = [
-		"<sbs version='2.*'>",
+		"<sbs version='2\.\d+\.\d+'>",
 		"fullname='arm\.v5\.urel\.rvct.*'",
 		"outputpath='.*/epoc32/release/armv5/urel'",
 		"</sbs>"
@@ -68,9 +68,9 @@
 	t.name = "query_cli_config_bv"
 	t.command = "sbs --query=config[armv5_urel.test_bv_1] --configpath=test/smoke_suite/test_resources/bv"
 	t.mustmatch_singleline = [
-		"<sbs version='2.*'>",
+		"<sbs version='2\.\d+\.\d+'>",
 		"fullname='arm\.v5\.urel\.rvct._.\.test_bv_1'",
-		"outputpath='.*/epoc32/release/armv5.one/urel'",
+		"outputpath='.*/epoc32/release/armv5\.one/urel'",
 		"</sbs>"
 		]
 	t.mustnotmatch_singleline = []
@@ -85,7 +85,7 @@
 		t2 = raptor_tests.ReplaceEnvs("tools2/$(HOSTPLATFORM_DIR)")
 		
 	t.mustmatch_singleline = [
-		"<sbs version='2.*'>",
+		"<sbs version='2\.\d+\.\d+'>",
 		"outputpath='.*/epoc32/release/winscw/urel'",
 		"outputpath='.*/epoc32/release/%s/rel'" % t2,
 		"</sbs>"
@@ -96,7 +96,7 @@
 	t.name = "query_cli_bad"
 	t.command = "sbs --query=nonsense"
 	t.mustmatch_singleline = [
-		"<sbs version='2.*'>",
+		"<sbs version='2\.\d+\.\d+'>",
 		"exception 'unknown query' with query 'nonsense'",
 		"</sbs>"
 		]
--- a/sbsv2/raptor/test/unit_suite/raptor_api_unit.py	Thu Apr 29 13:50:38 2010 +0100
+++ b/sbsv2/raptor/test/unit_suite/raptor_api_unit.py	Fri Apr 30 13:26:13 2010 +0100
@@ -34,15 +34,15 @@
 
 		api = raptor_api.Context(r)
 	
-		aliases = api.GetAliases() # type == ""
+		aliases = api.getaliases() # type == ""
 		self.failUnlessEqual(len(aliases), 4)
 		self.failUnlessEqual(set(["alias_A","alias_B","s1","s2"]),
 							 set(a.name for a in aliases))
 		
-		aliases = api.GetAliases(None) # ignore type
+		aliases = api.getaliases(None) # ignore type
 		self.failUnlessEqual(len(aliases), 6)
 		
-		aliases = api.GetAliases("X") # type == "X"
+		aliases = api.getaliases("X") # type == "X"
 		self.failUnlessEqual(len(aliases), 1)
 		self.failUnlessEqual(aliases[0].name, "alias_D")
 		self.failUnlessEqual(aliases[0].meaning, "a.b.c.d")
@@ -58,19 +58,19 @@
 		else:
 			path = "C:/home/raptor/foo/bar"
 			
-		config = api.GetConfig("buildme")
+		config = api.getconfig("buildme")
 		self.failUnlessEqual(config.fullname, "buildme")
 		self.failUnlessEqual(config.outputpath, path)
 		
-		config = api.GetConfig("buildme.foo")
+		config = api.getconfig("buildme.foo")
 		self.failUnlessEqual(config.fullname, "buildme.foo")
 		self.failUnlessEqual(config.outputpath, path)
 		
-		config = api.GetConfig("s1")
+		config = api.getconfig("s1")
 		self.failUnlessEqual(config.fullname, "buildme.foo")
 		self.failUnlessEqual(config.outputpath, path)
 		
-		config = api.GetConfig("s2.product_A")
+		config = api.getconfig("s2.product_A")
 		self.failUnlessEqual(config.fullname, "buildme.foo.bar.product_A")
 		self.failUnlessEqual(config.outputpath, path)
 		
@@ -80,7 +80,7 @@
 
 		api = raptor_api.Context(r)
 		
-		products = api.GetProducts() # type == "product"
+		products = api.getproducts() # type == "product"
 		self.failUnlessEqual(len(products), 2)
 		self.failUnlessEqual(set(["product_A","product_C"]),
 							 set(p.name for p in products))