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


Python Config.get方法代码示例

本文整理汇总了Python中Legacy.Config.get方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get方法的具体用法?Python Config.get怎么用?Python Config.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Legacy.Config的用法示例。


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

示例1: update

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
    def update(self, sorting=None):
	''' Updates the Entries stored in the database '''
	if self.key.url [0] != 'file':
	    raise IOError, "can't update the remote database `%s'" % self.key

	name = self.key.url[2]
        if Config.get('base/directsave').data:
            if Config.get('base/backup').data:
                copyfile(name, name + '.bak')
            namefile = open(name, 'w')
            iterator = Selection.Selection(sort=sorting).iterator(self.iterator())
	    Open.bibwrite(iterator, out=namefile, how=self.id, database=self)
            namefile.close ()
        else:
            # create a temporary file for the new version
            tmp = os.path.join(os.path.dirname(name),
                               '.#' + os.path.basename(name))
            tmpfile = open(tmp, 'w')

            iterator = Selection.Selection(sort=sorting).iterator(self.iterator())
	    Open.bibwrite(iterator, out=tmpfile, how=self.id, database=self)
	    tmpfile.close()

	    # if we succeeded, and backup is set, backup file
            if Config.get('base/backup').data:
                os.rename(name, name + '.bak')
	    # ...and bring new version online
            os.rename(tmp, name)
        return
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:31,代码来源:Base.py

示例2: __parsefile__

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
    def __parsefile__(self):
	self.dict = {}
	# Ouvrir le fichier associe
	self.parser = _bibtex.open_file(Open.url_to_local(self.key),
                                        Config.get ('bibtex/strict').data)
	# Incorporer les definitions de l'utilisateur
	if not Config.get('bibtex+/override').data:
	    user = Config.get('bibtex/macros').data
	    valid = re.compile('^\w+$')
	    for k in user.keys():
		if not valid.match(k):
		    raise TypeError, _("key `%s' is malformed") % k
		_bibtex.set_string(self.parser, k,
                                   _bibtex.reverse(_base_fieldtype[Text],
                                                   Config.get('bibtex+/braces').data,
                                                   user [k][0]))
	finished = 0
	errors = []

	# Creer la base de cles
	iter = BibtexIterator(self, self.parser)
        try:
            entry = iter.first()
            if entry is not None:
                if entry.key is None:
                    self.add(entry)
                else:
                    if self.dict.has_key(entry.key):
                        errors.append(_("%s:%d: key `%s' already defined") % (
                            str(self.key), entry.line, entry.key.key))
                    else:
                        self.dict [entry.key] = entry
        except Exceptions.ParserError, err:
            errors.append (str (err))
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:36,代码来源:BibTeX.py

示例3: width

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
def width (field):
    ''' return the graphical width of a field given its name '''
    
    ht = Config.get ('base/fields').data

    field = string.lower (field)
    
    if ht.has_key (field) and hasattr (ht [field], 'width'):
        return ht [field].width
    else:
        return Config.get ('gnomeui/default').data [0]
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:13,代码来源:FieldsInfo.py

示例4: iterator

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
def iterator (url, check):
    ''' This methods returns an iterator that will parse the
    database on the fly (useful for merging or to parse broken
    databases '''

    if check and url.url [2] [-5:] != '.ovid': return

    file = open (Open.url_to_local (url))

    return  OvidLike.OvidLike (
        file,
        Config.get ('ovid/mapping').data,
        Config.get ('ovid/deftype').data
        )
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:16,代码来源:Ovid.py

示例5: bibwrite

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
def bibwrite (iter, out = None, how = None, database=None):
    ''' writes a descriptions of a list of entries '''

    if database and Config.get ('bibtex/keep-preamble').data:
	preamble = database.get_metadata ('bibtex-preamble', [])
    else:
	preamble = []
	
    # default output
    out = out or sys.stdout

    if how == None:
	entry = iter.first ()
	while entry:
	    out.write (str (entry) + "\n")
	    entry = iter.next ()

	return

    writer = get_by_name (how, 'write')

    if writer is None:
	raise IOError, "type `%s' does not specify write method" % how
    writer (iter, out, preamble=preamble)
    return
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:27,代码来源:Open.py

示例6: get_viewables

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
def get_viewables (item, priority=[]):
    """Return a list of possible viewable resources for an item"""
    R = userexit.resource_viewer_select (Director, item)
    if R: return R
    viewables = Config.get (config_fields).data 
    return [ (key, item[key], item [key].get_url ()) for key
	     in priority + viewables if item.has_key (key)]
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:9,代码来源:Resource.py

示例7: __init__

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
    def __init__ (self, dtype, props, key=None, parent=None,  help_text=''):
        BaseConfig.__init__ (self, dtype, props, key, parent)
        self.w = gtk.VBox (spacing = 6)
        self.sub = []

        self.resize = False

        for sub in dtype.subtypes:
            w = sub.w (sub, props, parent=self)
            self.sub.append (w)
            
            if w.resize:
                self.resize = True

        for w in self.sub:
            self.w.pack_start (w.w,
                               expand = w.resize,
                               fill   = w.resize)
        
        if key:
            data = Config.get (key).data
            i = 0
            for item in data:
                self.sub [i].set (item)
                i = i + 1
        self.w.show_all ()
        return
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:29,代码来源:Config.py

示例8: setUp

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
    def setUp(self):

        Config.parse_directory(os.path.abspath("../ConfDir"))
        Config.load_user()
        self.db = DataBase("//localhost/Internal")
        self.output = cStringIO.StringIO()
        self.mapping = Config.get("ovid/mapping").data
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:9,代码来源:ut_Ovidlike.py

示例9: init_page_1

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
 def init_page_1 (self):
     
     self.fields1 = self.xml.get_widget('f_list_1')
     rend = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Name'), rend, text = 0)
     self.fields1.append_column(col)
     rend = gtk.CellRendererText()
     col = gtk.TreeViewColumn(_('Type'), rend, text = 1)
     self.fields1.append_column(col)
     
     self.fm = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                             gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
     self.sfm = gtk.TreeModelSort(self.fm)
     self.sfm.set_sort_column_id(2, gtk.SORT_ASCENDING)
     self.fields1.set_model(self.sfm)
     self.s1 = self.fields1.get_selection()
     self.s1.connect ('changed', self.list_1_select)
     self.fields = copy.copy (Config.get ('base/fields').data)
     for key, item in  self.fields.iteritems():
         self.fm.append((item.name,
                         _typename [item.type], key, item)) 
     
     self.name1 = self.xml.get_widget('name1')
     self.menu1 = self.xml.get_widget('type1')
     menu = gtk.Menu ()
     self.menu1.set_menu (menu)
     self.menu_items = _typename.keys ()
     for item in self.menu_items:
         Utils.popup_add (menu, _typename [item], self.select_menu, item)
     self.menu1.set_history (0)
     self.current_menu = self.menu_items [0]
     self.check()
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:34,代码来源:Fields.py

示例10: justification

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
def justification (field):
    ''' returns the representative widget of a field '''
    
    ht = Config.get ('base/fields').data

    field = string.lower (field)
    
    if not ht.has_key (field):
        return Config.get ('gnomeui/default').data [1]
    
    if hasattr (ht [field], 'justification'):
        return ht [field].justification
    
    if hasattr (ht [field].type, 'justification'):
        return ht [field].type.justification

    return Config.get ('gnomeui/default').data [1]
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:19,代码来源:FieldsInfo.py

示例11: get_field

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
def get_field (field):
    ''' return a field description given its name '''
    
    fields = Config.get ("base/fields").data

    if fields.has_key (field):
        return fields [field]

    return FieldDescription (field)
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:11,代码来源:Types.py

示例12: _text_get

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
def _text_get ():

    v = Config.get ('base/fields').data

    fields = [ x.name.lower() for x in v.values() if
               x.type is Fields.Text or x.type is Fields.LongText ]
    fields.sort ()

    return fields
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:11,代码来源:GnomeUI.py

示例13: __init__

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
    def __init__(self, key, fieldtype, content, parser, line):
	Base.Entry.__init__(self, key, fieldtype, content)

	self.__text = {}
	self.parser = parser
        self.line   = line
        
	# Check for date fields
	datefields = Config.get ('bibtex/datefield').data
	convert    = Config.get ('bibtex/months').data
	for field in datefields.keys():
	    (yearfield, monthfield) = datefields[field]
	    
	    # check if this entry provides a date field
	    if not self.has_key (yearfield):
                continue

            day   = None
	    month = None
            try:
                year = int(self[yearfield].text)
            except ValueError:
                break
            
	    del self[yearfield]

	    if self.has_key(monthfield):
		mt = _bibtex.get_native(self.dict[monthfield])
		if convert.has_key(mt):
		    month = convert[mt]
		    del self[monthfield]
                else:
                    df = extended_date.match(mt)
                    if df:
                        (gd, gm) = (df.group(1), df.group(2))
                        if convert.has_key(gm):
                            month = convert[gm]
                            try:
                                day = int(gd)
                            except ValueError:
                                pass
                            del self[monthfield]
	    self[field] = Date((year, month, day))
	return
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:46,代码来源:BibTeX.py

示例14: widget

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
def widget (field):
    ''' returns the representative widget of a field '''

    default = Config.get ('gnomeui/default').data [2]
    
    ht = Config.get ('base/fields').data
    
    field = string.lower (field)

    if not ht.has_key (field):
        return default
    
    if hasattr (ht [field], 'widget'):
        return ht [field].widget
    
    if hasattr (ht [field].type, 'widget'):
        return ht [field].type.widget

    return default
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:21,代码来源:FieldsInfo.py

示例15: create_native

# 需要导入模块: from Legacy import Config [as 别名]
# 或者: from Legacy.Config import get [as 别名]
    def create_native(self, value):
	'''Parse text in native format.'''
	parser = _bibtex.open_string("<set_native string>", value,
                                     Config.get ('bibtex/strict').data)
	iter  = BibtexIterator(self, parser)
	entry = iter.first()
	if entry:
	    # set the entry parser to the current one, so
	    # that we keep the current string definitions
	    entry.parser = self.parser
	return entry
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:13,代码来源:BibTeX.py


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