Changeset 22
- Timestamp:
- 09/21/07 14:53:17 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bibopa.sh
r21 r22 5 5 # Dipole on the East African Short Rains: A CGCM Study, J. Climate, In 6 6 # press. 7 # 7 # 8 8 # donnerait 9 # 9 # 10 10 # <biblioentry id="behara2004"> 11 11 # <authorgroup> … … 25 25 # <biblioid class="doi">doi</bibliomisc> 26 26 # <bibliomisc role="pseudoref">In press.</bibliomisc> 27 # <bibliomisc role="internalref">from 27 # <bibliomisc role="internalref">from 28 28 # http://www.lodyc.jussieu.fr/~opatlod/NEMO_v1/6_Menu/2_page/index.html 29 29 # 2007-03-29T16:24:31Z fplod by hand</bibliomisc> 30 30 # </biblioentry> 31 # 31 # 32 32 # 33 33 # example : … … 41 41 # 42 42 # update 43 # ++ gestion des comments 43 # ++ gestion des comments 44 44 # ++ gestion des id existants (cf à la fin) 45 45 # ++ option debug … … 54 54 # comments (line begininig with #) are now possible 55 55 # Sebastien Masson avril 2007 creation 56 # 56 # 57 57 58 58 rmbl () { 59 echo "$ 1" | sed -e "s/^ *//" | sed -e "s/ *$//"59 echo "${1}" | sed -e "s/^ *//" | sed -e "s/ *$//" 60 60 } 61 61 cleanname () { 62 echo "$ 1" | sed -e "s/^ *//" \62 echo "${1}" | sed -e "s/^ *//" \ 63 63 -e "s/^ *,//" \ 64 64 -e "s/^ *;//" \ … … 86 86 usage=" Usage : ${command} -i filein -t type" 87 87 # 88 while [ ! -z "${1}" ] # ++ pb bash 88 minargcount=4 89 echo " narg ${#}" 90 if [ ${#} -lt ${minargcount} ] 91 then 92 echo "eee : not enought arguments" 93 echo "${usage}" 94 exit 1 95 fi 96 # 97 while [ ! -z "${1}" ] 89 98 do 90 99 case ${1} in 91 -i) # filein 100 -i) # filein 92 101 filein=${2} 93 102 shift 94 103 ;; 95 -t) # type 104 -t) # type 96 105 type=${2} 97 106 shift 107 ;; 108 -h) 109 echo "${usage}" 110 exit 0 98 111 ;; 99 112 *) # other choice … … 104 117 shift # next flag 105 118 done 106 # 119 # 107 120 set -u 108 121 # 109 # check for filein 122 # check for filein 110 123 if [ ! -f ${filein} ] 111 124 then … … 130 143 #read a #++ if debug 131 144 ;; 132 *) 145 *) 133 146 echo "eee : type should be raw or mailbody" 134 147 exit 1 … … 242 255 do 243 256 # extract one line 244 245 257 line=$( sed -n ${l}p ${fileraw_strict} ) 246 258 orgline=$( echo ${line} | sed -e "s/--/- -/g" ) … … 267 279 num=$( grep -c "<biblioentry id=\"${refid}_[0-9][0-9]\">" ${fileou} ) 268 280 num=$(( ${num} + 1 )) 269 [ ${num} -le 9 ] && num=0${num} 281 [ ${num} -le 9 ] && num=0${num} 270 282 refid=${refid}_${num} 271 283 272 284 cat <<EOF >> ${fileou} 273 285 <biblioentry id="${refid}"> … … 276 288 --> 277 289 <!-- original text 278 $ orgline290 ${orgline} 279 291 --> 280 292 <authorgroup> 281 293 <author> <personname> <surname>${firstsn}</surname> <firstname>${firstfn}</firstname> </personname> </author> 282 294 EOF 283 295 284 296 ## other authors.. 285 297 previous=${first}, … … 299 311 # 300 312 echo " <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" >> ${fileou} 313 echo " <author> <personname> <surname>${nextsn}</surname> <firstname>${nextfn}</firstname> </personname> </author>" #++debug 301 314 previous=${next}, 302 315 next=${auths##*${previous}} 303 316 304 317 done 305 318 echo " </authorgroup>" >> ${fileou} 306 319 307 320 # end of the line ; after the first : 308 321 endline=${line#*:} 309 322 310 323 ## find the journal 311 324 j=1 312 325 jfound="" 313 326 jlistsize=${#jlist[@]} 314 while [[ $ j -le $jlistsize&& "${jfound}" == "" ]]327 while [[ ${j} -le ${jlistsize} && "${jfound}" == "" ]] 315 328 do 316 ok=$( echo ${endline} | grep -ci "${jlist[j]} *," ) 329 ok=$( echo ${endline} | grep -ci "${jlist[j]} *," ) 317 330 [ $ok -eq 1 ] && jfound="${jlist[j]}" 318 j=$(( $ j+ 1 ))331 j=$(( ${j} + 1 )) 319 332 done 320 if [ "$ jfound" == "" ]333 if [ "${jfound}" == "" ] 321 334 then 322 echo " ERROR Journal not found"335 echo "eee: Journal not found " 323 336 echo "${endline}" 324 337 exit 325 338 fi 326 ## title 339 ## title 327 340 # before the first : 328 341 title=${endline%%${jfound}*} 329 342 title=$( cleanname "${title}" ) 330 343 echo " <title>${title}</title>" >> ${fileou} 331 ## end 344 ## end 332 345 ## end of the line ; after the first ${jfound} 333 346 endline=${endline#*${jfound}} … … 336 349 endline=$( echo ${endline} | sed -e "s/[dD][oO][iI] *\t* *: *\t* */doi:/" ) 337 350 ok=$( echo ${endline} | grep -ic "doi:" ) 338 if [ $ ok-eq 1 ]351 if [ ${ok} -eq 1 ] 339 352 then 340 353 doi=${endline##*doi:} … … 347 360 num=$( echo ${endline} | tr -dc "," | wc -c ) 348 361 case ${num} in 349 1) 362 1) 350 363 ### echo ${num}: ${endline} 351 364 vol=${endline%,*} 352 365 vol=$( cleanname "${vol}" ) 353 pag=${endline##*,} 366 pag=${endline##*,} 354 367 pag=$( cleanname "${pag}" ) 355 368 cat <<EOF >> ${fileou} … … 361 374 EOF 362 375 ;; 363 2) 376 2) 364 377 vol=${endline%,*} 365 378 vol=$( cleanname "${vol}" ) 366 iss=${vol##*,} 379 iss=${vol##*,} 367 380 iss=$( cleanname "${iss}" ) 368 381 vol=${vol%,*} 369 382 vol=$( cleanname "${vol}" ) 370 pag=${endline##*,} 383 pag=${endline##*,} 371 384 pag=$( cleanname "${pag}" ) 372 385 cat <<EOF >> ${fileou} … … 389 402 ;; 390 403 esac 391 404 392 405 cat <<EOF >> ${fileou} 393 406 </biblioentry> 394 395 EOF 396 397 398 399 400 401 l=$(( $ l+ 1 ))402 407 408 EOF 409 410 411 412 413 414 l=$(( ${l} + 1 )) 415 403 416 done 404 417 echo "</bibliography>" >> ${fileou} … … 413 426 # clean 414 427 echo "iii : xml.err contains stderr from the following command " 415 echo "iii : which was done just to check consistence of ${fileou}" 428 echo "iii : which was done just to check consistence of ${fileou}" 416 429 echo "iii : xmlto pdf ${fileou}" 417 430 rm -i xml.err 418 431 case ${type} in 419 raw) 432 raw) 420 433 echo "iii : ${fileraw_strict} contains a copy of input file without comments" 421 434 rm -i ${fileraw_strict}
Note: See TracChangeset
for help on using the changeset viewer.