# 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

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

# Search style in local path and standard installation
url = None

if os.path.exists (style + '.xml'):
    url = Fields.URL (style + '.xml')
else:

    full = os.path.join (version.pybdir, 'Styles', style)
    full = full + '.xml'
    if os.path.exists (full): url = Fields.URL (full)

if not url:
    error (_(u"can’t find style “%s”") % style)

# open the .bbl file
bblfile = os.path.splitext (os.path.split (latex) [1]) [0] + '.bbl'
bbl = open (bblfile, 'w')


# 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


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

# Search style in local path and standard installation
url = None

if os.path.exists (style + '.xml'):
    url = Fields.URL (style + '.xml')
else:

    full = os.path.join (version.pybdir, 'Styles', style)
    full = full + '.xml'
    if os.path.exists (full): url = Fields.URL (full)

if not url:
    error (_(u"can’t find style “%s”") % style)

# open the .bbl file
bblfile = os.path.splitext (os.path.split (latex) [1]) [0] + '.bbl'
bbl = open (bblfile, 'w')


Utils.generate (url, formatter, db, keys, bbl)