当前位置: 首页>>代码示例>>Python>>正文


Python Pyblio.Autoload类代码示例

本文整理汇总了Python中Pyblio.Autoload的典型用法代码示例。如果您正苦于以下问题:Python Autoload类的具体用法?Python Autoload怎么用?Python Autoload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Autoload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__ (self, parent = None):

        Utils.GladeWindow.__init__ (self, parent)

        # Fill the output format drop-down menu
        menu = gtk.Menu ()
        self._w_menu.set_menu (menu)
        
        outlist = Autoload.available ('output')
        outlist.sort ()
        
        for avail in outlist:
            Utils.popup_add (menu, avail, self._menu_select, avail)

        self._w_menu.set_history (0)
        self.menu_item = outlist [0]

        self._w_style_entry.set_default_path (FormatDialog.style)
        self._w_style.set_text (FormatDialog.style)

        if FormatDialog.output:
            self._w_output_entry.set_default_path (FormatDialog.output)
            self._w_output.set_text (FormatDialog.output)
        
        self._w_format.show ()
        return
开发者ID:ice-pice,项目名称:pybliographer,代码行数:26,代码来源:Format.py

示例2: __init__

    def __init__ (self, parent = None, has_auto = True):

        Utils.GladeWindow.__init__ (self, parent)

        liststore = gtk.ListStore (gobject.TYPE_STRING)
        menu = self._w_combobox
        menu.set_model (liststore)
        cell = gtk.CellRendererText()
        menu.pack_start(cell, True)
        menu.add_attribute(cell, 'text', 0)

        liste = Autoload.available ('format')
        liste.sort ()

        self.formats = [ None ]

        if has_auto:
            iter = liststore.append ()
            liststore.set (iter, 0, _(' - According to file suffix - '))
            self.ftype = None
        else:
            self.ftype = liste [0]

        for avail in liste:
            iter = liststore.append ()
            liststore.set (iter, 0, avail)

        self.formats += liste

        menu.set_active (0)
        menu.connect ("changed", self.menu_select)
        return
开发者ID:ice-pice,项目名称:pybliographer,代码行数:32,代码来源:OpenURL.py

示例3: get_by_regexp

def get_by_regexp (entity, method):
    ''' returns a specific field of the given entity '''

    meth = Autoload.get_by_regexp ("format", entity)

    if meth and meth.data.has_key (method):
	return meth.data [method]

    return None
开发者ID:GNOME,项目名称:pybliographer,代码行数:9,代码来源:Open.py

示例4: _on_validate

    def _on_validate (self, * arg):

        style  = self._w_style_entry.get_full_path (False)
        output = self._w_output_entry.get_full_path (False)

        FormatDialog.style  = style
        FormatDialog.output = output
        
        format = Autoload.get_by_name ('output', self.menu_item).data

        if style is None or output is None: return
        self._w_format.destroy ()

        self.issue ('format-query', style, format, output)
        return
开发者ID:ice-pice,项目名称:pybliographer,代码行数:15,代码来源:Format.py

示例5: format

def format (database, style, output, file = sys.stdout, id = 'Bibliography'):
	
	output = Autoload.get_by_name ("output", output).data
	
	url = None
	style = os.path.splitext (style) [0]
	if os.path.exists (style + '.xml'):
		url = Fields.URL (style + '.xml')
	else:
		from Pyblio import version
		full = os.path.join (version.pybdir, 'Styles', style)
		full = full + '.xml'
		if os.path.exists (full): url = Fields.URL (full)

	Utils.generate (url, output, database, database.keys (), file)
	return
开发者ID:ice-pice,项目名称:pybliographer,代码行数:16,代码来源:TextUI.py

示例6: bibopen

def bibopen (entity, how = None):
    ''' Generic function to open a bibliographic database '''

    def simple_try (url, how):
	# url is Fields.URL instance, only to be passed to opener
	base = None

	if how == None:
	    listedmethods = Autoload.available ("format")

	    for method in listedmethods:
		opener = get_by_name (method, 'open')
		if opener:
		    base = opener (url, 1)
		    if base is not None:
			return base
	    return None

	opener = get_by_name (how, 'open')

	if opener:
	    base = opener (url, 0)
	else:
	    raise Exceptions.FormatError (_(u"method “%s” provides no opener") % how)

	return base

    # Consider the reference as an URL: url is an Fields.URL instance
    url = Fields.URL (entity)

    if url.url [0] == 'file' and not os.path.exists (url.url [2]):
	raise Exceptions.FileError (_(u"File “%s” does not exist") % url.get_url ())

    # eventually load a new module
    if how is None:
	handler = Autoload.get_by_regexp ("format", url.get_url ())
	if handler:
	    how = handler.name

    base = simple_try (url, how)

    if base is None:
	raise Exceptions.FormatError (_(u"don’t know how to open “%s”") % entity)

    return base
开发者ID:GNOME,项目名称:pybliographer,代码行数:45,代码来源:Open.py

示例7: _on_validate

    def _on_validate(self, *arg):
        style = self._w_style.get_filename()
        output = self._w_output.get_filename()

        FormatDialog.style  = style
        FormatDialog.output = output
        
        format = Autoload.get_by_name ('output', self.menu_item).data

        # FIXME: We can't use GtkFileChooserButton for saving a file
        # So, now we are not saving anything
        if output is None:
            import inspect
            fname, lineno, funcname = inspect.getframeinfo(inspect.currentframe())[:3]
            print 'FIXME: Data not saved. %s:%d (%s)' % (fname, lineno, funcname)

        if style is None or output is None: return
        self._w_format.destroy ()

        self.issue ('format-query', style, format, output)
开发者ID:GNOME,项目名称:pybliographer,代码行数:20,代码来源:Format.py

示例8: __init__

    def __init__ (self, parent=None):
        Utils.Builder.__init__(self, parent)

        cell = gtk.CellRendererText()
        self._w_menu.pack_start (cell, True)
        self._w_menu.add_attribute (cell, 'text', 0)
        
        outlist = Autoload.available ('output')
        outlist.sort ()

        for avail in outlist:
            self._w_menu.append_text(avail)

        self._w_menu.set_active(0)
        self.menu_item = outlist[0]

        self._w_style.set_filename(FormatDialog.style)

        if FormatDialog.output:
            self._w_output.set_filename(FormatDialog.output)

        self._w_format.show ()
开发者ID:GNOME,项目名称:pybliographer,代码行数:22,代码来源:Format.py

示例9: simple_try

    def simple_try (url, how):
	# url is Fields.URL instance, only to be passed to opener
	base = None

	if how == None:
	    listedmethods = Autoload.available ("format")

	    for method in listedmethods:
		opener = get_by_name (method, 'open')
		if opener:
		    base = opener (url, 1)
		    if base is not None:
			return base
	    return None

	opener = get_by_name (how, 'open')

	if opener:
	    base = opener (url, 0)
	else:
	    raise Exceptions.FormatError (_(u"method “%s” provides no opener") % how)

	return base
开发者ID:GNOME,项目名称:pybliographer,代码行数:23,代码来源:Open.py

示例10: configure

    def configure (self):
        fmeth = {}
        
        module = None
        for mod in self.config:
            module = Autoload.get_by_name ('style', mod.module).data
            if module is None:
                raise RuntimeError, "unknown module `%s'" % mod.module

            for item in mod.data:
                if item.att.has_key ('method'):
                    meth = item.att ['method']
                    if module.has_key (item.data):
                        self.methods [meth] = module [item.data]
                    continue
                
                if item.att.has_key ('field'):
                    field = item.att ['field']
                    if module.has_key (item.data):
                        fmeth [field] = module [item.data]
                    continue

        self.format.meth = fmeth
        return
开发者ID:ice-pice,项目名称:pybliographer,代码行数:24,代码来源:Parser.py

示例11: _get_keytypes

def _get_keytypes ():
    return Autoload.available ('key')
开发者ID:ice-pice,项目名称:pybliographer,代码行数:2,代码来源:Base.py

示例12: first_last_full_authors

def first_last_full_authors (entry, coding):
    return author_desc (entry, coding, 0, -1)

def full_authors (entry, coding):
    return author_desc (entry, coding, 0, 0)


def initials_authors (entry, coding):
    return author_desc (entry, coding, 1, 0)

def first_last_initials_authors (entry, coding):
    return author_desc (entry, coding, 1, -1)

def last_first_initials_authors (entry, coding):
    return author_desc (entry, coding, 1, 1)


Autoload.register ('style', 'abbrv', {
    'first_last_full_authors'     : first_last_full_authors,
    'last_first_full_authors'     : last_first_full_authors,
    'full_authors'     : full_authors,
    'first_last_initials_authors' : first_last_initials_authors,
    'last_first_initials_authors' : last_first_initials_authors,
    'initials_authors' : initials_authors,
    'string_keys'      : create_string_key,
    'bibdb_keys'       : create_bibdb_key,
    'authoryear_keys'  : create_authoryear_key,
    'unsrtnum_keys'    : create_unsrtnum_key,
    'european_date'    : standard_date,
    })
开发者ID:ice-pice,项目名称:pybliographer,代码行数:30,代码来源:abbrv.py

示例13: generate_key

 def generate_key(self, entry):
     # call a key generator
     keytype = Config.get('base/keyformat').data
     return Autoload.get_by_name('key', keytype).data(entry, self)
开发者ID:GNOME,项目名称:pybliographer,代码行数:4,代码来源:Base.py

示例14: error

# adjust parameters to the chosen style
if spstyle == 'abbrvau':
    sep = '; '
    format = 'textau'

elif spstyle == 'abbrvnum':
    sep = ', '
    format = 'textnum'
else:
    sep = ', '
    format = 'text'


# get the specified output
output = Autoload.get_by_name ('output', format)

if output is None:
    error (_("unknown output format `%s'") % format)



reffile = outfile + '.ref'

if os.path.exists(outfile):
    error (_("File already exists: `%s'") % outfile)

if os.path.exists(reffile):
    error (_("A file with the same name already exists: `%s'") % reffile)

textfile = args [0]
开发者ID:ice-pice,项目名称:pybliographer,代码行数:30,代码来源:pybliotext.py

示例15: author_desc

    return author_desc (entry, coding, 0, 1)

def first_last_full_authors (entry, coding):
    return author_desc (entry, coding, 0, -1)

def full_authors (entry, coding):
    return author_desc (entry, coding, 0, 0)


def initials_authors (entry, coding):
    return author_desc (entry, coding, 1, 0)

def first_last_initials_authors (entry, coding):
    return author_desc (entry, coding, 1, -1)

def last_first_initials_authors (entry, coding):
    return author_desc (entry, coding, 1, 1)

# Line below changed
Autoload.register ('style', 'apa4e', {
    'first_last_full_authors'     : first_last_full_authors,
    'last_first_full_authors'     : last_first_full_authors,
    'full_authors'     : full_authors,
    'first_last_initials_authors' : first_last_initials_authors,
    'last_first_initials_authors' : last_first_initials_authors,
    'initials_authors' : initials_authors,
    'string_keys'      : create_string_key,
    'numeric_keys'     : create_numeric_key,
    'european_date'    : standard_date,
    })
开发者ID:ice-pice,项目名称:pybliographer,代码行数:30,代码来源:apa4e.py


注:本文中的Pyblio.Autoload类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。