'Given an rsync-style path, returns a list of globbed paths
that will hopefully provide equivalent behaviour for scp. Does not
support the full range of rsync pattern matching behaviour, only that
exposed in the get/send_file interface (trailing slashes).
The is_local param is flag indicating if the paths should be
interpreted as local or remote paths.'

def _make_rsync_compatible_globs(self, path, is_local):

    if ((len(path) == 0) or (path[(-1)] != '/')):
        return [path]
    if is_local:
        def glob_matches_files(path, pattern):
            return (len(glob.glob((path + pattern))) > 0)
    else:
        def glob_matches_files(path, pattern):
            result = self.run(('ls    "%s"%s' % (utils.sh_escape(path), pattern)), stdout_tee=None, ignore_status=True)
            return (result.exit_status == 0)
    patterns = ['*', '.[!.]*']
    patterns = [p for p in patterns if glob_matches_files(path, p)]
    if is_local:
        return [('"%s"%s' % (utils.sh_escape(path), pattern)) for pattern in patterns]
    else:
        return [(utils.scp_remote_escape(path) + pattern) for pattern in patterns]
