Page MenuHomec4science

bibconvert.in
No OneTemporary

File Metadata

Created
Thu, Sep 26, 04:41

bibconvert.in

## $Id$
## This file is part of the CERN Document Server Software (CDSware).
## Copyright (C) 2002, 2003, 2004, 2005 CERN.
##
## The CDSware is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## The CDSware is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDSware; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
## read config variables:
#include "config.wml"
#include "configbis.wml"
#include "cdswmllib.wml"
## start Python:
<protect>#!</protect><PYTHON>
<protect>## $Id$</protect>
<protect>## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDSware WML SOURCES.</protect>
"""BibConvert tool to convert bibliographic records from any format to any format."""
__version__ = "<: print generate_pretty_version_string('$Id$'); :>"
## okay, rest of the Python code goes below
#######
pylibdir = "<LIBDIR>/python"
try:
import fileinput
import string
import os
import re
import sys
import time
import getopt
from time import gmtime, strftime, localtime
import os.path
except ImportError, e:
print "Error: %s" % e
import sys
sys.exit(1)
try:
sys.path.append('%s' % pylibdir)
from cdsware.search_engine import perform_request_search
from cdsware.config import *
from cdsware import bibconvert
except ImportError, e:
print "Error: %s" % e
sys.exit(1)
<protect>
### MAIN ###
ar_ = []
conv_setting = bibconvert.set_conv()
sysno = bibconvert.generate("DATE(%w%H%M%S)")
sysno500 = bibconvert.generate("DATE(%w%H%M%S)")
separator = ""
tcounter = 0
source_data = ""
query_string = ""
match_mode = -1
begin_record_header = ""
ending_record_footer = ""
output_rec_sep = ""
begin_header = ""
ending_footer = ""
oai_identifier_from = 1
opts, args = getopt.getopt(sys.argv[1:],"c:d:hVl:o:b:e:B:E:s:m:C:",
[
"config",
"directory",
"help",
"version",
"length",
"oai",
"header",
"footer",
"record-header",
"record-footer",
"separator",
"match",
"config-alt"
])
# get options and arguments
dirmode = 0
Xcount = 0
for opt, opt_value in opts:
if opt in ["-c", "--config"]:
extract_tpl = opt_value
extract_tpl_parsed = bibconvert.parse_common_template(extract_tpl,1)
source_tpl = opt_value
source_tpl_parsed = bibconvert.parse_common_template(source_tpl,2)
target_tpl = opt_value
target_tpl_parsed = bibconvert.parse_common_template(target_tpl,3)
elif opt in ["-d", "--directory"]:
source_data = opt_value
source_data = source_data + "/"
extract_tpl = "/"
extract_tpl_parsed = None # FIXME: option -d shouldn't require -Cx
dirmode = 1
elif opt in ["-h", "--help"]:
bibconvert.printInfo()
sys.exit(0)
elif opt in ["-V", "--version"]:
print __version__
sys.exit(0)
elif opt in ["-l", "--length"]:
try:
conv_setting[0] = string.atoi(opt_value)
except ValueError, e:
conv_setting[0] = 1
elif opt in ["-o", "--oai"]:
try:
oai_identifier_from = string.atoi(opt_value)
except ValueError, e:
oai_identifier_from = 1
elif opt in ["-b", "--header"]:
begin_header = opt_value
elif opt in ["-e", "--footer"]:
ending_footer = opt_value
elif opt in ["-B", "--record-header"]:
begin_record_header = opt_value
elif opt in ["-E", "--record-footer"]:
ending_record_footer = opt_value
elif opt in ["-s", "--separator"]:
separator = opt_value
elif opt in ["-t", "--output_separator"]:
output_rec_sep = opt_value
elif opt in ["-m", "--match"]:
match_mode = string.atoi(opt_value[0:1])
query_string = opt_value[1:]
elif opt in ["-C", "--config-alt"]:
if opt_value[0:1] == "x":
extract_tpl = opt_value[1:]
extract_tpl_parsed = bibconvert.parse_template(extract_tpl)
if opt_value[0:1] == "t":
target_tpl = opt_value[1:]
target_tpl_parsed = bibconvert.parse_template(target_tpl)
if opt_value[0:1] == "s":
source_tpl = opt_value[1:]
source_tpl_parsed = bibconvert.parse_template(source_tpl)
ar_.append(dirmode)
ar_.append(Xcount)
ar_.append(conv_setting)
ar_.append(sysno)
ar_.append(sysno500)
ar_.append(separator)
ar_.append(tcounter)
ar_.append(source_data)
ar_.append(query_string)
ar_.append(match_mode)
ar_.append(begin_record_header)
ar_.append(ending_record_footer)
ar_.append(output_rec_sep)
ar_.append(begin_header)
ar_.append(ending_footer)
ar_.append(oai_identifier_from)
ar_.append(source_tpl)
ar_.append(source_tpl_parsed)
ar_.append(target_tpl)
ar_.append(target_tpl_parsed)
ar_.append(extract_tpl)
ar_.append(extract_tpl_parsed)
bibconvert.convert(ar_)
</protect>

Event Timeline