Commit 6c65ed39 authored by MEESSEN Christophe's avatar MEESSEN Christophe
Browse files

Fix code to get pylint 10/10

parent fb65b61f
......@@ -30,7 +30,7 @@ import os
import re
import sys
import tempfile
import urllib
#import urllib
from os.path import join as opj
......@@ -118,16 +118,16 @@ def build_pdf(doc):
# find the name of the tex file
os.chdir(latexdoc)
li = [el for el in os.listdir('.') if el.endswith('.tex')]
fn = (li[0] if len(li) == 1 else None)
filenames = [el for el in os.listdir('.') if el.endswith('.tex')]
filename = (filenames[0] if len(filenames) == 1 else None)
if not fn:
if not filename:
print "\n\tNo latex file !"
return
# process the latex file twice
call([PDFLATEX, fn])
call([PDFLATEX, fn])
call([PDFLATEX, filename])
call([PDFLATEX, filename])
# move the pdf file
os.chdir(cwd)
......@@ -136,8 +136,8 @@ def build_pdf(doc):
if not os.path.exists(pdfdir):
os.mkdir(pdfdir)
fin = fn.replace('.tex', '.pdf')
fout = "%s_%s.pdf" % (os.path.splitext(fn)[0], doc)
fin = filename.replace('.tex', '.pdf')
fout = "%s_%s.pdf" % (os.path.splitext(filename)[0], doc)
os.rename(opj(latexdoc, fin), opj(pdfdir, fout))
# remove the latex directory
......@@ -165,33 +165,34 @@ def change_log():
git("commit -m", msg)
def select_identifier(branchType):
def select_identifier(branch_type):
"""Select the identifier to close.
Args:
branchType (str): one of "feature", "hotfix", "release" or "bugfix"
Return (str): the selected identifier or an empty string if none is selected
branch_type (str): one of "feature", "hotfix", "release" or "bugfix"
Return (str): the selected identifier or an empty string if none is selected
"""
identifiers = get_identifiers(branchType)
identifiers = get_identifiers(branch_type)
if not identifiers:
print "Couldn't find any %s branch" % branchType
print "Couldn't find any %s branch" % branch_type
return ""
if len(identifiers) == 1:
rep = raw_input("Close %s '%s' [y/N]:" % [branchType, identifiers[0]])
rep = raw_input("Close %s '%s' [y/N]:" % (branch_type, identifiers[0]))
if rep == 'y':
identifier = identifiers[0]
else:
return ""
else:
print '%s identifiers:' % branchType
print '%s identifiers:' % branch_type
print ' ', '\n '.join(identifiers)
identifier = raw_input("Select the %s identifier:" % branchType)
identifier = raw_input("Select the %s identifier:" % branch_type)
if not identifier in identifiers:
return ""
return identifier
......@@ -204,7 +205,7 @@ def close_bugfix():
identifier = select_identifier("bugfix")
if not identifier:
sys.exit(0)
branch = "bugfix-%s" % identifier
git("checkout develop")
......@@ -224,7 +225,7 @@ def close_feature():
identifier = select_identifier("feature")
if not identifier:
sys.exit(0)
branch = "feature-%s" % identifier
git("checkout develop")
......@@ -240,12 +241,12 @@ def close_hotfix():
"""
print "Close the hotfix cycle..."
release = select_identifier("hotfix")
if not release:
sys.exit(0)
branch = "hotfix-%s" % identifier
branch = "hotfix-%s" % release
git("checkout master")
git("merge --no-ff", branch)
......@@ -274,8 +275,8 @@ def close_release():
release = select_identifier("release")
if not release:
sys.exit(0)
branch = "release-%s" % identifier
branch = "release-%s" % release
msg = "Release %s" % release
print msg
......@@ -328,10 +329,10 @@ def compile_js():
return
# clean previous version
for el in (JSLIBDEBUG, JSLIBMIN):
if os.path.exists(el):
os.remove(el)
print 'Remove old javascript library', el
for item in (JSLIBDEBUG, JSLIBMIN):
if os.path.exists(item):
os.remove(item)
print 'Remove old javascript library', item
# debug version of the javascript library
cwd = os.getcwd()
......@@ -360,26 +361,26 @@ def get_version():
"""Get the current version identifier.
"""
fi = tempfile.TemporaryFile()
git("describe --tags", stdout=fi)
fi.seek(0)
return fi.read()
fichier = tempfile.TemporaryFile()
git("describe --tags", stdout=fichier)
fichier.seek(0)
return fichier.read()
def get_identifiers(branchType):
def get_identifiers(branch_type):
"""Print out the list of identifiers for the branch type.
Args:
branchType (str): one of "feature", "hotfix", "release" or "bugfix"
"""
if not os.path.exists(GIT):
print '\n\tThe application git is missing !'
sys.exit(-1)
output = check_output([GIT, "branch", "--list", branchType+"-*"])
output = check_output([GIT, "branch", "--list", branch_type+"-*"])
output = output.rstrip().split("\n")
idx = len(branchType)+3
idx = len(branch_type)+3
return [branch[idx:] for branch in output]
......@@ -452,11 +453,11 @@ def set_version(version):
print "Update CHANGELOG with the release", version, "..."
# check tag in git
fi = tempfile.TemporaryFile()
git("tag", stdout=fi)
fichier = tempfile.TemporaryFile()
git("tag", stdout=fichier)
fi.seek(0)
if version in fi.read():
fichier.seek(0)
if version in fichier.read():
print "\n\tRelease %s already exit in git" % version
sys.exit(1)
......@@ -476,15 +477,15 @@ def set_version(version):
# update the version and edit the CHANGELOG
tpl = (match.group(1), version, NOW.strftime('%b %Y'), match.group(2))
txt = '%s\n%s (%s)\n%s' % tpl
fi = open(CHANGELOG, 'wb')
fi.write(txt)
fi.close()
fichier = open(CHANGELOG, 'wb')
fichier.write(txt)
fichier.close()
call(["vim", CHANGELOG])
# cleaning
fn = "%s~" % CHANGELOG
if os.path.exists(fn):
os.remove(fn)
filename = "%s~" % CHANGELOG
if os.path.exists(filename):
os.remove(filename)
def sphinx(*args, **kwargs):
......@@ -521,20 +522,20 @@ def start_bugfix():
"""
print "Start the bugfix cycle..."
issueNumber = raw_input("Enter the bugfix issue number [None]:")
if issueNumber and not issueNumber.isdigit():
issue_number = raw_input("Enter the bugfix issue number [None]:")
if issue_number and not issue_number.isdigit():
print "The issue number must be a number"
sys.exit(-1)
rep = raw_input("Enter the bugfix identifier:")
if not rep:
sys.exit(0)
if not issueNumber:
if not issue_number:
branch = "bugfix-%s" % rep
else
branch = "bugfix-%s-%s" % [issueNumber, rep]
else:
branch = "bugfix-%s-%s" % (issue_number, rep)
git("checkout -b", branch, "develop")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment