<commit_before>#!/usr/bin/python3.4
# -*-coding:Utf-8 -*
'''module to manage task scene  log'''
import xml.etree.ElementTree as xmlMod
from TaskList.TaskLog.FrameLog import *
from usefullFunctions import XML


class SceneLog:
	'''class to manage task scene log'''
	
	def __init__(self, xml = None, scene = None, task = None, pref):
		'''initialize scene log object'''
		if xml is None:
			self.defaultInit(scene, task, pref)
		else:
			self.fromXml(xml)
	
	
	
	
	
	
	def defaultInit(self, scene, task, pref):
		'''initialize Scene log'''
		self.name = scene
		
		fileName = task.path.split('/').pop().split('.')
		fileName.pop()
		fileName = fileName.join('.')
		self.path = pref.output.path+'render/'+fileName+'/'+scene+'/'
		
		self.start = task.info.scene[scene].start
		self.end = task.info.scene[scene].end
		self.frames = []
		self.status = 'ready to start'
	
	
	
	
	
	def fromXml(self, xml):
		'''initialize Scene log object with saved log'''
		self.name = XML.decode(xml.get('name'))
		self.path = XML.decode(xml.get('path'))
		self.start = int(xml.get('start'))
		self.end = int(xml.get('end'))
		self.status = xml.get('status')
		
		self.frames = []
		for node in xml.findall('frame'):
			self.frames.append(\
					FrameLog( xml = node )\
					)
	
	
	
	
	
	def toXml(self):
		'''export scene log into xml syntaxed string'''
		xml = '<scene name="'+XML.encode(self.name)\
				+'" path="'+XML.encode(self.path)\
				+'" start="'+str(self.start)\
				+'" end="'+str(self.end)\
				+'" status="'+self.status+'" >\n'
		
		for f in self.frames:
			xml += f.toXml()
		
		xml += '</scene>\n'
		return xml
	
	
	
	
	
	def menu(self):
		'''see detail of the Scene rendering'''
		
	
	
	
	
	
	def print(self, index = None):
		'''A method to print Scene log'''
	
	
	
	
	
	def runMenuPrint(self):
		'''display rendering progress during run mode '''
		total = self.end - self.start + 1
		
		if index is not None:
			index = str(index)+'-  '
		else:
			index = '╚═ '
		
		print(index+'«'+self.name+'» scene : '+str(len(self.frames))+'/'+str(total)\
					+' frames, '+str(total - len(self.frames))\
					+' remaining frames,\n     Average time by frame : '\
					+str(self.average())\
					)
	
	
	
	
	
	def average(self):
		'''return frame average rendering time'''
		if len(self.frames)>0:
			count = 0
			time = 0
			for f in self.frames:
				count += 1
				time += f.computingTime
			average = time / count
			return average
		else:
			return 0.0
	
	
	
	
	
	def remaining(self):
		'''return the count of frames that don't have been rendered yet'''
		return (self.end - self.start + 1 - len(self.frames) )
	
	
	
	
	
	def confirmFrame(self, frame, date, computingTime):
		'''add frame rendering log confirmation to the scene'''
		self.frames.append(
							FrameLog(
									frame = frame,
									date = date,
									computingTime = computingTime
									) 
							)
	
	
	
	
	
	
	
	
<commit_msg>code sceneLog.print()<commit_after>#!/usr/bin/python3.4
# -*-coding:Utf-8 -*
'''module to manage task scene  log'''
import xml.etree.ElementTree as xmlMod
from TaskList.TaskLog.FrameLog import *
from usefullFunctions import XML


class SceneLog:
	'''class to manage task scene log'''
	
	pageSize = 15
	
	def __init__(self, xml = None, scene = None, task = None, pref):
		'''initialize scene log object'''
		if xml is None:
			self.defaultInit(scene, task, pref)
		else:
			self.fromXml(xml)
	
	
	
	
	
	
	def defaultInit(self, scene, task, pref):
		'''initialize Scene log'''
		self.name = scene
		
		fileName = task.path.split('/').pop().split('.')
		fileName.pop()
		fileName = fileName.join('.')
		self.path = pref.output.path+'render/'+fileName+'/'+scene+'/'
		
		self.start = task.info.scene[scene].start
		self.end = task.info.scene[scene].end
		self.frames = []
		self.status = 'ready to start'
	
	
	
	
	
	def fromXml(self, xml):
		'''initialize Scene log object with saved log'''
		self.name = XML.decode(xml.get('name'))
		self.path = XML.decode(xml.get('path'))
		self.start = int(xml.get('start'))
		self.end = int(xml.get('end'))
		self.status = xml.get('status')
		
		self.frames = []
		for node in xml.findall('frame'):
			self.frames.append(\
					FrameLog( xml = node )\
					)
	
	
	
	
	
	def toXml(self):
		'''export scene log into xml syntaxed string'''
		xml = '<scene name="'+XML.encode(self.name)\
				+'" path="'+XML.encode(self.path)\
				+'" start="'+str(self.start)\
				+'" end="'+str(self.end)\
				+'" status="'+self.status+'" >\n'
		
		for f in self.frames:
			xml += f.toXml()
		
		xml += '</scene>\n'
		return xml
	
	
	
	
	
	def menu(self):
		'''see detail of the Scene rendering'''
		
	
	
	
	
	
	def print(self, page = 0):
		'''A method to print Scene log'''
		total = self.end - self.start + 1
		remain = total - len(self.frames)
		
		print('Status          : '+self.status)
		print('Output path  : '+self.path)
		
		print('\nRendered / total (remaining) : '+str(len(self.frames))+' / '\
				+str(total)+'     ( remain '+str(remain)+' frames )')
		print('Average rendering time : '+str(self.average())+' sec')
		
		if len(self.frames) > 0:
			print('Extract ('+str(page*self.pageSize+1)+' to '\
				+str((page+1)*self.pageSize)+' of '+str(len(self.frames))+') : ')
			print('Frame n°     rendering Date                 rendering time in seconds')
			for fr in self.frames[page*self.pageSize:(page+1)*self.pageSize]:
				fr.print()
		else:
			print('\n        No rendered frame')
	
	
	
	
	
	def runMenuPrint(self, index = None):
		'''display rendering progress during run mode '''
		total = self.end - self.start + 1
		
		if index is not None:
			index = str(index)+'-  '
		else:
			index = '╚═ '
		
		print(index+'«'+self.name+'» scene : '+str(len(self.frames))+'/'+str(total)\
					+' frames, '+str(total - len(self.frames))\
					+' remaining frames,\n     Average time by frame : '\
					+str(self.average())\
					)
	
	
	
	
	
	def average(self):
		'''return frame average rendering time'''
		if len(self.frames)>0:
			count = 0
			time = 0
			for f in self.frames:
				count += 1
				time += f.computingTime
			average = time / count
			return average
		else:
			return 0.0
	
	
	
	
	
	def remaining(self):
		'''return the count of frames that don't have been rendered yet'''
		return (self.end - self.start + 1 - len(self.frames) )
	
	
	
	
	
	def confirmFrame(self, frame, date, computingTime):
		'''add frame rendering log confirmation to the scene'''
		self.frames.append(
							FrameLog(
									frame = frame,
									date = date,
									computingTime = computingTime
									) 
							)
	
	
	
	
	
	
	
	

{'fraction_non_alphanumeric': 0.16625916870415647, 'fraction_numerical': 0.004584352078239609, 'mean_word_length': 2.687323943661972, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 36}, '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': '3922623', 'n_tokens_mistral': 2723, 'n_tokens_neox': 2194, 'n_words': 567}