Check if online file has been modified.
    Args:
        :web_file: online file to check.
        :destination: path of the offline file to compare.
355781
def is_remote_file_modified(web_file, destination):
    
    try:
        # check datetime of last modified in file.
        last_mod = web_file.headers.get('last-modified')
        if last_mod:
            web_file_time = time.strptime(
                web_file.headers.get(
                    'last-modified'), '%a, %d %b %Y %H:%M:%S %Z')
        else:
            web_file_time = time.gmtime()

        web_file_size = int(web_file.headers.get('content-length', -1))
        if os.path.exists(destination):
            file_time = time.gmtime(os.path.getmtime(destination))
            file_size = os.path.getsize(destination)
            if file_time >= web_file_time and file_size == web_file_size:
                return False

    except Exception as ex:
        msg = ('Fail checking if remote file is modified default returns TRUE'
               ' - {}'.format(ex))
        logger.debug(msg)

    return True
864315
def on_moved(self, event):
        
        logger.debug("file moved: %s -> %s", event.src_path, event.dest_path)
        if not event.is_directory:
            self.update_file(event.dest_path)
83549
def _scan(self, trigger=True):
        
        changed = False
        files_seen = set()
        os_path_join = os.path.join
        for path in self.paths:
            for root, dirs, files in os.walk(path):
                for f in files:
                    fpath = os_path_join(root, f)
                    if not self.is_valid_type(fpath):
                        continue
                    files_seen.add(fpath)
                    if self._requires_new_modtime(fpath):
                        self._watch_file(fpath, trigger)
                        changed = True
            for f in self._watched_files:
                if f not in files_seen:
                    self._unwatch_file(f, trigger)
                    changed = True
        return changed
979741
def _HasOOOWrite(self, path):
    """"""
    # Check the sizes of each path before the current one.
    size = tf.io.gfile.stat(path).length
    old_size = self._finalized_sizes.get(path, None)
    if size != old_size:
      if old_size is None:
        logger.error('File %s created after file %s even though it\'s '
                         'lexicographically earlier', path, self._path)
      else:
        logger.error('File %s updated even though the current file is %s',
                         path, self._path)
      return True
    else:
      return False
1366988
def _check_download_dir(link, download_dir, hashes):
    # type: (Link, str, Hashes) -> Optional[str]
    
    download_path = os.path.join(download_dir, link.filename)
    if os.path.exists(download_path):
        # If already downloaded, does its hash match?
        logger.info('File was already downloaded %s', download_path)
        if hashes:
            try:
                hashes.check_against_path(download_path)
            except HashMismatch:
                logger.warning(
                    'Previously-downloaded file %s has bad hash. '
                    'Re-downloading.',
                    download_path
                )
                os.unlink(download_path)
                return None
        return download_path
    return None
113802
def watch_file(path, func, *args, **kwargs):
    
    if not path:
        raise ValueError('Please specify a file to watch')
    print('Watching "{}" for changes'.format(path))
    last_modification_time = os.path.getmtime(path)
    try:
        while True:
            time.sleep(1)
            new_modification_time = os.path.getmtime(path)
            if new_modification_time == last_modification_time:
                continue
            func(*args, **kwargs)
            last_modification_time = new_modification_time
    except KeyboardInterrupt:
        pass
1092329
def _check_file(self):
        
        if not os.path.exists(self.file_path):
            return False
        self._migrate()
        config = configparser.RawConfigParser()
        config.read(self.file_path)
        try:
            config.get(
                escape_for_ini('keyring-setting'),
                escape_for_ini('password reference'),
            )
        except (configparser.NoSectionError, configparser.NoOptionError):
            return False
        try:
            self._check_scheme(config)
        except AttributeError:
            # accept a missing scheme
            return True
        return self._check_version(config)
130118
def on_modified(self, event, dry_run=False, remove_uploaded=True):
        ' '
        super(ArchiveEventHandler, self).on_modified(event)
        src_path = event.src_path
        if event.is_directory:
            if not platform.is_darwin():
                log.info("event is a directory, safe to ignore")
                return
            # OSX is behaving erratically and we need to paper over it.
            # the OS only reports every other file event,
            # but always fires off a directory event when a file has changed. (OSX 10.9 tested)
            # so we need to find the actual file changed and then go on from there
            files = [event.src_path+"/"+f for f in os.listdir(event.src_path)]
            try:
                src_path = max(files, key=os.path.getmtime)
            except (OSError, ValueError) as e: # broken symlink or directory empty
                return
        log.info('Modified file detectd: %s', src_path)
        #
        # we're receiving events at least two times: on file open and on file close.
        # OSes might report even more
        # we're only interested in files that are closed (finished), so we try to
        # open it. if it is locked, we can infer that someone is still writing to it.
        # this works on platforms: windows, ... ?
        # TODO: investigate http://stackoverflow.com/a/3876461 for POSIX support
        try:
            open(src_path)   # win exclusively
            os.open(src_path, os.O_EXLOCK) # osx exclusively
        except IOError: # file is not finished
            log.info('File is not finished')
            return
        except AttributeError: # no suuport for O_EXLOCK (only BSD)
            pass
        return self._new(src_path, dry_run, remove_uploaded)
53061
def _check(self, file):
        

        if not os.path.exists(file):
            raise Error("file \"{}\" not found".format(file))

        _, extension = os.path.splitext(file)
        try:
            check = self.extension_map[extension[1:]]
        except KeyError:
            magic_type = magic.from_file(file)
            for name, cls in self.magic_map.items():
                if name in magic_type:
                    check = cls
                    break
            else:
                raise Error("unknown file type \"{}\", skipping...".format(file))

        try:
            with open(file) as f:
                code = "\n".join(line.rstrip() for line in f)
        except UnicodeDecodeError:
            raise Error("file does not seem to contain text, skipping...")

        # Ensure we don't warn about adding trailing newline
        try:
            if code[-1] != '\n':
                code += '\n'
        except IndexError:
            pass

        return check(code)
68536
def remote_file_differs?(full_path, content)
      !remote_file_exists?(full_path) || remote_file_exists?(full_path) && !remote_file_content_same_as?(full_path, content)
    end
22312
def file_is_present(self, file_path):
        
        p = self.p(file_path)
        if not os.path.exists(p):
            return False
        if not os.path.isfile(p):
            raise IOError("%s is not a file" % file_path)
        return True
230519
def is_file(cls, file):
        ''''''
        peeked_data = wpull.string.printable_bytes(
            wpull.util.peek_file(file)).lower()

        if b'<html' in peeked_data:
            return VeryFalse

        if re.search(br'@import |color:|background[a-z-]*:|font[a-z-]*:',
                     peeked_data):
            return True
438277
private boolean isFile(FTPClient client, Path file) {
    try {
      return !getFileStatus(client, file).isDir();
    } catch (FileNotFoundException e) {
      return false; // file does not exist
    } catch (IOException ioe) {
      throw new FTPException("File check failed", ioe);
    }
  }
287248
def fixity_check_file(file)
        versions = file.has_versions? ? file.versions.all : [file]

        versions = [versions.max_by(&:created)] if file.has_versions? && latest_version_only

        versions.collect { |v| fixity_check_file_version(file.id, v.uri.to_s) }.flatten
      end
53634
def cache_file(self, local_path, ip, path):
        
        destination = self.__destination(ip, path)
        atomicish_move(local_path, destination)
171462
public static boolean isModifed(File file, long lastModifyTime) {
		if (null == file || false == file.exists()) {
			return true;
		}
		return file.lastModified() != lastModifyTime;
	}
1373991
def stale_on_remote?(local_file)
      remote_file = @remote.directory.files.head(local_file.key)
      return true unless remote_file # file is missing from remote, therefore stale
      if remote_file.respond_to?(:content_md5) && local_file.respond_to?(:content_md5)
        (
          ( remote_file.content_length != local_file.content_length ) &&
          ( remote_file.content_md5 != local_file.content_md5 )
        )
      else
        true # if we don't know, upload anyway
      end
    end