# Path: Pyblio/Types.py
# def get_entry (entry, has_default = 1):
# def get_field (field):
#     def __init__ (self, name, type = Fields.Text):
#     def __deepcopy__ (self, memo):
#     def __cmp__ (self, other):
#     def __str__ (self):
#     def __repr__ (self):
#     def __init__ (self, name):
#     def __cmp__ (self, other):
#     def __str__ (self):
#     def __repr__ (self):
#     def __getattr__ (self, attr):
#     def __setattr__ (self, attr, value):
# class FieldDescription:
# class EntryDescription:


import re
import string
from Pyblio import Types
    def extractor (self, entry):
        return [str(entry.key).lower()]

class FieldSort (AnySort):

    def __init__ (self, field, ascend = 1):
        self.field  = field
        AnySort.__init__ (self, ascend)

    def get_extractor (self):
        field = self.field
        if field ==  'date':
            if self.ascend < 0:
                return lambda x: [- self.date_extractor(x) [0]]
            else: return self.date_extractor
        elif field == '-author/editor-':
            return AnySort.get_extractor (
                self, self.author_editor_extractor)
        elif field in ['author', 'editor']:
            return AnySort.get_extractor (
                self,
                lambda entry: map (
                rakify, entry.get(field, [])))
        else:
            return AnySort.get_extractor(self)

    def get_field (self, entry):
        try:
            return entry [self.field]
        except KeyError:

# Path: Pyblio/Types.py
# def get_entry (entry, has_default = 1):
# def get_field (field):
#     def __init__ (self, name, type = Fields.Text):
#     def __deepcopy__ (self, memo):
#     def __cmp__ (self, other):
#     def __str__ (self):
#     def __repr__ (self):
#     def __init__ (self, name):
#     def __cmp__ (self, other):
#     def __str__ (self):
#     def __repr__ (self):
#     def __getattr__ (self, attr):
#     def __setattr__ (self, attr, value):
# class FieldDescription:
# class EntryDescription:


# Path: Pyblio/Sort.py
import re
import string
from Pyblio import Types

    def extractor (self, entry):
        return [str(entry.key).lower()]

class FieldSort (AnySort):

    def __init__ (self, field, ascend = 1):
        self.field  = field
        AnySort.__init__ (self, ascend)

    def get_extractor (self):
        field = self.field
        if field ==  'date':
            if self.ascend < 0:
                return lambda x: [- self.date_extractor(x) [0]]
            else: return self.date_extractor
        elif field == '-author/editor-':
            return AnySort.get_extractor (
                self, self.author_editor_extractor)
        elif field in ['author', 'editor']:
            return AnySort.get_extractor (
                self,
                lambda entry: map (
                rakify, entry.get(field, [])))
        else:
            return AnySort.get_extractor(self)

    def get_field (self, entry):
        try:
            return entry [self.field]
        except KeyError:

            return Types.get_field (self.field).type ('')