Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: chrome/common/extensions/docs/server2/file_system.py

Issue 10830252: Extensions Docs Server: Uniform handling of file not found errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 6
7 class FileNotFoundError(Exception):
8 def __init__(self, filename):
9 Exception.__init__(self, filename)
10
7 def _ProcessFileData(data, path): 11 def _ProcessFileData(data, path):
8 if os.path.splitext(path)[-1] not in ['.js', '.html', '.json']: 12 if os.path.splitext(path)[-1] not in ['.js', '.html', '.json']:
9 return data 13 return data
10 try: 14 try:
11 return unicode(data, 'utf-8') 15 return unicode(data, 'utf-8')
12 except: 16 except:
13 return unicode(data, 'latin-1') 17 return unicode(data, 'latin-1')
14 18
15 class FileSystem(object): 19 class FileSystem(object):
16 """A FileSystem interface that can read files and directories. 20 """A FileSystem interface that can read files and directories.
(...skipping 18 matching lines...) Expand all
35 def ReadSingle(self, path): 39 def ReadSingle(self, path):
36 """Reads a single file from the FileSystem. 40 """Reads a single file from the FileSystem.
37 """ 41 """
38 return self.Read([path]).Get()[path] 42 return self.Read([path]).Get()[path]
39 43
40 def Stat(self, path): 44 def Stat(self, path):
41 """Gets the version number of |path| if it is a directory, or the parent 45 """Gets the version number of |path| if it is a directory, or the parent
42 directory if it is a file. 46 directory if it is a file.
43 """ 47 """
44 raise NotImplementedError() 48 raise NotImplementedError()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698