Skip to content

Commit

Permalink
Release 0.0.4
Browse files Browse the repository at this point in the history
- #21 don't add texts to inventory if they don't have cites
- #23 fix cache handling on command line
- Bump version
  • Loading branch information
balmas authored and PonteIneptique committed Apr 26, 2016
1 parent e581ece commit a138493
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
4 changes: 2 additions & 2 deletions capitains_nautilus/cmd.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

from capitains_nautilus.flask_ext import FlaskNautilus
from capitains_nautilus.flask_ext import FlaskNautilus, WerkzeugCacheWrapper
from werkzeug.contrib.cache import FileSystemCache, RedisCache, NullCache
from flask import Flask
from flask_cache import Cache
Expand Down Expand Up @@ -45,7 +45,7 @@ def _commandline(repositories,
FlaskNautilus(
app=app,
resources=repositories,
parser_cache=nautilus_cache,
parser_cache=WerkzeugCacheWrapper(nautilus_cache),
http_cache=Cache(config={'CACHE_TYPE': cache_type}),
logger=None
)
Expand Down
11 changes: 9 additions & 2 deletions capitains_nautilus/inventory/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ def parse(self, resource, cache=True, verbose=True):
work.urn = URN(work.xml.get("urn"))
self.inventory.textgroups[str(textgroup.urn)].works[str(work.urn)] = work

for __text__ in self.inventory.textgroups[str(textgroup.urn)].works[str(work.urn)].texts.values():
for __textkey__ in self.inventory.textgroups[str(textgroup.urn)].works[str(work.urn)].texts:
__text__ = self.inventory.textgroups[str(textgroup.urn)].works[str(work.urn)].texts[__textkey__]
__text__.path = "{directory}/{textgroup}.{work}.{version}.xml".format(
directory=os.path.dirname(__subcts__),
textgroup=__text__.urn.textgroup,
Expand Down Expand Up @@ -148,9 +149,14 @@ def parse(self, resource, cache=True, verbose=True):
))
__text__.citation = cites[-1]
self.logger.info("%s has been parsed ", __text__.path)
if (__text__.citation):
self.__texts__.append(__text__)
else:
self.logger.error("%s has no passages", __text__.path)
except Exception:
self.logger.error("%s does not accept parsing at some level (most probably citation) ", __text__.path)
self.__texts__.append(__text__)
else:
self.logger.error("%s is not present", __text__.path)
except Exception:
self.logger.error("Error parsing %s ", __cts__)

Expand Down Expand Up @@ -208,6 +214,7 @@ def getCapabilities(self, urn=None, page=None, limit=None, inventory=None, lang=
for text in self.__texts__
if (lang is None or (lang is not None and lang == text.lang)) and
(urn is None or (urn is not None and text.urn.upTo(__PART) == urn)) and
(text.citation is not None) and
(category not in ["edition", "translation"] or (category in ["edition", "translation"] and category.lower() == text.subtype.lower()))
]
if pagination:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='capitains_nautilus',
version="0.0.3",
version="0.0.4",
description='Resolver for Capitains Guidelines Repository',
url='http://github.com/Capitains/nautilus',
author='Thibault Clerice',
Expand Down
11 changes: 10 additions & 1 deletion tests/inventory/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,13 @@ def test_get_capabilities(self):
self.assertEqual(
len(Repository.getCapabilities(urn="urn:cts:farsiLit:hafez.divan.perseus-eng1")[0]), 1,
"Complete URN filtering works"
)
)
def test_get_capabilities_nocites(self):
""" Check Get Capabilities latinLit data"""
Repository = XMLFolderResolver(
["./tests/test_data/latinLit"]
)
self.assertEqual(
len(Repository.getCapabilities(urn="urn:cts:latinLit:stoa0045.stoa008.perseus-lat2")[0]), 0,
"Texts without citations were ignored"
)

0 comments on commit a138493

Please sign in to comment.