# Path: bibstuff/bibadd.py
# def make_entry(choosetype='', options=False, extras=False):
# def make_entry_citekey(entry, used_citekeys,style=label_style1):
# def is_macro(s):
# def text_format(entry):
# def get_journal(entry, jrnl_lst=None): #TODO: extract fr journal list
# def get_volnum(entry):
# def get_pages(entry,dash='--',pagespref=('p. ','pp. ')):
# def html_format(entry):


import os
import sys
import shutil
import logging
from bibstuff.bibadd import (bibadd_logger, make_entry, html_format, text_format)
	from optparse import OptionParser

	 
	bibfile_name = args[-1]
	if (os.path.splitext(bibfile_name)[-1]).lower() != ".bib":
		bib4txt_logger.warning(bibfile_name + " does not appear to be a .bib file")
	try :
		bibfile_as_string = open(bibfile_name,'r').read()
	except :
		print "Database file not found."
		sys.exit(1)

	# read input file (default: stdin)
	if options.infile:
		try:
			input = open(options.infile,'r')
		except:
			print "Cannot open: "+options.infile
			sys.exit(1)

	# create object to store parsed .bib file
	bibfile_processor = bibfile.BibFile()
	#store parsed .bib file in the bibfile_processor
	#  TODO: allow multiple .bib files
	bibgrammar.Parse(bibfile_as_string, bibfile_processor)

	bfile = bibfile.BibFile()
	bibgrammar.Parse(src, bfile)
	used_citekeys = [] # stores created keys
	'''


# Path: bibstuff/bibadd.py
# def make_entry(choosetype='', options=False, extras=False):
# def make_entry_citekey(entry, used_citekeys,style=label_style1):
# def is_macro(s):
# def text_format(entry):
# def get_journal(entry, jrnl_lst=None): #TODO: extract fr journal list
# def get_volnum(entry):
# def get_pages(entry,dash='--',pagespref=('p. ','pp. ')):
# def html_format(entry):


# Path: scripts/add2bib.py
import os
import sys
import shutil
import logging
from bibstuff.bibadd import (bibadd_logger, make_entry, html_format, text_format)
	from optparse import OptionParser


	 
	bibfile_name = args[-1]
	if (os.path.splitext(bibfile_name)[-1]).lower() != ".bib":
		bib4txt_logger.warning(bibfile_name + " does not appear to be a .bib file")
	try :
		bibfile_as_string = open(bibfile_name,'r').read()
	except :
		print "Database file not found."
		sys.exit(1)

	# read input file (default: stdin)
	if options.infile:
		try:
			input = open(options.infile,'r')
		except:
			print "Cannot open: "+options.infile
			sys.exit(1)

	# create object to store parsed .bib file
	bibfile_processor = bibfile.BibFile()
	#store parsed .bib file in the bibfile_processor
	#  TODO: allow multiple .bib files
	bibgrammar.Parse(bibfile_as_string, bibfile_processor)

	bfile = bibfile.BibFile()
	bibgrammar.Parse(src, bfile)
	used_citekeys = [] # stores created keys
	'''


	entry = make_entry(options.entry_type, options.more_fields, options.MORE_FIELDS)