How to use comment method in wpt

Best JavaScript code snippet using wpt

qmatch.py

Source:qmatch.py Github

copy

Full Screen

1#! /usr/bin/env python2# -*- coding: utf-8 -*-3import os, re, sys4import urllib,urllib25from xml.dom import minidom as pydom6class QueryResComp:7 def __init__(self, serviceName):8 self.serviceName = serviceName9 self.queryString = ''10 self.leftagg = 'http://10.249.84.102:9000'11 self.rightagg = 'http://aggregator.daogou.yh.vip.aliyun.com:9090'12 qStr = ()13 self.leftXmlRes = ''14 self.rightXmlRes = ''15 def fetchResult(self,queryString):16 qStr = (('shortcut','--Method=Search --Parameter="'+queryString+'"'),)17 print urllib.urlencode(qStr)18 # req=urllib2.Request(self.rightagg,urllib.urlencode(qStr))19 # u=urllib2.urlopen(req)20 # print u.read()21 22 def parseUrlList(self,xmlRes):23 res = []24 sec = ''25 26 if self.serviceName == 'daogou_auction':27 sec = 'nid'28 else:29 sec = 'url'30 dom = pydom.parseString(xmlRes)31 for ele in dom.getElementsByTagName(sec):32 res.append(ele.firstChild.wholeText)33 return res34 35 def isEqual(self):36 if(len(self.leftXmlRes)==0 or len(self.rightXmlRes)==0):37 print "Query[%s] got 0result" % self.queryString38 return False39 leftUrlArray= self.parseUrlList(self.leftXmlRes)40 rightUrlArray= self.parseUrlList(self.rightXmlRes)41 42 if(leftUrlArray == rightUrlArray):43 return True44 else:45 return False46 47 48 49 50if __name__ == '__main__':51 52 xmlstr = '''<?xml version="1.0" encoding="UTF-8"?>53<Root>54<TotalTime>0.055</TotalTime>55<hits numhits="10" totalhits="117892">56 <hit hash_id="3" docid="9212704">57 <fields>58 <biz30day><![CDATA[1]]></biz30day>59 <cat_id><![CDATA[1512]]></cat_id>60 <comment0><![CDATA[超级喜欢~~~速度还很快。超值]]></comment0>61 <comment1><![CDATA[货很正。]]></comment1>62 <comment2><![CDATA[]]></comment2>63 <comment_num><![CDATA[2]]></comment_num>64 <comment_rate0><![CDATA[4]]></comment_rate0>65 <comment_rate1><![CDATA[41]]></comment_rate1>66 <comment_rate2><![CDATA[]]></comment_rate2>67 <comment_user0><![CDATA[1157saygoodbye]]></comment_user0>68 <comment_user1><![CDATA[changzheng92]]></comment_user1>69 <comment_user2><![CDATA[]]></comment_user2>70 <commercial><![CDATA[0]]></commercial>71 <desp><![CDATA[產品規格72顯示所有 隱藏所有73手機功能、電...]]></desp>74 <grade_avg><![CDATA[0]]></grade_avg>75 <nick><![CDATA[zpin10]]></nick>76 <nid><![CDATA[4052667480]]></nid>77 <people_num><![CDATA[0]]></people_num>78 <pict_url><![CDATA[i8/T1F18AXm4jXXbkT1c0_034730.jpg]]></pict_url>79 <pid><![CDATA[78348588]]></pid>80 <pidvidt><![CDATA[]]></pidvidt>81 <product_num><![CDATA[6201]]></product_num>82 <ratesum><![CDATA[9]]></ratesum>83 <reserve_price><![CDATA[2020]]></reserve_price>84 <seller_goodrate><![CDATA[9993]]></seller_goodrate>85 <title><![CDATA[*五年钻石好店三包赔付保障*<font color=red>Nokia</font>/诺基亚 X6]]></title>86 <total_sold_quantity><![CDATA[11]]></total_sold_quantity>87 <user_nid><![CDATA[22839402]]></user_nid>88 <user_strid><![CDATA[cfc07f8231e153dbdbfe872bf9f41ff0]]></user_strid>89 </fields>90 <property>91 </property>92 <sortExprValues>93 0.00021017194 </sortExprValues>95 </hit>96 <hit hash_id="0" docid="9190361">97 <fields>98 <biz30day><![CDATA[1]]></biz30day>99 <cat_id><![CDATA[50012584]]></cat_id>100 <comment0><![CDATA[给妹妹买的,她说不错,和在街上买的价格差不多,...]]></comment0>101 <comment1><![CDATA[宝贝都很不错,买家态度老好了,以后有需要还会继续...]]></comment1>102 <comment2><![CDATA[好使 没坏 就是有点贵]]></comment2>103 <comment_num><![CDATA[6]]></comment_num>104 <comment_rate0><![CDATA[501]]></comment_rate0>105 <comment_rate1><![CDATA[41]]></comment_rate1>106 <comment_rate2><![CDATA[41]]></comment_rate2>107 <comment_user0><![CDATA[空瓶子zch]]></comment_user0>108 <comment_user1><![CDATA[huihui_katrina]]></comment_user1>109 <comment_user2><![CDATA[showwinter]]></comment_user2>110 <commercial><![CDATA[0]]></commercial>111 <desp><![CDATA[<font color=red>Nokia</font>线充E65 E90 E95 N70充电器 N71 N72线充]]></desp>112 <grade_avg><![CDATA[0]]></grade_avg>113 <nick><![CDATA[taotao8601]]></nick>114 <nid><![CDATA[4042745681]]></nid>115 <people_num><![CDATA[0]]></people_num>116 <pict_url><![CDATA[i8/T1b0JBXlhyXXXSaBs2_044823.jpg]]></pict_url>117 <pid><![CDATA[23620066]]></pid>118 <pidvidt><![CDATA[]]></pidvidt>119 <product_num><![CDATA[2806]]></product_num>120 <ratesum><![CDATA[11]]></ratesum>121 <reserve_price><![CDATA[8]]></reserve_price>122 <seller_goodrate><![CDATA[9730]]></seller_goodrate>123 <title><![CDATA[<font color=red>Nokia</font>线充E65 E90 E95 N70充电器 N71 N72线充 N73线充]]></title>124 <total_sold_quantity><![CDATA[72]]></total_sold_quantity>125 <user_nid><![CDATA[74665395]]></user_nid>126 <user_strid><![CDATA[561198dfa4cd940c717cc84ca2b5fbd8]]></user_strid>127 </fields>128 <property>129 </property>130 <sortExprValues>131 0.000210171132 </sortExprValues>133 </hit>134 <hit hash_id="2" docid="9176120">135 <fields>136 <biz30day><![CDATA[1]]></biz30day>137 <cat_id><![CDATA[1512]]></cat_id>138 <comment0><![CDATA[]]></comment0>139 <comment1><![CDATA[]]></comment1>140 <comment2><![CDATA[]]></comment2>141 <comment_num><![CDATA[0]]></comment_num>142 <comment_rate0><![CDATA[]]></comment_rate0>143 <comment_rate1><![CDATA[]]></comment_rate1>144 <comment_rate2><![CDATA[]]></comment_rate2>145 <comment_user0><![CDATA[]]></comment_user0>146 <comment_user1><![CDATA[]]></comment_user1>147 <comment_user2><![CDATA[]]></comment_user2>148 <commercial><![CDATA[0]]></commercial>149 <desp><![CDATA[C 系中阶 QWERTY 款式150诺基亚于 2010 年 4 ...]]></desp>151 <grade_avg><![CDATA[0]]></grade_avg>152 <nick><![CDATA[zheng570546321]]></nick>153 <nid><![CDATA[6701442378]]></nid>154 <people_num><![CDATA[0]]></people_num>155 <pict_url><![CDATA[i2/T1ivVKXaFlXXc8A6o._113005.jpg]]></pict_url>156 <pid><![CDATA[96312365]]></pid>157 <pidvidt><![CDATA[]]></pidvidt>158 <product_num><![CDATA[6125]]></product_num>159 <ratesum><![CDATA[5]]></ratesum>160 <reserve_price><![CDATA[1800]]></reserve_price>161 <seller_goodrate><![CDATA[10000]]></seller_goodrate>162 <title><![CDATA[<font color=red>Nokia</font>/诺基亚 C6]]></title>163 <total_sold_quantity><![CDATA[1]]></total_sold_quantity>164 <user_nid><![CDATA[346568297]]></user_nid>165 <user_strid><![CDATA[a8325eb660a709ee925bc8c3928845d2]]></user_strid>166 </fields>167 <property>168 </property>169 <sortExprValues>170 0.000210171171 </sortExprValues>172 </hit>173 <hit hash_id="0" docid="9168980">174 <fields>175 <biz30day><![CDATA[1]]></biz30day>176 <cat_id><![CDATA[1512]]></cat_id>177 <comment0><![CDATA[是行货,手机还不错。第一次上手诺基亚的手机,感觉...]]></comment0>178 <comment1><![CDATA[手机是好手机,掌柜是好掌柜,别的真的没什么了。]]></comment1>179 <comment2><![CDATA[东西很好!]]></comment2>180 <comment_num><![CDATA[4]]></comment_num>181 <comment_rate0><![CDATA[91]]></comment_rate0>182 <comment_rate1><![CDATA[11]]></comment_rate1>183 <comment_rate2><![CDATA[151]]></comment_rate2>184 <comment_user0><![CDATA[奇葩famliy]]></comment_user0>185 <comment_user1><![CDATA[寻找柳如是]]></comment_user1>186 <comment_user2><![CDATA[qq_190257]]></comment_user2>187 <commercial><![CDATA[0]]></commercial>188 <desp><![CDATA[新鲜出炉的C6靓照!C 系中阶 QWERTY 款式189...]]></desp>190 <grade_avg><![CDATA[0]]></grade_avg>191 <nick><![CDATA[yw09098]]></nick>192 <nid><![CDATA[6822469113]]></nid>193 <people_num><![CDATA[0]]></people_num>194 <pict_url><![CDATA[i3/T1y2lHXfFvXXb4jYza_120258.jpg]]></pict_url>195 <pid><![CDATA[96312365]]></pid>196 <pidvidt><![CDATA[]]></pidvidt>197 <product_num><![CDATA[6125]]></product_num>198 <ratesum><![CDATA[7]]></ratesum>199 <reserve_price><![CDATA[2198]]></reserve_price>200 <seller_goodrate><![CDATA[10000]]></seller_goodrate>201 <title><![CDATA[诺基亚/<font color=red>NOKIA</font> C6-00【大陆行货+全国联保+重庆实体店+发票+包邮】]]></title>202 <total_sold_quantity><![CDATA[6]]></total_sold_quantity>203 <user_nid><![CDATA[13793617]]></user_nid>204 <user_strid><![CDATA[01c2f7bce131ce8f2b051513cf9128a1]]></user_strid>205 </fields>206 <property>207 </property>208 <sortExprValues>209 0.000210171210 </sortExprValues>211 </hit>212 <hit hash_id="2" docid="9145695">213 <fields>214 <biz30day><![CDATA[1]]></biz30day>215 <cat_id><![CDATA[50003775]]></cat_id>216 <comment0><![CDATA[]]></comment0>217 <comment1><![CDATA[]]></comment1>218 <comment2><![CDATA[]]></comment2>219 <comment_num><![CDATA[0]]></comment_num>220 <comment_rate0><![CDATA[]]></comment_rate0>221 <comment_rate1><![CDATA[]]></comment_rate1>222 <comment_rate2><![CDATA[]]></comment_rate2>223 <comment_user0><![CDATA[]]></comment_user0>224 <comment_user1><![CDATA[]]></comment_user1>225 <comment_user2><![CDATA[]]></comment_user2>226 <commercial><![CDATA[0]]></commercial>227 <desp><![CDATA[<font color=red>Nokia</font>/诺基亚 <font color=red>Nokia</font> E75 黑色手机外壳全套 ...]]></desp>228 <grade_avg><![CDATA[0]]></grade_avg>229 <nick><![CDATA[ccue163]]></nick>230 <nid><![CDATA[7883573863]]></nid>231 <people_num><![CDATA[0]]></people_num>232 <pict_url><![CDATA[i4/T1nl4NXityXXaK5EoZ_034002.jpg]]></pict_url>233 <pid><![CDATA[-7883573863]]></pid>234 <pidvidt><![CDATA[]]></pidvidt>235 <product_num><![CDATA[0]]></product_num>236 <ratesum><![CDATA[6]]></ratesum>237 <reserve_price><![CDATA[55]]></reserve_price>238 <seller_goodrate><![CDATA[9898]]></seller_goodrate>239 <title><![CDATA[<font color=red>Nokia</font>/诺基亚 <font color=red>Nokia</font> E75 黑色手机外壳全套 带按键和拆机工具]]></title>240 <total_sold_quantity><![CDATA[0]]></total_sold_quantity>241 <user_nid><![CDATA[350400477]]></user_nid>242 <user_strid><![CDATA[4e1d00e029058aaa1e1d53e9abefcab4]]></user_strid>243 </fields>244 <property>245 </property>246 <sortExprValues>247 0.000210171248 </sortExprValues>249 </hit>250 <hit hash_id="2" docid="9139861">251 <fields>252 <biz30day><![CDATA[2]]></biz30day>253 <cat_id><![CDATA[50012584]]></cat_id>254 <comment0><![CDATA[不好意思这几天挺忙 确认晚了]]></comment0>255 <comment1><![CDATA[]]></comment1>256 <comment2><![CDATA[]]></comment2>257 <comment_num><![CDATA[1]]></comment_num>258 <comment_rate0><![CDATA[11]]></comment_rate0>259 <comment_rate1><![CDATA[]]></comment_rate1>260 <comment_rate2><![CDATA[]]></comment_rate2>261 <comment_user0><![CDATA[zgqskzhifubao]]></comment_user0>262 <comment_user1><![CDATA[]]></comment_user1>263 <comment_user2><![CDATA[]]></comment_user2>264 <commercial><![CDATA[0]]></commercial>265 <desp><![CDATA[<font color=red>Nokia</font>线充E65 E90 E95 N70充电器 N71 N72...]]></desp>266 <grade_avg><![CDATA[0]]></grade_avg>267 <nick><![CDATA[路过泉城]]></nick>268 <nid><![CDATA[6698634985]]></nid>269 <people_num><![CDATA[0]]></people_num>270 <pict_url><![CDATA[i2/T105xGXlNqXXbUsE6b_095528.jpg]]></pict_url>271 <pid><![CDATA[23615829]]></pid>272 <pidvidt><![CDATA[]]></pidvidt>273 <product_num><![CDATA[6405]]></product_num>274 <ratesum><![CDATA[9]]></ratesum>275 <reserve_price><![CDATA[8]]></reserve_price>276 <seller_goodrate><![CDATA[9587]]></seller_goodrate>277 <title><![CDATA[<font color=red>Nokia</font>线充E65 E90 E95 N70充电器 N71 N72线充 N73线充]]></title>278 <total_sold_quantity><![CDATA[6]]></total_sold_quantity>279 <user_nid><![CDATA[117818253]]></user_nid>280 <user_strid><![CDATA[19d4a11e148c07ee3288ab9d96378482]]></user_strid>281 </fields>282 <property>283 </property>284 <sortExprValues>285 0.000210171286 </sortExprValues>287 </hit>288 <hit hash_id="3" docid="9137643">289 <fields>290 <biz30day><![CDATA[1]]></biz30day>291 <cat_id><![CDATA[50010614]]></cat_id>292 <comment0><![CDATA[]]></comment0>293 <comment1><![CDATA[]]></comment1>294 <comment2><![CDATA[]]></comment2>295 <comment_num><![CDATA[0]]></comment_num>296 <comment_rate0><![CDATA[]]></comment_rate0>297 <comment_rate1><![CDATA[]]></comment_rate1>298 <comment_rate2><![CDATA[]]></comment_rate2>299 <comment_user0><![CDATA[]]></comment_user0>300 <comment_user1><![CDATA[]]></comment_user1>301 <comment_user2><![CDATA[]]></comment_user2>302 <commercial><![CDATA[0]]></commercial>303 <desp><![CDATA[产品描述:蓝特(LT)<font color=red>Nokia</font>/诺基亚 3610A/...]]></desp>304 <grade_avg><![CDATA[0]]></grade_avg>305 <nick><![CDATA[杨惠茸]]></nick>306 <nid><![CDATA[6817724341]]></nid>307 <people_num><![CDATA[0]]></people_num>308 <pict_url><![CDATA[i3/T16vtHXdhfXXakivg0_035148.jpg]]></pict_url>309 <pid><![CDATA[-6817724341]]></pid>310 <pidvidt><![CDATA[]]></pidvidt>311 <product_num><![CDATA[0]]></product_num>312 <ratesum><![CDATA[3]]></ratesum>313 <reserve_price><![CDATA[20]]></reserve_price>314 <seller_goodrate><![CDATA[9655]]></seller_goodrate>315 <title><![CDATA[蓝特(LT)<font color=red>Nokia</font>/诺基亚3610A/6555带座排线]]></title>316 <total_sold_quantity><![CDATA[1]]></total_sold_quantity>317 <user_nid><![CDATA[436855978]]></user_nid>318 <user_strid><![CDATA[4b9ad1c3c7f405847c2a47815ffc08c6]]></user_strid>319 </fields>320 <property>321 </property>322 <sortExprValues>323 0.000210171324 </sortExprValues>325 </hit>326 <hit hash_id="0" docid="9128114">327 <fields>328 <biz30day><![CDATA[1]]></biz30day>329 <cat_id><![CDATA[1512]]></cat_id>330 <comment0><![CDATA[这个颜色非常漂亮,喜欢,老板服务不错,还给我安装...]]></comment0>331 <comment1><![CDATA[颜色很好看,老板还送了好多礼品,还包邮!是我在...]]></comment1>332 <comment2><![CDATA[发货很快,手机很喜欢,这个颜色很不错!老板人很...]]></comment2>333 <comment_num><![CDATA[7]]></comment_num>334 <comment_rate0><![CDATA[4]]></comment_rate0>335 <comment_rate1><![CDATA[4]]></comment_rate1>336 <comment_rate2><![CDATA[4]]></comment_rate2>337 <comment_user0><![CDATA[亲爱的囡囡88]]></comment_user0>338 <comment_user1><![CDATA[晴天妹妹8]]></comment_user1>339 <comment_user2><![CDATA[狗儿们的窝]]></comment_user2>340 <commercial><![CDATA[0]]></commercial>341 <desp><![CDATA[----------------------------------------...]]></desp>342 <grade_avg><![CDATA[0]]></grade_avg>343 <nick><![CDATA[萍萍一站式购物]]></nick>344 <nid><![CDATA[6722451228]]></nid>345 <people_num><![CDATA[0]]></people_num>346 <pict_url><![CDATA[i3/T15rpDXelyXXbTA4gV_020655.jpg]]></pict_url>347 <pid><![CDATA[72468326]]></pid>348 <pidvidt><![CDATA[]]></pidvidt>349 <product_num><![CDATA[7382]]></product_num>350 <ratesum><![CDATA[9]]></ratesum>351 <reserve_price><![CDATA[1280]]></reserve_price>352 <seller_goodrate><![CDATA[9972]]></seller_goodrate>353 <title><![CDATA[【桔子通讯】<font color=red>Nokia</font>/诺基亚6700S/Slide 智能机港行 红蓝紫粉绿银]]></title>354 <total_sold_quantity><![CDATA[4]]></total_sold_quantity>355 <user_nid><![CDATA[279716453]]></user_nid>356 <user_strid><![CDATA[95604865bdd3499532e79eec4e399401]]></user_strid>357 </fields>358 <property>359 </property>360 <sortExprValues>361 0.000210171362 </sortExprValues>363 </hit>364 <hit hash_id="1" docid="9124486">365 <fields>366 <biz30day><![CDATA[1]]></biz30day>367 <cat_id><![CDATA[150704]]></cat_id>368 <comment0><![CDATA[做工还成。但是的确偏大不少]]></comment0>369 <comment1><![CDATA[很不错的宝贝 很满意]]></comment1>370 <comment2><![CDATA[赞一个]]></comment2>371 <comment_num><![CDATA[3]]></comment_num>372 <comment_rate0><![CDATA[501]]></comment_rate0>373 <comment_rate1><![CDATA[4]]></comment_rate1>374 <comment_rate2><![CDATA[91]]></comment_rate2>375 <comment_user0><![CDATA[gegega]]></comment_user0>376 <comment_user1><![CDATA[熊熊爱吃饭]]></comment_user1>377 <comment_user2><![CDATA[小晴1799]]></comment_user2>378 <commercial><![CDATA[0]]></commercial>379 <desp><![CDATA[----------------------------------------...]]></desp>380 <grade_avg><![CDATA[0]]></grade_avg>381 <nick><![CDATA[baiyun数码]]></nick>382 <nid><![CDATA[6219039792]]></nid>383 <people_num><![CDATA[0]]></people_num>384 <pict_url><![CDATA[i1/T1RfpFXaFjXXbqLRM3_050811.jpg]]></pict_url>385 <pid><![CDATA[73686392]]></pid>386 <pidvidt><![CDATA[]]></pidvidt>387 <product_num><![CDATA[662]]></product_num>388 <ratesum><![CDATA[9]]></ratesum>389 <reserve_price><![CDATA[47]]></reserve_price>390 <seller_goodrate><![CDATA[10000]]></seller_goodrate>391 <title><![CDATA[澳洲PDair炫彩多色 <font color=red>Nokia</font> n97mini 硅胶套 品质之选 红色]]></title>392 <total_sold_quantity><![CDATA[9]]></total_sold_quantity>393 <user_nid><![CDATA[212478869]]></user_nid>394 <user_strid><![CDATA[f3327a1de93bee4398481d69f08b08e3]]></user_strid>395 </fields>396 <property>397 </property>398 <sortExprValues>399 0.000210171400 </sortExprValues>401 </hit>402 <hit hash_id="0" docid="9122611">403 <fields>404 <biz30day><![CDATA[2]]></biz30day>405 <cat_id><![CDATA[50012587]]></cat_id>406 <comment0><![CDATA[老板很厚道...]]></comment0>407 <comment1><![CDATA[老板依然厚道!]]></comment1>408 <comment2><![CDATA[]]></comment2>409 <comment_num><![CDATA[2]]></comment_num>410 <comment_rate0><![CDATA[11]]></comment_rate0>411 <comment_rate1><![CDATA[11]]></comment_rate1>412 <comment_rate2><![CDATA[]]></comment_rate2>413 <comment_user0><![CDATA[獨y無贰]]></comment_user0>414 <comment_user1><![CDATA[獨y無贰]]></comment_user1>415 <comment_user2><![CDATA[]]></comment_user2>416 <commercial><![CDATA[0]]></commercial>417 <desp><![CDATA[使用说明:4181、第一步清洁屏幕,用附赠的...]]></desp>419 <grade_avg><![CDATA[0]]></grade_avg>420 <nick><![CDATA[讨厌平安夜]]></nick>421 <nid><![CDATA[6818006015]]></nid>422 <people_num><![CDATA[0]]></people_num>423 <pict_url><![CDATA[i6/T1tUppXh0aXXbLmTo8_102003.jpg]]></pict_url>424 <pid><![CDATA[80427683]]></pid>425 <pidvidt><![CDATA[]]></pidvidt>426 <product_num><![CDATA[0]]></product_num>427 <ratesum><![CDATA[3]]></ratesum>428 <reserve_price><![CDATA[68]]></reserve_price>429 <seller_goodrate><![CDATA[10000]]></seller_goodrate>430 <title><![CDATA[阿迪普手机膜专家-<font color=red>NOKIA</font>诺基亚 5230 幻彩钻石系列套装]]></title>431 <total_sold_quantity><![CDATA[2]]></total_sold_quantity>432 <user_nid><![CDATA[56983709]]></user_nid>433 <user_strid><![CDATA[71f84a0915e9062e30df53c960641f21]]></user_strid>434 </fields>435 <property>436 </property>437 <sortExprValues>438 0.000210171439 </sortExprValues>440 </hit>441</hits>442<AggregateResults>443</AggregateResults>444<Error>445 <ErrorCode>0</ErrorCode>446 <ErrorDescription></ErrorDescription>447</Error>448</Root>449'''450 xmlstr1 = '''<?xml version="1.0" encoding="UTF-8"?>451<Root>452<TotalTime>0.055</TotalTime>453<hits numhits="10" totalhits="117892">454 <hit hash_id="3" docid="9212704">455 <fields>456 <biz30day><![CDATA[1]]></biz30day>457 <cat_id><![CDATA[1512]]></cat_id>458 <comment0><![CDATA[超级喜欢~~~速度还很快。超值]]></comment0>459 <comment1><![CDATA[货很正。]]></comment1>460 <comment2><![CDATA[]]></comment2>461 <comment_num><![CDATA[2]]></comment_num>462 <comment_rate0><![CDATA[4]]></comment_rate0>463 <comment_rate1><![CDATA[41]]></comment_rate1>464 <comment_rate2><![CDATA[]]></comment_rate2>465 <comment_user0><![CDATA[1157saygoodbye]]></comment_user0>466 <comment_user1><![CDATA[changzheng92]]></comment_user1>467 <comment_user2><![CDATA[]]></comment_user2>468 <commercial><![CDATA[0]]></commercial>469 <desp><![CDATA[產品規格470顯示所有 隱藏所有471手機功能、電...]]></desp>472 <grade_avg><![CDATA[0]]></grade_avg>473 <nick><![CDATA[zpin10]]></nick>474 <nid><![CDATA[4052667480]]></nid>475 <people_num><![CDATA[0]]></people_num>476 <pict_url><![CDATA[i8/T1F18AXm4jXXbkT1c0_034730.jpg]]></pict_url>477 <pid><![CDATA[78348588]]></pid>478 <pidvidt><![CDATA[]]></pidvidt>479 <product_num><![CDATA[6201]]></product_num>480 <ratesum><![CDATA[9]]></ratesum>481 <reserve_price><![CDATA[2020]]></reserve_price>482 <seller_goodrate><![CDATA[9993]]></seller_goodrate>483 <title><![CDATA[*五年钻石好店三包赔付保障*<font color=red>Nokia</font>/诺基亚 X6]]></title>484 <total_sold_quantity><![CDATA[11]]></total_sold_quantity>485 <user_nid><![CDATA[22839402]]></user_nid>486 <user_strid><![CDATA[cfc07f8231e153dbdbfe872bf9f41ff0]]></user_strid>487 </fields>488 <property>489 </property>490 <sortExprValues>491 0.000210171492 </sortExprValues>493 </hit>494 <hit hash_id="0" docid="9190361">495 <fields>496 <biz30day><![CDATA[1]]></biz30day>497 <cat_id><![CDATA[50012584]]></cat_id>498 <comment0><![CDATA[给妹妹买的,她说不错,和在街上买的价格差不多,...]]></comment0>499 <comment1><![CDATA[宝贝都很不错,买家态度老好了,以后有需要还会继续...]]></comment1>500 <comment2><![CDATA[好使 没坏 就是有点贵]]></comment2>501 <comment_num><![CDATA[6]]></comment_num>502 <comment_rate0><![CDATA[501]]></comment_rate0>503 <comment_rate1><![CDATA[41]]></comment_rate1>504 <comment_rate2><![CDATA[41]]></comment_rate2>505 <comment_user0><![CDATA[空瓶子zch]]></comment_user0>506 <comment_user1><![CDATA[huihui_katrina]]></comment_user1>507 <comment_user2><![CDATA[showwinter]]></comment_user2>508 <commercial><![CDATA[0]]></commercial>509 <desp><![CDATA[<font color=red>Nokia</font>线充E65 E90 E95 N70充电器 N71 N72线充]]></desp>510 <grade_avg><![CDATA[0]]></grade_avg>511 <nick><![CDATA[taotao8601]]></nick>512 <nid><![CDATA[4042745681]]></nid>513 <people_num><![CDATA[0]]></people_num>514 <pict_url><![CDATA[i8/T1b0JBXlhyXXXSaBs2_044823.jpg]]></pict_url>515 <pid><![CDATA[23620066]]></pid>516 <pidvidt><![CDATA[]]></pidvidt>517 <product_num><![CDATA[2806]]></product_num>518 <ratesum><![CDATA[11]]></ratesum>519 <reserve_price><![CDATA[8]]></reserve_price>520 <seller_goodrate><![CDATA[9730]]></seller_goodrate>521 <title><![CDATA[<font color=red>Nokia</font>线充E65 E90 E95 N70充电器 N71 N72线充 N73线充]]></title>522 <total_sold_quantity><![CDATA[72]]></total_sold_quantity>523 <user_nid><![CDATA[74665395]]></user_nid>524 <user_strid><![CDATA[561198dfa4cd940c717cc84ca2b5fbd8]]></user_strid>525 </fields>526 <property>527 </property>528 <sortExprValues>529 0.000210171530 </sortExprValues>531 </hit>532 <hit hash_id="2" docid="9176120">533 <fields>534 <biz30day><![CDATA[1]]></biz30day>535 <cat_id><![CDATA[1512]]></cat_id>536 <comment0><![CDATA[]]></comment0>537 <comment1><![CDATA[]]></comment1>538 <comment2><![CDATA[]]></comment2>539 <comment_num><![CDATA[0]]></comment_num>540 <comment_rate0><![CDATA[]]></comment_rate0>541 <comment_rate1><![CDATA[]]></comment_rate1>542 <comment_rate2><![CDATA[]]></comment_rate2>543 <comment_user0><![CDATA[]]></comment_user0>544 <comment_user1><![CDATA[]]></comment_user1>545 <comment_user2><![CDATA[]]></comment_user2>546 <commercial><![CDATA[0]]></commercial>547 <desp><![CDATA[C 系中阶 QWERTY 款式548诺基亚于 2010 年 4 ...]]></desp>549 <grade_avg><![CDATA[0]]></grade_avg>550 <nick><![CDATA[zheng570546321]]></nick>551 <nid><![CDATA[6701442378]]></nid>552 <people_num><![CDATA[0]]></people_num>553 <pict_url><![CDATA[i2/T1ivVKXaFlXXc8A6o._113005.jpg]]></pict_url>554 <pid><![CDATA[96312365]]></pid>555 <pidvidt><![CDATA[]]></pidvidt>556 <product_num><![CDATA[6125]]></product_num>557 <ratesum><![CDATA[5]]></ratesum>558 <reserve_price><![CDATA[1800]]></reserve_price>559 <seller_goodrate><![CDATA[10000]]></seller_goodrate>560 <title><![CDATA[<font color=red>Nokia</font>/诺基亚 C6]]></title>561 <total_sold_quantity><![CDATA[1]]></total_sold_quantity>562 <user_nid><![CDATA[346568297]]></user_nid>563 <user_strid><![CDATA[a8325eb660a709ee925bc8c3928845d2]]></user_strid>564 </fields>565 <property>566 </property>567 <sortExprValues>568 0.000210171569 </sortExprValues>570 </hit>571 <hit hash_id="0" docid="9168980">572 <fields>573 <biz30day><![CDATA[1]]></biz30day>574 <cat_id><![CDATA[1512]]></cat_id>575 <comment0><![CDATA[是行货,手机还不错。第一次上手诺基亚的手机,感觉...]]></comment0>576 <comment1><![CDATA[手机是好手机,掌柜是好掌柜,别的真的没什么了。]]></comment1>577 <comment2><![CDATA[东西很好!]]></comment2>578 <comment_num><![CDATA[4]]></comment_num>579 <comment_rate0><![CDATA[91]]></comment_rate0>580 <comment_rate1><![CDATA[11]]></comment_rate1>581 <comment_rate2><![CDATA[151]]></comment_rate2>582 <comment_user0><![CDATA[奇葩famliy]]></comment_user0>583 <comment_user1><![CDATA[寻找柳如是]]></comment_user1>584 <comment_user2><![CDATA[qq_190257]]></comment_user2>585 <commercial><![CDATA[0]]></commercial>586 <desp><![CDATA[新鲜出炉的C6靓照!C 系中阶 QWERTY 款式587...]]></desp>588 <grade_avg><![CDATA[0]]></grade_avg>589 <nick><![CDATA[yw09098]]></nick>590 <nid><![CDATA[6822469113]]></nid>591 <people_num><![CDATA[0]]></people_num>592 <pict_url><![CDATA[i3/T1y2lHXfFvXXb4jYza_120258.jpg]]></pict_url>593 <pid><![CDATA[96312365]]></pid>594 <pidvidt><![CDATA[]]></pidvidt>595 <product_num><![CDATA[6125]]></product_num>596 <ratesum><![CDATA[7]]></ratesum>597 <reserve_price><![CDATA[2198]]></reserve_price>598 <seller_goodrate><![CDATA[10000]]></seller_goodrate>599 <title><![CDATA[诺基亚/<font color=red>NOKIA</font> C6-00【大陆行货+全国联保+重庆实体店+发票+包邮】]]></title>600 <total_sold_quantity><![CDATA[6]]></total_sold_quantity>601 <user_nid><![CDATA[13793617]]></user_nid>602 <user_strid><![CDATA[01c2f7bce131ce8f2b051513cf9128a1]]></user_strid>603 </fields>604 <property>605 </property>606 <sortExprValues>607 0.000210171608 </sortExprValues>609 </hit>610 <hit hash_id="2" docid="9145695">611 <fields>612 <biz30day><![CDATA[1]]></biz30day>613 <cat_id><![CDATA[50003775]]></cat_id>614 <comment0><![CDATA[]]></comment0>615 <comment1><![CDATA[]]></comment1>616 <comment2><![CDATA[]]></comment2>617 <comment_num><![CDATA[0]]></comment_num>618 <comment_rate0><![CDATA[]]></comment_rate0>619 <comment_rate1><![CDATA[]]></comment_rate1>620 <comment_rate2><![CDATA[]]></comment_rate2>621 <comment_user0><![CDATA[]]></comment_user0>622 <comment_user1><![CDATA[]]></comment_user1>623 <comment_user2><![CDATA[]]></comment_user2>624 <commercial><![CDATA[0]]></commercial>625 <desp><![CDATA[<font color=red>Nokia</font>/诺基亚 <font color=red>Nokia</font> E75 黑色手机外壳全套 ...]]></desp>626 <grade_avg><![CDATA[0]]></grade_avg>627 <nick><![CDATA[ccue163]]></nick>628 <nid><![CDATA[7883573863]]></nid>629 <people_num><![CDATA[0]]></people_num>630 <pict_url><![CDATA[i4/T1nl4NXityXXaK5EoZ_034002.jpg]]></pict_url>631 <pid><![CDATA[-7883573863]]></pid>632 <pidvidt><![CDATA[]]></pidvidt>633 <product_num><![CDATA[0]]></product_num>634 <ratesum><![CDATA[6]]></ratesum>635 <reserve_price><![CDATA[55]]></reserve_price>636 <seller_goodrate><![CDATA[9898]]></seller_goodrate>637 <title><![CDATA[<font color=red>Nokia</font>/诺基亚 <font color=red>Nokia</font> E75 黑色手机外壳全套 带按键和拆机工具]]></title>638 <total_sold_quantity><![CDATA[0]]></total_sold_quantity>639 <user_nid><![CDATA[350400477]]></user_nid>640 <user_strid><![CDATA[4e1d00e029058aaa1e1d53e9abefcab4]]></user_strid>641 </fields>642 <property>643 </property>644 <sortExprValues>645 0.000210171646 </sortExprValues>647 </hit>648 <hit hash_id="2" docid="9139861">649 <fields>650 <biz30day><![CDATA[2]]></biz30day>651 <cat_id><![CDATA[50012584]]></cat_id>652 <comment0><![CDATA[不好意思这几天挺忙 确认晚了]]></comment0>653 <comment1><![CDATA[]]></comment1>654 <comment2><![CDATA[]]></comment2>655 <comment_num><![CDATA[1]]></comment_num>656 <comment_rate0><![CDATA[11]]></comment_rate0>657 <comment_rate1><![CDATA[]]></comment_rate1>658 <comment_rate2><![CDATA[]]></comment_rate2>659 <comment_user0><![CDATA[zgqskzhifubao]]></comment_user0>660 <comment_user1><![CDATA[]]></comment_user1>661 <comment_user2><![CDATA[]]></comment_user2>662 <commercial><![CDATA[0]]></commercial>663 <desp><![CDATA[<font color=red>Nokia</font>线充E65 E90 E95 N70充电器 N71 N72...]]></desp>664 <grade_avg><![CDATA[0]]></grade_avg>665 <nick><![CDATA[路过泉城]]></nick>666 <nid><![CDATA[6698634985]]></nid>667 <people_num><![CDATA[0]]></people_num>668 <pict_url><![CDATA[i2/T105xGXlNqXXbUsE6b_095528.jpg]]></pict_url>669 <pid><![CDATA[23615829]]></pid>670 <pidvidt><![CDATA[]]></pidvidt>671 <product_num><![CDATA[6405]]></product_num>672 <ratesum><![CDATA[9]]></ratesum>673 <reserve_price><![CDATA[8]]></reserve_price>674 <seller_goodrate><![CDATA[9587]]></seller_goodrate>675 <title><![CDATA[<font color=red>Nokia</font>线充E65 E90 E95 N70充电器 N71 N72线充 N73线充]]></title>676 <total_sold_quantity><![CDATA[6]]></total_sold_quantity>677 <user_nid><![CDATA[117818253]]></user_nid>678 <user_strid><![CDATA[19d4a11e148c07ee3288ab9d96378482]]></user_strid>679 </fields>680 <property>681 </property>682 <sortExprValues>683 0.000210171684 </sortExprValues>685 </hit>686 <hit hash_id="3" docid="9137643">687 <fields>688 <biz30day><![CDATA[1]]></biz30day>689 <cat_id><![CDATA[50010614]]></cat_id>690 <comment0><![CDATA[]]></comment0>691 <comment1><![CDATA[]]></comment1>692 <comment2><![CDATA[]]></comment2>693 <comment_num><![CDATA[0]]></comment_num>694 <comment_rate0><![CDATA[]]></comment_rate0>695 <comment_rate1><![CDATA[]]></comment_rate1>696 <comment_rate2><![CDATA[]]></comment_rate2>697 <comment_user0><![CDATA[]]></comment_user0>698 <comment_user1><![CDATA[]]></comment_user1>699 <comment_user2><![CDATA[]]></comment_user2>700 <commercial><![CDATA[0]]></commercial>701 <desp><![CDATA[产品描述:蓝特(LT)<font color=red>Nokia</font>/诺基亚 3610A/...]]></desp>702 <grade_avg><![CDATA[0]]></grade_avg>703 <nick><![CDATA[杨惠茸]]></nick>704 <nid><![CDATA[6817724341]]></nid>705 <people_num><![CDATA[0]]></people_num>706 <pict_url><![CDATA[i3/T16vtHXdhfXXakivg0_035148.jpg]]></pict_url>707 <pid><![CDATA[-6817724341]]></pid>708 <pidvidt><![CDATA[]]></pidvidt>709 <product_num><![CDATA[0]]></product_num>710 <ratesum><![CDATA[3]]></ratesum>711 <reserve_price><![CDATA[20]]></reserve_price>712 <seller_goodrate><![CDATA[9655]]></seller_goodrate>713 <title><![CDATA[蓝特(LT)<font color=red>Nokia</font>/诺基亚3610A/6555带座排线]]></title>714 <total_sold_quantity><![CDATA[1]]></total_sold_quantity>715 <user_nid><![CDATA[436855978]]></user_nid>716 <user_strid><![CDATA[4b9ad1c3c7f405847c2a47815ffc08c6]]></user_strid>717 </fields>718 <property>719 </property>720 <sortExprValues>721 0.000210171722 </sortExprValues>723 </hit>724 <hit hash_id="0" docid="9128114">725 <fields>726 <biz30day><![CDATA[1]]></biz30day>727 <cat_id><![CDATA[1512]]></cat_id>728 <comment0><![CDATA[这个颜色非常漂亮,喜欢,老板服务不错,还给我安装...]]></comment0>729 <comment1><![CDATA[颜色很好看,老板还送了好多礼品,还包邮!是我在...]]></comment1>730 <comment2><![CDATA[发货很快,手机很喜欢,这个颜色很不错!老板人很...]]></comment2>731 <comment_num><![CDATA[7]]></comment_num>732 <comment_rate0><![CDATA[4]]></comment_rate0>733 <comment_rate1><![CDATA[4]]></comment_rate1>734 <comment_rate2><![CDATA[4]]></comment_rate2>735 <comment_user0><![CDATA[亲爱的囡囡88]]></comment_user0>736 <comment_user1><![CDATA[晴天妹妹8]]></comment_user1>737 <comment_user2><![CDATA[狗儿们的窝]]></comment_user2>738 <commercial><![CDATA[0]]></commercial>739 <desp><![CDATA[----------------------------------------...]]></desp>740 <grade_avg><![CDATA[0]]></grade_avg>741 <nick><![CDATA[萍萍一站式购物]]></nick>742 <nid><![CDATA[6722451228]]></nid>743 <people_num><![CDATA[0]]></people_num>744 <pict_url><![CDATA[i3/T15rpDXelyXXbTA4gV_020655.jpg]]></pict_url>745 <pid><![CDATA[72468326]]></pid>746 <pidvidt><![CDATA[]]></pidvidt>747 <product_num><![CDATA[7382]]></product_num>748 <ratesum><![CDATA[9]]></ratesum>749 <reserve_price><![CDATA[1280]]></reserve_price>750 <seller_goodrate><![CDATA[9972]]></seller_goodrate>751 <title><![CDATA[【桔子通讯】<font color=red>Nokia</font>/诺基亚6700S/Slide 智能机港行 红蓝紫粉绿银]]></title>752 <total_sold_quantity><![CDATA[4]]></total_sold_quantity>753 <user_nid><![CDATA[279716453]]></user_nid>754 <user_strid><![CDATA[95604865bdd3499532e79eec4e399401]]></user_strid>755 </fields>756 <property>757 </property>758 <sortExprValues>759 0.000210171760 </sortExprValues>761 </hit>762 <hit hash_id="1" docid="9124486">763 <fields>764 <biz30day><![CDATA[1]]></biz30day>765 <cat_id><![CDATA[150704]]></cat_id>766 <comment0><![CDATA[做工还成。但是的确偏大不少]]></comment0>767 <comment1><![CDATA[很不错的宝贝 很满意]]></comment1>768 <comment2><![CDATA[赞一个]]></comment2>769 <comment_num><![CDATA[3]]></comment_num>770 <comment_rate0><![CDATA[501]]></comment_rate0>771 <comment_rate1><![CDATA[4]]></comment_rate1>772 <comment_rate2><![CDATA[91]]></comment_rate2>773 <comment_user0><![CDATA[gegega]]></comment_user0>774 <comment_user1><![CDATA[熊熊爱吃饭]]></comment_user1>775 <comment_user2><![CDATA[小晴1799]]></comment_user2>776 <commercial><![CDATA[0]]></commercial>777 <desp><![CDATA[----------------------------------------...]]></desp>778 <grade_avg><![CDATA[0]]></grade_avg>779 <nick><![CDATA[baiyun数码]]></nick>780 <nid><![CDATA[6219039792]]></nid>781 <people_num><![CDATA[0]]></people_num>782 <pict_url><![CDATA[i1/T1RfpFXaFjXXbqLRM3_050811.jpg]]></pict_url>783 <pid><![CDATA[73686392]]></pid>784 <pidvidt><![CDATA[]]></pidvidt>785 <product_num><![CDATA[662]]></product_num>786 <ratesum><![CDATA[9]]></ratesum>787 <reserve_price><![CDATA[47]]></reserve_price>788 <seller_goodrate><![CDATA[10000]]></seller_goodrate>789 <title><![CDATA[澳洲PDair炫彩多色 <font color=red>Nokia</font> n97mini 硅胶套 品质之选 红色]]></title>790 <total_sold_quantity><![CDATA[9]]></total_sold_quantity>791 <user_nid><![CDATA[212478869]]></user_nid>792 <user_strid><![CDATA[f3327a1de93bee4398481d69f08b08e3]]></user_strid>793 </fields>794 <property>795 </property>796 <sortExprValues>797 0.000210171798 </sortExprValues>799 </hit>800 <hit hash_id="0" docid="9122611">801 <fields>802 <biz30day><![CDATA[2]]></biz30day>803 <cat_id><![CDATA[50012587]]></cat_id>804 <comment0><![CDATA[老板很厚道...]]></comment0>805 <comment1><![CDATA[老板依然厚道!]]></comment1>806 <comment2><![CDATA[]]></comment2>807 <comment_num><![CDATA[2]]></comment_num>808 <comment_rate0><![CDATA[11]]></comment_rate0>809 <comment_rate1><![CDATA[11]]></comment_rate1>810 <comment_rate2><![CDATA[]]></comment_rate2>811 <comment_user0><![CDATA[獨y無贰]]></comment_user0>812 <comment_user1><![CDATA[獨y無贰]]></comment_user1>813 <comment_user2><![CDATA[]]></comment_user2>814 <commercial><![CDATA[0]]></commercial>815 <desp><![CDATA[使用说明:8161、第一步清洁屏幕,用附赠的...]]></desp>817 <grade_avg><![CDATA[0]]></grade_avg>818 <nick><![CDATA[讨厌平安夜]]></nick>819 <nid><![CDATA[6818006011]]></nid>820 <people_num><![CDATA[0]]></people_num>821 <pict_url><![CDATA[i6/T1tUppXh0aXXbLmTo8_102003.jpg]]></pict_url>822 <pid><![CDATA[80427683]]></pid>823 <pidvidt><![CDATA[]]></pidvidt>824 <product_num><![CDATA[0]]></product_num>825 <ratesum><![CDATA[3]]></ratesum>826 <reserve_price><![CDATA[68]]></reserve_price>827 <seller_goodrate><![CDATA[10000]]></seller_goodrate>828 <title><![CDATA[阿迪普手机膜专家-<font color=red>NOKIA</font>诺基亚 5230 幻彩钻石系列套装]]></title>829 <total_sold_quantity><![CDATA[2]]></total_sold_quantity>830 <user_nid><![CDATA[56983709]]></user_nid>831 <user_strid><![CDATA[71f84a0915e9062e30df53c960641f21]]></user_strid>832 </fields>833 <property>834 </property>835 <sortExprValues>836 0.000210171837 </sortExprValues>838 </hit>839</hits>840<AggregateResults>841</AggregateResults>842<Error>843 <ErrorCode>0</ErrorCode>844 <ErrorDescription></ErrorDescription>845</Error>846</Root>847'''848 if len(sys.argv) < 3:849 print >> sys.stderr, 'Usage: %s <servie_name> <queryfile>'850 sys.exit(1)851 srvn = sys.argv[1]852 qfn = sys.argv[2]853 854 cmper = QueryResComp(srvn)855 f = open(qfn)856 try:857 for qstr in f:858 cmper.fetchResult(qstr)859 # if not cmper.isEqual():860 # print qstr861 break862 finally:863 f.close()...

Full Screen

Full Screen

multiline-comment-style.js

Source:multiline-comment-style.js Github

copy

Full Screen

1/**2 * @fileoverview enforce a particular style for multiline comments3 * @author Teddy Katz4 */5"use strict";6const astUtils = require("./utils/ast-utils");7//------------------------------------------------------------------------------8// Rule Definition9//------------------------------------------------------------------------------10module.exports = {11 meta: {12 type: "suggestion",13 docs: {14 description: "enforce a particular style for multiline comments",15 category: "Stylistic Issues",16 recommended: false,17 url: "https://eslint.org/docs/rules/multiline-comment-style"18 },19 fixable: "whitespace",20 schema: [{ enum: ["starred-block", "separate-lines", "bare-block"] }],21 messages: {22 expectedBlock: "Expected a block comment instead of consecutive line comments.",23 expectedBareBlock: "Expected a block comment without padding stars.",24 startNewline: "Expected a linebreak after '/*'.",25 endNewline: "Expected a linebreak before '*/'.",26 missingStar: "Expected a '*' at the start of this line.",27 alignment: "Expected this line to be aligned with the start of the comment.",28 expectedLines: "Expected multiple line comments instead of a block comment."29 }30 },31 create(context) {32 const sourceCode = context.getSourceCode();33 const option = context.options[0] || "starred-block";34 //----------------------------------------------------------------------35 // Helpers36 //----------------------------------------------------------------------37 /**38 * Checks if a comment line is starred.39 * @param {string} line A string representing a comment line.40 * @returns {boolean} Whether or not the comment line is starred.41 */42 function isStarredCommentLine(line) {43 return /^\s*\*/u.test(line);44 }45 /**46 * Checks if a comment group is in starred-block form.47 * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment.48 * @returns {boolean} Whether or not the comment group is in starred block form.49 */50 function isStarredBlockComment([firstComment]) {51 if (firstComment.type !== "Block") {52 return false;53 }54 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER);55 // The first and last lines can only contain whitespace.56 return lines.length > 0 && lines.every((line, i) => (i === 0 || i === lines.length - 1 ? /^\s*$/u : /^\s*\*/u).test(line));57 }58 /**59 * Checks if a comment group is in JSDoc form.60 * @param {Token[]} commentGroup A group of comments, containing either multiple line comments or a single block comment.61 * @returns {boolean} Whether or not the comment group is in JSDoc form.62 */63 function isJSDocComment([firstComment]) {64 if (firstComment.type !== "Block") {65 return false;66 }67 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER);68 return /^\*\s*$/u.test(lines[0]) &&69 lines.slice(1, -1).every(line => /^\s* /u.test(line)) &&70 /^\s*$/u.test(lines[lines.length - 1]);71 }72 /**73 * Processes a comment group that is currently in separate-line form, calculating the offset for each line.74 * @param {Token[]} commentGroup A group of comments containing multiple line comments.75 * @returns {string[]} An array of the processed lines.76 */77 function processSeparateLineComments(commentGroup) {78 const allLinesHaveLeadingSpace = commentGroup79 .map(({ value }) => value)80 .filter(line => line.trim().length)81 .every(line => line.startsWith(" "));82 return commentGroup.map(({ value }) => (allLinesHaveLeadingSpace ? value.replace(/^ /u, "") : value));83 }84 /**85 * Processes a comment group that is currently in starred-block form, calculating the offset for each line.86 * @param {Token} comment A single block comment token in starred-block form.87 * @returns {string[]} An array of the processed lines.88 */89 function processStarredBlockComment(comment) {90 const lines = comment.value.split(astUtils.LINEBREAK_MATCHER)91 .filter((line, i, linesArr) => !(i === 0 || i === linesArr.length - 1))92 .map(line => line.replace(/^\s*$/u, ""));93 const allLinesHaveLeadingSpace = lines94 .map(line => line.replace(/\s*\*/u, ""))95 .filter(line => line.trim().length)96 .every(line => line.startsWith(" "));97 return lines.map(line => line.replace(allLinesHaveLeadingSpace ? /\s*\* ?/u : /\s*\*/u, ""));98 }99 /**100 * Processes a comment group that is currently in bare-block form, calculating the offset for each line.101 * @param {Token} comment A single block comment token in bare-block form.102 * @returns {string[]} An array of the processed lines.103 */104 function processBareBlockComment(comment) {105 const lines = comment.value.split(astUtils.LINEBREAK_MATCHER).map(line => line.replace(/^\s*$/u, ""));106 const leadingWhitespace = `${sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0])} `;107 let offset = "";108 /*109 * Calculate the offset of the least indented line and use that as the basis for offsetting all the lines.110 * The first line should not be checked because it is inline with the opening block comment delimiter.111 */112 for (const [i, line] of lines.entries()) {113 if (!line.trim().length || i === 0) {114 continue;115 }116 const [, lineOffset] = line.match(/^(\s*\*?\s*)/u);117 if (lineOffset.length < leadingWhitespace.length) {118 const newOffset = leadingWhitespace.slice(lineOffset.length - leadingWhitespace.length);119 if (newOffset.length > offset.length) {120 offset = newOffset;121 }122 }123 }124 return lines.map(line => {125 const match = line.match(/^(\s*\*?\s*)(.*)/u);126 const [, lineOffset, lineContents] = match;127 if (lineOffset.length > leadingWhitespace.length) {128 return `${lineOffset.slice(leadingWhitespace.length - (offset.length + lineOffset.length))}${lineContents}`;129 }130 if (lineOffset.length < leadingWhitespace.length) {131 return `${lineOffset.slice(leadingWhitespace.length)}${lineContents}`;132 }133 return lineContents;134 });135 }136 /**137 * Gets a list of comment lines in a group, formatting leading whitespace as necessary.138 * @param {Token[]} commentGroup A group of comments containing either multiple line comments or a single block comment.139 * @returns {string[]} A list of comment lines.140 */141 function getCommentLines(commentGroup) {142 const [firstComment] = commentGroup;143 if (firstComment.type === "Line") {144 return processSeparateLineComments(commentGroup);145 }146 if (isStarredBlockComment(commentGroup)) {147 return processStarredBlockComment(firstComment);148 }149 return processBareBlockComment(firstComment);150 }151 /**152 * Gets the initial offset (whitespace) from the beginning of a line to a given comment token.153 * @param {Token} comment The token to check.154 * @returns {string} The offset from the beginning of a line to the token.155 */156 function getInitialOffset(comment) {157 return sourceCode.text.slice(comment.range[0] - comment.loc.start.column, comment.range[0]);158 }159 /**160 * Converts a comment into starred-block form161 * @param {Token} firstComment The first comment of the group being converted162 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment163 * @returns {string} A representation of the comment value in starred-block form, excluding start and end markers164 */165 function convertToStarredBlock(firstComment, commentLinesList) {166 const initialOffset = getInitialOffset(firstComment);167 return `/*\n${commentLinesList.map(line => `${initialOffset} * ${line}`).join("\n")}\n${initialOffset} */`;168 }169 /**170 * Converts a comment into separate-line form171 * @param {Token} firstComment The first comment of the group being converted172 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment173 * @returns {string} A representation of the comment value in separate-line form174 */175 function convertToSeparateLines(firstComment, commentLinesList) {176 return commentLinesList.map(line => `// ${line}`).join(`\n${getInitialOffset(firstComment)}`);177 }178 /**179 * Converts a comment into bare-block form180 * @param {Token} firstComment The first comment of the group being converted181 * @param {string[]} commentLinesList A list of lines to appear in the new starred-block comment182 * @returns {string} A representation of the comment value in bare-block form183 */184 function convertToBlock(firstComment, commentLinesList) {185 return `/* ${commentLinesList.join(`\n${getInitialOffset(firstComment)} `)} */`;186 }187 /**188 * Each method checks a group of comments to see if it's valid according to the given option.189 * @param {Token[]} commentGroup A list of comments that appear together. This will either contain a single190 * block comment or multiple line comments.191 * @returns {void}192 */193 const commentGroupCheckers = {194 "starred-block"(commentGroup) {195 const [firstComment] = commentGroup;196 const commentLines = getCommentLines(commentGroup);197 if (commentLines.some(value => value.includes("*/"))) {198 return;199 }200 if (commentGroup.length > 1) {201 context.report({202 loc: {203 start: firstComment.loc.start,204 end: commentGroup[commentGroup.length - 1].loc.end205 },206 messageId: "expectedBlock",207 fix(fixer) {208 const range = [firstComment.range[0], commentGroup[commentGroup.length - 1].range[1]];209 return commentLines.some(value => value.startsWith("/"))210 ? null211 : fixer.replaceTextRange(range, convertToStarredBlock(firstComment, commentLines));212 }213 });214 } else {215 const lines = firstComment.value.split(astUtils.LINEBREAK_MATCHER);216 const expectedLeadingWhitespace = getInitialOffset(firstComment);217 const expectedLinePrefix = `${expectedLeadingWhitespace} *`;218 if (!/^\*?\s*$/u.test(lines[0])) {219 const start = firstComment.value.startsWith("*") ? firstComment.range[0] + 1 : firstComment.range[0];220 context.report({221 loc: {222 start: firstComment.loc.start,223 end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 }224 },225 messageId: "startNewline",226 fix: fixer => fixer.insertTextAfterRange([start, start + 2], `\n${expectedLinePrefix}`)227 });228 }229 if (!/^\s*$/u.test(lines[lines.length - 1])) {230 context.report({231 loc: {232 start: { line: firstComment.loc.end.line, column: firstComment.loc.end.column - 2 },233 end: firstComment.loc.end234 },235 messageId: "endNewline",236 fix: fixer => fixer.replaceTextRange([firstComment.range[1] - 2, firstComment.range[1]], `\n${expectedLinePrefix}/`)237 });238 }239 for (let lineNumber = firstComment.loc.start.line + 1; lineNumber <= firstComment.loc.end.line; lineNumber++) {240 const lineText = sourceCode.lines[lineNumber - 1];241 const errorType = isStarredCommentLine(lineText)242 ? "alignment"243 : "missingStar";244 if (!lineText.startsWith(expectedLinePrefix)) {245 context.report({246 loc: {247 start: { line: lineNumber, column: 0 },248 end: { line: lineNumber, column: lineText.length }249 },250 messageId: errorType,251 fix(fixer) {252 const lineStartIndex = sourceCode.getIndexFromLoc({ line: lineNumber, column: 0 });253 if (errorType === "alignment") {254 const [, commentTextPrefix = ""] = lineText.match(/^(\s*\*)/u) || [];255 const commentTextStartIndex = lineStartIndex + commentTextPrefix.length;256 return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], expectedLinePrefix);257 }258 const [, commentTextPrefix = ""] = lineText.match(/^(\s*)/u) || [];259 const commentTextStartIndex = lineStartIndex + commentTextPrefix.length;260 let offset;261 for (const [idx, line] of lines.entries()) {262 if (!/\S+/u.test(line)) {263 continue;264 }265 const lineTextToAlignWith = sourceCode.lines[firstComment.loc.start.line - 1 + idx];266 const [, prefix = "", initialOffset = ""] = lineTextToAlignWith.match(/^(\s*(?:\/?\*)?(\s*))/u) || [];267 offset = `${commentTextPrefix.slice(prefix.length)}${initialOffset}`;268 if (/^\s*\//u.test(lineText) && offset.length === 0) {269 offset += " ";270 }271 break;272 }273 return fixer.replaceTextRange([lineStartIndex, commentTextStartIndex], `${expectedLinePrefix}${offset}`);274 }275 });276 }277 }278 }279 },280 "separate-lines"(commentGroup) {281 const [firstComment] = commentGroup;282 if (firstComment.type !== "Block" || isJSDocComment(commentGroup)) {283 return;284 }285 const commentLines = getCommentLines(commentGroup);286 const tokenAfter = sourceCode.getTokenAfter(firstComment, { includeComments: true });287 if (tokenAfter && firstComment.loc.end.line === tokenAfter.loc.start.line) {288 return;289 }290 context.report({291 loc: {292 start: firstComment.loc.start,293 end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 }294 },295 messageId: "expectedLines",296 fix(fixer) {297 return fixer.replaceText(firstComment, convertToSeparateLines(firstComment, commentLines));298 }299 });300 },301 "bare-block"(commentGroup) {302 if (isJSDocComment(commentGroup)) {303 return;304 }305 const [firstComment] = commentGroup;306 const commentLines = getCommentLines(commentGroup);307 // Disallows consecutive line comments in favor of using a block comment.308 if (firstComment.type === "Line" && commentLines.length > 1 &&309 !commentLines.some(value => value.includes("*/"))) {310 context.report({311 loc: {312 start: firstComment.loc.start,313 end: commentGroup[commentGroup.length - 1].loc.end314 },315 messageId: "expectedBlock",316 fix(fixer) {317 return fixer.replaceTextRange(318 [firstComment.range[0], commentGroup[commentGroup.length - 1].range[1]],319 convertToBlock(firstComment, commentLines)320 );321 }322 });323 }324 // Prohibits block comments from having a * at the beginning of each line.325 if (isStarredBlockComment(commentGroup)) {326 context.report({327 loc: {328 start: firstComment.loc.start,329 end: { line: firstComment.loc.start.line, column: firstComment.loc.start.column + 2 }330 },331 messageId: "expectedBareBlock",332 fix(fixer) {333 return fixer.replaceText(firstComment, convertToBlock(firstComment, commentLines));334 }335 });336 }337 }338 };339 //----------------------------------------------------------------------340 // Public341 //----------------------------------------------------------------------342 return {343 Program() {344 return sourceCode.getAllComments()345 .filter(comment => comment.type !== "Shebang")346 .filter(comment => !astUtils.COMMENTS_IGNORE_PATTERN.test(comment.value))347 .filter(comment => {348 const tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true });349 return !tokenBefore || tokenBefore.loc.end.line < comment.loc.start.line;350 })351 .reduce((commentGroups, comment, index, commentList) => {352 const tokenBefore = sourceCode.getTokenBefore(comment, { includeComments: true });353 if (354 comment.type === "Line" &&355 index && commentList[index - 1].type === "Line" &&356 tokenBefore && tokenBefore.loc.end.line === comment.loc.start.line - 1 &&357 tokenBefore === commentList[index - 1]358 ) {359 commentGroups[commentGroups.length - 1].push(comment);360 } else {361 commentGroups.push([comment]);362 }363 return commentGroups;364 }, [])365 .filter(commentGroup => !(commentGroup.length === 1 && commentGroup[0].loc.start.line === commentGroup[0].loc.end.line))366 .forEach(commentGroupCheckers[option]);367 }368 };369 }...

Full Screen

Full Screen

moderation.py

Source:moderation.py Github

copy

Full Screen

1from __future__ import absolute_import2from django import template3from django.conf import settings4from django.contrib.auth.decorators import login_required, permission_required5from django.shortcuts import get_object_or_404, render_to_response6from django.views.decorators.csrf import csrf_protect7import annotations8from annotation import signals9from annotation.views.utils import next_redirect, confirmation_view10@csrf_protect11@permission_required("annotations.can_moderate")12def delete(request, comment_id, next=None):13 """14 Deletes a comment. Confirmation on GET, action on POST. Requires the "can15 moderate comments" permission.16 Templates: :template:`comments/delete.html`,17 Context:18 comment19 the flagged `comments.comment` object20 """21 comment = get_object_or_404(annotations.get_model(), pk=comment_id, site__pk=settings.SITE_ID)22 # Delete on POST23 if request.method == 'POST':24 # Flag the comment as deleted instead of actually deleting it.25 perform_delete(request, comment)26 return next_redirect(request, fallback=next or 'annotations-delete-done',27 c=comment.pk)28 # Render a form on GET29 else:30 return render_to_response('annotations/delete.html',31 {'body': comment, "next": next},32 template.RequestContext(request)33 )34@csrf_protect35@permission_required("annotations.can_moderate")36def approve(request, comment_id, next=None):37 """38 Approve a comment (that is, mark it as public and non-removed). Confirmation39 on GET, action on POST. Requires the "can moderate comments" permission.40 Templates: :template:`comments/approve.html`,41 Context:42 body43 the `annotations.annotations` object for approval44 """45 comment = get_object_or_404(annotations.get_model(), pk=comment_id, site__pk=settings.SITE_ID)46 # Delete on POST47 if request.method == 'POST':48 # Flag the comment as approved.49 perform_approve(request, comment)50 return next_redirect(request, fallback=next or 'annotations-approve-done',51 c=comment.pk)52 # Render a form on GET53 else:54 return render_to_response('annotations/approve.html',55 {'body': comment, "next": next},56 template.RequestContext(request)57 )58# The following functions actually perform the various flag/aprove/delete59# actions. They've been broken out into separate functions to that they60# may be called from admin actions.61def perform_flag(request, comment):62 """63 Actually perform the flagging of a comment from a request.64 """65 pass66 '''67 flag, created = django_comments.models.CommentFlag.objects.get_or_create(68 comment = comment,69 user = request.user,70 flag = django_comments.models.CommentFlag.SUGGEST_REMOVAL71 )72 signals.comment_was_flagged.send(73 sender = comment.__class__,74 comment = comment,75 flag = flag,76 created = created,77 request = request,78 )79 '''80#TODO: There will be a central actions table which performs actions, or at least81#records all actions in the framework. The apps may not, internally create such localized 82#tables.83def perform_delete(request, comment):84 '''85 flag, created = annotations.models.CommentFlag.objects.get_or_create(86 comment = comment,87 user = request.user,88 flag = annotations.models.CommentFlag.MODERATOR_DELETION89 )90 '''91 #comment.is_removed = True92 comment.save()93 '''94 signals.comment_was_flagged.send(95 sender = comment.__class__,96 comment = comment,97 flag = flag,98 created = created,99 request = request,100 )101 '''102def perform_approve(request, comment):103 '''104 flag, created = django_comments.models.CommentFlag.objects.get_or_create(105 comment = comment,106 user = request.user,107 flag = django_comments.models.CommentFlag.MODERATOR_APPROVAL,108 )109 '''110 comment.is_removed = False111 comment.is_public = True112 comment.save()113 '''114 signals.comment_was_flagged.send(115 sender = comment.__class__,116 comment = comment,117 flag = flag,118 created = created,119 request = request,120 )121 '''122# Confirmation views.123'''124flag_done = confirmation_view(125 template = "comments/flagged.html",126 doc = 'Displays a "comment was flagged" success page.'127)128'''129delete_done = confirmation_view(130 template = "comments/deleted.html",131 doc = 'Displays a "comment was deleted" success page.'132)133approve_done = confirmation_view(134 template = "comments/approved.html",135 doc = 'Displays a "comment was approved" success page.'...

Full Screen

Full Screen

Comment.jsx

Source:Comment.jsx Github

copy

Full Screen

1import React from "react";2import CommentForm from "./CommentForm";3import "../../styles/Scars/_Comment.scss";4const Comment = ({5 comment,6 replies,7 setActiveComment,8 activeComment,9 updateComment,10 deleteComment,11 addComment,12 parentId = null,13 currentUserId,14}) => {15 const isEditing =16 activeComment &&17 activeComment.id === comment.id &&18 activeComment.type === "editing";19 const isReplying =20 activeComment &&21 activeComment.id === comment.id &&22 activeComment.type === "replying";23 const fiveMinutes = 300000;24 const timePassed = new Date() - new Date(comment.createdAt) > fiveMinutes;25 const canDelete =26 currentUserId === comment.userId && replies.length === 0 && !timePassed;27 const canReply = Boolean(currentUserId);28 const canEdit = currentUserId === comment.userId && !timePassed;29 const replyId = parentId ? parentId : comment.id;30 const createdAt = new Date(comment.createdAt).toLocaleDateString();31 return (32 <div key={comment.id} className="comment">33 <div className="comment-image-container">34 <img src="https://img1.kienthucvui.vn/uploads/2021/01/09/anh-dai-dien-cho-con-gai-dep-dang-yeu_043116580.jpeg" />35 </div>36 <div className="comment-right-part">37 <div className="comment-content">38 <div className="comment-author">{comment.username}</div>39 <div>{createdAt}</div>40 </div>41 {!isEditing && <div className="comment-text">{comment.body}</div>}42 {isEditing && (43 <CommentForm44 submitLabel="Update"45 hasCancelButton46 initialText={comment.body}47 handleSubmit={(text) => updateComment(text, comment.id)}48 handleCancel={() => {49 setActiveComment(null);50 }}51 />52 )}53 <div className="comment-actions">54 {canReply && (55 <div56 className="comment-action"57 onClick={() =>58 setActiveComment({ id: comment.id, type: "replying" })59 }60 >61 trả lời62 </div>63 )}64 {canEdit && (65 <div66 className="comment-action"67 onClick={() =>68 setActiveComment({ id: comment.id, type: "editing" })69 }70 >71 sửa72 </div>73 )}74 {canDelete && (75 <div76 className="comment-action"77 onClick={() => deleteComment(comment.id)}78 >79 xóa80 </div>81 )}82 </div>83 {isReplying && (84 <CommentForm85 submitLabel="Reply"86 handleSubmit={(text) => addComment(text, replyId)}87 />88 )}89 {replies.length > 0 && (90 <div className="replies">91 {replies.map((reply) => (92 <Comment93 comment={reply}94 key={reply.id}95 setActiveComment={setActiveComment}96 activeComment={activeComment}97 updateComment={updateComment}98 deleteComment={deleteComment}99 addComment={addComment}100 parentId={comment.id}101 replies={[]}102 currentUserId={currentUserId}103 />104 ))}105 </div>106 )}107 </div>108 </div>109 );110};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org');3 if (err) return console.error(err);4 console.log(data);5 api.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8 });9});10var wpt = require('webpagetest');11var api = new wpt('www.webpagetest.org');12 if (err) return console.error(err);13 console.log(data);14 api.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data);17 });18});19var wpt = require('webpagetest');20var api = new wpt('www.webpagetest.org');21 if (err) return console.error(err);22 console.log(data);23 api.getTestResults(data.data.testId, function(err, data) {24 if (err) return console.error(err);25 console.log(data);26 });27});28var wpt = require('webpagetest');29var api = new wpt('www.webpagetest.org');30 if (err) return console.error(err);31 console.log(data);32 api.getTestResults(data.data.testId, function(err, data) {33 if (err) return console.error(err);34 console.log(data);35 });36});37var wpt = require('webpagetest');38var api = new wpt('www.webpagetest.org');39 if (err) return console.error(err);40 console.log(data);41 api.getTestResults(data.data.testId, function(err, data) {42 if (err) return console.error(err);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest('www.google.com', {location: 'Dulles:Chrome'}, function(err, data) {4 if (err) return console.error(err);5 wpt.getTestResults(data.data.testId, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8 });9});10var wpt = require('webpagetest');11var wpt = new WebPageTest('www.webpagetest.org');12wpt.runTest('www.google.com', {location: 'Dulles:Chrome'}, function(err, data) {13 if (err) return console.error(err);14 wpt.getTestResults(data.data.testId, function(err, data) {15 if (err) return console.error(err);16 console.log(data);17 });18});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var test = new wpt('www.webpagetest.org');3test.runTest(url, function(err, data) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log('Test status: ' + data.statusText);8 console.log('Test ID: ' + data.data.testId);9 console.log('Test URL: ' + data.data.summary);10 test.comment(data.data.testId, 'This is a comment', function(err, data) {11 if (err) {12 console.log('Error: ' + err);13 } else {14 console.log('Comment: ' + data);15 }16 });17 }18});19var wpt = require('webpagetest');20var test = new wpt('www.webpagetest.org');21test.runTest(url, function(err, data) {22 if (err) {23 console.log('Error: ' + err);24 } else {25 console.log('Test status: ' + data.statusText);26 console.log('Test ID: ' + data.data.testId);27 console.log('Test URL: ' + data.data.summary);28 test.comment(data.data.testId, 'This is a comment', function(err, data) {29 if (err) {30 console.log('Error: ' + err

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var client = wpt('www.webpagetest.org');3client.comment('Test comment', function(err, data) {4 if (err) {5 console.log('Error: ' + err);6 } else {7 console.log(data);8 }9});10var wpt = require('webpagetest');11var client = wpt('www.webpagetest.org');12client.getLocations(function(err, data) {13 if (err) {14 console.log('Error: ' + err);15 } else {16 console.log(data);17 }18});19var wpt = require('webpagetest');20var client = wpt('www.webpagetest.org');21client.getTesters(function(err, data) {22 if (err) {23 console.log('Error: ' + err);24 } else {25 console.log(data);26 }27});28var wpt = require('webpagetest');29var client = wpt('www.webpagetest.org');30client.getTesters(function(err, data) {31 if (err) {32 console.log('Error: ' + err);33 } else {34 console.log(data);35 }36});37var wpt = require('webpagetest');38var client = wpt('www.webpagetest.org');39client.getTesters(function(err, data) {40 if (err) {41 console.log('Error: ' + err);42 } else {43 console.log(data);44 }45});46var wpt = require('webpagetest');47var client = wpt('www.webpagetest.org');48client.getTesters(function(err, data) {49 if (err) {50 console.log('Error: ' + err);51 } else {52 console.log(data);53 }54});55var wpt = require('webpagetest');56var client = wpt('www.webpagetest.org');57client.getTesters(function(err, data

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful