Skip to content

Commit

Permalink
Merge pull request #4 from Capitains/greekfixes
Browse files Browse the repository at this point in the history
fixes needed to not crash with current canonical-greekLit repo
  • Loading branch information
PonteIneptique committed Feb 24, 2016
2 parents 8393314 + 821f12b commit 4b6bba4
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 51 deletions.
14 changes: 7 additions & 7 deletions nautilus/flask_ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,52 +147,52 @@ def _r_GetCapabilities(self, urn, inv):
:param urn:
:return:
"""
return self.endpoint.getCapabilities(inventory=inv, urn=urn).strip(), 200, {"content-type": "text/xml"}
return self.endpoint.getCapabilities(inventory=inv, urn=urn).strip(), 200, {"content-type": "application/xml"}

def _r_GetPassage(self, urn, inv):
"""
:param urn:
:return:
"""
return self.endpoint.getPassage(inventory=inv, urn=urn).strip(), 200, {"content-type": "text/xml"}
return self.endpoint.getPassage(inventory=inv, urn=urn).strip(), 200, {"content-type": "application/xml"}

def _r_GetPassagePlus(self, urn, inv):
"""
:param urn:
:return:
"""
return self.endpoint.getPassagePlus(inventory=inv, urn=urn).strip(), 200, {"content-type": "text/xml"}
return self.endpoint.getPassagePlus(inventory=inv, urn=urn).strip(), 200, {"content-type": "application/xml"}

def _r_GetValidReff(self, urn, inv, level):
"""
:param urn:
:return:
"""
return self.endpoint.getValidReff(inventory=inv, urn=urn, level=level).strip(), 200, {"content-type": "text/xml"}
return self.endpoint.getValidReff(inventory=inv, urn=urn, level=level).strip(), 200, {"content-type": "application/xml"}

def _r_GetPrevNext(self, urn, inv):
"""
:param urn:
:return:
"""
return self.endpoint.getPrevNextUrn(inventory=inv, urn=urn).strip(), 200, {"content-type": "text/xml"}
return self.endpoint.getPrevNextUrn(inventory=inv, urn=urn).strip(), 200, {"content-type": "application/xml"}

def _r_GetFirstUrn(self, urn, inv):
"""
:param urn:
:return:
"""
return self.endpoint.getFirstUrn(inventory=inv, urn=urn).strip(), 200, {"content-type": "text/xml"}
return self.endpoint.getFirstUrn(inventory=inv, urn=urn).strip(), 200, {"content-type": "application/xml"}

def _r_GetLabel(self, urn, inv):
"""
:param urn:
:return:
"""
return self.endpoint.getLabel(inventory=inv, urn=urn).strip(), 200, {"content-type": "text/xml"}
return self.endpoint.getLabel(inventory=inv, urn=urn).strip(), 200, {"content-type": "application/xml"}
92 changes: 48 additions & 44 deletions nautilus/inventory/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,50 +61,54 @@ def __parseDirectories(self, resource):
for folder in resource:
textgroups = glob("{base_folder}/data/*/__cts__.xml".format(base_folder=folder))
for __cts__ in textgroups:
with open(__cts__) as __xml__:
textgroup = TextGroup(resource=__xml__)
textgroup.urn = URN(textgroup.xml.get("urn"))
self.resource.textgroups[str(textgroup.urn)] = textgroup

for __subcts__ in glob("{parent}/*/__cts__.xml".format(parent=os.path.dirname(__cts__))):
with open(__subcts__) as __xml__:
work = Work(
resource=__xml__,
parents=[self.resource.textgroups[str(textgroup.urn)]]
)
work.urn = URN(work.xml.get("urn"))
self.resource.textgroups[str(textgroup.urn)].works[str(work.urn)] = work

for __text__ in self.resource.textgroups[str(textgroup.urn)].works[str(work.urn)].texts.values():
__text__.path = "{directory}/{textgroup}.{work}.{version}.xml".format(
directory=os.path.dirname(__subcts__),
textgroup=__text__.urn[3],
work=__text__.urn[4],
version=__text__.urn[5]
)
if os.path.isfile(__text__.path):
try:
with open(__text__.path) as f:
t = Text(resource=f)
cites = list()
for cite in [c for c in t.citation][::-1]:
if len(cites) >= 1:
cites.append(Citation(
xpath=cite.xpath.replace("'", '"'),
scope=cite.scope.replace("'", '"'),
name=cite.name,
child=cites[-1]
))
else:
cites.append(Citation(
xpath=cite.xpath.replace("'", '"'),
scope=cite.scope.replace("'", '"'),
name=cite.name
))
__text__.citation = cites[-1]
except Exception:
print(__text__.path + " does not accept parsing at some level (most probably citation) ")
self.__texts__.append(__text__)
try:
with open(__cts__) as __xml__:
textgroup = TextGroup(resource=__xml__)
textgroup.urn = URN(textgroup.xml.get("urn"))
self.resource.textgroups[str(textgroup.urn)] = textgroup

for __subcts__ in glob("{parent}/*/__cts__.xml".format(parent=os.path.dirname(__cts__))):
with open(__subcts__) as __xml__:
work = Work(
resource=__xml__,
parents=[self.resource.textgroups[str(textgroup.urn)]]
)
work.urn = URN(work.xml.get("urn"))

self.resource.textgroups[str(textgroup.urn)].works[str(work.urn)] = work

for __text__ in self.resource.textgroups[str(textgroup.urn)].works[str(work.urn)].texts.values():
__text__.path = "{directory}/{textgroup}.{work}.{version}.xml".format(
directory=os.path.dirname(__subcts__),
textgroup=__text__.urn[3],
work=__text__.urn[4],
version=__text__.urn[5]
)
if os.path.isfile(__text__.path):
try:
with open(__text__.path) as f:
t = Text(resource=f)
cites = list()
for cite in [c for c in t.citation][::-1]:
if len(cites) >= 1:
cites.append(Citation(
xpath=cite.xpath.replace("'", '"'),
scope=cite.scope.replace("'", '"'),
name=cite.name,
child=cites[-1]
))
else:
cites.append(Citation(
xpath=cite.xpath.replace("'", '"'),
scope=cite.scope.replace("'", '"'),
name=cite.name
))
__text__.citation = cites[-1]
except Exception:
print(__text__.path + " does not accept parsing at some level (most probably citation) ")
self.__texts__.append(__text__)
except Exception:
print("Error parsing " + __cts__)

return self.resource, self.__texts__

Expand Down

0 comments on commit 4b6bba4

Please sign in to comment.