-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6d9cb73
Showing
7 changed files
with
171 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# FLEx script collection | ||
This is a collection of scripts for SIL's [FieldWorks](https://software.sil.org/fieldworks/) projects. | ||
Download a [ZIP](https://github.com/fmatter/flex-script-collection/archive/refs/heads/main.zip) from github or `git clone https://github.com/fmatter/flex-script-collection`. | ||
It is recommended to use a [virtual environment](https://docs.python.org/3/library/venv.html), to run the setup: | ||
|
||
```shell | ||
pip install -r requirements.txt | ||
``` | ||
|
||
Then you can execute individual scripts. | ||
|
||
## Contributing a script | ||
To contribute a useful script, [fork the github repository](https://github.com/fmatter/flex-script-collection/fork) and add the following files to your fork: | ||
|
||
1. a `my_script.*` file; ideally with: | ||
* name and contact info | ||
* comments where necessary (!) | ||
* a license | ||
2. a `docs/my_script.md` file with least basic instructions | ||
|
||
Add necessary packages to `requirements.txt`. | ||
Look at existing scripts to compare. | ||
Run `mkdocs serve` and visit [`localhost:8000`](http://localhost:8000). | ||
Finally, create a pull request. | ||
|
||
## Other software | ||
* [cldflex](https://fl.mt/cldflex) | ||
* [flexpy](https://github.com/Kuhron/flexpy) | ||
* ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% | ||
include-markdown '../README.md' | ||
%} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Modify all audio paths | ||
|
||
This script iterates a `.lift` export and modifies the `href` attribute of every `media` tag. | ||
This is where paths to audio files are stored. | ||
|
||
## Setup | ||
The modification consists of adding a prefix to the path. | ||
Edit the variables `PREFIX` and `TARGET` in the script. | ||
It is very easy to implement other modifications using this as a basis (modifying attributes of entities). | ||
|
||
Requirements: | ||
|
||
```shell | ||
pip install beautifulsoup4 | ||
``` | ||
|
||
## Execution | ||
```shell | ||
python fix_audio_path.py | ||
|
||
Changing file-1.wav to: | ||
/home/audio/file-1.wav | ||
... | ||
``` | ||
|
||
## Source | ||
```python | ||
{% | ||
include-markdown '../../fix_audio_path.py' | ||
rewrite-relative-urls=false | ||
comments=false | ||
%} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
[data-md-color-scheme="default"] { | ||
--md-primary-fg-color: #79018D; | ||
--md-primary-bg-color: #ffffff; | ||
--md-accent-fg-color: #3E64A2; | ||
/* --md-code-bg-color: #3b4252;*/ | ||
} | ||
|
||
[data-md-color-scheme="slate"] { | ||
--md-primary-fg-color: #79018D; | ||
--md-primary-bg-color: #ffffff; | ||
--md-accent-fg-color: #3E64A2; | ||
/* --md-default-fg-color: #d8dee9;*/ | ||
/* --md-default-bg-color: #2e3440;*/ | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (c) 2023 Florian Matter <[email protected]> | ||
# Licensed under the MIT License, see below | ||
|
||
# The file you want to modify. | ||
TARGET = "path/to/my_lexicon.lift" | ||
# The string to be added to a path. | ||
PREFIX = "/path/to/my/audio/" | ||
|
||
from bs4 import BeautifulSoup | ||
with open(TARGET) as fp: | ||
soup = BeautifulSoup(fp, "xml") | ||
for media in soup.find_all("media"): | ||
if "href" in media.attrs: | ||
old = media["href"] | ||
if PREFIX not in old: | ||
new = PREFIX + old | ||
print(f"Changing {old} to:\n{new}") | ||
media["href"] = new | ||
with open(TARGET, "w") as f: | ||
f.write(str(soup)) | ||
|
||
# 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
site_name: FLEx script collection | ||
repo_url: https://github.com/fmatter/flex-script-collection | ||
plugins: | ||
- search | ||
# - mkdocstrings | ||
- include-markdown | ||
extra_css: | ||
- style.css | ||
theme: | ||
name: material | ||
features: | ||
- navigation.instant | ||
- navigation.tracking | ||
# - navigation.tabs | ||
# - navigation.tabs.sticky | ||
- navigation.sections | ||
- toc.follow | ||
- toc.integrate | ||
- content.code.copy | ||
palette: | ||
|
||
# Palette toggle for light mode | ||
- scheme: default | ||
primary: custom | ||
accent: custom | ||
toggle: | ||
icon: material/brightness-7 | ||
name: Switch to dark mode | ||
|
||
# Palette toggle for dark mode | ||
- scheme: slate | ||
primary: custom | ||
accent: custom | ||
toggle: | ||
icon: material/brightness-4 | ||
name: Switch to light mode | ||
|
||
markdown_extensions: | ||
- pymdownx.highlight: | ||
anchor_linenums: true | ||
line_spans: __span | ||
pygments_lang_class: true | ||
# pygments_style: railscast | ||
noclasses: true | ||
- pymdownx.inlinehilite | ||
- pymdownx.snippets | ||
- pymdownx.superfences |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
mkdocs | ||
pymdown-extensions | ||
mkdocs-material | ||
mkdocs-include-markdown-plugin | ||
beautifulsoup4 |