GithubHelp home page GithubHelp logo

palitype's Introduction

NOTES

If you haven't used this for a while or this is your first time, follow these steps.

  • Let's make sure that you can edit files!
    • I used to use ReText, but it doesn't install anymore.
    • Now I might as well create with pyCharm
  • Now what? If you are writing a commentary on a sutta, then you probably would like to use palitype.
  • After palitype produced the rst file, you can see the end resulting html by using `pelican <readme/pelican

Palitype is a preprocessor on markup. It takes text with quotes in different languages. It then:

  1. Reads a strict_yaml file using strictyaml. The yaml file indicates the delimiters that indicate the target text and the mark-up that will envelope the target text.

    Example:

    Text is presented that contains English, Pali and Sanskrit.

    DELIMITER1 English DELIMITER2 Pali DELIMITER3 Sanskrit DELIMITER4

  2. The first line in the text file refers to the yml file that contains the delimiters .. include:: palitype_instructions.yml

Use

cd palitype
(palitype)% cd content
(palitype)% python ../../palitype/cli.py SN001.txt

The palitype tests are run:

cd palitype
pipenv run python -m pytest

Some options:

pipenv run python -m pytest -x           # stop after first failure
pipenv run python -m pytest --maxfail=2  # stop after two failures

coverage.py

To guage effectiveness of tests, use coverage.py.

After preprocessing the text file with palitype, run pelican to generate the html files.

cd ~/My\ Buddhism/SN
pelican content
pelican --listen

TO change a theme, see Pelican themes .

but here, the m.css is used.

The pelicanconf.py file is

.. literalinclude:: ../../../../../pelicanconf.py
   :language: python

This is placed in the main directory where pelican is executed. All the content is in the content folder beneath it.

The default theme is m-theme-dark.css but this them will indent all paragraphs by 1.5rem. To avoid this, change this line:

--paragraph-indent:

to:

--paragraph-indent: 0rem;

On web browser, go to http://localhost:8000

Environment

Let's use virtualenv as the package manager.

Sphinx

cd py4web/apps/samyutta/palitype/docs
sphinx-quickstart

Added:

sys.path.insert(0, os.path.abspath('..'))
sys.path.append(os.path.abspath('.'))

to the conf.py. The second line is to read the ipython directives from a directory within docs. iPython directive was placed in there so that the extensions list in conf.py looks like:

extensions = ['sphinx.ext.autodoc',
              'sphinx.ext.coverage',
              'sphinx.ext.napoleon',
              'sphinxext.ipython_console_highlighting',
              'sphinxext.ipython_directive'
]

The sphinxext directory was obtained from https://github.com/ipython/ipython/tree/master/IPython

Generate html from this README.rst file by adding the line:

.. include:: ../README.rst

in the docs/read.rst.

cd docs
make html

Gotchas

Don't use any spaces in paths. Spaces in pathnames will generate bookmark errors.

docformatter

conda install -c conda-forge docformatter
docformatter --in-place example.py
docformatter --recursive --in-place dir

yapf

yapf is a python formatter.

conda install -c conda-forge yapf
yapf --recursive --in-place dir

If these settings in setup.cfg, google styling is used and this has the least errors after running pylama.:

[yapf]
based_on_style = google
spaces_before_comment = 4
split_before_logical_operator = true

Pylint

Git

https://realpython.com/python-git-github-intro/ (use gitignore.io to generate .gitignore file using 'Python', 'mac' and 'git' as seeds)

Buddhism % cd SN/py4web/apps/samyutta/palitype
palitype % git config --global user.name "your name goes here"
palitype % git init
Initialized empty Git repository in ...

Add docs/sphinxext/ to .gitignore To remove staged files use:

palitype % git reset docs/sphinxext/

To commit all

palitype % git commit -am 'Initial commit'

Wily

Project uses wily as mentioned at https://realpython.com/python-refactoring/

wily analyses the code and calculates a mertic that describes the complexity of the code.

coverage.py

To guage effectiveness of tests, use coverage.py.

Database

Database set up uses a postgres docker, so an postgresql image is first downloaded https://hub.docker.com Then:

docker run --name postgres -p 5433:5432 -v /Users/ben/Databases/sn:/var/lib/postgresql/data -e POSTGRES_PASSWORD=time67docker

Note that:

  1. The port has changed for the host. The host port is 5433

  2. The location of the database is in a host directory. So in settings.py:

    # DB_FOLDER:    Sets the place where migration files will be created
    #               and is the store location for SQLite databases
    DB_FOLDER = "/Users/ben/Databases/sn/py4web"
    DB_URI = "postgres://postgres:time67docker@localhost:5433/postgres"

Now in common.py, db is declared with the check_reserved = ["postgres"]:

db = DAL(
    settings.DB_URI,
    folder=settings.DB_FOLDER,
    pool_size=settings.DB_POOL_SIZE,
    migrate=settings.DB_MIGRATE,
    fake_migrate=settings.DB_FAKE_MIGRATE,
    check_reserved=['postgres'],
)

Postgresql Notes

Use https://www.postgresql.org/docs/current/pgtrgm.html

palitype's People

Contributors

benlawraus avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.