@@ -22,9 +22,9 @@ class NormalEntry(object):
22
22
__directory_mimetype = Conf .get ('directory_mimetype' )
23
23
24
24
__properties_extra = [
25
- 'is_directory' ,
26
- 'is_visible' ,
27
- 'parents' ,
25
+ 'is_directory' ,
26
+ 'is_visible' ,
27
+ 'parents' ,
28
28
'download_types' ,
29
29
'modified_date' ,
30
30
'modified_date_epoch' ,
@@ -42,56 +42,56 @@ def __init__(self, gd_resource_type, raw_data):
42
42
self .__cache_mimetypes = None
43
43
self .__cache_dict = {}
44
44
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
48
48
# mime-type in order to do so.
49
49
50
50
requires_mimetype = u'fileSize' not in self .__raw_data and \
51
51
raw_data [u'mimeType' ] != self .__directory_mimetype
52
52
53
53
self .__info ['requires_mimetype' ] = \
54
54
requires_mimetype
55
-
55
+
56
56
self .__info ['title' ] = \
57
57
raw_data [u'title' ]
58
-
58
+
59
59
self .__info ['mime_type' ] = \
60
60
raw_data [u'mimeType' ]
61
-
61
+
62
62
self .__info ['labels' ] = \
63
63
raw_data [u'labels' ]
64
-
64
+
65
65
self .__info ['id' ] = \
66
66
raw_data [u'id' ]
67
-
67
+
68
68
self .__info ['last_modifying_user_name' ] = \
69
- raw_data [ u'lastModifyingUserName' ]
70
-
69
+ raw_data . get ( u'lastModifyingUserName' )
70
+
71
71
self .__info ['writers_can_share' ] = \
72
72
raw_data [u'writersCanShare' ]
73
73
74
74
self .__info ['owner_names' ] = \
75
75
raw_data [u'ownerNames' ]
76
-
76
+
77
77
self .__info ['editable' ] = \
78
78
raw_data [u'editable' ]
79
-
79
+
80
80
self .__info ['user_permission' ] = \
81
81
raw_data [u'userPermission' ]
82
82
83
83
self .__info ['link' ] = \
84
84
raw_data .get (u'embedLink' )
85
-
85
+
86
86
self .__info ['file_size' ] = \
87
87
int (raw_data .get (u'fileSize' , 0 ))
88
-
88
+
89
89
self .__info ['file_extension' ] = \
90
90
raw_data .get (u'fileExtension' )
91
-
91
+
92
92
self .__info ['md5_checksum' ] = \
93
93
raw_data .get (u'md5Checksum' )
94
-
94
+
95
95
self .__info ['image_media_metadata' ] = \
96
96
raw_data .get (u'imageMediaMetadata' )
97
97
@@ -113,8 +113,8 @@ def __getattr__(self, key):
113
113
return self .__info [key ]
114
114
115
115
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 ,
118
118
len (self .download_links )))
119
119
120
120
def __repr__ (self ):
@@ -125,33 +125,33 @@ def __update_display_name(self):
125
125
self .__info ['title_fs' ] = utility .translate_filename_charset (self .__info ['title' ])
126
126
127
127
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
129
129
for the change at the server to propogate.
130
130
"""
131
-
131
+
132
132
self .__info ['title' ] = new_filename
133
133
self .__update_display_name ()
134
134
135
135
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
140
140
one download format.
141
141
"""
142
142
143
143
if self .__cache_mimetypes is None :
144
144
self .__cache_mimetypes = [[], None ]
145
-
145
+
146
146
if specific_mimetype is not None :
147
147
if specific_mimetype not in self .__cache_mimetypes [0 ]:
148
148
_logger .debug ("Normalizing mime-type [%s] for download. "
149
- "Options: %s" ,
149
+ "Options: %s" ,
150
150
specific_mimetype , self .download_types )
151
151
152
152
if specific_mimetype not in self .download_links :
153
153
raise ExportFormatError ("Mime-type [%s] is not available for "
154
- "download. Options: %s" %
154
+ "download. Options: %s" %
155
155
(self .download_types ))
156
156
157
157
self .__cache_mimetypes [0 ].append (specific_mimetype )
@@ -166,14 +166,14 @@ def normalize_download_mimetype(self, specific_mimetype=None):
166
166
mimetype_candidate in self .download_links :
167
167
mime_type = mimetype_candidate
168
168
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
170
170
# an uploaded file, assigned only one type).
171
171
elif len (self .download_links ) == 1 :
172
172
mime_type = self .download_links .keys ()[0 ]
173
173
174
174
else :
175
175
raise ExportFormatError ("A correct mime-type needs to be "
176
- "specified. Options: %s" %
176
+ "specified. Options: %s" %
177
177
(self .download_types ))
178
178
179
179
self .__cache_mimetypes [1 ] = mime_type
@@ -182,7 +182,7 @@ def normalize_download_mimetype(self, specific_mimetype=None):
182
182
183
183
def __convert (self , data ):
184
184
if isinstance (data , dict ):
185
- list_ = [("K(%s)=V(%s)" % (self .__convert (key ),
185
+ list_ = [("K(%s)=V(%s)" % (self .__convert (key ),
186
186
self .__convert (value ))) \
187
187
for key , value \
188
188
in data .iteritems ()]
@@ -205,16 +205,16 @@ def __convert(self, data):
205
205
206
206
def get_data (self ):
207
207
original = {
208
- key .encode ('utf8' ): value
209
- for key , value
208
+ key .encode ('utf8' ): value
209
+ for key , value
210
210
in self .__raw_data .iteritems ()
211
211
}
212
212
213
213
distilled = self .__info
214
214
215
215
extra = {
216
216
key : getattr (self , key )
217
- for key
217
+ for key
218
218
in self .__properties_extra
219
219
}
220
220
@@ -229,13 +229,13 @@ def get_data(self):
229
229
def xattr_data (self ):
230
230
if self .__cache_data is None :
231
231
data_dict = self .get_data ()
232
-
232
+
233
233
attrs = {}
234
234
for a_type , a_dict in data_dict .iteritems ():
235
235
for key , value in a_dict .iteritems ():
236
236
fqkey = ('user.%s.%s' % (a_type , key ))
237
237
attrs [fqkey ] = self .__convert (value )
238
-
238
+
239
239
self .__cache_data = attrs
240
240
241
241
return self .__cache_data
@@ -247,9 +247,9 @@ def is_directory(self):
247
247
248
248
@property
249
249
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 ()
253
253
if flag in Conf .get ('hidden_flags_list_local' ) and value ]:
254
254
return False
255
255
else :
@@ -273,11 +273,11 @@ def modified_date(self):
273
273
274
274
@property
275
275
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
277
277
# (this works with DST, too).
278
278
return mktime (self .modified_date .timetuple ()) - time .timezone
279
-
280
- @property
279
+
280
+ @property
281
281
def mtime_byme_date (self ):
282
282
if 'modified_byme_date' not in self .__cache_dict :
283
283
self .__cache_dict ['modified_byme_date' ] = \
0 commit comments