File: i18n_plugin_extractor.py

package info (click to toggle)
scribes 0.3.3.3-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 6,512 kB
  • ctags: 4,045
  • sloc: python: 24,125; sh: 3,358; xml: 2,224; makefile: 255
file content (61 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download
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
57
58
59
60
61
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright © 2007 Lateef Alabi-Oki
#
# This file is part of Scribes.
#
# Scribes is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Scribes is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Scribes; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
# USA

"""
This module generates a list of files that need internationalization
and writes the result to i18n_files.txt.

@author: Lateef Alabi-Oki
@organization: The Scribes Project
@copyright: Copyright © 2007 Lateef Alabi-Oki
@license: GNU GPLv2 or Later
@contact: mystilleef@gmail.com
"""

def main(argv):
	from operator import ne
	if ne(argv[0], "plugins"): raise RuntimeError
	files = __get_i18n_files(argv[0])
	__write_to_file(files)
	return

def __get_i18n_files(folder):
	from os import walk
	from operator import eq
	i18n_files = []
	for root, dirs, files in walk(folder):
		for filename in files:
			if filename.endswith("glade") or eq(filename, "i18n.py"):
				_file = root + "/" + filename + "\n"
				i18n_files.append(_file)
	return i18n_files

def __write_to_file(files):
	string = "".join(files)
	handle = open("i18n_plugin_files.txt", "w")
	handle.write(string)
	handle.close()
	return

if __name__ == "__main__":
	# Initialize the program.
	from sys import argv
	main(argv[1:])