Skip to content

Commit

Permalink
Lots of change, breaking because dependant on not release version£
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Feb 1, 2017
1 parent fbe3a7a commit 99e4e5f
Show file tree
Hide file tree
Showing 23 changed files with 7,021 additions and 380 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ lxml-3.4.4-py3.4-linux-x86_64.egg/
/venv*/
docs/_build
build
*.egg-info
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ If you have trouble with dependency conflicts with MyCapitains, try running :cod


Running Nemo from the command line
######################################
##################################

This small tutorial takes that you have a CTS API endpoint available, here :code:`http://localhost:8000`

Expand Down
6,528 changes: 6,528 additions & 0 deletions data.txt

Large diffs are not rendered by default.

68 changes: 58 additions & 10 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# Import Flask and Nemo
# This script can take a first argument giving a configuration from examples.py
from flask import Flask
from flask.ext.nemo import Nemo
from flask_nemo import Nemo
from flask_nemo.chunker import level_grouper
from MyCapytain.resolvers.cts.local import CTSCapitainsLocalResolver
from MyCapytain.resources.collections.cts import TextInventory
from MyCapytain.resources.prototypes.cts.inventory import TextInventoryCollection
from MyCapytain.resolvers.utils import CollectionDispatcher
import logging
from examples.configs import configs, classes
from sys import argv
from pkg_resources import resource_filename


if __name__ == "__main__":
Expand All @@ -22,17 +27,60 @@
__name__
)

# We set up Nemo
tic = TextInventoryCollection()
latin = TextInventory("urn:perseus:latinLit")
latin.parent = tic
latin.set_label("Classical Latin", "eng")
farsi = TextInventory("urn:perseus:farsiLit")
farsi.parent = tic
farsi.set_label("Farsi", "eng")
farsi = TextInventory("urn:perseus:greekLit")
farsi.parent = tic
farsi.set_label("Ancient Greek", "eng")

dispatcher = CollectionDispatcher(tic)

@dispatcher.inventory("urn:perseus:latinLit")
def dispatchLatinLit(collection):
if collection.id.startswith("urn:cts:latinLit:"):
return True
return False

@dispatcher.inventory("urn:perseus:latinLit")
def dispatchLatinLit(collection):
if collection.id.startswith("urn:cts:latinLit:"):
return True
return False

@dispatcher.inventory("urn:perseus:farsiLit")
def dispatchfFarsiLit(collection):
if collection.id.startswith("urn:cts:farsiLit:"):
return True
return False

@dispatcher.inventory("urn:perseus:greekLit")
def dispatchGreekLit(collection):
if collection.id.startswith("urn:cts:greekLit:"):
return True
return False

NautilusDummy = CTSCapitainsLocalResolver(
resource=[
"../../canonicals/First1KGreek",
"../../canonicals/canonical-latinLit",
"./tests/test_data/nautilus/farsiLit"
],
dispatcher=dispatcher
)
NautilusDummy.logger.setLevel(logging.ERROR)

nemo = Nemo(
app=app,
name="nemo",
**configs[key]
base_url="",
retriever=NautilusDummy,
chunker={"default": lambda x, y: level_grouper(x, y, groupby=30)},
plugins=None
)
# We register its routes
nemo.register_routes()
# We register its filters
nemo.register_filters()


# We run the app
app.debug = True
Expand Down

0 comments on commit 99e4e5f

Please sign in to comment.