[icalendar-checkins] r19619 - in iCalendar/trunk: . doc src
src/icalendar src/icalendar/tests
dreamcatcher at codespeak.net
dreamcatcher at codespeak.net
Mon Nov 7 22:08:13 CET 2005
Author: dreamcatcher
Date: Mon Nov 7 22:07:56 2005
New Revision: 19619
Added:
iCalendar/trunk/doc/multiple.ics
iCalendar/trunk/doc/multiple.txt (contents, props changed)
Modified:
iCalendar/trunk/CHANGES.txt
iCalendar/trunk/CREDITS.txt
iCalendar/trunk/README.txt
iCalendar/trunk/doc/example.txt
iCalendar/trunk/src/doctest.py
iCalendar/trunk/src/icalendar/__init__.py
iCalendar/trunk/src/icalendar/cal.py
iCalendar/trunk/src/icalendar/caselessdict.py
iCalendar/trunk/src/icalendar/interfaces.py
iCalendar/trunk/src/icalendar/parser.py
iCalendar/trunk/src/icalendar/prop.py
iCalendar/trunk/src/icalendar/tests/test_icalendar.py
iCalendar/trunk/src/icalendar/tools.py
iCalendar/trunk/src/icalendar/util.py
Log:
- Ugh, svn log fooled me.
- Merge missing changes from branch
- Update some docs
Modified: iCalendar/trunk/CHANGES.txt
==============================================================================
--- iCalendar/trunk/CHANGES.txt (original)
+++ iCalendar/trunk/CHANGES.txt Mon Nov 7 22:07:56 2005
@@ -1,3 +1,27 @@
+iCalendar 0.11 (2005-11-XX)
+===========================
+
+* Changed component .from_string to use types_factory instead of
+ hardcoding entries to 'inline'
+
+* Changed UTC tzinfo to a singleton so the same one is used everywhere
+
+* Made the parser more strict by using regular expressions for key
+ name, param name and quoted/unquoted safe char as per the RFC
+
+* Added some tests from the schooltool icalendar parser for better
+ coverage
+
+* Be more forgiving on the regex for folding lines
+
+* Allow for multiple top-level components on .from_string
+
+* Fix vWeekdays, wasn't accepting relative param (eg: -3SA vs -SA)
+
+* vDDDTypes didn't accept negative period (eg: -P30M)
+
+* '\N' is also acceptable as newline on content lines, per RFC
+
iCalendar 0.10 (2005-04-28)
===========================
Modified: iCalendar/trunk/CREDITS.txt
==============================================================================
--- iCalendar/trunk/CREDITS.txt (original)
+++ iCalendar/trunk/CREDITS.txt Mon Nov 7 22:07:56 2005
@@ -16,4 +16,6 @@
- Lennart Regebro (regebro at nuxeo.com)
+- Sidnei da Silva (sidnei at enfoldsystems.com)
+
Thanks to codespeak for hosting this project.
Modified: iCalendar/trunk/README.txt
==============================================================================
--- iCalendar/trunk/README.txt (original)
+++ iCalendar/trunk/README.txt Mon Nov 7 22:07:56 2005
@@ -9,10 +9,10 @@
Introduction
============
-
+
I (Max M) have often needed to parse and generate iCalendar
files. Finally I got tired of writing ad-hoc tools.
-
+
So this is my attempt at making an iCalendar package for Python. The
inspiration has come from the email package in the standard lib, which
I think is pretty simple, yet efficient and powerful.
@@ -35,26 +35,26 @@
=======
To open and parse a file::
-
+
>>> from icalendar import Calendar, Event
>>> cal = Calendar.from_string(open('test.ics','rb').read())
>>> cal
- VCALENDAR({'VERSION': '2.0', 'METHOD': 'Request', 'PRODID': '-//My product//mxm.dk/'})
-
+ VCALENDAR({'VERSION': vText(u'2.0'), 'METHOD': vText(u'Request'), 'PRODID': vText(u'-//My product//mxm.dk/')})
+
>>> for component in cal.walk():
... component.name
'VCALENDAR'
'VEVENT'
'VEVENT'
-
+
To create a calendar and write it to disk::
-
+
>>> cal = Calendar()
>>> from datetime import datetime
>>> from iCalendar import UTC # timezone
>>> cal.add('prodid', '-//My calendar product//mxm.dk//')
>>> cal.add('version', '2.0')
-
+
>>> event = Event()
>>> event.add('summary', 'Python meeting about calendaring')
>>> event.add('dtstart', datetime(2005,4,4,8,0,0,tzinfo=UTC()))
@@ -62,9 +62,9 @@
>>> event.add('dtstamp', datetime(2005,4,4,0,10,0,tzinfo=UTC()))
>>> event['uid'] = '20050115T101010/27346262376 at mxm.dk'
>>> event.add('priority', 5)
-
+
>>> cal.add_component(event)
-
+
>>> f = open('example.ics', 'wb')
>>> f.write(cal.as_string())
>>> f.close()
@@ -78,7 +78,8 @@
.. _example: example.html
.. _smaller: small.html
.. _examples: groupscheduled.html
-
+.. _multiple: multiple.html
+
All modules and classes also have doctests that shows how they
work. There is also an `interfaces.py`_ file which describes the API.
@@ -89,7 +90,7 @@
If you have any comments or feedback on the module, please use the iCalendar
mailing list. You can subscribe to it here:
-
+
http://codespeak.net/mailman/listinfo/icalendar-dev
We would love to hear use cases, or get ideas for improvements.
@@ -114,7 +115,7 @@
Dependencies
============
-
+
It is dependent on the datetime package, so it requires Python >=
2.3. There are no other dependencies.
Modified: iCalendar/trunk/doc/example.txt
==============================================================================
--- iCalendar/trunk/doc/example.txt (original)
+++ iCalendar/trunk/doc/example.txt Mon Nov 7 22:07:56 2005
@@ -1,25 +1,25 @@
iCalendar package
=================
-This package is used for parsing and generating iCalendar files following the
+This package is used for parsing and generating iCalendar files following the
standard in RFC 2445.
-It should be fully compliant, but it is possible to generate and parse invalid
+It should be fully compliant, but it is possible to generate and parse invalid
files if you really want to.
File structure
--------------
-An iCalendar file is a text file (utf-8) with a special format. Basically it
+An iCalendar file is a text file (utf-8) with a special format. Basically it
consists of content lines.
-Each content line defines a property that has 3 parts (name, parameters,
+Each content line defines a property that has 3 parts (name, parameters,
values). Parameters are optional.
A simple content line with only name and value could look like this::
BEGIN:VCALENDAR
-
+
A content line with parameters can look like this::
ATTENDEE;CN=Max Rasmussen;ROLE=REQ-PARTICIPANT:MAILTO:example at example.com
@@ -29,14 +29,14 @@
Name: ATTENDEE
Params: CN=Max Rasmussen;ROLE=REQ-PARTICIPANT
Value: MAILTO:example at example.com
-
-Long content lines are usually "folded" to less than 75 character, but the
+
+Long content lines are usually "folded" to less than 75 character, but the
package takes care of that.
Overview
--------
-On a higher level iCalendar files consists of components. Components can have
+On a higher level iCalendar files consists of components. Components can have
sub components.
The root component is the VCALENDAR::
@@ -59,7 +59,7 @@
have special types. like integer, text, datetime etc. These values are
encoded in a special text format in an iCalendar file.
-There are methods for converting to and from these encodings in the package.
+There are methods for converting to and from these encodings in the package.
These are the most important imports::
@@ -68,7 +68,7 @@
Components
----------
-Components are like (Case Insensitive) dicts. So if you want to set a property
+Components are like (Case Insensitive) dicts. So if you want to set a property
you do it like this. The calendar is a component::
>>> cal = Calendar()
@@ -78,16 +78,16 @@
... k,v
('DTSTART', '20050404T080000')
('SUMMARY', 'Python meeting about calendaring')
-
-You can generate a string for a file with the as_string() method. (Calling
+
+You can generate a string for a file with the as_string() method. (Calling
str(cal) does the same)::
-
+
>>> cal.as_string()
'BEGIN:VCALENDAR\r\nDTSTART:20050404T080000\r\nSUMMARY:Python meeting about calendaring\r\nEND:VCALENDAR\r\n'
-
+
>>> str(cal)
'BEGIN:VCALENDAR\r\nDTSTART:20050404T080000\r\nSUMMARY:Python meeting about calendaring\r\nEND:VCALENDAR\r\n'
-
+
The rendered view is easier to read::
BEGIN:VCALENDAR
@@ -99,7 +99,7 @@
>>> def display(cal):
... return cal.as_string().replace('\r\n', '\n').strip()
-
+
You can set multiple properties like this::
>>> cal = Calendar()
@@ -157,7 +157,7 @@
>>> cal.subcomponents
[VEVENT({'DTSTART': '20050404T080000', 'UID': '42'})]
-
+
Value types
-----------
@@ -168,7 +168,7 @@
'20050404T080000'. But the package makes it simple to Parse and
generate iCalendar formatted strings.
-Basically you can make the add() method do the thinking, or you can do it
+Basically you can make the add() method do the thinking, or you can do it
yourself.
To add a datetime value, you can use Pythons built in datetime types,
@@ -179,8 +179,8 @@
>>> cal.add('dtstart', datetime(2005,4,4,8,0,0))
>>> str(cal['dtstart'])
'20050404T080000'
-
-If that doesn't work satisfactorily for some reason, you can also do it
+
+If that doesn't work satisfactorily for some reason, you can also do it
manually.
In 'icalendar.prop', all the iCalendar data types are defined. Each
@@ -197,8 +197,8 @@
and then call the "ical()" method on the object. That will return an
ical encoded string.
-You can do it the other way around too. To parse an encoded string, just call
-the "from_ical()" method, and it will return an instance of the corresponding
+You can do it the other way around too. To parse an encoded string, just call
+the "from_ical()" method, and it will return an instance of the corresponding
Python type::
>>> vDatetime.from_ical('20050404T080000')
@@ -208,7 +208,7 @@
>>> repr(dt)[:62]
'datetime.datetime(2005, 4, 4, 8, 0, tzinfo=<icalendar.prop.UTC'
-You can also choose to use the decoded() method, which will return a decoded
+You can also choose to use the decoded() method, which will return a decoded
value directly::
>>> cal = Calendar()
@@ -229,12 +229,12 @@
>>> cal = Calendar()
>>> from datetime import datetime
>>> from icalendar import UTC # timezone
-
+
Some properties are required to be compliant::
>>> cal.add('prodid', '-//My calendar product//mxm.dk//')
>>> cal.add('version', '2.0')
-
+
We need at least one subcomponent for a calendar to be compliant::
>>> event = Event()
@@ -242,16 +242,16 @@
>>> event.add('dtstart', datetime(2005,4,4,8,0,0,tzinfo=UTC))
>>> event.add('dtend', datetime(2005,4,4,10,0,0,tzinfo=UTC))
>>> event.add('dtstamp', datetime(2005,4,4,0,10,0,tzinfo=UTC))
-
+
A property with parameters. Notice that they are an attribute on the value::
>>> from icalendar import vCalAddress, vText
>>> organizer = vCalAddress('MAILTO:noone at example.com')
-
+
Automatic encoding is not yet implemented for parameter values, so you
must use the 'v*' types you can import from the icalendar package
(they're defined in ``icalendar.prop``)::
-
+
>>> organizer.params['cn'] = vText('Max Rasmussen')
>>> organizer.params['role'] = vText('CHAIR')
>>> event['organizer'] = organizer
@@ -273,7 +273,7 @@
Add the event to the calendar::
>>> cal.add_component(event)
-
+
Write to disk::
>>> import tempfile, os
@@ -281,6 +281,6 @@
>>> f = open(os.path.join(directory, 'example.ics'), 'wb')
>>> f.write(cal.as_string())
>>> f.close()
-
+
XXX We should check whether the write succeeded here..
Added: iCalendar/trunk/doc/multiple.ics
==============================================================================
--- (empty file)
+++ iCalendar/trunk/doc/multiple.ics Mon Nov 7 22:07:56 2005
@@ -0,0 +1,80 @@
+BEGIN:VCALENDAR
+VERSION
+
+ :2.0
+PRODID
+
+ :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
+METHOD
+
+ :PUBLISH
+BEGIN:VEVENT
+UID
+
+ :956630271
+SUMMARY
+
+ :Christmas Day
+CLASS
+
+ :PUBLIC
+X-MOZILLA-ALARM-DEFAULT-UNITS
+
+ :minutes
+X-MOZILLA-ALARM-DEFAULT-LENGTH
+
+ :15
+X-MOZILLA-RECUR-DEFAULT-UNITS
+
+ :weeks
+X-MOZILLA-RECUR-DEFAULT-INTERVAL
+
+ :1
+DTSTART
+
+ ;VALUE=DATE
+ :20031225
+DTEND
+
+ ;VALUE=DATE
+ :20031226
+DTSTAMP
+
+ :20020430T114937Z
+END:VEVENT
+END:VCALENDAR
+BEGIN:VCALENDAR
+VERSION
+ :2.0
+PRODID
+ :-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN
+METHOD
+ :PUBLISH
+BEGIN:VEVENT
+UID
+ :911737808
+SUMMARY
+ :Boxing Day
+CLASS
+ :PUBLIC
+X-MOZILLA-ALARM-DEFAULT-UNITS
+ :minutes
+X-MOZILLA-ALARM-DEFAULT-LENGTH
+ :15
+X-MOZILLA-RECUR-DEFAULT-UNITS
+ :weeks
+X-MOZILLA-RECUR-DEFAULT-INTERVAL
+ :1
+DTSTART
+ ;VALUE=DATE
+ :20030501
+DTSTAMP
+ :20020430T114937Z
+END:VEVENT
+BEGIN:VEVENT
+UID
+ :wh4t3v3r
+DTSTART;VALUE=DATE:20031225
+SUMMARY:Christmas again!
+END:VEVENT
+END:VCALENDAR
Added: iCalendar/trunk/doc/multiple.txt
==============================================================================
--- (empty file)
+++ iCalendar/trunk/doc/multiple.txt Mon Nov 7 22:07:56 2005
@@ -0,0 +1,20 @@
+A exmaple with multiple VCALENDAR components::
+
+ >>> from icalendar import Calendar
+ >>> import os
+ >>> directory = os.path.dirname(__file__)
+ >>> cals = Calendar.from_string(
+ ... open(os.path.join(directory, 'multiple.ics'),'rb').read(), multiple=True)
+
+ >>> for cal in cals:
+ ... for component in cal.walk():
+ ... component.name
+ 'VCALENDAR'
+ 'VEVENT'
+ 'VCALENDAR'
+ 'VEVENT'
+ 'VEVENT'
+
+ >>> cals[0]['prodid']
+ vText(u'-//Mozilla.org/NONSGML Mozilla Calendar V1.0//EN')
+
Modified: iCalendar/trunk/src/doctest.py
==============================================================================
--- iCalendar/trunk/src/doctest.py (original)
+++ iCalendar/trunk/src/doctest.py Mon Nov 7 22:07:56 2005
@@ -2127,10 +2127,10 @@
words = 0
else:
words = 1
-
+
return count or 1
-
-
+
+
class DocTestCase(unittest.TestCase):
def __init__(self, test, optionflags=0, setUp=None, tearDown=None,
Modified: iCalendar/trunk/src/icalendar/__init__.py
==============================================================================
--- iCalendar/trunk/src/icalendar/__init__.py (original)
+++ iCalendar/trunk/src/icalendar/__init__.py Mon Nov 7 22:07:56 2005
@@ -11,6 +11,6 @@
# useful tzinfo subclasses
from icalendar.prop import FixedOffset, UTC, LocalTimezone
-# Parameters and helper methods for splitting and joining string with escaped
+# Parameters and helper methods for splitting and joining string with escaped
# chars.
from icalendar.parser import Parameters, q_split, q_join
Modified: iCalendar/trunk/src/icalendar/cal.py
==============================================================================
--- iCalendar/trunk/src/icalendar/cal.py (original)
+++ iCalendar/trunk/src/icalendar/cal.py Mon Nov 7 22:07:56 2005
@@ -25,7 +25,6 @@
# The component factory
class ComponentFactory(CaselessDict):
-
"""
All components defined in rfc 2445 are registered in this factory class. To
get a component you can use it like this.
@@ -61,9 +60,7 @@
_marker = []
class Component(CaselessDict):
-
"""
-
Component is the base object for calendar, Event and the other components
defined in RFC 2445. normally you will not use this class directy, but
rather one of the subclasses.
@@ -498,7 +495,6 @@
class Calendar(Component):
-
"""
This is the base object for an iCalendar file.
Modified: iCalendar/trunk/src/icalendar/caselessdict.py
==============================================================================
--- iCalendar/trunk/src/icalendar/caselessdict.py (original)
+++ iCalendar/trunk/src/icalendar/caselessdict.py Mon Nov 7 22:07:56 2005
@@ -91,6 +91,3 @@
def __repr__(self):
return 'CaselessDict(' + dict.__repr__(self) + ')'
-
-
-
Modified: iCalendar/trunk/src/icalendar/interfaces.py
==============================================================================
--- iCalendar/trunk/src/icalendar/interfaces.py (original)
+++ iCalendar/trunk/src/icalendar/interfaces.py Mon Nov 7 22:07:56 2005
@@ -15,12 +15,12 @@
"""
Component is the base object for calendar, Event and the other
components defined in RFC 2445.
-
+
A component is like a dictionary with extra methods and attributes.
"""
# MANIPULATORS
-
+
def __setitem__(name, value):
"""Set a property.
@@ -50,7 +50,7 @@
values - list of values to set
encode - if True, encode Python values as iCalendar types first.
"""
-
+
def add(name, value):
"""Add a property. Can be called multiple times to set a list.
@@ -69,7 +69,7 @@
Reads the iCalendar string and constructs components and
subcomponents out of it.
"""
-
+
# ACCESSORS
def __getitem__(name):
"""Get a property
@@ -78,7 +78,7 @@
Returns an iCalendar property object such as vText.
"""
-
+
def decoded(name, default=_marker):
"""Get a property as a python object.
@@ -98,7 +98,7 @@
Returns list of python objects.
"""
-
+
def as_string():
"""Render the component in the RFC 2445 (iCalendar) format.
@@ -112,15 +112,15 @@
name = Attribute("""
Name of this component (VEVENT, etc)
""")
-
+
def walk(name=None):
"""Recursively traverses component and subcomponents.
name - optional, if given, only return components with that name
-
+
Returns sequence of components.
"""
-
+
def property_items():
"""Return properties as (name, value) tuples.
@@ -143,7 +143,7 @@
class IFreeBusy(IComponent):
"""A component which conforms to an iCalendar VFREEBUSY.
"""
-
+
class ITimezone(IComponent):
"""A component which conforms to an iCalendar VTIMEZONE.
"""
@@ -151,17 +151,17 @@
class IAlarm(IComponent):
"""A component which conforms to an iCalendar VALARM.
"""
-
+
class ICalendar(IComponent):
"""A component which conforms to an iCalendar VCALENDAR.
"""
class IPropertyValue(Interface):
"""An iCalendar property value.
- iCalendar properties have strongly typed values.
+ iCalendar properties have strongly typed values.
This invariance should always be true:
-
+
assert x == vDataType.from_ical(vDataType(x).ical())
"""
@@ -191,11 +191,11 @@
Also behaves like a python str.
"""
-
+
class IDateTime(IPropertyValue):
"""Render and generates iCalendar datetime format.
-
- Important: if tzinfo is defined it renders itself as 'date with utc time'
+
+ Important: if tzinfo is defined it renders itself as 'date with utc time'
Meaning that it has a 'Z' appended, and is in absolute time.
"""
@@ -209,7 +209,7 @@
class IFloat(IPropertyValue):
"""Render and generate floats in iCalendar format.
-
+
Also behaves like a python float.
"""
@@ -222,7 +222,7 @@
class IPeriod(IPropertyValue):
"""A precise period of time (datetime, datetime).
"""
-
+
class IWeekDay(IPropertyValue):
"""Render and generate weekday abbreviation.
"""
@@ -260,6 +260,3 @@
class IInline(IPropertyValue):
"""Inline list.
"""
-
-
-
Modified: iCalendar/trunk/src/icalendar/parser.py
==============================================================================
--- iCalendar/trunk/src/icalendar/parser.py (original)
+++ iCalendar/trunk/src/icalendar/parser.py Mon Nov 7 22:07:56 2005
@@ -95,7 +95,6 @@
return sep.join([dQuote(itm) for itm in lst])
class Parameters(CaselessDict):
-
"""
Parser and generator of Property parameter strings. It knows nothing of
datatypes. It's main concern is textual structure.
@@ -244,7 +243,6 @@
# parsing and generation of content lines
class Contentline(str):
-
"""
A content line is basically a string that can be folded and parsed into
parts.
@@ -340,6 +338,22 @@
Traceback (most recent call last):
...
ValueError: Content line could not be parsed into parts
+
+ >>> c = Contentline('key;param=pvalue:value', strict=False)
+ >>> c.parts()
+ ('key', Parameters({'PARAM': 'pvalue'}), 'value')
+
+ If strict is set to True, uppercase param values that are not
+ double-quoted, this is because the spec says non-quoted params are
+ case-insensitive.
+
+ >>> c = Contentline('key;param=pvalue:value', strict=True)
+ >>> c.parts()
+ ('key', Parameters({'PARAM': 'PVALUE'}), 'value')
+
+ >>> c = Contentline('key;param="pValue":value', strict=True)
+ >>> c.parts()
+ ('key', Parameters({'PARAM': 'pValue'}), 'value')
"""
def __new__(cls, st, strict=False):
@@ -410,7 +424,6 @@
class Contentlines(list):
-
"""
I assume that iCalendar files generally are a few kilobytes in size. Then
this should be efficient. for Huge files, an iterator should probably be
Modified: iCalendar/trunk/src/icalendar/prop.py
==============================================================================
--- iCalendar/trunk/src/icalendar/prop.py (original)
+++ iCalendar/trunk/src/icalendar/prop.py Mon Nov 7 22:07:56 2005
@@ -198,7 +198,6 @@
class FixedOffset(tzinfo):
-
"""Fixed offset in minutes east from UTC."""
def __init__(self, offset, name):
@@ -229,7 +228,6 @@
UTC = UTC()
class LocalTimezone(tzinfo):
-
"""
Timezone of the machine where the code is running
"""
@@ -532,9 +530,7 @@
class vDDDTypes:
-
"""
-
A combined Datetime, Date or Duration parser/generator. Their format cannot
be confused, and often values can be of either types. So this is practical.
@@ -600,7 +596,6 @@
class vPeriod:
-
"""
A precise period of time.
One day in exact datetimes
@@ -1271,7 +1266,6 @@
class TypesFactory(CaselessDict):
-
"""
All Value types defined in rfc 2445 are registered in this factory class. To
get a type you can use it like this.
@@ -1434,4 +1428,3 @@
type_class = self.for_property(name)
decoded = type_class.from_ical(str(value))
return decoded
-
Modified: iCalendar/trunk/src/icalendar/tests/test_icalendar.py
==============================================================================
--- iCalendar/trunk/src/icalendar/tests/test_icalendar.py (original)
+++ iCalendar/trunk/src/icalendar/tests/test_icalendar.py Mon Nov 7 22:07:56 2005
@@ -3,12 +3,13 @@
def test_suite():
suite = unittest.TestSuite()
-
+
suite.addTest(doctest.DocTestSuite(caselessdict))
suite.addTest(doctest.DocTestSuite(parser))
suite.addTest(doctest.DocTestSuite(prop))
suite.addTest(doctest.DocTestSuite(cal))
doc_dir = '../../../doc'
- for docfile in ['example.txt', 'groupscheduled.txt', 'small.txt']:
+ for docfile in ['example.txt', 'groupscheduled.txt',
+ 'small.txt', 'multiple.txt']:
suite.addTest(doctest.DocFileSuite(os.path.join(doc_dir, docfile)))
return suite
Modified: iCalendar/trunk/src/icalendar/tools.py
==============================================================================
--- iCalendar/trunk/src/icalendar/tools.py (original)
+++ iCalendar/trunk/src/icalendar/tools.py Mon Nov 7 22:07:56 2005
@@ -1,4 +1,4 @@
-from string import ascii_letters, digits
+from string import ascii_letters, digits
import random
"""
@@ -10,28 +10,28 @@
"""
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()
'20050109T153222-7ekDDHKcw46QlwZK at example.com'
-
+
You Should at least insert your own hostname to be more complient
>> g = UIDGenerator()
>> uid = g.uid('Example.ORG')
>> uid.ical()
'20050109T153549-NbUItOPDjQj8Ux6q at 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 at 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)])
@@ -49,5 +49,5 @@
if __name__ == "__main__":
import os.path, doctest, tools
- # import and test this file
+ # import and test this file
doctest.testmod(tools)
Modified: iCalendar/trunk/src/icalendar/util.py
==============================================================================
--- iCalendar/trunk/src/icalendar/util.py (original)
+++ iCalendar/trunk/src/icalendar/util.py Mon Nov 7 22:07:56 2005
@@ -1,4 +1,4 @@
-from string import ascii_letters, digits
+from string import ascii_letters, digits
import random
"""
@@ -13,28 +13,28 @@
NOTE: this doctest is disabled
(only two > instead of three)
-
+
Automatic semi-random uid
>> g = UIDGenerator()
>> uid = g.uid()
>> uid.ical()
'20050109T153222-7ekDDHKcw46QlwZK at 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 at 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 at 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)])
More information about the icalendar-checkins
mailing list