Skip to content

Commit 1366b28

Browse files
ml-bnrdsoprea
authored andcommitted
Bugfix: last_modifying_user_name may be absent.
1 parent 56094ab commit 1366b28

File tree

1 file changed

+44
-44
lines changed

1 file changed

+44
-44
lines changed

gdrivefs/gdtool/normal_entry.py

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class NormalEntry(object):
2222
__directory_mimetype = Conf.get('directory_mimetype')
2323

2424
__properties_extra = [
25-
'is_directory',
26-
'is_visible',
27-
'parents',
25+
'is_directory',
26+
'is_visible',
27+
'parents',
2828
'download_types',
2929
'modified_date',
3030
'modified_date_epoch',
@@ -42,56 +42,56 @@ def __init__(self, gd_resource_type, raw_data):
4242
self.__cache_mimetypes = None
4343
self.__cache_dict = {}
4444

45-
# Return True if reading from this file should return info and deposit
46-
# the data elsewhere. This is predominantly determined by whether we
47-
# can get a file-size up-front, or we have to decide on a specific
45+
# Return True if reading from this file should return info and deposit
46+
# the data elsewhere. This is predominantly determined by whether we
47+
# can get a file-size up-front, or we have to decide on a specific
4848
# mime-type in order to do so.
4949

5050
requires_mimetype = u'fileSize' not in self.__raw_data and \
5151
raw_data[u'mimeType'] != self.__directory_mimetype
5252

5353
self.__info['requires_mimetype'] = \
5454
requires_mimetype
55-
55+
5656
self.__info['title'] = \
5757
raw_data[u'title']
58-
58+
5959
self.__info['mime_type'] = \
6060
raw_data[u'mimeType']
61-
61+
6262
self.__info['labels'] = \
6363
raw_data[u'labels']
64-
64+
6565
self.__info['id'] = \
6666
raw_data[u'id']
67-
67+
6868
self.__info['last_modifying_user_name'] = \
69-
raw_data[u'lastModifyingUserName']
70-
69+
raw_data.get(u'lastModifyingUserName')
70+
7171
self.__info['writers_can_share'] = \
7272
raw_data[u'writersCanShare']
7373

7474
self.__info['owner_names'] = \
7575
raw_data[u'ownerNames']
76-
76+
7777
self.__info['editable'] = \
7878
raw_data[u'editable']
79-
79+
8080
self.__info['user_permission'] = \
8181
raw_data[u'userPermission']
8282

8383
self.__info['link'] = \
8484
raw_data.get(u'embedLink')
85-
85+
8686
self.__info['file_size'] = \
8787
int(raw_data.get(u'fileSize', 0))
88-
88+
8989
self.__info['file_extension'] = \
9090
raw_data.get(u'fileExtension')
91-
91+
9292
self.__info['md5_checksum'] = \
9393
raw_data.get(u'md5Checksum')
94-
94+
9595
self.__info['image_media_metadata'] = \
9696
raw_data.get(u'imageMediaMetadata')
9797

@@ -113,8 +113,8 @@ def __getattr__(self, key):
113113
return self.__info[key]
114114

115115
def __str__(self):
116-
return ("<NORMAL ID= [%s] MIME= [%s] NAME= [%s] URIS= (%d)>" %
117-
(self.id, self.mime_type, self.title,
116+
return ("<NORMAL ID= [%s] MIME= [%s] NAME= [%s] URIS= (%d)>" %
117+
(self.id, self.mime_type, self.title,
118118
len(self.download_links)))
119119

120120
def __repr__(self):
@@ -125,33 +125,33 @@ def __update_display_name(self):
125125
self.__info['title_fs'] = utility.translate_filename_charset(self.__info['title'])
126126

127127
def temp_rename(self, new_filename):
128-
"""Set the name to something else, here, while we, most likely, wait
128+
"""Set the name to something else, here, while we, most likely, wait
129129
for the change at the server to propogate.
130130
"""
131-
131+
132132
self.__info['title'] = new_filename
133133
self.__update_display_name()
134134

135135
def normalize_download_mimetype(self, specific_mimetype=None):
136-
"""If a mimetype is given, return it if there is a download-URL
137-
available for it, or fail. Else, determine if a copy can downloaded
138-
with the default mime-type (application/octet-stream, or something
139-
similar), or return the only mime-type in the event that there's only
136+
"""If a mimetype is given, return it if there is a download-URL
137+
available for it, or fail. Else, determine if a copy can downloaded
138+
with the default mime-type (application/octet-stream, or something
139+
similar), or return the only mime-type in the event that there's only
140140
one download format.
141141
"""
142142

143143
if self.__cache_mimetypes is None:
144144
self.__cache_mimetypes = [[], None]
145-
145+
146146
if specific_mimetype is not None:
147147
if specific_mimetype not in self.__cache_mimetypes[0]:
148148
_logger.debug("Normalizing mime-type [%s] for download. "
149-
"Options: %s",
149+
"Options: %s",
150150
specific_mimetype, self.download_types)
151151

152152
if specific_mimetype not in self.download_links:
153153
raise ExportFormatError("Mime-type [%s] is not available for "
154-
"download. Options: %s" %
154+
"download. Options: %s" %
155155
(self.download_types))
156156

157157
self.__cache_mimetypes[0].append(specific_mimetype)
@@ -166,14 +166,14 @@ def normalize_download_mimetype(self, specific_mimetype=None):
166166
mimetype_candidate in self.download_links:
167167
mime_type = mimetype_candidate
168168

169-
# If there's only one download link, resort to using it (perhaps it was
169+
# If there's only one download link, resort to using it (perhaps it was
170170
# an uploaded file, assigned only one type).
171171
elif len(self.download_links) == 1:
172172
mime_type = self.download_links.keys()[0]
173173

174174
else:
175175
raise ExportFormatError("A correct mime-type needs to be "
176-
"specified. Options: %s" %
176+
"specified. Options: %s" %
177177
(self.download_types))
178178

179179
self.__cache_mimetypes[1] = mime_type
@@ -182,7 +182,7 @@ def normalize_download_mimetype(self, specific_mimetype=None):
182182

183183
def __convert(self, data):
184184
if isinstance(data, dict):
185-
list_ = [("K(%s)=V(%s)" % (self.__convert(key),
185+
list_ = [("K(%s)=V(%s)" % (self.__convert(key),
186186
self.__convert(value))) \
187187
for key, value \
188188
in data.iteritems()]
@@ -205,16 +205,16 @@ def __convert(self, data):
205205

206206
def get_data(self):
207207
original = {
208-
key.encode('utf8'): value
209-
for key, value
208+
key.encode('utf8'): value
209+
for key, value
210210
in self.__raw_data.iteritems()
211211
}
212212

213213
distilled = self.__info
214214

215215
extra = {
216216
key: getattr(self, key)
217-
for key
217+
for key
218218
in self.__properties_extra
219219
}
220220

@@ -229,13 +229,13 @@ def get_data(self):
229229
def xattr_data(self):
230230
if self.__cache_data is None:
231231
data_dict = self.get_data()
232-
232+
233233
attrs = {}
234234
for a_type, a_dict in data_dict.iteritems():
235235
for key, value in a_dict.iteritems():
236236
fqkey = ('user.%s.%s' % (a_type, key))
237237
attrs[fqkey] = self.__convert(value)
238-
238+
239239
self.__cache_data = attrs
240240

241241
return self.__cache_data
@@ -247,9 +247,9 @@ def is_directory(self):
247247

248248
@property
249249
def is_visible(self):
250-
if [ flag
251-
for flag, value
252-
in self.labels.items()
250+
if [ flag
251+
for flag, value
252+
in self.labels.items()
253253
if flag in Conf.get('hidden_flags_list_local') and value ]:
254254
return False
255255
else:
@@ -273,11 +273,11 @@ def modified_date(self):
273273

274274
@property
275275
def modified_date_epoch(self):
276-
# mktime() only works in terms of the local timezone, so compensate
276+
# mktime() only works in terms of the local timezone, so compensate
277277
# (this works with DST, too).
278278
return mktime(self.modified_date.timetuple()) - time.timezone
279-
280-
@property
279+
280+
@property
281281
def mtime_byme_date(self):
282282
if 'modified_byme_date' not in self.__cache_dict:
283283
self.__cache_dict['modified_byme_date'] = \

0 commit comments

Comments
 (0)