#!/usr/bin/python3.4
# -*-coding:Utf-8 -*
'''module containing class 'renderingTask' '''
from setting import setting
from copy import deepcopy

class renderingTask:
	'''class that contain the parameter for a rendering task'''
	
	def __init__(self,
					path = '', 
					scene = '', 
					fileXmlSetting = setting(),
					preferences = setting(),
					xml = None):
		'''renderingTask object initialisation
		if there is an xml argument paste to the function, the others are ignore'''
		if xml is None:
			# create new task with path, scene, fileXmlSetting and preferences arguments
			self.path = path
			self.scene = scene
			self.fileSetting = setting(fileXmlSetting)
			self.customSetting = preferences.getClone()
			
			# get parameters values that only original file settings have
			self.customSetting.start = self.fileSetting.start
			self.customSetting.end = self.fileSetting.end
			self.customSetting.renderLayerList = deepcopy(self.fileSetting.renderLayerList)
			
			#overwrite renderlayer pass settings
			for layer in self.customSetting.renderLayerList:
				layer['z'] = self.customSetting.zPass
				layer['object index'] = self.customSetting.objectIndexPass 
			
			
			self.status = 'ready'
			
		else:
			# load task from xml argument
			self.path = ''
			self.scene = ''
			self.fileSetting = setting()
			self.customSetting = setting()
			self.status='unset'
			
			self.fromXml(xml)
	
	
	
	
	def fromXml(self,xml):
		'''method that set the object attributes with the value extracted from an xml object with 'task' tag name '''
		if xml.tag == 'task':
			self.path = xml.get('path')
			self.scene = xml.get('scene')
			self.fileSetting.fromXml(xml.find('fileSet'))
			self.customSetting.fromXml(xml.find('taskSet'))
			self.status = 'ready'
	
	
	
	
	def toXmlStr(self,head=False):
		'''export the object values into an xml formated strings'''
		txt =''
		if head:
			txt+= '<?xml version="1.0" encoding="UTF-8"?>\n'
		txt += '<task path="'+self.path+'" scene="'+self.scene+'">\n'
		txt += '<taskSet>\n'+self.customSetting.toXmlStr()+'</taskSet>\n'
		txt += '<fileSet>\n'+self.fileSetting.toXmlStr()+'</fileSet>\n'
		txt += '</task>\n'
		return txt
	
	
	
	
	
	
	def settingsCompare(self, ref = None):
		if ref is None:
			ref = self.fileSetting
		return self.customSetting.compare(ref)





@@ -2216,90 +2216,436 @@
 :%0A%09%09
-if ref is None:%0A%09%09%09ref = self.fileSetting%0A%09%09return self.customSetting.compare(ref)
+'''method to comapare task settings to original file settings or to other settings'''%0A%09%09if ref is None:%0A%09%09%09ref = self.fileSetting%0A%09%09return self.customSetting.compare(ref)%0A%09%0A%09%0A%09%0A%09%0A%09%0A%09def taskSettingsMenu(self, pref):%0A%09%09'''method to customize task settings'''%0A%09%09change = False%0A%09%09log.menuIn('Compare Task Settings')%0A%09%09ref = self.fileSetting%0A%09%09%0A%09%09while True:%0A%09%09%09os.system('clear')%0A%09%09%09log.print()%0A%09%09%09log.menuOut()%0A%09%09%09return change%0A%0A%0A
 %0A%0A%0A%0A

create a method to manage task settings add a docstrings