Make sure all files have encoding set to utf-8 unless they already have an encoding Added COPYING with contense of GPL-2 Added plugin name prefix to all log output. This should take the form of self.log.severity("Plugin: message"), when not logging from plugin.py use: "Plugin/file_without_dot_py: message" Bantracker: Made the confgure() function do something, it also creates an initial database if it doesn't exist Encyclopedia: Made the configure() function do something, it also creates an initial database if it doesn't exist PackageInfo: Improve the configure() function, it also now creates some initial .list files and prompts to run update_apt and update_apt_file This goes some way to getting an "ubottu" package together, all we need to do is patch supybot-wizard to download the plugins from bzr and put them somewhere supybot will see them, then the wizard will do all the initial setup
52 lines
1.4 KiB
Python
52 lines
1.4 KiB
Python
# -*- Encoding: utf-8 -*-
|
|
from string import ascii_letters, digits
|
|
import random
|
|
|
|
"""
|
|
This module contains non-essential tools for iCalendar. Pretty thin so far eh?
|
|
|
|
"""
|
|
|
|
class UIDGenerator:
|
|
|
|
"""
|
|
If you are too lazy to create real uids.
|
|
|
|
NOTE: this doctest is disabled
|
|
(only two > instead of three)
|
|
|
|
Automatic semi-random uid
|
|
>> g = UIDGenerator()
|
|
>> uid = g.uid()
|
|
>> uid.ical()
|
|
'20050109T153222-7ekDDHKcw46QlwZK@example.com'
|
|
|
|
You should at least insert your own hostname to be more compliant
|
|
>> g = UIDGenerator()
|
|
>> uid = g.uid('Example.ORG')
|
|
>> uid.ical()
|
|
'20050109T153549-NbUItOPDjQj8Ux6q@Example.ORG'
|
|
|
|
You can also insert a path or similar
|
|
>> g = UIDGenerator()
|
|
>> uid = g.uid('Example.ORG', '/path/to/content')
|
|
>> uid.ical()
|
|
'20050109T153415-/path/to/content@Example.ORG'
|
|
"""
|
|
|
|
chars = list(ascii_letters + digits)
|
|
|
|
def rnd_string(self, length=16):
|
|
"Generates a string with random characters of length"
|
|
return ''.join([random.choice(self.chars) for i in range(length)])
|
|
|
|
def uid(self, host_name='example.com', unique=''):
|
|
"""
|
|
Generates a unique id consisting of:
|
|
datetime-uniquevalue@host. Like:
|
|
20050105T225746Z-HKtJMqUgdO0jDUwm@example.com
|
|
"""
|
|
from PropertyValues import vText, vDatetime
|
|
unique = unique or self.rnd_string()
|
|
return vText('%s-%s@%s' % (vDatetime.today().ical(), unique, host_name))
|