Explorar el Código

Fixed Python 3.4 compatibility

mikitex70 hace 8 años
padre
commit
7301d1f045

+ 2 - 0
.gitignore

@@ -1,5 +1,7 @@
 *.pyc
 *.log
 *~
+.directory
+.idea
 .project
 .pydevproject

+ 1 - 1
better_code_samples

@@ -1 +1 @@
-Subproject commit 8ae86dcddb4f65d0e6b5f1afe84b6afdb4297668
+Subproject commit 91717a204bbd0ae4a1af6fe25ac5dd783fb4a7db

+ 1 - 1
bootstrapify

@@ -1 +1 @@
-Subproject commit b3e3d9e669c44aff6b872c4d45448718b1f87e2c
+Subproject commit bc4e0a1bf274425a777f0b613c4199b2a5857ff8

+ 1 - 1
cjk-auto-spacing

@@ -1 +1 @@
-Subproject commit c56a09a823bc1d5ea97404bc33e09f37adb01df6
+Subproject commit 92346597b86f3ff85217871a42b404e30ec4f9ec

+ 1 - 1
pelican-gist

@@ -1 +1 @@
-Subproject commit d8205680a91dbb158de17f38a182693f5af7691c
+Subproject commit 4cce3dad9e7d03511bd04734def69f5fe2958ee5

+ 1 - 1
pelican-githubprojects

@@ -1 +1 @@
-Subproject commit c1590cb566e98a643b121c3571d0787a2dec2159
+Subproject commit f55b497dcc37c81791ef0e294a1b1c710a933ca6

+ 1 - 1
pelican-jinja2content

@@ -1 +1 @@
-Subproject commit f73ef9b1ef1ee1f56c80757b4190b53f8cd607d1
+Subproject commit 9adc69f786a673d37322235c35119f38feb153c4

+ 1 - 1
pelican-langcategory

@@ -1 +1 @@
-Subproject commit d05e7d6a8bdab9de8cf505615b82ad15866c56ab
+Subproject commit 94fc0bc2983e92d954708611b36448724bf71616

+ 1 - 1
pelican-page-hierarchy

@@ -1 +1 @@
-Subproject commit ad7c9879147bf82dc8c66e50ef464ecec4c8972c
+Subproject commit f11b533a50aa58800d1eade4aa6d3dfa17fd0f5c

+ 1 - 1
pelican_vimeo

@@ -1 +1 @@
-Subproject commit 1dd1a04768ff0d800c1f8edaa23ca100a5d76eab
+Subproject commit d18f1ddfe9fc76230409ed3eff1502f2fcd338c9

+ 1 - 1
pelican_youtube

@@ -1 +1 @@
-Subproject commit 0b72fdaf9dbbf2800bc0a463fbedd372b87808cd
+Subproject commit 045c43dd4deb56731366c13d54a41a5adf8fe66b

+ 1 - 1
pelicanfly

@@ -1 +1 @@
-Subproject commit fedfa1d40a20f6a41d419addd529b9b03591091e
+Subproject commit 265865f693092f6409f4e4ef451ff7543fa4e350

+ 1 - 1
pelicanthemes-generator

@@ -1 +1 @@
-Subproject commit 6d05b3a919dd9dcad6f472c51b210a6b9afdb46b
+Subproject commit 916f5a570fcd7c4042917642571f4fda6d42ee38

+ 1 - 1
pin_to_top

@@ -1 +1 @@
-Subproject commit fb34938931bb7c56af9fcd1043af5ac55e5d5c49
+Subproject commit 4c022ecbd958cbf5538e06d5bd233d048902dad4

+ 17 - 41
plantuml/Readme.rst

@@ -2,31 +2,23 @@
 PlantUML plugin for Pelican rst and md documents
 ================================================
 
-This plugin allows you to define UML diagrams directly into rst or md documents using the great
-PlantUML_ tool.
+This plugin allows you to define UML diagrams directly into rst or md documents using the great PlantUML_ tool.
 
-It gets the content of ``uml`` directive, passes it to the external
-program PlantUML_ and then links the generated image to the document.
+It gets the content of ``uml`` directive, passes it to the external program PlantUML_ and then links the generated image to the document.
 
 .. contents::
 
 Installation
 ============
 
-You need to install PlantUML_ (see the site for details) and Graphviz_ 2.26.3 or later.
-The plugin expects a program ``plantuml`` in the classpath. If not installed by your package
-manager, you can create a shell script and place it somewhere in the classpath. For example,
-save te following into ``/usr/local/bin/plantuml`` (supposing PlantUML_ installed into
-``/opt/plantuml``):
+You need to install PlantUML_ (see the site for details) and Graphviz_ 2.26.3 or later. The plugin expects a program ``plantuml`` in the classpath. If not installed by your package manager, you can create a shell script and place it somewhere in the classpath. For example, save te following into ``/usr/local/bin/plantuml`` (supposing PlantUML_ installed into ``/opt/plantuml``):
 
 .. code-block:: bash
 
     #!/bin/bash
     java -jar /opt/plantuml/plantuml.jar ${@}
 
-For Gentoo_ there is an ebuild at http://gpo.zugaina.org/dev-util/plantuml/RDep: you can download
-the ebuild and the ``files`` subfolder or you can add the ``zugaina`` repository with _layman
-(reccomended).
+For Gentoo_ there is an ebuild at http://gpo.zugaina.org/dev-util/plantuml/RDep: you can download the ebuild and the ``files`` subfolder or you can add the ``zugaina`` repository with _layman (reccomended).
 
 Usage
 =====
@@ -41,18 +33,11 @@ One loaded the plugin register also the Pyhton-Markdown_ extension.
 
 RST usage
 ---------
-Use the ``uml`` directive to start UML diagram description. It is not necessary to enclose
-diagram body between ``@startuml`` and ``@enduml`` directives: they are added automatically 
-before calling ``plantuml``.
+Use the ``uml`` directive to start UML diagram description. It is not necessary to enclose diagram body between ``@startuml`` and ``@enduml`` directives: they are added automatically  before calling ``plantuml``.
 
-In addition to ``class`` and
-``alt`` options common to all images, you can use the ``format`` option to select what kind
-of image must be produced. At the moment only ``png`` and ``svg`` are supported; the default
-is ``png``.
+In addition to ``class`` and ``alt`` options common to all images, you can use the ``format`` option to select what kind of image must be produced. At the moment only ``png`` and ``svg`` are supported; the default is ``png``.
 
-Please note that the ``format`` option in not recognized by the ``plantuml`` extension of
-``rst2pdf`` utility (call it with ``-e plantuml.py``) so if you use it you can get errors from
-that program.
+Please note that the ``format`` option in not recognized by the ``plantuml`` extension of ``rst2pdf`` utility (call it with ``-e plantuml.py``) so if you use it you can get errors from that program.
 
 MD usage
 --------
@@ -64,34 +49,24 @@ For use with the Pyhton-Markdown_ syntax, the UML block must be enclose with ``:
        PlantUML script
     ::end-uml::
 
-Please keep a blank line before ``::uml::`` and after ``::end-uml::`` to be sure that the UML code will be correctly
-recognized.
-See Examples_ for more details.
+Please keep a blank line before ``::uml::`` and after ``::end-uml::`` to be sure that the UML code will be correctly recognized. See Examples_ for more details.
 
-With MD syntax options must be specified in the same line as the opening ``:uml::``, with the
-order ``format``, ``classes`` anmd ``alt``. The general syntax for option is
+With MD syntax options must be specified in the same line as the opening ``:uml::``, with the order ``format``, ``classes`` anmd ``alt``. The general syntax for option is
 
 .. code-block:: text
 
     option="value"
 
-Option can be enclosed with single or double quotes, as you like.
-Options defaults are the same as for the rst plugin.
+Option can be enclosed with single or double quotes, as you like. Options defaults are the same as for the rst plugin.
 
 For pandoc_reader plugin users
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-The plugin ``pandoc_reader`` sends the Markdown body to the pandoc_ tool which has it's own Markdown parser, written
-in Haskell_ language: Python_ plugins manipulating Markdown posts (such this) are not used because the entire body
-id passed to pandoc_ without any iteraction by Pelican_.
+The plugin ``pandoc_reader`` sends the Markdown body to the pandoc_ tool which has it's own Markdown parser, written in Haskell_ language: Python_ plugins manipulating Markdown posts (such this) are not used because the entire body id passed to pandoc_ without any iteraction by Pelican_.
 
-For those who are using the ``pandoc_reader`` plugin and wants to include PlantUML_ diagrams, use the
-``pandoc-plantuml`` script (only *nix, sorry): it is a wrapper for filtering the code blocks parsed by pandoc_ before
-writing out the converted file.
-It is an adaption of the great work by Kurt Bonne for his
-`pandoc-plantuml-filter <https://github.com/kbonne/pandoc-plantuml-filter.git>`_.
+For those who are using the ``pandoc_reader`` plugin and wants to include PlantUML_ diagrams, use the ``pandoc-plantuml`` script (only *nix, sorry): it is a wrapper for filtering the code blocks parsed by pandoc_ before
+writing out the converted file. It is an adaption of the great work by Kurt Bonne for his `pandoc-plantuml-filter <https://github.com/kbonne/pandoc-plantuml-filter.git>`_.
 
-To use it, copy the ``pandoc-plantuml`` file in a subdirectory of your pelican project (for example `pandoc_extensions`)
-and make sure it is executable (``chmod +x pandoc-plantuml``).
+To use it, copy the ``pandoc-plantuml`` file in a subdirectory of your pelican project (for example `pandoc_extensions`) and make sure it is executable (``chmod +x pandoc-plantuml``).
 
 In the ``pelicanconf.py`` configure the needed plugins:
 
@@ -116,10 +91,11 @@ In Markdown posts use the following syntax to include PlantUML_ diagrams:
 
 Rendered images will bu put in the output/images folder.
 
+**NOTE:** ``pandoc-plantuml`` is broken from pandoc 1.16 cause an API change in pandoc ``Image`` function. I'm working on a fix but in the meanwhile use a version of pandoc prior to ``1.16`` .
+
 Debugging
 ---------
-The plugin can produce debugging informations to help to locate errors. To enable debugging
-execute ``pelican`` in debug mode:
+The plugin can produce debugging informations to help to locate errors. To enable debugging execute ``pelican`` in debug mode:
 
  .. code-block:: console
 

+ 1 - 1
plantuml/__init__.py

@@ -1 +1 @@
-from plantuml_rst import *
+from .plantuml_rst import *

+ 4 - 4
plantuml/generateUmlDiagram.py

@@ -9,9 +9,9 @@ from pelican import logger
 
 def generate_uml_image(path, plantuml_code, imgformat):
     tf = tempfile.NamedTemporaryFile(delete=False)
-    tf.write('@startuml\n')
+    tf.write('@startuml\n'.encode('utf8'))
     tf.write(plantuml_code.encode('utf8'))
-    tf.write('\n@enduml')
+    tf.write('\n@enduml'.encode('utf8'))
     tf.flush()
 
     logger.debug("[plantuml] Temporary PlantUML source at "+(tf.name))
@@ -43,10 +43,10 @@ def generate_uml_image(path, plantuml_code, imgformat):
             # diagram was correctly generated, we can remove the temporary file (if not debugging)
             if not logger.isEnabledFor(logging.DEBUG):
                 os.remove(tf.name)
-            # renaming output image using an hash code, just to not pullate
+            # renaming output image using an hash code, just to not pollute
             # output directory with a growing number of images
             name = os.path.join(path, os.path.basename(name))
-            newname = os.path.join(path, "%08x" % (adler32(plantuml_code) & 0xffffffff))+imgext
+            newname = os.path.join(path, "%08x" % (adler32(plantuml_code.encode()) & 0xffffffff))+imgext
 
             if os.path.exists(newname):
                 os.remove(newname)

+ 4 - 1
plantuml/pandoc-plantuml

@@ -42,7 +42,7 @@ import Text.Pandoc.JSON
 import Data.ByteString.Lazy (hGetContents, hPut)
 import Data.ByteString.Lazy.UTF8 (fromString)
 import Data.Digest.Pure.SHA (sha1, showDigest)
-import System.IO (hClose, hPutStr, IOMode(..), openBinaryFile)
+import System.IO (hClose, hPutStr, IOMode(..), openBinaryFile, hPutStrLn, stderr)
 import System.Process
 import System.Directory
 
@@ -55,6 +55,9 @@ processBlocks b =
 plantUMLToImg :: String -> IO Block
 plantUMLToImg content =  do
   path <- renderImage content
+  
+  --hPutStrLn stderr "dopo renderImage"
+
   return $ Para [Image [] (path, "")]
 
 renderImage :: String -> IO String

+ 1 - 1
plantuml/plantuml_md.py

@@ -26,7 +26,7 @@ import os
 import re
 import markdown
 from markdown.util import etree
-from generateUmlDiagram import generate_uml_image
+from .generateUmlDiagram import generate_uml_image
 
 # For details see https://pythonhosted.org/Markdown/extensions/api.html#blockparser
 class PlantUMLBlockProcessor(markdown.blockprocessors.BlockProcessor):

+ 1 - 1
plantuml/plantuml_rst.py

@@ -13,7 +13,7 @@ from docutils.nodes import image, literal_block
 from docutils.parsers.rst import Directive, directives
 from pelican import signals, logger
 
-from generateUmlDiagram import generate_uml_image
+from .generateUmlDiagram import generate_uml_image
 
 
 global_siteurl = "" # URL of the site, filled on plugin initialization