How to use _score method in fMBT

Best Python code snippet using fMBT_python

jsonat_json2xml_test.py

Source:jsonat_json2xml_test.py Github

copy

Full Screen

1#!/usr/bin/python32import unittest3import atpic.jsonat_json2xml4class jsonat_test(unittest.TestCase):5 """USER legacy urls"""6 def test_parse(self):7 inputs=[8 (b'{"alex" : "madon", "inside" : {"in" : "out"} }',b'<DOC><alex>madon</alex><inside><in>out</in></inside></DOC>'),9 (b'{"took":8,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":420,"max_score":2.496926,"hits":[{"_index":"atpic","_type":"pic","_id":"2522728","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2522728",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2011-07-31T16:02:28.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-40",\n"make" : "NIKON CORPORATION",\n"focallength" : "300/10",\n"model" : "NIKON D40",\n"exposuretime" : "-66",\n"rand_0" : "-18574",\n"rand_1" : "1805",\n"rand_2" : "-12886",\n"rand_3" : "-24010",\n"rand_4" : "15693",\n"rand_5" : "-845",\n"rand_6" : "-24901",\n"rand_7" : "-26798",\n"rand_8" : "-8400",\n"rand_9" : "9171",\n"rand_10" : "-28422",\n"rand_11" : "22985",\n"rand_12" : "27670",\n"rand_13" : "14992",\n"rand_14" : "-14151",\n"rand_15" : "7973",\n"rand_16" : "15367",\n"rand_17" : "17211",\n"rand_18" : "-29267",\n"rand_19" : "-20593",\n"originalname" : "DSC_0738.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2523115","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2523115",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2012-03-25T19:25:24.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-36",\n"make" : "NIKON CORPORATION",\n"focallength" : "320/10",\n"model" : "NIKON D40",\n"exposuretime" : "-34",\n"rand_0" : "-13705",\n"rand_1" : "-8060",\n"rand_2" : "-32262",\n"rand_3" : "-27425",\n"rand_4" : "11501",\n"rand_5" : "16719",\n"rand_6" : "-4222",\n"rand_7" : "9328",\n"rand_8" : "-17006",\n"rand_9" : "-23658",\n"rand_10" : "-6909",\n"rand_11" : "29865",\n"rand_12" : "5624",\n"rand_13" : "-31535",\n"rand_14" : "-16685",\n"rand_15" : "3289",\n"rand_16" : "-11457",\n"rand_17" : "18588",\n"rand_18" : "-8968",\n"rand_19" : "-13980",\n"originalname" : "DSC_1326.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2523116","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2523116",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2012-03-25T19:25:27.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-36",\n"make" : "NIKON CORPORATION",\n"focallength" : "320/10",\n"model" : "NIKON D40",\n"exposuretime" : "-34",\n"rand_0" : "-18162",\n"rand_1" : "-19614",\n"rand_2" : "-7290",\n"rand_3" : "22630",\n"rand_4" : "-26317",\n"rand_5" : "31253",\n"rand_6" : "25967",\n"rand_7" : "-30470",\n"rand_8" : "-28935",\n"rand_9" : "-29212",\n"rand_10" : "-31268",\n"rand_11" : "-7789",\n"rand_12" : "-27539",\n"rand_13" : "16605",\n"rand_14" : "14811",\n"rand_15" : "7211",\n"rand_16" : "-11113",\n"rand_17" : "-30096",\n"rand_18" : "28843",\n"rand_19" : "-19654",\n"originalname" : "DSC_1327.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2522729","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2522729",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2011-07-31T16:02:35.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-36",\n"make" : "NIKON CORPORATION",\n"focallength" : "310/10",\n"model" : "NIKON D40",\n"exposuretime" : "-62",\n"rand_0" : "20405",\n"rand_1" : "5928",\n"rand_2" : "-10524",\n"rand_3" : "18971",\n"rand_4" : "6351",\n"rand_5" : "30555",\n"rand_6" : "15163",\n"rand_7" : "-8256",\n"rand_8" : "-14368",\n"rand_9" : "5398",\n"rand_10" : "24876",\n"rand_11" : "23187",\n"rand_12" : "22118",\n"rand_13" : "-8380",\n"rand_14" : "20430",\n"rand_15" : "3632",\n"rand_16" : "23687",\n"rand_17" : "17039",\n"rand_18" : "31660",\n"rand_19" : "12826",\n"originalname" : "DSC_0739.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2522730","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2522730",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2011-07-31T16:02:52.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "0",\n"make" : "NIKON CORPORATION",\n"focallength" : "460/10",\n"model" : "NIKON D40",\n"exposuretime" : "-58",\n"rand_0" : "5654",\n"rand_1" : "-10295",\n"rand_2" : "28732",\n"rand_3" : "-170",\n"rand_4" : "-2521",\n"rand_5" : "-1632",\n"rand_6" : "18030",\n"rand_7" : "611",\n"rand_8" : "-29637",\n"rand_9" : "17879",\n"rand_10" : "-9135",\n"rand_11" : "-25735",\n"rand_12" : "-32563",\n"rand_13" : "-11824",\n"rand_14" : "28474",\n"rand_15" : "13217",\n"rand_16" : "15143",\n"rand_17" : "-26060",\n"rand_18" : "13153",\n"rand_19" : "-32101",\n"originalname" : "DSC_0740.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2523117","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2523117",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2012-03-25T19:25:28.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-36",\n"make" : "NIKON CORPORATION",\n"focallength" : "320/10",\n"model" : "NIKON D40",\n"exposuretime" : "-34",\n"rand_0" : "-19458",\n"rand_1" : "-31013",\n"rand_2" : "6560",\n"rand_3" : "-12197",\n"rand_4" : "6011",\n"rand_5" : "-10417",\n"rand_6" : "23937",\n"rand_7" : "-32414",\n"rand_8" : "-25532",\n"rand_9" : "15545",\n"rand_10" : "7834",\n"rand_11" : "30738",\n"rand_12" : "-10547",\n"rand_13" : "-14504",\n"rand_14" : "-25458",\n"rand_15" : "-17676",\n"rand_16" : "-2948",\n"rand_17" : "-4756",\n"rand_18" : "25761",\n"rand_19" : "-3587",\n"originalname" : "DSC_1328.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2523118","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2523118",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2012-03-25T19:25:32.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-29",\n"make" : "NIKON CORPORATION",\n"focallength" : "380/10",\n"model" : "NIKON D40",\n"exposuretime" : "-34",\n"rand_0" : "409",\n"rand_1" : "14904",\n"rand_2" : "-11330",\n"rand_3" : "-14964",\n"rand_4" : "-13611",\n"rand_5" : "9931",\n"rand_6" : "-16368",\n"rand_7" : "17612",\n"rand_8" : "4736",\n"rand_9" : "14690",\n"rand_10" : "-2835",\n"rand_11" : "-25474",\n"rand_12" : "-11809",\n"rand_13" : "-9039",\n"rand_14" : "30323",\n"rand_15" : "6733",\n"rand_16" : "-28095",\n"rand_17" : "8144",\n"rand_18" : "-28813",\n"rand_19" : "-3152",\n"originalname" : "DSC_1330.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2522731","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2522731",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2011-07-31T16:05:29.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-22",\n"make" : "NIKON CORPORATION",\n"focallength" : "550/10",\n"model" : "NIKON D40",\n"exposuretime" : "-27",\n"rand_0" : "31109",\n"rand_1" : "-20371",\n"rand_2" : "13652",\n"rand_3" : "9601",\n"rand_4" : "-2765",\n"rand_5" : "-8475",\n"rand_6" : "-19808",\n"rand_7" : "-22026",\n"rand_8" : "-5801",\n"rand_9" : "-24145",\n"rand_10" : "23127",\n"rand_11" : "7163",\n"rand_12" : "11047",\n"rand_13" : "-5108",\n"rand_14" : "18214",\n"rand_15" : "29883",\n"rand_16" : "-7607",\n"rand_17" : "12135",\n"rand_18" : "-21118",\n"rand_19" : "22292",\n"originalname" : "DSC_0741.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2523119","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2523119",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2012-03-25T19:25:34.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-36",\n"make" : "NIKON CORPORATION",\n"focallength" : "310/10",\n"model" : "NIKON D40",\n"exposuretime" : "-34",\n"rand_0" : "5705",\n"rand_1" : "23826",\n"rand_2" : "-18394",\n"rand_3" : "11784",\n"rand_4" : "15776",\n"rand_5" : "-26873",\n"rand_6" : "8697",\n"rand_7" : "15222",\n"rand_8" : "2824",\n"rand_9" : "27326",\n"rand_10" : "-24079",\n"rand_11" : "13964",\n"rand_12" : "-18808",\n"rand_13" : "18779",\n"rand_14" : "20978",\n"rand_15" : "6105",\n"rand_16" : "399",\n"rand_17" : "16642",\n"rand_18" : "-12722",\n"rand_19" : "10826",\n"originalname" : "DSC_1331.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}},{"_index":"atpic","_type":"pic","_id":"2522732","_score":2.496926, "_source" : {\n"uid" : "1",\n"gid" : "49724",\n"pid" : "2522732",\n"username" : "Alex M",\n"servershort" : "alex",\n"popularity" : "0.000000000000000000000000000000",\n"price" : "0.000000000000000000000000000000",\n"mode" : "v",\n"friends" : ["2","3"],\n"tags" : [],\n"phrases" : ["nikond40"],\n"gtitle" : "nikond40",\n"ptitle" : "",\n"datetime" : "2011-07-31T16:05:36.000000Z",\n"mimetype" : "",\n"mimesubtype" : "",\n"aperture" : "-22",\n"make" : "NIKON CORPORATION",\n"focallength" : "550/10",\n"model" : "NIKON D40",\n"exposuretime" : "-51",\n"rand_0" : "-30368",\n"rand_1" : "-718",\n"rand_2" : "-5807",\n"rand_3" : "-24991",\n"rand_4" : "10149",\n"rand_5" : "18260",\n"rand_6" : "8443",\n"rand_7" : "-3341",\n"rand_8" : "-4418",\n"rand_9" : "-13762",\n"rand_10" : "24895",\n"rand_11" : "-5821",\n"rand_12" : "4862",\n"rand_13" : "-5450",\n"rand_14" : "-26564",\n"rand_15" : "-387",\n"rand_16" : "9533",\n"rand_17" : "16410",\n"rand_18" : "-9356",\n"rand_19" : "20205",\n"originalname" : "DSC_0742.JPG",\n"gpath" : "nikond40",\n"dir_0" : "/nikond40"\n}}]}}',b'<DOC><took>8</took><timed_out>False</timed_out><_shards><total>1</total><successful>1</successful><failed>0</failed></_shards><hits><total>420</total><max_score>2.496926</max_score><hits><_index>atpic</_index><_type>pic</_type><_id>2522728</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2522728</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2011-07-31T16:02:28.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-40</aperture><make>NIKON CORPORATION</make><focallength>300/10</focallength><model>NIKON D40</model><exposuretime>-66</exposuretime><rand_0>-18574</rand_0><rand_1>1805</rand_1><rand_2>-12886</rand_2><rand_3>-24010</rand_3><rand_4>15693</rand_4><rand_5>-845</rand_5><rand_6>-24901</rand_6><rand_7>-26798</rand_7><rand_8>-8400</rand_8><rand_9>9171</rand_9><rand_10>-28422</rand_10><rand_11>22985</rand_11><rand_12>27670</rand_12><rand_13>14992</rand_13><rand_14>-14151</rand_14><rand_15>7973</rand_15><rand_16>15367</rand_16><rand_17>17211</rand_17><rand_18>-29267</rand_18><rand_19>-20593</rand_19><originalname>DSC_0738.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523115</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2523115</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2012-03-25T19:25:24.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-36</aperture><make>NIKON CORPORATION</make><focallength>320/10</focallength><model>NIKON D40</model><exposuretime>-34</exposuretime><rand_0>-13705</rand_0><rand_1>-8060</rand_1><rand_2>-32262</rand_2><rand_3>-27425</rand_3><rand_4>11501</rand_4><rand_5>16719</rand_5><rand_6>-4222</rand_6><rand_7>9328</rand_7><rand_8>-17006</rand_8><rand_9>-23658</rand_9><rand_10>-6909</rand_10><rand_11>29865</rand_11><rand_12>5624</rand_12><rand_13>-31535</rand_13><rand_14>-16685</rand_14><rand_15>3289</rand_15><rand_16>-11457</rand_16><rand_17>18588</rand_17><rand_18>-8968</rand_18><rand_19>-13980</rand_19><originalname>DSC_1326.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523116</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2523116</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2012-03-25T19:25:27.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-36</aperture><make>NIKON CORPORATION</make><focallength>320/10</focallength><model>NIKON D40</model><exposuretime>-34</exposuretime><rand_0>-18162</rand_0><rand_1>-19614</rand_1><rand_2>-7290</rand_2><rand_3>22630</rand_3><rand_4>-26317</rand_4><rand_5>31253</rand_5><rand_6>25967</rand_6><rand_7>-30470</rand_7><rand_8>-28935</rand_8><rand_9>-29212</rand_9><rand_10>-31268</rand_10><rand_11>-7789</rand_11><rand_12>-27539</rand_12><rand_13>16605</rand_13><rand_14>14811</rand_14><rand_15>7211</rand_15><rand_16>-11113</rand_16><rand_17>-30096</rand_17><rand_18>28843</rand_18><rand_19>-19654</rand_19><originalname>DSC_1327.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522729</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2522729</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2011-07-31T16:02:35.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-36</aperture><make>NIKON CORPORATION</make><focallength>310/10</focallength><model>NIKON D40</model><exposuretime>-62</exposuretime><rand_0>20405</rand_0><rand_1>5928</rand_1><rand_2>-10524</rand_2><rand_3>18971</rand_3><rand_4>6351</rand_4><rand_5>30555</rand_5><rand_6>15163</rand_6><rand_7>-8256</rand_7><rand_8>-14368</rand_8><rand_9>5398</rand_9><rand_10>24876</rand_10><rand_11>23187</rand_11><rand_12>22118</rand_12><rand_13>-8380</rand_13><rand_14>20430</rand_14><rand_15>3632</rand_15><rand_16>23687</rand_16><rand_17>17039</rand_17><rand_18>31660</rand_18><rand_19>12826</rand_19><originalname>DSC_0739.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522730</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2522730</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2011-07-31T16:02:52.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>0</aperture><make>NIKON CORPORATION</make><focallength>460/10</focallength><model>NIKON D40</model><exposuretime>-58</exposuretime><rand_0>5654</rand_0><rand_1>-10295</rand_1><rand_2>28732</rand_2><rand_3>-170</rand_3><rand_4>-2521</rand_4><rand_5>-1632</rand_5><rand_6>18030</rand_6><rand_7>611</rand_7><rand_8>-29637</rand_8><rand_9>17879</rand_9><rand_10>-9135</rand_10><rand_11>-25735</rand_11><rand_12>-32563</rand_12><rand_13>-11824</rand_13><rand_14>28474</rand_14><rand_15>13217</rand_15><rand_16>15143</rand_16><rand_17>-26060</rand_17><rand_18>13153</rand_18><rand_19>-32101</rand_19><originalname>DSC_0740.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523117</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2523117</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2012-03-25T19:25:28.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-36</aperture><make>NIKON CORPORATION</make><focallength>320/10</focallength><model>NIKON D40</model><exposuretime>-34</exposuretime><rand_0>-19458</rand_0><rand_1>-31013</rand_1><rand_2>6560</rand_2><rand_3>-12197</rand_3><rand_4>6011</rand_4><rand_5>-10417</rand_5><rand_6>23937</rand_6><rand_7>-32414</rand_7><rand_8>-25532</rand_8><rand_9>15545</rand_9><rand_10>7834</rand_10><rand_11>30738</rand_11><rand_12>-10547</rand_12><rand_13>-14504</rand_13><rand_14>-25458</rand_14><rand_15>-17676</rand_15><rand_16>-2948</rand_16><rand_17>-4756</rand_17><rand_18>25761</rand_18><rand_19>-3587</rand_19><originalname>DSC_1328.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523118</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2523118</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2012-03-25T19:25:32.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-29</aperture><make>NIKON CORPORATION</make><focallength>380/10</focallength><model>NIKON D40</model><exposuretime>-34</exposuretime><rand_0>409</rand_0><rand_1>14904</rand_1><rand_2>-11330</rand_2><rand_3>-14964</rand_3><rand_4>-13611</rand_4><rand_5>9931</rand_5><rand_6>-16368</rand_6><rand_7>17612</rand_7><rand_8>4736</rand_8><rand_9>14690</rand_9><rand_10>-2835</rand_10><rand_11>-25474</rand_11><rand_12>-11809</rand_12><rand_13>-9039</rand_13><rand_14>30323</rand_14><rand_15>6733</rand_15><rand_16>-28095</rand_16><rand_17>8144</rand_17><rand_18>-28813</rand_18><rand_19>-3152</rand_19><originalname>DSC_1330.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522731</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2522731</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2011-07-31T16:05:29.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-22</aperture><make>NIKON CORPORATION</make><focallength>550/10</focallength><model>NIKON D40</model><exposuretime>-27</exposuretime><rand_0>31109</rand_0><rand_1>-20371</rand_1><rand_2>13652</rand_2><rand_3>9601</rand_3><rand_4>-2765</rand_4><rand_5>-8475</rand_5><rand_6>-19808</rand_6><rand_7>-22026</rand_7><rand_8>-5801</rand_8><rand_9>-24145</rand_9><rand_10>23127</rand_10><rand_11>7163</rand_11><rand_12>11047</rand_12><rand_13>-5108</rand_13><rand_14>18214</rand_14><rand_15>29883</rand_15><rand_16>-7607</rand_16><rand_17>12135</rand_17><rand_18>-21118</rand_18><rand_19>22292</rand_19><originalname>DSC_0741.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523119</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2523119</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2012-03-25T19:25:34.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-36</aperture><make>NIKON CORPORATION</make><focallength>310/10</focallength><model>NIKON D40</model><exposuretime>-34</exposuretime><rand_0>5705</rand_0><rand_1>23826</rand_1><rand_2>-18394</rand_2><rand_3>11784</rand_3><rand_4>15776</rand_4><rand_5>-26873</rand_5><rand_6>8697</rand_6><rand_7>15222</rand_7><rand_8>2824</rand_8><rand_9>27326</rand_9><rand_10>-24079</rand_10><rand_11>13964</rand_11><rand_12>-18808</rand_12><rand_13>18779</rand_13><rand_14>20978</rand_14><rand_15>6105</rand_15><rand_16>399</rand_16><rand_17>16642</rand_17><rand_18>-12722</rand_18><rand_19>10826</rand_19><originalname>DSC_1331.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522732</_id><_score>2.496926</_score><_source><uid>1</uid><gid>49724</gid><pid>2522732</pid><username>Alex M</username><servershort>alex</servershort><popularity>0.000000000000000000000000000000</popularity><price>0.000000000000000000000000000000</price><mode>v</mode><friends>2</friends><friends>3</friends><phrases>nikond40</phrases><gtitle>nikond40</gtitle><ptitle></ptitle><datetime>2011-07-31T16:05:36.000000Z</datetime><mimetype></mimetype><mimesubtype></mimesubtype><aperture>-22</aperture><make>NIKON CORPORATION</make><focallength>550/10</focallength><model>NIKON D40</model><exposuretime>-51</exposuretime><rand_0>-30368</rand_0><rand_1>-718</rand_1><rand_2>-5807</rand_2><rand_3>-24991</rand_3><rand_4>10149</rand_4><rand_5>18260</rand_5><rand_6>8443</rand_6><rand_7>-3341</rand_7><rand_8>-4418</rand_8><rand_9>-13762</rand_9><rand_10>24895</rand_10><rand_11>-5821</rand_11><rand_12>4862</rand_12><rand_13>-5450</rand_13><rand_14>-26564</rand_14><rand_15>-387</rand_15><rand_16>9533</rand_16><rand_17>16410</rand_17><rand_18>-9356</rand_18><rand_19>20205</rand_19><originalname>DSC_0742.JPG</originalname><gpath>nikond40</gpath><dir_0>/nikond40</dir_0></_source></hits></hits></DOC>'),10 (b'{"took":19,"timed_out":false,"_shards":{"total":1,"successful":1,"failed":0},"hits":{"total":420,"max_score":2.5319257,"hits":[{"_index":"atpic","_type":"pic","_id":"2523090","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2522704","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2523091","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2523092","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2522705","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2522706","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2522707","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2523094","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2523095","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}},{"_index":"atpic","_type":"pic","_id":"2522708","_score":2.5319257,"fields":{"uid":"1","username":"Alex M","servershort":"alex"}}]}}',b'<DOC><took>19</took><timed_out>False</timed_out><_shards><total>1</total><successful>1</successful><failed>0</failed></_shards><hits><total>420</total><max_score>2.5319257</max_score><hits><_index>atpic</_index><_type>pic</_type><_id>2523090</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522704</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523091</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523092</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522705</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522706</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522707</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523094</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2523095</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits><hits><_index>atpic</_index><_type>pic</_type><_id>2522708</_id><_score>2.5319257</_score><fields><uid>1</uid><username>Alex M</username><servershort>alex</servershort></fields></hits></hits></DOC>'),11 (b'{"key1" : "val1", "key2" : {"in1":"out2"}}',b'<DOC><key1>val1</key1><key2><in1>out2</in1></key2></DOC>'),12 (b'{"key1" : "val1", "key22" : {"key333": {"key4444":"val4444"}}}',b'<DOC><key1>val1</key1><key22><key333><key4444>val4444</key4444></key333></key22></DOC>'),13 (b'{"key1" : "val1", "key2" : "val2", "key3": {"key44":"val44"}, "key5" : "val5"}',b'<DOC><key1>val1</key1><key2>val2</key2><key3><key44>val44</key44></key3><key5>val5</key5></DOC>'),14 (b'{"key1" : ["val1a","val1b"], "key2" : "val2"}',b'<DOC><key1>val1a</key1><key1>val1b</key1><key2>val2</key2></DOC>'),15 (b'{"key1" : "val1", "key2" : [{"key3":"val3"},{"key4":"val4"}]}',b'<DOC><key1>val1</key1><key2><key3>val3</key3></key2><key2><key4>val4</key4></key2></DOC>'),16 (b'{ "key1": {}}',b'<DOC><key1></key1></DOC>'),17 (b'{ "key1": []}',b'<DOC></DOC>'),18 ]19 20 for (json,expect) in inputs:21 print(json.decode('utf8'))22 xml=atpic.jsonat_json2xml.parse(json)23 print(xml.decode('utf8'))24 # print('XXX (',json,',',xml,'),',sep='')25 self.assertEqual(xml,expect)26if __name__=="__main__":...

Full Screen

Full Screen

go_to_champion.py

Source:go_to_champion.py Github

copy

Full Screen

1__author__ = 'sunary'2import copy3teams = set()4vietnam = 'VIETNAM'5def is_vietnam(name):6 return name.lower == 'vietnam'7def evaluate(_score, t1, t2, goals):8 '''9 ['score', 'different goals', 'num matches', 'num goals']10 '''11 global vietnam, teams12 if is_vietnam(t1):13 vietnam = t114 elif is_vietnam(t2):15 vietnam = t216 teams.add(t1)17 teams.add(t2)18 if t1 not in _score:19 _score[t1] = [0, 0, 0, 0]20 if t2 not in _score:21 _score[t2] = [0, 0, 0, 0]22 _score[t1][2] += 123 _score[t2][2] += 124 _score[t1][3] += goals[0]25 _score[t2][3] += goals[1]26 _score[t1][1] += (goals[0] - goals[1])27 _score[t2][1] += (goals[1] - goals[0])28 if goals[0] > goals[1]:29 _score[t1][0] += 330 elif goals[0] < goals[1]:31 _score[t2][0] += 332 else:33 _score[t1][0] += 134 _score[t2][0] += 135 return _score36def team_last_match(_score):37 for t in teams:38 if t == vietnam:39 continue40 if _score[t][2] == 2:41 return t42def rank_team(_score):43 ranker = []44 for t in teams:45 ranker.append([t] + _score[t])46 return sorted(ranker, key=lambda x: (-x[1], -x[2], -x[4], x[0][0]))47def main(m):48 _score = {}49 for detail in m:50 score_split = detail.split(' ')51 _score = evaluate(_score, score_split[0], score_split[1],52 [int(score_split[2].split(':')[0]), int(score_split[2].split(':')[1])])53 last_team = team_last_match(_score)54 min_mn = 9955 remember = []56 for i in range(9):57 for j in range(9):58 before_score = evaluate(copy.deepcopy(_score), vietnam, last_team, [i, j])59 ranker = rank_team(before_score)60 if vietnam == ranker[0][0] or vietnam == ranker[1][0]:61 if i - j < min_mn:62 min_mn = i - j63 remember = [i, j]64 if remember:65 return '{}:{}'.format(remember[0], remember[1])66 else:67 return 'IMPOSSIBLE'68# m = map(str, [raw_input() for _ in range(5)])69m = ['JAPAN KOREA 2:1', 'KOREA CHINA 0:3', 'CHINA JAPAN 0:1', 'JAPAN VIETNAM 2:0', 'KOREA VIETNAM 4:0']70# m = ['JAPAN KOREA 2:2', 'KOREA CHINA 2:3', 'CHINA JAPAN 1:3', 'JAPAN VIETNAM 2:1', 'KOREA VIETNAM 4:1']...

Full Screen

Full Screen

consts.py

Source:consts.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2SEARCH_URL_ROOT = '/hub/search_beta'3ADMINS = ['qingfeng', 'xutao', 'xyb', 'huanghuang', 'liwentao', 'fanjianjin',4 'testuser']5DATE_FORMAT = "%Y-%m-%dT%H:%M:%S"6SRC_SIZE_LIMIT = 5000007PERPAGE_LIMIT = 108WATCHS = 19FORKS = 210UPDATED = 311INDEXED = 412BADGES = 513PRAISES = 614FOLLOWERS = 715REPOS = 816CREATED = 917SEARCH_KINDS = (18 K_REPO,19 K_CODE,20 K_USER,21 K_DOC,22 K_PULL,23 K_ISSUE,24) = range(6)25SEARCH_KIND_NAMES = (26 'Repositories',27 'Codes',28 'Users',29 'Docs',30 'Pulls',31 'Issues',32)33SEARCH_KIND_ICON_NAMES = (34 'mini-icon-public-repo',35 'mini-icon-code',36 'mini-icon-person',37 'mini-icon-doc',38 'mini-icon-pull',39 'mini-icon-issue',40)41REPO_ORDERS = {42 WATCHS: ('Watchs', [{'watched_count': 'desc'}, '_score']),43 FORKS: ('Forks', [{'forked_count': 'desc'}, '_score']),44 UPDATED: ('Updated', [{'last_updated': 'desc'}, '_score']),45}46USER_ORDERS = {47 BADGES: ('Badges', [{'badges_count': 'desc'}, '_score']),48 PRAISES: ('Praises', [{'praises_count': 'desc'}, '_score']),49 FOLLOWERS: ('Followers', [{'followers_count': 'desc'}, '_score']),50 REPOS: ('Repositories', [{'repos_count': 'desc'}, '_score']),51}52CODE_ORDERS = {53 UPDATED: ('Updated', [{'last_updated': 'desc'}, '_score']),54 CREATED: ('Created', [{'commit_time': 'desc'}, '_score']),55}56PULL_ORDERS = {57 UPDATED: ('Updated', [{'base.repo.pushed_at': 'desc'}, '_score']),58 CREATED: ('Created', [{'created_at': 'desc'}, '_score']),59}60ISSUE_ORDERS = {61 UPDATED: ('Updated', [{'updated_at': 'desc'}, '_score']),62 CREATED: ('Created', [{'created_at': 'desc'}, '_score']),63}64DOC_ORDERS = {65 CREATED: ('Created', [{'time': 'desc'}, '_score']),66}67KIND_ORDERS_MAP = {68 K_REPO: REPO_ORDERS,69 K_USER: USER_ORDERS,70 K_DOC: DOC_ORDERS,71 K_CODE: CODE_ORDERS,72 K_ISSUE: ISSUE_ORDERS,73 K_PULL: PULL_ORDERS,...

Full Screen

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 fMBT 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