├── imageNetFlickr ├── 37classWordNetID │ ├── toy.csv │ ├── computer.csv │ ├── door.csv │ ├── floor.csv │ ├── hand.csv │ ├── sidewalk.csv │ ├── soda_can.csv │ ├── cellphone.csv │ ├── outdoor_walls.csv │ ├── microwave_oven.csv │ ├── remote_control.csv │ ├── ceiling.csv │ ├── motorbike.csv │ ├── indoor_walls.csv │ ├── television.csv │ ├── fork.csv │ ├── lamp.csv │ ├── laptop.csv │ ├── pencil.csv │ ├── pen.csv │ ├── glasses.csv │ ├── bicycle.csv │ ├── knife.csv │ ├── watch.csv │ ├── spoon.csv │ ├── cup.csv │ ├── kitchen_utensil.csv │ ├── chair.csv │ ├── cat.csv │ ├── bottle.csv │ ├── dog.csv │ ├── road.csv │ ├── window.csv │ ├── table.csv │ ├── shoe.csv │ ├── car.csv │ ├── plant.csv │ ├── grass.csv │ ├── tree.csv │ └── personId.csv ├── README.md ├── 37classes.csv ├── getIdFromWord.py ├── downloadFlickrFromCsv.py └── getImgs.py ├── 9murls ├── run.sh ├── requirments.txt ├── install.sh ├── info.txt ├── 41classes.csv ├── download.sh ├── README.md └── getImages.py ├── .gitignore ├── README.md ├── downloadFromBing ├── build │ ├── binding.Makefile │ ├── config.gypi │ ├── binding.target.mk │ ├── Makefile │ └── gyp-mac-tool ├── binding.gyp ├── index.js ├── install.sh ├── require.txt ├── README.md ├── package.json ├── scrape_imgs_from_url_master.py ├── wordnet.py ├── lib │ ├── bing-images-scraper.js │ ├── yahoo-images-scraper.js │ ├── picsearch-images-scraper.js │ ├── google-images-scraper.js │ └── jquery-2.1.4.min.js ├── getImgs.py └── scrape_urls_master.py └── LICENSE /imageNetFlickr/37classWordNetID/toy.csv: -------------------------------------------------------------------------------- 1 | n04461879 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/computer.csv: -------------------------------------------------------------------------------- 1 | n03180011 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/door.csv: -------------------------------------------------------------------------------- 1 | n03222176 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/floor.csv: -------------------------------------------------------------------------------- 1 | n09282208 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/hand.csv: -------------------------------------------------------------------------------- 1 | n10158506 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/sidewalk.csv: -------------------------------------------------------------------------------- 1 | n04215402 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/soda_can.csv: -------------------------------------------------------------------------------- 1 | n04255586 2 | -------------------------------------------------------------------------------- /9murls/run.sh: -------------------------------------------------------------------------------- 1 | #/usr/bin/python3 2 | python3 getImages.py 3 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/cellphone.csv: -------------------------------------------------------------------------------- 1 | n02992529 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/outdoor_walls.csv: -------------------------------------------------------------------------------- 1 | n04082710 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/microwave_oven.csv: -------------------------------------------------------------------------------- 1 | n03761084 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/remote_control.csv: -------------------------------------------------------------------------------- 1 | n04074963 2 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/ceiling.csv: -------------------------------------------------------------------------------- 1 | n02990373 2 | n03864542 3 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/motorbike.csv: -------------------------------------------------------------------------------- 1 | n03769722 2 | n03785016 3 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/indoor_walls.csv: -------------------------------------------------------------------------------- 1 | n14564779 2 | n04544325 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | node_modules/* 4 | *.log 5 | *.t7 6 | *.DS_Store 7 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/television.csv: -------------------------------------------------------------------------------- 1 | n06277280 2 | n06278338 3 | n06278475 4 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/fork.csv: -------------------------------------------------------------------------------- 1 | n13914265 2 | n03384167 3 | n03500457 4 | n02973805 5 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/lamp.csv: -------------------------------------------------------------------------------- 1 | n03636649 2 | n04380533 3 | n03367059 4 | n04057981 5 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/laptop.csv: -------------------------------------------------------------------------------- 1 | n03985232 2 | n02900987 3 | n03832673 4 | n03642806 5 | n03485407 6 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/pencil.csv: -------------------------------------------------------------------------------- 1 | n13863020 2 | n03908456 3 | n03908204 4 | n03652100 5 | n04234763 6 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/pen.csv: -------------------------------------------------------------------------------- 1 | n03906997 2 | n02783161 3 | n03326948 4 | n03388183 5 | n04033901 6 | n04185529 7 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/glasses.csv: -------------------------------------------------------------------------------- 1 | n04272054 2 | n02836607 3 | n03443912 4 | n03690168 5 | n03941586 6 | n04356056 7 | -------------------------------------------------------------------------------- /9murls/requirments.txt: -------------------------------------------------------------------------------- 1 | python >= 3.5 2 | 3 | python packages 4 | numpy 5 | urllib 6 | pillow 7 | scipy 8 | click 9 | tqdm 10 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/bicycle.csv: -------------------------------------------------------------------------------- 1 | n02834778 2 | n02835271 3 | n03792782 4 | n04026813 5 | n04524716 6 | n03853924 7 | n04126066 8 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/knife.csv: -------------------------------------------------------------------------------- 1 | n03624134 2 | n04612257 3 | n02812949 4 | n03158885 5 | n03615790 6 | n03699591 7 | n04198722 8 | n04479287 9 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/watch.csv: -------------------------------------------------------------------------------- 1 | n04555897 2 | n04607869 3 | n02708433 4 | n03197337 5 | n03549350 6 | n03909516 7 | n03973839 8 | n04314107 9 | -------------------------------------------------------------------------------- /9murls/install.sh: -------------------------------------------------------------------------------- 1 | pip3 install numpy 2 | pip3 install urllib 3 | pip3 install pillow 4 | pip3 install scipy 5 | pip3 install click 6 | pip3 install tqdm 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ##9 million images from google 2 | 3 | 9murls 4 | 5 | ##Image scraper with Bing 6 | 7 | downloadFromBing 8 | 9 | ##Flickr 10 | 11 | imageNetFlickr 12 | -------------------------------------------------------------------------------- /downloadFromBing/build/binding.Makefile: -------------------------------------------------------------------------------- 1 | # This file is generated by gyp; do not edit. 2 | 3 | export builddir_name ?= ./build/. 4 | .PHONY: all 5 | all: 6 | $(MAKE) binding 7 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/spoon.csv: -------------------------------------------------------------------------------- 1 | n04284002 2 | n03180384 3 | n04119630 4 | n04263502 5 | n04350769 6 | n04381073 7 | n04397860 8 | n04398688 9 | n04597913 10 | -------------------------------------------------------------------------------- /downloadFromBing/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [ 3 | { 4 | "target_name": "binding", 5 | "sources": [ "/node_modules/iconv/src/binding.cc" ] 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /9murls/info.txt: -------------------------------------------------------------------------------- 1 | hand (human hand) 2 | cellphone (tablet) 3 | computer (PC, laptop) 4 | cup (mug, drinking glass) 5 | kitchen-utensils (fork, knife, spoon) 6 | pen (pencil) 7 | 8 | 9 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/cup.csv: -------------------------------------------------------------------------------- 1 | n03147509 2 | n02815749 3 | n03002948 4 | n03063073 5 | n03216710 6 | n03451253 7 | n03629520 8 | n03802643 9 | n04158138 10 | n04397452 11 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/kitchen_utensil.csv: -------------------------------------------------------------------------------- 1 | n03621049 2 | n04396902 3 | n03012499 4 | n03101517 5 | n03101986 6 | n03454885 7 | n03621377 8 | n03724417 9 | n03767966 10 | n03775199 11 | n04088441 12 | n04103206 13 | n04167228 14 | n04293119 15 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/chair.csv: -------------------------------------------------------------------------------- 1 | n03001627 2 | n04576002 3 | n02738535 4 | n02791124 5 | n03002210 6 | n03002711 7 | n03260849 8 | n03335333 9 | n03376595 10 | n03518445 11 | n03632729 12 | n03649674 13 | n04099969 14 | n04331277 15 | n04373704 16 | n04381450 17 | -------------------------------------------------------------------------------- /downloadFromBing/index.js: -------------------------------------------------------------------------------- 1 | module.exports.Google = require('./lib/google-images-scraper'); 2 | module.exports.Bing = require('./lib/bing-images-scraper'); 3 | module.exports.Picsearch = require('./lib/picsearch-images-scraper'); 4 | module.exports.Yahoo = require('./lib/yahoo-images-scraper'); -------------------------------------------------------------------------------- /downloadFromBing/install.sh: -------------------------------------------------------------------------------- 1 | #!bin/bash 2 | npm install async 3 | npm install bluebird 4 | npm install cheerio 5 | npm install EventEmitter 6 | npm install gm 7 | npm install iconv 8 | npm install limiter 9 | npm install lupus 10 | npm install nightmare 11 | npm install request 12 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/cat.csv: -------------------------------------------------------------------------------- 1 | n02121808 2 | n02122430 3 | n02122725 4 | n02123478 5 | n02122298 6 | n02124313 7 | n02122878 8 | n02123045 9 | n02122510 10 | n02123597 11 | n02124157 12 | n02123394 13 | n02123159 14 | n02124484 15 | n02123917 16 | n02124075 17 | n02123242 18 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/bottle.csv: -------------------------------------------------------------------------------- 1 | n02876657 2 | n02823428 3 | n02960903 4 | n02962061 5 | n02985963 6 | n03140431 7 | n03174450 8 | n03359566 9 | n03449451 10 | n03571625 11 | n03603722 12 | n03923379 13 | n03937543 14 | n03983396 15 | n04246060 16 | n04271793 17 | n04557648 18 | n04579056 19 | n04591713 20 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/dog.csv: -------------------------------------------------------------------------------- 1 | n02084071 2 | n01322604 3 | n02112497 4 | n02113335 5 | n02111277 6 | n02084732 7 | n02111129 8 | n02103406 9 | n02112826 10 | n02111626 11 | n02110958 12 | n02110806 13 | n02085272 14 | n02113978 15 | n02087122 16 | n02111500 17 | n02110341 18 | n02085374 19 | n02084861 20 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/road.csv: -------------------------------------------------------------------------------- 1 | n04096066 2 | n02671988 3 | n02930645 4 | n02986920 5 | n03040836 6 | n03107609 7 | n03182506 8 | n03242713 9 | n03244388 10 | n03519981 11 | n03671272 12 | n03990385 13 | n04097622 14 | n04204953 15 | n04215056 16 | n04229363 17 | n04274214 18 | n04426618 19 | n04463510 20 | n04500704 21 | n02900459 22 | n02744323 23 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/window.csv: -------------------------------------------------------------------------------- 1 | n04587648 2 | n04473108 3 | n04329958 4 | n04297750 5 | n04239333 6 | n04232800 7 | n04137089 8 | n04110178 9 | n03986562 10 | n03952150 11 | n03932080 12 | n03841290 13 | n03692842 14 | n03637898 15 | n03320959 16 | n03227184 17 | n03227010 18 | n03224753 19 | n03224603 20 | n03211789 21 | n03041810 22 | n02976455 23 | n02813399 24 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/table.csv: -------------------------------------------------------------------------------- 1 | n04379243 2 | n04603729 3 | n02699629 4 | n02874214 5 | n02894337 6 | n02964075 7 | n02964196 8 | n03063968 9 | n03090000 10 | n03092883 11 | n03116530 12 | n03179701 13 | n03238586 14 | n03246933 15 | n03414676 16 | n03465426 17 | n03620967 18 | n03850492 19 | n03892728 20 | n03904060 21 | n03934565 22 | n03961630 23 | n03982430 24 | n04301000 25 | n04381587 26 | n04398951 27 | n04480033 28 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/shoe.csv: -------------------------------------------------------------------------------- 1 | n04199027 2 | n02713364 3 | n02767147 4 | n02783708 5 | n02855701 6 | n02882894 7 | n02904927 8 | n02938218 9 | n03025250 10 | n03027625 11 | n03041449 12 | n03090710 13 | n03364156 14 | n03411079 15 | n03436290 16 | n03472535 17 | n03680355 18 | n03776877 19 | n03868406 20 | n04022332 21 | n04120489 22 | n04122578 23 | n04133789 24 | n04239786 25 | n04545748 26 | n04546081 27 | n04570118 28 | n04593524 29 | -------------------------------------------------------------------------------- /imageNetFlickr/README.md: -------------------------------------------------------------------------------- 1 | ##Get wordNet id it will get 1depth only 2 | 3 | ```bash 4 | python3 getIdFromWord.py 37classes.csv lists 5 | ``` 6 | PS: WordNet id may not in the imageNet url list id in that case can't download 7 | 8 | Use imagNet website to verify 9 | 10 | ```bash 11 | 12 | python downloadFlickrFromCsv.py lists 13 | 14 | ``` 15 | 16 | 17 | ##To get 37 classes imageNet flickr 18 | 19 | ```bash 20 | python3 downloadFlickrFromCsv.py 37classWordNetID 21 | ``` 22 | -------------------------------------------------------------------------------- /downloadFromBing/require.txt: -------------------------------------------------------------------------------- 1 | Python > 3.5 2 | 3 | python packages 4 | concurrent 5 | tqdm 6 | urllib 7 | click 8 | scipy 9 | pillow 10 | nltk 11 | 12 | npm packages 13 | 14 | npm install async 15 | npm install bluebird 16 | npm install cheerio 17 | npm install EventEmitter 18 | npm install gm 19 | npm install iconv 20 | npm install limiter 21 | npm install lupus 22 | npm install nightmare 23 | npm install request 24 | 25 | Ubuntu packages 26 | imagemagick 27 | graphicsmagick 28 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/car.csv: -------------------------------------------------------------------------------- 1 | n02960352 2 | n02958343 3 | n04516354 4 | n02701002 5 | n02814533 6 | n02924554 7 | n02930766 8 | n03079136 9 | n03100240 10 | n03119396 11 | n03141065 12 | n03268790 13 | n03421669 14 | n03493219 15 | n03498781 16 | n03539103 17 | n03543394 18 | n03594945 19 | n03670208 20 | n03680512 21 | n03770085 22 | n03770679 23 | n03777568 24 | n03870105 25 | n04037443 26 | n04097373 27 | n04166281 28 | n04285008 29 | n04285965 30 | n04302988 31 | n04322924 32 | n04347119 33 | n04459122 34 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/plant.csv: -------------------------------------------------------------------------------- 1 | n00017222 2 | n13179056 3 | n01383896 4 | n11530008 5 | n11530512 6 | n11530715 7 | n11530860 8 | n11530990 9 | n11531090 10 | n11531193 11 | n11536087 12 | n11536230 13 | n11536369 14 | n11536567 15 | n11536673 16 | n11552133 17 | n11552806 18 | n11552976 19 | n11553240 20 | n11553419 21 | n11553522 22 | n11553634 23 | n11686503 24 | n11686780 25 | n11686912 26 | n11687071 27 | n13083023 28 | n13083306 29 | n13083586 30 | n13100156 31 | n13122985 32 | n13123681 33 | n13124654 34 | -------------------------------------------------------------------------------- /9murls/41classes.csv: -------------------------------------------------------------------------------- 1 | person 2 | cat 3 | dog 4 | hand 5 | door 6 | window 7 | chair 8 | sofa bed 9 | outdoor sofa 10 | table 11 | microwave oven 12 | plant 13 | tree 14 | grass 15 | ceiling 16 | floor 17 | wall 18 | television 19 | telephone 20 | tablet computer 21 | personal computer 22 | laptop 23 | remote control 24 | cup 25 | mug 26 | bottle 27 | aluminum can 28 | fork 29 | knife 30 | spoon 31 | scissors 32 | shoe 33 | toy 34 | pen 35 | pencil 36 | watch 37 | lamp 38 | car 39 | bicycle 40 | motorcycle 41 | road 42 | sidewalk 43 | book 44 | bookcase 45 | stairs 46 | painting 47 | face 48 | -------------------------------------------------------------------------------- /9murls/download.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export DOWNLOAD_DIR='./source' 4 | mkdir ${DOWNLOAD_DIR} 5 | cd ${DOWNLOAD_DIR} 6 | 7 | wget https://storage.googleapis.com/openimages/2016_08/images_2016_08_v5.tar.gz 8 | wget https://storage.googleapis.com/openimages/2016_08/machine_ann_2016_08_v3.tar.gz 9 | wget https://storage.googleapis.com/openimages/2016_08/human_ann_2016_08_v3.tar.gz 10 | 11 | tar xf images_2016_08_v5.tar.gz && rm images_2016_08_v5.tar.gz 12 | tar xf machine_ann_2016_08_v3.tar.gz && rm machine_ann_2016_08_v3.tar.gz 13 | tar xf human_ann_2016_08_v3.tar.gz && rm human_ann_2016_08_v3.tar.gz 14 | 15 | 16 | -------------------------------------------------------------------------------- /imageNetFlickr/37classes.csv: -------------------------------------------------------------------------------- 1 | NAME 2 | bicycle 3 | bottle 4 | car 5 | cat 6 | ceiling 7 | cellphone 8 | chair 9 | computer 10 | cup 11 | dog 12 | door 13 | floor 14 | fork 15 | grass 16 | hand 17 | knife 18 | lamp 19 | laptop 20 | motorbike 21 | pen 22 | pencil 23 | person 24 | plant 25 | road 26 | shoe 27 | sidewalk 28 | soda_can 29 | sofa 30 | spoon 31 | table 32 | tablet 33 | television 34 | toy 35 | tree 36 | wall 37 | watch 38 | window 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Peter Evers 2 | 3 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 4 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- /downloadFromBing/README.md: -------------------------------------------------------------------------------- 1 | ##This repo is for creating a large scale image data set from World Wide Web. 2 | ##To get images from csv list files 3 | 4 | Create list.csv Column name NAME list what you want under NAME 5 | 6 | test.csv form 7 | 8 | ```csv 9 | NAME 10 | dog 11 | cat 12 | ``` 13 | 14 | 1. Collect urls 15 | 16 | ```bash 17 | python3 scrape_urls_master.py test.csv 18 | ``` 19 | 20 | 2. Download images from urls 21 | 22 | ```bash 23 | python3 download_from_json_master.py json_files 24 | ``` 25 | 26 | It will download images under images folder 27 | 28 | 29 | Requirements: look for details require.txt 30 | 31 | ```bash 32 | pip3 install nltk 33 | 34 | ``` 35 | To use wordnet.py 36 | 37 | Need to install nltk and nltk.download('all') 38 | 39 | ```bash 40 | sudo apt-get install imagemagick graphicsmagick 41 | ``` 42 | 43 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/grass.csv: -------------------------------------------------------------------------------- 1 | n12102133 2 | n12146311 3 | n12103349 4 | n12103476 5 | n12103680 6 | n12103894 7 | n12104104 8 | n12104238 9 | n12104384 10 | n12104734 11 | n12105125 12 | n12106786 13 | n12108432 14 | n12108871 15 | n12110778 16 | n12112008 17 | n12112609 18 | n12112918 19 | n12113657 20 | n12113790 21 | n12114397 22 | n12115180 23 | n12115383 24 | n12115748 25 | n12116058 26 | n12116429 27 | n12117017 28 | n12119099 29 | n12119238 30 | n12120114 31 | n12121033 32 | n12121610 33 | n12121835 34 | n12122018 35 | n12122725 36 | n12122918 37 | n12124627 38 | n12125584 39 | n12128071 40 | n12128306 41 | n12128490 42 | n12129134 43 | n12129349 44 | n12129738 45 | n12129986 46 | n12130160 47 | n12130549 48 | n12131405 49 | n12131550 50 | n12133151 51 | n12133682 52 | n12139575 53 | n12140358 54 | n12140903 55 | n12141167 56 | n12141495 57 | -------------------------------------------------------------------------------- /downloadFromBing/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "images-scraper", 3 | "version": "2.0.9", 4 | "description": "Simple and fast scraper for Google/Bing images using Nightmare and Request", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "mocha test" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/pevers/images-scraper.git" 12 | }, 13 | "keywords": [ 14 | "scraper", 15 | "google", 16 | "images" 17 | ], 18 | "author": "Peter Evers", 19 | "license": "ISC", 20 | "bugs": { 21 | "url": "https://github.com/pevers/images-scraper/issues" 22 | }, 23 | "homepage": "https://github.com/pevers/images-scraper#readme", 24 | "dependencies": { 25 | "async": "^2.0.0-rc.3", 26 | "bluebird": "^3.0.5", 27 | "chai": "^3.4.1", 28 | "chai-as-promised": "^5.2.0", 29 | "cheerio": "^0.19.0", 30 | "limiter": "^1.1.0", 31 | "lodash": "^3.10.1", 32 | "nightmare": "^2.0.7", 33 | "request": "^2.67.0", 34 | "validator": "^4.5.0" 35 | }, 36 | "directories": { 37 | "test": "test" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /9murls/README.md: -------------------------------------------------------------------------------- 1 | # Open Image Dataset downloader 2 | 3 | Downloads images from the Google Open Image Dataset: https://github.com/openimages/dataset 4 | 5 | 6 | ## To install dependency 7 | 8 | Needs python >= 3.5 9 | 10 | See requirement.txt for python pacakges 11 | 12 | ``` 13 | sh install.sh 14 | ``` 15 | 16 | Have to upgrade pip3 when fail init pip3 in ubuntu 17 | 18 | ``` 19 | sudo -H python3 -m pip install --upgrade pip 20 | ``` 21 | 22 | ## First Downloading url and lebel files 23 | ``` 24 | sh download.sh 25 | ``` 26 | 27 | ## To download images from given csv file 28 | 29 | Do python3 getImages.py with follow option options 30 | 31 | 1st option : dict.csv 32 | 33 | 2end option: Your classes.csv 34 | 35 | 3rd option : path to images.csv i.e. images_2016_08/validation/images.csv 36 | 37 | 4th option : path to labels.csv i.e. machine_ann_2016_08/validation/labels.csv 38 | 39 | 5th option : Number of Max images per class 40 | 41 | 6th option : Number of Threads 42 | 43 | 6th option : Target folder to download 44 | 45 | #To test 46 | 47 | ``` 48 | sh run.sh 49 | ``` 50 | 51 | note: labels.csv and images.csv must sync i.e. train/labels.csv train/images.csv 52 | note: class: scissors is not in validation dataset it's only at trainSet 53 | -------------------------------------------------------------------------------- /downloadFromBing/scrape_imgs_from_url_master.py: -------------------------------------------------------------------------------- 1 | from os import listdir 2 | import click 3 | from os.path import join 4 | from os.path import isfile, join 5 | import sys 6 | from subprocess import call 7 | 8 | @click.command() 9 | @click.option('--path',help='Dir of json file which has url txt') 10 | @click.option('--img_size',default=256) 11 | @click.option('--thread_number',default=5) 12 | 13 | def main(path,img_size,thread_number): 14 | for d in listdir(path): 15 | if d[0] != ".": 16 | print("In directory " + d) 17 | classpath = join(path, d) 18 | destclasspath = join('./images/' , d) 19 | onlyfiles = [f for f in listdir(classpath) if isfile(join(classpath, f))] 20 | for query in onlyfiles: 21 | print('--------------') 22 | print("query:" + query) 23 | if query[0] != ".": 24 | srcTxtPath = join(path, d ,query) 25 | query = query.split('.') 26 | subClassPath = join(destclasspath ,query[0]) 27 | #Dest class path most top 28 | print(subClassPath) 29 | print(srcTxtPath) 30 | print('--------------') 31 | call(["python3", "getImgs.py", srcTxtPath,subClassPath,str(img_size),str(thread_number)]) 32 | 33 | 34 | 35 | if __name__ == '__main__': 36 | main() 37 | -------------------------------------------------------------------------------- /imageNetFlickr/getIdFromWord.py: -------------------------------------------------------------------------------- 1 | import csv 2 | import sys 3 | from os.path import join 4 | from os.path import isdir 5 | from subprocess import call 6 | from nltk.corpus import wordnet as wn 7 | 8 | def readCSV(fileName): 9 | names=[] 10 | with open(fileName,'rU') as csvfile: 11 | reader = csv.DictReader(csvfile) 12 | for row in reader: 13 | word = row['NAME'] 14 | word = word.replace('\t','') 15 | word = word.replace(' ','') 16 | word = word.strip() 17 | names.append(word) 18 | return names 19 | 20 | def writeCSV(array,dstFile): 21 | with open(dstFile,'w', newline='\n') as csvfile: 22 | writer = csv.writer(csvfile,delimiter='\n', lineterminator='\n') 23 | writer.writerow(array) 24 | 25 | def getId(name): 26 | ids = [] 27 | try: 28 | ss = wn.synset(str(name)+'.n.01') 29 | wordid = ss.pos()+str(ss.offset()) 30 | print(wordid) 31 | ids.append(wordid) 32 | except: 33 | print(name+' failed') 34 | return ids 35 | def checkFile(path): 36 | if not isdir(path): 37 | call(['mkdir','-p',path]) 38 | else: 39 | print('{} exist'.format(path)) 40 | #argv[1] will get name of files 41 | lists = readCSV(sys.argv[1]) 42 | dest = 'lists' 43 | checkFile(dest) 44 | print(lists) 45 | for name in lists: 46 | destfile = join(dest,name+'.csv') 47 | #Get ids from lists 48 | ids = getId(name) 49 | #Writing to list csv 50 | writeCSV(ids, destfile) 51 | -------------------------------------------------------------------------------- /downloadFromBing/build/config.gypi: -------------------------------------------------------------------------------- 1 | # Do not edit. File was generated by node-gyp's "configure" step 2 | { 3 | "target_defaults": { 4 | "cflags": [], 5 | "default_configuration": "Release", 6 | "defines": [], 7 | "include_dirs": [], 8 | "libraries": [] 9 | }, 10 | "variables": { 11 | "asan": 0, 12 | "host_arch": "x64", 13 | "icu_data_file": "icudt56l.dat", 14 | "icu_data_in": "../../deps/icu/source/data/in/icudt56l.dat", 15 | "icu_endianness": "l", 16 | "icu_gyp_path": "tools/icu/icu-generic.gyp", 17 | "icu_locales": "en,root", 18 | "icu_path": "./deps/icu", 19 | "icu_small": "true", 20 | "icu_ver_major": "56", 21 | "llvm_version": 0, 22 | "node_byteorder": "little", 23 | "node_install_npm": "true", 24 | "node_prefix": "/usr/local", 25 | "node_release_urlbase": "https://nodejs.org/download/release/", 26 | "node_shared_http_parser": "false", 27 | "node_shared_libuv": "false", 28 | "node_shared_openssl": "false", 29 | "node_shared_zlib": "false", 30 | "node_tag": "", 31 | "node_use_dtrace": "true", 32 | "node_use_etw": "false", 33 | "node_use_lttng": "false", 34 | "node_use_openssl": "true", 35 | "node_use_perfctr": "false", 36 | "openssl_fips": "", 37 | "openssl_no_asm": 0, 38 | "target_arch": "x64", 39 | "uv_parent_path": "/deps/uv/", 40 | "uv_use_dtrace": "true", 41 | "v8_enable_gdbjit": 0, 42 | "v8_enable_i18n_support": 1, 43 | "v8_no_strict_aliasing": 1, 44 | "v8_optimized_debug": 0, 45 | "v8_random_seed": 0, 46 | "v8_use_snapshot": "true", 47 | "want_separate_host_toolset": 0, 48 | "xcode_version": "7.0", 49 | "nodedir": "/Users/brianlee/.node-gyp/4.4.3", 50 | "copy_dev_lib": "true", 51 | "standalone_static_library": 1 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /downloadFromBing/wordnet.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from subprocess import call 3 | import nltk 4 | import sys 5 | import csv 6 | import os 7 | from os import path 8 | 9 | 10 | from nltk.corpus import wordnet as wn 11 | from nltk.tree import * 12 | 13 | def ensure_dir(d): 14 | d = path.join(os.getcwd(),d) 15 | if not path.isdir(d): 16 | os.mkdir(d) 17 | 18 | def getImage(query,root): 19 | keywords = [] 20 | 21 | if "/" in query: 22 | a = query.split("/") 23 | query = a[0] 24 | for w in a: 25 | keywords.append(w.strip()) 26 | 27 | path = root + '/' + query 28 | ensure_dir(path) 29 | 30 | key = query + '.n.01' 31 | 32 | word = wn.synset(key) 33 | hyp = lambda s:s.hyponyms() 34 | tree = word.tree(hyp) 35 | 36 | strTmp = str(tree) 37 | strTmp = strTmp.replace("Synset", "") 38 | strTmp = strTmp.replace("(", "") 39 | strTmp = strTmp.replace(")", "") 40 | strTmp = strTmp.replace("'", "") 41 | strTmp = strTmp.replace(",", "") 42 | strTmp = strTmp.replace(" ", "") 43 | list_char = list(strTmp) 44 | 45 | result = "" 46 | level = 0 47 | 48 | index = 0 49 | 50 | #parse tree with a stack to get only 1st and 2nd levels 51 | while index < len(list_char): 52 | if list_char[index] == '[': 53 | level += 1 54 | index += 1 55 | elif list_char[index] == ']': 56 | level -= 1 57 | index +=1 58 | else: 59 | if level <= 2: 60 | while list_char[index] != '.': 61 | result += list_char[index] 62 | index += 1 63 | 64 | while list_char[index] != '[' and list_char[index] != ']': 65 | index += 1 66 | 67 | result = result.replace("_", " ") 68 | keywords.append(result) 69 | result = "" 70 | 71 | else: 72 | index +=1 73 | 74 | print(keywords) 75 | 76 | if not keywords: 77 | keywords.append(query) 78 | 79 | for word in keywords: 80 | try: 81 | if not query in word: 82 | word = word + ' ' + query 83 | call(["node", "app.js", word, path]) 84 | except: 85 | print('Failed') 86 | 87 | def readCSV(fileName): 88 | with open(fileName,'rU') as csvfile: 89 | names = [] 90 | reader = csv.DictReader(csvfile) 91 | for row in reader: 92 | names.append(row['NAME']) 93 | return names 94 | 95 | csvFile = sys.argv[1] 96 | ensure_dir("images") 97 | names = readCSV(csvFile) 98 | for name in names: 99 | print(name) 100 | try: 101 | getImage(name,"images") 102 | except: 103 | print(str(name)+' Failed ') 104 | -------------------------------------------------------------------------------- /downloadFromBing/lib/bing-images-scraper.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var request = require('request') 4 | , cheerio = require('cheerio') 5 | , Promise = require('bluebird') 6 | , EventEmitter = require('events') 7 | , util = require('util'); 8 | 9 | function Scraper () { 10 | EventEmitter.call(this); 11 | } 12 | 13 | util.inherits(Scraper, EventEmitter); 14 | 15 | /** 16 | * Get the image src for all links, options.keyword is required. 17 | */ 18 | Scraper.prototype.list = function (options) { 19 | var self = this; 20 | 21 | if (!options || !options.keyword) return Promise.reject(new Error('no keyword provided')); 22 | 23 | var roptions = { 24 | 'url': 'http://www.bing.com/images/search?q=%&view=detailv2'.replace('%', encodeURIComponent(options.keyword)), 25 | 'User-Agent': options.userAgent || 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' 26 | }; 27 | 28 | var result = [], num = options.num; 29 | var extract = function(url) { 30 | return new Promise(function (resolve) { 31 | roptions.url = url; 32 | request(roptions, function (err, response, body) { 33 | if (!err && response.statusCode === 200) { 34 | // extract all items, go to next page if exist 35 | var $ = cheerio.load(body); 36 | $('.item a[class="thumb"]').each(function (el) { 37 | var item = $(this).attr('href'); 38 | 39 | var detail = $(this).parent().find('.fileInfo').text(); 40 | item = { 41 | url: item, 42 | thumb: $(this).find('img').attr('src'), 43 | width: detail.split(' ')[0], 44 | height: detail.split(' ')[2], 45 | format: detail.split(' ')[3], 46 | size: detail.split(' ')[4], 47 | unit: detail.split(' ')[5] 48 | }; 49 | 50 | self.emit('result', item); 51 | result.push(item); 52 | }); 53 | 54 | if (num && result.length > num) { 55 | var out = result.slice(0, num); 56 | self.emit('end', out); 57 | return resolve(result.slice(0,num)); 58 | } 59 | 60 | // search for current page and select next one 61 | var page = $('li a[class="sb_pagS"]').parent().next().find('a').attr('href'); 62 | if (page) { 63 | resolve(extract('http://www.bing.com' + page + '&view=detailv2')); 64 | } 65 | else { 66 | self.emit('end', result); 67 | resolve(result); 68 | } 69 | 70 | } else { 71 | self.emit('end', result); 72 | resolve(result) 73 | } 74 | }); 75 | }); 76 | }; 77 | 78 | return extract(roptions.url); 79 | } 80 | 81 | module.exports = Scraper; -------------------------------------------------------------------------------- /downloadFromBing/lib/yahoo-images-scraper.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var request = require('request') 4 | , cheerio = require('cheerio') 5 | , Promise = require('bluebird') 6 | , RateLimiter = require('limiter').RateLimiter 7 | , EventEmitter = require('events') 8 | , util = require('util'); 9 | 10 | function Scraper () { 11 | EventEmitter.call(this); 12 | } 13 | 14 | util.inherits(Scraper, EventEmitter); 15 | 16 | /** 17 | * Get the image src for images, options specify the details. 18 | */ 19 | Scraper.prototype.list = function (options) { 20 | var self = this; 21 | 22 | if (!options || !options.keyword) return Promise.reject(new Error('no keyword provided')); 23 | 24 | this.rlimit = new RateLimiter(options.rlimit || 0, 'second'); 25 | this.userAgent = options.userAgent || 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'; 26 | 27 | var base = 'https://images.search.yahoo.com/search/images?fr=yfp-t-404&fr2=piv-web&o=js&p=%&tab=organic&tmpl=&nost=1'; 28 | 29 | var roptions = { 30 | 'User-Agent': this.userAgent 31 | } 32 | 33 | var result = []; 34 | var nextPage = function (n) { 35 | return new Promise(function (resolve, reject) { 36 | roptions.url = base.replace('%', options.keyword) + '&b=' + n; 37 | self.rlimit.removeTokens(1, function() { 38 | request(roptions, function(err, response, body) { 39 | if (!err && response.statusCode === 200) { 40 | var html = JSON.parse(body).html; 41 | if (!html) { 42 | self.emit('end', result); 43 | return resolve(result); 44 | } 45 | 46 | var $ = cheerio.load(html); 47 | $('.ld').each(function () { 48 | var meta = JSON.parse($(this).attr('data')); 49 | try { 50 | var item = { 51 | url: meta.iurl, 52 | thumb: meta.ith, 53 | width: meta.w, 54 | height: meta.h, 55 | size: meta.s.match(/[-+]?(\d*[.])?\d+/)[0], 56 | format: meta.s.match(/\D\D/)[0] 57 | } 58 | 59 | self.emit('result', item); 60 | result.push(item); 61 | } catch(err) { 62 | // warn 63 | console.log('warn', err); 64 | } 65 | }); 66 | 67 | if (options.num && result.length > options.num) { 68 | var out = result.slice(0, options.num); 69 | self.emit('end', out); 70 | return resolve(out); 71 | } 72 | 73 | // next page 74 | resolve(nextPage(n + 60)) 75 | } else { 76 | self.emit('end', result); 77 | resolve(result); 78 | } 79 | }); 80 | }); 81 | }); 82 | } 83 | 84 | return nextPage(1); 85 | } 86 | 87 | module.exports = Scraper; -------------------------------------------------------------------------------- /imageNetFlickr/downloadFlickrFromCsv.py: -------------------------------------------------------------------------------- 1 | #Made by Sangpil Kim 2 | #June 2016 3 | #python 3.5 4 | 5 | import sys 6 | import csv 7 | from os.path import join 8 | import subprocess as sub 9 | import requests 10 | import codecs 11 | import click 12 | from walkdir import filtered_walk, dir_paths, all_paths, file_paths 13 | from getImgs import downLoadImg 14 | from bs4 import BeautifulSoup as bs4 15 | 16 | def getIdfromHtml(html): 17 | #Open html file 18 | f = codecs.open(html,'r', 'utf-8') 19 | dom = f.read().encode('ascii','ignore') 20 | f.close() 21 | #make soup 22 | soup = bs4(dom) 23 | urls = soup.find_all(href=True) 24 | #get id 25 | conId = [] 26 | for url in urls: 27 | id = url.get('href').split('=') 28 | conId.append(id[1]) 29 | return conId 30 | def getIds(csvFile): 31 | conIds = [] 32 | with open(csvFile, 'r') as f: 33 | reader = csv.reader(f) 34 | for row in reader: 35 | conIds.append(row[0]) 36 | return conIds 37 | def getUrlsFromId(id): 38 | url = 'http://www.image-net.org/api/text/imagenet.synset.geturls?wnid='+id 39 | print(url) 40 | r = requests.get(url) 41 | html = r.text 42 | return html 43 | def getFlickerUrls(html): 44 | urls =[] 45 | urls = html.split('\n') 46 | for url in urls: 47 | if not 'flickr' in url: 48 | urls.pop() 49 | infoList = [] 50 | idx = 0 51 | for url in urls: 52 | idx += 1 53 | dic = {} 54 | dic['idx'] = idx 55 | dic['url'] = url 56 | infoList.append(dic) 57 | return infoList 58 | def down(csvfile,destpath,img_size,thread_number): 59 | className = csvfile.replace('.csv','') 60 | destpath = join(destpath,className) 61 | conIds = getIds(csvfile) 62 | for conId in conIds: 63 | print(conId) 64 | html = getUrlsFromId(conId) 65 | #html = html.encode('ascii','ignore') 66 | html = str(html) 67 | infoList = getFlickerUrls(html) 68 | downLoadImg(destpath,infoList,img_size,thread_number) 69 | 70 | @click.command() 71 | @click.argument('srcdir') #,help='Dir of json file which has url txt') 72 | @click.option('-destpath',default='images') #,help='Dest dir') 73 | @click.option('-img_size',default=256) 74 | @click.option('-thread_number',default=5) 75 | def main(srcdir,destpath,img_size,thread_number): 76 | #Iterate csv container 77 | csvFiles = file_paths(filtered_walk(srcdir, depth=1, included_files='*.csv')) 78 | for csvfile in list(csvFiles): 79 | #Download files 80 | down(csvfile,destpath,img_size,thread_number) 81 | 82 | if __name__ == '__main__': 83 | main() 84 | 85 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/tree.csv: -------------------------------------------------------------------------------- 1 | n13104059 2 | n13142907 3 | n11696450 4 | n11696935 5 | n13240362 6 | n13144084 7 | n11708658 8 | n11739978 9 | n11745817 10 | n11749112 11 | n11756092 12 | n11758799 13 | n11759224 14 | n11761202 15 | n11761650 16 | n11761836 17 | n11762018 18 | n11762433 19 | n11762927 20 | n11763625 21 | n11764478 22 | n11770256 23 | n11772879 24 | n11799331 25 | n11841247 26 | n12154773 27 | n12180885 28 | n12185254 29 | n12188289 30 | n12189429 31 | n12191240 32 | n12192132 33 | n12192877 34 | n12194147 35 | n12194613 36 | n12196129 37 | n12198286 38 | n12200905 39 | n12201331 40 | n12201938 41 | n12202936 42 | n12220496 43 | n12222090 44 | n12222900 45 | n12223160 46 | n12224978 47 | n12260799 48 | n12262553 49 | n12264512 50 | n12264786 51 | n12265394 52 | n12266217 53 | n12268246 54 | n12281241 55 | n12284262 56 | n12286826 57 | n12287642 58 | n12302071 59 | n12303462 60 | n12309630 61 | n12323665 62 | n12324906 63 | n12325234 64 | n12330891 65 | n12334293 66 | n12364604 67 | n12364940 68 | n12365158 69 | n12365285 70 | n12365900 71 | n12366053 72 | n12370549 73 | n12373739 74 | n12377198 75 | n12378963 76 | n12379531 77 | n12379781 78 | n12380305 79 | n12394328 80 | n12401335 81 | n12405714 82 | n12409231 83 | n12478768 84 | n12488454 85 | n12488709 86 | n12489268 87 | n12489676 88 | n12490490 89 | n12491435 90 | n12491826 91 | n12495146 92 | n12496427 93 | n12498055 94 | n12506181 95 | n12509109 96 | n12510343 97 | n12522188 98 | n12522894 99 | n12523141 100 | n12523850 101 | n12524188 102 | n12527738 103 | n12531727 104 | n12549799 105 | n12551173 106 | n12551457 107 | n12553573 108 | n12559518 109 | n12562577 110 | n12563702 111 | n12565102 112 | n12565368 113 | n12565730 114 | n12565912 115 | n12566331 116 | n12569037 117 | n12569851 118 | n12570394 119 | n12570703 120 | n12570972 121 | n12573911 122 | n12579822 123 | n12580012 124 | n12582231 125 | n12662074 126 | n12662772 127 | n12663804 128 | n12668917 129 | n12669803 130 | n12670758 131 | n12670962 132 | n12690653 133 | n12695144 134 | n12695975 135 | n12696492 136 | n12697514 137 | n12698435 138 | n12699301 139 | n12699618 140 | n12700996 141 | n12701666 142 | n12702124 143 | n12713866 144 | n12714254 145 | n12714755 146 | n12715914 147 | n12718074 148 | n12724942 149 | n12735160 150 | n12736603 151 | n12740967 152 | n12741222 153 | n12764978 154 | n12765115 155 | n12765402 156 | n12770529 157 | n12770892 158 | n12774299 159 | n12775070 160 | n12775393 161 | n12775919 162 | n12787364 163 | n12806732 164 | n12815668 165 | n12818601 166 | n12915811 167 | n12916179 168 | n12916511 169 | n13103877 170 | n13107694 171 | n13107807 172 | n13107891 173 | n13108131 174 | n13108323 175 | n13108481 176 | n13108545 177 | n13108662 178 | n13109733 179 | n13111340 180 | n11650558 181 | n13111881 182 | -------------------------------------------------------------------------------- /imageNetFlickr/getImgs.py: -------------------------------------------------------------------------------- 1 | from urllib import request as rq 2 | from os.path import join 3 | from os.path import isdir 4 | from os.path import getsize 5 | from pathlib import Path 6 | from subprocess import call 7 | from scipy.misc import imresize, imread, imsave 8 | import time 9 | import multiprocessing as mul 10 | from concurrent import futures 11 | from tqdm import tqdm 12 | 13 | #reSize img 14 | def resizeImg(imgPath,img_size): 15 | try: 16 | img = imread(imgPath) 17 | h, w, _ = img.shape 18 | scale = 1 19 | if w >= h: 20 | new_w = img_size 21 | if w >= new_w: 22 | scale = float(new_w) / w 23 | new_h = int(h * scale) 24 | else: 25 | new_h = img_size 26 | if h >= new_h: 27 | scale = float(new_h) / h 28 | new_w = int(w * scale) 29 | new_img = imresize(img, (new_h, new_w), interp='bilinear') 30 | imsave(imgPath,new_img) 31 | print('Img Resized as {}'.format(img_size)) 32 | except Exception as e: 33 | print(e) 34 | 35 | def checkFile(path): 36 | if not isdir(path): 37 | call(['mkdir','-p',path]) 38 | else: 39 | print('{} exist'.format(path)) 40 | 41 | #Txt file is dictionary txt return list of dicts 42 | def readTxt(txtFile): 43 | tmp = [] 44 | #Get info from txt 45 | idx = 0 46 | with open(txtFile,'r') as inf: 47 | for line in inf: 48 | tmp.append(eval(line)) 49 | infoList = tmp[0] 50 | for info in infoList: 51 | idx += 1 52 | info['idx'] = idx 53 | return infoList 54 | #Check if img is valid one 55 | def checkValid(savePath): 56 | si = getsize(savePath) 57 | print(si) 58 | if si == 2051: 59 | print('Not valid delete') 60 | call(['rm', '-rf', str(savePath)]) 61 | 62 | #Download img 63 | def downLoadImg(destPath,infoList,img_size,thred_number): 64 | checkFile(destPath) 65 | lencl= len(destPath)-1 66 | if destPath[lencl] == '/': 67 | destPath = destPath[:-1] 68 | className = destPath.split('/') 69 | className = className[len(className)-1] 70 | def process(info): 71 | url = info['url'] 72 | ext = 'jpeg' 73 | idx = info['idx'] 74 | print(idx) 75 | savePath = join(destPath,className+ str(idx) + '.' + ext) 76 | check = Path(savePath) 77 | if not check.is_file(): 78 | print('Downloading : {} th {}' .format(idx,className)) 79 | start = time.clock() 80 | p = mul.Process(target = rq.urlretrieve, name='download',args=(url,savePath)) 81 | p.start() 82 | p.join(200) 83 | if p.is_alive(): 84 | print('Too longdownloading terminate') 85 | p.terminate() 86 | p.join() 87 | call(['rm','-rf',savePath]) 88 | if p.exitcode == 1: 89 | print('fail') 90 | call(['rm','-rf',savePath]) 91 | resizeImg(savePath,img_size) 92 | checkValid(savePath) 93 | else: 94 | print('Already Downloaded') 95 | with futures.ThreadPoolExecutor(max_workers=thred_number) as worker: 96 | mapper = [worker.submit(process,info) for info in infoList ] 97 | for tmp in tqdm(futures.as_completed(mapper), total=len(mapper)): 98 | pass 99 | 100 | -------------------------------------------------------------------------------- /downloadFromBing/getImgs.py: -------------------------------------------------------------------------------- 1 | from urllib import request as rq 2 | from os.path import join 3 | from os.path import isdir 4 | from pathlib import Path 5 | from subprocess import call 6 | from scipy.misc import imresize, imread, imsave 7 | import sys 8 | import time 9 | import multiprocessing as mul 10 | from concurrent import futures 11 | from tqdm import tqdm 12 | 13 | #reSize img 14 | def resizeImg(imgPath,img_size): 15 | img = imread(imgPath) 16 | h, w, _ = img.shape 17 | scale = 1 18 | if w >= h: 19 | new_w = img_size 20 | if w >= new_w: 21 | scale = float(new_w) / w 22 | new_h = int(h * scale) 23 | else: 24 | new_h = img_size 25 | if h >= new_h: 26 | scale = float(new_h) / h 27 | new_w = int(w * scale) 28 | new_img = imresize(img, (new_h, new_w), interp='bilinear') 29 | imsave(imgPath,new_img) 30 | print('Img Resized as {}'.format(img_size)) 31 | 32 | def checkFile(path): 33 | if not isdir(path): 34 | call(['mkdir','-p',path]) 35 | else: 36 | print('{} exist'.format(path)) 37 | 38 | #Txt file is dictionary txt return list of dicts 39 | def readTxt(txtFile): 40 | tmp = [] 41 | #Get info from txt 42 | idx = 0 43 | with open(txtFile,'r') as inf: 44 | for line in inf: 45 | tmp.append(eval(line)) 46 | infoList = tmp[0] 47 | for info in infoList: 48 | idx += 1 49 | info['idx'] = idx 50 | return infoList 51 | 52 | 53 | #Download img 54 | def downLoadImg(destPath,infoList,img_size,thred_number): 55 | lencl= len(destPath)-1 56 | if destPath[lencl] == '/': 57 | destPath = destPath[:-1] 58 | className = destPath.split('/') 59 | className = className[len(className)-1] 60 | def process(info): 61 | url = info['url'] 62 | ext = info['format'] 63 | idx = info['idx'] 64 | print(idx) 65 | savePath = join(destPath,className+ str(idx) + '.' + ext) 66 | check = Path(savePath) 67 | if not check.is_file(): 68 | print('Downloading : {} th {}' .format(idx,className)) 69 | start = time.clock() 70 | p = mul.Process(target = rq.urlretrieve, name='download',args=(url,savePath)) 71 | p.start() 72 | p.join(20) 73 | if p.is_alive(): 74 | print('Too longdownloading terminate') 75 | p.terminate() 76 | p.join() 77 | call(['rm','-rf',savePath]) 78 | if p.exitcode == 1: 79 | print('fail') 80 | call(['rm','-rf',savePath]) 81 | else: 82 | resizeImg(savePath,img_size) 83 | else: 84 | print('Already Downloaded') 85 | with futures.ThreadPoolExecutor(max_workers=thred_number) as worker: 86 | mapper = [worker.submit(process,info) for info in infoList ] 87 | for tmp in tqdm(futures.as_completed(mapper), total=len(mapper)): 88 | pass 89 | 90 | 91 | #Source txt file 92 | txtFile = sys.argv[1] 93 | #Destination folder 94 | destPath = sys.argv[2] 95 | #img size 96 | img_size = int(sys.argv[3]) 97 | #Thread number 98 | th_number = int(sys.argv[4]) 99 | #Check file exist not creat 100 | checkFile(destPath) 101 | #Get info 102 | infoList = readTxt(txtFile) 103 | downLoadImg(destPath,infoList,img_size,th_number) 104 | 105 | -------------------------------------------------------------------------------- /downloadFromBing/lib/picsearch-images-scraper.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var request = require('request') 4 | , cheerio = require('cheerio') 5 | , Promise = require('bluebird') 6 | , EventEmitter = require('events') 7 | , util = require('util'); 8 | 9 | function Scraper () { 10 | EventEmitter.call(this); 11 | } 12 | 13 | util.inherits(Scraper, EventEmitter); 14 | 15 | /** 16 | * Get the image src for all links, options.keyword is required. 17 | */ 18 | Scraper.prototype.list = function (options) { 19 | var self = this; 20 | 21 | if (!options || !options.keyword) return Promise.reject(new Error('no keyword provided')); 22 | 23 | var base = 'http://www.picsearch.com'; 24 | 25 | // define options 26 | this.roptions = { 27 | 'url': base + '/index.cgi?q=%'.replace('%', encodeURIComponent(options.keyword)), 28 | 'User-Agent': options.userAgent || 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36' 29 | }; 30 | 31 | var result = [], num = options.num || 2000; // max it to 2000 for default because we can go on indefinitely 32 | var nextPage = function(url) { 33 | return new Promise(function (resolve) { 34 | self.roptions.url = url; 35 | request(self.roptions, function (err, response, body) { 36 | if (!err && response.statusCode === 200) { 37 | var $ = cheerio.load(body); 38 | 39 | // no results 40 | if (!$('.result').length) { 41 | return resolve(result); 42 | } 43 | 44 | $('.result').each(function() { 45 | result.push(base + $(this).find('a').attr('href')); 46 | }); 47 | 48 | if (num && result.length > num) { 49 | return resolve(result.slice(0,num)); 50 | } 51 | 52 | // search for current page and select next one 53 | var page = $('#nextPage').attr('href'); 54 | if (page) { 55 | resolve(nextPage(base + page)); 56 | } 57 | else { 58 | resolve(result); 59 | } 60 | } else { 61 | resolve(result) 62 | } 63 | }); 64 | }); 65 | }; 66 | 67 | return nextPage(self.roptions.url).then(function (res) { 68 | return Promise.mapSeries(res, function (r) { 69 | return self._extract(r); 70 | }).then(function (details) { 71 | var result = details.filter(function (d) { 72 | return d !== undefined; 73 | }); 74 | self.emit('end', result); 75 | return result; 76 | }); 77 | }); 78 | } 79 | 80 | /** 81 | * Extract the original image and details from a target link. 82 | */ 83 | Scraper.prototype._extract = function (item) { 84 | var self = this; 85 | 86 | self.roptions.url = item; 87 | 88 | return new Promise(function (resolve, reject) { 89 | request(self.roptions, function (err, response, body) { 90 | if (!err && response.statusCode === 200) { 91 | var $ = cheerio.load(body); 92 | 93 | var detail = $('.detail-links p').eq(1).html().split('
')[1].trim(); 94 | var url = $('.thumbnailDetails a[rel="nofollow"]').attr('href') 95 | 96 | try { 97 | var item = { 98 | url: url, 99 | thumb: $('a[rel="nofollow"] img').attr('src'), 100 | width: detail.split('x')[0], 101 | height: detail.split('x')[1].split(',')[0], // regex vs. split 102 | format: url.match(/[0-9a-z]+$/i)[0], // guess the format from the url 103 | size: detail.split(',')[1].match(/[-+]?(\d*[.])?\d+/)[0], 104 | unit: detail.split(',')[1].match(/[^\d]\D+/)[0] 105 | } 106 | 107 | self.emit('result', item); 108 | resolve(item); 109 | } catch(err) { 110 | resolve(); // silently die 111 | } 112 | } else resolve(); // empty response, don't fail 113 | }); 114 | }); 115 | } 116 | 117 | module.exports = Scraper; -------------------------------------------------------------------------------- /downloadFromBing/scrape_urls_master.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | from subprocess import call 3 | import nltk 4 | import sys 5 | import csv 6 | import os 7 | from os import path 8 | 9 | 10 | from nltk.corpus import wordnet as wn 11 | from nltk.tree import * 12 | 13 | def ensure_dir(d): 14 | d = path.join(os.getcwd(),d) 15 | if not path.isdir(d): 16 | os.mkdir(d) 17 | 18 | def getJSON(query,root): 19 | path = root + '/' + query + '.txt' 20 | call(["node", "scrape_url.js", query, path]) 21 | 22 | def getWordnetJSON(query,root): 23 | classpath = root + '/' + query + '/' 24 | ensure_dir(classpath) 25 | 26 | keywords = [] 27 | key = query + '.n.01' 28 | keywords.append(query) 29 | try: 30 | word = wn.synset(key) 31 | hyp = lambda s:s.hyponyms() 32 | tree = word.tree(hyp) 33 | 34 | strTmp = str(tree) 35 | strTmp = strTmp.replace("Synset", "") 36 | strTmp = strTmp.replace("(", "") 37 | strTmp = strTmp.replace(")", "") 38 | strTmp = strTmp.replace("'", "") 39 | strTmp = strTmp.replace(",", "") 40 | strTmp = strTmp.replace(" ", "") 41 | list_char = list(strTmp) 42 | 43 | result = "" 44 | level = 0 45 | 46 | index = 0 47 | 48 | #parse tree with a stack to get only 1st and 2nd levels 49 | while index < len(list_char): 50 | if list_char[index] == '[': 51 | level += 1 52 | index += 1 53 | elif list_char[index] == ']': 54 | level -= 1 55 | index +=1 56 | else: 57 | if level <= 2: 58 | while list_char[index] != '.': 59 | result += list_char[index] 60 | index += 1 61 | 62 | while list_char[index] != '[' and list_char[index] != ']': 63 | index += 1 64 | 65 | result = result.replace("_", " ") 66 | if query not in result: 67 | result = result + " " + query 68 | 69 | keywords.append(result) 70 | result = "" 71 | 72 | else: 73 | index +=1 74 | except: 75 | keywords.append(query) 76 | 77 | print(keywords) 78 | 79 | for w in keywords: 80 | print("Getting JSON for: " + w) 81 | call(["node", "scrape_url.js", w, classpath + w + ".txt"]) 82 | 83 | # def getImage(query,root): 84 | # keywords = [] 85 | 86 | # if "/" in query: 87 | # a = query.split("/") 88 | # query = a[0] 89 | # for w in a: 90 | # keywords.append(w.strip()) 91 | 92 | # path = root + '/' + query 93 | # ensure_dir(path) 94 | 95 | # key = query + '.n.01' 96 | 97 | # word = wn.synset(key) 98 | # hyp = lambda s:s.hyponyms() 99 | # tree = word.tree(hyp) 100 | 101 | # strTmp = str(tree) 102 | # strTmp = strTmp.replace("Synset", "") 103 | # strTmp = strTmp.replace("(", "") 104 | # strTmp = strTmp.replace(")", "") 105 | # strTmp = strTmp.replace("'", "") 106 | # strTmp = strTmp.replace(",", "") 107 | # strTmp = strTmp.replace(" ", "") 108 | # list_char = list(strTmp) 109 | 110 | # result = "" 111 | # level = 0 112 | 113 | # index = 0 114 | 115 | # #parse tree with a stack to get only 1st and 2nd levels 116 | # while index < len(list_char): 117 | # if list_char[index] == '[': 118 | # level += 1 119 | # index += 1 120 | # elif list_char[index] == ']': 121 | # level -= 1 122 | # index +=1 123 | # else: 124 | # if level <= 2: 125 | # while list_char[index] != '.': 126 | # result += list_char[index] 127 | # index += 1 128 | 129 | # while list_char[index] != '[' and list_char[index] != ']': 130 | # index += 1 131 | 132 | # result = result.replace("_", " ") 133 | 134 | # keywords.append(result) 135 | # result = "" 136 | 137 | # else: 138 | # index +=1 139 | 140 | # print(keywords) 141 | 142 | # if not keywords: 143 | # keywords.append(query) 144 | 145 | # for word in keywords: 146 | # try: 147 | # if not query in word: 148 | # word = word + ' ' + query 149 | # call(["node", "app.js", word, path]) 150 | # except: 151 | # print('Failed') 152 | 153 | def readCSV(fileName): 154 | with open(fileName,'rU') as csvfile: 155 | names = [] 156 | reader = csv.DictReader(csvfile) 157 | for row in reader: 158 | names.append(row['NAME']) 159 | return names 160 | 161 | csvFile = sys.argv[1] 162 | ensure_dir("json_files") 163 | names = readCSV(csvFile) 164 | for name in names: 165 | print(name) 166 | try: 167 | getWordnetJSON(name,"json_files") 168 | except: 169 | print(str(name)+' Failed ') 170 | -------------------------------------------------------------------------------- /downloadFromBing/lib/google-images-scraper.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | var request = require('request') 4 | , cheerio = require('cheerio') 5 | , Promise = require('bluebird') 6 | , Nightmare = require('nightmare') 7 | , RateLimiter = require('limiter').RateLimiter 8 | , EventEmitter = require('events') 9 | , util = require('util'); 10 | 11 | function Scraper () { 12 | EventEmitter.call(this); 13 | } 14 | 15 | util.inherits(Scraper, EventEmitter); 16 | 17 | /** 18 | * Get the image src for images, options specify the details. 19 | */ 20 | Scraper.prototype.list = function (options) { 21 | var self = this; 22 | 23 | if (!options || !options.keyword) return Promise.reject(new Error('no keyword provided')); 24 | 25 | this.keyword = options.keyword; 26 | this.rlimit = new RateLimiter(options.rlimit || 0, 'second'); 27 | this.userAgent = options.userAgent || 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'; 28 | this.noptions = options.nightmare || {}; 29 | this.timeout = options.timeout || 10000; 30 | this.advanced = options.advanced; 31 | 32 | return self._links().then(function (res) { 33 | if (options.num) { 34 | res = res.slice(0, options.num); 35 | } 36 | 37 | res.filter(function (r) { 38 | return r !== null; 39 | }); 40 | 41 | self.emit('end', res); 42 | 43 | return res; 44 | }); 45 | } 46 | 47 | /** 48 | * Returns a complete list of all the image details. 49 | */ 50 | Scraper.prototype._links = function () { 51 | var self = this; 52 | var search_base = 'https://www.google.com/search?q=%&source=lnms&tbm=isch&sa=X'; 53 | if (this.advanced) { 54 | var base = '&tbs='; 55 | var build = []; 56 | if (this.advanced.resolution) { 57 | build.push('isz:'+this.advanced.resolution); 58 | } 59 | if (this.advanced.imgType) { 60 | build.push('itp:'+this.advanced.imgType); 61 | } 62 | 63 | build = build.length > 1 ? build.join(',') : build[0]; 64 | search_base += '&tbs='+build; 65 | } 66 | return new Promise.resolve( 67 | new Nightmare(self.noptions) 68 | .useragent(self.userAgent) 69 | .goto(search_base.replace('%', encodeURIComponent(self.keyword))) 70 | .wait() 71 | .inject('js', __dirname + '/jquery-2.1.4.min.js') 72 | 73 | .evaluate(function (timeout) { 74 | $.data(document, 'timeout', false); 75 | setTimeout(function () { 76 | $.data(document, 'timeout', true); 77 | }, timeout); 78 | 79 | setInterval(function() { 80 | $('html, body').animate({ scrollTop: $(document).height() }, 1000); 81 | 82 | var button = $('.ksb._kvc'); // try to load more 83 | if (button) { 84 | $.data(document, 'finished', false); 85 | button.click(); 86 | } 87 | }, 1000); 88 | 89 | // catch all AJAX events such that we can determine when we are finished 90 | var oldSend = XMLHttpRequest.prototype.send; 91 | XMLHttpRequest.prototype.send = function () { 92 | var oldOnReady = this.onreadystatechange; 93 | this.onreadystatechange = function () { 94 | oldOnReady.call(this); 95 | if (this.readyState === XMLHttpRequest.DONE) 96 | $.data(document, 'finished', true); 97 | } 98 | oldSend.apply(this, arguments); 99 | } 100 | }, self.timeout) 101 | .wait(function () { 102 | return (($(window).scrollTop() + $(window).height() == $(document).height()) && 103 | !$('.ksb._kvc').is(':visible') && 104 | $.data(document, 'finished')) || $.data(document, 'timeout'); 105 | }) 106 | 107 | .on('console', function(type, msg) { 108 | console.log('msg ' + msg); 109 | }) 110 | 111 | .evaluate(function () { 112 | // get all the src's 113 | var results = []; 114 | $('.rg_l').each(function () { 115 | var meta = JSON.parse($(this).parent().find('.rg_meta').text()); 116 | 117 | console.log(JSON.stringify(meta)); 118 | 119 | var item = { 120 | type: 'image/' + meta.ity, 121 | width: meta.ow, 122 | height: meta.oh, 123 | // size: meta.os.match(/[-+]?(\d*[.])?\d+/)[0], // fails query as property no longer exists 124 | url: meta.ou, 125 | thumb_url: meta.tu, 126 | thumb_width: meta.tw, 127 | thumb_height: meta.th 128 | // unit: meta.os.match(/\D+/).slice(-1)[0] // fails query as property no longer exists 129 | }; 130 | 131 | results.push(item); 132 | }); 133 | return results; 134 | }).end() 135 | ); 136 | } 137 | 138 | module.exports = Scraper; -------------------------------------------------------------------------------- /downloadFromBing/build/binding.target.mk: -------------------------------------------------------------------------------- 1 | # This file is generated by gyp; do not edit. 2 | 3 | TOOLSET := target 4 | TARGET := binding 5 | DEFS_Debug := \ 6 | '-DNODE_GYP_MODULE_NAME=binding' \ 7 | '-D_DARWIN_USE_64_BIT_INODE=1' \ 8 | '-D_LARGEFILE_SOURCE' \ 9 | '-D_FILE_OFFSET_BITS=64' \ 10 | '-DBUILDING_NODE_EXTENSION' \ 11 | '-DDEBUG' \ 12 | '-D_DEBUG' 13 | 14 | # Flags passed to all source files. 15 | CFLAGS_Debug := \ 16 | -O0 \ 17 | -gdwarf-2 \ 18 | -mmacosx-version-min=10.5 \ 19 | -arch x86_64 \ 20 | -Wall \ 21 | -Wendif-labels \ 22 | -W \ 23 | -Wno-unused-parameter 24 | 25 | # Flags passed to only C files. 26 | CFLAGS_C_Debug := \ 27 | -fno-strict-aliasing 28 | 29 | # Flags passed to only C++ files. 30 | CFLAGS_CC_Debug := \ 31 | -std=gnu++0x \ 32 | -fno-rtti \ 33 | -fno-exceptions \ 34 | -fno-threadsafe-statics \ 35 | -fno-strict-aliasing 36 | 37 | # Flags passed to only ObjC files. 38 | CFLAGS_OBJC_Debug := 39 | 40 | # Flags passed to only ObjC++ files. 41 | CFLAGS_OBJCC_Debug := 42 | 43 | INCS_Debug := \ 44 | -I/Users/brianlee/.node-gyp/4.4.3/include/node \ 45 | -I/Users/brianlee/.node-gyp/4.4.3/src \ 46 | -I/Users/brianlee/.node-gyp/4.4.3/deps/uv/include \ 47 | -I/Users/brianlee/.node-gyp/4.4.3/deps/v8/include 48 | 49 | DEFS_Release := \ 50 | '-DNODE_GYP_MODULE_NAME=binding' \ 51 | '-D_DARWIN_USE_64_BIT_INODE=1' \ 52 | '-D_LARGEFILE_SOURCE' \ 53 | '-D_FILE_OFFSET_BITS=64' \ 54 | '-DBUILDING_NODE_EXTENSION' 55 | 56 | # Flags passed to all source files. 57 | CFLAGS_Release := \ 58 | -Os \ 59 | -gdwarf-2 \ 60 | -mmacosx-version-min=10.5 \ 61 | -arch x86_64 \ 62 | -Wall \ 63 | -Wendif-labels \ 64 | -W \ 65 | -Wno-unused-parameter 66 | 67 | # Flags passed to only C files. 68 | CFLAGS_C_Release := \ 69 | -fno-strict-aliasing 70 | 71 | # Flags passed to only C++ files. 72 | CFLAGS_CC_Release := \ 73 | -std=gnu++0x \ 74 | -fno-rtti \ 75 | -fno-exceptions \ 76 | -fno-threadsafe-statics \ 77 | -fno-strict-aliasing 78 | 79 | # Flags passed to only ObjC files. 80 | CFLAGS_OBJC_Release := 81 | 82 | # Flags passed to only ObjC++ files. 83 | CFLAGS_OBJCC_Release := 84 | 85 | INCS_Release := \ 86 | -I/Users/brianlee/.node-gyp/4.4.3/include/node \ 87 | -I/Users/brianlee/.node-gyp/4.4.3/src \ 88 | -I/Users/brianlee/.node-gyp/4.4.3/deps/uv/include \ 89 | -I/Users/brianlee/.node-gyp/4.4.3/deps/v8/include 90 | 91 | OBJS := \ 92 | $(obj).target/$(TARGET)//node_modules/iconv/src/binding.o 93 | 94 | # Add to the list of files we specially track dependencies for. 95 | all_deps += $(OBJS) 96 | 97 | # CFLAGS et al overrides must be target-local. 98 | # See "Target-specific Variable Values" in the GNU Make manual. 99 | $(OBJS): TOOLSET := $(TOOLSET) 100 | $(OBJS): GYP_CFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) 101 | $(OBJS): GYP_CXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) 102 | $(OBJS): GYP_OBJCFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_C_$(BUILDTYPE)) $(CFLAGS_OBJC_$(BUILDTYPE)) 103 | $(OBJS): GYP_OBJCXXFLAGS := $(DEFS_$(BUILDTYPE)) $(INCS_$(BUILDTYPE)) $(CFLAGS_$(BUILDTYPE)) $(CFLAGS_CC_$(BUILDTYPE)) $(CFLAGS_OBJCC_$(BUILDTYPE)) 104 | 105 | # Suffix rules, putting all outputs into $(obj). 106 | 107 | $(obj).$(TOOLSET)/$(TARGET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD 108 | @$(call do_cmd,cxx,1) 109 | 110 | # Try building from generated source, too. 111 | 112 | $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD 113 | @$(call do_cmd,cxx,1) 114 | 115 | $(obj).$(TOOLSET)/$(TARGET)/%.o: $(obj)/%.cc FORCE_DO_CMD 116 | @$(call do_cmd,cxx,1) 117 | 118 | # End of this set of suffix rules 119 | ### Rules for final target. 120 | LDFLAGS_Debug := \ 121 | -undefined dynamic_lookup \ 122 | -Wl,-search_paths_first \ 123 | -mmacosx-version-min=10.5 \ 124 | -arch x86_64 \ 125 | -L$(builddir) 126 | 127 | LIBTOOLFLAGS_Debug := \ 128 | -undefined dynamic_lookup \ 129 | -Wl,-search_paths_first 130 | 131 | LDFLAGS_Release := \ 132 | -undefined dynamic_lookup \ 133 | -Wl,-search_paths_first \ 134 | -mmacosx-version-min=10.5 \ 135 | -arch x86_64 \ 136 | -L$(builddir) 137 | 138 | LIBTOOLFLAGS_Release := \ 139 | -undefined dynamic_lookup \ 140 | -Wl,-search_paths_first 141 | 142 | LIBS := 143 | 144 | $(builddir)/binding.node: GYP_LDFLAGS := $(LDFLAGS_$(BUILDTYPE)) 145 | $(builddir)/binding.node: LIBS := $(LIBS) 146 | $(builddir)/binding.node: GYP_LIBTOOLFLAGS := $(LIBTOOLFLAGS_$(BUILDTYPE)) 147 | $(builddir)/binding.node: TOOLSET := $(TOOLSET) 148 | $(builddir)/binding.node: $(OBJS) FORCE_DO_CMD 149 | $(call do_cmd,solink_module) 150 | 151 | all_deps += $(builddir)/binding.node 152 | # Add target alias 153 | .PHONY: binding 154 | binding: $(builddir)/binding.node 155 | 156 | # Short alias for building this executable. 157 | .PHONY: binding.node 158 | binding.node: $(builddir)/binding.node 159 | 160 | # Add executable to "all" target. 161 | .PHONY: all 162 | all: $(builddir)/binding.node 163 | 164 | -------------------------------------------------------------------------------- /imageNetFlickr/37classWordNetID/personId.csv: -------------------------------------------------------------------------------- 1 | n00007846 2 | n09604981 3 | n09605289 4 | n09606009 5 | n09606527 6 | n09607280 7 | n09607630 8 | n09609232 9 | n09609561 10 | n09609871 11 | n09610255 12 | n09610405 13 | n09610660 14 | n09613191 15 | n09614047 16 | n09614315 17 | n09615465 18 | n09615807 19 | n09616922 20 | n09617696 21 | n09617867 22 | n09618957 23 | n09619168 24 | n09619824 25 | n09620078 26 | n09620794 27 | n09621232 28 | n09621359 29 | n09621545 30 | n09622049 31 | n09622302 32 | n09622928 33 | n09623038 34 | n09624168 35 | n09624980 36 | n09625401 37 | n09625789 38 | n09626031 39 | n09626238 40 | n09626589 41 | n09627017 42 | n09627117 43 | n09627462 44 | n09628382 45 | n09629246 46 | n09629752 47 | n09630641 48 | n09631129 49 | n09632274 50 | n09632518 51 | n09634494 52 | n09636106 53 | n09636339 54 | n09638875 55 | n09644820 56 | n09676884 57 | n09679170 58 | n09681351 59 | n09752246 60 | n09752381 61 | n09752519 62 | n09752657 63 | n09752795 64 | n09752927 65 | n09753065 66 | n09753204 67 | n09753348 68 | n09753498 69 | n09753642 70 | n09753792 71 | n09754051 72 | n09754541 73 | n09756961 74 | n09757944 75 | n09762821 76 | n09763784 77 | n09764201 78 | n09764900 79 | n09767197 80 | n09769636 81 | n09771664 82 | n09772330 83 | n09773245 84 | n09774167 85 | n09774783 86 | n09776261 87 | n09779124 88 | n09786585 89 | n09793141 90 | n09796809 91 | n09796974 92 | n09801102 93 | n09802445 94 | n09804230 95 | n09810364 96 | n09815076 97 | n09817536 98 | n09824609 99 | n09825413 100 | n09828403 101 | n09828600 102 | n09831856 103 | n09831962 104 | n09833896 105 | n09833997 106 | n09836160 107 | n09843602 108 | n09845401 109 | n09846265 110 | n09850457 111 | n09851165 112 | n09856671 113 | n09857852 114 | n09860415 115 | n09860506 116 | n09861287 117 | n09862845 118 | n09864536 119 | n09877856 120 | n09883452 121 | n09890749 122 | n09898892 123 | n09899289 124 | n09902954 125 | n09903936 126 | n09906449 127 | n09910374 128 | n09918554 129 | n09921673 130 | n09930464 131 | n09931267 132 | n09936620 133 | n09939313 134 | n09947127 135 | n09950457 136 | n09951274 137 | n09960315 138 | n09962414 139 | n09964411 140 | n09969491 141 | n09970088 142 | n09976119 143 | n09976429 144 | n09976728 145 | n09978889 146 | n09990415 147 | n09994943 148 | n09996481 149 | n09997212 150 | n09997622 151 | n10000007 152 | n10000616 153 | n10001058 154 | n10001647 155 | n10012377 156 | n10012815 157 | n10016954 158 | n10018021 159 | n10019888 160 | n10024362 161 | n10027246 162 | n10033225 163 | n10033663 164 | n10036266 165 | n10040617 166 | n10044682 167 | n10046527 168 | n10050712 169 | n10052843 170 | n10055730 171 | n10058411 172 | n10059162 173 | n10065547 174 | n10072708 175 | n10074841 176 | n10075899 177 | n10076778 178 | n10080337 179 | n10086074 180 | n10093396 181 | n10099375 182 | n10109662 183 | n10112591 184 | n10115082 185 | n10117511 186 | n10117739 187 | n10118844 188 | n10122128 189 | n10122300 190 | n10138369 191 | n10138767 192 | n10143725 193 | n10146927 194 | n10147262 195 | n10147619 196 | n10149436 197 | n10150794 198 | n10158756 199 | n10162194 200 | n10173895 201 | n10182913 202 | n10183157 203 | n10184946 204 | n10185148 205 | n10190745 206 | n10191001 207 | n10199783 208 | n10209888 209 | n10212780 210 | n10213429 211 | n10219879 212 | n10221656 213 | n10226993 214 | n10227266 215 | n10231087 216 | n10235549 217 | n10236842 218 | n10238272 219 | n10239761 220 | n10240082 221 | n10247044 222 | n10247880 223 | n10248876 224 | n10251779 225 | n10253122 226 | n10260706 227 | n10262183 228 | n10264219 229 | n10266328 230 | n10268299 231 | n10270878 232 | n10271525 233 | n10278666 234 | n10282920 235 | n10284965 236 | n10289039 237 | n10291110 238 | n10291730 239 | n10295819 240 | n10299700 241 | n10304383 242 | n10308066 243 | n10310903 244 | n10311823 245 | n10314182 246 | n10321754 247 | n10322546 248 | n10323999 249 | n10326551 250 | n10328941 251 | n10333165 252 | n10335563 253 | n10341955 254 | n10344774 255 | n10344922 256 | n10351625 257 | n10352299 258 | n10355142 259 | n10361060 260 | n10361296 261 | n10361390 262 | n10361525 263 | n10362003 264 | n10362319 265 | n10365399 266 | n10367409 267 | n10370381 268 | n10380126 269 | n10384496 270 | n10385707 271 | n10386071 272 | n10386515 273 | n10386618 274 | n10389398 275 | n10395390 276 | n10396462 277 | n10399299 278 | n10402417 279 | n10402824 280 | n10404550 281 | n10417682 282 | n10418101 283 | n10418735 284 | n10425946 285 | n10431625 286 | n10435716 287 | n10438172 288 | n10440580 289 | n10457777 290 | n10461169 291 | n10466918 292 | n10484739 293 | n10490965 294 | n10495167 295 | n10495975 296 | n10498699 297 | n10502046 298 | n10503452 299 | n10509605 300 | n10512982 301 | n10513823 302 | n10516692 303 | n10518349 304 | n10521470 305 | n10522759 306 | n10524973 307 | n10525134 308 | n10526534 309 | n10529231 310 | n10530959 311 | n10532576 312 | n10538154 313 | n10540656 314 | n10541229 315 | n10543795 316 | n10560637 317 | n10563711 318 | n10569179 319 | n10575594 320 | n10575787 321 | n10576223 322 | n10579676 323 | n10584853 324 | n10585077 325 | n10585976 326 | n10594043 327 | n10597234 328 | n10599354 329 | n10604180 330 | n10605088 331 | n10609325 332 | n10609686 333 | n10611541 334 | n10612803 335 | n10613505 336 | n10614225 337 | n10614363 338 | n10616578 339 | n10616670 340 | n10616779 341 | n10617904 342 | n10618007 343 | n10619492 344 | n10626722 345 | n10627349 346 | n10635788 347 | n10636874 348 | n10639047 349 | n10640968 350 | n10641551 351 | n10643727 352 | n10656223 353 | n10656488 354 | n10659762 355 | n10661216 356 | n10665302 357 | n10668666 358 | n10676682 359 | n10679998 360 | n10680910 361 | n10681060 362 | n10681383 363 | n10688811 364 | n10688975 365 | n10691600 366 | n10699752 367 | n10702167 368 | n10702615 369 | n10703336 370 | n10708797 371 | n10709256 372 | n10709529 373 | n10710632 374 | n10717461 375 | n10717589 376 | n10724372 377 | n10725734 378 | n10726031 379 | n10728998 380 | n10733350 381 | n10735564 382 | n10737431 383 | n10741590 384 | n10746346 385 | n10752480 386 | n10753061 387 | n10756641 388 | n10757625 389 | n10763725 390 | n10763878 391 | n10764296 392 | n10766025 393 | n10767020 394 | n10768585 395 | n10769782 396 | n10771636 397 | n10771990 398 | n10781236 399 | n10783539 400 | n10785695 401 | n10786517 402 | n10791890 403 | n10803193 404 | -------------------------------------------------------------------------------- /9murls/getImages.py: -------------------------------------------------------------------------------- 1 | #2016 Oct by Sangpil Kim 2 | __author__ = 'Sangpil Kim' 3 | 4 | import os 5 | import csv 6 | import json 7 | import click 8 | from scipy.misc import imresize, imread, imsave 9 | from urllib import request as rq 10 | from os.path import join 11 | from os.path import isdir 12 | from pathlib import Path 13 | from subprocess import call 14 | import multiprocessing as mul 15 | from tqdm import tqdm 16 | from concurrent import futures 17 | 18 | #Write Json 19 | def writeJson(label,filename): 20 | with open(filename, mode='w', encoding='utf-8') as f: 21 | json.dump(label,f) 22 | #read Json 23 | def readJson(filename): 24 | with open(filename, mode='r', encoding='utf-8') as f: 25 | jsonV = json.load(f) 26 | return jsonV 27 | #Loading csv 28 | def load_csv(csv_filepath): 29 | csv_filepath = join(os.curdir,csv_filepath) 30 | print('loading csv from {}'.format(csv_filepath)) 31 | with open(csv_filepath) as csvfile: 32 | reader = csv.reader(csvfile) 33 | lists = list(reader) 34 | return lists 35 | #Loading dic format csv for images.csv 36 | def load_dic_csv(csv_filepath): 37 | csv_filepath = join(os.curdir,csv_filepath) 38 | print('loading dic from {} '.format(csv_filepath)) 39 | with open(csv_filepath) as csvfile: 40 | reader = csv.DictReader(csvfile) 41 | lists = [] 42 | for row in reader: 43 | lists.append({ 'ImageID': row['ImageID'], 44 | 'Subset': row['Subset'], 45 | 'OriginalURL': row['OriginalURL'], 46 | 'License': row['License'], 47 | 'Title': row['Title']}) 48 | return lists 49 | #Loading label csv 50 | def load_label_csv(csv_filepath): 51 | csv_filepath = join(os.curdir,csv_filepath) 52 | tmp = load_csv(csv_filepath) 53 | lists = [] 54 | print('Laoding label from csv') 55 | for i in range(1,len(tmp)): 56 | tmp2 = tmp[i] 57 | for i in range(1,len(tmp2)): 58 | tmp3 = tmp2[i].split(':') 59 | lists.append({ tmp3[1]:tmp2[0]}) 60 | return lists 61 | 62 | #code extract function 63 | def getCode(classes41,dicts): 64 | print('Combin class with dict.csv') 65 | match = {} 66 | #Iter target classes 67 | for name in classes41: 68 | name = name[0] 69 | tmp = [] 70 | #Iter 9murl classes 71 | for info in dicts: 72 | #Perform exact match 73 | if name == info[1]: 74 | tmp.append(info[0]) 75 | #Since exact match it mas only 1 code 76 | match[name] = tmp[0] 77 | #Check missing item 78 | for item in match: 79 | list = match[item] 80 | if not list: 81 | print('{} item missing in dict'.format(item)) 82 | return match 83 | 84 | #Check file if not create 85 | def checkFile(path): 86 | if not isdir(path): 87 | call(['mkdir','-p',path]) 88 | else: 89 | print('{} exist'.format(path)) 90 | #reSize img 91 | def resizeImg(imgPath,img_size): 92 | img = imread(imgPath) 93 | h, w, _ = img.shape 94 | scale = 1 95 | if w >= h: 96 | new_w = img_size 97 | if w >= new_w: 98 | scale = float(new_w) / w 99 | new_h = int(h * scale) 100 | else: 101 | new_h = img_size 102 | if h >= new_h: 103 | scale = float(new_h) / h 104 | new_w = int(w * scale) 105 | new_img = imresize(img, (new_h, new_w), interp='bilinear') 106 | imsave(imgPath,new_img) 107 | 108 | #Download img 109 | #Later we can do multi thread apply workers to do faster work 110 | def downLoadImg(rootPath,img_size,thred_number,infoList,codeTable): 111 | rootPath = join(rootPath,infoList[0]['Subset']) 112 | #MAKE code as key change infoList 113 | dic = {} 114 | #Convert infoList to hashable dic with 64bit img code ID 115 | for info in infoList: 116 | dic[info['ImageID']] = info 117 | def process(code): 118 | print('Downloading class : {}'.format(code[0])) 119 | folderPath = join(rootPath,code[0]) 120 | #Check folder if not create 121 | checkFile(folderPath) 122 | #Lets download code code[1] has option number of code 123 | for id in code[1]: 124 | #Get info from dictionary 125 | if id in dic.keys(): 126 | info = dic[id] 127 | #Get url 128 | url = info['OriginalURL'] 129 | #Extract extention 130 | ext = url.split('.') 131 | ext = ext[len(ext)-1] 132 | #Set save path for image 133 | savePath = join(folderPath,str(id)+ '.' + ext) 134 | check = Path(savePath) 135 | #Check if we downloaded before 136 | if not check.is_file(): 137 | print('Downloading : {} at {} class {}' .format(info['ImageID'],info['Subset'],code[0])) 138 | print(url) 139 | p = mul.Process(target = rq.urlretrieve, name='download',args=(url,savePath)) 140 | p.start() 141 | # Let's wait 20 sec for downloading 142 | p.join(20) 143 | if p.is_alive(): 144 | print('Too longdownloading terminate') 145 | p.terminate() 146 | p.join() 147 | #Delete junks which we fail to download 148 | call(['rm','-rf',savePath]) 149 | # If we succeed exitcode will be 0 150 | if p.exitcode == 1: 151 | print('fail') 152 | else: 153 | #Lets resize with 256 size 154 | try: 155 | resizeImg(savePath,img_size) 156 | print('resized') 157 | except Exception as e: 158 | print(e) 159 | else: 160 | print('Already Downloaded') 161 | 162 | #Check classes with own code 163 | #Iterate code table 164 | with futures.ThreadPoolExecutor(max_workers=thred_number) as worker: 165 | mapper = [worker.submit(process,code) for code in codeTable] 166 | for tmp in tqdm(futures.as_completed(mapper), total=len(mapper)): 167 | pass 168 | #for code in codeTable: 169 | # num : number of image match: dic of image class 170 | #labels from labes.csv 171 | def getCodeFromLabel(num,match,labels): 172 | print('Get code from labels') 173 | t = [] 174 | for key, value in match.items(): 175 | tmp = [] 176 | for label in labels: 177 | if value in label.keys(): 178 | tmp.append(label[value]) 179 | if len(tmp) == num: 180 | break 181 | t.append([key,tmp]) 182 | return t 183 | @click.command() 184 | @click.option('--dict',default='dict.csv') 185 | @click.option('--target',default='41classes.csv') 186 | @click.option('--images_csv',default='source/images_2016_08/validation/images.csv') 187 | @click.option('--label_csv',default='source/machine_ann_2016_08/validation/labels.csv') 188 | @click.option('--num',default=2) 189 | @click.option('--img_size',default=256) 190 | @click.option('--down_folder',default='testDown') 191 | @click.option('--thred_number',default=5) 192 | 193 | def main(dict,target,images_csv,label_csv,num,img_size,down_folder,thred_number): 194 | print(dict) 195 | # dict is class name and own id mapper from google 196 | #Load dictionary 197 | dicts = load_csv(dict) 198 | #Get our class 199 | # We want this classes csv 200 | classes41 = load_csv(target) 201 | # MApping our to google dictionary 202 | match = getCode(classes41,dicts) 203 | #Print for test 204 | print('Show classes and target code') 205 | print(match) 206 | #Decide where we want train? validation 207 | #images.csv have url, authorm licence, etc 208 | #ImageID, Subset, OriginalURL, Title 209 | source = load_dic_csv(images_csv) 210 | #labels.csv has 64bit img ids and map to target class 211 | labels = load_label_csv(label_csv) 212 | #Set our number per class 213 | #Get img 64bit info mapping 214 | codeTable = getCodeFromLabel(num,match,labels) 215 | #Set up our target folder 216 | #Call downloader to download images 217 | downLoadImg(down_folder,img_size,thred_number,source,codeTable) 218 | 219 | if __name__ == '__main__': 220 | main() 221 | -------------------------------------------------------------------------------- /downloadFromBing/build/Makefile: -------------------------------------------------------------------------------- 1 | # We borrow heavily from the kernel build setup, though we are simpler since 2 | # we don't have Kconfig tweaking settings on us. 3 | 4 | # The implicit make rules have it looking for RCS files, among other things. 5 | # We instead explicitly write all the rules we care about. 6 | # It's even quicker (saves ~200ms) to pass -r on the command line. 7 | MAKEFLAGS=-r 8 | 9 | # The source directory tree. 10 | srcdir := .. 11 | abs_srcdir := $(abspath $(srcdir)) 12 | 13 | # The name of the builddir. 14 | builddir_name ?= . 15 | 16 | # The V=1 flag on command line makes us verbosely print command lines. 17 | ifdef V 18 | quiet= 19 | else 20 | quiet=quiet_ 21 | endif 22 | 23 | # Specify BUILDTYPE=Release on the command line for a release build. 24 | BUILDTYPE ?= Release 25 | 26 | # Directory all our build output goes into. 27 | # Note that this must be two directories beneath src/ for unit tests to pass, 28 | # as they reach into the src/ directory for data with relative paths. 29 | builddir ?= $(builddir_name)/$(BUILDTYPE) 30 | abs_builddir := $(abspath $(builddir)) 31 | depsdir := $(builddir)/.deps 32 | 33 | # Object output directory. 34 | obj := $(builddir)/obj 35 | abs_obj := $(abspath $(obj)) 36 | 37 | # We build up a list of every single one of the targets so we can slurp in the 38 | # generated dependency rule Makefiles in one pass. 39 | all_deps := 40 | 41 | 42 | 43 | CC.target ?= $(CC) 44 | CFLAGS.target ?= $(CPPFLAGS) $(CFLAGS) 45 | CXX.target ?= $(CXX) 46 | CXXFLAGS.target ?= $(CPPFLAGS) $(CXXFLAGS) 47 | LINK.target ?= $(LINK) 48 | LDFLAGS.target ?= $(LDFLAGS) 49 | AR.target ?= $(AR) 50 | 51 | # C++ apps need to be linked with g++. 52 | LINK ?= $(CXX.target) 53 | 54 | # TODO(evan): move all cross-compilation logic to gyp-time so we don't need 55 | # to replicate this environment fallback in make as well. 56 | CC.host ?= gcc 57 | CFLAGS.host ?= $(CPPFLAGS_host) $(CFLAGS_host) 58 | CXX.host ?= g++ 59 | CXXFLAGS.host ?= $(CPPFLAGS_host) $(CXXFLAGS_host) 60 | LINK.host ?= $(CXX.host) 61 | LDFLAGS.host ?= 62 | AR.host ?= ar 63 | 64 | # Define a dir function that can handle spaces. 65 | # http://www.gnu.org/software/make/manual/make.html#Syntax-of-Functions 66 | # "leading spaces cannot appear in the text of the first argument as written. 67 | # These characters can be put into the argument value by variable substitution." 68 | empty := 69 | space := $(empty) $(empty) 70 | 71 | # http://stackoverflow.com/questions/1189781/using-make-dir-or-notdir-on-a-path-with-spaces 72 | replace_spaces = $(subst $(space),?,$1) 73 | unreplace_spaces = $(subst ?,$(space),$1) 74 | dirx = $(call unreplace_spaces,$(dir $(call replace_spaces,$1))) 75 | 76 | # Flags to make gcc output dependency info. Note that you need to be 77 | # careful here to use the flags that ccache and distcc can understand. 78 | # We write to a dep file on the side first and then rename at the end 79 | # so we can't end up with a broken dep file. 80 | depfile = $(depsdir)/$(call replace_spaces,$@).d 81 | DEPFLAGS = -MMD -MF $(depfile).raw 82 | 83 | # We have to fixup the deps output in a few ways. 84 | # (1) the file output should mention the proper .o file. 85 | # ccache or distcc lose the path to the target, so we convert a rule of 86 | # the form: 87 | # foobar.o: DEP1 DEP2 88 | # into 89 | # path/to/foobar.o: DEP1 DEP2 90 | # (2) we want missing files not to cause us to fail to build. 91 | # We want to rewrite 92 | # foobar.o: DEP1 DEP2 \ 93 | # DEP3 94 | # to 95 | # DEP1: 96 | # DEP2: 97 | # DEP3: 98 | # so if the files are missing, they're just considered phony rules. 99 | # We have to do some pretty insane escaping to get those backslashes 100 | # and dollar signs past make, the shell, and sed at the same time. 101 | # Doesn't work with spaces, but that's fine: .d files have spaces in 102 | # their names replaced with other characters. 103 | define fixup_dep 104 | # The depfile may not exist if the input file didn't have any #includes. 105 | touch $(depfile).raw 106 | # Fixup path as in (1). 107 | sed -e "s|^$(notdir $@)|$@|" $(depfile).raw >> $(depfile) 108 | # Add extra rules as in (2). 109 | # We remove slashes and replace spaces with new lines; 110 | # remove blank lines; 111 | # delete the first line and append a colon to the remaining lines. 112 | sed -e 's|\\||' -e 'y| |\n|' $(depfile).raw |\ 113 | grep -v '^$$' |\ 114 | sed -e 1d -e 's|$$|:|' \ 115 | >> $(depfile) 116 | rm $(depfile).raw 117 | endef 118 | 119 | # Command definitions: 120 | # - cmd_foo is the actual command to run; 121 | # - quiet_cmd_foo is the brief-output summary of the command. 122 | 123 | quiet_cmd_cc = CC($(TOOLSET)) $@ 124 | cmd_cc = $(CC.$(TOOLSET)) $(GYP_CFLAGS) $(DEPFLAGS) $(CFLAGS.$(TOOLSET)) -c -o $@ $< 125 | 126 | quiet_cmd_cxx = CXX($(TOOLSET)) $@ 127 | cmd_cxx = $(CXX.$(TOOLSET)) $(GYP_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< 128 | 129 | quiet_cmd_objc = CXX($(TOOLSET)) $@ 130 | cmd_objc = $(CC.$(TOOLSET)) $(GYP_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< 131 | 132 | quiet_cmd_objcxx = CXX($(TOOLSET)) $@ 133 | cmd_objcxx = $(CXX.$(TOOLSET)) $(GYP_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< 134 | 135 | # Commands for precompiled header files. 136 | quiet_cmd_pch_c = CXX($(TOOLSET)) $@ 137 | cmd_pch_c = $(CC.$(TOOLSET)) $(GYP_PCH_CFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< 138 | quiet_cmd_pch_cc = CXX($(TOOLSET)) $@ 139 | cmd_pch_cc = $(CC.$(TOOLSET)) $(GYP_PCH_CXXFLAGS) $(DEPFLAGS) $(CXXFLAGS.$(TOOLSET)) -c -o $@ $< 140 | quiet_cmd_pch_m = CXX($(TOOLSET)) $@ 141 | cmd_pch_m = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCFLAGS) $(DEPFLAGS) -c -o $@ $< 142 | quiet_cmd_pch_mm = CXX($(TOOLSET)) $@ 143 | cmd_pch_mm = $(CC.$(TOOLSET)) $(GYP_PCH_OBJCXXFLAGS) $(DEPFLAGS) -c -o $@ $< 144 | 145 | # gyp-mac-tool is written next to the root Makefile by gyp. 146 | # Use $(4) for the command, since $(2) and $(3) are used as flag by do_cmd 147 | # already. 148 | quiet_cmd_mac_tool = MACTOOL $(4) $< 149 | cmd_mac_tool = ./gyp-mac-tool $(4) $< "$@" 150 | 151 | quiet_cmd_mac_package_framework = PACKAGE FRAMEWORK $@ 152 | cmd_mac_package_framework = ./gyp-mac-tool package-framework "$@" $(4) 153 | 154 | quiet_cmd_infoplist = INFOPLIST $@ 155 | cmd_infoplist = $(CC.$(TOOLSET)) -E -P -Wno-trigraphs -x c $(INFOPLIST_DEFINES) "$<" -o "$@" 156 | 157 | quiet_cmd_touch = TOUCH $@ 158 | cmd_touch = touch $@ 159 | 160 | quiet_cmd_copy = COPY $@ 161 | # send stderr to /dev/null to ignore messages when linking directories. 162 | cmd_copy = rm -rf "$@" && cp -af "$<" "$@" 163 | 164 | quiet_cmd_alink = LIBTOOL-STATIC $@ 165 | cmd_alink = rm -f $@ && ./gyp-mac-tool filter-libtool libtool $(GYP_LIBTOOLFLAGS) -static -o $@ $(filter %.o,$^) 166 | 167 | quiet_cmd_link = LINK($(TOOLSET)) $@ 168 | cmd_link = $(LINK.$(TOOLSET)) $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) 169 | 170 | quiet_cmd_solink = SOLINK($(TOOLSET)) $@ 171 | cmd_solink = $(LINK.$(TOOLSET)) -shared $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o "$@" $(LD_INPUTS) $(LIBS) 172 | 173 | quiet_cmd_solink_module = SOLINK_MODULE($(TOOLSET)) $@ 174 | cmd_solink_module = $(LINK.$(TOOLSET)) -bundle $(GYP_LDFLAGS) $(LDFLAGS.$(TOOLSET)) -o $@ $(filter-out FORCE_DO_CMD, $^) $(LIBS) 175 | 176 | 177 | # Define an escape_quotes function to escape single quotes. 178 | # This allows us to handle quotes properly as long as we always use 179 | # use single quotes and escape_quotes. 180 | escape_quotes = $(subst ','\'',$(1)) 181 | # This comment is here just to include a ' to unconfuse syntax highlighting. 182 | # Define an escape_vars function to escape '$' variable syntax. 183 | # This allows us to read/write command lines with shell variables (e.g. 184 | # $LD_LIBRARY_PATH), without triggering make substitution. 185 | escape_vars = $(subst $$,$$$$,$(1)) 186 | # Helper that expands to a shell command to echo a string exactly as it is in 187 | # make. This uses printf instead of echo because printf's behaviour with respect 188 | # to escape sequences is more portable than echo's across different shells 189 | # (e.g., dash, bash). 190 | exact_echo = printf '%s\n' '$(call escape_quotes,$(1))' 191 | 192 | # Helper to compare the command we're about to run against the command 193 | # we logged the last time we ran the command. Produces an empty 194 | # string (false) when the commands match. 195 | # Tricky point: Make has no string-equality test function. 196 | # The kernel uses the following, but it seems like it would have false 197 | # positives, where one string reordered its arguments. 198 | # arg_check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \ 199 | # $(filter-out $(cmd_$@), $(cmd_$(1)))) 200 | # We instead substitute each for the empty string into the other, and 201 | # say they're equal if both substitutions produce the empty string. 202 | # .d files contain ? instead of spaces, take that into account. 203 | command_changed = $(or $(subst $(cmd_$(1)),,$(cmd_$(call replace_spaces,$@))),\ 204 | $(subst $(cmd_$(call replace_spaces,$@)),,$(cmd_$(1)))) 205 | 206 | # Helper that is non-empty when a prerequisite changes. 207 | # Normally make does this implicitly, but we force rules to always run 208 | # so we can check their command lines. 209 | # $? -- new prerequisites 210 | # $| -- order-only dependencies 211 | prereq_changed = $(filter-out FORCE_DO_CMD,$(filter-out $|,$?)) 212 | 213 | # Helper that executes all postbuilds until one fails. 214 | define do_postbuilds 215 | @E=0;\ 216 | for p in $(POSTBUILDS); do\ 217 | eval $$p;\ 218 | E=$$?;\ 219 | if [ $$E -ne 0 ]; then\ 220 | break;\ 221 | fi;\ 222 | done;\ 223 | if [ $$E -ne 0 ]; then\ 224 | rm -rf "$@";\ 225 | exit $$E;\ 226 | fi 227 | endef 228 | 229 | # do_cmd: run a command via the above cmd_foo names, if necessary. 230 | # Should always run for a given target to handle command-line changes. 231 | # Second argument, if non-zero, makes it do asm/C/C++ dependency munging. 232 | # Third argument, if non-zero, makes it do POSTBUILDS processing. 233 | # Note: We intentionally do NOT call dirx for depfile, since it contains ? for 234 | # spaces already and dirx strips the ? characters. 235 | define do_cmd 236 | $(if $(or $(command_changed),$(prereq_changed)), 237 | @$(call exact_echo, $($(quiet)cmd_$(1))) 238 | @mkdir -p "$(call dirx,$@)" "$(dir $(depfile))" 239 | $(if $(findstring flock,$(word 2,$(cmd_$1))), 240 | @$(cmd_$(1)) 241 | @echo " $(quiet_cmd_$(1)): Finished", 242 | @$(cmd_$(1)) 243 | ) 244 | @$(call exact_echo,$(call escape_vars,cmd_$(call replace_spaces,$@) := $(cmd_$(1)))) > $(depfile) 245 | @$(if $(2),$(fixup_dep)) 246 | $(if $(and $(3), $(POSTBUILDS)), 247 | $(call do_postbuilds) 248 | ) 249 | ) 250 | endef 251 | 252 | # Declare the "all" target first so it is the default, 253 | # even though we don't have the deps yet. 254 | .PHONY: all 255 | all: 256 | 257 | # make looks for ways to re-generate included makefiles, but in our case, we 258 | # don't have a direct way. Explicitly telling make that it has nothing to do 259 | # for them makes it go faster. 260 | %.d: ; 261 | 262 | # Use FORCE_DO_CMD to force a target to run. Should be coupled with 263 | # do_cmd. 264 | .PHONY: FORCE_DO_CMD 265 | FORCE_DO_CMD: 266 | 267 | TOOLSET := target 268 | # Suffix rules, putting all outputs into $(obj). 269 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.c FORCE_DO_CMD 270 | @$(call do_cmd,cc,1) 271 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cc FORCE_DO_CMD 272 | @$(call do_cmd,cxx,1) 273 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cpp FORCE_DO_CMD 274 | @$(call do_cmd,cxx,1) 275 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.cxx FORCE_DO_CMD 276 | @$(call do_cmd,cxx,1) 277 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.m FORCE_DO_CMD 278 | @$(call do_cmd,objc,1) 279 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.mm FORCE_DO_CMD 280 | @$(call do_cmd,objcxx,1) 281 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.S FORCE_DO_CMD 282 | @$(call do_cmd,cc,1) 283 | $(obj).$(TOOLSET)/%.o: $(srcdir)/%.s FORCE_DO_CMD 284 | @$(call do_cmd,cc,1) 285 | 286 | # Try building from generated source, too. 287 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.c FORCE_DO_CMD 288 | @$(call do_cmd,cc,1) 289 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cc FORCE_DO_CMD 290 | @$(call do_cmd,cxx,1) 291 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cpp FORCE_DO_CMD 292 | @$(call do_cmd,cxx,1) 293 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.cxx FORCE_DO_CMD 294 | @$(call do_cmd,cxx,1) 295 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.m FORCE_DO_CMD 296 | @$(call do_cmd,objc,1) 297 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.mm FORCE_DO_CMD 298 | @$(call do_cmd,objcxx,1) 299 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.S FORCE_DO_CMD 300 | @$(call do_cmd,cc,1) 301 | $(obj).$(TOOLSET)/%.o: $(obj).$(TOOLSET)/%.s FORCE_DO_CMD 302 | @$(call do_cmd,cc,1) 303 | 304 | $(obj).$(TOOLSET)/%.o: $(obj)/%.c FORCE_DO_CMD 305 | @$(call do_cmd,cc,1) 306 | $(obj).$(TOOLSET)/%.o: $(obj)/%.cc FORCE_DO_CMD 307 | @$(call do_cmd,cxx,1) 308 | $(obj).$(TOOLSET)/%.o: $(obj)/%.cpp FORCE_DO_CMD 309 | @$(call do_cmd,cxx,1) 310 | $(obj).$(TOOLSET)/%.o: $(obj)/%.cxx FORCE_DO_CMD 311 | @$(call do_cmd,cxx,1) 312 | $(obj).$(TOOLSET)/%.o: $(obj)/%.m FORCE_DO_CMD 313 | @$(call do_cmd,objc,1) 314 | $(obj).$(TOOLSET)/%.o: $(obj)/%.mm FORCE_DO_CMD 315 | @$(call do_cmd,objcxx,1) 316 | $(obj).$(TOOLSET)/%.o: $(obj)/%.S FORCE_DO_CMD 317 | @$(call do_cmd,cc,1) 318 | $(obj).$(TOOLSET)/%.o: $(obj)/%.s FORCE_DO_CMD 319 | @$(call do_cmd,cc,1) 320 | 321 | 322 | ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ 323 | $(findstring $(join ^,$(prefix)),\ 324 | $(join ^,binding.target.mk)))),) 325 | include binding.target.mk 326 | endif 327 | 328 | quiet_cmd_regen_makefile = ACTION Regenerating $@ 329 | cmd_regen_makefile = cd $(srcdir); /usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/brianlee/Desktop/images-scraper-master/build/config.gypi -I/usr/local/lib/node_modules/node-gyp/addon.gypi -I/Users/brianlee/.node-gyp/4.4.3/include/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/brianlee/.node-gyp/4.4.3" "-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp" "-Dnode_lib_file=node.lib" "-Dmodule_root_dir=/Users/brianlee/Desktop/images-scraper-master" binding.gyp 330 | Makefile: $(srcdir)/../../.node-gyp/4.4.3/include/node/common.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../usr/local/lib/node_modules/node-gyp/addon.gypi 331 | $(call do_cmd,regen_makefile) 332 | 333 | # "all" is a concatenation of the "all" targets from all the included 334 | # sub-makefiles. This is just here to clarify. 335 | all: 336 | 337 | # Add in dependency-tracking rules. $(all_deps) is the list of every single 338 | # target in our tree. Only consider the ones with .d (dependency) info: 339 | d_files := $(wildcard $(foreach f,$(all_deps),$(depsdir)/$(f).d)) 340 | ifneq ($(d_files),) 341 | include $(d_files) 342 | endif 343 | -------------------------------------------------------------------------------- /downloadFromBing/build/gyp-mac-tool: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # Generated by gyp. Do not edit. 3 | # Copyright (c) 2012 Google Inc. All rights reserved. 4 | # Use of this source code is governed by a BSD-style license that can be 5 | # found in the LICENSE file. 6 | 7 | """Utility functions to perform Xcode-style build steps. 8 | 9 | These functions are executed via gyp-mac-tool when using the Makefile generator. 10 | """ 11 | 12 | import fcntl 13 | import fnmatch 14 | import glob 15 | import json 16 | import os 17 | import plistlib 18 | import re 19 | import shutil 20 | import string 21 | import subprocess 22 | import sys 23 | import tempfile 24 | 25 | 26 | def main(args): 27 | executor = MacTool() 28 | exit_code = executor.Dispatch(args) 29 | if exit_code is not None: 30 | sys.exit(exit_code) 31 | 32 | 33 | class MacTool(object): 34 | """This class performs all the Mac tooling steps. The methods can either be 35 | executed directly, or dispatched from an argument list.""" 36 | 37 | def Dispatch(self, args): 38 | """Dispatches a string command to a method.""" 39 | if len(args) < 1: 40 | raise Exception("Not enough arguments") 41 | 42 | method = "Exec%s" % self._CommandifyName(args[0]) 43 | return getattr(self, method)(*args[1:]) 44 | 45 | def _CommandifyName(self, name_string): 46 | """Transforms a tool name like copy-info-plist to CopyInfoPlist""" 47 | return name_string.title().replace('-', '') 48 | 49 | def ExecCopyBundleResource(self, source, dest, convert_to_binary): 50 | """Copies a resource file to the bundle/Resources directory, performing any 51 | necessary compilation on each resource.""" 52 | extension = os.path.splitext(source)[1].lower() 53 | if os.path.isdir(source): 54 | # Copy tree. 55 | # TODO(thakis): This copies file attributes like mtime, while the 56 | # single-file branch below doesn't. This should probably be changed to 57 | # be consistent with the single-file branch. 58 | if os.path.exists(dest): 59 | shutil.rmtree(dest) 60 | shutil.copytree(source, dest) 61 | elif extension == '.xib': 62 | return self._CopyXIBFile(source, dest) 63 | elif extension == '.storyboard': 64 | return self._CopyXIBFile(source, dest) 65 | elif extension == '.strings': 66 | self._CopyStringsFile(source, dest, convert_to_binary) 67 | else: 68 | shutil.copy(source, dest) 69 | 70 | def _CopyXIBFile(self, source, dest): 71 | """Compiles a XIB file with ibtool into a binary plist in the bundle.""" 72 | 73 | # ibtool sometimes crashes with relative paths. See crbug.com/314728. 74 | base = os.path.dirname(os.path.realpath(__file__)) 75 | if os.path.relpath(source): 76 | source = os.path.join(base, source) 77 | if os.path.relpath(dest): 78 | dest = os.path.join(base, dest) 79 | 80 | args = ['xcrun', 'ibtool', '--errors', '--warnings', '--notices', 81 | '--output-format', 'human-readable-text', '--compile', dest, source] 82 | ibtool_section_re = re.compile(r'/\*.*\*/') 83 | ibtool_re = re.compile(r'.*note:.*is clipping its content') 84 | ibtoolout = subprocess.Popen(args, stdout=subprocess.PIPE) 85 | current_section_header = None 86 | for line in ibtoolout.stdout: 87 | if ibtool_section_re.match(line): 88 | current_section_header = line 89 | elif not ibtool_re.match(line): 90 | if current_section_header: 91 | sys.stdout.write(current_section_header) 92 | current_section_header = None 93 | sys.stdout.write(line) 94 | return ibtoolout.returncode 95 | 96 | def _ConvertToBinary(self, dest): 97 | subprocess.check_call([ 98 | 'xcrun', 'plutil', '-convert', 'binary1', '-o', dest, dest]) 99 | 100 | def _CopyStringsFile(self, source, dest, convert_to_binary): 101 | """Copies a .strings file using iconv to reconvert the input into UTF-16.""" 102 | input_code = self._DetectInputEncoding(source) or "UTF-8" 103 | 104 | # Xcode's CpyCopyStringsFile / builtin-copyStrings seems to call 105 | # CFPropertyListCreateFromXMLData() behind the scenes; at least it prints 106 | # CFPropertyListCreateFromXMLData(): Old-style plist parser: missing 107 | # semicolon in dictionary. 108 | # on invalid files. Do the same kind of validation. 109 | import CoreFoundation 110 | s = open(source, 'rb').read() 111 | d = CoreFoundation.CFDataCreate(None, s, len(s)) 112 | _, error = CoreFoundation.CFPropertyListCreateFromXMLData(None, d, 0, None) 113 | if error: 114 | return 115 | 116 | fp = open(dest, 'wb') 117 | fp.write(s.decode(input_code).encode('UTF-16')) 118 | fp.close() 119 | 120 | if convert_to_binary == 'True': 121 | self._ConvertToBinary(dest) 122 | 123 | def _DetectInputEncoding(self, file_name): 124 | """Reads the first few bytes from file_name and tries to guess the text 125 | encoding. Returns None as a guess if it can't detect it.""" 126 | fp = open(file_name, 'rb') 127 | try: 128 | header = fp.read(3) 129 | except e: 130 | fp.close() 131 | return None 132 | fp.close() 133 | if header.startswith("\xFE\xFF"): 134 | return "UTF-16" 135 | elif header.startswith("\xFF\xFE"): 136 | return "UTF-16" 137 | elif header.startswith("\xEF\xBB\xBF"): 138 | return "UTF-8" 139 | else: 140 | return None 141 | 142 | def ExecCopyInfoPlist(self, source, dest, convert_to_binary, *keys): 143 | """Copies the |source| Info.plist to the destination directory |dest|.""" 144 | # Read the source Info.plist into memory. 145 | fd = open(source, 'r') 146 | lines = fd.read() 147 | fd.close() 148 | 149 | # Insert synthesized key/value pairs (e.g. BuildMachineOSBuild). 150 | plist = plistlib.readPlistFromString(lines) 151 | if keys: 152 | plist = dict(plist.items() + json.loads(keys[0]).items()) 153 | lines = plistlib.writePlistToString(plist) 154 | 155 | # Go through all the environment variables and replace them as variables in 156 | # the file. 157 | IDENT_RE = re.compile(r'[/\s]') 158 | for key in os.environ: 159 | if key.startswith('_'): 160 | continue 161 | evar = '${%s}' % key 162 | evalue = os.environ[key] 163 | lines = string.replace(lines, evar, evalue) 164 | 165 | # Xcode supports various suffices on environment variables, which are 166 | # all undocumented. :rfc1034identifier is used in the standard project 167 | # template these days, and :identifier was used earlier. They are used to 168 | # convert non-url characters into things that look like valid urls -- 169 | # except that the replacement character for :identifier, '_' isn't valid 170 | # in a URL either -- oops, hence :rfc1034identifier was born. 171 | evar = '${%s:identifier}' % key 172 | evalue = IDENT_RE.sub('_', os.environ[key]) 173 | lines = string.replace(lines, evar, evalue) 174 | 175 | evar = '${%s:rfc1034identifier}' % key 176 | evalue = IDENT_RE.sub('-', os.environ[key]) 177 | lines = string.replace(lines, evar, evalue) 178 | 179 | # Remove any keys with values that haven't been replaced. 180 | lines = lines.split('\n') 181 | for i in range(len(lines)): 182 | if lines[i].strip().startswith("${"): 183 | lines[i] = None 184 | lines[i - 1] = None 185 | lines = '\n'.join(filter(lambda x: x is not None, lines)) 186 | 187 | # Write out the file with variables replaced. 188 | fd = open(dest, 'w') 189 | fd.write(lines) 190 | fd.close() 191 | 192 | # Now write out PkgInfo file now that the Info.plist file has been 193 | # "compiled". 194 | self._WritePkgInfo(dest) 195 | 196 | if convert_to_binary == 'True': 197 | self._ConvertToBinary(dest) 198 | 199 | def _WritePkgInfo(self, info_plist): 200 | """This writes the PkgInfo file from the data stored in Info.plist.""" 201 | plist = plistlib.readPlist(info_plist) 202 | if not plist: 203 | return 204 | 205 | # Only create PkgInfo for executable types. 206 | package_type = plist['CFBundlePackageType'] 207 | if package_type != 'APPL': 208 | return 209 | 210 | # The format of PkgInfo is eight characters, representing the bundle type 211 | # and bundle signature, each four characters. If that is missing, four 212 | # '?' characters are used instead. 213 | signature_code = plist.get('CFBundleSignature', '????') 214 | if len(signature_code) != 4: # Wrong length resets everything, too. 215 | signature_code = '?' * 4 216 | 217 | dest = os.path.join(os.path.dirname(info_plist), 'PkgInfo') 218 | fp = open(dest, 'w') 219 | fp.write('%s%s' % (package_type, signature_code)) 220 | fp.close() 221 | 222 | def ExecFlock(self, lockfile, *cmd_list): 223 | """Emulates the most basic behavior of Linux's flock(1).""" 224 | # Rely on exception handling to report errors. 225 | fd = os.open(lockfile, os.O_RDONLY|os.O_NOCTTY|os.O_CREAT, 0o666) 226 | fcntl.flock(fd, fcntl.LOCK_EX) 227 | return subprocess.call(cmd_list) 228 | 229 | def ExecFilterLibtool(self, *cmd_list): 230 | """Calls libtool and filters out '/path/to/libtool: file: foo.o has no 231 | symbols'.""" 232 | libtool_re = re.compile(r'^.*libtool: file: .* has no symbols$') 233 | libtool_re5 = re.compile( 234 | r'^.*libtool: warning for library: ' + 235 | r'.* the table of contents is empty ' + 236 | r'\(no object file members in the library define global symbols\)$') 237 | env = os.environ.copy() 238 | # Ref: 239 | # http://www.opensource.apple.com/source/cctools/cctools-809/misc/libtool.c 240 | # The problem with this flag is that it resets the file mtime on the file to 241 | # epoch=0, e.g. 1970-1-1 or 1969-12-31 depending on timezone. 242 | env['ZERO_AR_DATE'] = '1' 243 | libtoolout = subprocess.Popen(cmd_list, stderr=subprocess.PIPE, env=env) 244 | _, err = libtoolout.communicate() 245 | for line in err.splitlines(): 246 | if not libtool_re.match(line) and not libtool_re5.match(line): 247 | print >>sys.stderr, line 248 | # Unconditionally touch the output .a file on the command line if present 249 | # and the command succeeded. A bit hacky. 250 | if not libtoolout.returncode: 251 | for i in range(len(cmd_list) - 1): 252 | if cmd_list[i] == "-o" and cmd_list[i+1].endswith('.a'): 253 | os.utime(cmd_list[i+1], None) 254 | break 255 | return libtoolout.returncode 256 | 257 | def ExecPackageFramework(self, framework, version): 258 | """Takes a path to Something.framework and the Current version of that and 259 | sets up all the symlinks.""" 260 | # Find the name of the binary based on the part before the ".framework". 261 | binary = os.path.basename(framework).split('.')[0] 262 | 263 | CURRENT = 'Current' 264 | RESOURCES = 'Resources' 265 | VERSIONS = 'Versions' 266 | 267 | if not os.path.exists(os.path.join(framework, VERSIONS, version, binary)): 268 | # Binary-less frameworks don't seem to contain symlinks (see e.g. 269 | # chromium's out/Debug/org.chromium.Chromium.manifest/ bundle). 270 | return 271 | 272 | # Move into the framework directory to set the symlinks correctly. 273 | pwd = os.getcwd() 274 | os.chdir(framework) 275 | 276 | # Set up the Current version. 277 | self._Relink(version, os.path.join(VERSIONS, CURRENT)) 278 | 279 | # Set up the root symlinks. 280 | self._Relink(os.path.join(VERSIONS, CURRENT, binary), binary) 281 | self._Relink(os.path.join(VERSIONS, CURRENT, RESOURCES), RESOURCES) 282 | 283 | # Back to where we were before! 284 | os.chdir(pwd) 285 | 286 | def _Relink(self, dest, link): 287 | """Creates a symlink to |dest| named |link|. If |link| already exists, 288 | it is overwritten.""" 289 | if os.path.lexists(link): 290 | os.remove(link) 291 | os.symlink(dest, link) 292 | 293 | def ExecCompileXcassets(self, keys, *inputs): 294 | """Compiles multiple .xcassets files into a single .car file. 295 | 296 | This invokes 'actool' to compile all the inputs .xcassets files. The 297 | |keys| arguments is a json-encoded dictionary of extra arguments to 298 | pass to 'actool' when the asset catalogs contains an application icon 299 | or a launch image. 300 | 301 | Note that 'actool' does not create the Assets.car file if the asset 302 | catalogs does not contains imageset. 303 | """ 304 | command_line = [ 305 | 'xcrun', 'actool', '--output-format', 'human-readable-text', 306 | '--compress-pngs', '--notices', '--warnings', '--errors', 307 | ] 308 | is_iphone_target = 'IPHONEOS_DEPLOYMENT_TARGET' in os.environ 309 | if is_iphone_target: 310 | platform = os.environ['CONFIGURATION'].split('-')[-1] 311 | if platform not in ('iphoneos', 'iphonesimulator'): 312 | platform = 'iphonesimulator' 313 | command_line.extend([ 314 | '--platform', platform, '--target-device', 'iphone', 315 | '--target-device', 'ipad', '--minimum-deployment-target', 316 | os.environ['IPHONEOS_DEPLOYMENT_TARGET'], '--compile', 317 | os.path.abspath(os.environ['CONTENTS_FOLDER_PATH']), 318 | ]) 319 | else: 320 | command_line.extend([ 321 | '--platform', 'macosx', '--target-device', 'mac', 322 | '--minimum-deployment-target', os.environ['MACOSX_DEPLOYMENT_TARGET'], 323 | '--compile', 324 | os.path.abspath(os.environ['UNLOCALIZED_RESOURCES_FOLDER_PATH']), 325 | ]) 326 | if keys: 327 | keys = json.loads(keys) 328 | for key, value in keys.iteritems(): 329 | arg_name = '--' + key 330 | if isinstance(value, bool): 331 | if value: 332 | command_line.append(arg_name) 333 | elif isinstance(value, list): 334 | for v in value: 335 | command_line.append(arg_name) 336 | command_line.append(str(v)) 337 | else: 338 | command_line.append(arg_name) 339 | command_line.append(str(value)) 340 | # Note: actool crashes if inputs path are relative, so use os.path.abspath 341 | # to get absolute path name for inputs. 342 | command_line.extend(map(os.path.abspath, inputs)) 343 | subprocess.check_call(command_line) 344 | 345 | def ExecMergeInfoPlist(self, output, *inputs): 346 | """Merge multiple .plist files into a single .plist file.""" 347 | merged_plist = {} 348 | for path in inputs: 349 | plist = self._LoadPlistMaybeBinary(path) 350 | self._MergePlist(merged_plist, plist) 351 | plistlib.writePlist(merged_plist, output) 352 | 353 | def ExecCodeSignBundle(self, key, resource_rules, entitlements, provisioning): 354 | """Code sign a bundle. 355 | 356 | This function tries to code sign an iOS bundle, following the same 357 | algorithm as Xcode: 358 | 1. copy ResourceRules.plist from the user or the SDK into the bundle, 359 | 2. pick the provisioning profile that best match the bundle identifier, 360 | and copy it into the bundle as embedded.mobileprovision, 361 | 3. copy Entitlements.plist from user or SDK next to the bundle, 362 | 4. code sign the bundle. 363 | """ 364 | resource_rules_path = self._InstallResourceRules(resource_rules) 365 | substitutions, overrides = self._InstallProvisioningProfile( 366 | provisioning, self._GetCFBundleIdentifier()) 367 | entitlements_path = self._InstallEntitlements( 368 | entitlements, substitutions, overrides) 369 | subprocess.check_call([ 370 | 'codesign', '--force', '--sign', key, '--resource-rules', 371 | resource_rules_path, '--entitlements', entitlements_path, 372 | os.path.join( 373 | os.environ['TARGET_BUILD_DIR'], 374 | os.environ['FULL_PRODUCT_NAME'])]) 375 | 376 | def _InstallResourceRules(self, resource_rules): 377 | """Installs ResourceRules.plist from user or SDK into the bundle. 378 | 379 | Args: 380 | resource_rules: string, optional, path to the ResourceRules.plist file 381 | to use, default to "${SDKROOT}/ResourceRules.plist" 382 | 383 | Returns: 384 | Path to the copy of ResourceRules.plist into the bundle. 385 | """ 386 | source_path = resource_rules 387 | target_path = os.path.join( 388 | os.environ['BUILT_PRODUCTS_DIR'], 389 | os.environ['CONTENTS_FOLDER_PATH'], 390 | 'ResourceRules.plist') 391 | if not source_path: 392 | source_path = os.path.join( 393 | os.environ['SDKROOT'], 'ResourceRules.plist') 394 | shutil.copy2(source_path, target_path) 395 | return target_path 396 | 397 | def _InstallProvisioningProfile(self, profile, bundle_identifier): 398 | """Installs embedded.mobileprovision into the bundle. 399 | 400 | Args: 401 | profile: string, optional, short name of the .mobileprovision file 402 | to use, if empty or the file is missing, the best file installed 403 | will be used 404 | bundle_identifier: string, value of CFBundleIdentifier from Info.plist 405 | 406 | Returns: 407 | A tuple containing two dictionary: variables substitutions and values 408 | to overrides when generating the entitlements file. 409 | """ 410 | source_path, provisioning_data, team_id = self._FindProvisioningProfile( 411 | profile, bundle_identifier) 412 | target_path = os.path.join( 413 | os.environ['BUILT_PRODUCTS_DIR'], 414 | os.environ['CONTENTS_FOLDER_PATH'], 415 | 'embedded.mobileprovision') 416 | shutil.copy2(source_path, target_path) 417 | substitutions = self._GetSubstitutions(bundle_identifier, team_id + '.') 418 | return substitutions, provisioning_data['Entitlements'] 419 | 420 | def _FindProvisioningProfile(self, profile, bundle_identifier): 421 | """Finds the .mobileprovision file to use for signing the bundle. 422 | 423 | Checks all the installed provisioning profiles (or if the user specified 424 | the PROVISIONING_PROFILE variable, only consult it) and select the most 425 | specific that correspond to the bundle identifier. 426 | 427 | Args: 428 | profile: string, optional, short name of the .mobileprovision file 429 | to use, if empty or the file is missing, the best file installed 430 | will be used 431 | bundle_identifier: string, value of CFBundleIdentifier from Info.plist 432 | 433 | Returns: 434 | A tuple of the path to the selected provisioning profile, the data of 435 | the embedded plist in the provisioning profile and the team identifier 436 | to use for code signing. 437 | 438 | Raises: 439 | SystemExit: if no .mobileprovision can be used to sign the bundle. 440 | """ 441 | profiles_dir = os.path.join( 442 | os.environ['HOME'], 'Library', 'MobileDevice', 'Provisioning Profiles') 443 | if not os.path.isdir(profiles_dir): 444 | print >>sys.stderr, ( 445 | 'cannot find mobile provisioning for %s' % bundle_identifier) 446 | sys.exit(1) 447 | provisioning_profiles = None 448 | if profile: 449 | profile_path = os.path.join(profiles_dir, profile + '.mobileprovision') 450 | if os.path.exists(profile_path): 451 | provisioning_profiles = [profile_path] 452 | if not provisioning_profiles: 453 | provisioning_profiles = glob.glob( 454 | os.path.join(profiles_dir, '*.mobileprovision')) 455 | valid_provisioning_profiles = {} 456 | for profile_path in provisioning_profiles: 457 | profile_data = self._LoadProvisioningProfile(profile_path) 458 | app_id_pattern = profile_data.get( 459 | 'Entitlements', {}).get('application-identifier', '') 460 | for team_identifier in profile_data.get('TeamIdentifier', []): 461 | app_id = '%s.%s' % (team_identifier, bundle_identifier) 462 | if fnmatch.fnmatch(app_id, app_id_pattern): 463 | valid_provisioning_profiles[app_id_pattern] = ( 464 | profile_path, profile_data, team_identifier) 465 | if not valid_provisioning_profiles: 466 | print >>sys.stderr, ( 467 | 'cannot find mobile provisioning for %s' % bundle_identifier) 468 | sys.exit(1) 469 | # If the user has multiple provisioning profiles installed that can be 470 | # used for ${bundle_identifier}, pick the most specific one (ie. the 471 | # provisioning profile whose pattern is the longest). 472 | selected_key = max(valid_provisioning_profiles, key=lambda v: len(v)) 473 | return valid_provisioning_profiles[selected_key] 474 | 475 | def _LoadProvisioningProfile(self, profile_path): 476 | """Extracts the plist embedded in a provisioning profile. 477 | 478 | Args: 479 | profile_path: string, path to the .mobileprovision file 480 | 481 | Returns: 482 | Content of the plist embedded in the provisioning profile as a dictionary. 483 | """ 484 | with tempfile.NamedTemporaryFile() as temp: 485 | subprocess.check_call([ 486 | 'security', 'cms', '-D', '-i', profile_path, '-o', temp.name]) 487 | return self._LoadPlistMaybeBinary(temp.name) 488 | 489 | def _MergePlist(self, merged_plist, plist): 490 | """Merge |plist| into |merged_plist|.""" 491 | for key, value in plist.iteritems(): 492 | if isinstance(value, dict): 493 | merged_value = merged_plist.get(key, {}) 494 | if isinstance(merged_value, dict): 495 | self._MergePlist(merged_value, value) 496 | merged_plist[key] = merged_value 497 | else: 498 | merged_plist[key] = value 499 | else: 500 | merged_plist[key] = value 501 | 502 | def _LoadPlistMaybeBinary(self, plist_path): 503 | """Loads into a memory a plist possibly encoded in binary format. 504 | 505 | This is a wrapper around plistlib.readPlist that tries to convert the 506 | plist to the XML format if it can't be parsed (assuming that it is in 507 | the binary format). 508 | 509 | Args: 510 | plist_path: string, path to a plist file, in XML or binary format 511 | 512 | Returns: 513 | Content of the plist as a dictionary. 514 | """ 515 | try: 516 | # First, try to read the file using plistlib that only supports XML, 517 | # and if an exception is raised, convert a temporary copy to XML and 518 | # load that copy. 519 | return plistlib.readPlist(plist_path) 520 | except: 521 | pass 522 | with tempfile.NamedTemporaryFile() as temp: 523 | shutil.copy2(plist_path, temp.name) 524 | subprocess.check_call(['plutil', '-convert', 'xml1', temp.name]) 525 | return plistlib.readPlist(temp.name) 526 | 527 | def _GetSubstitutions(self, bundle_identifier, app_identifier_prefix): 528 | """Constructs a dictionary of variable substitutions for Entitlements.plist. 529 | 530 | Args: 531 | bundle_identifier: string, value of CFBundleIdentifier from Info.plist 532 | app_identifier_prefix: string, value for AppIdentifierPrefix 533 | 534 | Returns: 535 | Dictionary of substitutions to apply when generating Entitlements.plist. 536 | """ 537 | return { 538 | 'CFBundleIdentifier': bundle_identifier, 539 | 'AppIdentifierPrefix': app_identifier_prefix, 540 | } 541 | 542 | def _GetCFBundleIdentifier(self): 543 | """Extracts CFBundleIdentifier value from Info.plist in the bundle. 544 | 545 | Returns: 546 | Value of CFBundleIdentifier in the Info.plist located in the bundle. 547 | """ 548 | info_plist_path = os.path.join( 549 | os.environ['TARGET_BUILD_DIR'], 550 | os.environ['INFOPLIST_PATH']) 551 | info_plist_data = self._LoadPlistMaybeBinary(info_plist_path) 552 | return info_plist_data['CFBundleIdentifier'] 553 | 554 | def _InstallEntitlements(self, entitlements, substitutions, overrides): 555 | """Generates and install the ${BundleName}.xcent entitlements file. 556 | 557 | Expands variables "$(variable)" pattern in the source entitlements file, 558 | add extra entitlements defined in the .mobileprovision file and the copy 559 | the generated plist to "${BundlePath}.xcent". 560 | 561 | Args: 562 | entitlements: string, optional, path to the Entitlements.plist template 563 | to use, defaults to "${SDKROOT}/Entitlements.plist" 564 | substitutions: dictionary, variable substitutions 565 | overrides: dictionary, values to add to the entitlements 566 | 567 | Returns: 568 | Path to the generated entitlements file. 569 | """ 570 | source_path = entitlements 571 | target_path = os.path.join( 572 | os.environ['BUILT_PRODUCTS_DIR'], 573 | os.environ['PRODUCT_NAME'] + '.xcent') 574 | if not source_path: 575 | source_path = os.path.join( 576 | os.environ['SDKROOT'], 577 | 'Entitlements.plist') 578 | shutil.copy2(source_path, target_path) 579 | data = self._LoadPlistMaybeBinary(target_path) 580 | data = self._ExpandVariables(data, substitutions) 581 | if overrides: 582 | for key in overrides: 583 | if key not in data: 584 | data[key] = overrides[key] 585 | plistlib.writePlist(data, target_path) 586 | return target_path 587 | 588 | def _ExpandVariables(self, data, substitutions): 589 | """Expands variables "$(variable)" in data. 590 | 591 | Args: 592 | data: object, can be either string, list or dictionary 593 | substitutions: dictionary, variable substitutions to perform 594 | 595 | Returns: 596 | Copy of data where each references to "$(variable)" has been replaced 597 | by the corresponding value found in substitutions, or left intact if 598 | the key was not found. 599 | """ 600 | if isinstance(data, str): 601 | for key, value in substitutions.iteritems(): 602 | data = data.replace('$(%s)' % key, value) 603 | return data 604 | if isinstance(data, list): 605 | return [self._ExpandVariables(v, substitutions) for v in data] 606 | if isinstance(data, dict): 607 | return {k: self._ExpandVariables(data[k], substitutions) for k in data} 608 | return data 609 | 610 | if __name__ == '__main__': 611 | sys.exit(main(sys.argv[1:])) 612 | -------------------------------------------------------------------------------- /downloadFromBing/lib/jquery-2.1.4.min.js: -------------------------------------------------------------------------------- 1 | /*! jQuery v2.1.4 | (c) 2005, 2015 jQuery Foundation, Inc. | jquery.org/license */ 2 | !function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.4",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b,c,b)}))},slice:function(){return this.pushStack(d.apply(this,arguments))},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},eq:function(a){var b=this.length,c=+a+(0>a?b:0);return this.pushStack(c>=0&&b>c?[this[c]]:[])},end:function(){return this.prevObject||this.constructor(null)},push:f,sort:c.sort,splice:c.splice},n.extend=n.fn.extend=function(){var a,b,c,d,e,f,g=arguments[0]||{},h=1,i=arguments.length,j=!1;for("boolean"==typeof g&&(j=g,g=arguments[h]||{},h++),"object"==typeof g||n.isFunction(g)||(g={}),h===i&&(g=this,h--);i>h;h++)if(null!=(a=arguments[h]))for(b in a)c=g[b],d=a[b],g!==d&&(j&&d&&(n.isPlainObject(d)||(e=n.isArray(d)))?(e?(e=!1,f=c&&n.isArray(c)?c:[]):f=c&&n.isPlainObject(c)?c:{},g[b]=n.extend(j,f,d)):void 0!==d&&(g[b]=d));return g},n.extend({expando:"jQuery"+(m+Math.random()).replace(/\D/g,""),isReady:!0,error:function(a){throw new Error(a)},noop:function(){},isFunction:function(a){return"function"===n.type(a)},isArray:Array.isArray,isWindow:function(a){return null!=a&&a===a.window},isNumeric:function(a){return!n.isArray(a)&&a-parseFloat(a)+1>=0},isPlainObject:function(a){return"object"!==n.type(a)||a.nodeType||n.isWindow(a)?!1:a.constructor&&!j.call(a.constructor.prototype,"isPrototypeOf")?!1:!0},isEmptyObject:function(a){var b;for(b in a)return!1;return!0},type:function(a){return null==a?a+"":"object"==typeof a||"function"==typeof a?h[i.call(a)]||"object":typeof a},globalEval:function(a){var b,c=eval;a=n.trim(a),a&&(1===a.indexOf("use strict")?(b=l.createElement("script"),b.text=a,l.head.appendChild(b).parentNode.removeChild(b)):c(a))},camelCase:function(a){return a.replace(p,"ms-").replace(q,r)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toLowerCase()===b.toLowerCase()},each:function(a,b,c){var d,e=0,f=a.length,g=s(a);if(c){if(g){for(;f>e;e++)if(d=b.apply(a[e],c),d===!1)break}else for(e in a)if(d=b.apply(a[e],c),d===!1)break}else if(g){for(;f>e;e++)if(d=b.call(a[e],e,a[e]),d===!1)break}else for(e in a)if(d=b.call(a[e],e,a[e]),d===!1)break;return a},trim:function(a){return null==a?"":(a+"").replace(o,"")},makeArray:function(a,b){var c=b||[];return null!=a&&(s(Object(a))?n.merge(c,"string"==typeof a?[a]:a):f.call(c,a)),c},inArray:function(a,b,c){return null==b?-1:g.call(b,a,c)},merge:function(a,b){for(var c=+b.length,d=0,e=a.length;c>d;d++)a[e++]=b[d];return a.length=e,a},grep:function(a,b,c){for(var d,e=[],f=0,g=a.length,h=!c;g>f;f++)d=!b(a[f],f),d!==h&&e.push(a[f]);return e},map:function(a,b,c){var d,f=0,g=a.length,h=s(a),i=[];if(h)for(;g>f;f++)d=b(a[f],f,c),null!=d&&i.push(d);else for(f in a)d=b(a[f],f,c),null!=d&&i.push(d);return e.apply([],i)},guid:1,proxy:function(a,b){var c,e,f;return"string"==typeof b&&(c=a[b],b=a,a=c),n.isFunction(a)?(e=d.call(arguments,2),f=function(){return a.apply(b||this,e.concat(d.call(arguments)))},f.guid=a.guid=a.guid||n.guid++,f):void 0},now:Date.now,support:k}),n.each("Boolean Number String Function Array Date RegExp Object Error".split(" "),function(a,b){h["[object "+b+"]"]=b.toLowerCase()});function s(a){var b="length"in a&&a.length,c=n.type(a);return"function"===c||n.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||0===b||"number"==typeof b&&b>0&&b-1 in a}var t=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u="sizzle"+1*new Date,v=a.document,w=0,x=0,y=ha(),z=ha(),A=ha(),B=function(a,b){return a===b&&(l=!0),0},C=1<<31,D={}.hasOwnProperty,E=[],F=E.pop,G=E.push,H=E.push,I=E.slice,J=function(a,b){for(var c=0,d=a.length;d>c;c++)if(a[c]===b)return c;return-1},K="checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",L="[\\x20\\t\\r\\n\\f]",M="(?:\\\\.|[\\w-]|[^\\x00-\\xa0])+",N=M.replace("w","w#"),O="\\["+L+"*("+M+")(?:"+L+"*([*^$|!~]?=)"+L+"*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|("+N+"))|)"+L+"*\\]",P=":("+M+")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|"+O+")*)|.*)\\)|)",Q=new RegExp(L+"+","g"),R=new RegExp("^"+L+"+|((?:^|[^\\\\])(?:\\\\.)*)"+L+"+$","g"),S=new RegExp("^"+L+"*,"+L+"*"),T=new RegExp("^"+L+"*([>+~]|"+L+")"+L+"*"),U=new RegExp("="+L+"*([^\\]'\"]*?)"+L+"*\\]","g"),V=new RegExp(P),W=new RegExp("^"+N+"$"),X={ID:new RegExp("^#("+M+")"),CLASS:new RegExp("^\\.("+M+")"),TAG:new RegExp("^("+M.replace("w","w*")+")"),ATTR:new RegExp("^"+O),PSEUDO:new RegExp("^"+P),CHILD:new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\("+L+"*(even|odd|(([+-]|)(\\d*)n|)"+L+"*(?:([+-]|)"+L+"*(\\d+)|))"+L+"*\\)|)","i"),bool:new RegExp("^(?:"+K+")$","i"),needsContext:new RegExp("^"+L+"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\("+L+"*((?:-\\d)?\\d*)"+L+"*\\)|)(?=[^-]|$)","i")},Y=/^(?:input|select|textarea|button)$/i,Z=/^h\d$/i,$=/^[^{]+\{\s*\[native \w/,_=/^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,aa=/[+~]/,ba=/'|\\/g,ca=new RegExp("\\\\([\\da-f]{1,6}"+L+"?|("+L+")|.)","ig"),da=function(a,b,c){var d="0x"+b-65536;return d!==d||c?b:0>d?String.fromCharCode(d+65536):String.fromCharCode(d>>10|55296,1023&d|56320)},ea=function(){m()};try{H.apply(E=I.call(v.childNodes),v.childNodes),E[v.childNodes.length].nodeType}catch(fa){H={apply:E.length?function(a,b){G.apply(a,I.call(b))}:function(a,b){var c=a.length,d=0;while(a[c++]=b[d++]);a.length=c-1}}}function ga(a,b,d,e){var f,h,j,k,l,o,r,s,w,x;if((b?b.ownerDocument||b:v)!==n&&m(b),b=b||n,d=d||[],k=b.nodeType,"string"!=typeof a||!a||1!==k&&9!==k&&11!==k)return d;if(!e&&p){if(11!==k&&(f=_.exec(a)))if(j=f[1]){if(9===k){if(h=b.getElementById(j),!h||!h.parentNode)return d;if(h.id===j)return d.push(h),d}else if(b.ownerDocument&&(h=b.ownerDocument.getElementById(j))&&t(b,h)&&h.id===j)return d.push(h),d}else{if(f[2])return H.apply(d,b.getElementsByTagName(a)),d;if((j=f[3])&&c.getElementsByClassName)return H.apply(d,b.getElementsByClassName(j)),d}if(c.qsa&&(!q||!q.test(a))){if(s=r=u,w=b,x=1!==k&&a,1===k&&"object"!==b.nodeName.toLowerCase()){o=g(a),(r=b.getAttribute("id"))?s=r.replace(ba,"\\$&"):b.setAttribute("id",s),s="[id='"+s+"'] ",l=o.length;while(l--)o[l]=s+ra(o[l]);w=aa.test(a)&&pa(b.parentNode)||b,x=o.join(",")}if(x)try{return H.apply(d,w.querySelectorAll(x)),d}catch(y){}finally{r||b.removeAttribute("id")}}}return i(a.replace(R,"$1"),b,d,e)}function ha(){var a=[];function b(c,e){return a.push(c+" ")>d.cacheLength&&delete b[a.shift()],b[c+" "]=e}return b}function ia(a){return a[u]=!0,a}function ja(a){var b=n.createElement("div");try{return!!a(b)}catch(c){return!1}finally{b.parentNode&&b.parentNode.removeChild(b),b=null}}function ka(a,b){var c=a.split("|"),e=a.length;while(e--)d.attrHandle[c[e]]=b}function la(a,b){var c=b&&a,d=c&&1===a.nodeType&&1===b.nodeType&&(~b.sourceIndex||C)-(~a.sourceIndex||C);if(d)return d;if(c)while(c=c.nextSibling)if(c===b)return-1;return a?1:-1}function ma(a){return function(b){var c=b.nodeName.toLowerCase();return"input"===c&&b.type===a}}function na(a){return function(b){var c=b.nodeName.toLowerCase();return("input"===c||"button"===c)&&b.type===a}}function oa(a){return ia(function(b){return b=+b,ia(function(c,d){var e,f=a([],c.length,b),g=f.length;while(g--)c[e=f[g]]&&(c[e]=!(d[e]=c[e]))})})}function pa(a){return a&&"undefined"!=typeof a.getElementsByTagName&&a}c=ga.support={},f=ga.isXML=function(a){var b=a&&(a.ownerDocument||a).documentElement;return b?"HTML"!==b.nodeName:!1},m=ga.setDocument=function(a){var b,e,g=a?a.ownerDocument||a:v;return g!==n&&9===g.nodeType&&g.documentElement?(n=g,o=g.documentElement,e=g.defaultView,e&&e!==e.top&&(e.addEventListener?e.addEventListener("unload",ea,!1):e.attachEvent&&e.attachEvent("onunload",ea)),p=!f(g),c.attributes=ja(function(a){return a.className="i",!a.getAttribute("className")}),c.getElementsByTagName=ja(function(a){return a.appendChild(g.createComment("")),!a.getElementsByTagName("*").length}),c.getElementsByClassName=$.test(g.getElementsByClassName),c.getById=ja(function(a){return o.appendChild(a).id=u,!g.getElementsByName||!g.getElementsByName(u).length}),c.getById?(d.find.ID=function(a,b){if("undefined"!=typeof b.getElementById&&p){var c=b.getElementById(a);return c&&c.parentNode?[c]:[]}},d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){return a.getAttribute("id")===b}}):(delete d.find.ID,d.filter.ID=function(a){var b=a.replace(ca,da);return function(a){var c="undefined"!=typeof a.getAttributeNode&&a.getAttributeNode("id");return c&&c.value===b}}),d.find.TAG=c.getElementsByTagName?function(a,b){return"undefined"!=typeof b.getElementsByTagName?b.getElementsByTagName(a):c.qsa?b.querySelectorAll(a):void 0}:function(a,b){var c,d=[],e=0,f=b.getElementsByTagName(a);if("*"===a){while(c=f[e++])1===c.nodeType&&d.push(c);return d}return f},d.find.CLASS=c.getElementsByClassName&&function(a,b){return p?b.getElementsByClassName(a):void 0},r=[],q=[],(c.qsa=$.test(g.querySelectorAll))&&(ja(function(a){o.appendChild(a).innerHTML="",a.querySelectorAll("[msallowcapture^='']").length&&q.push("[*^$]="+L+"*(?:''|\"\")"),a.querySelectorAll("[selected]").length||q.push("\\["+L+"*(?:value|"+K+")"),a.querySelectorAll("[id~="+u+"-]").length||q.push("~="),a.querySelectorAll(":checked").length||q.push(":checked"),a.querySelectorAll("a#"+u+"+*").length||q.push(".#.+[+~]")}),ja(function(a){var b=g.createElement("input");b.setAttribute("type","hidden"),a.appendChild(b).setAttribute("name","D"),a.querySelectorAll("[name=d]").length&&q.push("name"+L+"*[*^$|!~]?="),a.querySelectorAll(":enabled").length||q.push(":enabled",":disabled"),a.querySelectorAll("*,:x"),q.push(",.*:")})),(c.matchesSelector=$.test(s=o.matches||o.webkitMatchesSelector||o.mozMatchesSelector||o.oMatchesSelector||o.msMatchesSelector))&&ja(function(a){c.disconnectedMatch=s.call(a,"div"),s.call(a,"[s!='']:x"),r.push("!=",P)}),q=q.length&&new RegExp(q.join("|")),r=r.length&&new RegExp(r.join("|")),b=$.test(o.compareDocumentPosition),t=b||$.test(o.contains)?function(a,b){var c=9===a.nodeType?a.documentElement:a,d=b&&b.parentNode;return a===d||!(!d||1!==d.nodeType||!(c.contains?c.contains(d):a.compareDocumentPosition&&16&a.compareDocumentPosition(d)))}:function(a,b){if(b)while(b=b.parentNode)if(b===a)return!0;return!1},B=b?function(a,b){if(a===b)return l=!0,0;var d=!a.compareDocumentPosition-!b.compareDocumentPosition;return d?d:(d=(a.ownerDocument||a)===(b.ownerDocument||b)?a.compareDocumentPosition(b):1,1&d||!c.sortDetached&&b.compareDocumentPosition(a)===d?a===g||a.ownerDocument===v&&t(v,a)?-1:b===g||b.ownerDocument===v&&t(v,b)?1:k?J(k,a)-J(k,b):0:4&d?-1:1)}:function(a,b){if(a===b)return l=!0,0;var c,d=0,e=a.parentNode,f=b.parentNode,h=[a],i=[b];if(!e||!f)return a===g?-1:b===g?1:e?-1:f?1:k?J(k,a)-J(k,b):0;if(e===f)return la(a,b);c=a;while(c=c.parentNode)h.unshift(c);c=b;while(c=c.parentNode)i.unshift(c);while(h[d]===i[d])d++;return d?la(h[d],i[d]):h[d]===v?-1:i[d]===v?1:0},g):n},ga.matches=function(a,b){return ga(a,null,null,b)},ga.matchesSelector=function(a,b){if((a.ownerDocument||a)!==n&&m(a),b=b.replace(U,"='$1']"),!(!c.matchesSelector||!p||r&&r.test(b)||q&&q.test(b)))try{var d=s.call(a,b);if(d||c.disconnectedMatch||a.document&&11!==a.document.nodeType)return d}catch(e){}return ga(b,n,null,[a]).length>0},ga.contains=function(a,b){return(a.ownerDocument||a)!==n&&m(a),t(a,b)},ga.attr=function(a,b){(a.ownerDocument||a)!==n&&m(a);var e=d.attrHandle[b.toLowerCase()],f=e&&D.call(d.attrHandle,b.toLowerCase())?e(a,b,!p):void 0;return void 0!==f?f:c.attributes||!p?a.getAttribute(b):(f=a.getAttributeNode(b))&&f.specified?f.value:null},ga.error=function(a){throw new Error("Syntax error, unrecognized expression: "+a)},ga.uniqueSort=function(a){var b,d=[],e=0,f=0;if(l=!c.detectDuplicates,k=!c.sortStable&&a.slice(0),a.sort(B),l){while(b=a[f++])b===a[f]&&(e=d.push(f));while(e--)a.splice(d[e],1)}return k=null,a},e=ga.getText=function(a){var b,c="",d=0,f=a.nodeType;if(f){if(1===f||9===f||11===f){if("string"==typeof a.textContent)return a.textContent;for(a=a.firstChild;a;a=a.nextSibling)c+=e(a)}else if(3===f||4===f)return a.nodeValue}else while(b=a[d++])c+=e(b);return c},d=ga.selectors={cacheLength:50,createPseudo:ia,match:X,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function(a){return a[1]=a[1].replace(ca,da),a[3]=(a[3]||a[4]||a[5]||"").replace(ca,da),"~="===a[2]&&(a[3]=" "+a[3]+" "),a.slice(0,4)},CHILD:function(a){return a[1]=a[1].toLowerCase(),"nth"===a[1].slice(0,3)?(a[3]||ga.error(a[0]),a[4]=+(a[4]?a[5]+(a[6]||1):2*("even"===a[3]||"odd"===a[3])),a[5]=+(a[7]+a[8]||"odd"===a[3])):a[3]&&ga.error(a[0]),a},PSEUDO:function(a){var b,c=!a[6]&&a[2];return X.CHILD.test(a[0])?null:(a[3]?a[2]=a[4]||a[5]||"":c&&V.test(c)&&(b=g(c,!0))&&(b=c.indexOf(")",c.length-b)-c.length)&&(a[0]=a[0].slice(0,b),a[2]=c.slice(0,b)),a.slice(0,3))}},filter:{TAG:function(a){var b=a.replace(ca,da).toLowerCase();return"*"===a?function(){return!0}:function(a){return a.nodeName&&a.nodeName.toLowerCase()===b}},CLASS:function(a){var b=y[a+" "];return b||(b=new RegExp("(^|"+L+")"+a+"("+L+"|$)"))&&y(a,function(a){return b.test("string"==typeof a.className&&a.className||"undefined"!=typeof a.getAttribute&&a.getAttribute("class")||"")})},ATTR:function(a,b,c){return function(d){var e=ga.attr(d,a);return null==e?"!="===b:b?(e+="","="===b?e===c:"!="===b?e!==c:"^="===b?c&&0===e.indexOf(c):"*="===b?c&&e.indexOf(c)>-1:"$="===b?c&&e.slice(-c.length)===c:"~="===b?(" "+e.replace(Q," ")+" ").indexOf(c)>-1:"|="===b?e===c||e.slice(0,c.length+1)===c+"-":!1):!0}},CHILD:function(a,b,c,d,e){var f="nth"!==a.slice(0,3),g="last"!==a.slice(-4),h="of-type"===b;return 1===d&&0===e?function(a){return!!a.parentNode}:function(b,c,i){var j,k,l,m,n,o,p=f!==g?"nextSibling":"previousSibling",q=b.parentNode,r=h&&b.nodeName.toLowerCase(),s=!i&&!h;if(q){if(f){while(p){l=b;while(l=l[p])if(h?l.nodeName.toLowerCase()===r:1===l.nodeType)return!1;o=p="only"===a&&!o&&"nextSibling"}return!0}if(o=[g?q.firstChild:q.lastChild],g&&s){k=q[u]||(q[u]={}),j=k[a]||[],n=j[0]===w&&j[1],m=j[0]===w&&j[2],l=n&&q.childNodes[n];while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if(1===l.nodeType&&++m&&l===b){k[a]=[w,n,m];break}}else if(s&&(j=(b[u]||(b[u]={}))[a])&&j[0]===w)m=j[1];else while(l=++n&&l&&l[p]||(m=n=0)||o.pop())if((h?l.nodeName.toLowerCase()===r:1===l.nodeType)&&++m&&(s&&((l[u]||(l[u]={}))[a]=[w,m]),l===b))break;return m-=e,m===d||m%d===0&&m/d>=0}}},PSEUDO:function(a,b){var c,e=d.pseudos[a]||d.setFilters[a.toLowerCase()]||ga.error("unsupported pseudo: "+a);return e[u]?e(b):e.length>1?(c=[a,a,"",b],d.setFilters.hasOwnProperty(a.toLowerCase())?ia(function(a,c){var d,f=e(a,b),g=f.length;while(g--)d=J(a,f[g]),a[d]=!(c[d]=f[g])}):function(a){return e(a,0,c)}):e}},pseudos:{not:ia(function(a){var b=[],c=[],d=h(a.replace(R,"$1"));return d[u]?ia(function(a,b,c,e){var f,g=d(a,null,e,[]),h=a.length;while(h--)(f=g[h])&&(a[h]=!(b[h]=f))}):function(a,e,f){return b[0]=a,d(b,null,f,c),b[0]=null,!c.pop()}}),has:ia(function(a){return function(b){return ga(a,b).length>0}}),contains:ia(function(a){return a=a.replace(ca,da),function(b){return(b.textContent||b.innerText||e(b)).indexOf(a)>-1}}),lang:ia(function(a){return W.test(a||"")||ga.error("unsupported lang: "+a),a=a.replace(ca,da).toLowerCase(),function(b){var c;do if(c=p?b.lang:b.getAttribute("xml:lang")||b.getAttribute("lang"))return c=c.toLowerCase(),c===a||0===c.indexOf(a+"-");while((b=b.parentNode)&&1===b.nodeType);return!1}}),target:function(b){var c=a.location&&a.location.hash;return c&&c.slice(1)===b.id},root:function(a){return a===o},focus:function(a){return a===n.activeElement&&(!n.hasFocus||n.hasFocus())&&!!(a.type||a.href||~a.tabIndex)},enabled:function(a){return a.disabled===!1},disabled:function(a){return a.disabled===!0},checked:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&!!a.checked||"option"===b&&!!a.selected},selected:function(a){return a.parentNode&&a.parentNode.selectedIndex,a.selected===!0},empty:function(a){for(a=a.firstChild;a;a=a.nextSibling)if(a.nodeType<6)return!1;return!0},parent:function(a){return!d.pseudos.empty(a)},header:function(a){return Z.test(a.nodeName)},input:function(a){return Y.test(a.nodeName)},button:function(a){var b=a.nodeName.toLowerCase();return"input"===b&&"button"===a.type||"button"===b},text:function(a){var b;return"input"===a.nodeName.toLowerCase()&&"text"===a.type&&(null==(b=a.getAttribute("type"))||"text"===b.toLowerCase())},first:oa(function(){return[0]}),last:oa(function(a,b){return[b-1]}),eq:oa(function(a,b,c){return[0>c?c+b:c]}),even:oa(function(a,b){for(var c=0;b>c;c+=2)a.push(c);return a}),odd:oa(function(a,b){for(var c=1;b>c;c+=2)a.push(c);return a}),lt:oa(function(a,b,c){for(var d=0>c?c+b:c;--d>=0;)a.push(d);return a}),gt:oa(function(a,b,c){for(var d=0>c?c+b:c;++db;b++)d+=a[b].value;return d}function sa(a,b,c){var d=b.dir,e=c&&"parentNode"===d,f=x++;return b.first?function(b,c,f){while(b=b[d])if(1===b.nodeType||e)return a(b,c,f)}:function(b,c,g){var h,i,j=[w,f];if(g){while(b=b[d])if((1===b.nodeType||e)&&a(b,c,g))return!0}else while(b=b[d])if(1===b.nodeType||e){if(i=b[u]||(b[u]={}),(h=i[d])&&h[0]===w&&h[1]===f)return j[2]=h[2];if(i[d]=j,j[2]=a(b,c,g))return!0}}}function ta(a){return a.length>1?function(b,c,d){var e=a.length;while(e--)if(!a[e](b,c,d))return!1;return!0}:a[0]}function ua(a,b,c){for(var d=0,e=b.length;e>d;d++)ga(a,b[d],c);return c}function va(a,b,c,d,e){for(var f,g=[],h=0,i=a.length,j=null!=b;i>h;h++)(f=a[h])&&(!c||c(f,d,e))&&(g.push(f),j&&b.push(h));return g}function wa(a,b,c,d,e,f){return d&&!d[u]&&(d=wa(d)),e&&!e[u]&&(e=wa(e,f)),ia(function(f,g,h,i){var j,k,l,m=[],n=[],o=g.length,p=f||ua(b||"*",h.nodeType?[h]:h,[]),q=!a||!f&&b?p:va(p,m,a,h,i),r=c?e||(f?a:o||d)?[]:g:q;if(c&&c(q,r,h,i),d){j=va(r,n),d(j,[],h,i),k=j.length;while(k--)(l=j[k])&&(r[n[k]]=!(q[n[k]]=l))}if(f){if(e||a){if(e){j=[],k=r.length;while(k--)(l=r[k])&&j.push(q[k]=l);e(null,r=[],j,i)}k=r.length;while(k--)(l=r[k])&&(j=e?J(f,l):m[k])>-1&&(f[j]=!(g[j]=l))}}else r=va(r===g?r.splice(o,r.length):r),e?e(null,g,r,i):H.apply(g,r)})}function xa(a){for(var b,c,e,f=a.length,g=d.relative[a[0].type],h=g||d.relative[" "],i=g?1:0,k=sa(function(a){return a===b},h,!0),l=sa(function(a){return J(b,a)>-1},h,!0),m=[function(a,c,d){var e=!g&&(d||c!==j)||((b=c).nodeType?k(a,c,d):l(a,c,d));return b=null,e}];f>i;i++)if(c=d.relative[a[i].type])m=[sa(ta(m),c)];else{if(c=d.filter[a[i].type].apply(null,a[i].matches),c[u]){for(e=++i;f>e;e++)if(d.relative[a[e].type])break;return wa(i>1&&ta(m),i>1&&ra(a.slice(0,i-1).concat({value:" "===a[i-2].type?"*":""})).replace(R,"$1"),c,e>i&&xa(a.slice(i,e)),f>e&&xa(a=a.slice(e)),f>e&&ra(a))}m.push(c)}return ta(m)}function ya(a,b){var c=b.length>0,e=a.length>0,f=function(f,g,h,i,k){var l,m,o,p=0,q="0",r=f&&[],s=[],t=j,u=f||e&&d.find.TAG("*",k),v=w+=null==t?1:Math.random()||.1,x=u.length;for(k&&(j=g!==n&&g);q!==x&&null!=(l=u[q]);q++){if(e&&l){m=0;while(o=a[m++])if(o(l,g,h)){i.push(l);break}k&&(w=v)}c&&((l=!o&&l)&&p--,f&&r.push(l))}if(p+=q,c&&q!==p){m=0;while(o=b[m++])o(r,s,g,h);if(f){if(p>0)while(q--)r[q]||s[q]||(s[q]=F.call(i));s=va(s)}H.apply(i,s),k&&!f&&s.length>0&&p+b.length>1&&ga.uniqueSort(i)}return k&&(w=v,j=t),r};return c?ia(f):f}return h=ga.compile=function(a,b){var c,d=[],e=[],f=A[a+" "];if(!f){b||(b=g(a)),c=b.length;while(c--)f=xa(b[c]),f[u]?d.push(f):e.push(f);f=A(a,ya(e,d)),f.selector=a}return f},i=ga.select=function(a,b,e,f){var i,j,k,l,m,n="function"==typeof a&&a,o=!f&&g(a=n.selector||a);if(e=e||[],1===o.length){if(j=o[0]=o[0].slice(0),j.length>2&&"ID"===(k=j[0]).type&&c.getById&&9===b.nodeType&&p&&d.relative[j[1].type]){if(b=(d.find.ID(k.matches[0].replace(ca,da),b)||[])[0],!b)return e;n&&(b=b.parentNode),a=a.slice(j.shift().value.length)}i=X.needsContext.test(a)?0:j.length;while(i--){if(k=j[i],d.relative[l=k.type])break;if((m=d.find[l])&&(f=m(k.matches[0].replace(ca,da),aa.test(j[0].type)&&pa(b.parentNode)||b))){if(j.splice(i,1),a=f.length&&ra(j),!a)return H.apply(e,f),e;break}}}return(n||h(a,o))(f,b,!p,e,aa.test(a)&&pa(b.parentNode)||b),e},c.sortStable=u.split("").sort(B).join("")===u,c.detectDuplicates=!!l,m(),c.sortDetached=ja(function(a){return 1&a.compareDocumentPosition(n.createElement("div"))}),ja(function(a){return a.innerHTML="","#"===a.firstChild.getAttribute("href")})||ka("type|href|height|width",function(a,b,c){return c?void 0:a.getAttribute(b,"type"===b.toLowerCase()?1:2)}),c.attributes&&ja(function(a){return a.innerHTML="",a.firstChild.setAttribute("value",""),""===a.firstChild.getAttribute("value")})||ka("value",function(a,b,c){return c||"input"!==a.nodeName.toLowerCase()?void 0:a.defaultValue}),ja(function(a){return null==a.getAttribute("disabled")})||ka(K,function(a,b,c){var d;return c?void 0:a[b]===!0?b.toLowerCase():(d=a.getAttributeNode(b))&&d.specified?d.value:null}),ga}(a);n.find=t,n.expr=t.selectors,n.expr[":"]=n.expr.pseudos,n.unique=t.uniqueSort,n.text=t.getText,n.isXMLDoc=t.isXML,n.contains=t.contains;var u=n.expr.match.needsContext,v=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,w=/^.[^:#\[\.,]*$/;function x(a,b,c){if(n.isFunction(b))return n.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return n.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(w.test(b))return n.filter(b,a,c);b=n.filter(b,a)}return n.grep(a,function(a){return g.call(b,a)>=0!==c})}n.filter=function(a,b,c){var d=b[0];return c&&(a=":not("+a+")"),1===b.length&&1===d.nodeType?n.find.matchesSelector(d,a)?[d]:[]:n.find.matches(a,n.grep(b,function(a){return 1===a.nodeType}))},n.fn.extend({find:function(a){var b,c=this.length,d=[],e=this;if("string"!=typeof a)return this.pushStack(n(a).filter(function(){for(b=0;c>b;b++)if(n.contains(e[b],this))return!0}));for(b=0;c>b;b++)n.find(a,e[b],d);return d=this.pushStack(c>1?n.unique(d):d),d.selector=this.selector?this.selector+" "+a:a,d},filter:function(a){return this.pushStack(x(this,a||[],!1))},not:function(a){return this.pushStack(x(this,a||[],!0))},is:function(a){return!!x(this,"string"==typeof a&&u.test(a)?n(a):a||[],!1).length}});var y,z=/^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/,A=n.fn.init=function(a,b){var c,d;if(!a)return this;if("string"==typeof a){if(c="<"===a[0]&&">"===a[a.length-1]&&a.length>=3?[null,a,null]:z.exec(a),!c||!c[1]&&b)return!b||b.jquery?(b||y).find(a):this.constructor(b).find(a);if(c[1]){if(b=b instanceof n?b[0]:b,n.merge(this,n.parseHTML(c[1],b&&b.nodeType?b.ownerDocument||b:l,!0)),v.test(c[1])&&n.isPlainObject(b))for(c in b)n.isFunction(this[c])?this[c](b[c]):this.attr(c,b[c]);return this}return d=l.getElementById(c[2]),d&&d.parentNode&&(this.length=1,this[0]=d),this.context=l,this.selector=a,this}return a.nodeType?(this.context=this[0]=a,this.length=1,this):n.isFunction(a)?"undefined"!=typeof y.ready?y.ready(a):a(n):(void 0!==a.selector&&(this.selector=a.selector,this.context=a.context),n.makeArray(a,this))};A.prototype=n.fn,y=n(l);var B=/^(?:parents|prev(?:Until|All))/,C={children:!0,contents:!0,next:!0,prev:!0};n.extend({dir:function(a,b,c){var d=[],e=void 0!==c;while((a=a[b])&&9!==a.nodeType)if(1===a.nodeType){if(e&&n(a).is(c))break;d.push(a)}return d},sibling:function(a,b){for(var c=[];a;a=a.nextSibling)1===a.nodeType&&a!==b&&c.push(a);return c}}),n.fn.extend({has:function(a){var b=n(a,this),c=b.length;return this.filter(function(){for(var a=0;c>a;a++)if(n.contains(this,b[a]))return!0})},closest:function(a,b){for(var c,d=0,e=this.length,f=[],g=u.test(a)||"string"!=typeof a?n(a,b||this.context):0;e>d;d++)for(c=this[d];c&&c!==b;c=c.parentNode)if(c.nodeType<11&&(g?g.index(c)>-1:1===c.nodeType&&n.find.matchesSelector(c,a))){f.push(c);break}return this.pushStack(f.length>1?n.unique(f):f)},index:function(a){return a?"string"==typeof a?g.call(n(a),this[0]):g.call(this,a.jquery?a[0]:a):this[0]&&this[0].parentNode?this.first().prevAll().length:-1},add:function(a,b){return this.pushStack(n.unique(n.merge(this.get(),n(a,b))))},addBack:function(a){return this.add(null==a?this.prevObject:this.prevObject.filter(a))}});function D(a,b){while((a=a[b])&&1!==a.nodeType);return a}n.each({parent:function(a){var b=a.parentNode;return b&&11!==b.nodeType?b:null},parents:function(a){return n.dir(a,"parentNode")},parentsUntil:function(a,b,c){return n.dir(a,"parentNode",c)},next:function(a){return D(a,"nextSibling")},prev:function(a){return D(a,"previousSibling")},nextAll:function(a){return n.dir(a,"nextSibling")},prevAll:function(a){return n.dir(a,"previousSibling")},nextUntil:function(a,b,c){return n.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return n.dir(a,"previousSibling",c)},siblings:function(a){return n.sibling((a.parentNode||{}).firstChild,a)},children:function(a){return n.sibling(a.firstChild)},contents:function(a){return a.contentDocument||n.merge([],a.childNodes)}},function(a,b){n.fn[a]=function(c,d){var e=n.map(this,b,c);return"Until"!==a.slice(-5)&&(d=c),d&&"string"==typeof d&&(e=n.filter(d,e)),this.length>1&&(C[a]||n.unique(e),B.test(a)&&e.reverse()),this.pushStack(e)}});var E=/\S+/g,F={};function G(a){var b=F[a]={};return n.each(a.match(E)||[],function(a,c){b[c]=!0}),b}n.Callbacks=function(a){a="string"==typeof a?F[a]||G(a):n.extend({},a);var b,c,d,e,f,g,h=[],i=!a.once&&[],j=function(l){for(b=a.memory&&l,c=!0,g=e||0,e=0,f=h.length,d=!0;h&&f>g;g++)if(h[g].apply(l[0],l[1])===!1&&a.stopOnFalse){b=!1;break}d=!1,h&&(i?i.length&&j(i.shift()):b?h=[]:k.disable())},k={add:function(){if(h){var c=h.length;!function g(b){n.each(b,function(b,c){var d=n.type(c);"function"===d?a.unique&&k.has(c)||h.push(c):c&&c.length&&"string"!==d&&g(c)})}(arguments),d?f=h.length:b&&(e=c,j(b))}return this},remove:function(){return h&&n.each(arguments,function(a,b){var c;while((c=n.inArray(b,h,c))>-1)h.splice(c,1),d&&(f>=c&&f--,g>=c&&g--)}),this},has:function(a){return a?n.inArray(a,h)>-1:!(!h||!h.length)},empty:function(){return h=[],f=0,this},disable:function(){return h=i=b=void 0,this},disabled:function(){return!h},lock:function(){return i=void 0,b||k.disable(),this},locked:function(){return!i},fireWith:function(a,b){return!h||c&&!i||(b=b||[],b=[a,b.slice?b.slice():b],d?i.push(b):j(b)),this},fire:function(){return k.fireWith(this,arguments),this},fired:function(){return!!c}};return k},n.extend({Deferred:function(a){var b=[["resolve","done",n.Callbacks("once memory"),"resolved"],["reject","fail",n.Callbacks("once memory"),"rejected"],["notify","progress",n.Callbacks("memory")]],c="pending",d={state:function(){return c},always:function(){return e.done(arguments).fail(arguments),this},then:function(){var a=arguments;return n.Deferred(function(c){n.each(b,function(b,f){var g=n.isFunction(a[b])&&a[b];e[f[1]](function(){var a=g&&g.apply(this,arguments);a&&n.isFunction(a.promise)?a.promise().done(c.resolve).fail(c.reject).progress(c.notify):c[f[0]+"With"](this===d?c.promise():this,g?[a]:arguments)})}),a=null}).promise()},promise:function(a){return null!=a?n.extend(a,d):d}},e={};return d.pipe=d.then,n.each(b,function(a,f){var g=f[2],h=f[3];d[f[1]]=g.add,h&&g.add(function(){c=h},b[1^a][2].disable,b[2][2].lock),e[f[0]]=function(){return e[f[0]+"With"](this===e?d:this,arguments),this},e[f[0]+"With"]=g.fireWith}),d.promise(e),a&&a.call(e,e),e},when:function(a){var b=0,c=d.call(arguments),e=c.length,f=1!==e||a&&n.isFunction(a.promise)?e:0,g=1===f?a:n.Deferred(),h=function(a,b,c){return function(e){b[a]=this,c[a]=arguments.length>1?d.call(arguments):e,c===i?g.notifyWith(b,c):--f||g.resolveWith(b,c)}},i,j,k;if(e>1)for(i=new Array(e),j=new Array(e),k=new Array(e);e>b;b++)c[b]&&n.isFunction(c[b].promise)?c[b].promise().done(h(b,k,c)).fail(g.reject).progress(h(b,j,i)):--f;return f||g.resolveWith(k,c),g.promise()}});var H;n.fn.ready=function(a){return n.ready.promise().done(a),this},n.extend({isReady:!1,readyWait:1,holdReady:function(a){a?n.readyWait++:n.ready(!0)},ready:function(a){(a===!0?--n.readyWait:n.isReady)||(n.isReady=!0,a!==!0&&--n.readyWait>0||(H.resolveWith(l,[n]),n.fn.triggerHandler&&(n(l).triggerHandler("ready"),n(l).off("ready"))))}});function I(){l.removeEventListener("DOMContentLoaded",I,!1),a.removeEventListener("load",I,!1),n.ready()}n.ready.promise=function(b){return H||(H=n.Deferred(),"complete"===l.readyState?setTimeout(n.ready):(l.addEventListener("DOMContentLoaded",I,!1),a.addEventListener("load",I,!1))),H.promise(b)},n.ready.promise();var J=n.access=function(a,b,c,d,e,f,g){var h=0,i=a.length,j=null==c;if("object"===n.type(c)){e=!0;for(h in c)n.access(a,b,h,c[h],!0,f,g)}else if(void 0!==d&&(e=!0,n.isFunction(d)||(g=!0),j&&(g?(b.call(a,d),b=null):(j=b,b=function(a,b,c){return j.call(n(a),c)})),b))for(;i>h;h++)b(a[h],c,g?d:d.call(a[h],h,b(a[h],c)));return e?a:j?b.call(a):i?b(a[0],c):f};n.acceptData=function(a){return 1===a.nodeType||9===a.nodeType||!+a.nodeType};function K(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=n.expando+K.uid++}K.uid=1,K.accepts=n.acceptData,K.prototype={key:function(a){if(!K.accepts(a))return 0;var b={},c=a[this.expando];if(!c){c=K.uid++;try{b[this.expando]={value:c},Object.defineProperties(a,b)}catch(d){b[this.expando]=c,n.extend(a,b)}}return this.cache[c]||(this.cache[c]={}),c},set:function(a,b,c){var d,e=this.key(a),f=this.cache[e];if("string"==typeof b)f[b]=c;else if(n.isEmptyObject(f))n.extend(this.cache[e],b);else for(d in b)f[d]=b[d];return f},get:function(a,b){var c=this.cache[this.key(a)];return void 0===b?c:c[b]},access:function(a,b,c){var d;return void 0===b||b&&"string"==typeof b&&void 0===c?(d=this.get(a,b),void 0!==d?d:this.get(a,n.camelCase(b))):(this.set(a,b,c),void 0!==c?c:b)},remove:function(a,b){var c,d,e,f=this.key(a),g=this.cache[f];if(void 0===b)this.cache[f]={};else{n.isArray(b)?d=b.concat(b.map(n.camelCase)):(e=n.camelCase(b),b in g?d=[b,e]:(d=e,d=d in g?[d]:d.match(E)||[])),c=d.length;while(c--)delete g[d[c]]}},hasData:function(a){return!n.isEmptyObject(this.cache[a[this.expando]]||{})},discard:function(a){a[this.expando]&&delete this.cache[a[this.expando]]}};var L=new K,M=new K,N=/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,O=/([A-Z])/g;function P(a,b,c){var d;if(void 0===c&&1===a.nodeType)if(d="data-"+b.replace(O,"-$1").toLowerCase(),c=a.getAttribute(d),"string"==typeof c){try{c="true"===c?!0:"false"===c?!1:"null"===c?null:+c+""===c?+c:N.test(c)?n.parseJSON(c):c}catch(e){}M.set(a,b,c)}else c=void 0;return c}n.extend({hasData:function(a){return M.hasData(a)||L.hasData(a)},data:function(a,b,c){ 3 | return M.access(a,b,c)},removeData:function(a,b){M.remove(a,b)},_data:function(a,b,c){return L.access(a,b,c)},_removeData:function(a,b){L.remove(a,b)}}),n.fn.extend({data:function(a,b){var c,d,e,f=this[0],g=f&&f.attributes;if(void 0===a){if(this.length&&(e=M.get(f),1===f.nodeType&&!L.get(f,"hasDataAttrs"))){c=g.length;while(c--)g[c]&&(d=g[c].name,0===d.indexOf("data-")&&(d=n.camelCase(d.slice(5)),P(f,d,e[d])));L.set(f,"hasDataAttrs",!0)}return e}return"object"==typeof a?this.each(function(){M.set(this,a)}):J(this,function(b){var c,d=n.camelCase(a);if(f&&void 0===b){if(c=M.get(f,a),void 0!==c)return c;if(c=M.get(f,d),void 0!==c)return c;if(c=P(f,d,void 0),void 0!==c)return c}else this.each(function(){var c=M.get(this,d);M.set(this,d,b),-1!==a.indexOf("-")&&void 0!==c&&M.set(this,a,b)})},null,b,arguments.length>1,null,!0)},removeData:function(a){return this.each(function(){M.remove(this,a)})}}),n.extend({queue:function(a,b,c){var d;return a?(b=(b||"fx")+"queue",d=L.get(a,b),c&&(!d||n.isArray(c)?d=L.access(a,b,n.makeArray(c)):d.push(c)),d||[]):void 0},dequeue:function(a,b){b=b||"fx";var c=n.queue(a,b),d=c.length,e=c.shift(),f=n._queueHooks(a,b),g=function(){n.dequeue(a,b)};"inprogress"===e&&(e=c.shift(),d--),e&&("fx"===b&&c.unshift("inprogress"),delete f.stop,e.call(a,g,f)),!d&&f&&f.empty.fire()},_queueHooks:function(a,b){var c=b+"queueHooks";return L.get(a,c)||L.access(a,c,{empty:n.Callbacks("once memory").add(function(){L.remove(a,[b+"queue",c])})})}}),n.fn.extend({queue:function(a,b){var c=2;return"string"!=typeof a&&(b=a,a="fx",c--),arguments.lengthx",k.noCloneChecked=!!b.cloneNode(!0).lastChild.defaultValue}();var U="undefined";k.focusinBubbles="onfocusin"in a;var V=/^key/,W=/^(?:mouse|pointer|contextmenu)|click/,X=/^(?:focusinfocus|focusoutblur)$/,Y=/^([^.]*)(?:\.(.+)|)$/;function Z(){return!0}function $(){return!1}function _(){try{return l.activeElement}catch(a){}}n.event={global:{},add:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.get(a);if(r){c.handler&&(f=c,c=f.handler,e=f.selector),c.guid||(c.guid=n.guid++),(i=r.events)||(i=r.events={}),(g=r.handle)||(g=r.handle=function(b){return typeof n!==U&&n.event.triggered!==b.type?n.event.dispatch.apply(a,arguments):void 0}),b=(b||"").match(E)||[""],j=b.length;while(j--)h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o&&(l=n.event.special[o]||{},o=(e?l.delegateType:l.bindType)||o,l=n.event.special[o]||{},k=n.extend({type:o,origType:q,data:d,handler:c,guid:c.guid,selector:e,needsContext:e&&n.expr.match.needsContext.test(e),namespace:p.join(".")},f),(m=i[o])||(m=i[o]=[],m.delegateCount=0,l.setup&&l.setup.call(a,d,p,g)!==!1||a.addEventListener&&a.addEventListener(o,g,!1)),l.add&&(l.add.call(a,k),k.handler.guid||(k.handler.guid=c.guid)),e?m.splice(m.delegateCount++,0,k):m.push(k),n.event.global[o]=!0)}},remove:function(a,b,c,d,e){var f,g,h,i,j,k,l,m,o,p,q,r=L.hasData(a)&&L.get(a);if(r&&(i=r.events)){b=(b||"").match(E)||[""],j=b.length;while(j--)if(h=Y.exec(b[j])||[],o=q=h[1],p=(h[2]||"").split(".").sort(),o){l=n.event.special[o]||{},o=(d?l.delegateType:l.bindType)||o,m=i[o]||[],h=h[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),g=f=m.length;while(f--)k=m[f],!e&&q!==k.origType||c&&c.guid!==k.guid||h&&!h.test(k.namespace)||d&&d!==k.selector&&("**"!==d||!k.selector)||(m.splice(f,1),k.selector&&m.delegateCount--,l.remove&&l.remove.call(a,k));g&&!m.length&&(l.teardown&&l.teardown.call(a,p,r.handle)!==!1||n.removeEvent(a,o,r.handle),delete i[o])}else for(o in i)n.event.remove(a,o+b[j],c,d,!0);n.isEmptyObject(i)&&(delete r.handle,L.remove(a,"events"))}},trigger:function(b,c,d,e){var f,g,h,i,k,m,o,p=[d||l],q=j.call(b,"type")?b.type:b,r=j.call(b,"namespace")?b.namespace.split("."):[];if(g=h=d=d||l,3!==d.nodeType&&8!==d.nodeType&&!X.test(q+n.event.triggered)&&(q.indexOf(".")>=0&&(r=q.split("."),q=r.shift(),r.sort()),k=q.indexOf(":")<0&&"on"+q,b=b[n.expando]?b:new n.Event(q,"object"==typeof b&&b),b.isTrigger=e?2:3,b.namespace=r.join("."),b.namespace_re=b.namespace?new RegExp("(^|\\.)"+r.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,b.result=void 0,b.target||(b.target=d),c=null==c?[b]:n.makeArray(c,[b]),o=n.event.special[q]||{},e||!o.trigger||o.trigger.apply(d,c)!==!1)){if(!e&&!o.noBubble&&!n.isWindow(d)){for(i=o.delegateType||q,X.test(i+q)||(g=g.parentNode);g;g=g.parentNode)p.push(g),h=g;h===(d.ownerDocument||l)&&p.push(h.defaultView||h.parentWindow||a)}f=0;while((g=p[f++])&&!b.isPropagationStopped())b.type=f>1?i:o.bindType||q,m=(L.get(g,"events")||{})[b.type]&&L.get(g,"handle"),m&&m.apply(g,c),m=k&&g[k],m&&m.apply&&n.acceptData(g)&&(b.result=m.apply(g,c),b.result===!1&&b.preventDefault());return b.type=q,e||b.isDefaultPrevented()||o._default&&o._default.apply(p.pop(),c)!==!1||!n.acceptData(d)||k&&n.isFunction(d[q])&&!n.isWindow(d)&&(h=d[k],h&&(d[k]=null),n.event.triggered=q,d[q](),n.event.triggered=void 0,h&&(d[k]=h)),b.result}},dispatch:function(a){a=n.event.fix(a);var b,c,e,f,g,h=[],i=d.call(arguments),j=(L.get(this,"events")||{})[a.type]||[],k=n.event.special[a.type]||{};if(i[0]=a,a.delegateTarget=this,!k.preDispatch||k.preDispatch.call(this,a)!==!1){h=n.event.handlers.call(this,a,j),b=0;while((f=h[b++])&&!a.isPropagationStopped()){a.currentTarget=f.elem,c=0;while((g=f.handlers[c++])&&!a.isImmediatePropagationStopped())(!a.namespace_re||a.namespace_re.test(g.namespace))&&(a.handleObj=g,a.data=g.data,e=((n.event.special[g.origType]||{}).handle||g.handler).apply(f.elem,i),void 0!==e&&(a.result=e)===!1&&(a.preventDefault(),a.stopPropagation()))}return k.postDispatch&&k.postDispatch.call(this,a),a.result}},handlers:function(a,b){var c,d,e,f,g=[],h=b.delegateCount,i=a.target;if(h&&i.nodeType&&(!a.button||"click"!==a.type))for(;i!==this;i=i.parentNode||this)if(i.disabled!==!0||"click"!==a.type){for(d=[],c=0;h>c;c++)f=b[c],e=f.selector+" ",void 0===d[e]&&(d[e]=f.needsContext?n(e,this).index(i)>=0:n.find(e,this,null,[i]).length),d[e]&&d.push(f);d.length&&g.push({elem:i,handlers:d})}return h]*)\/>/gi,ba=/<([\w:]+)/,ca=/<|&#?\w+;/,da=/<(?:script|style|link)/i,ea=/checked\s*(?:[^=]|=\s*.checked.)/i,fa=/^$|\/(?:java|ecma)script/i,ga=/^true\/(.*)/,ha=/^\s*\s*$/g,ia={option:[1,""],thead:[1,"","
"],col:[2,"","
"],tr:[2,"","
"],td:[3,"","
"],_default:[0,"",""]};ia.optgroup=ia.option,ia.tbody=ia.tfoot=ia.colgroup=ia.caption=ia.thead,ia.th=ia.td;function ja(a,b){return n.nodeName(a,"table")&&n.nodeName(11!==b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function ka(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function la(a){var b=ga.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function ma(a,b){for(var c=0,d=a.length;d>c;c++)L.set(a[c],"globalEval",!b||L.get(b[c],"globalEval"))}function na(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(L.hasData(a)&&(f=L.access(a),g=L.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)n.event.add(b,e,j[e][c])}M.hasData(a)&&(h=M.access(a),i=n.extend({},h),M.set(b,i))}}function oa(a,b){var c=a.getElementsByTagName?a.getElementsByTagName(b||"*"):a.querySelectorAll?a.querySelectorAll(b||"*"):[];return void 0===b||b&&n.nodeName(a,b)?n.merge([a],c):c}function pa(a,b){var c=b.nodeName.toLowerCase();"input"===c&&T.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}n.extend({clone:function(a,b,c){var d,e,f,g,h=a.cloneNode(!0),i=n.contains(a.ownerDocument,a);if(!(k.noCloneChecked||1!==a.nodeType&&11!==a.nodeType||n.isXMLDoc(a)))for(g=oa(h),f=oa(a),d=0,e=f.length;e>d;d++)pa(f[d],g[d]);if(b)if(c)for(f=f||oa(a),g=g||oa(h),d=0,e=f.length;e>d;d++)na(f[d],g[d]);else na(a,h);return g=oa(h,"script"),g.length>0&&ma(g,!i&&oa(a,"script")),h},buildFragment:function(a,b,c,d){for(var e,f,g,h,i,j,k=b.createDocumentFragment(),l=[],m=0,o=a.length;o>m;m++)if(e=a[m],e||0===e)if("object"===n.type(e))n.merge(l,e.nodeType?[e]:e);else if(ca.test(e)){f=f||k.appendChild(b.createElement("div")),g=(ba.exec(e)||["",""])[1].toLowerCase(),h=ia[g]||ia._default,f.innerHTML=h[1]+e.replace(aa,"<$1>")+h[2],j=h[0];while(j--)f=f.lastChild;n.merge(l,f.childNodes),f=k.firstChild,f.textContent=""}else l.push(b.createTextNode(e));k.textContent="",m=0;while(e=l[m++])if((!d||-1===n.inArray(e,d))&&(i=n.contains(e.ownerDocument,e),f=oa(k.appendChild(e),"script"),i&&ma(f),c)){j=0;while(e=f[j++])fa.test(e.type||"")&&c.push(e)}return k},cleanData:function(a){for(var b,c,d,e,f=n.event.special,g=0;void 0!==(c=a[g]);g++){if(n.acceptData(c)&&(e=c[L.expando],e&&(b=L.cache[e]))){if(b.events)for(d in b.events)f[d]?n.event.remove(c,d):n.removeEvent(c,d,b.handle);L.cache[e]&&delete L.cache[e]}delete M.cache[c[M.expando]]}}}),n.fn.extend({text:function(a){return J(this,function(a){return void 0===a?n.text(this):this.empty().each(function(){(1===this.nodeType||11===this.nodeType||9===this.nodeType)&&(this.textContent=a)})},null,a,arguments.length)},append:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.appendChild(a)}})},prepend:function(){return this.domManip(arguments,function(a){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var b=ja(this,a);b.insertBefore(a,b.firstChild)}})},before:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this)})},after:function(){return this.domManip(arguments,function(a){this.parentNode&&this.parentNode.insertBefore(a,this.nextSibling)})},remove:function(a,b){for(var c,d=a?n.filter(a,this):this,e=0;null!=(c=d[e]);e++)b||1!==c.nodeType||n.cleanData(oa(c)),c.parentNode&&(b&&n.contains(c.ownerDocument,c)&&ma(oa(c,"script")),c.parentNode.removeChild(c));return this},empty:function(){for(var a,b=0;null!=(a=this[b]);b++)1===a.nodeType&&(n.cleanData(oa(a,!1)),a.textContent="");return this},clone:function(a,b){return a=null==a?!1:a,b=null==b?a:b,this.map(function(){return n.clone(this,a,b)})},html:function(a){return J(this,function(a){var b=this[0]||{},c=0,d=this.length;if(void 0===a&&1===b.nodeType)return b.innerHTML;if("string"==typeof a&&!da.test(a)&&!ia[(ba.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(aa,"<$1>");try{for(;d>c;c++)b=this[c]||{},1===b.nodeType&&(n.cleanData(oa(b,!1)),b.innerHTML=a);b=0}catch(e){}}b&&this.empty().append(a)},null,a,arguments.length)},replaceWith:function(){var a=arguments[0];return this.domManip(arguments,function(b){a=this.parentNode,n.cleanData(oa(this)),a&&a.replaceChild(b,this)}),a&&(a.length||a.nodeType)?this:this.remove()},detach:function(a){return this.remove(a,!0)},domManip:function(a,b){a=e.apply([],a);var c,d,f,g,h,i,j=0,l=this.length,m=this,o=l-1,p=a[0],q=n.isFunction(p);if(q||l>1&&"string"==typeof p&&!k.checkClone&&ea.test(p))return this.each(function(c){var d=m.eq(c);q&&(a[0]=p.call(this,c,d.html())),d.domManip(a,b)});if(l&&(c=n.buildFragment(a,this[0].ownerDocument,!1,this),d=c.firstChild,1===c.childNodes.length&&(c=d),d)){for(f=n.map(oa(c,"script"),ka),g=f.length;l>j;j++)h=c,j!==o&&(h=n.clone(h,!0,!0),g&&n.merge(f,oa(h,"script"))),b.call(this[j],h,j);if(g)for(i=f[f.length-1].ownerDocument,n.map(f,la),j=0;g>j;j++)h=f[j],fa.test(h.type||"")&&!L.access(h,"globalEval")&&n.contains(i,h)&&(h.src?n._evalUrl&&n._evalUrl(h.src):n.globalEval(h.textContent.replace(ha,"")))}return this}}),n.each({appendTo:"append",prependTo:"prepend",insertBefore:"before",insertAfter:"after",replaceAll:"replaceWith"},function(a,b){n.fn[a]=function(a){for(var c,d=[],e=n(a),g=e.length-1,h=0;g>=h;h++)c=h===g?this:this.clone(!0),n(e[h])[b](c),f.apply(d,c.get());return this.pushStack(d)}});var qa,ra={};function sa(b,c){var d,e=n(c.createElement(b)).appendTo(c.body),f=a.getDefaultComputedStyle&&(d=a.getDefaultComputedStyle(e[0]))?d.display:n.css(e[0],"display");return e.detach(),f}function ta(a){var b=l,c=ra[a];return c||(c=sa(a,b),"none"!==c&&c||(qa=(qa||n("