From 63083dc68f436983c822858f049ec683c9e5daad Mon Sep 17 00:00:00 2001 From: Johannes Raggam Date: Thu, 12 Jan 2012 16:41:12 +0100 Subject: [PATCH] remove reduntant and not-working util.py, fix to_ical API in tools.py --- src/icalendar/tools.py | 10 ++++----- src/icalendar/util.py | 50 ------------------------------------------ 2 files changed, 5 insertions(+), 55 deletions(-) delete mode 100644 src/icalendar/util.py diff --git a/src/icalendar/tools.py b/src/icalendar/tools.py index c37d09d..7ecd192 100644 --- a/src/icalendar/tools.py +++ b/src/icalendar/tools.py @@ -15,19 +15,19 @@ class UIDGenerator: Automatic semi-random uid >> g = UIDGenerator() >> uid = g.uid() - >> uid.ical() + >> uid.to_ical() '20050109T153222-7ekDDHKcw46QlwZK@example.com' - You Should at least insert your own hostname to be more complient + You should at least insert your own hostname to be more compliant >> g = UIDGenerator() >> uid = g.uid('Example.ORG') - >> uid.ical() + >> uid.to_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() + >> uid.to_ical() '20050109T153415-/path/to/content@Example.ORG' """ @@ -45,7 +45,7 @@ class UIDGenerator: """ from icalendar.prop import vText, vDatetime unique = unique or self.rnd_string() - return vText('%s-%s@%s' % (vDatetime(datetime.today()).ical(), unique, host_name)) + return vText('%s-%s@%s' % (vDatetime(datetime.today()).to_ical(), unique, host_name)) if __name__ == "__main__": diff --git a/src/icalendar/util.py b/src/icalendar/util.py deleted file mode 100644 index f3b31de..0000000 --- a/src/icalendar/util.py +++ /dev/null @@ -1,50 +0,0 @@ -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))