import logging
import time
import datetime
import calendar
import pyfaceb

from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
from django.db.models import Q
from django.conf import settings
from social.models import Feed
from social.utils import FeedUpdater, UpdateError

class Command(BaseCommand):
    help = "Update social media feeds"
    option_list = BaseCommand.option_list + (
        make_option('--cached', action='store_true', dest='cached', default=False,
            help='Use local cache for HTTP requests'),
        make_option('--type', action='store', dest='type', help='Types of feed to update'),
        make_option('--feed-id', action='store', dest='feed_id', help='Update only single feed'),
    )

    def handle(self, *args, **options):
        self.logger = logging.getLogger(__name__)
        if options['cached']:
            import requests_cache
            requests_cache.install_cache("update-social")
        self.updater = FeedUpdater(self.logger)
        update_opts = {}
        if 'type' in options and options['type']:
            update_opts['type'] = options['type'].split(',')
        update_opts['feed_id'] = options.get('feed_id', None)
        self.updater.update_feeds(**update_opts)

@@ -52,16 +52,18 @@
 alendar%0A
+##
 import p
@@ -69,16 +69,16 @@
 pyfaceb%0A
-
 %0Afrom op
@@ -390,81 +390,97 @@
     
-option_list = BaseCommand.option_list + (%0A        make_option('--cached',
+%0A    def add_arguments(self, parser):%0A        parser.add_argument('--cached',%0A           
  act
@@ -496,16 +496,28 @@
 e_true',
+%0A           
  dest='c
@@ -523,16 +523,28 @@
 cached',
+%0A           
  default
@@ -604,17 +604,16 @@
 quests')
-,
 %0A       
@@ -617,29 +617,49 @@
     
-make_option('--type',
+parser.add_argument('--type',%0A           
  act
@@ -666,24 +666,36 @@
 ion='store',
+%0A           
  dest='type'
@@ -695,16 +695,28 @@
 ='type',
+%0A           
  help='T
@@ -739,17 +739,16 @@
 update')
-,
 %0A       
@@ -748,27 +748,35 @@
         
-make_option
+parser.add_argument
 ('--feed
@@ -780,16 +780,28 @@
 eed-id',
+%0A           
  action=
@@ -808,16 +808,28 @@
 'store',
+%0A           
  dest='f
@@ -836,16 +836,28 @@
 eed_id',
+%0A           
  help='U
@@ -884,15 +884,8 @@
 ed')
-,%0A    )
 %0A%0A  

Update update_social