# Path: bibstuff/bibstyles/default_templates.py
# DEFAULT_CITATION_TEMPLATE = dict(
# book = '(%(year)s) *%(title)s*. %(address)s: %(publisher)s.',
# article  = '%(year)s. %(title)s. *%(journal)s* %(volume)s, %(pages)s.',
# techreport  = '(%(year)s) "%(title)s". %(institution)s %(type)s %(number)s. %(url)s',
# inproceedings  = '(%(year)s) "%(title)s". In %(editor)s (Eds.) *%(booktitle)s*, %(address)s: %(publisher)s.',
# incollection  = '(%(year)s) "%(title)s". In %(editor)s (Eds.) *%(booktitle)s*, %(address)s: %(publisher)s.',
# misc = '%(year)s.  %(title)s.',
# default_type = '  %(year)s. %(title)s.',
# name_first = 'v |l,| j,| f',
# name_other = 'f |v |l|, j',
# name_name_sep = (', ',', and '),
# etal = ', et al.',
# initials = '',
# max_citation_names = 3,
# indent_left = 3,
# citation_sep = "\n\n",
# names_details_sep = '. ',
# post_processor = default_post_processor
# )


import logging, re
import simpleparse
import simpleparse.dispatchprocessor
from .default_templates import DEFAULT_CITATION_TEMPLATE

		:note: parsing a name template into a partdict is trivial, so just do it here
		:note: allow capital part id (to force capitalization)
		"""
		#to keep track of the order of the parts...
		parts_order = ''
		#split a name template into parts (each part shd have part-designator)
		template_parts = template.split('|')
		partdict = {}
		for part in template_parts:
			for partid in 'FVLJfvlj':
				if partid in part:
					parts_order += partid
					pre, temp = part.split(partid)
					if temp and temp[0] == '{':   #found a partsep
						partsep,post = temp[1:].split('}')
					else:
						post = temp
						partsep = self.default_partsep
					partdict[partid] = dict(pre=pre,post=post,partsep=partsep)
					break
		shared_logger.debug("template2dict: name formatting template parsed to:\n"+str(partdict))
		partdict['parts_order'] = parts_order
		return partdict


class CitationManager(object):
	"""
	:TODO: possibly useful for bibsearch.py
	"""

# Path: bibstuff/bibstyles/default_templates.py
# DEFAULT_CITATION_TEMPLATE = dict(
# book = '(%(year)s) *%(title)s*. %(address)s: %(publisher)s.',
# article  = '%(year)s. %(title)s. *%(journal)s* %(volume)s, %(pages)s.',
# techreport  = '(%(year)s) "%(title)s". %(institution)s %(type)s %(number)s. %(url)s',
# inproceedings  = '(%(year)s) "%(title)s". In %(editor)s (Eds.) *%(booktitle)s*, %(address)s: %(publisher)s.',
# incollection  = '(%(year)s) "%(title)s". In %(editor)s (Eds.) *%(booktitle)s*, %(address)s: %(publisher)s.',
# misc = '%(year)s.  %(title)s.',
# default_type = '  %(year)s. %(title)s.',
# name_first = 'v |l,| j,| f',
# name_other = 'f |v |l|, j',
# name_name_sep = (', ',', and '),
# etal = ', et al.',
# initials = '',
# max_citation_names = 3,
# indent_left = 3,
# citation_sep = "\n\n",
# names_details_sep = '. ',
# post_processor = default_post_processor
# )


# Path: bibstuff/bibstyles/shared.py
import logging, re
import simpleparse
import simpleparse.dispatchprocessor
from .default_templates import DEFAULT_CITATION_TEMPLATE


		:note: parsing a name template into a partdict is trivial, so just do it here
		:note: allow capital part id (to force capitalization)
		"""
		#to keep track of the order of the parts...
		parts_order = ''
		#split a name template into parts (each part shd have part-designator)
		template_parts = template.split('|')
		partdict = {}
		for part in template_parts:
			for partid in 'FVLJfvlj':
				if partid in part:
					parts_order += partid
					pre, temp = part.split(partid)
					if temp and temp[0] == '{':   #found a partsep
						partsep,post = temp[1:].split('}')
					else:
						post = temp
						partsep = self.default_partsep
					partdict[partid] = dict(pre=pre,post=post,partsep=partsep)
					break
		shared_logger.debug("template2dict: name formatting template parsed to:\n"+str(partdict))
		partdict['parts_order'] = parts_order
		return partdict


class CitationManager(object):
	"""
	:TODO: possibly useful for bibsearch.py
	"""

	default_citation_template = DEFAULT_CITATION_TEMPLATE.copy()