Skip to content

Commit 364cd15

Browse files
author
Eric Koleda
authored
Merge pull request googleworkspace#70 from jsmeredith/master
Adding comments to helper functions in Drive Activity v2 API.
2 parents 15ffa1b + cefbacc commit 364cd15

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drive/activity-v2/quickstart.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2018 Google LLC
1+
# Copyright 2019 Google LLC
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -69,18 +69,21 @@ def main():
6969
truncated(targets)))
7070

7171

72+
# Returns a string representation of the first elements in a list.
7273
def truncated(array, limit=2):
7374
contents = ', '.join(array[:limit])
7475
more = '' if len(array) <= limit else ', ...'
7576
return u'[{0}{1}]'.format(contents, more)
7677

7778

79+
# Returns the name of a set property in an object, or else "unknown".
7880
def getOneOf(obj):
7981
for key in obj:
8082
return key
8183
return 'unknown'
8284

8385

86+
# Returns a time associated with an activity.
8487
def getTimeInfo(activity):
8588
if 'timestamp' in activity:
8689
return activity['timestamp']
@@ -89,10 +92,12 @@ def getTimeInfo(activity):
8992
return 'unknown'
9093

9194

95+
# Returns the type of action.
9296
def getActionInfo(actionDetail):
9397
return getOneOf(actionDetail)
9498

9599

100+
# Returns user information, or the type of user if not a known user.
96101
def getUserInfo(user):
97102
if 'knownUser' in user:
98103
knownUser = user['knownUser']
@@ -101,12 +106,14 @@ def getUserInfo(user):
101106
return getOneOf(user)
102107

103108

109+
# Returns actor information, or the type of actor if not a user.
104110
def getActorInfo(actor):
105111
if 'user' in actor:
106112
return getUserInfo(actor['user'])
107113
return getOneOf(actor)
108114

109115

116+
# Returns the type of a target and an associated title.
110117
def getTargetInfo(target):
111118
if 'driveItem' in target:
112119
title = target['driveItem'].get('title', 'unknown')

0 commit comments

Comments
 (0)