]> git.mxchange.org Git - friendica.git/blob - util/updatetpl.py
ping: docu fix
[friendica.git] / util / updatetpl.py
1 #!/usr/bin/python
2 #
3 # Script to update Smarty template files from all internal templates
4 # Copyright 2013 Zach Prezkuta
5 # Licensed under GPL v3
6
7
8 import os
9 import sys, getopt
10 import subprocess
11
12
13 def help(pname):
14         print "\nUsage:"
15         print "\t" + pname + " -h\n\n\t\t\tShow this help screen\n"
16         print "\t" + pname + " -p directory\n\n\t\t\tConvert all .tpl files in top-level\n\t\t\tFriendica directory to Smarty templates\n"
17         print "\t" + pname + "\n\n\t\t\tInteractive mode\n"
18
19
20
21 #
22 # Main script
23 #
24
25 path = ''
26
27 try:
28         opts, args = getopt.getopt(sys.argv[1:], "hp:")
29         for opt, arg in opts:
30                 if opt == '-h':
31                         help(sys.argv[0])
32                         sys.exit()
33                 elif opt == '-p':
34                         path = arg
35 except getopt.GetoptError:
36         help(sys.argv[0])
37         sys.exit(2)
38
39 if path == '':
40         path = raw_input('Path to top-level Friendica directory: ')
41
42 if path[-1:] != '/':
43         path = path + '/'
44
45 tplpaths = ['view/']
46 names = os.listdir(path + 'view/')
47 for name in names:
48         if os.path.isdir(path + 'view/' + name):
49                 if name != 'smarty3' and name != 'theme':
50                         tplpaths.append('view/' + name + '/')
51
52 names = os.listdir(path + 'view/theme/')
53 for name in names:
54         if os.path.isdir(path + 'view/theme/' + name):
55                 tplpaths.append('view/theme/' + name + '/')
56
57 fnull = open(os.devnull, "w")
58
59 for tplpath in tplpaths:
60         print "Converting " + path + tplpath
61         subprocess.call(['python', path + 'util/friendica-to-smarty-tpl.py', '-p', path + tplpath], stdout = fnull)
62
63 fnull.close()
64