vobjectx¶
Main package documentation for VObjectX.
Module: vobjectx¶
vobjectx ¶
VObjectx Overview¶
vobjectx parses vCard or vCalendar files, returning a tree of Python objects.
It also provids an API to create vCard or vCalendar data structures which
can then be serialized.
Parsing existing streams
------------------------
Streams containing one or many L{Component<base.Component>}s can be
parsed using L{read_components<base.read_components>}. As each Component
is parsed, vobjectx will attempt to give it a L{Behavior<behavior.Behavior>}.
If an appropriate Behavior is found, any base64, quoted-printable, or
backslash escaped data will automatically be decoded. Dates and datetimes
will be transformed to datetime.date or datetime.datetime instances.
Components containing recurrence information will have a special rruleset
attribute (a dateutil.rrule.rruleset instance).
Validation
----------
L{Behavior<behavior.Behavior>} classes implement validation for
L{Component<base.Component>}s. To validate, an object must have all
required children. There (TODO: will be) a toggle to raise an exception or
just log unrecognized, non-experimental children and parameters.
Creating objects programatically
--------------------------------
A L{Component<base.Component>} can be created from scratch. No encoding
is necessary, serialization will encode data automatically. Factory
functions (TODO: will be) available to create standard objects.
Serializing objects
-------------------
Serialization:
- Looks for missing required children that can be automatically generated,
like a UID or a PRODID, and adds them
- Encodes all values that can be automatically encoded
- Checks to make sure the object is valid (unless this behavior is
explicitly disabled)
- Appends the serialized object to a buffer, or fills a new
buffer and returns it
Examples
--------
>>> import datetime
>>> import dateutil.rrule as rrule
>>> x = iCalendar()
>>> x.add('vevent')
<VEVENT| []>
>>> x
<VCALENDAR| [<VEVENT| []>]>
>>> v = x.vevent
>>> utc = icalendar.utc
>>> v.add('dtstart').value = datetime.datetime(2004, 12, 15, 14, tzinfo = utc)
>>> v
<VEVENT| [<DTSTART{}2004-12-15 14:00:00+00:00>]>
>>> x
<VCALENDAR| [<VEVENT| [<DTSTART{}2004-12-15 14:00:00+00:00>]>]>
>>> newrule = rrule.rruleset()
>>> newrule.rrule(rrule.rrule(rrule.WEEKLY, count=2, dtstart=v.dtstart.value))
>>> v.rruleset = newrule
>>> list(v.rruleset)
[datetime.datetime(2004, 12, 15, 14, 0, tzinfo=tzutc()), datetime.datetime(2004, 12, 22, 14, 0, tzinfo=tzutc())]
>>> v.add('uid').value = "randomuid@MYHOSTNAME"
>>> print(x.serialize())
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//VOBJECTX//NONSGML Version 1//EN
BEGIN:VEVENT
UID:randomuid@MYHOSTNAME
DTSTART:20041215T140000Z
RRULE:FREQ=WEEKLY;COUNT=2
END:VEVENT
END:VCALENDAR
Functions¶
read_components ¶
read_components(stream_or_string, validate=False, transform=True, ignore_unreadable=False, allow_qp=False)
Generate one Component at a time from a stream.
Source code in vobjectx/base.py
read_one ¶
Return the first component from stream.
new_from_behavior ¶
Given a name, return a behaviored ContentLine or Component.
Source code in vobjectx/behavior.py
Modules¶
base ¶
vobjectx module for reading vCard and vCalendar files.
Classes¶
VBase ¶
Base class for ContentLine and Component.
@ivar behavior: The Behavior class associated with this object, which controls validation, transformations, and encoding. @ivar parent_behavior: The object's parent's behavior, or None if no behaviored parent exists. @ivar is_native: Boolean describing whether this component is a Native instance. @ivar group: An optional group prefix, should be used only to indicate sort order in vCards, according to spec.
Current spec: 4.0 (http://tools.ietf.org/html/rfc6350)
Source code in vobjectx/base.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
Set behavior if name is in self.parent_behavior.known_children.
If cascade is True, unset behavior and parent_behavior for all descendants, then recalculate behavior and parent_behavior.
Source code in vobjectx/base.py
Set behavior. If cascade is True, auto_behavior all descendants.
Source code in vobjectx/base.py
Transform this object into a custom VBase subclass.
transform_to_native should always return a representation of this object. It may do so by modifying self in place then returning self, or by creating a new object.
Source code in vobjectx/base.py
Return self transformed into a ContentLine or Component if needed.
May have side effects. If it does, transform_from_native and transform_to_native MUST have perfectly inverse side effects. Allowing such side effects is convenient for objects whose transformations only change a few attributes.
Note that it isn't always possible for transform_from_native to be a perfect inverse of transform_to_native, in such cases transform_from_native should return a new object, not self after modifications.
Source code in vobjectx/base.py
Serialize to buf if it exists, otherwise return a string.
Use self.behavior.serialize if behavior exists.
Source code in vobjectx/base.py
ContentLine ¶
Bases: VBase
Holds one content line for formats like vCard and vCalendar.
For example::
@ivar name: The uppercased name of the contentline. @ivar params: A dictionary of parameters and associated lists of values. Singleton params (e.g., WORK, CELL in vCard 2.1) are stored with an empty list as the value. @ivar value: The value of the contentline. @ivar encoded: A boolean describing whether the data in the content line is encoded. Generally, text read from a serialized vCard or vCalendar should be considered encoded. Data added programmatically should not be encoded. @ivar line_number: An optional line number associated with the contentline.
Source code in vobjectx/base.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
Component ¶
Bases: VBase
A complex property that can contain multiple ContentLines.
For our purposes, a component must start with a BEGIN:xxxx line and end with END:xxxx, or have a PROFILE:xxx line if a top-level component.
@ivar contents: A dictionary of lists of Component or ContentLine instances. The keys are the lowercased names of child ContentLines or Components. Note that BEGIN and END ContentLines are not included in contents. @ivar name: Uppercase string used to represent this Component, i.e VCARD if the serialized object starts with BEGIN:VCARD. @ivar use_begin: A boolean flag determining whether BEGIN: and END: lines should be serialized.
Source code in vobjectx/base.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
Assign a PROFILE to this unnamed component.
Used by vCard, not by vCalendar.
Source code in vobjectx/base.py
Return a child's value (the first, by default), or None.
Add obj_or_name to contents, set behavior if it can be inferred.
If obj_or_name is a string, create an empty component or line based on behavior. If no behavior is found for the object, add a ContentLine.
group is an optional prefix to the name of the object (see RFC 2425).
Source code in vobjectx/base.py
Remove obj from contents.
Set behavior if one matches name, version_line.value.
Source code in vobjectx/base.py
Recursively replace children with their native representation.
Sort to get dependency order right, like vtimezone before vevent.
Source code in vobjectx/base.py
Recursively transform native children to vanilla representations.
Source code in vobjectx/base.py
Functions¶
parse_params ¶
Parse parameters
Source code in vobjectx/base.py
parse_line ¶
Parse line
Source code in vobjectx/base.py
get_logical_lines ¶
Iterate through a stream, yielding one logical line at a time.
Because many applications still use vCard 2.1, we have to deal with the quoted-printable encoding for long lines, as well as the vCard 3.0 and vCalendar line folding technique, a whitespace character at the start of the line.
Quoted-printable data will be decoded in the Behavior decoding phase.
Source code in vobjectx/base.py
dquote_escape ¶
Return param, or "param" if ',' or ';' or ':' is in param.
Source code in vobjectx/base.py
fold_one_line ¶
Folding line procedure that ensures multi-byte utf-8 sequences are not broken across lines
Source code in vobjectx/base.py
default_serialize ¶
Encode and fold obj and its children, write to buf or return a string.
Source code in vobjectx/base.py
read_components ¶
read_components(stream_or_string, validate=False, transform=True, ignore_unreadable=False, allow_qp=False)
Generate one Component at a time from a stream.
Source code in vobjectx/base.py
read_one ¶
Return the first component from stream.
behavior ¶
Classes¶
Behavior ¶
Behavior (validation, encoding, and transformations) for vobjects.
Abstract class to describe vobjectx options, requirements and encodings.
Behaviors are used for root components like VCALENDAR, for subcomponents like VEVENT, and for individual lines in components.
Behavior subclasses are not meant to be instantiated, all methods should be classmethods.
@cvar name: The uppercase name of the object described by the class, or a generic name if the class defines behavior for many objects. @cvar description: A brief excerpt from the RFC explaining the function of the component or line. @cvar version_string: The string associated with the component, for instance, 2.0 if there's a line like VERSION:2.0, an empty string otherwise. @cvar known_children: A dictionary with uppercased component/property names as keys and a tuple (min, max, id) as value, where id is the id used by L{register_behavior}, min and max are the limits on how many of this child must occur. None is used to denote no max or no id. @cvar quoted_printable: A boolean describing whether the object should be encoded and decoded using quoted printable line folding and character escaping. @cvar default_behavior: Behavior to apply to ContentLine children when no behavior is found. @cvar has_native: A boolean describing whether the object can be transformed into a more Pythonic object. @cvar is_component: A boolean, True if the object should be a Component. @cvar sort_first: The lower-case list of children which should come first when sorting. @cvar allow_group: Whether or not vCard style group prefixes are allowed.
Source code in vobjectx/behavior.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
classmethod
¶Check if the object satisfies this behavior's requirements.
@param obj:
The L{ContentLine
Source code in vobjectx/behavior.py
staticmethod
¶Turn a ContentLine or Component into a Python-native representation.
If appropriate, turn dates or datetime strings into Python objects. Components containing VTIMEZONEs turn into VtimezoneComponents.
Source code in vobjectx/behavior.py
staticmethod
¶staticmethod
¶classmethod
¶Set implicit parameters, do encoding, return unicode string.
If validate is True, raise VObjectError if the line doesn't validate after implicit parameters are generated.
Default is to call base.default_serialize.
Source code in vobjectx/behavior.py
Functions¶
new_from_behavior ¶
Given a name, return a behaviored ContentLine or Component.
Source code in vobjectx/behavior.py
change_tz ¶
Translate an ics file's events to a different timezone.
Functions¶
change_tz ¶
Change the timezone of the specified component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cal
|
Component
|
the component to change |
required |
new_timezone
|
tzinfo
|
the timezone to change to |
required |
default
|
tzinfo
|
a timezone to assume if the dtstart or dtend in cal doesn't have an existing timezone |
required |
utc_only
|
bool
|
only convert dates that are in utc |
False
|
utc_tz
|
tzinfo
|
the tzinfo to compare to for UTC when processing utc_only=True |
tzutc()
|
Source code in vobjectx/change_tz.py
exceptions ¶
hcalendar ¶
A microformat for serializing iCalendar data
(http://microformats.org/wiki/hcalendar)
Here is a sample event in an iCalendar:
BEGIN:VCALENDAR PRODID:-//XYZproduct//EN VERSION:2.0 BEGIN:VEVENT URL:http://www.web2con.com/ DTSTART:20051005 DTEND:20051008 SUMMARY:Web 2.0 Conference LOCATION:Argent Hotel\, San Francisco\, CA END:VEVENT END:VCALENDAR
and an equivalent event in hCalendar format with various elements optimized appropriately.
Web 2.0 Conference: October 5- 7, at the Argent Hotel, San Francisco, CA
Classes¶
HCalendar ¶
Bases: VCalendar2_0
Source code in vobjectx/hcalendar.py
classmethod
¶Serialize iCalendar to HTML using the hCalendar microformat (http://microformats.org/wiki/hcalendar)
Source code in vobjectx/hcalendar.py
helper ¶
Classes¶
Functions¶
Modules¶
imports_ ¶
List of all common imports except future and aliases
parser ¶
Return the datetime of the transition to/from DST, or None.
Returns the transition time as a naive datetime in local wall-clock time, typically at 2:00 AM for most timezones.
Source code in vobjectx/helper/parser.py
Compare offsets and DST transitions from start_year to end_year.
Source code in vobjectx/helper/parser.py
serializer ¶
Convert timedelta to an ical DURATION format: PnYnMnDTnHnMnS
Source code in vobjectx/helper/serializer.py
overloading function for date_to_string and datetime_to_string
Ignore tzinfo unless convert_to_utc. Output string.
Source code in vobjectx/helper/serializer.py
Returns offset in format : ±HHMM
Source code in vobjectx/helper/serializer.py
wrappers ¶
This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emitted when the function is used.
Source code in vobjectx/helper/wrappers.py
This is a decorator logs inputs and outputs of a func
Source code in vobjectx/helper/wrappers.py
ical ¶
Functions¶
Modules¶
ical_helper ¶
How many weeks from the end of the month dt is, starting from 1.
Source code in vobjectx/ical/ical_helper.py
Convert a contentline's value into a date or date-time.
A variety of clients don't serialize dates with the appropriate VALUE parameter, so rather than failing on these (technically invalid) lines, if allow_signature_mismatch is True, try to parse both varieties.
Source code in vobjectx/ical/ical_helper.py
icalendar ¶
Definitions and behavior for iCalendar, also known as vCalendar 2.0
Classes¶
TimezoneComponent ¶
Bases: Component
A VTIMEZONE object.
VTIMEZONEs are parsed by tz.tzical, the resulting dt.tzinfo subclass is stored in self.tzinfo, self.tzid stores the TZID associated with this timezone.
@ivar name: The uppercased name of the object, in this case always 'VTIMEZONE'. @ivar tzinfo: A dt.tzinfo subclass representing this timezone. @ivar tzid: The string used to refer to this timezone.
Source code in vobjectx/icalendar.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
classmethod
¶Register tzinfo if it's not already registered, return its tzid.
staticmethod
¶Given a tzinfo class, use known APIs to determine TZID, or use tzname.
Source code in vobjectx/icalendar.py
RecurringComponent ¶
Bases: Component
A vCalendar component like VEVENT or VTODO which may recur.
Any recurring component can have one or multiple RRULE, RDATE, EXRULE, or EXDATE lines, and one or zero DTSTART lines. It can also have a variety of children that don't have any recurrence information.
In the example below, note that dtstart is included in the rruleset. This is not the default behavior for dateutil's rrule implementation unless dtstart would already have been a member of the recurrence rule, and as a result, COUNT is wrong. This can be worked around when getting rruleset by adjusting count down by one if an rrule has a count and dtstart isn't in its result set, but by default, the rruleset property doesn't do this work around, to access it getrruleset must be called with addRDate set True.
@property rruleset: A U{rrulesethttps://moin.conectiva.com.br/DateUtil}.
Source code in vobjectx/icalendar.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | |
Get an rruleset created from self.
If addRDate is True, add an RDATE for dtstart if it's not included in an RRULE or RDATE, and count is decremented if it exists.
Note that for rules which don't match DTSTART, DTSTART may not appear in list(rruleset), although it should. By default, an RDATE is not created in these cases, and count isn't updated, so dateutil may list a spurious occurrence.
Source code in vobjectx/icalendar.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
TextBehavior ¶
Bases: Behavior
Provide backslash escape encoding/decoding for single valued properties.
TextBehavior also deals with base64 encoding if the ENCODING parameter is explicitly set to BASE64.
Source code in vobjectx/icalendar.py
classmethod
¶Remove backslash escaping from line.value.
Source code in vobjectx/icalendar.py
classmethod
¶Backslash escape line.value.
Source code in vobjectx/icalendar.py
RecurringBehavior ¶
Bases: VCalendarComponentBehavior
Parent Behavior for components which should be RecurringComponents.
Source code in vobjectx/icalendar.py
staticmethod
¶Turn a recurring Component into a RecurringComponent.
staticmethod
¶Generate a UID and DTSTAMP if one does not exist.
This is just a dummy implementation, for now.
Source code in vobjectx/icalendar.py
DateTimeBehavior ¶
Bases: Behavior
Parent Behavior for ContentLines containing one DATE-TIME.
Source code in vobjectx/icalendar.py
staticmethod
¶Turn obj.value into a dt.
RFC2445 allows times without time zone information, "floating times" in some properties. Mostly, this isn't what you want, but when parsing a file, real floating times are noted by setting to 'TRUE' the X-VOBJ-FLOATINGTIME-ALLOWED parameter.
Source code in vobjectx/icalendar.py
classmethod
¶Replace the datetime in obj.value with an ISO 8601 string.
Source code in vobjectx/icalendar.py
UTCDateTimeBehavior ¶
DateOrDateTimeBehavior ¶
Bases: Behavior
Parent Behavior for ContentLines containing one DATE or DATE-TIME.
Source code in vobjectx/icalendar.py
staticmethod
¶Turn obj.value into a date or dt.
Source code in vobjectx/icalendar.py
staticmethod
¶Replace the date or datetime in obj.value with an ISO 8601 string.
Source code in vobjectx/icalendar.py
MultiDateBehavior ¶
Bases: Behavior
Parent Behavior for ContentLines containing one or more DATE, DATE-TIME, or PERIOD.
Source code in vobjectx/icalendar.py
staticmethod
¶Turn obj.value into a list of dates, datetimes, or (datetime, timedelta) tuples.
Source code in vobjectx/icalendar.py
staticmethod
¶Replace the date, datetime or period tuples in obj.value with appropriate strings.
Source code in vobjectx/icalendar.py
MultiTextBehavior ¶
Bases: Behavior
Provide backslash escape encoding/decoding of each of several values.
After transformation, value is a list of strings.
Source code in vobjectx/icalendar.py
VCalendar2 ¶
Bases: VCalendarComponentBehavior
vCalendar 2.0 behavior. With added VAVAILABILITY support.
Source code in vobjectx/icalendar.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | |
classmethod
¶Create PRODID, VERSION and VTIMEZONEs if needed.
VTIMEZONEs will need to exist whenever TZID parameters exist or when datetimes with tzinfo exist.
Source code in vobjectx/icalendar.py
classmethod
¶Set implicit parameters, do encoding, return unicode string.
If validate is True, raise VObjectError if the line doesn't validate after implicit parameters are generated.
Default is to call base.default_serialize.
Source code in vobjectx/icalendar.py
VTimezone ¶
Bases: VCalendarComponentBehavior
Timezone behavior.
Source code in vobjectx/icalendar.py
TZID ¶
Bases: Behavior
Don't use TextBehavior for TZID.
RFC2445 only allows TZID lines to be paramtext, so they shouldn't need any encoding or decoding. Unfortunately, some Microsoft products use commas in TZIDs which should NOT be treated as a multi-valued text property, nor do we want to escape them. Leaving them alone works for Microsoft's breakage, and doesn't affect compliant iCalendar streams.
Source code in vobjectx/icalendar.py
VEvent ¶
Bases: RecurringBehavior
Event behavior.
Source code in vobjectx/icalendar.py
VTodo ¶
Bases: RecurringBehavior
To-do behavior.
Source code in vobjectx/icalendar.py
VJournal ¶
Bases: RecurringBehavior
Journal entry behavior.
Source code in vobjectx/icalendar.py
VFreeBusy ¶
Bases: VCalendarComponentBehavior
Free/busy state behavior.
Source code in vobjectx/icalendar.py
VAlarm ¶
Bases: VCalendarComponentBehavior
Alarm behavior
Source code in vobjectx/icalendar.py
VAvailability ¶
Bases: VCalendarComponentBehavior
Availability state behavior.
Used to represent user's available time slots.
Source code in vobjectx/icalendar.py
Available ¶
Bases: RecurringBehavior
Event behavior.
Source code in vobjectx/icalendar.py
Duration ¶
Bases: Behavior
Behavior for Duration ContentLines. Transform to dt.timedelta.
Source code in vobjectx/icalendar.py
Trigger ¶
Bases: Behavior
DATE-TIME or DURATION
Source code in vobjectx/icalendar.py
staticmethod
¶Turn obj.value into a timedelta or dt.
Source code in vobjectx/icalendar.py
PeriodBehavior ¶
Bases: Behavior
A list of (date-time, timedelta) tuples.
Source code in vobjectx/icalendar.py
staticmethod
¶Convert comma separated periods into tuples.
Source code in vobjectx/icalendar.py
classmethod
¶Convert the list of tuples in obj.value to strings.
Source code in vobjectx/icalendar.py
FreeBusy ¶
RRule ¶
Bases: Behavior
Dummy behavior to avoid having RRULEs being treated as text lines (and thus having semi-colons inaccurately escaped).
Source code in vobjectx/icalendar.py
Functions¶
ics_diff ¶
Compares VTODOs and VEVENTs in two iCalendar sources.
Classes¶
Functions¶
delete_extraneous ¶
Recursively walk the component's children, deleting extraneous details like X-VOBJ-ORIGINAL-TZID.
Source code in vobjectx/ics_diff.py
diff ¶
Take two VCALENDAR components, compare VEVENTs and VTODOs in them, return a list of object pairs containing just UID and the bits that didn't match, using None for objects that weren't present in one version or the other.
When there are multiple ContentLines in one VEVENT, for instance many DESCRIPTION lines, such lines original order is assumed to be meaningful. Order is also preserved when comparing (the unlikely case of) multiple parameters of the same type in a ContentLine
Source code in vobjectx/ics_diff.py
registry ¶
Classes¶
BehaviorRegistry ¶
Source code in vobjectx/registry.py
classmethod
¶Return a matching behavior if it exists, or None.
If id is None, return the default for name.
Source code in vobjectx/registry.py
classmethod
¶Register the given behavior.
If default is True (or if this is the first version registered with this name), the version will be the default if no id is given.
Source code in vobjectx/registry.py
TzidRegistry ¶
TZID registry for iCalendar timezone handling.
A registry for mapping timezone identifiers (TZIDs) to tzinfo objects, with automatic fallback to zoneinfo for unknown timezones.
Source code in vobjectx/registry.py
classmethod
¶classmethod
¶Register a new tzid to tzinfo mapping.
Source code in vobjectx/registry.py
classmethod
¶Functions¶
to_unicode ¶
Converts a string argument to a unicode string.
If the argument is already a unicode string, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8.
Source code in vobjectx/registry.py
vcard ¶
Definitions and behavior for vCard 3.0
Classes¶
Name ¶
Source code in vobjectx/vcard.py
Address ¶
Source code in vobjectx/vcard.py
VCardTextBehavior ¶
Bases: Behavior
Provide backslash escape encoding/decoding for single valued properties.
TextBehavior also deals with base64 encoding if the ENCODING parameter is explicitly set to BASE64.
Source code in vobjectx/vcard.py
classmethod
¶Remove backslash escaping from line.value_decode line, either to remove backslash escaping, or to decode base64 encoding. The content line should contain a ENCODING=b for base64 encoding, but Apple Addressbook seems to export a singleton parameter of 'BASE64', which does not match the 3.0 vCard spec. If we encounter that, then we transform the parameter to ENCODING=b
Source code in vobjectx/vcard.py
classmethod
¶Backslash escape line.value.
Source code in vobjectx/vcard.py
VCard3 ¶
Bases: VCardBehavior
vCard 3.0 behavior.
Source code in vobjectx/vcard.py
classmethod
¶Create PRODID, VERSION, and VTIMEZONEs if needed.
VTIMEZONEs will need to exist whenever TZID parameters exist or when datetimes with tzinfo exist.
Source code in vobjectx/vcard.py
Photo ¶
Bases: VCardTextBehavior
Source code in vobjectx/vcard.py
classmethod
¶Apple's Address Book is really weird with images, it expects base64 data to have very specific whitespace. It seems Address Book can handle PHOTO if it's not wrapped, so don't wrap it.
Source code in vobjectx/vcard.py
NameBehavior ¶
Bases: VCardBehavior
A structured name.
Source code in vobjectx/vcard.py
AddressBehavior ¶
Bases: VCardBehavior
A structured address.
Source code in vobjectx/vcard.py
OrgBehavior ¶
Bases: VCardBehavior
A list of organization values and sub-organization values.
Source code in vobjectx/vcard.py
Functions¶
split_fields ¶
Return a list of strings or lists from a Name or Address.
Source code in vobjectx/vcard.py
serialize_fields ¶
Turn an object's fields into a ';' and ',' separated string.
If order is None, obj should be a list, backslash escape each field and return a ';' separated string.
Source code in vobjectx/vcard.py
Module: vobjectx.base¶
vobjectx.base ¶
vobjectx module for reading vCard and vCalendar files.
Classes¶
VBase ¶
Base class for ContentLine and Component.
@ivar behavior: The Behavior class associated with this object, which controls validation, transformations, and encoding. @ivar parent_behavior: The object's parent's behavior, or None if no behaviored parent exists. @ivar is_native: Boolean describing whether this component is a Native instance. @ivar group: An optional group prefix, should be used only to indicate sort order in vCards, according to spec.
Current spec: 4.0 (http://tools.ietf.org/html/rfc6350)
Source code in vobjectx/base.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
Functions¶
validate ¶
get_children ¶
clear_behavior ¶
auto_behavior ¶
Set behavior if name is in self.parent_behavior.known_children.
If cascade is True, unset behavior and parent_behavior for all descendants, then recalculate behavior and parent_behavior.
Source code in vobjectx/base.py
set_behavior ¶
Set behavior. If cascade is True, auto_behavior all descendants.
Source code in vobjectx/base.py
transform_to_native ¶
Transform this object into a custom VBase subclass.
transform_to_native should always return a representation of this object. It may do so by modifying self in place then returning self, or by creating a new object.
Source code in vobjectx/base.py
transform_from_native ¶
Return self transformed into a ContentLine or Component if needed.
May have side effects. If it does, transform_from_native and transform_to_native MUST have perfectly inverse side effects. Allowing such side effects is convenient for objects whose transformations only change a few attributes.
Note that it isn't always possible for transform_from_native to be a perfect inverse of transform_to_native, in such cases transform_from_native should return a new object, not self after modifications.
Source code in vobjectx/base.py
transform_children_to_native ¶
transform_children_from_native ¶
serialize ¶
Serialize to buf if it exists, otherwise return a string.
Use self.behavior.serialize if behavior exists.
Source code in vobjectx/base.py
ContentLine ¶
Bases: VBase
Holds one content line for formats like vCard and vCalendar.
For example::
@ivar name: The uppercased name of the contentline. @ivar params: A dictionary of parameters and associated lists of values. Singleton params (e.g., WORK, CELL in vCard 2.1) are stored with an empty list as the value. @ivar value: The value of the contentline. @ivar encoded: A boolean describing whether the data in the content line is encoded. Generally, text read from a serialized vCard or vCalendar should be considered encoded. Data added programmatically should not be encoded. @ivar line_number: An optional line number associated with the contentline.
Source code in vobjectx/base.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
Component ¶
Bases: VBase
A complex property that can contain multiple ContentLines.
For our purposes, a component must start with a BEGIN:xxxx line and end with END:xxxx, or have a PROFILE:xxx line if a top-level component.
@ivar contents: A dictionary of lists of Component or ContentLine instances. The keys are the lowercased names of child ContentLines or Components. Note that BEGIN and END ContentLines are not included in contents. @ivar name: Uppercase string used to represent this Component, i.e VCARD if the serialized object starts with BEGIN:VCARD. @ivar use_begin: A boolean flag determining whether BEGIN: and END: lines should be serialized.
Source code in vobjectx/base.py
397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
Functions¶
set_profile ¶
Assign a PROFILE to this unnamed component.
Used by vCard, not by vCalendar.
Source code in vobjectx/base.py
get_child_value ¶
Return a child's value (the first, by default), or None.
add ¶
Add obj_or_name to contents, set behavior if it can be inferred.
If obj_or_name is a string, create an empty component or line based on behavior. If no behavior is found for the object, add a ContentLine.
group is an optional prefix to the name of the object (see RFC 2425).
Source code in vobjectx/base.py
remove ¶
Remove obj from contents.
get_children ¶
components ¶
lines ¶
set_behavior_from_version_line ¶
Set behavior if one matches name, version_line.value.
Source code in vobjectx/base.py
transform_children_to_native ¶
Recursively replace children with their native representation.
Sort to get dependency order right, like vtimezone before vevent.
Source code in vobjectx/base.py
transform_children_from_native ¶
Recursively transform native children to vanilla representations.
Source code in vobjectx/base.py
Functions¶
parse_params ¶
Parse parameters
Source code in vobjectx/base.py
parse_line ¶
Parse line
Source code in vobjectx/base.py
get_logical_lines ¶
Iterate through a stream, yielding one logical line at a time.
Because many applications still use vCard 2.1, we have to deal with the quoted-printable encoding for long lines, as well as the vCard 3.0 and vCalendar line folding technique, a whitespace character at the start of the line.
Quoted-printable data will be decoded in the Behavior decoding phase.
Source code in vobjectx/base.py
dquote_escape ¶
Return param, or "param" if ',' or ';' or ':' is in param.
Source code in vobjectx/base.py
fold_one_line ¶
Folding line procedure that ensures multi-byte utf-8 sequences are not broken across lines
Source code in vobjectx/base.py
default_serialize ¶
Encode and fold obj and its children, write to buf or return a string.
Source code in vobjectx/base.py
read_components ¶
read_components(stream_or_string, validate=False, transform=True, ignore_unreadable=False, allow_qp=False)
Generate one Component at a time from a stream.
Source code in vobjectx/base.py
read_one ¶
Return the first component from stream.
Module: vobjectx.behavior¶
vobjectx.behavior ¶
Classes¶
Behavior ¶
Behavior (validation, encoding, and transformations) for vobjects.
Abstract class to describe vobjectx options, requirements and encodings.
Behaviors are used for root components like VCALENDAR, for subcomponents like VEVENT, and for individual lines in components.
Behavior subclasses are not meant to be instantiated, all methods should be classmethods.
@cvar name: The uppercase name of the object described by the class, or a generic name if the class defines behavior for many objects. @cvar description: A brief excerpt from the RFC explaining the function of the component or line. @cvar version_string: The string associated with the component, for instance, 2.0 if there's a line like VERSION:2.0, an empty string otherwise. @cvar known_children: A dictionary with uppercased component/property names as keys and a tuple (min, max, id) as value, where id is the id used by L{register_behavior}, min and max are the limits on how many of this child must occur. None is used to denote no max or no id. @cvar quoted_printable: A boolean describing whether the object should be encoded and decoded using quoted printable line folding and character escaping. @cvar default_behavior: Behavior to apply to ContentLine children when no behavior is found. @cvar has_native: A boolean describing whether the object can be transformed into a more Pythonic object. @cvar is_component: A boolean, True if the object should be a Component. @cvar sort_first: The lower-case list of children which should come first when sorting. @cvar allow_group: Whether or not vCard style group prefixes are allowed.
Source code in vobjectx/behavior.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
Functions¶
validate
classmethod
¶
Check if the object satisfies this behavior's requirements.
@param obj:
The L{ContentLine
Source code in vobjectx/behavior.py
transform_to_native
staticmethod
¶
Turn a ContentLine or Component into a Python-native representation.
If appropriate, turn dates or datetime strings into Python objects. Components containing VTIMEZONEs turn into VtimezoneComponents.
Source code in vobjectx/behavior.py
transform_from_native
staticmethod
¶
generate_implicit_parameters
staticmethod
¶
serialize
classmethod
¶
Set implicit parameters, do encoding, return unicode string.
If validate is True, raise VObjectError if the line doesn't validate after implicit parameters are generated.
Default is to call base.default_serialize.
Source code in vobjectx/behavior.py
Functions¶
new_from_behavior ¶
Given a name, return a behaviored ContentLine or Component.
Source code in vobjectx/behavior.py
Module: vobjectx.custom_class¶
vobjectx.custom_class ¶
Module: vobjectx.exceptions¶
vobjectx.exceptions ¶
Module: vobjectx.patterns¶
vobjectx.patterns ¶
Module: vobjectx.registry¶
vobjectx.registry ¶
Classes¶
BehaviorRegistry ¶
Source code in vobjectx/registry.py
Functions¶
get
classmethod
¶
Return a matching behavior if it exists, or None.
If id is None, return the default for name.
Source code in vobjectx/registry.py
register
classmethod
¶
Register the given behavior.
If default is True (or if this is the first version registered with this name), the version will be the default if no id is given.
Source code in vobjectx/registry.py
TzidRegistry ¶
TZID registry for iCalendar timezone handling.
A registry for mapping timezone identifiers (TZIDs) to tzinfo objects, with automatic fallback to zoneinfo for unknown timezones.
Source code in vobjectx/registry.py
Functions¶
get
classmethod
¶
register
classmethod
¶
Register a new tzid to tzinfo mapping.
Source code in vobjectx/registry.py
unregister
classmethod
¶
Functions¶
to_unicode ¶
Converts a string argument to a unicode string.
If the argument is already a unicode string, it is returned unchanged. Otherwise it must be a byte string and is decoded as utf8.
Source code in vobjectx/registry.py
Module: vobjectx.hcalendar¶
vobjectx.hcalendar ¶
A microformat for serializing iCalendar data
(http://microformats.org/wiki/hcalendar)
Here is a sample event in an iCalendar:
BEGIN:VCALENDAR PRODID:-//XYZproduct//EN VERSION:2.0 BEGIN:VEVENT URL:http://www.web2con.com/ DTSTART:20051005 DTEND:20051008 SUMMARY:Web 2.0 Conference LOCATION:Argent Hotel\, San Francisco\, CA END:VEVENT END:VCALENDAR
and an equivalent event in hCalendar format with various elements optimized appropriately.
Web 2.0 Conference: October 5- 7, at the Argent Hotel, San Francisco, CA
Classes¶
HCalendar ¶
Bases: VCalendar2_0
Source code in vobjectx/hcalendar.py
Functions¶
serialize
classmethod
¶
Serialize iCalendar to HTML using the hCalendar microformat (http://microformats.org/wiki/hcalendar)
Source code in vobjectx/hcalendar.py
Module: vobjectx.icalendar¶
vobjectx.icalendar ¶
Definitions and behavior for iCalendar, also known as vCalendar 2.0
Classes¶
TimezoneComponent ¶
Bases: Component
A VTIMEZONE object.
VTIMEZONEs are parsed by tz.tzical, the resulting dt.tzinfo subclass is stored in self.tzinfo, self.tzid stores the TZID associated with this timezone.
@ivar name: The uppercased name of the object, in this case always 'VTIMEZONE'. @ivar tzinfo: A dt.tzinfo subclass representing this timezone. @ivar tzid: The string used to refer to this timezone.
Source code in vobjectx/icalendar.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
Functions¶
register_tzinfo
classmethod
¶
Register tzinfo if it's not already registered, return its tzid.
pick_tzid
staticmethod
¶
Given a tzinfo class, use known APIs to determine TZID, or use tzname.
Source code in vobjectx/icalendar.py
RecurringComponent ¶
Bases: Component
A vCalendar component like VEVENT or VTODO which may recur.
Any recurring component can have one or multiple RRULE, RDATE, EXRULE, or EXDATE lines, and one or zero DTSTART lines. It can also have a variety of children that don't have any recurrence information.
In the example below, note that dtstart is included in the rruleset. This is not the default behavior for dateutil's rrule implementation unless dtstart would already have been a member of the recurrence rule, and as a result, COUNT is wrong. This can be worked around when getting rruleset by adjusting count down by one if an rrule has a count and dtstart isn't in its result set, but by default, the rruleset property doesn't do this work around, to access it getrruleset must be called with addRDate set True.
@property rruleset: A U{rrulesethttps://moin.conectiva.com.br/DateUtil}.
Source code in vobjectx/icalendar.py
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 | |
Functions¶
getrruleset ¶
Get an rruleset created from self.
If addRDate is True, add an RDATE for dtstart if it's not included in an RRULE or RDATE, and count is decremented if it exists.
Note that for rules which don't match DTSTART, DTSTART may not appear in list(rruleset), although it should. By default, an RDATE is not created in these cases, and count isn't updated, so dateutil may list a spurious occurrence.
Source code in vobjectx/icalendar.py
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | |
TextBehavior ¶
Bases: Behavior
Provide backslash escape encoding/decoding for single valued properties.
TextBehavior also deals with base64 encoding if the ENCODING parameter is explicitly set to BASE64.
Source code in vobjectx/icalendar.py
Functions¶
decode
classmethod
¶
Remove backslash escaping from line.value.
Source code in vobjectx/icalendar.py
encode
classmethod
¶
Backslash escape line.value.
Source code in vobjectx/icalendar.py
RecurringBehavior ¶
Bases: VCalendarComponentBehavior
Parent Behavior for components which should be RecurringComponents.
Source code in vobjectx/icalendar.py
Functions¶
transform_to_native
staticmethod
¶
Turn a recurring Component into a RecurringComponent.
generate_implicit_parameters
staticmethod
¶
Generate a UID and DTSTAMP if one does not exist.
This is just a dummy implementation, for now.
Source code in vobjectx/icalendar.py
DateTimeBehavior ¶
Bases: Behavior
Parent Behavior for ContentLines containing one DATE-TIME.
Source code in vobjectx/icalendar.py
Functions¶
transform_to_native
staticmethod
¶
Turn obj.value into a dt.
RFC2445 allows times without time zone information, "floating times" in some properties. Mostly, this isn't what you want, but when parsing a file, real floating times are noted by setting to 'TRUE' the X-VOBJ-FLOATINGTIME-ALLOWED parameter.
Source code in vobjectx/icalendar.py
transform_from_native
classmethod
¶
Replace the datetime in obj.value with an ISO 8601 string.
Source code in vobjectx/icalendar.py
UTCDateTimeBehavior ¶
DateOrDateTimeBehavior ¶
Bases: Behavior
Parent Behavior for ContentLines containing one DATE or DATE-TIME.
Source code in vobjectx/icalendar.py
Functions¶
transform_to_native
staticmethod
¶
Turn obj.value into a date or dt.
Source code in vobjectx/icalendar.py
transform_from_native
staticmethod
¶
Replace the date or datetime in obj.value with an ISO 8601 string.
Source code in vobjectx/icalendar.py
MultiDateBehavior ¶
Bases: Behavior
Parent Behavior for ContentLines containing one or more DATE, DATE-TIME, or PERIOD.
Source code in vobjectx/icalendar.py
Functions¶
transform_to_native
staticmethod
¶
Turn obj.value into a list of dates, datetimes, or (datetime, timedelta) tuples.
Source code in vobjectx/icalendar.py
transform_from_native
staticmethod
¶
Replace the date, datetime or period tuples in obj.value with appropriate strings.
Source code in vobjectx/icalendar.py
MultiTextBehavior ¶
Bases: Behavior
Provide backslash escape encoding/decoding of each of several values.
After transformation, value is a list of strings.
Source code in vobjectx/icalendar.py
VCalendar2 ¶
Bases: VCalendarComponentBehavior
vCalendar 2.0 behavior. With added VAVAILABILITY support.
Source code in vobjectx/icalendar.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 | |
Functions¶
generate_implicit_parameters
classmethod
¶
Create PRODID, VERSION and VTIMEZONEs if needed.
VTIMEZONEs will need to exist whenever TZID parameters exist or when datetimes with tzinfo exist.
Source code in vobjectx/icalendar.py
serialize
classmethod
¶
Set implicit parameters, do encoding, return unicode string.
If validate is True, raise VObjectError if the line doesn't validate after implicit parameters are generated.
Default is to call base.default_serialize.
Source code in vobjectx/icalendar.py
VTimezone ¶
Bases: VCalendarComponentBehavior
Timezone behavior.
Source code in vobjectx/icalendar.py
TZID ¶
Bases: Behavior
Don't use TextBehavior for TZID.
RFC2445 only allows TZID lines to be paramtext, so they shouldn't need any encoding or decoding. Unfortunately, some Microsoft products use commas in TZIDs which should NOT be treated as a multi-valued text property, nor do we want to escape them. Leaving them alone works for Microsoft's breakage, and doesn't affect compliant iCalendar streams.
Source code in vobjectx/icalendar.py
VEvent ¶
Bases: RecurringBehavior
Event behavior.
Source code in vobjectx/icalendar.py
VTodo ¶
Bases: RecurringBehavior
To-do behavior.
Source code in vobjectx/icalendar.py
VJournal ¶
Bases: RecurringBehavior
Journal entry behavior.
Source code in vobjectx/icalendar.py
VFreeBusy ¶
Bases: VCalendarComponentBehavior
Free/busy state behavior.
Source code in vobjectx/icalendar.py
VAlarm ¶
Bases: VCalendarComponentBehavior
Alarm behavior
Source code in vobjectx/icalendar.py
VAvailability ¶
Bases: VCalendarComponentBehavior
Availability state behavior.
Used to represent user's available time slots.
Source code in vobjectx/icalendar.py
Available ¶
Bases: RecurringBehavior
Event behavior.
Source code in vobjectx/icalendar.py
Duration ¶
Bases: Behavior
Behavior for Duration ContentLines. Transform to dt.timedelta.
Source code in vobjectx/icalendar.py
Trigger ¶
Bases: Behavior
DATE-TIME or DURATION
Source code in vobjectx/icalendar.py
Functions¶
transform_to_native
staticmethod
¶
Turn obj.value into a timedelta or dt.
Source code in vobjectx/icalendar.py
PeriodBehavior ¶
Bases: Behavior
A list of (date-time, timedelta) tuples.
Source code in vobjectx/icalendar.py
Functions¶
transform_to_native
staticmethod
¶
Convert comma separated periods into tuples.
Source code in vobjectx/icalendar.py
transform_from_native
classmethod
¶
Convert the list of tuples in obj.value to strings.
Source code in vobjectx/icalendar.py
FreeBusy ¶
RRule ¶
Bases: Behavior
Dummy behavior to avoid having RRULEs being treated as text lines (and thus having semi-colons inaccurately escaped).
Source code in vobjectx/icalendar.py
Functions¶
Module: vobjectx.vcard¶
vobjectx.vcard ¶
Definitions and behavior for vCard 3.0
Classes¶
Name ¶
Source code in vobjectx/vcard.py
Address ¶
Source code in vobjectx/vcard.py
VCardTextBehavior ¶
Bases: Behavior
Provide backslash escape encoding/decoding for single valued properties.
TextBehavior also deals with base64 encoding if the ENCODING parameter is explicitly set to BASE64.
Source code in vobjectx/vcard.py
Functions¶
decode
classmethod
¶
Remove backslash escaping from line.value_decode line, either to remove backslash escaping, or to decode base64 encoding. The content line should contain a ENCODING=b for base64 encoding, but Apple Addressbook seems to export a singleton parameter of 'BASE64', which does not match the 3.0 vCard spec. If we encounter that, then we transform the parameter to ENCODING=b
Source code in vobjectx/vcard.py
encode
classmethod
¶
Backslash escape line.value.
Source code in vobjectx/vcard.py
VCard3 ¶
Bases: VCardBehavior
vCard 3.0 behavior.
Source code in vobjectx/vcard.py
Functions¶
generate_implicit_parameters
classmethod
¶
Create PRODID, VERSION, and VTIMEZONEs if needed.
VTIMEZONEs will need to exist whenever TZID parameters exist or when datetimes with tzinfo exist.
Source code in vobjectx/vcard.py
Photo ¶
Bases: VCardTextBehavior
Source code in vobjectx/vcard.py
Functions¶
serialize
classmethod
¶
Apple's Address Book is really weird with images, it expects base64 data to have very specific whitespace. It seems Address Book can handle PHOTO if it's not wrapped, so don't wrap it.
Source code in vobjectx/vcard.py
NameBehavior ¶
Bases: VCardBehavior
A structured name.
Source code in vobjectx/vcard.py
AddressBehavior ¶
Bases: VCardBehavior
A structured address.
Source code in vobjectx/vcard.py
OrgBehavior ¶
Bases: VCardBehavior
A list of organization values and sub-organization values.
Source code in vobjectx/vcard.py
Functions¶
split_fields ¶
Return a list of strings or lists from a Name or Address.
Source code in vobjectx/vcard.py
serialize_fields ¶
Turn an object's fields into a ';' and ',' separated string.
If order is None, obj should be a list, backslash escape each field and return a ';' separated string.