Browse Source

added determineType, output

Sam Flint 10 years ago
parent
commit
0da243ff05
1 changed files with 26 additions and 7 deletions
  1. 26 7
      email2orgsched.org

+ 26 - 7
email2orgsched.org

@@ -39,9 +39,10 @@ We use each library for a purpose:
 #+Name: MiscVars
 #+BEGIN_SRC python
   data = {}
+  messagedata = {}
   agendafile = '~/org/emailagenda.org'
   level = 1
-  type = 'inactive'
+  datetype = 'inactive'
   if 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
  - 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.
- - 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
 #+Name: Subroutines
 #+BEGIN_SRC python
@@ -65,20 +66,38 @@ We use each library for a purpose:
 #+Name: Output
 #+BEGIN_SRC python
   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
 #+CAPTION: use-name-as-caption
 *** TODO Determine Type
 #+Name: DetermineType
 #+BEGIN_SRC python
   def determineType(datadict):
-     ...
+     if re.match('^SCHEDRQ: .*', datadict['subject']):
+        return 'schedrq'
+     elif re.match('^Invitation: .*', datadict['subject']):
+        return 'gcal'
+     else:
+        return 'unknown'
 #+END_SRC
 #+CAPTION: use-name-as-caption
-*** TODO Parse subject
+*** TODO Message Muncher
 #+Name: ParseSubject
 #+BEGIN_SRC python
-  def parseSubject(datadict):
+  def munchMessage(datadict):
      ...
 #+END_SRC
 #+CAPTION: use-name-as-caption
@@ -91,7 +110,7 @@ We use each library for a purpose:
   data = parsemail.parsestr(message)
   
   data['type'] = determineType(data)
-  data['parsedsubject'] = parseSubject(data)
+  messagedata = munchMessage(data)
   
   ofile = open(agendafile, 'a')
   output(data, ofile)