|
@@ -39,9 +39,10 @@ We use each library for a purpose:
|
|
#+Name: MiscVars
|
|
#+Name: MiscVars
|
|
#+BEGIN_SRC python
|
|
#+BEGIN_SRC python
|
|
data = {}
|
|
data = {}
|
|
|
|
+ messagedata = {}
|
|
agendafile = '~/org/emailagenda.org'
|
|
agendafile = '~/org/emailagenda.org'
|
|
level = 1
|
|
level = 1
|
|
- type = 'inactive'
|
|
|
|
|
|
+ datetype = 'inactive'
|
|
if os.environ['EMAILTOAGENDAFILE']:
|
|
if os.environ['EMAILTOAGENDAFILE']:
|
|
agendafile = os.environ['EMAILTOAGENDAFILE']
|
|
agendafile = os.environ['EMAILTOAGENDAFILE']
|
|
|
|
|
|
@@ -50,7 +51,7 @@ We use each library for a purpose:
|
|
- data :: a dictionary used to store data for output
|
|
- data :: a dictionary used to store data for output
|
|
- agendafile :: this is set by default to =~/org/emailagenda.org=. if the environment variable =EMAILTOAGENDAFILE= is defined that is used
|
|
- agendafile :: this is set by default to =~/org/emailagenda.org=. if the environment variable =EMAILTOAGENDAFILE= is defined that is used
|
|
- level :: this is the level you want the heading to be, defaults to level 1, the top.
|
|
- level :: this is the level you want the heading to be, defaults to level 1, the top.
|
|
- - type :: this is the type of timestamp to be generated, either =active= or =inactive=, defaults to =inactive=.
|
|
|
|
|
|
+ - datetype :: this is the type of timestamp to be generated, either =active= or =inactive=, defaults to =inactive=.
|
|
** Subroutines
|
|
** Subroutines
|
|
#+Name: Subroutines
|
|
#+Name: Subroutines
|
|
#+BEGIN_SRC python
|
|
#+BEGIN_SRC python
|
|
@@ -65,20 +66,38 @@ We use each library for a purpose:
|
|
#+Name: Output
|
|
#+Name: Output
|
|
#+BEGIN_SRC python
|
|
#+BEGIN_SRC python
|
|
def output(datadict, outputfile):
|
|
def output(datadict, outputfile):
|
|
- ...
|
|
|
|
|
|
+ headingstart = '*' * level
|
|
|
|
+ date = datadict['date']
|
|
|
|
+ person = datadict['person']
|
|
|
|
+ subject = datadict['subject']
|
|
|
|
+ notes = datadict['notes']
|
|
|
|
+ if datetype == 'inactive':
|
|
|
|
+ fdate = '[%s]' % date
|
|
|
|
+ elif datetype == 'active':
|
|
|
|
+ fdate = '<%s>' % date
|
|
|
|
+ else:
|
|
|
|
+ fdate = '[%s]' % date
|
|
|
|
+
|
|
|
|
+ header = '\n{1} {2} {3}, {4}\n{5}\n' % (headingstart, date, person, subject, notes)
|
|
|
|
+ outputfile.write(header)
|
|
#+END_SRC
|
|
#+END_SRC
|
|
#+CAPTION: use-name-as-caption
|
|
#+CAPTION: use-name-as-caption
|
|
*** TODO Determine Type
|
|
*** TODO Determine Type
|
|
#+Name: DetermineType
|
|
#+Name: DetermineType
|
|
#+BEGIN_SRC python
|
|
#+BEGIN_SRC python
|
|
def determineType(datadict):
|
|
def determineType(datadict):
|
|
- ...
|
|
|
|
|
|
+ if re.match('^SCHEDRQ: .*', datadict['subject']):
|
|
|
|
+ return 'schedrq'
|
|
|
|
+ elif re.match('^Invitation: .*', datadict['subject']):
|
|
|
|
+ return 'gcal'
|
|
|
|
+ else:
|
|
|
|
+ return 'unknown'
|
|
#+END_SRC
|
|
#+END_SRC
|
|
#+CAPTION: use-name-as-caption
|
|
#+CAPTION: use-name-as-caption
|
|
-*** TODO Parse subject
|
|
|
|
|
|
+*** TODO Message Muncher
|
|
#+Name: ParseSubject
|
|
#+Name: ParseSubject
|
|
#+BEGIN_SRC python
|
|
#+BEGIN_SRC python
|
|
- def parseSubject(datadict):
|
|
|
|
|
|
+ def munchMessage(datadict):
|
|
...
|
|
...
|
|
#+END_SRC
|
|
#+END_SRC
|
|
#+CAPTION: use-name-as-caption
|
|
#+CAPTION: use-name-as-caption
|
|
@@ -91,7 +110,7 @@ We use each library for a purpose:
|
|
data = parsemail.parsestr(message)
|
|
data = parsemail.parsestr(message)
|
|
|
|
|
|
data['type'] = determineType(data)
|
|
data['type'] = determineType(data)
|
|
- data['parsedsubject'] = parseSubject(data)
|
|
|
|
|
|
+ messagedata = munchMessage(data)
|
|
|
|
|
|
ofile = open(agendafile, 'a')
|
|
ofile = open(agendafile, 'a')
|
|
output(data, ofile)
|
|
output(data, ofile)
|