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

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

Issue 15009006: Docserver: refactor Servlet, ObjectStore, and ServerInstance architecture to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cduvall, redirect fix Created 7 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 | 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 from base64 import b64encode
6 from hashlib import sha1
5 import os 7 import os
6 8
7 def FormatKey(key): 9 def FormatKey(key):
8 """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
9 '.'s to '_'s. 11 '.'s to '_'s.
10 """ 12 '''
11 if key.endswith('.html'): 13 if key.endswith('.html'):
12 key = key[:-len('.html')] 14 key = key[:-len('.html')]
13 safe_key = key.replace('.', '_') 15 safe_key = key.replace('.', '_')
14 return '%s.html' % safe_key 16 return '%s.html' % safe_key
15 17
16 def SanitizeAPIName(name): 18 def SanitizeAPIName(name):
17 """Sanitizes API filenames that are in subdirectories. 19 '''Sanitizes API filenames that are in subdirectories.
18 """ 20 '''
19 filename = os.path.splitext(name)[0].replace(os.sep, '_') 21 filename = os.path.splitext(name)[0].replace(os.sep, '_')
20 if 'experimental' in filename: 22 if 'experimental' in filename:
21 filename = 'experimental_' + filename.replace('experimental_', '') 23 filename = 'experimental_' + filename.replace('experimental_', '')
22 return filename 24 return filename
25
26 def StringIdentity(string):
27 '''Creates a small hash of a string.
28 '''
29 return b64encode(sha1(string).digest())[:8]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698