1 #!/usr/bin/env python2.7
4 from __future__ import absolute_import, division
10 MAN_NAME_RE = re.compile(r'/man/(?:[^/]+/)?man([^/]+)/[^/]+.\1$')
12 SO_RE = re.compile(r'^\.so\s+(.*)$')
14 def process_file(name):
15 full_name = os.path.join(os.getcwd(), name)
16 m = MAN_NAME_RE.search(full_name)
20 dir_name = 'man' + category
21 with open(name, 'r') as f:
32 if link.startswith('/') or link.count('/') > 1:
34 if link.startswith(dir_name+'/'):
35 link = link[len(dir_name)+1:]
39 os.symlink(link, name)
40 print 'Converted {} into a symlink to {}'.format(name, link)
45 dashes = args.index('--')
50 compressor = args[:dashes]
51 all_files = args[dashes+1:]
53 for name in all_files:
54 if not process_file(name):
56 if not compressor or not files:
58 os.execvp(compressor[0], compressor + files)
61 if __name__ == '__main__':
62 sys.exit(main(sys.argv[1:]))