From ca4248966c3d730add34789bd9f2661b15a7f3ab Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Tue, 2 Feb 2010 17:38:38 +0000 Subject: [PATCH] Add examples folder with mickey.svg git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1323 eee81c28-f429-11dd-99c0-75d572ba1ddd --- examples/mickey.svg | 141 +++++++++++++++++++++++++++++++++++++++++ extras/update-langs.py | 128 ++++++++++++++++++------------------- 2 files changed, 202 insertions(+), 67 deletions(-) create mode 100644 examples/mickey.svg diff --git a/examples/mickey.svg b/examples/mickey.svg new file mode 100644 index 00000000..72bcde50 --- /dev/null +++ b/examples/mickey.svg @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SVG-edit + SVG-edit + + \ No newline at end of file diff --git a/extras/update-langs.py b/extras/update-langs.py index b863c4d3..b92d6eb6 100755 --- a/extras/update-langs.py +++ b/extras/update-langs.py @@ -1,81 +1,75 @@ #!/usr/bin/env python -# -*- coding: utf-8 -*- +# -*- coding: iso-8859-15 -*- +""" +This is a helper script for the svg-edit project, useful for managing +all the language files -# This is a helper script for the svg-edit project, useful for managing -# all the language files -# -# Licensed under the Apache 2 License as is the rest of the project -# Requires Python 2.6 -# -# Copyright (c) 2010 Jeff Schiller +Licensed under the Apache 2 License as is the rest of the project +Requires Python 2.6 +Copyright (c) 2010 Jeff Schiller +""" import os -import sys -import re import json -from types import * +from types import DictType def updateMainMenu(j): - """ - Converts title into textContent for items in the main menu - """ - tools = ['tool_clear', 'tool_open', 'tool_save', 'tool_docprops'] - for row in j: - try: - id = row['id'] - if id in tools: - row[u'textContent'] = row.pop('title') - except KeyError: - pass + """ + Converts title into textContent for items in the main menu + """ + tools = ['tool_clear', 'tool_open', 'tool_save', 'tool_docprops'] + for row in j: + try: + ids = row['id'] + if ids in tools: + row[u'textContent'] = row.pop('title') + except KeyError: + pass def ourPrettyPrint(j): - """ - Outputs a string representation of the JSON object passed in - formatted properly for our lang.XX.js files. - """ - s = '[' + os.linesep - js_strings = None - j.sort() - for row in j: - try: - id = row['id'] - row_string = json.dumps(row, sort_keys=True, ensure_ascii=False) - s += row_string + ',' + os.linesep - except KeyError: - if type(row) is DictType: - js_strings = row - - s += json.dumps(js_strings, sort_keys=True, ensure_ascii=False, indent=1) + os.linesep - s += ']' - return s + """ + Outputs a string representation of the JSON object passed in + formatted properly for our lang.XX.js files. + """ + s = '[' + os.linesep + js_strings = None + j.sort() + for row in j: + try: + ids = row['id'] + row_string = json.dumps(row, sort_keys=True, ensure_ascii=False) + s += row_string + ',' + os.linesep + except KeyError: + if type(row) is DictType: + js_strings = row + + s += json.dumps(js_strings, sort_keys=True, ensure_ascii=False, indent=1) + os.linesep + s += ']' + return s def processFile(filename): - """ - Loads the given lang.XX.js file, processes it and saves it - back to the file system - """ - in_file = open('./editor/locale/'+filename, 'r') - in_string = in_file.read() - in_file.close() - - try: - j = json.loads(in_string) - - # process the JSON object here -# updateMainMenu(j) - - # now write it out back to the file - s = ourPrettyPrint(j).encode("UTF-8"); - out_file = open('./editor/locale/'+filename, 'w') - out_file.write( s ) - out_file.close() + """ + Loads the given lang.XX.js file, processes it and saves it + back to the file system + """ + in_string = open('./editor/locale/' + filename, 'r').read() - print "Updated " + filename - except ValueError: - print "ERROR! " + filename + " was not valid JSON, please fix it!" + try: + j = json.loads(in_string) + + # process the JSON object here + # updateMainMenu(j) + + # now write it out back to the file + s = ourPrettyPrint(j).encode("UTF-8") + open('./editor/locale/' + filename, 'w').write(s) + + print "Updated " + filename + except ValueError: + print "ERROR! " + filename + " was not valid JSON, please fix it!" if __name__ == '__main__': - # get list of all lang files and process them - for file in os.listdir('./editor/locale/'): - if file[:4] == "lang": - processFile(file) \ No newline at end of file + # get list of all lang files and process them + for file_name in os.listdir('./editor/locale/'): + if file_name[:4] == "lang": + processFile(file_name)