Browse Source

Code clean up and python 2and3 compatibility

Code clean up:
- removed unecessary global calls

Python 2and3 compatibility:
- changed iteritems call to items
wilsonfreitas 9 years ago
parent
commit
673a43435d
1 changed files with 2 additions and 6 deletions
  1. 2 6
      rmd_reader/rmd_reader.py

+ 2 - 6
rmd_reader/rmd_reader.py

@@ -9,14 +9,12 @@ logger = logging.getLogger(__name__)
 from pelican import readers
 from pelican import readers
 from pelican import signals
 from pelican import signals
 from pelican import settings
 from pelican import settings
-from pelican.utils import pelican_open
-from markdown import Markdown
 
 
 knitr = None
 knitr = None
 rmd = False
 rmd = False
 
 
 def initsignal(pelicanobj):
 def initsignal(pelicanobj):
-    global knitr,rmd
+    global knitr, rmd
     try:
     try:
         with warnings.catch_warnings():
         with warnings.catch_warnings():
             warnings.simplefilter("ignore")
             warnings.simplefilter("ignore")
@@ -29,7 +27,7 @@ def initsignal(pelicanobj):
         idx = knitr.opts_chunk.names.index('set')
         idx = knitr.opts_chunk.names.index('set')
         knitroptschunk = pelicanobj.settings.get('RMD_READER_KNITR_OPTS_CHUNK', None)
         knitroptschunk = pelicanobj.settings.get('RMD_READER_KNITR_OPTS_CHUNK', None)
         if knitroptschunk is not None:     
         if knitroptschunk is not None:     
-            knitr.opts_chunk[idx](**{str(k): v for k,v in knitroptschunk.iteritems()})
+            knitr.opts_chunk[idx](**{str(k): v for k,v in knitroptschunk.items()})
         rmd = True
         rmd = True
     except ImportError as ex:
     except ImportError as ex:
         rmd = False
         rmd = False
@@ -39,14 +37,12 @@ class RmdReader(readers.BaseReader):
     
     
     @property
     @property
     def enabled():
     def enabled():
-        global rmd
         return rmd
         return rmd
 
 
     # You need to have a read method, which takes a filename and returns
     # You need to have a read method, which takes a filename and returns
     # some content and the associated metadata.
     # some content and the associated metadata.
     def read(self, filename):
     def read(self, filename):
         """Parse content and metadata of markdown files"""
         """Parse content and metadata of markdown files"""
-        global knitr
         QUIET = self.settings.get('RMD_READER_KNITR_QUIET', True)
         QUIET = self.settings.get('RMD_READER_KNITR_QUIET', True)
         ENCODING = self.settings.get('RMD_READER_KNITR_ENCODING', 'UTF-8')
         ENCODING = self.settings.get('RMD_READER_KNITR_ENCODING', 'UTF-8')
         CLEANUP = self.settings.get('RMD_READER_CLEANUP', True)
         CLEANUP = self.settings.get('RMD_READER_CLEANUP', True)