downloads an item to local disk

        Inputs:
           itemID - unique id of item to download
           savePath - folder to save the file in
331806
def download(self, itemID, savePath):
        
        if os.path.isdir(savePath) == False:
            os.makedirs(savePath)
        url = self._url + "/%s/download" % itemID
        params = {
        }
        if len(params.keys()):
            url =  url + "?%s" % urlencode(params)
        return self._get(url=url,
                         param_dict=params,
                         out_folder=savePath,
                         securityHandler=self._securityHandler,
                         proxy_url=self._proxy_url,
                         proxy_port=self._proxy_port)
1136527
function getItem(path) {
                return localStorage.getItem(self.PROTOCOL_LOCAL_STORAGE + ":///" + (path.indexOf("/") == 0? path.substr(1) : path));
            }
724436
def do_get(self, from_path, to_path):
        
        to_file = open(os.path.expanduser(to_path), "wb")

        self.n.downloadFile(self.current_path + "/" + from_path, to_path)
6681
def get(self, path, local_path):
        
        normpath = os.path.normpath(local_path)
        folder = os.path.dirname(normpath)
        if folder and not os.path.exists(folder):
            os.makedirs(folder)

        tmp_local_path = local_path + '-luigi-tmp-%09d' % random.randrange(0, 1e10)

        # download file
        self._connect()

        if self.sftp:
            self._sftp_get(path, tmp_local_path)
        else:
            self._ftp_get(path, tmp_local_path)

        self._close()

        os.rename(tmp_local_path, local_path)
1237896
def itemData(self, f=None, savePath=None):
        

        params = {
        }
        if f is not None and \
           f.lower() in ['zip', 'json']:
            params['f'] = f
        url = "%s/data" % self.root
        if self.type in ["Shapefile", "CityEngine Web Scene", "Web Scene", "KML",
                         "Code Sample",
                         "Code Attachment", "Operations Dashboard Add In",
                         "CSV", "CSV Collection", "CAD Drawing", "Service Definition",
                         "Microsoft Word", "Microsoft Powerpoint",
                         "Microsoft Excel", "PDF", "Image",
                         "Visio Document", "iWork Keynote", "iWork Pages",
                         "iWork Numbers", "Map Document", "Map Package",
                         "Basemap Package", "Tile Package", "Project Package",
                         "Task File", "ArcPad Package", "Explorer Map",
                         "Globe Document", "Scene Document", "Published Map",
                         "Map Template", "Windows Mobile Package", "Pro Map",
                         "Layout", "Layer", "Layer Package", "File Geodatabase",
                         "Explorer Layer", "Geoprocessing Package", "Geoprocessing Sample",
                         "Locator Package", "Rule Package", "Workflow Manager Package",
                         "Desktop Application", "Desktop Application Template",
                         "Code Sample", "Desktop Add In", "Explorer Add In",
                         "ArcGIS Desktop Add-In", "ArcGIS Explorer Add-In",
                         "ArcGIS Explorer application configuration", "ArcGIS Explorer document",
                         ]:
            if savePath is None:
                raise AttributeError('savePath must be provided for a item of type: %s' % self.type)
            if os.path.isdir(savePath) == False:
                os.makedirs(savePath)
            result = self._get(url=url,
                               param_dict=params,
                               securityHandler=self._securityHandler,
                               proxy_url=self._proxy_url,
                               proxy_port=self._proxy_port,
                               out_folder=savePath,
                               file_name=self.name)
            return result
        else:
            results =  self._get(url, params,
                                 proxy_port=self._proxy_port,
                                 securityHandler=self._securityHandler,
                                 proxy_url=self._proxy_url)
            return results
744954
def _download_items(db, last_id):
    
    MAX_RETRY = 20  # how many times to try till decision that this is an end
    MAX_DOC_ID = 10000000  # this is used for download iterator

    not_found_cnt = 0  # circuit breaker
    for doc_id in xrange(last_id, MAX_DOC_ID):
        doc_id += 1
        print "Downloading %d.." % (doc_id)

        if not_found_cnt >= MAX_RETRY:
            print "It looks like this is an end:", doc_id - MAX_RETRY
            break

        try:
            record = _download(doc_id)
        except (DocumentNotFoundException, InvalidAlephBaseException):
            print "\tnot found, skipping"
            not_found_cnt += 1
            continue

        not_found_cnt = 0
        db["item_%d" % doc_id] = record
        db["last_id"] = doc_id - MAX_RETRY if doc_id > MAX_RETRY else 1

        if doc_id % 100 == 0:
            db.commit()
1087426
private File fileForItem(String id) {
		File subDir = subDirForId(id);
		String fileName = id.substring(SUBDIR_POLICY);
		return new File(subDir, fileName);
	}
1319543
def get_item_with_id(self, uid):
        
        for item in self.get_items():
            if item.id == uid:
                return item

        return None
1359275
def _interact_with_folder(self, output_folder, action):
        
        if not action in ('r', 'w'):
            raise ValueError("action must be either 'r' or 'w'.")
        for key, item in self.__dict__.items():
            if isinstance(item, dict):
                for side in ("left", "right"):
                    filename = os.path.join(output_folder,
                                            "{}_{}.npy".format(key, side))
                    if action == 'w':
                        np.save(filename, self.__dict__[key][side])
                    else:
                        self.__dict__[key][side] = np.load(filename)
            else:
                filename = os.path.join(output_folder, "{}.npy".format(key))
                if action == 'w':
                    np.save(filename, self.__dict__[key])
                else:
                    self.__dict__[key] = np.load(filename)
868004
def download_contents(self, to_folder=None):
        
        to_folder = to_folder or Path()
        if not to_folder.exists():
            to_folder.mkdir()

        for item in self.get_items(query=self.new_query().select('id', 'size')):
            if item.is_folder and item.child_count > 0:
                item.download_contents(to_folder=to_folder / item.name)
            else:
                item.download(to_folder)
277536
def download(self, path, file):
        """"""

        resp = self._sendRequest("GET", path)
        if resp.status_code == 200:
            with open(file, "wb") as f:
                f.write(resp.content)
        else:
            raise YaDiskException(resp.status_code, resp.content)
341670
def save(self, path):
        
        (folder, filename) = os.path.split(path)
        (name, extension) = os.path.splitext(filename)

        if not name:
            raise ValueError, "name is required"

        path = os.path.join(folder, name + self.extension)
        f = open(path, "wb")
        f.write(self.contents)
        f.close()

        return path
388716
private String pathToItem(String id) {
		return subDirForId(id) + UNIX_PATH_SEPERATOR + id.substring(SUBDIR_POLICY);
	}
943271
def download(path)
      resp, body = content_request('/files/download', path: path)
      return FileMetadata.new(resp), body
    end
144954
def itemInfoUpload(self, folder, filePath):
        
        files = {}
        url = self._url + "/iteminfo/upload"
        params = {
            "f" : "json",
            "folder" : folder
        }
        files['file'] = filePath
        return self._post(url=url,
                          param_dict=params,
                          files=files,
                          securityHandler=self._securityHandler,
                          proxy_url=self._proxy_url,
                          proxy_port=self._proxy_port)
1191288
def download(self, url, dir_path, filename=None):
        
        if not filename:
            filename = url.rsplit('/', 1)[1]
        path = os.path.join(dir_path, filename)

        content = self.fetch(url)
        with open(path, "wb") as f:
            f.write(content)

        return path
863693
def download(self, resource_id):
        
        self.resource_id(str(resource_id))
        self._request_uri = '{}/download'.format(self._request_uri)