widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #08967
[Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
GunChleoc has proposed merging lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/pyformat_util/+merge/312427
Added script to run pyformat over the code base.
In the future, when merging branches into trunk, this could be run before the bzr commit.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website.
=== added directory 'utils'
=== added file 'utils/fix_formatting.py'
--- utils/fix_formatting.py 1970-01-01 00:00:00 +0000
+++ utils/fix_formatting.py 2016-12-04 06:57:43 +0000
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+
+"""This script runs pyformat over the code base.
+"""
+
+import argparse
+import os
+import re
+import sys
+from subprocess import call
+
+LEADING_TABS = re.compile(r'^\s*\t+\s*')
+PYTHON3 = sys.version_info >= (3, 0)
+SPACES_PER_TAB = 3
+
+
+def parse_args():
+ p = argparse.ArgumentParser(
+ description='Run pyformat over the code base.'
+ ' Recurses over all relevant files.')
+ return p.parse_args()
+
+
+def find_files(startpath, extensions):
+ for (dirpath, _, filenames) in os.walk(startpath):
+ for filename in filenames:
+ if os.path.splitext(filename)[-1].lower() in extensions:
+ yield os.path.join(dirpath, filename)
+
+
+def main():
+ parse_args()
+
+ if not os.path.isdir('pybb') or not os.path.isdir('utils'):
+ print('CWD is not the root of the repository.')
+ return 1
+
+ sys.stdout.write('\nFormatting Python code ')
+ for filename in find_files('.', ['.py']):
+ sys.stdout.write('.')
+ sys.stdout.flush()
+ call(['pyformat', '-i', filename])
+ print(' done.')
+
+ print 'Formatting finished.'
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
Follow ups
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: GunChleoc, 2016-12-14
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: kaputtnik, 2016-12-13
-
[Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: noreply, 2016-12-13
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: GunChleoc, 2016-12-12
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: SirVer, 2016-12-12
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: kaputtnik, 2016-12-10
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: GunChleoc, 2016-12-07
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: kaputtnik, 2016-12-06
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: GunChleoc, 2016-12-05
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: kaputtnik, 2016-12-05
-
Re: [Merge] lp:~widelands-dev/widelands-website/pyformat_util into lp:widelands-website
From: kaputtnik, 2016-12-05