~freshapplepy/mct/main

« back to all changes in this revision

Viewing changes to generate_pot.py

  • Committer: Isaiah Heyer
  • Date: 2009-03-13 02:48:07 UTC
  • Revision ID: freshapplepy@gmail.com-20090313024807-0yhpdj4e61s6ib34
Reordered file structure, added setup.py.Added icon set and n    ew about dialog.Enabled constant removal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
 
145
145
 
146
146
def run():
147
 
    if len(sys.argv) != 4:
148
 
        print 'usage: %s <basefolder> <name> <version>' % sys.argv[0]
 
147
    if len(sys.argv) != 5:
 
148
        print 'usage: %s <basefolder> <name> <version> <outputfile>' % sys.argv[0]
149
149
        sys.exit()
150
 
    print PO_HEADER % {
 
150
    output = sys.argv[4]
 
151
    output = open(output,'w')
 
152
 
 
153
    print >> output, PO_HEADER % {
151
154
        'time':     datetime.now(),
152
155
        'filename': sys.argv[0],
153
156
        'name':     sys.argv[2],
154
157
        'version':  sys.argv[3]
155
158
    }
 
159
 
156
160
    basepath = sys.argv[1]
157
161
    for string, occurrences in scan_tree(basepath):
158
 
        print
159
 
        for path, lineno in occurrences:
160
 
            print '#. file %r, line %s' % (path, lineno or '?')
161
 
        print 'msgid %s' % quote(string)
162
 
        print 'msgstr ""'
 
162
        try:
 
163
            print >> output, 'msgid %s' % quote(string)
 
164
        except Exception,data:
 
165
            print data
 
166
        else:
 
167
            for path, lineno in occurrences:
 
168
                print >> output,'#. file %r, line %s' % (path, lineno or '?')
 
169
            print >> output, 'msgstr ""'
163
170
 
 
171
    output.close()
164
172
 
165
173
if __name__ == '__main__':
166
174
    run()