ConfluenceConverter

tools/get_profiles.py

141:d54fd34e39c0
2015-01-10 Paul Boddie Added missing link label tag support.
     1 #!/usr/bin/env python     2      3 """     4 Fetching the profile of each user from a Confluence site in order to obtain     5 name and e-mail details.     6      7 User details are written to standard output in a tab-separated sequence using     8 the following format:     9     10 USERNAME FULLNAME EMAIL IMAGE-URL    11 """    12     13 from time import sleep    14 from os.path import split    15 import sys    16 import codecs    17     18 this_dir = split(sys.argv[0])[0]    19 sys.path.append(this_dir)    20     21 from get_profile import get_profile    22     23 def main():    24     progname = split(sys.argv[0])[-1]    25     26     try:    27         url = sys.argv[1]    28         delay = int((sys.argv[2:3] or ["1"])[0])    29     except (IndexError, ValueError):    30         print >>sys.stderr, "%s <wiki URL> [ <retrieval delay> ]" % progname    31         print >>sys.stderr    32         print >>sys.stderr, "Example: %s http://wiki.list.org/" % progname    33         sys.exit(1)    34     35     stdout = codecs.getwriter("utf-8")(sys.stdout)    36     line = sys.stdin.readline()    37     while line:    38         username = line.strip()    39         details = get_profile(url, username)    40         if details:    41             print >>stdout, "\t".join(details)    42     43         sleep(delay)    44         line = sys.stdin.readline()    45     46 if __name__ == "__main__":    47     main()    48     49 # vim: tabstop=4 expandtab shiftwidth=4