INNER CODE UNIT · Python

fixcase

ixray-team/ixray-1.6-stcop · util/includes_case_fix.py:6

def fixcase(path):
  (dirname, filename) = os.path.split(path)
  if dirname and filename:
    try:
        fixed_filename = [f for f in os.listdir(dirname) if f.lower() == filename.lower()][0]
        return os.path.join(fixcase(dirname), fixed_filename)
    except:
        print("ERROR ", path, dirname, filename)
  else:
    return filename or dirname
  
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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…