kopia lustrzana https://github.com/collective/icalendar
Prepare for grand renaming to lowercase, shorter module names, non-plural
in module names.pull/6/head
rodzic
fa6370a88d
commit
968133c0db
|
@ -70,7 +70,7 @@ There are methods for converting to and from these encodings in the package.
|
|||
|
||||
These are the most important imports.
|
||||
|
||||
>>> from iCalendar import Calendar, Event
|
||||
>>> from icalendar import Calendar, Event
|
||||
|
||||
Components
|
||||
----------
|
||||
|
@ -128,9 +128,10 @@ ATTENDEE:MAILTO:test@example.com
|
|||
END:VCALENDAR
|
||||
|
||||
|
||||
Note: this version doesn't check for compliance, so you should look in the RFC
|
||||
2445 spec for legal properties for each component, or look in the iCalendar.py
|
||||
file, where it is at least defined for each component.
|
||||
Note: this version doesn't check for compliance, so you should look in
|
||||
the RFC 2445 spec for legal properties for each component, or look in
|
||||
the icalendar/calendar.py file, where it is at least defined for each
|
||||
component.
|
||||
|
||||
Subcomponents
|
||||
-------------
|
||||
|
@ -189,7 +190,7 @@ a class that can parse and encode the type.
|
|||
|
||||
So if you want to do it manually ...
|
||||
|
||||
>>> from iCalendar import vDatetime
|
||||
>>> from icalendar import vDatetime
|
||||
>>> now = datetime(2005,4,4,8,0,0)
|
||||
>>> vDatetime(now).ical()
|
||||
'20050404T080000'
|
||||
|
@ -205,8 +206,8 @@ Python type.
|
|||
datetime.datetime(2005, 4, 4, 8, 0)
|
||||
|
||||
>>> dt = vDatetime.from_ical('20050404T080000Z')
|
||||
>>> repr(dt)[:85] + repr(dt)[85+8:]
|
||||
'datetime.datetime(2005, 4, 4, 8, 0, tzinfo=<iCalendar.PropertyValues.UTC object at 0x>)'
|
||||
>>> 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
|
||||
|
@ -229,7 +230,7 @@ that can be loaded into the Mozilla calendar
|
|||
Init the calendar
|
||||
>>> cal = Calendar()
|
||||
>>> from datetime import datetime
|
||||
>>> from iCalendar import UTC # timezone
|
||||
>>> from icalendar import UTC # timezone
|
||||
|
||||
Som properties are required to be complient
|
||||
>>> cal.add('prodid', '-//My calendar product//mxm.dk//')
|
||||
|
@ -244,7 +245,7 @@ that can be loaded into the Mozilla calendar
|
|||
|
||||
|
||||
A property with parameters. Notice that they are an attribute on the value.
|
||||
>>> from iCalendar import vCalAddress, vText
|
||||
>>> from icalendar import vCalAddress, vText
|
||||
>>> organizer = vCalAddress('MAILTO:noone@example.com')
|
||||
|
||||
Automatic encoding is not yet implemented for parameter values.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
An example from the RFC 2445 spec.
|
||||
|
||||
>>> from iCalendar import Calendar
|
||||
>>> from icalendar import Calendar
|
||||
>>> import os
|
||||
>>> directory = os.path.dirname(__file__)
|
||||
>>> cal = Calendar.from_string(
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
A small example
|
||||
|
||||
>>> from iCalendar import Calendar
|
||||
>>> from icalendar import Calendar
|
||||
>>> import os
|
||||
>>> directory = os.path.dirname(__file__)
|
||||
>>> cal = Calendar.from_string(
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
# Components
|
||||
from iCalendar import Calendar, Event, Todo, Journal, FreeBusy, Timezone, Alarm, \
|
||||
ComponentFactory
|
||||
from icalendar.calendar import Calendar, Event, Todo, Journal
|
||||
from icalendar.calendar import FreeBusy, Timezone, Alarm, ComponentFactory
|
||||
|
||||
# Property Data Value Types
|
||||
from PropertyValues import vBinary, vBoolean, vCalAddress, vDatetime, vDate, \
|
||||
vDDDTypes, vDuration, vFloat, vInt, vPeriod, \
|
||||
vWeekday, vFrequency, vRecur, vText, vTime, vUri, \
|
||||
vGeo, vUTCOffset, TypesFactory
|
||||
from icalendar.prop import vBinary, vBoolean, vCalAddress, vDatetime, vDate, \
|
||||
vDDDTypes, vDuration, vFloat, vInt, vPeriod, \
|
||||
vWeekday, vFrequency, vRecur, vText, vTime, vUri, \
|
||||
vGeo, vUTCOffset, TypesFactory
|
||||
|
||||
# usefull tzinfo subclasses
|
||||
from PropertyValues import FixedOffset, UTC, LocalTimezone
|
||||
from icalendar.prop import FixedOffset, UTC, LocalTimezone
|
||||
|
||||
# Parameters and helper methods for splitting and joining string with escaped
|
||||
# chars.
|
||||
from ContentlinesParser import Parameters, q_split, q_join
|
||||
from icalendar.parser import Parameters, q_split, q_join
|
||||
|
|
|
@ -15,10 +15,10 @@ SequenceTypes = (ListType, TupleType)
|
|||
import re
|
||||
|
||||
# from this package
|
||||
from CaselessDict import CaselessDict
|
||||
from ContentlinesParser import Contentlines, Contentline, Parameters,\
|
||||
q_split, q_join
|
||||
from PropertyValues import TypesFactory
|
||||
from icalendar.caselessdict import CaselessDict
|
||||
from icalendar.parser import Contentlines, Contentline, Parameters
|
||||
from icalendar.parser import q_split, q_join
|
||||
from icalendar.prop import TypesFactory
|
||||
|
||||
|
||||
######################################
|
||||
|
@ -37,7 +37,7 @@ class ComponentFactory(CaselessDict):
|
|||
'BEGIN:VEVENT\\r\\nDTSTART:19700101\\r\\nEND:VEVENT\\r\\n'
|
||||
|
||||
>>> factory.get('VCALENDAR', Component)
|
||||
<class 'iCalendar.iCalendar.Calendar'>
|
||||
<class 'icalendar.calendar.Calendar'>
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
@ -110,7 +110,7 @@ class Component(CaselessDict):
|
|||
>>> c.as_string()
|
||||
'BEGIN:VCALENDAR\\r\\nATTENDEE:Max M\\r\\nEND:VCALENDAR\\r\\n'
|
||||
|
||||
>>> from PropertyValues import vDatetime
|
||||
>>> from icalendar.prop import vDatetime
|
||||
|
||||
Components can be nested, so You can add a subcompont. Eg a calendar holds events.
|
||||
>>> e = Component(summary='A brief history of time')
|
||||
|
@ -523,10 +523,3 @@ class Calendar(Component):
|
|||
# These are read only singleton, so one instance is enough for the module
|
||||
types_factory = TypesFactory()
|
||||
component_factory = ComponentFactory()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
import os.path, doctest, iCalendar
|
||||
# import and test this file
|
||||
doctest.testmod(iCalendar)
|
|
@ -94,9 +94,4 @@ class CaselessDict(dict):
|
|||
return 'CaselessDict(' + dict.__repr__(self) + ')'
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os.path, doctest, CaselessDict
|
||||
# import and test this file
|
||||
doctest.testmod(CaselessDict)
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ from types import TupleType, ListType
|
|||
SequenceTypes = [TupleType, ListType]
|
||||
import re
|
||||
# from this package
|
||||
from CaselessDict import CaselessDict
|
||||
from icalendar.caselessdict import CaselessDict
|
||||
|
||||
|
||||
#################################################################
|
||||
|
@ -250,13 +250,13 @@ class Contentline(str):
|
|||
'ATTENDEE:MAILTO:maxm@example.com'
|
||||
|
||||
A value can also be any of the types defined in PropertyValues
|
||||
>>> from PropertyValues import vText
|
||||
>>> from icalendar.prop import vText
|
||||
>>> parts = ('ATTENDEE', Parameters(), vText('MAILTO:test@example.com'))
|
||||
>>> Contentline.from_parts(parts)
|
||||
'ATTENDEE:MAILTO:test@example.com'
|
||||
|
||||
A value can also be unicode
|
||||
>>> from PropertyValues import vText
|
||||
>>> from icalendar.prop import vText
|
||||
>>> parts = ('SUMMARY', Parameters(), vText(u'INternational char æ ø å'))
|
||||
>>> Contentline.from_parts(parts)
|
||||
'SUMMARY:INternational char \\xc3\\xa6 \\xc3\\xb8 \\xc3\\xa5'
|
||||
|
@ -381,13 +381,6 @@ class Contentlines(list):
|
|||
from_string = staticmethod(from_string)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os.path, doctest, ContentlinesParser
|
||||
# import and test this file
|
||||
doctest.testmod(ContentlinesParser)
|
||||
|
||||
|
||||
# ran this:
|
||||
# sample = open('./samples/test.ics', 'rb').read() # binary file in windows!
|
||||
# lines = Contentlines.from_string(sample)
|
||||
|
@ -412,4 +405,4 @@ if __name__ == "__main__":
|
|||
#('SUMMARY', Parameters({}), 'A single event')
|
||||
#('UID', Parameters({}), '42')
|
||||
#('END', Parameters({}), 'VEVENT')
|
||||
#('END', Parameters({}), 'VCALENDAR')
|
||||
#('END', Parameters({}), 'VCALENDAR')
|
|
@ -49,8 +49,8 @@ import re
|
|||
import time as _time
|
||||
|
||||
# from this package
|
||||
from CaselessDict import CaselessDict
|
||||
from ContentlinesParser import Parameters
|
||||
from icalendar.caselessdict import CaselessDict
|
||||
from icalendar.parser import Parameters
|
||||
|
||||
|
||||
|
||||
|
@ -534,8 +534,8 @@ class vDDDTypes:
|
|||
>>> type(d)
|
||||
<type 'datetime.datetime'>
|
||||
|
||||
>>> repr(vDDDTypes.from_ical('20010101T123000Z'))[:75]
|
||||
'datetime.datetime(2001, 1, 1, 12, 30, tzinfo=<iCalendar.PropertyValues.UTC '
|
||||
>>> repr(vDDDTypes.from_ical('20010101T123000Z'))[:65]
|
||||
'datetime.datetime(2001, 1, 1, 12, 30, tzinfo=<icalendar.prop.UTC '
|
||||
|
||||
>>> d = vDDDTypes.from_ical('20010101')
|
||||
>>> type(d)
|
||||
|
@ -1394,10 +1394,3 @@ class TypesFactory(CaselessDict):
|
|||
decoded = type_class.from_ical(str(value))
|
||||
return decoded
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os.path, doctest, PropertyValues
|
||||
# import and test this file
|
||||
doctest.testmod(PropertyValues)
|
||||
|
|
@ -1,17 +1,14 @@
|
|||
import unittest, doctest, os
|
||||
from iCalendar import iCalendar, CaselessDict, ContentlinesParser
|
||||
from iCalendar import PropertyValues, tools
|
||||
from icalendar import calendar, caselessdict, parser, prop
|
||||
|
||||
def test_suite():
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
suite.addTest(doctest.DocTestSuite(CaselessDict))
|
||||
suite.addTest(doctest.DocTestSuite(ContentlinesParser))
|
||||
suite.addTest(doctest.DocTestSuite(PropertyValues))
|
||||
suite.addTest(doctest.DocTestSuite(iCalendar))
|
||||
suite.addTest(doctest.DocTestSuite(caselessdict))
|
||||
suite.addTest(doctest.DocTestSuite(parser))
|
||||
suite.addTest(doctest.DocTestSuite(prop))
|
||||
suite.addTest(doctest.DocTestSuite(calendar))
|
||||
doc_dir = '../../../doc'
|
||||
for docfile in ['example.txt', 'groupscheduled.txt', 'small.txt']:
|
||||
suite.addTest(doctest.DocFileSuite(os.path.join(doc_dir, docfile)))
|
||||
# only has a disabled doctest
|
||||
# suite.addTest(doctest.DocTestSuite(tools))
|
||||
return suite
|
||||
|
|
|
@ -9,7 +9,10 @@ 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!
|
||||
If you are too lazy to create real uid's.
|
||||
|
||||
NOTE: this doctest is disabled
|
||||
(only two > instead of three)
|
||||
|
||||
Automatic semi-random uid
|
||||
>> g = UIDGenerator()
|
||||
|
@ -46,8 +49,3 @@ class UIDGenerator:
|
|||
unique = unique or self.rnd_string()
|
||||
return vText('%s-%s@%s' % (vDatetime.today().ical(), unique, host_name))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import os.path, doctest, tools
|
||||
# import and test this file
|
||||
doctest.testmod(tools)
|
Ładowanie…
Reference in New Issue