~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/fileservice/listing.py

  • Committer: mattgiuca
  • Date: 2008-01-11 04:57:19 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:179
fileservice: Added an extra field to the directory listing: mtime_nice - a
human-readable date (this used to be in "mtime"). mtime now prints
seconds-since-epoch. This is used for sorting by date.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
#   files.
67
67
#   * type: String. Guessed mime type of the file. Present for non-directory
68
68
#   files.
69
 
#   * mtime: String. Modification time of the file or directory. Always
 
69
#   * mtime: Number. Number of seconds elapsed since the epoch.
 
70
#   The epoch is not defined (this is an arbitrary number used for sorting
 
71
#   dates).
 
72
#   * mtime_nice: String. Modification time of the file or directory. Always
70
73
#   present unless svnstatus is "Missing". Human-friendly.
71
74
#
72
75
# Members are not guaranteed to be present - client code should always check
174
177
        # The subversion one includes "." while the OS one does not.
175
178
        # Add "." to the output, so the caller can see we are
176
179
        # unversioned.
 
180
        mtime = os.path.getmtime(path)
177
181
        listing["."] = {"isdir" : True,
178
 
            "mtime" : time.ctime(os.path.getmtime(path))}
 
182
            "mtime" : mtime, "mtime_nice" : time.ctime(mtime)}
179
183
 
180
184
    # Listing is a nested object inside the top-level JSON.
181
185
    listing = {"listing" : listing}
206
210
        if type is None:
207
211
            type = conf.mimetypes.default_mimetype
208
212
        d["type"] = type
209
 
    d["mtime"] = time.ctime(file_stat.st_mtime)
 
213
    d["mtime"] = file_stat.st_mtime
 
214
    d["mtime_nice"] = time.ctime(file_stat.st_mtime)
210
215
    return d
211
216
 
212
217
def PysvnStatus_to_fileinfo(path, status):
241
246
            if type is None:
242
247
                type = conf.mimetypes.default_mimetype
243
248
            d["type"] = type
244
 
        d["mtime"] = time.ctime(file_stat.st_mtime)
 
249
        d["mtime"] = file_stat.st_mtime
 
250
        d["mtime_nice"] = time.ctime(file_stat.st_mtime)
245
251
    except OSError:
246
252
        # Here if, eg, the file is missing.
247
253
        # Can't get any more information so just return d