<commit_before>#!/usr/bin/python
# _*_ coding: UTF-8 _*_

# create: 2016/10/21
# version: 0.0.1
# author: Junhg
# contribute:
# 
__author__ = 'Junhg'

from CommonObject import JHCommomObject

class JHBasicObject(JHCommomObject):
	def __init__(self):
		pass
			
	def __del__(self):
		pass

	def addSubview(self, attribView, isLoadView):
		classViewName = self.attribViewTag(attribView)
		classType = self.objcClassNameType(classViewName)
		classMethodName = self.attribViewViewMethod(attribView)
		backgroundColor = self.objcClassColor(attribView.get('backgroundColor', {}))
		frame = self.objcClassFrame(attribView.get('frame', {}))
		autoresizingMask = self.loadAutoresizingMask(attribView.get('autoresizingMask', {}))
		contentModel = self.loadViewContentModel(attribView.get('contentMode', 'scaleToFill'))
		
		describle = "\n"

		# 变更成classViewName所对应的类型
		if isLoadView:
			classViewName = "self.view"
			describle += "- (void)loadView\n{\n"
			if len(frame) > 0:
				describle +="	self.view = [["+classType+" alloc] initWithFrame:"+frame+"];\n"
				pass
			else :
				describle +="	self.view = [["+classType+" alloc] init];\n"
				pass
			pass
		else:
			describle += "- ("+classType+" *"+")"+classMethodName+"\n{\n"
			if len(frame) > 0:
				describle +="	"+classType+"* "+classViewName+" = [["+classType+" alloc] initWithFrame:"+frame+"];\n"
				pass
			else :
				describle +="	"+classType+"* "+classViewName+" = [["+classType+" alloc] init];\n"
				pass
			pass

		describle +="	"+classViewName+".tag = [@"+"\""+self.attribViewMethodNameId(classMethodName)+"\""+" hash];\n"
		
		if len(backgroundColor) > 0:
			describle +="	"+classViewName+".backgroundColor = "+backgroundColor+";\n"
			pass
		
		if autoresizingMask != 'UIViewAutoresizingNone':
			describle +="	"+classViewName+".autoresizingMask = "+autoresizingMask+";\n"
			pass
		
		if contentModel != 'UIViewContentModeScaleToFill':
			describle +="	"+classViewName+".contentMode = "+contentModel+";\n"
			pass

		return describle
		
	def objcClassFrame(self, frame):
		classFrame = ""
		if len(frame) == 0:
			pass
		else :
			if frame.get('key','frameInset') == 'frameInset':
				classFrame = "CGRectMake("+str(frame.get('minX', 0))+","+str(frame.get('minY', 0))+","+str(frame.get('width', 320))+","+str(frame.get('height', 480))+")"
				pass
			else :
				classFrame = "CGRectMake("+str(frame.get('x', 0))+","+str(frame.get('y', 0))+","+str(frame.get('width', 320))+","+str(frame.get('height', 480))+")"
				pass
		return classFrame

	def objcClassColor(self, color):
		if len(color) > 0:
			red = str(color.get('red', 0))
			green = str(color.get('green', 0))
			blue = str(color.get('blue',0))
			alpha = str(color.get('alpha', 1))
			return "[UIColor colorWithRed:"+red+" green:"+green+" blue:"+blue+" alpha:"+alpha+"]"
			pass
		else :
			return ""

	def loadViewContentModel(self, model):
		contentMode = 'UIViewContentModeScaleToFill'

		if model == 'scaleToFill':
			contentMode = 'UIViewContentModeScaleToFill'
			pass
		elif model == 'scaleAspectFit':
			contentMode = 'UIViewContentModeScaleAspectFit'
			pass
		elif model == 'scaleAspectFill':
			contentMode = 'UIViewContentModeScaleAspectFill'<commit_msg>mdoify viewObject frame key<commit_after>#!/usr/bin/python
# _*_ coding: UTF-8 _*_

# create: 2016/10/21
# version: 0.0.1
# author: Junhg
# contribute:
# 
__author__ = 'Junhg'

from CommonObject import JHCommomObject

class JHBasicObject(JHCommomObject):
	def __init__(self):
		pass
			
	def __del__(self):
		pass

	def addSubview(self, attribView, isLoadView):
		classViewName = self.attribViewTag(attribView)
		classType = self.objcClassNameType(classViewName)
		classMethodName = self.attribViewViewMethod(attribView)
		backgroundColor = self.objcClassColor(attribView.get('backgroundColor', {}))
		autoresizingMask = self.loadAutoresizingMask(attribView.get('autoresizingMask', {}))
		contentModel = self.loadViewContentModel(attribView.get('contentMode', 'scaleToFill'))
		
		describle = "\n"

		# 变更成classViewName所对应的类型
		if isLoadView:
			classViewName = "self.view"
			describle += "- (void)loadView\n{\n"

			frame = self.objcClassFrame(attribView.get('rect', {}))
			if len(frame) > 0:
				describle +="	self.view = [["+classType+" alloc] initWithFrame:"+frame+"];\n"
				pass
			else :
				describle +="	self.view = [["+classType+" alloc] init];\n"
				pass
			pass
		else:
			describle += "- ("+classType+" *"+")"+classMethodName+"\n{\n"
			frame = self.objcClassFrame(attribView.get('frame', {}))
			if len(frame) > 0:
				describle +="	"+classType+"* "+classViewName+" = [["+classType+" alloc] initWithFrame:"+frame+"];\n"
				pass
			else :
				describle +="	"+classType+"* "+classViewName+" = [["+classType+" alloc] init];\n"
				pass
			pass

		describle +="	"+classViewName+".tag = [@"+"\""+self.attribViewMethodNameId(classMethodName)+"\""+" hash];\n"
		
		if len(backgroundColor) > 0:
			describle +="	"+classViewName+".backgroundColor = "+backgroundColor+";\n"
			pass
		
		if autoresizingMask != 'UIViewAutoresizingNone':
			describle +="	"+classViewName+".autoresizingMask = "+autoresizingMask+";\n"
			pass
		
		if contentModel != 'UIViewContentModeScaleToFill':
			describle +="	"+classViewName+".contentMode = "+contentModel+";\n"
			pass

		return describle
		
	def objcClassFrame(self, frame):
		classFrame = ""
		if len(frame) == 0:
			pass
		else :
			print 'frame=',frame.get('key','frameInset')
			if frame.get('key','frameInset') == 'frameInset':
				classFrame = "CGRectMake("+str(frame.get('minX', 0))+","+str(frame.get('minY', 0))+","+str(frame.get('width', 320))+","+str(frame.get('height', 480))+")"
				pass
			else :
				classFrame = "CGRectMake("+str(frame.get('x', 0))+","+str(frame.get('y', 0))+","+str(frame.get('width', 320))+","+str(frame.get('height', 480))+")"
				pass
		return classFrame

	def objcClassColor(self, color):
		if len(color) > 0:
			red = str(color.get('red', 0))
			green = str(color.get('green', 0))
			blue = str(color.get('blue',0))
			alpha = str(color.get('alpha', 1))
			return "[UIColor colorWithRed:"+red+" green:"+green+" blue:"+blue+" alpha:"+alpha+"]"
			pass
		else :
			return ""

	def loadViewContentModel(self, model):
		contentMode = 'UIViewContentModeScaleToFill'

		if model == 'scaleToFill':
			contentMode = 'UIViewContentModeScaleToFill'
			pass
		elif model == 'scaleAspectFit':
			contentMode = 'UIViewContentModeScaleAspectFit'
			pass
		elif model == 'scaleAspectFill':
			contentMode = 'UIViewContentModeScaleAspectFill'
{'fraction_non_alphanumeric': 0.18248961378673642, 'fraction_numerical': 0.011386367133405139, 'mean_word_length': 4.767524401064774, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '806788', 'n_tokens_mistral': 2697, 'n_tokens_neox': 2324, 'n_words': 398}