コード例 #1
0
ファイル: converters.py プロジェクト: pingali/ckan
def date_to_db(value, context):
    try:
        value = DateType.form_to_db(value)
    except DateConvertError, e:
        raise Invalid(str(e))
コード例 #2
0
ファイル: dataset_form.py プロジェクト: afjensen/ckanext-dgu
def date_to_db(value, context):
    try:
        value = DateType.form_to_db(value)
    except DateConvertError, e:
        raise Invalid(str(e))
コード例 #3
0
ファイル: dataset_form.py プロジェクト: datagovuk/ckanext-dgu
def date_to_db(value, context):
    try:
        value = DateType.form_to_db(value)
    except DateConvertError, e:
        raise Invalid(unicode(e).encode('ascii', 'ignore'))
コード例 #4
0
ファイル: tasks.py プロジェクト: salum-ar/ckanext-dgu
    try:
        title = row[0].value.encode('utf-8')
    except Exception, e:
        raise Exception('Error with encoding of Title: %s' % e)
    try:
        description = row[1].value.encode('utf-8')
    except Exception, e:
        raise Exception('Error with encoding of Description: %s' % e)
    publisher_name = row[2].value
    publish_date = row[3].value
    release_notes = row[4].value

    if isinstance(publish_date, basestring) and publish_date.strip():
        # e.g. CSV containing "1/2/14" -> "14/02/01"
        try:
            publish_date = DateType.form_to_db(publish_date)
        except DateConvertError:
            # Lots of text went into this field but have decided to not allow from now
            # and it never gets displayed.
            msg = 'Could not parse date: "%s" Must be: DD/MM/YY' % publish_date
            log.error(msg)
            raise Exception(msg)
    if isinstance(publish_date, datetime.datetime):
        # e.g. Excel -> "14/02/01"
        publish_date = DateType.date_to_db(publish_date)
    if not isinstance(publish_date, basestring):
        # e.g. Excel int
        msg = 'Could not parse date: "%s" Must be: DD/MM/YY' % publish_date
        log.error(msg)
        raise Exception(msg)
コード例 #5
0
    try:
        title = row[0].value.encode('utf-8')
    except Exception, e:
        raise Exception('Error with encoding of Title: %s' % e)
    try:
        description = row[1].value.encode('utf-8')
    except Exception, e:
        raise Exception('Error with encoding of Description: %s' % e)
    publisher_name = row[2].value
    publish_date = row[3].value
    release_notes = row[4].value

    if isinstance(publish_date, basestring) and publish_date.strip():
        # e.g. CSV containing "1/2/14" -> "14/02/01"
        try:
            publish_date = DateType.form_to_db(publish_date)
        except DateConvertError:
            # Lots of text went into this field but have decided to not allow from now
            # and it never gets displayed.
            msg = 'Could not parse date: "%s" Must be: DD/MM/YY' % publish_date
            log.error(msg)
            raise Exception(msg)
    if isinstance(publish_date, datetime.datetime):
        # e.g. Excel -> "14/02/01"
        publish_date = DateType.date_to_db(publish_date)
    if not isinstance(publish_date, basestring):
        # e.g. Excel int
        msg = 'Could not parse date: "%s" Must be: DD/MM/YY' % publish_date
        log.error(msg)
        raise Exception(msg)