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.
7273def 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".
7880def getOneOf (obj ):
7981 for key in obj :
8082 return key
8183 return 'unknown'
8284
8385
86+ # Returns a time associated with an activity.
8487def 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.
9296def getActionInfo (actionDetail ):
9397 return getOneOf (actionDetail )
9498
9599
100+ # Returns user information, or the type of user if not a known user.
96101def 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.
104110def 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.
110117def getTargetInfo (target ):
111118 if 'driveItem' in target :
112119 title = target ['driveItem' ].get ('title' , 'unknown' )
0 commit comments