INNER CODE UNIT · Python
find_in_paths
ixray-team/ixray-1.6-stcop · util/includes_case_fix.py:17
def find_in_paths(include, include_paths):
for include_path in include_paths:
full_path = os.path.abspath(os.path.join(include_path, include))
if os.path.exists(full_path):
fixed_case = fixcase(full_path)
return os.path.relpath(fixed_case, include_path).replace('\\','/')
return None
def fix_include_case(source_file, include_paths):
source_dir = os.path.dirname(source_file)
include_paths_with_local = include_paths + [source_dir]
e = chardet.detect(open(source_file, 'rb').read())['encoding']
with open(source_file, 'r', encoding=e) as f:
try:
lines = f.readlines()
except:
print("ERROR reading file ", source_file, e)