Munge the committer's name when posting a new commit to avoid highlights

Sat, 05 Sep 2015 05:24:38 +0300

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Sat, 05 Sep 2015 05:24:38 +0300
changeset 158
f96730dee026
parent 157
aaa5618e8dc2
child 159
4c06dfae9beb

Munge the committer's name when posting a new commit to avoid highlights

hgpoll.py file | annotate | diff | comparison | revisions
mod_util.py file | annotate | diff | comparison | revisions
modulecore.py file | annotate | diff | comparison | revisions
munge.py file | annotate | diff | comparison | revisions
--- a/hgpoll.py	Wed Aug 26 05:39:23 2015 +0300
+++ b/hgpoll.py	Sat Sep 05 05:24:38 2015 +0300
@@ -39,6 +39,7 @@
 from hgdb import HgCommitsDatabase
 import traceback
 import sys
+from munge import munge
 
 Repositories = []
 RepositoriesByName = {}
@@ -275,7 +276,7 @@
 				continue
 
 		username = Config.find_developer_by_email (commit['email'])
-		committer = username if username else commit['author']
+		committer = munge (username if username else commit['author'])
 		descriptor = """commit""" if random.randrange (100) != 0 else """KERMIT"""
 
 		if not isMergeFromSandbox:
--- a/mod_util.py	Wed Aug 26 05:39:23 2015 +0300
+++ b/mod_util.py	Sat Sep 05 05:24:38 2015 +0300
@@ -35,6 +35,7 @@
 import calc
 import urllib.parse
 import datetime
+from munge import munge
 
 @modulecore.irc_command (args='<value> as <valuetype>')
 def convert (bot, args, reply, error, **rest):
@@ -170,4 +171,10 @@
 
 @modulecore.irc_command (args='<format...>')
 def strftime (reply, args, **rest):
+	'''Formats current time.'''
 	reply ('\x0f' + datetime.datetime.utcnow().strftime (args['format']))
+
+@modulecore.irc_command (name='munge', args='<string...>')
+def mungecmd (reply, args, **rest):
+	'''Tests text munging.'''
+	reply ('\x0f' + munge (args['string']))
\ No newline at end of file
--- a/modulecore.py	Wed Aug 26 05:39:23 2015 +0300
+++ b/modulecore.py	Sat Sep 05 05:24:38 2015 +0300
@@ -382,10 +382,12 @@
 
 def irc_command (**command):
 	def result (fn):
-		command['name'] = fn.__name__
 		command['description'] = fn.__doc__
 		command['function'] = fn
 
+		if 'name' not in command:
+			command['name'] = fn.__name__
+
 		if command['description'] == None:
 			command['description'] = ''
 	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/munge.py	Sat Sep 05 05:24:38 2015 +0300
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+# encoding: utf-8
+'''
+Provides the munge function.
+'''
+
+'''
+	Copyright 2015 Teemu Piippo
+	All rights reserved.
+
+	Redistribution and use in source and binary forms, with or without
+	modification, are permitted provided that the following conditions
+	are met:
+
+	1. Redistributions of source code must retain the above copyright
+	   notice, this list of conditions and the following disclaimer.
+	2. Redistributions in binary form must reproduce the above copyright
+	   notice, this list of conditions and the following disclaimer in the
+	   documentation and/or other materials provided with the distribution.
+	3. The name of the author may not be used to endorse or promote products
+	   derived from this software without specific prior written permission.
+
+	THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+	IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+	OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+	IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+	INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+	DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+	THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+	THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+'''
+
+import string
+mungechars = 'аɓᴄđеƒɡɦіјķɭṁɳорqŗѕƫᴜᴠᴡхуᴢАВСḌЕḞǴНІЈКLМΝОРQɌЅТÙⅤⱲХΥΖ'
+mungedict = dict (zip (string.ascii_lowercase + string.ascii_uppercase, mungechars))
+
+def mungeone (ch):
+	'''
+	Munges one character.
+	'''
+	try:
+		return mungedict[ch]
+	except:
+		return ch
+
+def munge (a):
+	'''
+	Munges the given string
+	'''
+	return ''.join ([mungeone (ch) for ch in a])
\ No newline at end of file

mercurial