Summarize data

Please, check my code!
I forgot to include some kind of readme.st. To test custom command:
python manage.py summarize [date YYYY-MM-DD] [--nodeletion]
If you pass no parameters it summarizes current date minus 15 days (single day and no a 15-days period)
But as Fidel suggested, we've thought in raising an exception instead of
returning a boolean value:
try:
    datetime.strptime(string_date, format_string)
        output = True
    except ValueError:
        raise CommandError('Date should have the right format YYYY-MM-DD')
    return output

On Fri, Oct 10, 2014 at 7:36 PM, Alejandro Garcia <
alejandro.garcia@redbeacon.com> wrote:

> I agree. Is clearer this way.
>
> On Fri, Oct 10, 2014 at 12:33 PM, Huseyin Yilmaz <notifications@github.com
> > wrote:
>
>> In okapiweb/management/commands/summarize.py:
>>
>> > +        make_option('--nodelete',
>> > +                    action='store_true',
>> > +                    dest='nodelete',
>> > +                    default=False,
>> > +                    help='Preserve processed data'),
>> > +    )
>> > +
>> > +    def check_date(self, processed_date="", format_string=DEFAULT_DATE_FORMAT):
>> > +        """Helper to check if a date is valid"""
>> > +
>> > +        output = True
>> > +        try:
>> > +            datetime.strptime(processed_date, format_string)
>> > +        except ValueError:
>> > +            output = False
>> > +        return output
>>
>> How about this
>>
>>         try:
>>             datetime.strptime(processed_date, format_string)
>>             output = True
>>         except ValueError:
>>             output = False
>>         return output
>>
>> It more clearly shows two branches and how output value is changing in
>> each branch.
>>
>> —
>> Reply to this email directly or view it on GitHub
>> <https://github.com/redbeacon/okapi-web/pull/23/files#r18698454>.
>>
>
>
>
> --
> Alejandro Garcia
> Software Engineer at RedBeacon.com
>



-- 
Alejandro Garcia
Software Engineer at RedBeacon.com