Skip to content

Commit

Permalink
Rebrand to ScriptShifter.
Browse files Browse the repository at this point in the history
  • Loading branch information
scossu committed Aug 21, 2022
1 parent 9c1afe2 commit 58cd0be
Show file tree
Hide file tree
Showing 49 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ FROM python:3.9-alpine3.15
RUN apk add --no-cache -t buildtools build-base
RUN apk add --no-cache linux-headers

ENV _workroot "/usr/local/transliterator/src"
ENV _workroot "/usr/local/scriptshifter/src"

WORKDIR ${_workroot}
COPY requirements.txt ./
RUN pip install -r requirements.txt
COPY entrypoint.sh uwsgi.ini wsgi.py ./
COPY transliterator ./transliterator/
COPY scriptshifter ./scriptshifter/
RUN chmod +x ./entrypoint.sh

RUN addgroup -S www && adduser -S www -G www
Expand Down
6 changes: 3 additions & 3 deletions NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## `.cfg` files

The `.cfg` format seems to follow a INI-like syntax that is ad-hoc-parsed by
the Transliterator.
the ScriptShifter.

Unicode points are expressed as `U+????` rather than `\x????` of the standard
INI syntax.
Expand Down Expand Up @@ -54,7 +54,7 @@ A (RB): Yes.
## `ReRomanizeRecord.bas`

Much of the code deals with MARC records. No need to concern about that since
the new Transliterator is meant to convert text strings to text strings.
the new ScriptShifter is meant to convert text strings to text strings.

Q: Is it possible (and desirable) to determine the S2R/R2S direction from user
prompt rather than guessing it from the text as the legacy software seems to
Expand Down Expand Up @@ -248,7 +248,7 @@ HTML or Markdown, so this may need to be taken into account.)
Q: It seems like several characters are parsed and added to the text to denote
MARC markers. Do we need to deal with these manually as indicators related to
the script/language handled, or shall we expect any text string input in the
new Transliterator to be clean from MARC flags?
new ScriptShifter to be clean from MARC flags?

A (RB): Most MARC markers are obsolete; but there may be other markers that
are not easily transliterated, e.g. BIBFRAME markers. More discussion is needed
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# transliterator
# ScriptShifter

REST API service to convert non-Latin scripts to Latin, and vice versa.

Expand All @@ -7,13 +7,13 @@ REST API service to convert non-Latin scripts to Latin, and vice versa.
Build container in current dir:

```
docker build -t transliterator:latest .
docker build -t scriptshifter:latest .
```

Start container:

```
docker run -e TXL_FLASK_SECRET=changeme -p 8000:8000 transliterator:latest
docker run -e TXL_FLASK_SECRET=changeme -p 8000:8000 scriptshifter:latest
```

For running in development mode, add `-e FLASK_ENV=development` to the options.
Expand Down
8 changes: 4 additions & 4 deletions doc/config.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Transliterator configuration file format
# ScriptShifter configuration file format

Language transliteration is made according to set of rules contained in static
files. Generally, each file represents one script and one language, but there
may be exception to this rule in cases of multiple languages sharing the same
script.

Configuration files, also called transliteration tables, are contained in the
[`/transliterator/tables/data`](../transliterator/tables/data) directory.
[`/scriptshifter/tables/data`](../scriptshifter/tables/data) directory.

## Types of configuration files

Expand Down Expand Up @@ -189,7 +189,7 @@ Each key in this section is one of the predefined hook names and is paired with
a list of functions that shall be run when the life cycle point designated for
the hook is reached. Each function definition is a list of one or two elements.
The first is the function path including the path, relative to the
`transliterator.hooks` package. The second, optional element, is a map of
`scriptshifter.hooks` package. The second, optional element, is a map of
key-value pairs provding additional keyword arguments for the function. These
arguments are fixed for all the calls to this function made by this hook.

Expand All @@ -207,7 +207,7 @@ script_to_roman:
```
runs the function `myfn(ctx, x=32, y="hello")` in
`transliterator.hooks.my_module` (`ctx` is always provided by the application)
`scriptshifter.hooks.my_module` (`ctx` is always provided by the application)
for the `pre_tx_token` hook.

### `script_to_roman`
Expand Down
10 changes: 5 additions & 5 deletions doc/hooks.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Transliterator life cycle hooks
# ScriptShifter life cycle hooks

This is a guide for language specialists with some Python development skills,
or who can partner with Python developers to create new, complex
Expand Down Expand Up @@ -98,12 +98,12 @@ Hook functions may be defined for each language/script in the corresponding
configuration file. See [`config.md`](./config.md) for details.

The function name takes the form of `<module name>.<function name>` and must
correspond to an existing module and function under the `transliterator.hooks`
package. Check the [`rot3.yml`](../transliterator/tables/data/rot3.yml) test
correspond to an existing module and function under the `scriptshifter.hooks`
package. Check the [`rot3.yml`](../scriptshifter/tables/data/rot3.yml) test
configuration and the referred functions for a working example.

Each hook requires some arguments to be defined in each function associated
with it: `ctx`, an instance of `transliterator.trans.Context` which carries
with it: `ctx`, an instance of `scriptshifter.trans.Context` which carries
information about the current scanner status and can be manipulated by the hook
function; and `**kw`, optional keyword-only arguments, whose values can be
defined in the configuration.
Expand All @@ -112,7 +112,7 @@ Each function must also return an output that the process is able to handle as
expected. the output may instruct the application to make a specific decision
after the hook function is executed. Possible return values are defined below
for each hook. Some special return values, such as `BREAK` and `CONT`, are
registered as constants under `transliterator.exceptions`.
registered as constants under `scriptshifter.exceptions`.

**[TODO]** These hooks are being implemented in a vacuum, without much of a
real-world use case. Modifications to these capabilities may change as actual
Expand Down
2 changes: 1 addition & 1 deletion doc/rest_api.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Transliterator REST API
# ScriptShifter REST API

## `GET /health`

Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/bin/sh

export PYTHONPATH=$PYTHONPATH:.
export WEBAPP_PIDFILE="/run/transliterator_webapp.pid"
export FLASK_APP="transliterator.rest_api"
export WEBAPP_PIDFILE="/run/scriptshifter_webapp.pid"
export FLASK_APP="scriptshifter.rest_api"
if [ "${TXL_APP_MODE}" == "development" ]; then
export FLASK_ENV="development"
else
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging

from transliterator.exceptions import CONT
from scriptshifter.exceptions import CONT


__doc__ = """ Test hook functions. """
Expand Down
4 changes: 2 additions & 2 deletions transliterator/rest_api.py → scriptshifter/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

from flask import Flask, Response, jsonify, render_template, request

from transliterator.tables import list_tables, load_table
from transliterator.trans import transliterate
from scriptshifter.tables import list_tables, load_table
from scriptshifter.trans import transliterate


def create_app():
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
except ImportError:
from yaml import Loader

from transliterator.exceptions import ConfigError
from scriptshifter.exceptions import ConfigError


__doc__ = """
Expand Down Expand Up @@ -39,7 +39,7 @@
"post_assembly",
)
# Package path where hook functions are kept.
HOOK_PKG_PATH = "transliterator.hooks"
HOOK_PKG_PATH = "scriptshifter.hooks"

logger = logging.getLogger(__name__)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions transliterator/trans.py → scriptshifter/trans.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging
import re

from transliterator.exceptions import BREAK, CONT
from transliterator.tables import load_table
from scriptshifter.exceptions import BREAK, CONT
from scriptshifter.tables import load_table


# Match multiple spaces.
Expand Down
6 changes: 3 additions & 3 deletions tests/test01_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
from os import environ

from tests import TEST_DATA_DIR
import transliterator.tables
import scriptshifter.tables


class TestConfig(TestCase):
""" Test configuration parsing. """

def test_ordering(self):
environ["TXL_CONFIG_TABLE_DIR"] = TEST_DATA_DIR
reload(transliterator.tables) # Reload new config dir.
from transliterator import tables
reload(scriptshifter.tables) # Reload new config dir.
from scriptshifter import tables
tables.list_tables.cache_clear()
tables.load_table.cache_clear()

Expand Down
10 changes: 5 additions & 5 deletions tests/test02_transliteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
from os import environ, path

from tests import TEST_DATA_DIR
from transliterator.trans import transliterate
import transliterator.tables
from scriptshifter.trans import transliterate
import scriptshifter.tables


logger = logging.getLogger(__name__)
Expand All @@ -32,7 +32,7 @@ def sample_s2r(self):
This function name won't start with `test_` otherwise will be
automatically run without parameters.
"""
config = transliterator.tables.load_table(self.tbl)
config = scriptshifter.tables.load_table(self.tbl)
if "script_to_roman" in config:
txl = transliterate(self.script, self.tbl)
self.assertEqual(txl, self.roman)
Expand All @@ -44,7 +44,7 @@ def sample_r2s(self):
This function name won't start with `test_` otherwise will be
automatically run without parameters.
"""
config = transliterator.tables.load_table(self.tbl)
config = scriptshifter.tables.load_table(self.tbl)
if "roman_to_script" in config:
txl = transliterate(self.roman, self.tbl, r2s=True)
self.assertEqual(txl, self.script)
Expand Down Expand Up @@ -76,6 +76,6 @@ def make_suite():

if "TXL_CONFIG_TABLE_DIR" in environ:
del environ["TXL_CONFIG_TABLE_DIR"]
reload(transliterator.tables)
reload(scriptshifter.tables)

TextTestRunner().run(make_suite())
Empty file removed transliterator/convert.py
Empty file.
2 changes: 1 addition & 1 deletion wsgi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from transliterator.rest_api import app
from scriptshifter.rest_api import app


if __name__ == "__main__":
Expand Down

0 comments on commit 58cd0be

Please sign in to comment.