Return True if data are copied
        * optimized for http->fs copy
        * not supported return_status
769533
async def copy(self, key_source, storage_dest, key_dest):
        
        from aioworkers.storage.filesystem import FileSystemStorage
        if not isinstance(storage_dest, FileSystemStorage):
            return super().copy(key_source, storage_dest, key_dest)
        url = self.raw_key(key_source)
        logger = self.context.logger
        async with self._semaphore:
            async with self.session.get(url) as response:
                if response.status == 404:
                    return
                elif response.status >= 400:
                    if logger.getEffectiveLevel() == logging.DEBUG:
                        logger.debug(
                            'HttpStorage request to %s '
                            'returned code %s:\n%s' % (
                                url, response.status,
                                (await response.read()).decode()))
                    return
                async with storage_dest.raw_key(key_dest).open('wb') as f:
                    async for chunk in response.content.iter_any():
                        await f.write(chunk)
                    return True
1129514
function isFile(fp, stat) {
  if (stat === true) {
    stat = tryStats(fp);
  }
  return !isDir(fp, stat);
}
367882
def _check_for_duplicates(xs, attr, check_fn=None):
    
    dups = []
    for key, vals in itertools.groupby(x[attr] for x in xs):
        if len(list(vals)) > 1:
            dups.append(key)
    if len(dups) > 0:
        psamples = []
        for x in xs:
            if x[attr] in dups:
                psamples.append(x)
        # option to skip problem based on custom input function.
        if check_fn and check_fn(psamples):
            return
        descrs = [x["description"] for x in psamples]
        raise ValueError("Duplicate '%s' found in input sample configuration.\n"
                         "Required to be unique for a project: %s\n"
                         "Problem found in these samples: %s" % (attr, dups, descrs))
671783
def only_newer(copy_func):
    
    @functools.wraps(copy_func)
    def wrapper(src, dst, *args, **kwargs):
        is_newer_dst = (
            dst.exists()
            and dst.getmtime() >= src.getmtime()
        )
        if is_newer_dst:
            return dst
        return copy_func(src, dst, *args, **kwargs)
    return wrapper
446440
def copy(self, cls=None):
        '''  '''
        cls = cls or BaseResponse
        assert issubclass(cls, BaseResponse)
        copy = cls()
        copy.status = self.status
        copy._headers = dict((k, v[:]) for (k, v) in self._headers.items())
        if self._cookies:
            copy._cookies = SimpleCookie()
            copy._cookies.load(self._cookies.output(header=''))
        return copy
1058022
def check_if_alive(self):
        

        try:
            from urllib2 import urlopen, URLError, HTTPError
        except ImportError:
            from urllib.request import urlopen, URLError, HTTPError

        if len(self.instance.STATUS_LINK):
            check_url = self.instance.STATUS_LINK % ({'content_uid': self.get_content_uid()})
        else:
            # fallback
            check_url = self.instance.url

        try:
            response = urlopen(check_url)
        except (HTTPError, URLError):
            return False
        except ValueError:
            raise URLError('Invalid URL: %s'.format(check_url))
        else:
            return True if response.code == 200 else False
477097
def termination_check(self):
        # type: (SyncCopy) -> bool
        
        with self._transfer_lock:
            return (self._synccopy_terminate or
                    len(self._exceptions) > 0 or
                    (self._all_remote_files_processed and
                     len(self._transfer_set) == 0))
945461
private static boolean ifExistsAndFresh(Configuration conf, FileSystem fs,
                                          URI cache, long confFileStamp,
                                          CacheStatus lcacheStatus,
                                          FileStatus fileStatus)
  throws IOException {
    // check for existence of the cache
    long dfsFileStamp;
    if (fileStatus != null) {
      dfsFileStamp = fileStatus.getModificationTime();
    } else {
      dfsFileStamp = getTimestamp(conf, cache);
    }

    // ensure that the file on hdfs hasn't been modified since the job started
    if (dfsFileStamp != confFileStamp) {
      LOG.fatal("File: " + cache + " has changed on HDFS since job started");
      throw new IOException("File: " + cache +
          " has changed on HDFS since job started");
    }

    if (dfsFileStamp != lcacheStatus.mtime) {
      // needs refreshing
      return false;
    }

    return true;
  }
658213
def check_datafile_present_and_download(path, backup_url=None):
    
    path = Path(path)
    if path.is_file(): return True
    if backup_url is None: return False
    logg.info('try downloading from url\n' + backup_url + '\n' +
              '... this may take a while but only happens once')
    if not path.parent.is_dir():
        logg.info('creating directory', str(path.parent) + '/', 'for saving data')
        path.parent.mkdir(parents=True)
    from urllib.request import urlretrieve
    urlretrieve(backup_url, str(path), reporthook=download_progress)
    logg.info('')
    return True
1229604
def copy_file(self, filepath):
        
        copy_file = False
        try:
            copy_file = self.data[filepath]['copy']
        except KeyError:
            return False
        return copy_file
572370
def _check_copy_conditions(self, src, dst):
        # type: (SyncCopy, blobxfer.models.azure.StorageEntity,
        #        blobxfer.models.azure.StorageEntity) -> UploadAction
        
        # if remote file doesn't exist, copy
        if dst is None or dst.from_local:
            return SynccopyAction.Copy
        # check overwrite option
        if not self._spec.options.overwrite:
            logger.info(
                'not overwriting remote file: {})'.format(dst.path))
            return SynccopyAction.Skip
        # check skip on options, MD5 match takes priority
        src_md5 = blobxfer.models.metadata.get_md5_from_metadata(src)
        dst_md5 = blobxfer.models.metadata.get_md5_from_metadata(dst)
        if (self._spec.skip_on.md5_match and
                blobxfer.util.is_not_empty(src_md5)):
            if src_md5 == dst_md5:
                return SynccopyAction.Skip
            else:
                return SynccopyAction.Copy
        # if neither of the remaining skip on actions are activated, copy
        if (not self._spec.skip_on.filesize_match and
                not self._spec.skip_on.lmt_ge):
            return SynccopyAction.Copy
        # check skip on file size match
        ul_fs = None
        if self._spec.skip_on.filesize_match:
            if src.size == dst.size:
                ul_fs = False
            else:
                ul_fs = True
        # check skip on lmt ge
        ul_lmt = None
        if self._spec.skip_on.lmt_ge:
            if dst.lmt >= src.lmt:
                ul_lmt = False
            else:
                ul_lmt = True
        # upload if either skip on mismatch is True
        if ul_fs or ul_lmt:
            return SynccopyAction.Copy
        else:
            return SynccopyAction.Skip
407579
def _copy_finfo(finfo, storage_dir, pass_uptodate=False):
    
    out_file = _get_file_upload_path(finfo, storage_dir)
    if not shared.up_to_date(out_file, finfo):
        logger.info("Storing in local filesystem: %s" % out_file)
        shutil.copy(finfo["path"], out_file)
        return out_file
    if pass_uptodate:
        return out_file
140449
def verify_hash(self, hashed_data, compare_data):
        
        return self.security.hashing_context.verify(
            encode_string(compare_data), hashed_data)
91423
def is_downloaded(self):
        
        if self.file_path is None:
            return False
        return os.path.exists(self.file_path)
407129
async def check(self, *args):
        
        data = {}
        for target in self.targets:
            result = await target(*args)
            if not result:
                return False
            if isinstance(result, dict):
                data.update(result)
        if not data:
            return True
        return data
643477
def copy_func(dest, src, symlinks=True):
    

    dest = str(dest)
    src = str(src)

    SCons.Node.FS.invalidate_node_memos(dest)
    if SCons.Util.is_List(src) and os.path.isdir(dest):
        for file in src:
            shutil.copy2(file, dest)
        return 0
    elif os.path.islink(src):
        if symlinks:
            return os.symlink(os.readlink(src), dest)
        else:
            return copy_func(dest, os.path.realpath(src))
    elif os.path.isfile(src):
        shutil.copy2(src, dest)
        return 0
    else:
        shutil.copytree(src, dest, symlinks)
        # copytree returns None in python2 and destination string in python3
        # A error is raised in both cases, so we can just return 0 for success
        return 0
831918
def isfile(self, version=None, *args, **kwargs):
        '''
        
        '''
        version = _process_version(self, version)

        path = self.get_version_path(version)
        self.authority.fs.isfile(path, *args, **kwargs)