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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/docs_server_utils.py
diff --git a/chrome/common/extensions/docs/server2/docs_server_utils.py b/chrome/common/extensions/docs/server2/docs_server_utils.py
index 72ab3214e0e28fe4adc412f7d3b8d9022cc31725..524137ad9c924d05c17f041372d40bed27066d3c 100644
--- a/chrome/common/extensions/docs/server2/docs_server_utils.py
+++ b/chrome/common/extensions/docs/server2/docs_server_utils.py
@@ -2,21 +2,28 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+from base64 import b64encode
+from hashlib import sha1
import os
def FormatKey(key):
- """Normalize a key by making sure it has a .html extension, and convert any
+ '''Normalize a key by making sure it has a .html extension, and convert any
'.'s to '_'s.
- """
+ '''
if key.endswith('.html'):
key = key[:-len('.html')]
safe_key = key.replace('.', '_')
return '%s.html' % safe_key
def SanitizeAPIName(name):
- """Sanitizes API filenames that are in subdirectories.
- """
+ '''Sanitizes API filenames that are in subdirectories.
+ '''
filename = os.path.splitext(name)[0].replace(os.sep, '_')
if 'experimental' in filename:
filename = 'experimental_' + filename.replace('experimental_', '')
return filename
+
+def StringIdentity(string):
+ '''Creates a small hash of a string.
+ '''
+ return b64encode(sha1(string).digest())[:8]

Powered by Google App Engine
This is Rietveld 408576698