Beispiel #1
0
"""


FMT_DEFAULT = 0
FMT_SIMPLE = 1
FMT_WARN = 2

msgformats = {
    FMT_DEFAULT: ("-" * 80 + "\n%s\n" + "-" * 80),
    FMT_SIMPLE: "%s",
    FMT_WARN: ("\n" + "#" * 80 + "\nWARNING: %s\n" + "#" * 80 + "\n"),
}

EchoFormat = enum_class(
    "EchoFormat",
    [("default", FMT_DEFAULT), ("simple", FMT_SIMPLE), ("warn", FMT_WARN)],
    default_value="default",
    value_attr_name="msgformat",
)


class EchoFilter(BibFilter):

    helpauthor = HELP_AUTHOR
    helpdescription = HELP_DESC
    helptext = HELP_TEXT

    def __init__(self, message=None, *args, **kwargs):
        """Echo a custom message into the bibolamazi logger.

        Arguments:
          - message: the message to echo
Beispiel #2
0
and getting relevant diffs between different revisions.
"""





# modes
ORDER_RAW = 0
ORDER_CITATION_KEY_ALPHA = 1
ORDER_DATE = 2


OrderMode = enum_class('OrderMode', [('raw', ORDER_RAW),
                                     ('alphabetical', ORDER_CITATION_KEY_ALPHA),
                                     ('date', ORDER_DATE),
                                     ],
                       default_value='alphabetical',
                       value_attr_name='ordermode')



class OrderEntriesFilter(BibFilter):

    helpauthor = HELP_AUTHOR
    helpdescription = HELP_DESC
    helptext = HELP_TEXT
    
    
    def __init__(self, order=None, reverse=False):
        """
        Arguments:
Beispiel #3
0
def getnameinitial(x):
    # x is the value returned from normnamelist([ first, names ])
    return x[0][0] if x else ''


# possible modes in which to operate
MATCHMODE_EXACT = 0
MATCHMODE_INITIAL = 1
MATCHMODE_PARTIAL = 2

# All these defs are useful for the GUI
MatchMode = enum_class(
    'MatchMode',
    [
        ('exact', MATCHMODE_EXACT),
        ('initial', MATCHMODE_INITIAL),
        ('partial', MATCHMODE_PARTIAL),
    ],
    default_value=MATCHMODE_INITIAL
)


HELP_AUTHOR = r"""
Philippe Faist, (C) 2019, GPL 3+
"""

HELP_DESC = r"""
Change an author name to a specified LaTeX string or macro.
"""

HELP_TEXT = r"""
Beispiel #4
0
MODE_STRIP = 5;


# All these defs are useful for the GUI

_modes = [
    ('none', MODE_NONE),
    ('unpublished-note', MODE_UNPUBLISHED_NOTE),
    ('unpublished-note-notitle', MODE_UNPUBLISHED_NOTE_NOTITLE),
    ('note', MODE_NOTE),
    ('eprint', MODE_EPRINT),
    ('strip', MODE_STRIP),
    ];
#_modes_dict = dict(_modes)

Mode = enum_class('Mode', _modes, default_value=MODE_NONE, value_attr_name='mode')



# --- the filter object itself ---


class ArxivNormalizeFilter(BibFilter):
    
    helpauthor = HELP_AUTHOR
    helpdescription = HELP_DESC
    helptext = HELP_TEXT


    def __init__(self,
                 mode="eprint",
Beispiel #5
0

FMT_DEFAULT = 0
FMT_SIMPLE = 1
FMT_WARN = 2

msgformats = {
    FMT_DEFAULT:  ("-"*80 + "\n%s\n" + "-"*80),
    FMT_SIMPLE:   "%s",
    FMT_WARN:     ("\n" + "#"*80 + "\nWARNING: %s\n" + "#"*80 + "\n"),
    }

EchoFormat = enum_class('EchoFormat',
                        [('default', FMT_DEFAULT),
                         ('simple', FMT_SIMPLE),
                         ('warn', FMT_WARN)
                         ],
                       default_value='default',
                       value_attr_name='msgformat')



class EchoFilter(BibFilter):
    
    helpauthor = HELP_AUTHOR
    helpdescription = HELP_DESC
    helptext = HELP_TEXT

    def __init__(self, message=None, *args, **kwargs):
        """Echo a custom message into the bibolamazi logger.
Beispiel #6
0
    formatter = BibolamaziConsoleFormatter(ttycolors=ttycolors)
    ch.setFormatter(formatter);
    
    # add the handlers to the logger
    logger.addHandler(ch);

    # for accessing the bibolamazi formatter. This is so that the main module
    # can set the level at which the logrecord position info (module, line no,
    # function) is reproduced
    logger.bibolamazi_formatter = formatter

    



# ------------------------------------------------------------------------------

# utility: enum_class for a log level

from bibolamazi.core.bibfilter.argtypes import enum_class

LogLevel = enum_class('LogLevel',
                      [('CRITICAL', logging.CRITICAL),
                       ('ERROR', logging.ERROR),
                       ('WARNING', logging.WARNING),
                       ('INFO', logging.INFO),
                       ('DEBUG', logging.DEBUG),
                       ('LONGDEBUG', LONGDEBUG)],
                      default_value='INFO',
                      value_attr_name='levelno')
You can define your own abbreviation schemes by provinding a fully qualified
python module name for `-sScheme=my.python.jab.module` that provides a
`replacement_pairs` global variable.  See examples at https://github.com/phfaist/bibolamazi-qi-filters/tree/master/bibolamazi_qi_filters/jab .
"""

# --- journal abbrev schemes ---

# thanks https://stackoverflow.com/a/1310912/1694896
import pkgutil
jabbrevmods = [
    name for _, name, _ in pkgutil.iter_modules(
        [os.path.join(os.path.dirname(__file__), 'jab')])
]
_jabbrevmods_pairs = [(s, i) for i, s in enumerate(jabbrevmods)]
JAbbrevModule = enum_class('JAbbrevModule',
                           _jabbrevmods_pairs,
                           default_value='defaults')

# --- filter definition ---


class JNameAbbrevFilter(BibFilter):

    # import help texts above here
    helpauthor = HELP_AUTHOR
    helpdescription = HELP_DESC
    helptext = HELP_TEXT

    def __init__(self,
                 scheme=JAbbrevModule('defaults'),
                 dot_at_abbrev=True,