Commit f3188d86 authored by Tatuya Kamada's avatar Tatuya Kamada

- replace 4SuiteXML with lxml

- replace distutill with setuptool 
- append test-cases using docstring
- append buildout setting
- append interface
- eggify
parent 1ba251e9
This diff is collapsed.
This diff is collapsed.
##############################################################################
#
# Copyright (c) 2006 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Bootstrap a buildout-based project
Simply run this script in a directory containing a buildout.cfg.
The script accepts buildout command-line options, so you can
use the -c option to specify an alternate configuration file.
$Id: bootstrap.py 77225 2007-06-29 09:20:13Z dobe $
"""
import os, shutil, sys, tempfile, urllib2
tmpeggs = tempfile.mkdtemp()
try:
import pkg_resources
except ImportError:
ez = {}
exec urllib2.urlopen('http://peak.telecommunity.com/dist/ez_setup.py'
).read() in ez
ez['use_setuptools'](to_dir=tmpeggs, download_delay=0)
import pkg_resources
cmd = 'from setuptools.command.easy_install import main; main()'
if sys.platform == 'win32':
cmd = '"%s"' % cmd # work around spawn lamosity on windows
ws = pkg_resources.working_set
assert os.spawnle(
os.P_WAIT, sys.executable, sys.executable,
'-c', cmd, '-mqNxd', tmpeggs, 'zc.buildout',
dict(os.environ,
PYTHONPATH=
ws.find(pkg_resources.Requirement.parse('setuptools')).location
),
) == 0
ws.add_entry(tmpeggs)
ws.require('zc.buildout')
import zc.buildout.buildout
zc.buildout.buildout.main(sys.argv[1:] + ['bootstrap'])
shutil.rmtree(tmpeggs)
[buildout]
develop = .
parts = test
[test]
recipe = zc.recipe.testrunner
eggs = erp5diff
from zope.interface import Interface
class IERP5Diff(Interface):
"""
Make a difference between two XML documents using XUpdate.
Use some assumptions in ERP5's data representation.
The strategy is:
1. Find a matching element among elements of the other XML document at the same depth.
2. Use the first matching element, even if there can be other better elements.
3. Assume that two elements are matching, if the tag names are identical. If either of
them has an attribute 'id', the values of the attrib 'id' also must be identical.
4. Don't use xupdate:rename for elements. It should be quite rare to rename tag names
in ERP5, and it is too complicated to support this renaming.
5. Ignore some types of nodes, such as EntityReference and Comment, because they are not
used in ERP5 XML documents.
"""
def compare(self, old_xml, new_xml):
"""
Compare two given XML documents.
If an argument is a string, it is assumed to be a XML document itself.
Otherwise, it is assumed to be a file object which contains a XML document.
"""
def output(self, output_file=None):
"""
Output the result of parsing XML documents to 'output_file'.
If it is not specified, stdout is assumed.
"""
def outputString(self):
"""
Return the result as a string object.
"""
def main():
"""
The main routine of ERP5Diff.
"""
\ No newline at end of file
[egg_info]
tag_build =
tag_date = 0
tag_svn_revision = 0
#! /usr/bin/env python
from distutils.core import setup
from setuptools import setup, find_packages
setup(name="erp5diff",
version="0.1",
......@@ -9,7 +9,11 @@ setup(name="erp5diff",
author_email="yo@nexedi.com",
url="http://nexedi.com",
license="GPL",
packages=find_packages(),
py_modules=["ERP5Diff"],
scripts=["erp5diff"],
data_files=[('share/man/man1', ['erp5diff.1'])]
data_files=[('share/man/man1', ['erp5diff.1'])],
install_requires=[ 'zope.interface', 'lxml'],
include_package_data=True,
zip_safe=False,
)
from zope import interface
import zope.testing
import unittest
OPTIONFLAGS = (zope.testing.doctest.ELLIPSIS |
zope.testing.doctest.NORMALIZE_WHITESPACE)
def test_suite():
doctests = ('README',)
globs = dict(interface=interface)
return unittest.TestSuite((
zope.testing.doctest.DocFileSuite(doctest,
optionflags=OPTIONFLAGS,
globs=globs,
) for doctest in doctests
))
if __name__ == '__main__':
unittest.main(defaultTest='test_suite')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment