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

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

Issue 1151283007: Docserver overhaul: Gitiles away from me. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 from base64 import b64encode 5 from base64 import b64encode
6 from hashlib import sha1 6 from hashlib import sha1
7 import os 7 import os
8 8
9 def FormatKey(key): 9 def FormatKey(key):
10 '''Normalize a key by making sure it has a .html extension, and convert any 10 '''Normalize a key by making sure it has a .html extension, and convert any
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 def MarkFirstAndLast(dicts): 48 def MarkFirstAndLast(dicts):
49 '''Marks the first and last element in a list of dicts. 49 '''Marks the first and last element in a list of dicts.
50 ''' 50 '''
51 MarkFirst(dicts) 51 MarkFirst(dicts)
52 MarkLast(dicts) 52 MarkLast(dicts)
53 53
54 def ToUnicode(data): 54 def ToUnicode(data):
55 '''Returns the str |data| as a unicode object. It's expected to be utf8, but 55 '''Returns the str |data| as a unicode object. It's expected to be utf8, but
56 there are also latin-1 encodings in there for some reason. Fall back to that. 56 there are also latin-1 encodings in there for some reason. Fall back to that.
57
58 Returns None if given None.
57 ''' 59 '''
60 if data is None:
61 return None
Ken Rockot(use gerrit already) 2015/05/26 00:26:24 I was having a very bad time trying to track down
58 try: 62 try:
59 return unicode(data, 'utf-8') 63 return unicode(data, 'utf-8')
60 except: 64 except:
61 return unicode(data, 'latin-1') 65 return unicode(data, 'latin-1')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698