Skip to content
Snippets Groups Projects
Commit 4cc195d9 authored by Pawel Szostek's avatar Pawel Szostek
Browse files

Recursive manifest search replaced with shallow search

parent 21987e70
No related merge requests found
......@@ -8,6 +8,11 @@ import msg as p
std_libs = ['ieee', 'altera_mf', 'cycloneiii', 'lpm', 'std', 'unisim']
def try_utf8(data):
try:
return data.decode('utf-8')
except UnicodeDecodeError:
return None
def search_for_use(file):
"""
......@@ -15,8 +20,12 @@ def search_for_use(file):
non-standard library a tuple (lib, file) is returned in a list.
"""
f = open(file, "r")
text = f.readlines()
data = f.read()
text = try_utf8(data)
if text is None:
return []
text = text.split("\n")
ret = []
use_pattern = re.compile("^[ \t]*use[ \t]+([^; ]+)[ \t]*;.*$")
lib_pattern = re.compile("([^.]+)\.([^.]+)\.all")
......@@ -41,7 +50,11 @@ def search_for_package(file):
from the file
"""
f = open(file, "r")
text = f.readlines()
data = f.read()
text = try_utf8(data)
if text is None:
return []
text = text.split("\n")
ret = []
package_pattern = re.compile("^[ \t]*package[ \t]+([^ \t]+)[ \t]+is[ \t]*$")
......
......@@ -138,25 +138,19 @@ def convert_xise(xise):
new_ise.append(line + "\n")
new_ise_file = open(xise + ".new", "w")
def search_for_manifest(search_path):
"""
Look for manifest in the given folder ans subfolders
Look for manifest in the given folder
"""
cmd = "find -H " + search_path + " -name manifest.py"
p.vprint(cmd)
files = os.popen(cmd).readlines()
if len(files) == 0:
p.vprint("No manifest found in: " + search_path)
return None
elif len(files) > 1:
p.echo("Too many manifests in" + search_path + ": " + str(files))
return files[0].strip()
p.echo("Found manifest: " + os.path.abspath(files[0]).strip())
return os.path.abspath(files[0].strip())
p.vprint("Looking for manifest in " + search_path)
for filename in os.listdir(search_path):
if filename == "manifest.py" and not os.path.isdir(filename):
p.echo("Found manifest: " + os.path.abspath(search_path+'/'+filename))
return os.path.abspath(search_path+'/'+filename)
# no manifest file found
return None
def check_address_length(module):
p = module.popen("uname -a")
p = p.readlines()
......
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