pycalendar.git
11 years agoRun update-copyright.py master
W. Trevor King [Wed, 3 Jul 2013 17:31:30 +0000 (13:31 -0400)]
Run update-copyright.py

11 years agoREADME: Point to icalendar and other pre-existing libraries
W. Trevor King [Wed, 3 Jul 2013 17:25:16 +0000 (13:25 -0400)]
README: Point to icalendar and other pre-existing libraries

icalendar seems to be the only one that is serious.  I'll take a
deeper look into their code and see if pycalendar is worth
maintaining.

11 years agoREADME.rst: Add a symlink for GitHub rendering
W. Trevor King [Tue, 2 Jul 2013 03:20:35 +0000 (23:20 -0400)]
README.rst: Add a symlink for GitHub rendering

11 years agoREADME: Use a standard link instead of :RFC:`...`
W. Trevor King [Tue, 2 Jul 2013 02:17:20 +0000 (22:17 -0400)]
README: Use a standard link instead of :RFC:`...`

PyPI doesn't like the :RFC: role, and distutils gives the unhelpful:

  $ python setup.py check --restructuredtext
  running check
  warning: check: Could not finish the parsing.

Using a standard link avoids this issue.

11 years agoMajor restructuring to get automatic decoding/encoding
W. Trevor King [Tue, 2 Jul 2013 02:03:08 +0000 (22:03 -0400)]
Major restructuring to get automatic decoding/encoding

Storing raw iCalendar data or unfolded lines is silly.  We should only
store native Python types, and serialize/deserialize as needed.  This
monster commit reworks the whole package to make this possible, adding
sub-packages for a number of data-types, properties, and components
defined in RFC 5545.  The conversion is not complete yet, and there
are a number of placeholder comments waiting to be filled in still.

Some of the test output changed because now that we serialize from
scratch, we lose information about the input that was unimportant
(e.g. GEO precision is now rounded up to 6 decimals, properties are
re-ordered inside their component, etc.).

11 years agoMANIFEST.in: Add AUTHORS to the manifest
W. Trevor King [Tue, 2 Jul 2013 01:59:32 +0000 (21:59 -0400)]
MANIFEST.in: Add AUTHORS to the manifest

This should have happened after 36813e4 (Run update-copyright.py,
2013-06-30).

11 years agoRemove - and : from example DTSTAMPs
W. Trevor King [Mon, 1 Jul 2013 12:14:51 +0000 (08:14 -0400)]
Remove - and : from example DTSTAMPs

RFC 5545 does not use these separators (unfortunately) in their dates
and times.  See sections 3.3.4 (Date), 3.3.5 (Date-Time), and 3.3.12
(Time), which specify:

  date               = date-value
  date-value         = date-fullyear date-month date-mday
  date-fullyear      = 4DIGIT
  date-month         = 2DIGIT        ;01-12
  date-mday          = 2DIGIT        ;01-28, 01-29, 01-30, 01-31
                                     ;based on month/year

  date-time  = date "T" time ;As specified in the DATE and TIME
                             ;value definitions

  time         = time-hour time-minute time-second [time-utc]
  time-hour    = 2DIGIT        ;00-23
  time-minute  = 2DIGIT        ;00-59
  time-second  = 2DIGIT        ;00-60
  ;The "60" value is used to account for positive "leap" seconds.
  time-utc     = "Z"

11 years agoentry: Add parameter parsing to lines
W. Trevor King [Sun, 30 Jun 2013 21:00:26 +0000 (17:00 -0400)]
entry: Add parameter parsing to lines

Split the initial key/params/value parsing into its own function to
keep Entry._parse from growing unwieldy.

11 years agoentry: Add Feed.get_geo for parsing the GEO field
W. Trevor King [Sun, 30 Jun 2013 20:45:01 +0000 (16:45 -0400)]
entry: Add Feed.get_geo for parsing the GEO field

This is library-level code, so it should go in the library.

11 years agoentry: Add a docstring to Feed.get_text
W. Trevor King [Sun, 30 Jun 2013 20:44:24 +0000 (16:44 -0400)]
entry: Add a docstring to Feed.get_text

Pointing people towards the TEXT specification.

11 years agoRun update-copyright.py
W. Trevor King [Sun, 30 Jun 2013 20:36:01 +0000 (16:36 -0400)]
Run update-copyright.py

11 years agotest/aggregate.py: Add a Map class for persistent streams
W. Trevor King [Sun, 30 Jun 2013 20:32:10 +0000 (16:32 -0400)]
test/aggregate.py: Add a Map class for persistent streams

Using a class method as a processing function allows you to keep open
file handles (and similar processor state) between feeds.

11 years agotest/aggregate.py: Add an example aggregation script
W. Trevor King [Sun, 30 Jun 2013 20:22:52 +0000 (16:22 -0400)]
test/aggregate.py: Add an example aggregation script

This is how you use the library :).

11 years agotest/data/bootcamps: Add a whole bunch of SWC boot camp feeds
W. Trevor King [Sun, 30 Jun 2013 20:22:06 +0000 (16:22 -0400)]
test/data/bootcamps: Add a whole bunch of SWC boot camp feeds

This gives us lots of example feeds to aggregate.

11 years agotest/data/geohash.ics: Separate lat/lon with a semicolon
W. Trevor King [Sun, 30 Jun 2013 20:07:35 +0000 (16:07 -0400)]
test/data/geohash.ics: Separate lat/lon with a semicolon

From RFC 5545, section 3.8.1.6 (Geographic Position):

  Value Type:  FLOAT.  The value MUST be two SEMICOLON-separated FLOAT
      values.

11 years agoentry: Die unless we're parsing a version 2.0 iCalendar
W. Trevor King [Sun, 30 Jun 2013 19:03:03 +0000 (15:03 -0400)]
entry: Die unless we're parsing a version 2.0 iCalendar

RFC 5545, section 3.7.4 (Version) describes this text field.  Until I
actually see something using using the (minver ";" maxver) syntax,
I'll just require everything to be version 2.0.

11 years agoentry: Adjust entry parsing to handle nested entries (BEGIN & END)
W. Trevor King [Sun, 30 Jun 2013 18:52:12 +0000 (14:52 -0400)]
entry: Adjust entry parsing to handle nested entries (BEGIN & END)

Now Entry can parse a whole VCALENDAR, and return a nested tree of
Entry instances.

This also makes Feed a subclass of Entry.  The new entry BEGIN/END
parsing is derived from the old Feed BEGIN/END parsing.

11 years agoentry: Hash entries by their UID (when possible)
W. Trevor King [Sun, 30 Jun 2013 18:14:08 +0000 (14:14 -0400)]
entry: Hash entries by their UID (when possible)

From RFC 5545, section 3.8.4.7 (Unique Identifier):

  Conformance:  The property MUST be specified in the "VEVENT",
      "VTODO", "VJOURNAL", or "VFREEBUSY" calendar components.

11 years agoREADME: Add installation and testing advice
W. Trevor King [Sun, 30 Jun 2013 18:11:18 +0000 (14:11 -0400)]
README: Add installation and testing advice

11 years agoREADME: Flesh out the description with links to other aggregators
W. Trevor King [Sun, 30 Jun 2013 17:55:44 +0000 (13:55 -0400)]
README: Flesh out the description with links to other aggregators

Unfortunately, none of the existing aggregators are libraries.

11 years agoMANIFEST.in: Add a basic manifest
W. Trevor King [Sun, 30 Jun 2013 17:34:15 +0000 (13:34 -0400)]
MANIFEST.in: Add a basic manifest

We don't have any READMEs under test/ yet, but I imagine we will
eventually.

11 years agosetup.py: Add a boilerplate setup.py
W. Trevor King [Sun, 30 Jun 2013 17:32:23 +0000 (13:32 -0400)]
setup.py: Add a boilerplate setup.py

11 years ago.gitignore: Add the usual suspects
W. Trevor King [Sun, 30 Jun 2013 17:26:08 +0000 (13:26 -0400)]
.gitignore: Add the usual suspects

11 years ago.update-copyright.conf: Add copyright configuration
W. Trevor King [Sun, 30 Jun 2013 17:24:59 +0000 (13:24 -0400)]
.update-copyright.conf: Add copyright configuration

Use my external update-copyright package to maintain copyright blurbs.

http://pypi.python.org/pypi/update-copyright/

11 years agoentry: Make Entry a subclass of dict
W. Trevor King [Sun, 30 Jun 2013 17:19:16 +0000 (13:19 -0400)]
entry: Make Entry a subclass of dict

This gives us the familiar interface, and moves key/value processing
to a one-time-per-entry loop in ._fill_dict().

11 years agoentry: Add Entry.process() and .get*()
W. Trevor King [Sun, 30 Jun 2013 16:19:38 +0000 (12:19 -0400)]
entry: Add Entry.process() and .get*()

Because we will definitely want a Pythonic API to access entry items.

11 years agofeed: Use splitlines() instead of split('\r\n') in Feed.process()
W. Trevor King [Sun, 30 Jun 2013 16:33:48 +0000 (12:33 -0400)]
feed: Use splitlines() instead of split('\r\n') in Feed.process()

The specs require '\r\n', but we don't have to be that strict.

11 years agoaggregator: Escape VERSION and PRODID
W. Trevor King [Sun, 30 Jun 2013 16:09:04 +0000 (12:09 -0400)]
aggregator: Escape VERSION and PRODID

From RFC 5545, sections 3.7.3 (Product Identifier) and 3.7.4
(Version), these are both text fields.

11 years agotext: Add escape() and unescape() for RFC 5545 compliance
W. Trevor King [Sun, 30 Jun 2013 16:04:35 +0000 (12:04 -0400)]
text: Add escape() and unescape() for RFC 5545 compliance

11 years agoaggregator: Add processors field for post-fetch processing hooks
W. Trevor King [Sun, 30 Jun 2013 15:15:10 +0000 (11:15 -0400)]
aggregator: Add processors field for post-fetch processing hooks

11 years agofeed: Turn Feed into a set of entries
W. Trevor King [Sun, 30 Jun 2013 15:07:39 +0000 (11:07 -0400)]
feed: Turn Feed into a set of entries

11 years agoentry: Add an initial Entry implementation
W. Trevor King [Sun, 30 Jun 2013 15:07:18 +0000 (11:07 -0400)]
entry: Add an initial Entry implementation

11 years agofeed: Only fetch if we haven't already (or if we're forcing a fetch)
W. Trevor King [Sun, 30 Jun 2013 14:35:33 +0000 (10:35 -0400)]
feed: Only fetch if we haven't already (or if we're forcing a fetch)

11 years agoaggregator: Add an initial Aggregator implementation
W. Trevor King [Sun, 30 Jun 2013 14:27:44 +0000 (10:27 -0400)]
aggregator: Add an initial Aggregator implementation

Currently broken pending support for `for entry in feed`.  The version
and product identifier fields are required, as specified in RFC 5545,
sections 3.7.3 (Product Identifier) and 3.7.4 (Version).  They'll also
need to have special characters (e.g. commas) escaped, but I'll get to
that later.

11 years agofeed: Implement feed.fetch()
W. Trevor King [Sun, 30 Jun 2013 14:04:48 +0000 (10:04 -0400)]
feed: Implement feed.fetch()

Add __version__, __url__, and USER_AGENT to the package namespace, so
we have a useful user agent to use when fetching.  The fetch code can
hard-code UTF-8 as the feed charset, because RFC 5545, section 6
(Internationalization Considerations) reads:

  Applications MUST generate iCalendar streams in the UTF-8 charset
  and MUST accept an iCalendar stream in the UTF-8 or US-ASCII
  charset.

From a character conversion standpoint, that means we can always use
UTF-8, because US-ASCII is a subset of UTF-8.

11 years agotest/data/geohash.ics: Pull out geohashing example from Feed doctest
W. Trevor King [Sun, 30 Jun 2013 13:41:21 +0000 (09:41 -0400)]
test/data/geohash.ics: Pull out geohashing example from Feed doctest

This makes it easier to reuse the test data in other locations.

Also escape commas in the data.  From RFC 5545, section 3.3.11. Text:

  The "TEXT" property values may also contain special characters that
  are used to signify delimiters, such as a COMMA character for lists
  of values or a SEMICOLON character for structured values.  In order
  to support the inclusion of these special characters in "TEXT"
  property values, they MUST be escaped with a BACKSLASH character.

11 years agofeed: Stub out the Feed class
W. Trevor King [Sun, 30 Jun 2013 13:25:29 +0000 (09:25 -0400)]
feed: Stub out the Feed class

11 years agoBegin versioning under the GPLv3
W. Trevor King [Sun, 30 Jun 2013 12:54:37 +0000 (08:54 -0400)]
Begin versioning under the GPLv3