Permalink
Browse files

Moved MarkDownTool out of api.py into apimarkdown.py to prevent circular

import dependancies.
Built first pass at release 3.2 dump files
  • Loading branch information...
1 parent 6fbeba3 commit a0ba01c9f0af9724683f50bfc17a9867cb3bb84b @RichardWallis RichardWallis committed Sep 6, 2016
Showing with 134,923 additions and 71 deletions.
  1. +2 −51 api.py
  2. +49 −0 apimarkdown.py
  3. +7 −7 apirdflib.py
  4. +245 −0 data/releases/3.2/all-layers-enumvalues.csv
  5. +1,271 −0 data/releases/3.2/all-layers-properties.csv
  6. +1,145 −0 data/releases/3.2/all-layers-types.csv
  7. +28,391 −0 data/releases/3.2/all-layers.jsonld
  8. +11,201 −0 data/releases/3.2/all-layers.nq
  9. +11,177 −0 data/releases/3.2/all-layers.nt
  10. +13,866 −0 data/releases/3.2/all-layers.ttl
  11. +1 −0 data/releases/3.2/ext-attic-enumvalues.csv
  12. +2 −0 data/releases/3.2/ext-attic-properties.csv
  13. +2 −0 data/releases/3.2/ext-attic-types.csv
  14. +42 −0 data/releases/3.2/ext-attic.jsonld
  15. +13 −0 data/releases/3.2/ext-attic.nq
  16. +13 −0 data/releases/3.2/ext-attic.nt
  17. +23 −0 data/releases/3.2/ext-attic.ttl
  18. +4 −0 data/releases/3.2/ext-auto-enumvalues.csv
  19. +101 −0 data/releases/3.2/ext-auto-properties.csv
  20. +5 −0 data/releases/3.2/ext-auto-types.csv
  21. +501 −0 data/releases/3.2/ext-auto.jsonld
  22. +187 −0 data/releases/3.2/ext-auto.nq
  23. +187 −0 data/releases/3.2/ext-auto.nt
  24. +302 −0 data/releases/3.2/ext-auto.ttl
  25. +2 −0 data/releases/3.2/ext-bib-enumvalues.csv
  26. +19 −0 data/releases/3.2/ext-bib-properties.csv
  27. +21 −0 data/releases/3.2/ext-bib-types.csv
  28. +608 −0 data/releases/3.2/ext-bib.jsonld
  29. +186 −0 data/releases/3.2/ext-bib.nq
  30. +186 −0 data/releases/3.2/ext-bib.nt
  31. +239 −0 data/releases/3.2/ext-bib.ttl
  32. +127 −0 data/releases/3.2/ext-health-lifesci-enumvalues.csv
  33. +177 −0 data/releases/3.2/ext-health-lifesci-properties.csv
  34. +99 −0 data/releases/3.2/ext-health-lifesci-types.csv
  35. +5,523 −0 data/releases/3.2/ext-health-lifesci.jsonld
  36. +2,185 −0 data/releases/3.2/ext-health-lifesci.nq
  37. +2,185 −0 data/releases/3.2/ext-health-lifesci.nt
  38. +2,598 −0 data/releases/3.2/ext-health-lifesci.ttl
  39. +1 −0 data/releases/3.2/ext-meta-enumvalues.csv
  40. +5 −0 data/releases/3.2/ext-meta-properties.csv
  41. +3 −0 data/releases/3.2/ext-meta-types.csv
  42. +122 −0 data/releases/3.2/ext-meta.jsonld
  43. +42 −0 data/releases/3.2/ext-meta.nq
  44. +42 −0 data/releases/3.2/ext-meta.nt
  45. +57 −0 data/releases/3.2/ext-meta.ttl
  46. +1 −0 data/releases/3.2/ext-pending-enumvalues.csv
  47. +41 −0 data/releases/3.2/ext-pending-properties.csv
  48. +38 −0 data/releases/3.2/ext-pending-types.csv
  49. +1,196 −0 data/releases/3.2/ext-pending.jsonld
  50. +488 −0 data/releases/3.2/ext-pending.nq
  51. +488 −0 data/releases/3.2/ext-pending.nt
  52. +578 −0 data/releases/3.2/ext-pending.ttl
  53. +115 −0 data/releases/3.2/schema-enumvalues.csv
  54. +935 −0 data/releases/3.2/schema-properties.csv
  55. +987 −0 data/releases/3.2/schema-types.csv
  56. +20,462 −0 data/releases/3.2/schema.jsonld
  57. +8,118 −0 data/releases/3.2/schema.nq
  58. +8,118 −0 data/releases/3.2/schema.nt
  59. +10,179 −0 data/releases/3.2/schema.ttl
  60. +4 −3 scripts/exportgraphs.py
  61. +7 −6 sdoapp.py
  62. +4 −4 sdordf2csv.py
View
@@ -8,10 +8,9 @@
import parsers
from google.appengine.ext import ndb
-
import apirdflib
#from apirdflib import rdfGetTargets, rdfGetSources
-
+from apimarkdown import Markdown
logging.basicConfig(level=logging.INFO) # dev_appserver.py --log_level debug .
log = logging.getLogger(__name__)
@@ -663,7 +662,7 @@ def GetComment(node, layers='core') :
"""Get the first rdfs:comment we find on this node (or "No comment"), within any of the specified layers."""
tx = GetComments(node, layers)
if len(tx) > 0:
- return MD.parse(tx[0])
+ return Markdown.parse(tx[0])
else:
return "No comment"
@@ -1096,7 +1095,6 @@ def read_extensions(extensions):
expfiles = glob.glob("data/ext/%s/*examples.txt" % i)
read_examples(expfiles,i)
- log.info("Extensions found: %s ." % " , ".join(extfiles) )
# fnstrip_re = re.compile("\/.*")
# for ext in extfiles:
# ext_file_path = full_path(ext)
@@ -1147,51 +1145,4 @@ def ShortenOnSentence(source,lengthHint=250):
source = com
return source
-WIKILINKPATTERN = r'\[\[([\w0-9_ -]+)\]\]'
-
-class MarkdownTool():
- def __init__ (self):
- import markdown2
- from markdown2 import Markdown
- #from markdown.extensions.wikilinks import WikiLinkExtension
- #self._md = markdown2.Markdown(extensions=[WikiLinkExtension(base_url='/', end_url='', html_class='localLink')])
- self._md = Markdown()
- self.wclass = "localLink"
- self.wpre = "/"
- self.wpost = ""
- self.parselock = threading.Lock()
-
- def setPre(self,pre="/"):
- self.wpre = pre
-
- def setPost(self,post=""):
- self.wpost = post
-
- def parse(self,source,preservePara=False):
- if not source or len(source) == 0:
- return ""
- source = source.strip()
- source = source.replace("\\n","\n")
- try:
- self.parselock.acquire()
- ret = self._md.convert(source)
- finally:
- self.parselock.release()
-
- if not preservePara:
- #Remove wrapping <p> </p>\n that Markdown2 adds by default
- if len(ret) > 7 and ret.startswith("<p>") and ret.endswith("</p>\n"):
- ret = ret[3:len(ret)-5]
-
- return self.parseWiklinks(ret)
-
- def parseWiklinks(self,source):
- return re.sub(WIKILINKPATTERN, self.wikilinkReplace, source)
-
- def wikilinkReplace(self,match):
- t = match.group(1)
- return '<a class="%s" href="%s%s%s">%s</a>' % (self.wclass,self.wpre,t,self.wpost,t)
-
-
-MD = MarkdownTool()
View
@@ -0,0 +1,49 @@
+import markdown2
+from markdown2 import Markdown
+import re
+import threading
+WIKILINKPATTERN = r'\[\[([\w0-9_ -]+)\]\]'
+
+class MarkdownTool():
+ def __init__ (self):
+ #from markdown.extensions.wikilinks import WikiLinkExtension
+ #self._md = markdown2.Markdown(extensions=[WikiLinkExtension(base_url='/', end_url='', html_class='localLink')])
+ self._md = Markdown()
+ self.wclass = "localLink"
+ self.wpre = "/"
+ self.wpost = ""
+ self.parselock = threading.Lock()
+
+ def setPre(self,pre="/"):
+ self.wpre = pre
+
+ def setPost(self,post=""):
+ self.wpost = post
+
+ def parse(self,source,preservePara=False):
+ if not source or len(source) == 0:
+ return ""
+ source = source.strip()
+ source = source.replace("\\n","\n")
+ try:
+ self.parselock.acquire()
+ ret = self._md.convert(source)
+ finally:
+ self.parselock.release()
+
+ if not preservePara:
+ #Remove wrapping <p> </p>\n that Markdown2 adds by default
+ if len(ret) > 7 and ret.startswith("<p>") and ret.endswith("</p>\n"):
+ ret = ret[3:len(ret)-5]
+
+ return self.parseWiklinks(ret)
+
+ def parseWiklinks(self,source):
+ return re.sub(WIKILINKPATTERN, self.wikilinkReplace, source)
+
+ def wikilinkReplace(self,match):
+ t = match.group(1)
+ return '<a class="%s" href="%s%s%s">%s</a>' % (self.wclass,self.wpre,t,self.wpost,t)
+
+
+Markdown = MarkdownTool()
View
@@ -11,7 +11,7 @@
from rdflib.plugins.sparql import prepareQuery
import threading
import api
-from api import MD
+from apimarkdown import Markdown
import StringIO
@@ -67,10 +67,10 @@ def loadNss():
global revNss
if not NSSLoaded:
NSSLoaded = True
- log.info("allLayersList: %s"% allLayersList)
+ #log.info("allLayersList: %s"% allLayersList)
for i in allLayersList:
if i != "core":
- log.info("Setting %s to %s" % (i, "http://%s.schema.org/" % i))
+ #log.info("Setting %s to %s" % (i, "http://%s.schema.org/" % i))
nss.update({i:"http://%s.schema.org/" % i})
revNss = {v: k for k, v in nss.items()}
@@ -103,7 +103,7 @@ def load_graph(context, files):
import glob
import re
- log.info("Loading %s graph." % context)
+ log.debug("Loading %s graph." % context)
for f in files:
if(f[-5:] == ".rdfa"):
format = "rdfa"
@@ -345,14 +345,14 @@ def buildSingleTermGraph(node,excludeAttic=True,markdown=True):
try:
RDFLIBLOCK.acquire()
trips = list(g.triples((None,RDFS.comment,None)))
- MD.setPre("http://schema.org/")
+ Markdown.setPre("http://schema.org/")
for (s,p,com) in trips:
- mcom = MD.parse(com)
+ mcom = Markdown.parse(com)
g.remove((s,p,com))
g.add((s,p,Literal(mcom)))
finally:
RDFLIBLOCK.release()
- MD.setPre()
+ Markdown.setPre()
return g
Oops, something went wrong.

0 comments on commit a0ba01c

Please sign in to comment.