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


Python Legacy.Config类代码示例

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


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

示例1: update

    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,代码行数:29,代码来源:Base.py

示例2: setUp

    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,代码行数:7,代码来源:ut_Ovidlike.py

示例3: __parsefile__

    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,代码行数:34,代码来源:BibTeX.py

示例4: page3_add

 def page3_add (self, *args):
     m, iter = self.s3a.get_selected()
     if iter:
         p = self.sfm.convert_iter_to_child_iter(None, iter)
         field = self.fm[p] [3]
         self.current_entry.optional.append(field)
         self.sm.append ((field.name, False, field.name, field))
         Config.set_and_save('base/entries', self.entries)
     self.check()
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:9,代码来源:Fields.py

示例5: page2_rm

 def page2_rm (self, *args):
     self.check()
     m, iter = self.s2.get_selected()
     if iter:
         p = self.sem.convert_iter_to_child_iter(None, iter)
         del self.entries [self.em[p] [2]]
         self.em.remove(p)
         Config.set_and_save('base/entries', self.entries)
         self.check()
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:9,代码来源:Fields.py

示例6: page1_rm

 def page1_rm (self, *args):
     m, iter = self.s1.get_selected()
     if iter:
         p = self.sfm.convert_iter_to_child_iter(None, iter)
         #print 'SELF:FM[P][2]:', self.fm[p] [2]
         try: del self.fields [self.fm[p][2]]
         except KeyError: pass
         self.fm.remove(p)
         Config.set_and_save('base/fields', self.fields)
         self.check()
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:10,代码来源:Fields.py

示例7: width

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,代码行数:11,代码来源:FieldsInfo.py

示例8: apply

    def apply (self, * arg):
        if not self.changed: return
        
        result = self.get ()
        
        Config.set_and_save ('base/fields', result)

        if self.parent:
            self.parent.warning (_("Some changes require to restart Pybliographic\n"
                                   "to be correctly taken into account"))
        return
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:11,代码来源:Fields.py

示例9: update

 def update (self, force=False, *args):
     """Call this with an additional parameter
     force=True if the widget does nor use changed()."""
     #print 'UPDATE:', self.key, self.get(), force
     if not (force or self.state ()): return 0
     if self.key:
         Config.set_and_save (self.key, self.get ())
         self.prop.changed()
     else:
         self.parent.update(force = force)
     return False
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:11,代码来源:Config.py

示例10: _check_default

def _check_default (item, value, user):
    """ If the entries are updated, update the default type with the new entry """
    
    dfl = Config.get ('base/defaulttype').data
    if dfl is None: return 1

    value = value [string.lower (dfl.name)]
    
    if dfl == value:
        Config.set ('base/defaulttype', value)
        
    return 1
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:12,代码来源:Base.py

示例11: page3_rm

 def page3_rm (self, *args):
     m, iter = self.s3b.get_selected()
     if iter:
         p = self.ssm.convert_iter_to_child_iter (None, iter)
         field = self.sm[p] [3]
         if self.sm[p] [1]:
             self.current_entry.mandatory.remove(field)
         else:
             self.current_entry.optional.remove(field)
         del self.sm [p]
         Config.set_and_save('base/entries', self.entries)
     self.check()
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:12,代码来源:Fields.py

示例12: iterator

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,代码行数:14,代码来源:Ovid.py

示例13: toggle_mandatory

 def toggle_mandatory (self, rend, path):
     p = self.ssm.convert_path_to_child_path(path)
     iter = self.sm.get_iter(p)
     field = self.sm[iter][3]
     x = self.sm.get_value (iter, 1)
     self.sm.set_value(iter, 1, not x)
     if x:
         self.current_entry.mandatory.remove(field)
         self.current_entry.optional.append(field)
     else:
         self.current_entry.optional.remove(field)
         self.current_entry.mandatory.append(field)
     self.entries [self.current_entry.name.lower()] = self.current_entry
     Config.set_and_save ('base/entries', self.entries)
     self.check()
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:15,代码来源:Fields.py

示例14: on_name2_changed

 def on_name2_changed (self, *args):
     sel = self.entries2.get_selection()
     m, iter = sel.get_selected()
     if iter:
         p = self.sem.convert_iter_to_child_iter(None, iter)
         newname = self.name2.get_text()
         try: del self.entries [self.em[p][2]]
         except KeyError: print 'Keyerror', self.em[
             p] [2], self.entries.keys()
         self.em[p][1].name = newname
         self.em[p][0] = newname
         self.em[p][2] = newname.lower()
         self.entries[newname.lower()] = self.em[p][1]
         Config.set_and_save ('base/entries', self.entries)
     self.check()
开发者ID:zkota,项目名称:pyblio-1.3,代码行数:15,代码来源:Fields.py

示例15: __init__

    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,代码行数:27,代码来源:Config.py


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