1
- # Copyright 2018 Google LLC
1
+ # Copyright 2019 Google LLC
2
2
#
3
3
# Licensed under the Apache License, Version 2.0 (the "License");
4
4
# you may not use this file except in compliance with the License.
@@ -69,18 +69,21 @@ def main():
69
69
truncated (targets )))
70
70
71
71
72
+ # Returns a string representation of the first elements in a list.
72
73
def truncated (array , limit = 2 ):
73
74
contents = ', ' .join (array [:limit ])
74
75
more = '' if len (array ) <= limit else ', ...'
75
76
return u'[{0}{1}]' .format (contents , more )
76
77
77
78
79
+ # Returns the name of a set property in an object, or else "unknown".
78
80
def getOneOf (obj ):
79
81
for key in obj :
80
82
return key
81
83
return 'unknown'
82
84
83
85
86
+ # Returns a time associated with an activity.
84
87
def getTimeInfo (activity ):
85
88
if 'timestamp' in activity :
86
89
return activity ['timestamp' ]
@@ -89,10 +92,12 @@ def getTimeInfo(activity):
89
92
return 'unknown'
90
93
91
94
95
+ # Returns the type of action.
92
96
def getActionInfo (actionDetail ):
93
97
return getOneOf (actionDetail )
94
98
95
99
100
+ # Returns user information, or the type of user if not a known user.
96
101
def getUserInfo (user ):
97
102
if 'knownUser' in user :
98
103
knownUser = user ['knownUser' ]
@@ -101,12 +106,14 @@ def getUserInfo(user):
101
106
return getOneOf (user )
102
107
103
108
109
+ # Returns actor information, or the type of actor if not a user.
104
110
def getActorInfo (actor ):
105
111
if 'user' in actor :
106
112
return getUserInfo (actor ['user' ])
107
113
return getOneOf (actor )
108
114
109
115
116
+ # Returns the type of a target and an associated title.
110
117
def getTargetInfo (target ):
111
118
if 'driveItem' in target :
112
119
title = target ['driveItem' ].get ('title' , 'unknown' )
0 commit comments