<commit_before>import gntp
import Growl

GNTPParseError = gntp.GNTPParseError
GNTPOK = gntp.GNTPOK
GNTPError = gntp.GNTPError
parse_gntp = gntp.parse_gntp

class GNTPRegister(gntp.GNTPRegister):
	def send(self):
		print 'Sending Local Registration'
		
		#Local growls only need a list of strings
		notifications=[]
		defaultNotifications = []
		for notice in self.notifications:
			notifications.append(notice['Notification-Name'])
			if notice.get('Notification-Enabled',True):
				defaultNotifications.append(notice['Notification-Name'])
				
		growl = Growl.GrowlNotifier(
			applicationName			= self.headers['Application-Name'],
			notifications			= notifications,
			defaultNotifications	= defaultNotifications,
		)
		growl.register()
		
class GNTPNotice(gntp.GNTPNotice):
	def send(self):
		print 'Sending Local Notification'
		growl = Growl.GrowlNotifier(
			applicationName			= self.headers['Application-Name'],
			notifications			= [self.headers['Notification-Name']]
		)
		
		noticeIcon = None
		if self.headers.get('Notification-Icon',False):
			resource = self.headers['Notification-Icon'].split('://')
			#print resource
			resource = self.resources.get(resource[1],False)
			#print resource
			if resource:
				noticeIcon = resource['Data']
		
		growl.notify(
			noteType = self.headers['Notification-Name'],
			title = self.headers['Notification-Title'],
			description=self.headers['Notification-Text'],
		)<commit_msg>Clean up local.py for OSX notifications<commit_after>from gntp import *
import Growl

def register_send(self):
	'''
	Resend a GNTP Register message to Growl running on a local OSX Machine
	'''
	print 'Sending Local Registration'
	
	#Local growls only need a list of strings
	notifications=[]
	defaultNotifications = []
	for notice in self.notifications:
		notifications.append(notice['Notification-Name'])
		if notice.get('Notification-Enabled',True):
			defaultNotifications.append(notice['Notification-Name'])
			
	growl = Growl.GrowlNotifier(
		applicationName			= self.headers['Application-Name'],
		notifications			= notifications,
		defaultNotifications	= defaultNotifications,
	)
	growl.register()
	return self.encode()
	
def notice_send(self):
	'''
	Resend a GNTP Notify message to Growl running on a local OSX Machine
	'''
	print 'Sending Local Notification'
	growl = Growl.GrowlNotifier(
		applicationName			= self.headers['Application-Name'],
		notifications			= [self.headers['Notification-Name']]
	)
	
	noticeIcon = None
	if self.headers.get('Notification-Icon',False):
		resource = self.headers['Notification-Icon'].split('://')
		#print resource
		resource = self.resources.get(resource[1],False)
		#print resource
		if resource:
			noticeIcon = resource['Data']
	
	growl.notify(
		noteType = self.headers['Notification-Name'],
		title = self.headers['Notification-Title'],
		description=self.headers.get('Notification-Text',''),
	)
	return self.encode()

GNTPRegister.send = register_send
GNTPNotice.send = notice_send
{'fraction_non_alphanumeric': 0.11855843718423711, 'fraction_numerical': 0.0006736274840013472, 'mean_word_length': 4.812133072407045, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5717904', 'n_tokens_mistral': 1020, 'n_tokens_neox': 917, 'n_words': 194}