View Source Naiveical.Extractor (Naiveical v0.1.8)
This module allows the extraction of parts of a icalendar text.
Link to this section Summary
Functions
Extracts a specific attribute from a list of attributes.
Extract a single content line from an icalendar text split into tag, properties, and values. It returns a tuple with {tag-name, properties, value}
.
Extract a single date content line from an icalendar text. It returns a the datetime object.
Extract a single datetime content line from an icalendar text. It returns a the datetime object.
Extract a single datetime content line from an icalendar text. It returns a the datetime object.
Extract a raw single content line from an icalendar text.
Extract parts of an icalender text, such as all VALARMs. ## Examples
Remove sections of an icalender text, such as remove all VALARMs from a VEVENT.
Link to this section Functions
Extracts a specific attribute from a list of attributes.
Extract a single content line from an icalendar text split into tag, properties, and values. It returns a tuple with {tag-name, properties, value}
.
## Examples:
iex> Naiveical.Extractor.extract_contentline_by_tag("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nEND:YY\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "A") {"A","","aa"}
iex> Naiveical.Extractor.extract_contentline_by_tag("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nEND:YY\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "ZZZ") {"ZZZ","",nil}
Extract a single date content line from an icalendar text. It returns a the datetime object.
Basically, it tries to parse the extracted text as a date object
## Examples:
iex> Naiveical.Extractor.extract_date_contentline_by_tag!("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nDTSTART;TZID=Europe/Berlin:20210422\nEND:YY\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "DTSTART")
Extract a single datetime content line from an icalendar text. It returns a the datetime object.
Basically, it tries to parse the extracted text as a datetime object with the given timezone information
## Examples:
iex> Naiveical.Extractor.extract_datetime_contentline_by_tag("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nDTSTART;TZID=Europe/Berlin:20210422T150000\nEND:YY\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "DTSTART")
Extract a single datetime content line from an icalendar text. It returns a the datetime object.
Basically, it tries to parse the extracted text as a datetime object with the given timezone information
## Examples:
iex> Naiveical.Extractor.extract_datetime_contentline_by_tag!("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nDTSTART;TZID=Europe/Berlin:20210422T150000\nEND:YY\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "DTSTART")
Extract a raw single content line from an icalendar text.
## Examples:
iex> Naiveical.Extractor.extract_raw_contentline_by_tag("BEGIN:XX\nBEGIN:YY\nA;xx:aa\nB:bb\nEND:YY\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "A") "A;xx:aa"
iex> Naiveical.Extractor.extract_raw_contentline_by_tag("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nEND:YY\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "ZZZ") nil
Extract parts of an icalender text, such as all VALARMs. ## Examples:
iex> Naiveical.Extractor.extract_sections_by_tag("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nEND:YY\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "XX") ["BEGIN:XX\r\nBEGIN:YY\r\nA:aa\r\nB:bb\r\nEND:YY\r\nBEGIN:YY\r\nC:cc\r\nD:dd\r\nEND:YY\r\nEND:XX"]
iex> Naiveical.Extractor.extract_sections_by_tag("BEGIN:XX\r\nBEGIN:YY\r\nA:aa\r\nB:bb\r\nEND:YY\r\nBEGIN:YY\r\nC:cc\r\nD:dd\r\nEND:YY\r\nEND:XX", "YY") ["BEGIN:YY\r\nA:aa\r\nB:bb\r\nEND:YY", "BEGIN:YY\r\nC:cc\r\nD:dd\r\nEND:YY"]
Remove sections of an icalender text, such as remove all VALARMs from a VEVENT.
The reason of this is to allow the correct extraction of the content lines. If, for example, a VEVENT also contains a VALARM with a description, but the VEVENT does not contain a description, the function extract_contentline_by_tag would fetch the description of the VALARM instead of returning nil.
## Examples:
iex> Naiveical.Extractor.remove_sections_by_tag("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nEND:YY\nEND:XX", "YY") "BEGIN:XX\nEND:XX"
iex> Naiveical.Extractor.remove_sections_by_tag("BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nEND:YY\naaaa:bbbb\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX", "NOTEXIST") "BEGIN:XX\nBEGIN:YY\nA:aa\nB:bb\nEND:YY\naaaa:bbbb\nBEGIN:YY\nC:cc\nD:dd\nEND:YY\nEND:XX"