docstrings
这个提交包含在:
父节点
4fa42a677a
当前提交
8e40534a76
共有 2 个文件被更改,包括 18 次插入 和 19 次删除
|
@ -18,9 +18,6 @@ limitations under the License.
|
|||
"""
|
||||
|
||||
import os
|
||||
import json
|
||||
import utils
|
||||
import datetime
|
||||
|
||||
import tornado.httpserver
|
||||
import tornado.ioloop
|
||||
|
@ -29,20 +26,10 @@ from tornado.options import define, options
|
|||
import tornado.web
|
||||
from tornado import gen, escape
|
||||
|
||||
import utils
|
||||
import backend
|
||||
|
||||
|
||||
class ImprovedEncoder(json.JSONEncoder):
|
||||
"""Enhance the default JSON encoder to serialize datetime objects."""
|
||||
def default(self, o):
|
||||
if isinstance(o, (datetime.datetime, datetime.date,
|
||||
datetime.time, datetime.timedelta)):
|
||||
return str(o)
|
||||
return json.JSONEncoder.default(self, o)
|
||||
|
||||
json._default_encoder = ImprovedEncoder()
|
||||
|
||||
|
||||
class BaseHandler(tornado.web.RequestHandler):
|
||||
"""Base class for request handlers."""
|
||||
def initialize(self, **kwargs):
|
||||
|
@ -110,11 +97,8 @@ class EventsHandler(CollectionHandler):
|
|||
collection = 'events'
|
||||
|
||||
|
||||
class ImportPersonsHandler(BaseHandler):
|
||||
pass
|
||||
|
||||
|
||||
class EbCSVImportPersonsHandler(ImportPersonsHandler):
|
||||
class EbCSVImportPersonsHandler(BaseHandler):
|
||||
"""Importer for CSV files exported from eventbrite."""
|
||||
csvRemap = {
|
||||
'Nome evento': 'event_title',
|
||||
'ID evento': 'event_id',
|
||||
|
|
15
utils.py
15
utils.py
|
@ -17,8 +17,11 @@ limitations under the License.
|
|||
"""
|
||||
|
||||
import csv
|
||||
import json
|
||||
import datetime
|
||||
import StringIO
|
||||
|
||||
|
||||
def csvParse(csvStr, remap=None, merge=None):
|
||||
"""Parse a CSV file, optionally renaming the columns and merging other information.
|
||||
|
||||
|
@ -66,3 +69,15 @@ def csvParse(csvStr, remap=None, merge=None):
|
|||
fd.close()
|
||||
return reply, results
|
||||
|
||||
|
||||
class ImprovedEncoder(json.JSONEncoder):
|
||||
"""Enhance the default JSON encoder to serialize datetime objects."""
|
||||
def default(self, o):
|
||||
if isinstance(o, (datetime.datetime, datetime.date,
|
||||
datetime.time, datetime.timedelta)):
|
||||
return str(o)
|
||||
return json.JSONEncoder.default(self, o)
|
||||
|
||||
# Inject our class as the default encoder.
|
||||
json._default_encoder = ImprovedEncoder()
|
||||
|
||||
|
|
正在加载…
在新工单中引用