[sword-svn] r496 - trunk/modules/conf

refdoc at crosswire.org refdoc at crosswire.org
Mon Jul 13 13:33:38 MST 2015


Author: refdoc
Date: 2015-07-13 13:33:38 -0700 (Mon, 13 Jul 2015)
New Revision: 496

Modified:
   trunk/modules/conf/confmaker.pl
Log:
improved confmaking script somewhat more


Modified: trunk/modules/conf/confmaker.pl
===================================================================
--- trunk/modules/conf/confmaker.pl	2015-07-13 13:00:23 UTC (rev 495)
+++ trunk/modules/conf/confmaker.pl	2015-07-13 20:33:38 UTC (rev 496)
@@ -46,9 +46,10 @@
 ## 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 @@
        @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,10 +98,26 @@
 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
 
 my @doc_features = ('title', 'note', 'reference', 'q', 'figure', 'rdg');
@@ -183,12 +215,12 @@
       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";
 
 }




More information about the sword-cvs mailing list