SO_RE = re.compile(r'^\.so\s+(.*)$')
def process_file(name):
- m = MAN_NAME_RE.search(name)
+ full_name = os.path.abspath(name)
+ m = MAN_NAME_RE.search(full_name)
if not m:
return False
category = m.group(1)
s = f.read(MAX_LEN+1)
if len(s) > MAX_LEN:
return False
- s = s.strip()
- if '\n' in s:
- return False
- m = SO_RE.search(s)
+ lines = [line for line in s.rstrip().split('\n') if not line.startswith('.\\"')]
+ if len(lines) != 1:
+ return False
+ m = SO_RE.search(lines[0])
if not m:
return False
link = m.group(1)
return False
if link.startswith(dir_name+'/'):
link = link[len(dir_name)+1:]
- else:
+ elif '/' in link:
link = '../' + link
os.unlink(name)
os.symlink(link, name)
- print 'Converted {} into a symlink to {}'.format(name, link)
+ print 'Converted {} into a symlink to {}'.format(full_name, link)
return True
def main(args=[]):