-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtakeover
executable file
·57 lines (45 loc) · 1.53 KB
/
takeover
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/python
#-*- coding: utf-8 -*-
import os
import sys
TEMPLATE = """sed -i "/<Packager>$/{
N
N
N
s/<Name>.*<\/Name>\\n/<Name>%s<\/Name>\\n/
s/<Email>.*<\/Email>\\n/<Email>%s<\/Email>\\n/
}" %s """
def get_and_save_user_info():
name = "PACKAGER_NAME"
email = "PACKAGER_EMAIL"
conf_file = os.path.expanduser("~/.packagerinfo")
if os.path.exists(conf_file):
# Read from it
name, email = open(conf_file, "r").read().strip().split(",")
else:
print "Please enter your full name as seen in pspec files"
name = raw_input("> ")
print "Please enter your e-mail as seen in pspec files"
email = raw_input("> ")
print "Saving packager info into %s" % conf_file
open(conf_file, "w").write("%s,%s" % (name, email))
return name, email
def takeover(path):
packager_name, packager_email = get_and_save_user_info()
if os.path.isdir(path):
path = os.path.join(path, 'pspec.xml')
if not os.path.exists(path):
print "Taking over %s failed, package not found !" % path
elif not os.system(TEMPLATE % (packager_name, packager_email, path)):
print "Taking over %s ... done" % path
if __name__=='__main__':
if len(sys.argv) == 1:
print "Usage: takeover PATH_TO_PSPEC_FILE_TO_TAKE | PATH_TO_PACKAGE_LIST"
sys.exit(1)
for arg in sys.argv[1:]:
if arg.endswith('.xml'):
takeover(arg)
else:
paths = open(arg).readlines()
for path in paths:
takeover(path.strip())