summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter von Kaehne <refdoc@gmx.net>2015-07-13 20:33:38 +0000
committerPeter von Kaehne <refdoc@gmx.net>2015-07-13 20:33:38 +0000
commita2f7635cf896c34ea0083b1ae0bc650441491b8d (patch)
tree36a318e8d2a4eebaed5552a443ee349d0c8e8014
parent96768c0da107497e8c9025abf182ef83604fd396 (diff)
downloadsword-tools-a2f7635cf896c34ea0083b1ae0bc650441491b8d.tar.gz
improved confmaking script somewhat more
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@496 07627401-56e2-0310-80f4-f8cd0041bdcd
-rwxr-xr-xmodules/conf/confmaker.pl42
1 files changed, 37 insertions, 5 deletions
diff --git a/modules/conf/confmaker.pl b/modules/conf/confmaker.pl
index 99b42f8..07268f2 100755
--- a/modules/conf/confmaker.pl
+++ b/modules/conf/confmaker.pl
@@ -46,9 +46,10 @@ binmode (STDOUT,":utf8");
## Obtain arguments
if (scalar(@ARGV) < 1) {
print "\nconfmaker.pl -- - provides a initial conf file for a new module by analysing given OSIS xml file.\n";
- print "Syntax: confmaker.pl <osis XML file> [-o conf-output-file] [-i conf-input-file]\n";
+ print "Syntax: confmaker.pl <osis XML file> [-o conf-output-file] [-i conf-input-file] [-m] \n";
print "- Arguments in braces < > are required. Arguments in brackets [ ] are optional.\n";
print "- If no -o option is specified <STDOUT> is used.\n";
+ print "- if the -m option is used no -i option may be used. -m expects parametres added by other means, e.g. a makefile";
print "- The script can currently produce a valid conf file for OSIS bibles, but not for any other import formats.\n";
exit (-1);
}
@@ -70,6 +71,21 @@ if (@ARGV[$nextarg] eq "-i") {
@inputFile=`cat $inputFileName`;
}
+if (@ARGV[$nextarg] eq "-m") {
+ if ($inputFileName) {
+ print "You can not define both an input file and use the -m option, sorry...\n";
+ exit 1;}
+ $makefile=true;
+ $nextarg +=1;
+ }
+
+if (@ARGV[$nextarg] eq "-l") {
+ $language = "@ARGV[$nextarg+1]";
+ $nextarg += 2;
+ }
+
+
+
my $parser = XML::LibXML->new();
my $doc = $parser->parse_file($file);
@@ -82,8 +98,24 @@ my @elements = $doc->getElementsByTagName('osisText');
my $doc_name = @elements[0]->getAttribute('osisIDWork');
my $doc_type = @elements[0]->getAttribute('osisRefWork');
my $doc_lang = @elements[0]->getAttribute('xml:lang');
+my $doc_lang_name=I18N::LangTags::List::name($doc_lang);
+if ((length($language)==0) && (length($doc_lang_name)==0)) {
+ print STDERR $language."\n", $doc_lang."\n", $doc_lang_name."\n";
+ print STDERR "The language is undefined and no language was given on the commandline !\n";
+ exit;
+ }
+
+if ((length($language)>0) && (length($doc_lang_name)>0)) {
+ print STDERR "The language given on the commandline and the language of the document appear not to agree with each other !\n";
+ exit;
+ }
+
+if ((length($language)>0) && (length($doc_lang_name)==0)) {
+ $doc_lang_name = $language;
+ }
+
##GlobalOptionsFilter - prepare
@@ -183,12 +215,12 @@ if (@inputFile>0) {
print $_;
}
}
-else {
+elsif (!$makefile){
print "Version=1.0\n";
print "History=1.0 First release\n";
print "DistributionLicense=copyrighted. Do not distribute\n";
- print "Description=".$doc_name." Bible in ".I18N::LangTags::List::name($doc_lang)."\n";
- print "About=".$doc_name." Bible in ".I18N::LangTags::List::name($doc_lang)."\n";
- print "LCSH=".$doc_type.".".I18N::LangTags::List::name($doc_lang)."\n";
+ print "Description=".$doc_name." Bible in ".$doc_lang_name."\n";
+ print "About=".$doc_name." Bible in ".$doc_lang_name."\n";
+ print "LCSH=".$doc_type.".".$doc_lang_name."\n";
}