diff rhodecode/lib/__init__.py @ 1307:c1516b35f91d beta

pep8ify
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 03 May 2011 16:54:43 +0200
parents 166317d464f3
children 9dacacc5b7c2
line wrap: on
line diff
--- a/rhodecode/lib/__init__.py	Tue May 03 16:20:06 2011 +0200
+++ b/rhodecode/lib/__init__.py	Tue May 03 16:54:43 2011 +0200
@@ -24,7 +24,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
-
 def __get_lem():
     from pygments import lexers
     from string import lower
@@ -60,12 +59,13 @@
 # extensions will index it's content
 LANGUAGES_EXTENSIONS_MAP = __get_lem()
 
-#Additional mappings that are not present in the pygments lexers
+# Additional mappings that are not present in the pygments lexers
 # NOTE: that this will overide any mappings in LANGUAGES_EXTENSIONS_MAP
 ADDITIONAL_MAPPINGS = {'xaml': 'XAML'}
 
 LANGUAGES_EXTENSIONS_MAP.update(ADDITIONAL_MAPPINGS)
 
+
 def str2bool(_str):
     """
     returs True/False value from given string, it tries to translate the
@@ -82,6 +82,7 @@
     _str = str(_str).strip().lower()
     return _str in ('t', 'true', 'y', 'yes', 'on', '1')
 
+
 def convert_line_endings(temp, mode):
     from string import replace
     #modes:  0 - Unix, 1 - Mac, 2 - DOS
@@ -98,6 +99,15 @@
 
 
 def detect_mode(line, default):
+    """
+    Detects line break for given line, if line break couldn't be found
+    given default value is returned
+
+    :param line: str line
+    :param default: default
+    :rtype: int
+    :return: value of line end on of 0 - Unix, 1 - Mac, 2 - DOS
+    """
     if line.endswith('\r\n'):
         return 2
     elif line.endswith('\n'):
@@ -107,6 +117,7 @@
     else:
         return default
 
+
 def generate_api_key(username, salt=None):
     """
     Generates unique API key for given username,if salt is not given
@@ -151,7 +162,7 @@
     """
     Custom engine_from_config functions that makes sure we use NullPool for
     file based sqlite databases. This prevents errors on sqlite.
-    
+
     """
     from sqlalchemy import engine_from_config as efc
     from sqlalchemy.pool import NullPool
@@ -159,8 +170,6 @@
     url = configuration[prefix + 'url']
 
     if url.startswith('sqlite'):
-        kwargs.update({'poolclass':NullPool})
+        kwargs.update({'poolclass': NullPool})
 
     return efc(configuration, prefix, **kwargs)
-
-