# Path: Pyblio/Autoload.py
# class Loader:
#     def __init__ (self, name, regexp, module,
#                   info = None, data = None):
#     def load (self, key = None):
#     def is_loaded (self):
# def preregister (group, name, module, regexp = None, info = None):
# def register (group, name, data = None):
# def get_by_regexp (group, key):
# def get_by_name (group, name, load = 1):
# def available (group):
# def groups ():
# 
# Path: Pyblio/Fields.py
# def get_formatter (format):
#     def __init__ (self, copy = None, strict = 0):
#                 def clean_entry (f):
#     def format (self, fmt = 'latin1'):
#     def __str__ (self):
#     def __repr__ (self):
#     def match (self, regex):
#     def initials (self, format = None):
#     def __cmp__ (self, other):
#     def __init__ (self, text = ''):
#     def __getitem__ (self, pos):
#     def __setitem__ (self, pos, val):
#     def __len__ (self):
#     def append (self, value):
#     def __str__ (self):
#     def __repr__ (self):
#     def match (self, regex):
#     def __cmp__ (self, other):
#     def __init__ (self, arg = (None, None, None)):
#     def __cmp__ (self, other):
#     def __str__ (self):
#     def format (self, fmt = 'latin1'):
#     def __repr__ (self):
#     def match (self, regex):
#     def asInt (self):
#     def __init__ (self, text):
#     def __str__ (self):
#     def __repr__ (self):
#     def match (self, regex):
#     def __cmp__ (self, other):
#     def format (self, fmt = 'latin1'):
#     def __str__  (self):
#     def __repr__ (self):
#     def __len__  (self):
#     def __getitem__ (self, key):
#     def __init__ (self, url, invalid=False,
# 		  inexact=False, date='', note=''):
#     def set (self, other):
#     def full (self):
#     def parse_full (self, s):
#     def match (self, regex):
#     def __cmp__ (self, other):
#     def __hash__ (self):
#     def __str__ (self):
#     def __repr__ (self):
#     def get_url (self):
#     def __init__ (self, keylist, database = None):
#     def __str__ (self):
#     def __repr__ (self):
#     def match (self, regex):
#     def __cmp__ (self, other):
#     def format (self, fmt = 'latin1'):
# class Author:
# class AuthorGroup:
# class Date:
# class Text:
# class LongText (Text) :
# class URL:
# class Reference:
# 
# Path: Pyblio/Style/Utils.py
# def generate (style_url, format, database, keys, output):


import string
import sys
import os
import locale
from gettext import gettext as _
from Pyblio import Autoload, Fields
from Pyblio.Output import latexutils
from Pyblio.Style import Utils
    from Pyblio import version

# test input arguments
if len (sys.argv) < 3:
    # user gave wrong arguments...
    usage ()
    sys.exit (1)
    
latex  = sys.argv [2]
bibtex = sys.argv [3:]

# --------------------------------------------------
# Search the entries found in the LaTeX document
# --------------------------------------------------

db, keys, style, missing = latexutils.find_entries (latex, bibtex)

if missing:
    # warn the user that some entries were not found
    print _("pybliotex: warning: the following keys were not resolved").encode (charset)
    print '	' + string.join (missing, '\n	') + '\n'

if style is None:
    # If the LaTeX document declares no style...
    error (_("no style defined"))

# --------------------------------------------------
# generate the latex bibliography
# --------------------------------------------------

# Create a formatter that writes in the .bbl file

# Path: Pyblio/Autoload.py
# class Loader:
#     def __init__ (self, name, regexp, module,
#                   info = None, data = None):
#     def load (self, key = None):
#     def is_loaded (self):
# def preregister (group, name, module, regexp = None, info = None):
# def register (group, name, data = None):
# def get_by_regexp (group, key):
# def get_by_name (group, name, load = 1):
# def available (group):
# def groups ():
# 
# Path: Pyblio/Fields.py
# def get_formatter (format):
#     def __init__ (self, copy = None, strict = 0):
#                 def clean_entry (f):
#     def format (self, fmt = 'latin1'):
#     def __str__ (self):
#     def __repr__ (self):
#     def match (self, regex):
#     def initials (self, format = None):
#     def __cmp__ (self, other):
#     def __init__ (self, text = ''):
#     def __getitem__ (self, pos):
#     def __setitem__ (self, pos, val):
#     def __len__ (self):
#     def append (self, value):
#     def __str__ (self):
#     def __repr__ (self):
#     def match (self, regex):
#     def __cmp__ (self, other):
#     def __init__ (self, arg = (None, None, None)):
#     def __cmp__ (self, other):
#     def __str__ (self):
#     def format (self, fmt = 'latin1'):
#     def __repr__ (self):
#     def match (self, regex):
#     def asInt (self):
#     def __init__ (self, text):
#     def __str__ (self):
#     def __repr__ (self):
#     def match (self, regex):
#     def __cmp__ (self, other):
#     def format (self, fmt = 'latin1'):
#     def __str__  (self):
#     def __repr__ (self):
#     def __len__  (self):
#     def __getitem__ (self, key):
#     def __init__ (self, url, invalid=False,
# 		  inexact=False, date='', note=''):
#     def set (self, other):
#     def full (self):
#     def parse_full (self, s):
#     def match (self, regex):
#     def __cmp__ (self, other):
#     def __hash__ (self):
#     def __str__ (self):
#     def __repr__ (self):
#     def get_url (self):
#     def __init__ (self, keylist, database = None):
#     def __str__ (self):
#     def __repr__ (self):
#     def match (self, regex):
#     def __cmp__ (self, other):
#     def format (self, fmt = 'latin1'):
# class Author:
# class AuthorGroup:
# class Date:
# class Text:
# class LongText (Text) :
# class URL:
# class Reference:
# 
# Path: Pyblio/Style/Utils.py
# def generate (style_url, format, database, keys, output):


# Path: scripts/pybliotex.py
import string
import sys
import os
import locale
from gettext import gettext as _
from Pyblio import Autoload, Fields
from Pyblio.Output import latexutils
from Pyblio.Style import Utils
    from Pyblio import version


# test input arguments
if len (sys.argv) < 3:
    # user gave wrong arguments...
    usage ()
    sys.exit (1)
    
latex  = sys.argv [2]
bibtex = sys.argv [3:]

# --------------------------------------------------
# Search the entries found in the LaTeX document
# --------------------------------------------------

db, keys, style, missing = latexutils.find_entries (latex, bibtex)

if missing:
    # warn the user that some entries were not found
    print _("pybliotex: warning: the following keys were not resolved").encode (charset)
    print '	' + string.join (missing, '\n	') + '\n'

if style is None:
    # If the LaTeX document declares no style...
    error (_("no style defined"))

# --------------------------------------------------
# generate the latex bibliography
# --------------------------------------------------

# Create a formatter that writes in the .bbl file

formatter = Autoload.get_by_name ('output', 'LaTeX').data