changeset 7977978e25be in tryton-tools:default
details: https://hg.tryton.org/tryton-tools?cmd=changeset;node=7977978e25be
description:
        Update release tools to Python 3
diffstat:

 increase_version |   7 ++++---
 to_release       |  15 ++++++++-------
 update_changelog |  10 ++++++----
 update_copyright |  13 +++++++------
 4 files changed, 25 insertions(+), 20 deletions(-)

diffs (143 lines):

diff -r eb2fc46a1f86 -r 7977978e25be increase_version
--- a/increase_version  Tue Jan 28 00:27:46 2020 +0100
+++ b/increase_version  Sun Feb 02 16:55:01 2020 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 Increase version number of current repository.
 Use -d for development release
@@ -7,8 +7,9 @@
 import os
 import sys
 
-version = subprocess.check_output('python setup.py -V', shell=True).strip()
-version_info = map(int, version.replace('dev0', '0').split('.'))
+version = subprocess.check_output(
+    'python setup.py -V', shell=True, encoding='utf-8').strip()
+version_info = list(map(int, version.replace('dev0', '0').split('.')))
 if (version_info[1] % 2
         or version_info[2] == 0 and '-d' in sys.argv):
     version_info[1] += 1
diff -r eb2fc46a1f86 -r 7977978e25be to_release
--- a/to_release        Tue Jan 28 00:27:46 2020 +0100
+++ b/to_release        Sun Feb 02 16:55:01 2020 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 Is listed repositories or current repository to release.
 """
@@ -19,10 +19,11 @@
         continue
     current_branch = subprocess.check_output('hg id -b --cwd "%s"' % directory,
         shell=True, universal_newlines=True).strip()
-    branches = subprocess.check_output('hg branches --cwd "%s"' % directory,
+    branches_out = subprocess.check_output(
+        'hg branches --cwd "%s"' % directory,
         shell=True, universal_newlines=True)
     branches = [(b.split()[0], b.split()[1].split(':')[0])
-        for b in branches.splitlines()]
+        for b in branches_out.splitlines()]
     for branch, tip in branches:
         if branch == 'default':
             continue
@@ -32,7 +33,7 @@
         tags = subprocess.check_output('hg tags --cwd "%s"|grep "^%s"'
             % (directory, branch), shell=True, universal_newlines=True)
         tag = tags.splitlines()[0].split()[0]
-        changes = subprocess.check_output(
+        changes_out = subprocess.check_output(
             'hg log -b "%(branch)s" --cwd "%(directory)s" '
             '-r%(tip)s:%(tag)s|grep "changeset: "|wc -l' % {
                 'branch': branch,
@@ -40,17 +41,17 @@
                 'tip': tip,
                 'tag': tag,
                 }, shell=True, universal_newlines=True)
-        changes = int(changes.strip())
+        changes = int(changes_out.strip())
         if int(tag.split('.')[-1]) == 0:
             # First release tag is not in the branch
             changes += 1
         commits = 0
         if branch < '3.2':
             # For earlier branches, the last tag could not be in the branch
-            commits = subprocess.check_output(
+            commits_out = subprocess.check_output(
                     'hg log -b "%s" --cwd "%s"|grep "changeset: "|wc -l'
                     % (branch, directory), shell=True, universal_newlines=True)
-            commits = int(commits.strip())
+            commits = int(commits_out.strip())
         if changes > 3 or (2 <= commits <= 3):
             if sys.argv[1:]:
                 print("%(directory)s %(branch)s: %(changes)d changes" % {
diff -r eb2fc46a1f86 -r 7977978e25be update_changelog
--- a/update_changelog  Tue Jan 28 00:27:46 2020 +0100
+++ b/update_changelog  Sun Feb 02 16:55:01 2020 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 Update CHANGELOG file for imminent release based on the setup.py version.
 It must be run from inside the repository in the same directory of the file.
@@ -9,11 +9,13 @@
 import json
 
 if os.path.exists('setup.py'):
-    version = subprocess.check_output('python setup.py -V', shell=True).strip()
+    version = subprocess.check_output(
+        'python setup.py -V', shell=True, encoding='utf-8').strip()
 else:
-    version = subprocess.check_output('npm version --json', shell=True)
+    version = subprocess.check_output(
+        'npm version --json', shell=True, encoding='utf-8')
     version = json.loads(version)['tryton-sao']
-version_info = map(int, version.split('.'))
+version_info = list(map(int, version.split('.')))
 if version_info[1] % 2:
     version_info[1] += 1
 version = '.'.join(map(str, version_info))
diff -r eb2fc46a1f86 -r 7977978e25be update_copyright
--- a/update_copyright  Tue Jan 28 00:27:46 2020 +0100
+++ b/update_copyright  Sun Feb 02 16:55:01 2020 +0100
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """
 Update COPYRIGHT file according to commits in the current year.
 It must be run from inside the repository in the same directory of the file.
@@ -18,9 +18,9 @@
 # Retrieve the names and companies from mercurial
 names = set()
 companies = set()
-date = date(datetime.utcnow().year, 1, 1)
-for line in subprocess.check_output('hg log -d ">%s"' % date,
-        shell=True, env=script_env).splitlines():
+start_date = date(datetime.utcnow().year, 1, 1)
+for line in subprocess.check_output('hg log -d ">%s"' % start_date,
+        shell=True, env=script_env, encoding='utf-8').splitlines():
     if not line.startswith('user:'):
         continue
     _, name = line.split(' ', 1)
@@ -39,10 +39,10 @@
         sub = re_years.sub
     else:
         year, = re_year.findall(line)
-        if int(year) == date.year:
+        if int(year) == start_date.year:
             return line
         sub = re_year.sub
-    return sub(r'\1-%s' % date.year, line)
+    return sub(r'\1-%s' % start_date.year, line)
 
 
 def upgrade(line):
@@ -61,6 +61,7 @@
         return increase_year(line)
     return line
 
+
 COPYRIGHT = 'COPYRIGHT'
 ABOUT = os.path.join('tryton', 'gui', 'window', 'about.py')
 for path in [COPYRIGHT, ABOUT]:

Reply via email to