Merge 2.6.3
authorClaudio Luck <claudio.luck@pep.foundation>
Thu, 19 Mar 2020 16:45:02 +0100
changeset 62 00a196f8d14a
parent 61 482106d33bf6
child 65 d659b8c2ed22
Merge 2.6.3
.hgignore
MANIFEST.in
Makefile
setup.cfg
setup.py
yml2/yml2c.py
yml2/yml2proc.py
yml2c
yml2proc
--- a/.hgignore	Thu Mar 19 14:54:23 2020 +0100
+++ b/.hgignore	Thu Mar 19 16:45:02 2020 +0100
@@ -1,5 +1,7 @@
 syntax: glob
 *.pyc
 *.html
-YML2.egg-info
-dist
+dist/
+build/
+*.egg-info/
+.git/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MANIFEST.in	Thu Mar 19 16:45:02 2020 +0100
@@ -0,0 +1,19 @@
+# Files to include in the source package - for the case
+# the project directory is are not in a VCS.
+include yml2c
+include yml2proc
+include yml2/*.ysl2
+include yml2/*.yml2
+
+include Makefile
+include *.yhtml2
+include format.css
+include COPYING.txt
+include README.rst
+include README.md
+
+include samples/*
+include vim/syntax/*
+
+exclude .hgtags
+exclude .hgignore
--- a/Makefile	Thu Mar 19 14:54:23 2020 +0100
+++ b/Makefile	Thu Mar 19 16:45:02 2020 +0100
@@ -1,21 +1,21 @@
+YML_PATH  =
+DEBVER   := 1
 PYTHON   := python3
-YML_PATH  =
-YML2C     = yml2c
-DEBVER   := 1
 PKGVER    = $(shell $(PYTHON) setup.py -V)
 TWINE    := $(PYTHON) -m twine
+YML2C     = $(PYTHON) yml2c
 
 all: homepage
 
 homepage: index.html features.html yslt.html toolchain.html programming.html hello.html
 
-update: homepage format.css gpl-2.0.txt
-	rsync -avC *.html *.yml2 format.css *.yhtml2 gpl-2.0.txt samples dragon:fdik.org/yml2/
+update: homepage format.css COPYING.txt
+	rsync -avC *.html *.yml2 format.css *.yhtml2 COPYING.txt samples dragon:fdik.org/yml2/
 
 update-all: update yml2c yml2.py pyPEG.py backend.py yml2proc
 	if test -z $(VERSION) ; then echo VERSION not set ; exit 1 ; fi
-	rsync -avC *.py yml2c Makefile yml2proc xml2yml.ysl2 standardlib.ysl2 samples dragon:fdik.org/yml2/
-	ssh dragon bash -c "cd ; cd fdik.org/; tar cvjf yml-$(VERSION).tar.bz2 yml2/{*.py,*.yml2,*.yhtml2,format.css,gpl-2.0.txt,yml2c,Makefile,yml2proc,xml2yml.ysl2,standardlib.ysl2,samples} ; rm yml2.tar.bz2 ; ln -s yml-$(VERSION).tar.bz2 yml2.tar.bz2"
+	rsync -avC *.py yml2 yml2c Makefile yml2proc xml2yml.ysl2 standardlib.ysl2 samples dragon:fdik.org/yml2/
+	ssh dragon bash -c "cd ; cd fdik.org/; tar cvjf yml-$(VERSION).tar.bz2 yml2/{*.py,*.yml2,*.yhtml2,format.css,COPYING.txt,yml2,yml2c,Makefile,yml2proc,xml2yml.ysl2,standardlib.ysl2,samples} ; rm yml2.tar.bz2 ; ln -s yml-$(VERSION).tar.bz2 yml2.tar.bz2"
 
 %.html: %.en.yhtml2 heading.en.yhtml2 homepage.en.yhtml2
 	$(YML2C) $< -o $@
@@ -32,15 +32,18 @@
 	mv -f deb_dist/python-yml2_$(PKGVER)-$(DEBVER)_all.deb .
 
 clean:
-	rm -f *.html *.pyc *.pyo
+	rm -f *.html *.pyc *.pyo */*.pyc */*.pyo
+	rm -rf *.egg-info
 	rm -f YML2_$(PKGVER).orig.tar.gz
 	rm -f python-yml2_$(PKGVER)-$(DEBVER)_all.deb
 
-.PHONY: dist
+.PHONY: dist dist/YML2-$(PKGVER).tar.gz
 dist: dist/YML2-$(PKGVER).tar.gz
 	$(TWINE) check $<
 
 dist/YML2-$(PKGVER).tar.gz:
 	$(PYTHON) setup.py sdist
-	ls -lh dist/YML2-$(PKGVER).tar.gz
 
+install:
+	pip install .
+
--- a/setup.cfg	Thu Mar 19 14:54:23 2020 +0100
+++ b/setup.cfg	Thu Mar 19 16:45:02 2020 +0100
@@ -1,2 +1,22 @@
+[sdist]
+formats=gztar
+
 [metadata]
-description-file = README.md
+name         = yml2
+version      = 2.6.4
+author	     = Volker Birk
+author_email = vb@pep-project.org
+url	     = https://pep.foundation/dev/repos/yml2/
+license	     = GPL-2.0
+license_file = COPYING.txt
+description-file = README.rst
+
+[options]
+packages = yml2
+scripts =
+    yml2c
+    yml2proc
+include_package_data = True
+zip_safe = False
+install_requires = lxml
+
--- a/setup.py	Thu Mar 19 14:54:23 2020 +0100
+++ b/setup.py	Thu Mar 19 16:45:02 2020 +0100
@@ -1,33 +1,13 @@
 # -*- coding: utf-8 -*-
 
-import sys, os
-from setuptools import setup
+from setuptools import setup, find_packages
 
-DESC = "YML 2 compiler"
-SDISTVER = '2.6.2.3'
-
-with open('README.rst', 'r', encoding='utf-8') as fh:
-    long_desc = fh.read().strip()
-    long_description_content_type = 'text/markdown'
+with open('README.rst', 'r', encoding='utf-8') as f:
+    long_description = f.read()
 
 setup(
-    name='YML2',
-    version=SDISTVER,
-    description=DESC,
-    long_description=long_desc,
-    long_description_content_type=long_description_content_type,
-    author="Volker Birk",
-    author_email="vb@pep.foundation",
-    license="GPL-2.0",
-    url="https://pep.foundation/dev/repos/yml2",
-    download_url="https://software.pep.foundation/r/pypi/yml2/YML2-%s.tar.gz" % SDISTVER,
-    zip_safe=False,
-    packages=["yml2"],
-    install_requires=['lxml'],
-    package_data = {
-        '': ['COPYING.txt', '*.css', '*.yhtml2'],
-        'yml2': ['*.yml2', '*.ysl2'],
-    },
+    setup_requires = ["setuptools >= 30.3.0"],  # release 2016-12-06
+    long_description=long_description,
     entry_points = {
         'console_scripts': [
             'yml2c=yml2.yml2c:main',
--- a/yml2/yml2c.py	Thu Mar 19 14:54:23 2020 +0100
+++ b/yml2/yml2c.py	Thu Mar 19 16:45:02 2020 +0100
@@ -2,8 +2,8 @@
 # vim: set fileencoding=utf-8 :
 
 """\
-YML 2 compiler version 2.6.2
-Copyleft (c), 2009-2019, Volker Birk  http://fdik.org/yml/
+YML 2 compiler version 6.2
+Copyleft (c), 2009-2020, Volker Birk  http://fdik.org/yml/
 
 """
 
@@ -16,7 +16,9 @@
 
 from yml2.pyPEG import parse, u
 from yml2.yml2 import ymlCStyle, comment, oldSyntax
-from yml2 import backend
+import yml2.backend as backend
+
+YML_DEFAULT_PATH = [os.path.dirname(backend.__file__)]
 
 def printInfo(option, opt_str, value, parser):
     sys.stdout.write(__doc__)
@@ -62,7 +64,7 @@
         if options.includePathText:
             backend.includePath = options.includePathText.split(':')
 
-        dirs = os.environ.get('YML_PATH', '.').split(':')
+        dirs = os.environ.get('YML_PATH', '.').split(':') + YML_DEFAULT_PATH
         backend.includePath.extend(dirs)
 
         files = fileinput.input(args, mode="rU", openhook=fileinput.hook_encoded(options.encoding))
@@ -101,3 +103,4 @@
 
 if __name__ == "__main__":
     sys.exit(main())
+
--- a/yml2/yml2proc.py	Thu Mar 19 14:54:23 2020 +0100
+++ b/yml2/yml2proc.py	Thu Mar 19 16:45:02 2020 +0100
@@ -3,7 +3,7 @@
 
 """\
 YML/YSLT 2 processor version 6.2
-Copyleft (c), 2009-2019 Volker Birk  http://fdik.org/yml/
+Copyleft (c), 2009-2020 Volker Birk  http://fdik.org/yml/
 
 """
 
@@ -22,7 +22,9 @@
 
 from yml2.yml2 import ymlCStyle, comment, oldSyntax
 from yml2.pyPEG import parse, u
-from yml2 import backend
+import yml2.backend as backend
+
+YML_DEFAULT_PATH = [os.path.dirname(backend.__file__)]
 
 def printInfo(option, opt_str, value, parser):
     sys.stdout.write(__doc__)
@@ -78,49 +80,48 @@
             help="convert XML to normalized YML code")
     optParser.add_option("-V", "--version", action="callback", callback=printInfo, help="show version info and exit")
     (options, args) = optParser.parse_args()
-    
+
     if options.old_syntax:
         oldSyntax()
-    
+
     if options.trace:
         backend.enable_tracing = True
-    
+
     if options.emitlinenumbers:
         backend.emitlinenumbers = True
-    
+
     if options.includePathText:
         backend.includePath = options.includePathText.split(':')
-    
+
     backend.encoding = options.encoding
-    
-    dirs = os.environ.get('YML_PATH', '.').split(':')
+
+    dirs = os.environ.get('YML_PATH', '.').split(':') + YML_DEFAULT_PATH
     backend.includePath.extend(dirs)
-    
+
     if options.xml2yml:
         for directory in backend.includePath:
-            try:
-                name = directory + "/xml2yml.ysl2"
-                f = open(name, "r")
-                f.close()
+            name = os.path.join(directory, "xml2yml.ysl2")
+            if os.path.isfile(name):
+                options.yslt = name
+                options.xml = True
                 break
-            except:
-                pass
-    
-        options.yslt = name
-        options.xml = True
-    
+        else:
+            sys.stderr.write("Error: Stylesheet xml2yml.ysl2 required for --xml2yml not found\n")
+            sys.stderr.write("Please check your YML_PATH\n")
+            sys.exit(1)
+
     if  (options.xslt and options.yslt) or (options.xslt and options.xpath) or (options.yslt and options.xpath):
         sys.stderr.write("Cannot combine --xpath, --xslt and --yslt params\n")
         sys.exit(1)
-    
+
     try:
         ymlC = ymlCStyle()
-    
+
         rtext = ""
-    
+
         if not options.emptyinput:
             files = fileinput.input(args, mode="rU", openhook=fileinput.hook_encoded(options.encoding))
-    
+
             if options.xml:
                 rtext = ""
                 for line in files:
@@ -132,26 +133,26 @@
                     sys.exit(0)
                 else:
                     rtext = backend.finish(result)
-    
+
         if not rtext:
             rtext = "<empty/>"
-    
+
         def ymldebug(context, text):
             if options.trace:
                 sys.stderr.write("Debug: " + codecs.encode(u(text), options.encoding) + "\n")
             return ""
-    
+
         def ymlassert(context, value, msg):
             if options.trace:
                 if not value:
                     raise YMLAssert(msg)
             return ""
-    
+
         ymlns = etree.FunctionNamespace("http://fdik.org/yml")
         ymlns.prefix = "yml"
         ymlns['debug'] = ymldebug
         ymlns['assert'] = ymlassert
-    
+
         if options.xpath:
             tree = etree.fromstring(rtext)
             ltree = tree.xpath(codecs.decode(options.xpath, options.encoding))
@@ -161,10 +162,10 @@
                     rtext += etree.tostring(rtree, pretty_print=options.pretty, encoding=unicode)
             except:
                 rtext = ltree
-    
+
         elif options.yslt or options.xslt:
             params = {}
-    
+
             if options.yslt:
                 backend.clearAll()
                 yscript = fileinput.input(options.yslt, mode="rU", openhook=fileinput.hook_encoded(options.encoding))
@@ -175,9 +176,9 @@
                 ytext = ""
                 for line in yscript:
                     ytext += line
-    
+
             doc = etree.fromstring(rtext)
-    
+
             xsltree = etree.XML(ytext, base_url=os.path.abspath(yscript.filename()))
             transform = etree.XSLT(xsltree)
             
@@ -189,7 +190,7 @@
             if options.stringparams:
                 for key, value in eval(options.stringparams).iteritems():
                     params[key] = "'" + u(value) + "'"
-    
+
             rresult = transform(doc, **params)
             # lxml is somewhat buggy
             try:
@@ -198,10 +199,10 @@
                 rtext = etree.tostring(rresult, encoding=unicode)
                 if not rtext:
                     rtext = codecs.decode(str(rresult), "utf-8")
-    
+
         if options.normalization != "none":
             rtext = unicodedata.normalize(options.normalization, rtext)
-    
+
         if options.pretty:
             plaintext = etree.tostring(etree.fromstring(rtext), pretty_print=True, xml_declaration=True, encoding=options.encoding)
         else:
@@ -209,12 +210,12 @@
                 plaintext = codecs.encode(rtext, options.encoding)
             else:
                 plaintext = rtext
-    
+
         try:
             if plaintext[-1] == "\n":
                 plaintext = plaintext[:-1]
         except: pass
-    
+
         if options.outputFile and options.outputFile != "-":
             outfile = open(options.outputFile, "wb")
             outfile.write(plaintext)
@@ -223,7 +224,7 @@
             sys.stdout.buffer.write(plaintext)
             if not options.pretty:
                 print()
-    
+
     except KeyboardInterrupt:
         w("\n")
         sys.exit(1)
@@ -248,3 +249,4 @@
 
 if __name__ == "__main__":
     sys.exit(main())
+
--- a/yml2c	Thu Mar 19 14:54:23 2020 +0100
+++ b/yml2c	Thu Mar 19 16:45:02 2020 +0100
@@ -1,1 +1,10 @@
-yml2/yml2c.py
\ No newline at end of file
+#!/usr/bin/env python3
+import sys, os
+sys.path.insert(0, os.path.dirname(__file__))
+try:
+    from yml2 import yml2c
+except ImportError as e:
+    import pkg_resources
+    pkg_resources.require('YML2')
+    from yml2 import yml2c
+sys.exit(yml2c.main())
--- a/yml2proc	Thu Mar 19 14:54:23 2020 +0100
+++ b/yml2proc	Thu Mar 19 16:45:02 2020 +0100
@@ -1,1 +1,10 @@
-yml2/yml2proc.py
\ No newline at end of file
+#!/usr/bin/env python3
+import sys, os
+sys.path.insert(0, os.path.dirname(__file__))
+try:
+    from yml2 import yml2proc
+except ModuleNotFoundError:
+    import pkg_resources
+    pkg_resources.require('YML2')
+    from yml2 import yml2proc
+sys.exit(yml2proc.main())