Author: justi9
Date: 2010-10-08 16:52:47 -0400 (Fri, 08 Oct 2010)
New Revision: 4383
Modified:
mgmt/trunk/cumin/python/cumin/messaging/binding.py
mgmt/trunk/wooly/python/wooly/__init__.py
mgmt/trunk/wooly/python/wooly/demo.py
mgmt/trunk/wooly/python/wooly/pages.py
mgmt/trunk/wooly/python/wooly/resources.py
mgmt/trunk/wooly/python/wooly/util.py
Log:
Move StringCatalog to wooly.util
Modified: mgmt/trunk/cumin/python/cumin/messaging/binding.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/messaging/binding.py 2010-10-08 20:20:00 UTC (rev 4382)
+++ mgmt/trunk/cumin/python/cumin/messaging/binding.py 2010-10-08 20:52:47 UTC (rev 4383)
@@ -3,7 +3,6 @@
from wooly import WidgetTemplate, Writer, Attribute, Parameter, Widget
from wooly.forms import FormInput, FormField, Form
from wooly.parameters import DictParameter
-from wooly.resources import StringCatalog
from cumin.formats import *
from cumin.objectselector import *
from cumin.sqladapter import *
Modified: mgmt/trunk/wooly/python/wooly/__init__.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/__init__.py 2010-10-08 20:20:00 UTC (rev 4382)
+++ mgmt/trunk/wooly/python/wooly/__init__.py 2010-10-08 20:52:47 UTC (rev 4383)
@@ -1,5 +1,5 @@
from profile import *
-from resources import ResourceFinder, StringCatalog
+from resources import ResourceFinder
from template import *
from util import *
Modified: mgmt/trunk/wooly/python/wooly/demo.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/demo.py 2010-10-08 20:20:00 UTC (rev 4382)
+++ mgmt/trunk/wooly/python/wooly/demo.py 2010-10-08 20:52:47 UTC (rev 4383)
@@ -1,6 +1,5 @@
from forms import *
from pages import HtmlPage
-from resources import StringCatalog
from server import WebServer
from util import *
from widgets import *
Modified: mgmt/trunk/wooly/python/wooly/pages.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/pages.py 2010-10-08 20:20:00 UTC (rev 4382)
+++ mgmt/trunk/wooly/python/wooly/pages.py 2010-10-08 20:52:47 UTC (rev 4383)
@@ -1,5 +1,4 @@
from parameters import ListParameter
-from resources import StringCatalog
from util import *
from widgets import ItemSet
from wooly import *
Modified: mgmt/trunk/wooly/python/wooly/resources.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/resources.py 2010-10-08 20:20:00 UTC (rev 4382)
+++ mgmt/trunk/wooly/python/wooly/resources.py 2010-10-08 20:52:47 UTC (rev 4383)
@@ -1,55 +1,6 @@
import os
import wooly
-class StringCatalog(object):
- def __init__(self, file):
- self.strings = None
- self.path = os.path.splitext(file)[0] + ".strings"
-
- def clear(self):
- self.strings = None
-
- def load(self):
- file = open(self.path)
- try:
- self.strings = parse_catalog_file(file)
- finally:
- file.close()
-
- def get(self, key):
- if not self.strings:
- self.load()
-
- return self.strings.get(key)
-
- def __repr__(self):
- return "%s('%s')" % (self.__class__.__name__, self.path)
-
-def parse_catalog_file(file):
- strings = dict()
- key = None
- writer = wooly.Writer()
-
- for line in file:
- line = line.rstrip()
-
- if line.startswith("[") and line.endswith("]"):
- if key:
- strings[key] = writer.to_string().strip()
-
- writer = wooly.Writer()
-
- key = line[1:-1]
-
- continue
-
- writer.write(line)
- writer.write("\r\n")
-
- strings[key] = writer.to_string().strip()
-
- return strings
-
class ResourceFinder(object):
def __init__(self):
self.dirs = list()
Modified: mgmt/trunk/wooly/python/wooly/util.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/util.py 2010-10-08 20:20:00 UTC (rev 4382)
+++ mgmt/trunk/wooly/python/wooly/util.py 2010-10-08 20:52:47 UTC (rev 4383)
@@ -25,20 +25,6 @@
return "%08x-%08x-%08x-%08x" % (bits0, bits1, bits2, bits3)
-class Writer(object):
- def __init__(self):
- self.writer = StringIO()
-
- def write(self, string):
- self.writer.write(string)
-
- def to_string(self):
- string = self.writer.getvalue()
-
- self.writer.close()
-
- return string
-
def escape_amp(string):
return str(string).replace("&", "&")
@@ -55,3 +41,67 @@
else:
t += i
return t
+
+class Writer(object):
+ def __init__(self):
+ self.writer = StringIO()
+
+ def write(self, string):
+ self.writer.write(string)
+
+ def to_string(self):
+ string = self.writer.getvalue()
+
+ self.writer.close()
+
+ return string
+
+class StringCatalog(object):
+ def __init__(self, file):
+ self.strings = None
+ self.path = os.path.splitext(file)[0] + ".strings"
+
+ def clear(self):
+ self.strings = None
+
+ def load(self):
+ file = open(self.path)
+ try:
+ self.strings = self.parse_catalog_file(file)
+ finally:
+ file.close()
+
+ def parse_catalog_file(self, file):
+ strings = dict()
+ key = None
+ writer = Writer()
+
+ for line in file:
+ line = line.rstrip()
+
+ if line.startswith("[") and line.endswith("]"):
+ if key:
+ strings[key] = writer.to_string().strip()
+
+ writer = Writer()
+
+ key = line[1:-1]
+
+ continue
+
+ writer.write(line)
+ writer.write("\r\n")
+
+ strings[key] = writer.to_string().strip()
+
+ return strings
+
+ def get(self, key):
+ if not self.strings:
+ self.load()
+
+ return self.strings.get(key)
+
+ def __repr__(self):
+ return "%s('%s')" % (self.__class__.__name__, self.path)
+
Show replies by date