diff --git a/README.md b/README.md index bbe0838..388ea54 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,18 @@ Create / edit codeplug source files under [`/input`](/input). If multiple subdirectories exist under `/input`, then multiple codeplugs will be generated. +The [`default`](./input/default) directory contains the example codeplug +input files along with 2 scripts: + + * [`generate.sh`](./input/default/generate.sh) builds the codeplug with a + standard bash shell command. + * [`generate.py`](./input/default/generate.py) builds the same codeplug + using python code. + +Derivative codeplugs don't need to include both scripts. Use the format +that is most familiar. While the sample scripts show identical functionality, +the python code could be extended to hack at the generation process itself. + ### See [dzcb README.md](https://github.com/mycodeplug/dzcb#dzcb) for more information on input files and formats. ## Generating @@ -51,14 +63,20 @@ for step-by-step instructions. * Copy templates from [default-tyt-md380](https://github.com/mycodeplug/dzcb/blob/main/codeplug/default-tyt-md380) for monoband variants. + * [`example-d878uv.conf`](./input/default/example-d878uv.conf): + set your Radio ID and Radio Name + * See README and templates in + [dmrconfig](https://github.com/mycodeplug/dzcb/blob/main/src/dzcb/data/dmrconfig) + for more information and other radio types. * [`k7abd`](./input/default/k7abd): manually defined zones in K7ABD anytone-config-builder format. See N7EKB's [`cps-import-builder` reference data files](https://github.com/n7ekb/cps-import-builder/tree/main/reference_data_files/N7EKB_shared_files) for more examples. - * [`order.json`](./input/default/order.json): preferred zone order, - zone exclusion, preferred talkgroup order + * [`order.csv`](./input/default/order.csv): preferred zone, contact, channel order + * [`exclude.csv`](./input/default/exclude.csv): zone, contact, channel exclude + * [`replacements.csv`](./input/default/replacements.csv): object name replacements (regex) * [`scanlists.json`](./input/default/scanlists.json): additional scanlists - * [`generate.sh`](./input/default/generate.sh): options passed to `dzcb` (whether + * [`generate.py`](./input/default/generate.py): options passed to `dzcb` (whether to include PNWDigital, SeattleDMR, default files, etc) * [`prox.csv`](./input/default/prox.csv): customize points of interest, distances, and desired bands @@ -71,11 +89,21 @@ for step-by-step instructions. #### Requirements -* linux or macOS (windows not yet supported) -* python 3.5+ (python 3.8 recommended) +* linux, macOS, windows +* python 3.6+ (python 3.8 recommended) * [tox](https://tox.readthedocs.io/en/latest/) +#### Build + +To output to a specific directory, set the `OUTPUT` environment variable. + ``` pip install tox tox ``` + +To run the `generate.sh` shell scripts + +``` +tox -e shell +``` diff --git a/input/default/example-d878uv.conf b/input/default/example-d878uv.conf new file mode 100644 index 0000000..dd0aec5 --- /dev/null +++ b/input/default/example-d878uv.conf @@ -0,0 +1,25 @@ +# +# mycodeplug/example-codeplug generated $ISODATE +# by dzcb (https://github.com/mycodeplug/dzcb) +# +# !dzcb.ranges: 136-174,400-480 +Radio: Anytone AT-D878UV + +# Table of text messages. +# 1) Message number: 1-100 +# 2) Text: up to 200 characters +# +Message Text + 1 Hello + 2 Thank you + 3 73 + 4 QTH? + 5 Test message + +# Unique DMR ID and name of this radio. +ID: 12345678 +Name: AA1AA + +# Text displayed when the radio powers up. +Intro Line 1: $DATE +Intro Line 2: PNWDigital diff --git a/input/default/example-md-uv380.json b/input/default/example-md-uv380.json index 7170ce3..7ef071e 100644 --- a/input/default/example-md-uv380.json +++ b/input/default/example-md-uv380.json @@ -171,7 +171,7 @@ "GroupCallHangTime": "3000", "GroupCallMatch": "On", "IntroScreen": "Character String", - "IntroScreenLine1": "2021/01/01", + "IntroScreenLine1": "$DATE", "IntroScreenLine2": "PNWDigital", "KeypadTones": "Off", "LoneWorkerReminderTime": "10", diff --git a/input/default/exclude.csv b/input/default/exclude.csv new file mode 100644 index 0000000..edcb189 --- /dev/null +++ b/input/default/exclude.csv @@ -0,0 +1,22 @@ +Channels,Contacts,Zones +"MM/Peter 430","Kitsap CARC", +"MM/Wes 430","Wash ARES", +"Coeur d'Alene","Idaho ARES 2", +"Lewiston ID","SoCal 2", +"Poteros/Goat Mtn","Utah 2", +"Prineville/Town",, +"Saint Maries ID",, +"Sultan/Haystack",, +"BC:Whisler/Black",, +"BC:NewWstmnstr",, +"BC:Vancouver/Sey",, +"BC:Squamish",, +"BC:W.Vancvr/Ambl",, +"Tulalip/Tulalip",, +"Gresham/Hospital",, +"BM Port Townsend",, +"CC Port Angeles",, +"CC Sequim",, +"Sequim KC7EQO",, +"BM Ferndale",, +"BM Scappoose",, diff --git a/input/default/generate.py b/input/default/generate.py new file mode 100755 index 0000000..282ee91 --- /dev/null +++ b/input/default/generate.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python3 + +# This generates the same codeplug as generate.sh +# using python code. + +from pathlib import Path +import os + +from dzcb.recipe import CodeplugRecipe + +cp_dir = Path(__file__).parent +output = Path(os.environ.get("OUTPUT") or (cp_dir / ".." / ".." / "OUTPUT")) + +CodeplugRecipe( + source_pnwdigital=True, + source_seattledmr=True, + source_default_k7abd=True, + source_k7abd=[(cp_dir / "k7abd")], + source_repeaterbook_proximity=cp_dir / "prox.csv", + repeaterbook_states=["washington", "oregon"], + repeaterbook_name_format='{Callsign} {Nearest City} {Landmark}', + scanlists_json=cp_dir / "scanlists.json", + exclude=cp_dir / "exclude.csv", + order=cp_dir / "order.csv", + replacements=cp_dir / "replacements.csv", + output_anytone=True, + output_dmrconfig=[(cp_dir / "example-d878uv.conf")], + output_farnsworth=[(cp_dir / "example-md-uv380.json")], + output_gb3gf=True +).generate(output / cp_dir.name) diff --git a/input/default/generate.sh b/input/default/generate.sh index 886ac30..adea950 100755 --- a/input/default/generate.sh +++ b/input/default/generate.sh @@ -1,15 +1,24 @@ #!/usr/bin/env bash +# This generates the same codeplug as generate.py +# using bash scripting. Linux or macOS only. + DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" OUTPUT=${OUTPUT:-$DIR/../../OUTPUT} python -m dzcb \ --pnwdigital \ --seattledmr \ --default-k7abd \ - --repeaterbook-state washington oregon \ - --repeaterbook-proximity-csv "$DIR/prox.csv" \ --k7abd $DIR/k7abd \ - --farnsworth-template-json "$DIR/example-md-uv380.json" \ + --repeaterbook-proximity-csv "$DIR/prox.csv" \ + --repeaterbook-state washington oregon \ + --repeaterbook-name-format '{Callsign} {Nearest City} {Landmark}' \ --scanlists-json "$DIR/scanlists.json" \ - --order-json "$DIR/order.json" \ -$OUTPUT/$(basename "$DIR") + --exclude "$DIR/exclude.csv" \ + --order "$DIR/order.csv" \ + --replacements "$DIR/replacements.csv" \ + --anytone \ + --dmrconfig "$DIR/example-d878uv.conf" \ + --farnsworth-template-json "$DIR/example-md-uv380.json" \ + --gb3gf \ +-- "$OUTPUT/$(basename "$DIR")" diff --git a/input/default/k7abd/Digital-Repeaters__Hotspot.csv b/input/default/k7abd/Digital-Repeaters__Hotspot.csv index 55ada12..a6b2a50 100644 --- a/input/default/k7abd/Digital-Repeaters__Hotspot.csv +++ b/input/default/k7abd/Digital-Repeaters__Hotspot.csv @@ -1,3 +1,3 @@ -Zone Name,Comment,Power,RX Freq,TX Freq,Color Code,CNJHam,Colorado Mega,CO Skyhub,Illinois-Link,Olympic P,Oregon 1,Oregon TAC,PNW Rgnl,Quadnet Array,Reddit,TAC 310-2,TAC 311-2,TAC 312-2,Texas,Washington 1,Worldwide -DPHS Static;DHS,Static Tgs,Low,430.4375,439.4375,1,-,-,-,-,2,1,2,2,-,2,-,-,-,-,1,- -DPHS Wide;DHW,Dynamic Tgs,Low,430.4375,439.4375,1,2,2,2,2,-,-,-,-,2,2,2,2,2,2,-,2 +Zone Name,Comment,Power,RX Freq,TX Freq,Color Code,CNJHam,Colorado Mega,CO Skyhub,Illinois-Link,Olympic P,Oregon 1,Oregon TAC,PNW Rgnl,Quadnet Array,Reddit,Parrot BM,TAC 310-2,TAC 311-2,TAC 312-2,Texas,Washington 1,Worldwide +DPHS Static;DHS,Static Tgs,Low,430.4375,439.4375,1,-,-,-,-,2,1,2,2,-,2,2,-,-,-,-,1,- +DPHS Wide;DHW,Dynamic Tgs,Low,430.4375,439.4375,1,2,2,2,2,-,-,-,-,2,2,2,2,2,2,2,-,2 diff --git a/input/default/k7abd/Digital-Repeaters__Washington.csv b/input/default/k7abd/Digital-Repeaters__Washington.csv new file mode 100644 index 0000000..912abf3 --- /dev/null +++ b/input/default/k7abd/Digital-Repeaters__Washington.csv @@ -0,0 +1,7 @@ +Zone Name,Comment,Power,RX Freq,TX Freq,Color Code,California,Emcom US,Kitsap CARC,Olympic P,Oregon 1,Oregon TAC,PNW Rgnl,TAC 310,TAC 311,TAC 312,TG 2,TG 9,Washington 1,Wash ARES +BM Port Townsend;BPT,W7JCR,High,443.825,448.825,1,2,2,1,1,2,1,1,1,1,1,1,1,2,1 +CC Port Angeles;CPA,W7FW,High,442.125,447.125,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1 +CC Sequim;CSQ,K6MBY,High,440.75,445.75,1,1,1,2,1,1,1,1,1,1,1,1,1,2,1 +Sequim KC7EQO;SQK,KC7EQO,High,442.1,447.1,1,1,1,2,1,1,1,1,1,1,1,1,1,2,1 +BM Ferndale;BFD,W7ECG,High,440.7375,445.7375,1,-,1,-,-,1,-,2,1,1,1,1,1,1,1 +BM Scappoose;BSC,AA7BG,High,441.8625,446.8625,1,-,2,-,-,1,2,2,1,1,1,1,2,1,- diff --git a/input/default/k7abd/Talkgroups__Hotspot.csv b/input/default/k7abd/Talkgroups__Hotspot.csv index 00fd587..928b6a4 100644 --- a/input/default/k7abd/Talkgroups__Hotspot.csv +++ b/input/default/k7abd/Talkgroups__Hotspot.csv @@ -8,6 +8,7 @@ Oregon TAC,31410 PNW Rgnl,31771 Quadnet Array,31012 Reddit,98003 +Parrot BM,9990P TAC 310-2,310 TAC 311-2,311 TAC 312-2,312 diff --git a/input/default/k7abd/Talkgroups__Washington.csv b/input/default/k7abd/Talkgroups__Washington.csv new file mode 100644 index 0000000..14684f1 --- /dev/null +++ b/input/default/k7abd/Talkgroups__Washington.csv @@ -0,0 +1,16 @@ +California,3106 +Emcom US,9911 +Kitsap CARC,311429 +Local 1,3181 +Olympic P,31531 +Oregon 1,3141 +Oregon TAC,31410 +PNW Rgnl,31771 +TAC 310,310 +TAC 311,311 +TAC 312,312 +TG 2,2 +TG 9,9 +Washington 1,3153 +Wash ARES,31538 +Simplex 99,99 diff --git a/input/default/order.csv b/input/default/order.csv new file mode 100644 index 0000000..b37bf92 --- /dev/null +++ b/input/default/order.csv @@ -0,0 +1,11 @@ +zones,contacts,channels +PNWDigital,Oregon 1,Rainier Hill +Hotspot,Washington 1,DPHS Static +Local,Washington 2,DPHS Wide +SeattleDMR,Cascades 1, +Longview WA VHF 35mi,Local 1, +Longview WA UHF 35mi,Local 2, +Simplex A VHF,Parrot 1, +Simplex A UHF,, +Simplex D VHF,, +Simplex D UHF,, diff --git a/input/default/order.json b/input/default/order.json deleted file mode 100644 index 4c6d82e..0000000 --- a/input/default/order.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "zone": { - "default": [ - "PNWDigital", - "Hotspot", - "Local", - "SeattleDMR", - "Longview WA VHF 35mi", - "Longview WA UHF 35mi", - "Simplex A VHF", - "Simplex A UHF", - "Simplex D VHF", - "Simplex D UHF" - ], - "expanded": [ - "Longview/Rainier", - "DPHS Static", - "DPHS Wide", - "Longview WA VHF 35mi", - "Longview WA UHF 35mi", - "Simplex A VHF", - "Simplex A UHF", - "Simplex D VHF", - "Simplex D UHF" - ], - "exclude_expanded": [ - "PNWDigital", - "Hotspot", - "Local", - "SeattleDMR" - ] - }, - "static_talkgroup": [ - "Oregon 1", - "Washington 1", - "Washington 2", - "Cascades 1", - "Local 1", - "Local 2", - "Parrot 1" - ] -} diff --git a/input/default/replacements.csv b/input/default/replacements.csv new file mode 100644 index 0000000..ef48aa5 --- /dev/null +++ b/input/default/replacements.csv @@ -0,0 +1,3 @@ +Channels_pattern,Channels_repl,Zones_pattern,Zones_repl,Contacts_pattern,Contacts_repl, +Oregon,OR,Longview/Rainier,Rainier Hill,,, +Washington,WA,,,,, diff --git a/input/default/scanlists.json b/input/default/scanlists.json index 22f9858..3f90e0f 100644 --- a/input/default/scanlists.json +++ b/input/default/scanlists.json @@ -3,18 +3,19 @@ "Longview/Rainier", "DPHS Static", "DPHS Wide", - "Oregon 1 LVR", - "Washington 2 LVR", - "W7DG Longview 1", + "OR 1 LVR", + "WA 2 LVR", + "W7DG Longview1", + "W7DG Longview Co", "N7EI Deer Island", - "W7BU Astoria Ni1", - "W7BU Astoria Wi1", - "K7RPT Astoria W1", - "KJ7IY Timber ", - "WA7UHD Chehalis ", - "W7DG Longview ", + "W7BU Astoria Nic", + "W7BU Astoria Wic", + "K7RPT Astoria Wi", + "KJ7IY Timber", + "WA7UHD Chehalis", + "W7DG Longview", "N3EG Longview Co", - "AB7F Longview ", + "AB7F Longview", "W7OTV Colton Goa", "SP U01 441.000", "SP U02 446.5", diff --git a/input/generate_all.py b/input/generate_all.py new file mode 100755 index 0000000..493b02c --- /dev/null +++ b/input/generate_all.py @@ -0,0 +1,13 @@ +#!/usr/bin/env python3 + +# execute all generate.py files in subdirectories of this +# scripts directory + +from pathlib import Path +import subprocess +import sys + +cp_dir = Path(__file__).parent + +for genpy in cp_dir.glob("**/generate.py"): + subprocess.check_call([sys.executable, genpy]) diff --git a/input/generate_all.sh b/input/generate_all.sh new file mode 100755 index 0000000..d4d93da --- /dev/null +++ b/input/generate_all.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# execute all generate.sh files in subdirectories of this +# scripts directory (posix-like only) + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" + +if find --version 2>/dev/null | grep "GNU findutils" > /dev/null; then + FIND_OPTS="-executable" +else + FIND_OPTS="-perm +111" +fi + +find $DIR \ + -name "generate.sh" \ + $FIND_OPTS -print0 | \ +xargs -0 -n 1 bash diff --git a/tox.ini b/tox.ini index 0c71c50..464314c 100644 --- a/tox.ini +++ b/tox.ini @@ -2,22 +2,16 @@ minversion = 3.7.0 skipsdist = true allowlist_external = /usr/bin/env -envlist = py3-{linux,mac} +envlist = py3 [testenv] -platform = - linux: linux - mac: darwin passenv = OUTPUT -setenv = - !mac: FIND_OPTS = -executable - mac: FIND_OPTS = -perm '+111' deps = - dzcb~=0.2.0 + dzcb~=0.3.0 commands = - /usr/bin/env bash -c " \ - find {toxinidir}/input \ - -name "generate.sh" \ - {env:FIND_OPTS} -print0 | \ - xargs -0 -n 1 bash \ - " + python {toxinidir}/input/generate_all.py + +[testenv:shell] +platform = linux|darwin +commands = + {toxinidir}/input/generate_all.sh