root/lamer/mod_svn.py

Revision 107, 1.6 kB (checked in by haypo, 1 year ago)
  • evolution: use Lamer.displayAccount() method
  • svn: remove useless port specification
  • gaim: rename it to pidgin
  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1 #!/usr/bin/python
2 import re
3 from lamer import Lamer
4
5 class Subversion(Lamer):
6     def __init__(self, verbose):
7         Lamer.__init__(self, "subversion", verbose)
8
9     def parse(self, filename):
10         infos = {}
11         next = None
12         skip = False
13         for line in open(filename):
14             if skip:
15                 skip = False
16                 continue
17             line = line.strip()
18             if line in ('username', 'password', 'svn:realmstring'):
19                 next = line
20                 skip = True
21             elif next:
22                 infos[next] = line
23                 next = None
24         try:
25             # Read server string
26             server = infos["svn:realmstring"]
27             if not server:
28                 return
29             server = re.sub("^<(.+)> .+$", r"\1", server)
30
31             # Remove useless port specification
32             match = re.match("(http://.+):80", server)
33             if match:
34                 server = match.group(1)
35             match = re.match("(https://.+):443", server)
36             if match:
37                 server = match.group(1)
38
39             # Create message
40             credentials = "--username=%s" % infos["username"]
41             if "password" in infos:
42                 credentials += " --password=%s" % infos["password"]
43             elif self.skip_no_password:
44                 return
45             self.write("svn co %s %s" % (server, credentials))
46         except KeyError:
47             return
48
49     def _extract(self):
50         for filename in self.glob("~/.subversion/auth/svn.simple/*"):
51             self.parse(filename)
52
53 def main():
54     Subversion(False).extract()
55
56 if __name__ == "__main__":
57     main()
Note: See TracBrowser for help on using the browser.