Beispiel #1
0
class IP(Resource):
    def __init__(self):
        self.mh = MongoHelper()
        self.mh.init_db()

    @marshal_with(
        resource_field, )
    def get(self):
        print('get')
        parser = reqparse.RequestParser()
        parser.add_argument('count', type=str)
        parser.add_argument('page_index', type=int)
        parser.add_argument('page_size', type=int)
        args = parser.parse_args()
        return self.mh.select(
            args['count'] if args['count'] is not None else 5,
            page_index=args['page_index'] if args['page_index'] else 1,
            page_size=args['page_size'] if args['page_size'] else 5)

    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument('id', type=str)
        args = parser.parse_args()
        return self.mh.downscore(
            args if args['id'] is not None else abort(500))
 dataMod2 = [u"厂商指导价", u"气缸数(个)", u"排量(mL)", \
   u"最大扭矩转速(rpm)", \
   u"发动机", u"最大功率(kW)", u"座位数(个)", u"变速箱", u"车门数(个)",  u"最大扭矩(N・m)",\
   u"挡位个数", u"最大马力(Ps)",  u"排量(L)", u"每缸气门(个)"]
 dataMod9  = [u"厂商指导价", u"长度(mm)", u"轴距(mm)", u"气缸数(个)", u"排量(mL)", \
   u"最大扭矩转速(rpm)", u"宽度(mm)",\
   u"发动机", u"最大功率(kW)", u"座位数(个)", u"变速箱", u"车门数(个)",  u"最大扭矩(N・m)",\
   u"挡位个数", u"最大马力(Ps)",  u"排量(L)", u"每缸气门(个)", \
   u"长*宽*高(mm)", u"前轮胎规格", u"后轮胎规格", u"燃油标号"]
 dataMod = [u"厂商指导价", u"长度(mm)", u"轴距(mm)", u"气缸数(个)", u"排量(mL)", \
   u"最大扭矩转速(rpm)", u"宽度(mm)",\
   u"发动机", u"最大功率(kW)", u"座位数(个)", u"变速箱", u"车门数(个)",  u"最大扭矩(N・m)",\
   u"挡位个数", u"最大马力(Ps)",  u"排量(L)", u"每缸气门(个)", \
   u"长*宽*高(mm)", u"前轮胎规格", u"后轮胎规格", u"燃油标号"]
 errorCount = 0
 allData = mongoDB.select(None, None)
 mylen = len(allData)
 lstConf = [0 for n in range(mylen)]
 lstPric = [0 for n in range(mylen)]
 j = 0
 for item in allData:
   dataCell = [0 for n in range(0,len(dataMod))]
   i = 0
   try:
     for set in dataMod:
       ##print type(set)
       if isinstance(set, byte):
         import chardet
         ##print chardet.detect(set)
       dataCell[i] = item[set].split('~')[0].split('-')[0].split(' ')[0]
       dataCell[i] = reSub(dataCell[i])