gensrc: handle argument count when printing usage
[freebsd-maintainer-scripts/.git] / ftabs
1 #!/usr/bin/env python
2
3 import os
4 import webbrowser
5 import sys
6
7 username = os.environ.get('USER') or 'sbz'
8 g_label = "freebsd/freebsd-{}".format(username)
9 g_link = "https://mail.google.com/mail/u/0/?tab=wm#label/{}".format(g_label)
10 out_link = "http://portscout.freebsd.org/{}@freebsd.org.html".format(username)
11 bts_args = "?email1={}%40FreeBSD.org&order=changeddate&resolution=---"
12 bts_args = bts_args.format(username)
13 bts_link = "https://bugs.freebsd.org/bugzilla/buglist.cgi{}"
14
15
16 class URL(object):
17     def __init__(self, **kwargs):
18         self.link = kwargs.get("link")
19         self.desc = kwargs.get("desc", "N/A")
20         self.abrv = kwargs.get("abrv", "N/A")
21
22     def link(self):
23         return self.link
24
25     def desc(self):
26         return self.desc
27
28     def abrv(self):
29         return self.abrv.upper()
30
31 URLS = [
32     URL(link="https://reviews.freebsd.org/", desc="code review", abrv="cr"),
33     URL(link=bts_link.format(bts_args), desc="bug tracking", abrv="bts"),
34     URL(link="https://github.com/freebsd/", desc="github", abrv="gh"),
35     URL(link="https://svnweb.freebsd.org/", desc="code browser", abrv="cb"),
36     URL(link=out_link, desc="portcout", abrv="pc"),
37     URL(link=g_link, desc="freebsd-{}".format(username), abrv="gmail"),
38     URL(link="https://wiki.freebsd.org", desc="wiki", abrv="wk"),
39     URL(link="http://beefy6.nyi.freebsd.org/", desc="builder status",
40         abrv="build"),
41     URL(link="https://secure.freshbsd.org/search?project=freebsd",
42         desc="commit stats", abrv="stats"),
43     URL(link="http://grok.dragonflybsd.org/source/xref/freebsd/",
44         desc="xref browser", abrv="xref"),
45 ]
46
47
48 def main():
49     rc = 1
50     browser = webbrowser.get()
51     for url in URLS:
52         ret = browser.open_new_tab(url.link)
53         if ret is False:  # cannot open the link, try next one
54             rc = 0
55             continue
56
57     return rc
58
59 if __name__ == "__main__":
60     sys.exit(main())