From feefe5629710084ff78f8de0098001ff09038f59 Mon Sep 17 00:00:00 2001 From: Henry Whitney Date: Thu, 8 Aug 2019 16:06:13 -0400 Subject: [PATCH] Adding needed files --- .../Convert_OHSB_to_MAST_HB.pl | 59 ++++++++++++++ .../Convert_refs_in_MAST_HB.pl | 78 +++++++++++++++++++ .../FilesForUpdates/lupload.sh | 43 ++++++++++ .../FilesForUpdates/mupload.sh | 44 +++++++++++ 4 files changed, 224 insertions(+) create mode 100644 MAST_tW_PDF_Updater/FilesForUpdates/Convert_OHSB_to_MAST_HB.pl create mode 100644 MAST_tW_PDF_Updater/FilesForUpdates/Convert_refs_in_MAST_HB.pl create mode 100644 MAST_tW_PDF_Updater/FilesForUpdates/lupload.sh create mode 100644 MAST_tW_PDF_Updater/FilesForUpdates/mupload.sh diff --git a/MAST_tW_PDF_Updater/FilesForUpdates/Convert_OHSB_to_MAST_HB.pl b/MAST_tW_PDF_Updater/FilesForUpdates/Convert_OHSB_to_MAST_HB.pl new file mode 100644 index 0000000..63082e5 --- /dev/null +++ b/MAST_tW_PDF_Updater/FilesForUpdates/Convert_OHSB_to_MAST_HB.pl @@ -0,0 +1,59 @@ +# Step 1 in updating OSHB to MAST_HB +# Converts file names and internal verse refs to WA MAST abbreviations +# After this need to run Convert_refs_in_MAST_HB.pl to get data in file to conform + +while () { + if (/([^\t]*)\t([^\t]*)/) { + #($oldName, $newName) = ($1, $2); + $new_name{$1} = $2 + } +} + +chdir "/Users/Henry/Documents/git.Door43/MAST_HB"; + +foreach $old_name (sort keys %new_name) { + system "mv $old_name $new_name{$old_name}" +} + +print "Done.\n" + +__DATA__ +Gen.xml 01-GEN.xml +Exod.xml 02-EXO.xml +Lev.xml 03-LEV.xml +Num.xml 04-NUM.xml +Deut.xml 05-DEU.xml +Josh.xml 06-JOS.xml +Judg.xml 07-JDG.xml +Ruth.xml 08-RUT.xml +1Sam.xml 09-1SA.xml +2Sam.xml 10-2SA.xml +1Kgs.xml 11-1KI.xml +2Kgs.xml 12-2KI.xml +1Chr.xml 13-1CH.xml +2Chr.xml 14-2CH.xml +Ezra.xml 15-EZR.xml +Neh.xml 16-NEH.xml +Esth.xml 17-EST.xml +Job.xml 18-JOB.xml +Ps.xml 19-PSA.xml +Prov.xml 20-PRO.xml +Eccl.xml 21-ECC.xml +Song.xml 22-SNG.xml +Isa.xml 23-ISA.xml +Jer.xml 24-JER.xml +Lam.xml 25-LAM.xml +Ezek.xml 26-EZK.xml +Dan.xml 27-DAN.xml +Hos.xml 28-HOS.xml +Joel.xml 29-JOL.xml +Amos.xml 30-AMO.xml +Obad.xml 31-OBA.xml +Jonah.xml 32-JON.xml +Mic.xml 33-MIC.xml +Nah.xml 34-NAM.xml +Hab.xml 35-HAB.xml +Zeph.xml 36-ZEP.xml +Hag.xml 37-HAG.xml +Zech.xml 38-ZEC.xml +Mal.xml 39-MAL.xml diff --git a/MAST_tW_PDF_Updater/FilesForUpdates/Convert_refs_in_MAST_HB.pl b/MAST_tW_PDF_Updater/FilesForUpdates/Convert_refs_in_MAST_HB.pl new file mode 100644 index 0000000..793cb9a --- /dev/null +++ b/MAST_tW_PDF_Updater/FilesForUpdates/Convert_refs_in_MAST_HB.pl @@ -0,0 +1,78 @@ +# Converts internal verse refs to WA MAST abbreviations +use 5.12.0; +use File::Slurp; +use File::Find ; +use Cwd ; +use utf8; +#use open IN => ":utf8", OUT => ":utf8"; +use open IO => ":utf8"; + +my ($oldName, $newName); +my $topDir = "/Users/Henry/Documents/git.Door43/MAST_HB"; +my (%new_name); + +while () { + chomp; + if (/([^\t]*)\t([^\t]*)/) { + ($oldName, $newName) = ($1, lc $2); + $new_name{$1} = lc $2 + } +} + + +my @filesToRun = (); +my $filePattern = '*.xml' ; +find( sub { push @filesToRun, $File::Find::name if ( m/^(.*)$filePattern$/ ) }, $topDir) ; + +foreach my $file ( @filesToRun ) { + say $file; + my $fileText = read_file("$file", binmode => 'utf8'); + foreach my $key (sort keys %new_name) { + $fileText =~ s/(osisID=")$key(\.\d+\.\d+")/$1$new_name{$key}$2/g; + } + open(OUT, ">:utf8", "$file") or die "$file:\n$!"; + say OUT $fileText; + close OUT; +} +print "Done.\n" + +__DATA__ +Gen GEN +Exod EXO +Lev LEV +Num NUM +Deut DEU +Josh JOS +Judg JDG +Ruth RUT +1Sam 1SA +2Sam 2SA +1Kgs 1KI +2Kgs 2KI +1Chr 1CH +2Chr 2CH +Ezra EZR +Neh NEH +Esth EST +Job JOB +Ps PSA +Prov PRO +Eccl ECC +Song SNG +Isa ISA +Jer JER +Lam LAM +Ezek EZK +Dan DAN +Hos HOS +Joel JOL +Amos AMO +Obad OBA +Jonah JON +Mic MIC +Nah NAM +Hab HAB +Zeph ZEP +Hag HAG +Zech ZEC +Mal MAL diff --git a/MAST_tW_PDF_Updater/FilesForUpdates/lupload.sh b/MAST_tW_PDF_Updater/FilesForUpdates/lupload.sh new file mode 100644 index 0000000..0206024 --- /dev/null +++ b/MAST_tW_PDF_Updater/FilesForUpdates/lupload.sh @@ -0,0 +1,43 @@ +Do_it () { + echo + echo "pushing Files for Update" + (cd "/home/henry/Documents/WA_Repo/Tips_and_Hacks/MAST_tW_PDF_Updater/FilesForUpdates"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } + echo + echo "pushing ULB" + (cd "/home/henry/Documents/WA_Repo/en_ulb"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } + echo + echo "pushing UDB" + (cd "/home/henry/Documents/WA_Repo/en_udb"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } + echo + echo "pushing tW" + (cd "/home/henry/Documents/WA_Repo/en_tw"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } + echo + echo "pushing tN" + (cd "/home/henry/Documents/WA_Repo/en_tn"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } +} + +echo +answer=$1 +if [ -z "$answer" ] +then + echo "Commit message needed" +else + echo "Commit message is $answer" + Do_it +fi +echo diff --git a/MAST_tW_PDF_Updater/FilesForUpdates/mupload.sh b/MAST_tW_PDF_Updater/FilesForUpdates/mupload.sh new file mode 100644 index 0000000..bb579bd --- /dev/null +++ b/MAST_tW_PDF_Updater/FilesForUpdates/mupload.sh @@ -0,0 +1,44 @@ +Do_it () { + echo + echo "pushing ULB" + (cd "/Users/Henry/Documents/git.Door43/en_ulb"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } + echo + echo "pushing UDB" + (cd "/Users/Henry/Documents/git.Door43/en_udb"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } + echo + echo "pushing tW" + (cd "/Users/Henry/Documents/git.Door43/en_tw"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } + echo + echo "pushing tN" + (cd "/Users/Henry/Documents/git.Door43/en_tn"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } + echo + echo "pushing Files for Update" + (cd "/Users/Henry/Documents/git.Door43/Tips_and_Hacks/MAST_tW_PDF_Updater/FilesForUpdates"; + git pull + git commit -a -m "$answer" + git push) || { echo 'Could not commit!' >&2; exit 1; } +} + +echo +answer=$1 +if [ -z "$answer" ] +then + echo "Commit message needed" +else + echo "Commit message is $answer" + Do_it +fi +echo +echo