Applied pylint on converter.py

This commit is contained in:
cylon 2016-09-25 12:16:58 +02:00
parent 57d45f6bad
commit e3fad2d08b

View File

@ -1,61 +1,62 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Entry point for project conversion
@file
"""
import os import os
import argparse import argparse
import cmake import cmake
import ewpproject import ewpproject
import uvprojxproject import uvprojxproject
def findFile (path,fileext): def find_file(path, fileext):
""" Find file with extension in path
f = '' @param path Root path of the project
@param fileext File extension to find
@return File name
"""
filename = ''
for root, dirs, files in os.walk(path): for root, dirs, files in os.walk(path):
for file in files: for file in files:
if file.endswith(fileext): if file.endswith(fileext):
f = os.path.join(root, file) file = os.path.join(root, filename)
return filename
return f
if __name__ == '__main__': if __name__ == '__main__':
""" Parses params and calls the right conversion"""
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("path", type=str, help="Root directory of project") parser.add_argument("path", type=str, help="Root directory of project")
parser.add_argument("--ewp",help="Search for *.EWP file in project structure",action='store_true') parser.add_argument("--ewp", help="Search for *.EWP file in project structure", action='store_true')
parser.add_argument("--uvprojx",help="Search for *.UPROJX file in project structure",action='store_true') parser.add_argument("--uvprojx", help="Search for *.UPROJX file in project structure", action='store_true')
args = parser.parse_args() args = parser.parse_args()
if (os.path.isdir (args.path)): if os.path.isdir(args.path):
if args.ewp: if args.ewp:
print ('Looking for *.ewp file in ' + args.path) print('Looking for *.ewp file in ' + args.path)
file = findFile(args.path,'.ewp') filename = find_file(args.path, '.ewp')
if (len(file)): if len(filename):
print ('Found project file: ' + file) print('Found project file: ' + filename)
project = ewpproject.EWPProject(args.path,file) project = ewpproject.EWPProject(args.path, filename)
project.parseProject() project.parseProject()
project.displaySummary() project.displaySummary()
cmakefile = cmake.CMake(project.getProject(), args.path)
cmakefile = cmake.CMake(project.getProject(),args.path)
cmakefile.populateCMake() cmakefile.populateCMake()
else: else:
print ('No project *.ewp file found') print('No project *.ewp file found')
elif args.uvprojx: elif args.uvprojx:
print ('Looking for *.uvprojx file in ' + args.path) print('Looking for *.uvprojx file in ' + args.path)
file = findFile(args.path,'.uvprojx') filename = find_file(args.path, '.uvprojx')
if (len(file)): if len(filename):
print ('Found project file: ' + file) print('Found project file: ' + filename)
project = uvprojxproject.UVPROJXProject(args.path,file) project = uvprojxproject.UVPROJXProject(args.path, filename)
project.parseProject() project.parseProject()
project.displaySummary() project.displaySummary()
cmakefile = cmake.CMake(project.getProject(),args.path) cmakefile = cmake.CMake(project.getProject(), args.path)
cmakefile.populateCMake() cmakefile.populateCMake()
else: else:
print ('No project *.uvprojx file found') print('No project *.uvprojx file found')
else: else:
print('Not a valid file path')
print ('Not a valid file path')