Commits

Felix Geller  committed c755c8b

Refactor: Extract query, should not be in `create_org_file'.

  • Participants
  • Parent commits e93ad3b

Comments (0)

Files changed (1)

 %s
 """
 
-def date_range_query(cal_client, 
+def date_range_query(cal_client,
                      max_results = 333, 
                      start_date = str(date.today() - timedelta(30)), 
                      end_date = str(date.today() + timedelta(30))):
   client.ClientLogin(login, authinfo_pw(login), client.source)
   return client
 
-def create_org_file(client, filename):
+def create_org_file(filename, events):
   org_file = open(filename, 'w')
   org_file.write(PREAMBLE % datetime.now())
-  for event in date_range_query(client):
+  for event in events:
     write_item(event, org_file)
   org_file.close()
 
         return update_event(client, event_id, fields)
       elif op == 'download':
         filename = sys.argv[3]
-        return create_org_file(client, filename)
+        events = date_range_query(client)
+        return create_org_file(filename, events)
       else: raise Usage('Operation "%s" not supported.' % op)
 
   except Usage, err: