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

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

Issue 12230015: Fix unicode rendering of IDL files in the extension/apps developer server. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/local_file_system.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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): 7 class FileNotFoundError(Exception):
8 def __init__(self, filename): 8 def __init__(self, filename):
9 Exception.__init__(self, filename) 9 Exception.__init__(self, filename)
10 10
11 class StatInfo(object): 11 class StatInfo(object):
12 """The result of calling Stat on a FileSystem. 12 """The result of calling Stat on a FileSystem.
13 """ 13 """
14 def __init__(self, version, child_versions=None): 14 def __init__(self, version, child_versions=None):
15 self.version = version 15 self.version = version
16 self.child_versions = child_versions 16 self.child_versions = child_versions
17 17
18 def _ProcessFileData(data, path): 18 def _ToUnicode(data):
19 if os.path.splitext(path)[-1] not in ['.js', '.html', '.json']:
not at google - send to devlin 2013/02/13 17:12:55 IIRC this check was so that we didn't try to unico
20 return data
21 try: 19 try:
22 return unicode(data, 'utf-8') 20 return unicode(data, 'utf-8')
23 except: 21 except:
24 return unicode(data, 'latin-1') 22 return unicode(data, 'latin-1')
25 23
26 class FileSystem(object): 24 class FileSystem(object):
27 """A FileSystem interface that can read files and directories. 25 """A FileSystem interface that can read files and directories.
28 """ 26 """
29 27
30 def Read(self, paths, binary=False): 28 def Read(self, paths, binary=False):
(...skipping 12 matching lines...) Expand all
43 """ 41 """
44 return self.Read([path]).Get()[path] 42 return self.Read([path]).Get()[path]
45 43
46 # TODO(cduvall): Allow Stat to take a list of paths like Read. 44 # TODO(cduvall): Allow Stat to take a list of paths like Read.
47 def Stat(self, path): 45 def Stat(self, path):
48 """Returns a |StatInfo| object containing the version of |path|. If |path| 46 """Returns a |StatInfo| object containing the version of |path|. If |path|
49 is a directory, |StatInfo| will have the versions of all the children of 47 is a directory, |StatInfo| will have the versions of all the children of
50 the directory in |StatInfo.child_versions|. 48 the directory in |StatInfo.child_versions|.
51 """ 49 """
52 raise NotImplementedError() 50 raise NotImplementedError()
OLDNEW
« no previous file with comments | « no previous file | chrome/common/extensions/docs/server2/local_file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698