示例#1
0
def get_archive(hostname, project, treeish, dir_path=None, **fetch_kwargs):
    """Gets a directory as a tar.gz archive or None if not found."""
    _validate_args(hostname, project, treeish, dir_path)
    dir_path = (dir_path or '').strip('/')
    if dir_path:
        dir_path = '/%s' % dir_path
    return gerrit.fetch(
        hostname, '%s/+archive/%s%s.tar.gz' % (project, treeish, dir_path),
        **fetch_kwargs)
示例#2
0
def get_archive(hostname, project, treeish, dir_path=None, **fetch_kwargs):
  """Gets a directory as a tar.gz archive or None if not found."""
  _validate_args(hostname, project, treeish, dir_path)
  dir_path = (dir_path or '').strip('/')
  if dir_path:
    dir_path = '/%s' % dir_path
  return gerrit.fetch(
      hostname, '%s/+archive/%s%s.tar.gz' % (project, treeish, dir_path),
      **fetch_kwargs)
示例#3
0
文件: gitiles.py 项目: nodirt/luci-py
def get_archive(hostname, project, treeish, dir_path=None):
  """Gets a directory as a tar.gz archive."""
  assert project
  assert treeish
  dir_path = (dir_path or '').strip('/')
  if dir_path:
    dir_path = '/./%s' % dir_path
  res = gerrit.fetch(
      hostname, '%s/+archive/%s%s.tar.gz' % (project, treeish, dir_path))
  return res.content if res else None
示例#4
0
def get_file_content(hostname, project, treeish, path, **fetch_kwargs):
    """Gets file contents.

  Returns:
    Raw contents of the file or None if not found.
  """
    _validate_args(hostname, project, treeish, path, path_required=True)
    data = gerrit.fetch(hostname,
                        '%s/+/%s%s' % (project, treeish, path),
                        headers={'Accept': 'text/plain'},
                        **fetch_kwargs)
    return base64.b64decode(data) if data is not None else None
示例#5
0
def get_file_content(hostname, project, treeish, path, **fetch_kwargs):
  """Gets file contents.

  Returns:
    Raw contents of the file or None if not found.
  """
  _validate_args(hostname, project, treeish, path, path_required=True)
  data = gerrit.fetch(
      hostname,
      '%s/+/%s%s' % (project, treeish, path),
      headers={'Accept': 'text/plain'},
      **fetch_kwargs)
  return base64.b64decode(data) if data is not None else None
示例#6
0
文件: gitiles.py 项目: nodirt/luci-py
def get_file_content(hostname, project, treeish, path):
  """Gets file contents.

  Returns:
    Raw contents of the file.
  """
  assert hostname
  assert project
  assert treeish
  assert path
  assert path.startswith('/')
  data = gerrit.fetch(
      hostname,
      '%s/+/%s/.%s' % (project, treeish, path),
      accept_header='text/plain').content
  if data is None:
    return None
  return base64.b64decode(data)