diff --git a/kallithea/bin/vcs_hooks.py b/kallithea/bin/vcs_hooks.py
--- a/kallithea/bin/vcs_hooks.py
+++ b/kallithea/bin/vcs_hooks.py
@@ -13,7 +13,7 @@
# along with this program. If not, see .
"""
kallithea.bin.vcs_hooks
-~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~~
Entry points for Kallithea hooking into Mercurial and Git.
diff --git a/kallithea/config/middleware/https_fixup.py b/kallithea/config/middleware/https_fixup.py
--- a/kallithea/config/middleware/https_fixup.py
+++ b/kallithea/config/middleware/https_fixup.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
"""
-kallithea.lib.middleware.https_fixup
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+kallithea.config.middleware.https_fixup
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
middleware to handle https correctly
diff --git a/kallithea/config/middleware/permanent_repo_url.py b/kallithea/config/middleware/permanent_repo_url.py
--- a/kallithea/config/middleware/permanent_repo_url.py
+++ b/kallithea/config/middleware/permanent_repo_url.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
"""
-kallithea.lib.middleware.permanent_repo_url
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+kallithea.config.middleware.permanent_repo_url
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
middleware to handle permanent repo URLs, replacing PATH_INFO '/_123/yada' with
'/name/of/repo/yada' after looking 123 up in the database.
diff --git a/kallithea/config/middleware/pygrack.py b/kallithea/config/middleware/pygrack.py
--- a/kallithea/config/middleware/pygrack.py
+++ b/kallithea/config/middleware/pygrack.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
"""
-kallithea.lib.middleware.pygrack
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+kallithea.config.middleware.pygrack
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Python implementation of git-http-backend's Smart HTTP protocol
diff --git a/kallithea/config/middleware/simplegit.py b/kallithea/config/middleware/simplegit.py
--- a/kallithea/config/middleware/simplegit.py
+++ b/kallithea/config/middleware/simplegit.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
"""
-kallithea.lib.middleware.simplegit
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+kallithea.config.middleware.simplegit
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SimpleGit middleware for handling Git protocol requests (push/clone etc.)
It's implemented with basic auth function
diff --git a/kallithea/config/middleware/simplehg.py b/kallithea/config/middleware/simplehg.py
--- a/kallithea/config/middleware/simplehg.py
+++ b/kallithea/config/middleware/simplehg.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
"""
-kallithea.lib.middleware.simplehg
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+kallithea.config.middleware.simplehg
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
SimpleHg middleware for handling Mercurial protocol requests (push/clone etc.).
It's implemented with basic auth function
diff --git a/kallithea/config/middleware/wrapper.py b/kallithea/config/middleware/wrapper.py
--- a/kallithea/config/middleware/wrapper.py
+++ b/kallithea/config/middleware/wrapper.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
"""
-kallithea.lib.middleware.wrapper
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+kallithea.config.middleware.wrapper
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Wrap app to measure request and response time ... all the way to the response
WSGI iterator has been closed.
diff --git a/kallithea/lib/conf.py b/kallithea/lib/conf.py
--- a/kallithea/lib/conf.py
+++ b/kallithea/lib/conf.py
@@ -13,7 +13,7 @@
# along with this program. If not, see .
"""
kallithea.lib.conf
-~~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~
Various config settings for Kallithea
diff --git a/kallithea/lib/webutils.py b/kallithea/lib/webutils.py
--- a/kallithea/lib/webutils.py
+++ b/kallithea/lib/webutils.py
@@ -13,7 +13,7 @@
# along with this program. If not, see .
"""
kallithea.lib.webutils
-~~~~~~~~~~~~~~~~~~~~
+~~~~~~~~~~~~~~~~~~~~~~
Helper functions that may rely on the current WSGI request, exposed in the TG2
thread-local "global" variables. It should have few dependencies so it can be
diff --git a/kallithea/model/userlog.py b/kallithea/model/userlog.py
--- a/kallithea/model/userlog.py
+++ b/kallithea/model/userlog.py
@@ -12,8 +12,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
"""
-kallithea.model.db
-~~~~~~~~~~~~~~~~~~
+kallithea.model.userlog
+~~~~~~~~~~~~~~~~~~~~~~~
Database Models for Kallithea
diff --git a/scripts/run-all-cleanup b/scripts/run-all-cleanup
--- a/scripts/run-all-cleanup
+++ b/scripts/run-all-cleanup
@@ -8,6 +8,7 @@ set -x
scripts/docs-headings.py
scripts/generate-ini.py
scripts/whitespacecleanup.sh
+hg files 'set:!binary()&grep("^#!.*python")' 'set:**.py' | xargs scripts/source_format.py
hg files 'set:!binary()&grep("^#!.*python")' 'set:**.py' | xargs scripts/pyflakes
echo "no blocking problems found by $0"
diff --git a/scripts/source_format.py b/scripts/source_format.py
new file mode 100755
--- /dev/null
+++ b/scripts/source_format.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+# hg files 'set:!binary()&grep("^#!.*python")' 'set:**.py' | xargs scripts/source_format.py
+
+import re
+import sys
+
+
+filenames = sys.argv[1:]
+
+for fn in filenames:
+ with open(fn) as f:
+ org_content = f.read()
+
+ mod_name = fn[:-3] if fn.endswith('.py') else fn
+ mod_name = mod_name[:-9] if mod_name.endswith('/__init__') else mod_name
+ mod_name = mod_name.replace('/', '.')
+ def f(m):
+ return '"""\n%s\n%s\n' % (mod_name, '~' * len(mod_name))
+ new_content = re.sub(r'^"""\n(kallithea\..*\n)(~+\n)?', f, org_content, count=1, flags=re.MULTILINE)
+
+ if new_content != org_content:
+ with open(fn, 'w') as f:
+ f.write(new_content)