<commit_before>#!/usr/bin/python3
# -*- coding: utf-8 -*-
from __future__ import print_function
import smallsmilhandler
import sys
from xml.sax import make_parser
from xml.sax.handler import ContentHandler
import urllib.request


class KaraokeLocal():

	def __init__(self, fichero):
		parser = make_parser()
		cHandler = smallsmilhandler.SmallSMILHandler()
		parser.setContentHandler(cHandler)
		parser.parse(open(fichero))
		self.etiquetas = cHandler.get_tags()

	# def __str__(etiquetas):


	def __str__(self):
		a = ''
		for valor in self.etiquetas:
			if valor == str(valor):
				etiqueta = valor
				a += etiqueta + '\t'
			else:
				for i in valor.keys():
					if valor[i] != '':
						a += i + '=' + '"' + valor[i]+ '"' + '\t'
				a = a + '\n'
		a = a[:-1]
		return a
#
#
# def descargar(lista):
# 	for dicc in lista:
# 		if dicc != str(dicc):
# 			for i in dicc:
# 				u = dicc[i].split('/')
# 				if i == 'src' and u[0] == 'http:':
# 					urllib.request.urlretrieve(dicc[i],u[-1])
#
#
if __name__ == '__main__':

	if len(sys.argv) != 2:
		sys.exit('Usage: python3 karaoke.py file.smil')

	karaoke = KaraokeLocal(sys.argv[1])
	# print(karaoke.etiquetas)
	elementos = karaoke.etiquetas
	karaoke.ordenar()
	# descargar(cHandler.get_tags())<commit_msg>Apartado 6 + do_local<commit_after>#!/usr/bin/python3
# -*- coding: utf-8 -*-
from __future__ import print_function
import smallsmilhandler
import sys
from xml.sax import make_parser
from xml.sax.handler import ContentHandler
import urllib.request


class KaraokeLocal():

	def __init__(self, fichero):
		parser = make_parser()
		cHandler = smallsmilhandler.SmallSMILHandler()
		parser.setContentHandler(cHandler)
		parser.parse(open(fichero))
		self.etiquetas = cHandler.get_tags()


	def __str__(self):
		a = ''
		for valor in self.etiquetas:
			if valor == str(valor):
				etiqueta = valor
				a += etiqueta + '\t'
			else:
				for i in valor.keys():
					if valor[i] != '':
						a += i + '=' + '"' + valor[i]+ '"' + '\t'
				a = a + '\n'
		a = a[:-1]
		return a


	def do_local(self):
		for dicc in self.etiquetas:
			if dicc != str(dicc):
				for i in dicc:
					u = dicc[i].split('/')
					if i == 'src' and u[0] == 'http:':
						urllib.request.urlretrieve(dicc[i],u[-1])


if __name__ == '__main__':

	if len(sys.argv) != 2:
		sys.exit('Usage: python3 karaoke.py file.smil')

	karaoke = KaraokeLocal(sys.argv[1])
	elementos = karaoke.etiquetas
	print(karaoke.__str__())
	do_local()
	print(karoke.__str__())
{'fraction_non_alphanumeric': 0.16181229773462782, 'fraction_numerical': 0.006877022653721683, 'mean_word_length': 3.4398563734290843, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '4636501', 'n_tokens_mistral': 1099, 'n_tokens_neox': 984, 'n_words': 215}