Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (41 sloc) 1.5 KB
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 uid's. Notice, this doctest is disabled!
Automatic semi-random uid
>> g = UIDGenerator()
>> uid = g.uid()
>> uid.ical()
You Should at least insert your own hostname to be more complient
>> g = UIDGenerator()
>> uid = g.uid('Example.ORG')
>> uid.ical()
You can also insert a path or similar
>> g = UIDGenerator()
>> uid = g.uid('Example.ORG', '/path/to/content')
>> uid.ical()
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='', unique=''):
Generates a unique id consisting of:
datetime-uniquevalue@host. Like:
from PropertyValues import vText, vDatetime
unique = unique or self.rnd_string()
return vText('%s-%s@%s' % (, unique, host_name))
if __name__ == "__main__":
import os.path, doctest, tools
# import and test this file
Something went wrong with that request. Please try again.