Python googleapiclient.discovery 模块,build_from_document() 实例源码

我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用googleapiclient.discovery.build_from_document()

项目:pygsheets    作者:nithinmurali    | 项目源码 | 文件源码
def __init__(self, oauth, http_client=None, retries=1, no_cache=False):
        if no_cache:
            cache = None
        else:
            cache = os.path.join(tempfile.gettempdir(), str(uuid.uuid4()))

        self.oauth = oauth
        http_client = http_client or httplib2.Http(cache=cache, timeout=20)
        http = self.oauth.authorize(http_client)
        data_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data")
        with open(os.path.join(data_path, "sheets_discovery.json")) as jd:
            self.service = discovery.build_from_document(jload(jd), http=http)
        with open(os.path.join(data_path, "drive_discovery.json")) as jd:
            self.driveService = discovery.build_from_document(jload(jd), http=http)
        self._spreadsheeets = []
        self.batch_requests = dict()
        self.retries = retries
        self.enableTeamDriveSupport = False  # if teamdrive files should be included
        self.teamDriveId = None  # teamdrive to search for spreadsheet
        self._fetch_sheets()
项目:artman    作者:googleapis    | 项目源码 | 文件源码
def _create_tasks_client():
    credentials = GoogleCredentials.get_application_default()
    with open(
        os.path.join(os.path.dirname(__file__), 'cloudtasks.json'), 'r') as f:
            return build_from_document(f.read(), credentials=credentials)
项目:artman    作者:googleapis    | 项目源码 | 文件源码
def _create_cloudtasks_client_testing(self, http):
        with open(
            os.path.join(os.path.dirname(__file__),
                         '../../artman/conductors/cloudtasks.json'), 'r') as f:
                return build_from_document(f.read(),  http=http)