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

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

Issue 10804036: Extensions Docs Server: Internationalized samples (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Move logic into file_system 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
6
7 def _ProcessFileData(data, path):
8 if os.path.splitext(path)[-1] not in ['.js', '.html', '.json']:
9 return data
10 try:
11 return unicode(data, 'utf-8')
12 except:
13 return unicode(data, 'latin-1')
14
5 class FileSystem(object): 15 class FileSystem(object):
6 """A FileSystem interface that can read files and directories. 16 """A FileSystem interface that can read files and directories.
7 """ 17 """
8 class StatInfo(object): 18 class StatInfo(object):
9 """The result of calling Stat on a FileSystem. 19 """The result of calling Stat on a FileSystem.
10 """ 20 """
11 def __init__(self, version): 21 def __init__(self, version):
12 self.version = version 22 self.version = version
13 23
14 def Read(self, paths): 24 def Read(self, paths):
15 """Reads each file in paths and returns a dictionary mapping the path to the 25 """Reads each file in paths and returns a dictionary mapping the path to the
16 contents. If a path in paths ends with a '/', it is assumed to be a 26 contents. If a path in paths ends with a '/', it is assumed to be a
17 directory, and a list of files in the directory is mapped to the path. 27 directory, and a list of files in the directory is mapped to the path.
18 """ 28 """
19 raise NotImplementedError() 29 raise NotImplementedError()
20 30
21 def ReadSingle(self, path): 31 def ReadSingle(self, path):
22 """Reads a single file from the FileSystem. 32 """Reads a single file from the FileSystem.
23 """ 33 """
24 return self.Read([path]).Get()[path] 34 return self.Read([path]).Get()[path]
25 35
26 def Stat(self, path): 36 def Stat(self, path):
27 """Gets the version number of |path| if it is a directory, or the parent 37 """Gets the version number of |path| if it is a directory, or the parent
28 directory if it is a file. 38 directory if it is a file.
29 """ 39 """
30 raise NotImplementedError() 40 raise NotImplementedError()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/echo_handler.py ('k') | chrome/common/extensions/docs/server2/file_system_cache.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698