From e2a0fef600d797e7215c02b8bf22305e7a438c89 Mon Sep 17 00:00:00 2001 From: "techdragon.nguyen@gmail.com" Date: Mon, 7 May 2012 05:09:12 +0000 Subject: [PATCH] * updated release version to 0.18.6 * updated build tools to have core files zip naming scheme be based on version information contained in build.number.properties * added new python library to allow reading java property files, remember to add the library to your PYTHONPATH before executing the python script otherwise the script will fail. ` --- projects/mtg/Android/AndroidManifest.xml | 2 +- projects/mtg/bin/Res/createResourceZip.py | 17 +- projects/mtg/build.number.properties | 8 +- projects/mtg/build.xml | 4 + projects/mtg/include/Wagic_Version.h | 8 +- .../lib/pyjavaproperties-0.6/MANIFEST.in | 3 + .../build/lib/pyjavaproperties-0.6/PKG-INFO | 109 ++++++ .../build/lib/pyjavaproperties-0.6/README | 96 +++++ .../tools/build/lib/pyjavaproperties-0.6/TODO | 5 + .../pyjavaproperties.egg-info/PKG-INFO | 109 ++++++ .../pyjavaproperties.egg-info/SOURCES.txt | 11 + .../dependency_links.txt | 1 + .../pyjavaproperties.egg-info/top_level.txt | 2 + .../pyjavaproperties-0.6/pyjavaproperties.py | 331 ++++++++++++++++++ .../pyjavaproperties_test.py | 54 +++ .../build/lib/pyjavaproperties-0.6/setup.cfg | 5 + .../build/lib/pyjavaproperties-0.6/setup.py | 35 ++ .../testdata/complex.properties | 46 +++ 18 files changed, 838 insertions(+), 8 deletions(-) create mode 100755 projects/mtg/tools/build/lib/pyjavaproperties-0.6/MANIFEST.in create mode 100755 projects/mtg/tools/build/lib/pyjavaproperties-0.6/PKG-INFO create mode 100755 projects/mtg/tools/build/lib/pyjavaproperties-0.6/README create mode 100755 projects/mtg/tools/build/lib/pyjavaproperties-0.6/TODO create mode 100644 projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/PKG-INFO create mode 100644 projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/SOURCES.txt create mode 100644 projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/dependency_links.txt create mode 100644 projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/top_level.txt create mode 100755 projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.py create mode 100755 projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties_test.py create mode 100755 projects/mtg/tools/build/lib/pyjavaproperties-0.6/setup.cfg create mode 100755 projects/mtg/tools/build/lib/pyjavaproperties-0.6/setup.py create mode 100644 projects/mtg/tools/build/lib/pyjavaproperties-0.6/testdata/complex.properties diff --git a/projects/mtg/Android/AndroidManifest.xml b/projects/mtg/Android/AndroidManifest.xml index 36fe0f16a..28a47b5a3 100644 --- a/projects/mtg/Android/AndroidManifest.xml +++ b/projects/mtg/Android/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/projects/mtg/bin/Res/createResourceZip.py b/projects/mtg/bin/Res/createResourceZip.py index 952760402..3699b882b 100644 --- a/projects/mtg/bin/Res/createResourceZip.py +++ b/projects/mtg/bin/Res/createResourceZip.py @@ -1,6 +1,7 @@ import sys import os import zipfile +from pyjavaproperties import Properties from optparse import OptionParser def createResZipFile(filename): @@ -25,15 +26,27 @@ def createResZipFile(filename): utilities.addFolderToZip(zip_file, 'ai') zip_file.close() +def getFilename(): + p = Properties(); + p.load(open('../../build.number.properties')); + minor = p['build.minor']; + major = p['build.major']; + point = p['build.point']; + filename = 'core_' + major + minor + point + return filename + + + def createStandardResFile(): - filename = 'core_0184.zip' + print "Creating Standard Resource File" + filename = getFilename() + '.zip' createResZipFile( filename ) print >> sys.stderr, 'Created Resource Package for Standard Distribution: {0}'.format( filename) def createIosResFile(): print 'Preparing Resource Package for iOS' utilities = ZipUtilities() - filename = 'core_0184_iOS.zip' + filename = getFilename() + '_iOS.zip' #createResZipFile( filename ) zip_file = zipfile.ZipFile(filename, 'a', zipfile.ZIP_STORED) zip_file.write("../../iOS/Res/rules/modrules.xml", "rules/modrules.xml", zipfile.ZIP_STORED) diff --git a/projects/mtg/build.number.properties b/projects/mtg/build.number.properties index db5a30cb0..b63a4fe3d 100644 --- a/projects/mtg/build.number.properties +++ b/projects/mtg/build.number.properties @@ -1,3 +1,5 @@ -build.major = 0 -build.minor = 18 -build.point = 5 +#build.number.properties (normally this file is maintained by build.xml) +#Sun, 06 May 2012 11:56:35 -0700 +build.major=0 +build.minor=18 +build.point=6 diff --git a/projects/mtg/build.xml b/projects/mtg/build.xml index 24c0a41e0..2eb5982e5 100644 --- a/projects/mtg/build.xml +++ b/projects/mtg/build.xml @@ -61,6 +61,10 @@ /* This file was auto-generated by ant build script on ${TODAY} +To make changes please edit the ant build script, otherwise your changes will be lost + +Author: Michael Nguyen + */ #ifndef wagic_Wagic_Version_h diff --git a/projects/mtg/include/Wagic_Version.h b/projects/mtg/include/Wagic_Version.h index 6c2e7af14..962088de8 100644 --- a/projects/mtg/include/Wagic_Version.h +++ b/projects/mtg/include/Wagic_Version.h @@ -1,6 +1,10 @@ /* -This file was auto-generated by ant build script on Fri, 20-Apr-2012 00::54:16 +This file was auto-generated by ant build script on Sun, 06-May-2012 11::58:10 +To make changes please edit the ant build script, otherwise your changes will be lost + +Author: Michael Nguyen + */ #ifndef wagic_Wagic_Version_h @@ -9,7 +13,7 @@ This file was auto-generated by ant build script on Fri, 20-Apr-2012 00::54:16 /* Wagic versions */ #define WAGIC_VERSION_MAJOR 0 #define WAGIC_VERSION_MEDIUM 18 -#define WAGIC_VERSION_MINOR 5 +#define WAGIC_VERSION_MINOR 6 #define VERSION_DOT(a, b, c) a ##.## b ##.## c #define VERSION_WITHOUT_DOT(a, b, c) a ## b ## c diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/MANIFEST.in b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/MANIFEST.in new file mode 100755 index 000000000..b325d2285 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/MANIFEST.in @@ -0,0 +1,3 @@ +include TODO +include README +recursive-include testdata *.properties diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/PKG-INFO b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/PKG-INFO new file mode 100755 index 000000000..2691eb599 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/PKG-INFO @@ -0,0 +1,109 @@ +Metadata-Version: 1.0 +Name: pyjavaproperties +Version: 0.6 +Summary: Python replacement for java.util.Properties. +Home-page: http://pypi.python.org/pypi/pyjavaproperties +Author: Jesse Noller +Author-email: jnoller@gmail.com +License: PSF License +Description: ================ + pyjavaproperties + ================ + + * Project hosting: + + .. contents:: + + About + ------------------ + + This is a "fork" of the "python replacement for java.util.Properties" recipe + on ASPN: and uploaded by + Anand Balachandran Pillai. + + The project is maintained by Jesse Noller , Anand Pilla + . + + License + ------------------ + As with all ASPN recipes not otherwise licensed prior to July 15, 2008 on + aspn.activestate.com, the original recipe is under PSF License. For more + information, see the ASPN terms of service here: + + + + While the licensing under the PSF license is sub-optimal, it is what it is. See + for more information about the PSF + license. + + What this is + ------------------ + This module is designed to be a python equivalent to the `java.util.Properties `_ class. + Currently, the basic input/output methods are supported, and there are plans + to add the XML input/output methods found in J2SE 5.0. + + Fundamentally, this module is designed so that users can easily parse and + manipulate Java Properties files - that's it. There's a fair number of us + pythonistas who work in multi-language shops, and constantly writing your own + parsing mechanism is just painful. Not to mention Java guys are notoriously + unwilling to use anything which is cross-language for configuration, unless + it's XML, which is a form of self-punishment. :) + + Plans + ------------------ + Here is a rough plan of features: + + - Keep/maintain blank lines and comments found in the original file + - Make the module compatible with the new methods in J2SE 5.0 + - Switch to/add python property access rather than direct dictionary get/set + - Add unit tests + - Add unicode support + - When-Pigs-Fly: If running within Jython, switch to java.util.Properties + under the hood + - Coercion/conversion to python types for values + + Usage + ------------------ + This is the easy part:: + + from pyjavaproperties import Properties + p = Properties() + p.load(open('test2.properties')) + p.list() + print p + print p.items() + print p['name3'] + p['name3'] = 'changed = value' + print p['name3'] + p['new key'] = 'new value' + p.store(open('test2.properties','w')) + + See also the Properties.list() method, which will return an iterator over the + property keys + + Changes & News + -------------- + + 0.4: + - Patch from Pepper Lebeck-Jobe for handling ! style comments. + + 0.3: + - Keys that are added which were not part of the original file + are simply appended to the index. Shenanigans. + + 0.2: + - Added an internal list (self._keyorder) to keep an ordered index of keys + as they are encountered, so the file can we written-back out in the + same order. + + 0.1: + - Initial release/fork. + - Added setup/packaging and doc + - added in {foo} style references for previous properties, thanks to N B + on ASPN. +Platform: UNKNOWN +Classifier: Development Status :: 3 - Alpha +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Topic :: Software Development :: Libraries +Classifier: Topic :: Software Development :: Libraries :: Python Modules diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/README b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/README new file mode 100755 index 000000000..f69b1e507 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/README @@ -0,0 +1,96 @@ +================ +pyjavaproperties +================ + +* Project hosting: + +.. contents:: + +About +------------------ + +This is a "fork" of the "python replacement for java.util.Properties" recipe +on ASPN: and uploaded by +Anand Balachandran Pillai. + +The project is maintained by Jesse Noller , Anand Pilla +. + +License +------------------ +As with all ASPN recipes not otherwise licensed prior to July 15, 2008 on +aspn.activestate.com, the original recipe is under PSF License. For more +information, see the ASPN terms of service here: + + + +While the licensing under the PSF license is sub-optimal, it is what it is. See + for more information about the PSF +license. + +What this is +------------------ +This module is designed to be a python equivalent to the `java.util.Properties `_ class. +Currently, the basic input/output methods are supported, and there are plans +to add the XML input/output methods found in J2SE 5.0. + +Fundamentally, this module is designed so that users can easily parse and +manipulate Java Properties files - that's it. There's a fair number of us +pythonistas who work in multi-language shops, and constantly writing your own +parsing mechanism is just painful. Not to mention Java guys are notoriously +unwilling to use anything which is cross-language for configuration, unless +it's XML, which is a form of self-punishment. :) + +Plans +------------------ +Here is a rough plan of features: + +- Keep/maintain blank lines and comments found in the original file +- Make the module compatible with the new methods in J2SE 5.0 +- Switch to/add python property access rather than direct dictionary get/set +- Add unit tests +- Add unicode support +- When-Pigs-Fly: If running within Jython, switch to java.util.Properties + under the hood +- Coercion/conversion to python types for values + +Usage +------------------ +This is the easy part:: + + from pyjavaproperties import Properties + p = Properties() + p.load(open('test2.properties')) + p.list() + print p + print p.items() + print p['name3'] + p['name3'] = 'changed = value' + print p['name3'] + p['new key'] = 'new value' + p.store(open('test2.properties','w')) + +See also the Properties.list() method, which will return an iterator over the +property keys + +Changes & News +-------------- + +0.4: + - Patch from Pepper Lebeck-Jobe for handling ! style comments. + +0.3: + - Keys that are added which were not part of the original file + are simply appended to the index. Shenanigans. + +0.2: + - Added an internal list (self._keyorder) to keep an ordered index of keys + as they are encountered, so the file can we written-back out in the + same order. + +0.1: + - Initial release/fork. + - Added setup/packaging and doc + - added in {foo} style references for previous properties, thanks to N B + on ASPN. + diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/TODO b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/TODO new file mode 100755 index 000000000..3737bbfd5 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/TODO @@ -0,0 +1,5 @@ +* Add PEP 8 interface, python properties. +* Add in unit tests + - Have to find some really offensive .properties files +* Switch to returning Unicode values +* Possible coercion to python types (on ints/etc) diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/PKG-INFO b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/PKG-INFO new file mode 100644 index 000000000..2691eb599 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/PKG-INFO @@ -0,0 +1,109 @@ +Metadata-Version: 1.0 +Name: pyjavaproperties +Version: 0.6 +Summary: Python replacement for java.util.Properties. +Home-page: http://pypi.python.org/pypi/pyjavaproperties +Author: Jesse Noller +Author-email: jnoller@gmail.com +License: PSF License +Description: ================ + pyjavaproperties + ================ + + * Project hosting: + + .. contents:: + + About + ------------------ + + This is a "fork" of the "python replacement for java.util.Properties" recipe + on ASPN: and uploaded by + Anand Balachandran Pillai. + + The project is maintained by Jesse Noller , Anand Pilla + . + + License + ------------------ + As with all ASPN recipes not otherwise licensed prior to July 15, 2008 on + aspn.activestate.com, the original recipe is under PSF License. For more + information, see the ASPN terms of service here: + + + + While the licensing under the PSF license is sub-optimal, it is what it is. See + for more information about the PSF + license. + + What this is + ------------------ + This module is designed to be a python equivalent to the `java.util.Properties `_ class. + Currently, the basic input/output methods are supported, and there are plans + to add the XML input/output methods found in J2SE 5.0. + + Fundamentally, this module is designed so that users can easily parse and + manipulate Java Properties files - that's it. There's a fair number of us + pythonistas who work in multi-language shops, and constantly writing your own + parsing mechanism is just painful. Not to mention Java guys are notoriously + unwilling to use anything which is cross-language for configuration, unless + it's XML, which is a form of self-punishment. :) + + Plans + ------------------ + Here is a rough plan of features: + + - Keep/maintain blank lines and comments found in the original file + - Make the module compatible with the new methods in J2SE 5.0 + - Switch to/add python property access rather than direct dictionary get/set + - Add unit tests + - Add unicode support + - When-Pigs-Fly: If running within Jython, switch to java.util.Properties + under the hood + - Coercion/conversion to python types for values + + Usage + ------------------ + This is the easy part:: + + from pyjavaproperties import Properties + p = Properties() + p.load(open('test2.properties')) + p.list() + print p + print p.items() + print p['name3'] + p['name3'] = 'changed = value' + print p['name3'] + p['new key'] = 'new value' + p.store(open('test2.properties','w')) + + See also the Properties.list() method, which will return an iterator over the + property keys + + Changes & News + -------------- + + 0.4: + - Patch from Pepper Lebeck-Jobe for handling ! style comments. + + 0.3: + - Keys that are added which were not part of the original file + are simply appended to the index. Shenanigans. + + 0.2: + - Added an internal list (self._keyorder) to keep an ordered index of keys + as they are encountered, so the file can we written-back out in the + same order. + + 0.1: + - Initial release/fork. + - Added setup/packaging and doc + - added in {foo} style references for previous properties, thanks to N B + on ASPN. +Platform: UNKNOWN +Classifier: Development Status :: 3 - Alpha +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: Apache Software License +Classifier: Topic :: Software Development :: Libraries +Classifier: Topic :: Software Development :: Libraries :: Python Modules diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/SOURCES.txt b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/SOURCES.txt new file mode 100644 index 000000000..c09eed390 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/SOURCES.txt @@ -0,0 +1,11 @@ +MANIFEST.in +README +TODO +setup.py +./pyjavaproperties.py +./pyjavaproperties_test.py +pyjavaproperties.egg-info/PKG-INFO +pyjavaproperties.egg-info/SOURCES.txt +pyjavaproperties.egg-info/dependency_links.txt +pyjavaproperties.egg-info/top_level.txt +testdata/complex.properties \ No newline at end of file diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/dependency_links.txt b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/dependency_links.txt new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/dependency_links.txt @@ -0,0 +1 @@ + diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/top_level.txt b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/top_level.txt new file mode 100644 index 000000000..adb726e59 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.egg-info/top_level.txt @@ -0,0 +1,2 @@ + +pyjavaproperties diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.py b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.py new file mode 100755 index 000000000..f4f3fabb8 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties.py @@ -0,0 +1,331 @@ +#! /usr/bin/env python + +""" +A Python replacement for java.util.Properties class +This is modelled as closely as possible to the Java original. + +Created - Anand B Pillai +""" + +import sys,os +import re +import time + +class IllegalArgumentException(Exception): + + def __init__(self, lineno, msg): + self.lineno = lineno + self.msg = msg + + def __str__(self): + s='Exception at line number %d => %s' % (self.lineno, self.msg) + return s + +class Properties(object): + """ A Python replacement for java.util.Properties """ + + def __init__(self, props=None): + + # Note: We don't take a default properties object + # as argument yet + + # Dictionary of properties. + self._props = {} + # Dictionary of properties with 'pristine' keys + # This is used for dumping the properties to a file + # using the 'store' method + self._origprops = {} + self._keyorder = [] + # Dictionary mapping keys from property + # dictionary to pristine dictionary + self._keymap = {} + + self.othercharre = re.compile(r'(?',line + # Means we need to split by space. + first, last = m2.span() + sepidx = first + elif m: + # print 'Other match=>',line + # No matching wspace char found, need + # to split by either '=' or ':' + first, last = m.span() + sepidx = last - 1 + # print line[sepidx] + + + # If the last character is a backslash + # it has to be preceded by a space in which + # case the next line is read as part of the + # same property + while line[-1] == '\\': + # Read next line + nextline = i.next() + nextline = nextline.strip() + lineno += 1 + # This line will become part of the value + line = line[:-1] + nextline + + # Now split to key,value according to separation char + if sepidx != -1: + key, value = line[:sepidx], line[sepidx+1:] + else: + key,value = line,'' + self._keyorder.append(key) + self.processPair(key, value) + + def processPair(self, key, value): + """ Process a (key, value) pair """ + + oldkey = key + oldvalue = value + + # Create key intelligently + keyparts = self.bspacere.split(key) + # print keyparts + + strippable = False + lastpart = keyparts[-1] + + if lastpart.find('\\ ') != -1: + keyparts[-1] = lastpart.replace('\\','') + + # If no backspace is found at the end, but empty + # space is found, strip it + elif lastpart and lastpart[-1] == ' ': + strippable = True + + key = ''.join(keyparts) + if strippable: + key = key.strip() + oldkey = oldkey.strip() + + oldvalue = self.unescape(oldvalue) + value = self.unescape(value) + + # Patch from N B @ ActiveState + curlies = re.compile("{.+?}") + found = curlies.findall(value) + + for f in found: + srcKey = f[1:-1] + if self._props.has_key(srcKey): + value = value.replace(f, self._props[srcKey], 1) + + self._props[key] = value.strip() + + # Check if an entry exists in pristine keys + if self._keymap.has_key(key): + oldkey = self._keymap.get(key) + self._origprops[oldkey] = oldvalue.strip() + else: + self._origprops[oldkey] = oldvalue.strip() + # Store entry in keymap + self._keymap[key] = oldkey + + if key not in self._keyorder: + self._keyorder.append(key) + + def escape(self, value): + + # Java escapes the '=' and ':' in the value + # string with backslashes in the store method. + # So let us do the same. + newvalue = value.replace(':','\:') + newvalue = newvalue.replace('=','\=') + + return newvalue + + def unescape(self, value): + + # Reverse of escape + newvalue = value.replace('\:',':') + newvalue = newvalue.replace('\=','=') + + return newvalue + + def load(self, stream): + """ Load properties from an open file stream """ + + # For the time being only accept file input streams + if type(stream) is not file: + raise TypeError,'Argument should be a file object!' + # Check for the opened mode + if stream.mode != 'r': + raise ValueError,'Stream should be opened in read-only mode!' + + try: + lines = stream.readlines() + self.__parse(lines) + except IOError, e: + raise + + def getProperty(self, key): + """ Return a property for the given key """ + + return self._props.get(key,'') + + def setProperty(self, key, value): + """ Set the property for the given key """ + + if type(key) is str and type(value) is str: + self.processPair(key, value) + else: + raise TypeError,'both key and value should be strings!' + + def propertyNames(self): + """ Return an iterator over all the keys of the property + dictionary, i.e the names of the properties """ + + return self._props.keys() + + def list(self, out=sys.stdout): + """ Prints a listing of the properties to the + stream 'out' which defaults to the standard output """ + + out.write('-- listing properties --\n') + for key,value in self._props.items(): + out.write(''.join((key,'=',value,'\n'))) + + def store(self, out, header=""): + """ Write the properties list to the stream 'out' along + with the optional 'header' """ + + if out.mode[0] != 'w': + raise ValueError,'Steam should be opened in write mode!' + + try: + out.write(''.join(('#',header,'\n'))) + # Write timestamp + tstamp = time.strftime('%a %b %d %H:%M:%S %Z %Y', time.localtime()) + out.write(''.join(('#',tstamp,'\n'))) + # Write properties from the pristine dictionary + for prop in self._keyorder: + if prop in self._origprops: + val = self._origprops[prop] + out.write(''.join((prop,'=',self.escape(val),'\n'))) + + out.close() + except IOError, e: + raise + + def getPropertyDict(self): + return self._props + + def __getitem__(self, name): + """ To support direct dictionary like access """ + + return self.getProperty(name) + + def __setitem__(self, name, value): + """ To support direct dictionary like access """ + + self.setProperty(name, value) + + def __getattr__(self, name): + """ For attributes not found in self, redirect + to the properties dictionary """ + + try: + return self.__dict__[name] + except KeyError: + if hasattr(self._props,name): + return getattr(self._props, name) + +if __name__=="__main__": + p = Properties() + p.load(open('test2.properties')) + p.list() + print p + print p.items() + print p['name3'] + p['name3'] = 'changed = value' + print p['name3'] + p['new key'] = 'new value' + p.store(open('test2.properties','w')) diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties_test.py b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties_test.py new file mode 100755 index 000000000..a4960b0ae --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/pyjavaproperties_test.py @@ -0,0 +1,54 @@ +#! /usr/bin/env python + +"""Basic tests to ensure pyjavaproperties behaves like java.util.Properties. + +Created - Pepper Lebeck-Jobe (eljobe@gmail.com) +""" + +import os +import unittest + +from pyjavaproperties import Properties + + +class PyJavaPropertiesTest(unittest.TestCase): + """Tests pyjavaproperties complies to java.util.Properties contract.""" + + def setUp(self): + test_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'testdata') + self.properties_file = os.path.join(test_dir, 'complex.properties') + + def testParsePropertiesInput(self): + properties = Properties() + properties.load(open(self.properties_file)) + self.assertEquals(23, len(properties.items())) + self.assertEquals('Value00', properties['Key00']) + self.assertEquals('Value01', properties['Key01']) + self.assertEquals('Value02', properties['Key02']) + self.assertEquals('Value03', properties['Key03']) + self.assertEquals('Value04', properties['Key04']) + self.assertEquals('Value05a, Value05b, Value05c', properties['Key05']) + self.assertEquals('Value06a, Value06b, Value06c', properties['Key06']) + self.assertEquals('Value07b', properties['Key07']) + self.assertEquals( + 'Value08a, Value08b, Value08c, Value08d, Value08e, Value08f', + properties['Key08']) + self.assertEquals( + 'Value09a, Value09b, Value09c, Value09d, Value09e, Value09f', + properties['Key09']) + self.assertEquals('Value10', properties['Key10']) + self.assertEquals('', properties['Key11']) + self.assertEquals('Value12a, Value12b, Value12c', properties['Key12']) + self.assertEquals('Value13 With Spaces', properties['Key13']) + self.assertEquals('Value14 With Spaces', properties['Key14']) + self.assertEquals('Value15 With Spaces', properties['Key15']) + self.assertEquals('Value16', properties['Key16 With Spaces']) + self.assertEquals('Value17', properties['Key17 With Spaces']) + self.assertEquals('Value18 # Not a comment.', properties['Key18']) + self.assertEquals('Value19 ! Not a comment.', properties['Key19']) + self.assertEquals('Value20', properties['Key20=WithEquals']) + self.assertEquals('Value21', properties['Key21:WithColon']) + self.assertEquals('Value22', properties['Key22']) + +if __name__ == '__main__': + unittest.main() diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/setup.cfg b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/setup.cfg new file mode 100755 index 000000000..861a9f554 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/setup.cfg @@ -0,0 +1,5 @@ +[egg_info] +tag_build = +tag_date = 0 +tag_svn_revision = 0 + diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/setup.py b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/setup.py new file mode 100755 index 000000000..bcf470b35 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/setup.py @@ -0,0 +1,35 @@ +import os +import sys +try: + import ez_setup + ez_setup.use_setuptools() +except ImportError: + pass +from setuptools import setup + +# Use a cute trick to include the rest-style docs as the long_description +# therefore having it self-doc'ed and hosted on pypi +f = open(os.path.join(os.path.dirname(__file__), 'README')) +long_description = f.read().strip() +f.close() + +setup( + name='pyjavaproperties', + version='0.6', + author='Jesse Noller', + author_email = 'jnoller@gmail.com', + description = 'Python replacement for java.util.Properties.', + long_description = long_description, + url='http://pypi.python.org/pypi/pyjavaproperties', + license = 'PSF License', + classifiers=[ + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: Apache Software License', + 'Topic :: Software Development :: Libraries', + 'Topic :: Software Development :: Libraries :: Python Modules', + ], + py_modules=['pyjavaproperties'], + packages=[''], + package_dir={'': '.'}, + ) diff --git a/projects/mtg/tools/build/lib/pyjavaproperties-0.6/testdata/complex.properties b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/testdata/complex.properties new file mode 100644 index 000000000..9d65bbf66 --- /dev/null +++ b/projects/mtg/tools/build/lib/pyjavaproperties-0.6/testdata/complex.properties @@ -0,0 +1,46 @@ +# notKey00:notValue00 This is a comment and ignored. +! notKey01:notValue01 This is a comment and ignored. +# notKey02=notValue02 This is a comment and ignored. +! notKey03=notValue03 This is a comment and ignored. + +Key00:Value00 +Key01=Value01 + Key02:Value02 + Key03 : Value03 + Key04 = Value04 +Key05: Value05a, Value05b, Value05c +Key06 = Value06a, Value06b, Value06c +Key07 = Value07a +Key07 = Value07b + +Key08: Value08a, Value08b, \ + Value08c, Value08d, \ + Value08e, Value08f + +Key09 = Value09a, Value09b, \ + Value09c, Value09d, \ + Value09e, Value09f + +# notKey04=notValue04 This is a comment and ignored. + +Key10 Value10 + +! notKey05=notValue05 This is a comment and ignored. + +Key11 + +Key12 Value12a, Value12b, Value12c + +Key13:Value13 With Spaces +Key14=Value14 With Spaces +Key15 Value15 With Spaces +Key16\ With\ Spaces:Value16 +Key17\ With\ Spaces=Value17 + +Key18 = Value18 # Not a comment. +Key19 : Value19 ! Not a comment. + +Key20\=WithEquals = Value20 +Key21\:WithColon : Value21 + +Key22 Value22