Skip to content

Commit

Permalink
seperate app
Browse files Browse the repository at this point in the history
  • Loading branch information
interrogator committed Aug 17, 2019
0 parents commit d6b7ad3
Show file tree
Hide file tree
Showing 29 changed files with 903 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[bumpversion]
commit = True
tag = True
tag_name = {new_version}
current_version = 0.0.1

[bumpversion:file:setup.py]
search = version="{current_version}"
replace = version="{new_version}"

[bumpversion:file:buzzword/__init__.py]
search = __version__ = "{current_version}"
replace = __version__ = "{new_version}"

[bumpversion:file:README.md]
search = > Version {current_version}
replace = > Version {new_version}
3 changes: 3 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[report]
omit =
tests/*
11 changes: 11 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# .env example for deploying buzzword
# comment out keys you are not using
BUZZWORD_CORPORA_FILE=corpora.json
BUZZWORD_LOAD=true
BUZZWORD_TITLE=buzzword
BUZZWORD_DEBUG=false
# BUZZWORD_MAX_DATASET_ROWS=
BUZZWORD_DROP_COLUMNS=parse,text
BUZZWORD_PAGE_SIZE=25
BUZZWORD_TABLE_SIZE=2000,200
BUZZWORD_ADD_GOVERNOR=false
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[flake8]
max-line-length = 88
# These checks violate PEP8 so let's ignore them
ignore = W503,E203
117 changes: 117 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
do-the-right-thing-norm.txt
unparsed.txt
dist/

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
*.DS_Store
tests-parsed/
tests/data-parsed/
tests/data-stripped/
tests/odata-parsed/
unabomber/manifesto-parsed/
sopranos/
sopranos-parsed/
publish.sh
csv/
corpora.json
uploads/
23 changes: 23 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
#sphinx:
# configuration: docs/conf.py

# Build documentation with MkDocs
mkdocs:
configuration: mkdocs.yml
fail_on_warning: false

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
dist: xenial
language: python
python:
- '3.7'
stages:
- build
- static-checks
- test
jobs:
include:
- stage: build
script:
- python setup.py install
- stage: static-checks
script:
- flake8 buzzword/ tests/ setup.py
- mypy buzzword/ tests/ setup.py
- black --check .
- stage: test
script: # coverage
- coverage run -m unittest
- coverage report
- codecov
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 {real_name}

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# buzzword

> Version 0.0.1
[![Build Status](https://travis-ci.org/interrogator/buzzword.svg?branch=master)](https://travis-ci.org/interrogator/buzzword)
[![codecov.io](https://codecov.io/gh/interrogator/buzzword/branch/master/graph/badge.svg)](https://codecov.io/gh/interrogator/buzzword)
[![PyPI version](https://badge.fury.io/py/buzzword.svg)](https://badge.fury.io/py/buzzword)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)

> Web-app for corpus linguistics
## Install buzzword

```bash
pip install buzzword
```

First, configure a `.env` file from `.env.example`, a `corpora.json` file from `corpora.json.example`, and then do:

```bash
buzzword
# or
python -m buzzword
```
5 changes: 5 additions & 0 deletions bin/buzzword
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# Run the buzzword app

python -m buzzword $@
3 changes: 3 additions & 0 deletions buzzword/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

if __name__ == "__main__":
print('HERE NOW')
76 changes: 76 additions & 0 deletions buzzword/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

from buzzword.parts.main import app, CORPORA, CONFIG, INITIAL_TABLES, CORPUS_META
from buzzword.parts import start, guide, about, depgrep, building
from buzzword.parts.tabs import _make_tabs
from dash.exceptions import PreventUpdate
from collections import OrderedDict
from buzzword.parts import explore # noqa: F401
from buzzword.parts.main import server # noqa: F401

import os

# where downloadable CSVs get stored
if not os.path.isdir("csv"):
os.makedirs("csv")


def _get_layout():
"""
Function for layout. Could be helpful in future to do it this way.
"""
loc = dcc.Location(id="url", refresh=False)
content = html.Div(id="page-content")
return html.Div([loc, content])


app.layout = _get_layout

LAYOUTS = dict()


def _make_explore_layout(slug, name):
corpus = CORPORA[slug]
SEARCHES = OrderedDict({name: corpus})
TABLES = OrderedDict({"initial": INITIAL_TABLES[slug]})
return _make_tabs(SEARCHES, TABLES, slug, **CONFIG)


@app.callback(Output("page-content", "children"), [Input("url", "pathname")])
def _choose_correct_page(pathname):
if pathname is None:
raise PreventUpdate
if pathname == "/about":
return about.layout
if pathname == "/guide":
return guide.layout
if pathname == "/building":
return building.layout
if pathname == "/depgrep":
return depgrep.layout
if pathname.startswith("/explore"):
slug = pathname.rstrip("/").split("/")[-1]
if slug not in CORPORA:
pathname = "/"
else:
gen = (k for k, v in CORPUS_META.items() if v["slug"] == slug)
name = next(gen, None)
name = name or slug
if slug in LAYOUTS:
layout = LAYOUTS[slug]
else:
layout = _make_explore_layout(slug, name)
LAYOUTS[slug] = layout
# app.title = "buzzword: {}".format(name)
return layout
if pathname in {"", "/", "/start"}:
# app.title = "buzzword: home"
return start.layout
else:
return "404"


if __name__ == "__main__":
app.run_server(debug=True)

0 comments on commit d6b7ad3

Please sign in to comment.