• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python server.UnwrapObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: KoTerminalProcess

class KoTerminalProcess(KoRunProcess):

    _terminal = None

    def linkIOWithTerminal(self, terminal):
        # Need to unwrap the terminal handler because we are not actually
        # passing in koIFile xpcom objects as described by the API, we are
        # using the subprocess python file handles instead.
        self._terminal = UnwrapObject(terminal)
        self._terminal.hookIO(self._process.stdin, self._process.stdout,
                              self._process.stderr, "KoTerminalProcess")

    # Override the KoRunProcess.wait() method.
    def wait(self, timeout=None):
        retval = KoRunProcess.wait(self, timeout)
        if self._terminal:
            # Need to wait until the IO is fully synchronized (due to threads)
            # before returning. Otherwise additional data could arrive after
            # this call returns.
            # 
            # Set timeout to 5 seconds due to bugs 89280 and 88439
            self._terminal.waitForIOToFinish(timeout=5)
            self._terminal = None
        return retval

    def waitAsynchronously(self, runTerminationListener):
        t = threading.Thread(target=_terminalProcessWaiter,
                             args=(self, runTerminationListener))
        t.setDaemon(True)
        t.start()
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:30,代码来源:runutils.py


示例2: DOMDeserialize

    def DOMDeserialize(self, rootElement, parentPref, prefFactory, basedir=None, chainNotifications=0):
        """We know how to deserialize ordered-preference elements."""

        # Create a new ordered preference.
        xpOrderedPref = components.classes["@activestate.com/koOrderedPreference;1"].createInstance(
            components.interfaces.koIOrderedPreference
        )
        newOrderedPref = UnwrapObject(xpOrderedPref)
        try:
            newOrderedPref.id = rootElement.getAttribute("id") or ""
        except KeyError:
            newOrderedPref.id = ""

        # Iterate over the elements of the preference set,
        # deserializing them and fleshing out the new preference
        # set with content.
        childNodes = rootElement.childNodes

        for childNode in childNodes:
            if childNode and childNode.nodeType == minidom.Node.ELEMENT_NODE:
                pref = _dispatch_deserializer(self, childNode, newOrderedPref, prefFactory, basedir)
                if pref:
                    newOrderedPref.appendPref(pref)

        return xpOrderedPref
开发者ID:twhiteman,项目名称:KomodoEdit,代码行数:25,代码来源:koXMLPrefs.py


示例3: test_differentOnDisk

    def test_differentOnDisk(self):
        path = tempfile.mktemp()
        try:
            # Init the test file with some content.
            _writefile(path, "blah\nblah\nblah\n")

            koDoc = self._koDocFromPath(path)
            # Make it look like a remote file.
            rawFile = UnwrapObject(koDoc.file)
            rawFile.isLocal = 0
            rawFile.isRemoteFile = 1
            koDoc.load()

            # Wait one second, so we generate a different mtime.
            import time
            time.sleep(1.1)
            _writefile(path, "blah\nblah\nblah\nblah\n")

            self.assertTrue(koDoc.differentOnDisk(), "Remote file change was not detected")
            # Next time we call it - it should still detect the file as being changed - bug 95690.
            self.assertTrue(koDoc.differentOnDisk(), "Remote file change was not detected a second time")
            koDoc.save(True)
            self.assertFalse(koDoc.differentOnDisk(), "Remote file change detected after saving the file")
        finally:
            if os.path.exists(path):
                os.unlink(path) # clean up
开发者ID:ball6847,项目名称:openkomodo,代码行数:26,代码来源:test_koDocument.py


示例4: test_differentOnDisk

    def test_differentOnDisk(self):
        path = tempfile.mktemp()
        try:
            # Init the test file with some content.
            _writefile(path, "blah\nblah\nblah\n")

            koDoc = self._koDocFromPath(path, load=False)
            # Make it look like a remote file.
            rawFile = UnwrapObject(koDoc.file)
            rawFile.isLocal = 0
            rawFile.isRemoteFile = 1
            koDoc.load()

            # Wait one second, so we generate a different mtime.
            import time
            time.sleep(1.1)
            _writefile(path, "blah\nblah\nblah\nblah\n")

            self.assertTrue(koDoc.differentOnDisk(), "Remote file change was not detected")
            # Next time we call it - it should still detect the file as being changed - bug 95690.
            self.assertTrue(koDoc.differentOnDisk(), "Remote file change was not detected a second time")
            # Because we are using a fake koIFileEx (or really a local file),
            # this test can fail if the timestamp between the save and the
            # differentOnDisk calls has changed. To work around that, we run
            # multiple checks and only accept one failure.
            success_count = 0
            for tries in range(3):
                koDoc.save(True)
                if not koDoc.differentOnDisk():
                    success_count += 1
            self.assertTrue(success_count >= 2, "Remote file change detected after saving the file")
        finally:
            if os.path.exists(path):
                os.unlink(path) # clean up
开发者ID:Defman21,项目名称:KomodoEdit,代码行数:34,代码来源:test_koDocument.py


示例5: DOMDeserialize

    def DOMDeserialize(self, rootElement, parentPref, prefFactory, basedir=None, chainNotifications=0):
        """We know how to deserialize preferent-set elements."""
        # Create a new preference set and rig it into the preference set hierarchy.
        xpPrefSet = components.classes["@activestate.com/koPreferenceSet;1"] \
                  .createInstance(components.interfaces.koIPreferenceSet)
        newPrefSet = UnwrapObject(xpPrefSet)
        newPrefSet.chainNotifications = chainNotifications
        try:
            newPrefSet.id = rootElement.getAttribute('id') or ""
        except KeyError:
            newPrefSet.id = ""
        try:
            newPrefSet.idref = rootElement.getAttribute('idref') or ""
        except KeyError:
            newPrefSet.idref = ""

        # Iterate over the elements of the preference set,
        # deserializing them and fleshing out the new preference
        # set with content.
        childNodes = rootElement.childNodes

        for node in childNodes:
            if node and node.nodeType == minidom.Node.ELEMENT_NODE:
                if node.hasAttribute('validate'):
                    newPrefSet.setValidation(node.getAttribute('id'), node.getAttribute('validate'))
                pref = _dispatch_deserializer(self, node, newPrefSet, prefFactory, basedir, chainNotifications)
                if pref:
                    if pref.id:
                        newPrefSet.setPref(pref.id, pref)
                    else:
                        log.error("Preference has no id - dumping preference:")
                        pref.dump(0)

        return xpPrefSet 
开发者ID:mook,项目名称:komodo-python-sitelib,代码行数:34,代码来源:koXMLPrefs.py


示例6: test_language_reset

    def test_language_reset(self):
        manifest = [
            ("Python", tempfile.mktemp(".py"), """\
#!/usr/bin/env python
print 'should be py'
"""),
            ("Python3", tempfile.mktemp(".py"), """\
#  -*- python3 -*-
print('should be py3')
"""),
            ("JavaScript", tempfile.mktemp(".js"), """\
alert('should be js')
"""),
        ]
        for lang, name, content in manifest:
            path = join(self.data_dir, name)
            _writefile(path, content)
            koDoc = self._koDocFromPath(path)
            self.assertEqual(koDoc.language, lang)
            koDoc.language = "Perl"
            self.assertEqual(koDoc.language, "Perl")
            koDoc.language = ""
            self.assertEqual(koDoc.language, lang)
            # Validate the documents preference chain - bug 97728.
            doc = UnwrapObject(koDoc)
            doc._walkPrefChain(doc.prefs, doPrint=False)
开发者ID:Defman21,项目名称:KomodoEdit,代码行数:26,代码来源:test_koDocument.py


示例7: deleteRows

 def deleteRows(self, dataTreeView, rowNums):
     # @param dataTreeView { koIDBXTableDumpTreeView }
     #  koIDBXTableDumpTreeView: koDatabaseExplorerTreeView.koDatabaseExplorerTreeView
     # @param rowNums {array of int}
     column_names = self.getColumnNames()
     query_names = []
     dataTreeView = UnwrapObject(dataTreeView)
     schemaTreeView = UnwrapObject(dataTreeView.get_schemaTreeView())
     for i in range(len(column_names)):
         is_key = (schemaTreeView.getCellText(i, dbxlib.Column('is_primary_key')).lower()
                   in ('true', '1')) # windows: 'true', linux: '1'
         if is_key:
             query_names.append(column_names[i])
     if not query_names:
         raise dbxlib.DBXception("No attributes are keys, can't delete")
     table_name = self._table_name
     # return True if any rows are deleted
     final_res = ""
     for rowNum in rowNums:
         query_values = []
         for column_name in query_names:
             query_values.append(dataTreeView.getCellText(rowNum,
                                                          dbxlib.Column(column_name)))
         res = self._db.deleteRowByKey(self._table_name,
                                 query_names,
                                 query_values)
         if not (res or final_res):
             final_res = ("Failed to delete keys:%s, values:%s" %
                         (", ".join(query_names),
                          ", ".join([str(x) for x in query_values])))
     return final_res
开发者ID:belonesox,项目名称:dbexplorer_pgsql,代码行数:31,代码来源:koDBConnPG.py


示例8: _setup_for_xpcom

def _setup_for_xpcom():
    # Use a temporary user data dir
    userDataRoot = tempfile.mkdtemp(prefix="ko-test-userdata-")
    atexit.register(shutil.rmtree, userDataRoot)
    os.environ["KOMODO_USERDATADIR"] = userDataRoot

    # The tests are run outside of Komodo. If run with PyXPCOM up
    # parts codeintel will try to use the nsIDirectoryService and
    # will query dirs only provided by nsXREDirProvider -- which
    # isn't registered outside of Komodo (XRE_main() isn't called).
    # The KoTestService provides a backup.
    from xpcom import _xpcom
    from xpcom import components
    from xpcom.server import UnwrapObject
    koTestSvc = components.classes["@activestate.com/koTestService;1"] \
        .getService(components.interfaces.koITestService)
    koTestSvc.init()

    # Reset the startup-env.tmp file (normally done by komodo.exe), otherwise
    # we'll be reading stale environment settings from whenever Komodo was last
    # run on this machine.
    koEnvironSvc = components.classes["@activestate.com/koUserEnviron;1"] \
        .getService(components.interfaces.koIUserEnviron)
    pyEnvironSvc = UnwrapObject(koEnvironSvc)
    try:
        os.remove(pyEnvironSvc.startupEnvFileName)
    except OSError:
        # Doesn't exist, or we don't have the correct permissions... ignore.
        pass
    pyEnvironSvc._UpdateFromStartupEnv()
开发者ID:MynorCifuentes,项目名称:KomodoEdit,代码行数:30,代码来源:test.py


示例9: initialize

 def initialize(self, toolbox_db_svc):
     global _tbdbSvc
     _tbdbSvc = self.toolbox_db = toolbox_db_svc
     self._koToolbox2Service = UnwrapObject(components.classes["@activestate.com/koToolbox2Service;1"].getService(components.interfaces.koIToolbox2Service))
     self._koProjectService = UnwrapObject(components.classes["@activestate.com/koPartService;1"].getService(components.interfaces.koIPartService))
     self._globalPrefs = components.classes["@activestate.com/koPrefService;1"].\
                    getService(components.interfaces.koIPrefService).prefs
开发者ID:,项目名称:,代码行数:7,代码来源:


示例10: KoCodeIntelXPCOMSupportReigstrationHelper

class KoCodeIntelXPCOMSupportReigstrationHelper(object):
    """Helper class for codeintel command extension registration; See kd290 /
    KoCodeIntelManager._send_init_requests.initialization_completed"""
    _com_interfaces_ = []
    _reg_clsid_ = "{3ae458a3-b767-47d8-a5a6-1731d415c54b}"
    _reg_contractid_ = "@activestate.com/codeintel/xpcom/registration-helper;1"
    _reg_desc_ = "Komodo XPCOM Code Intelligence Backend Registration Helper"
    _reg_categories_ = [
        ("codeintel-command-extension", _reg_contractid_),
    ]
    def __init__(self):
        self.completer = \
            UnwrapObject(Cc[KoCodeIntelXPCOMSupport._reg_contractid_]
                           .getService())
        self.data = [
            (dirname(__file__), "xpcomJSElements"),
        ]
    def __iter__(self):
        """Iteration for codeintel command extension registration"""
        return self
    def next(self):
        try:
            return self.data.pop(0)
        except IndexError:
            self.completer.send_connection_request()
            raise StopIteration
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:26,代码来源:koCodeIntelXPCOMSupport.py


示例11: addNewItemToParent

    def addNewItemToParent(self, parent, item, showNewItem=True):
        """
        This code has a model part and a view part.  Call the view
        part if we need to update it.
        """
        # TODO: if parent is null, use the std toolbox node
        item = UnwrapObject(item)
        parent = UnwrapObject(parent)
        parent_path = self.toolbox_db.getPath(parent.id)
        item_name = item.name
        itemIsContainer = item.isContainer
        if itemIsContainer:
            # Bug 96486: Can't create folders named "*" on Windows
            # Now that we're encouraging people to create folders with this name,
            # we need to quietly change the "*"s to "_"s.  I don't
            # remember why I decided not to do this in general.
            system_item_name = item_name.replace("*", "_")

            # Don't do anything else to this name.  If there's a dup, or
            # it contains bad characters, give the user the actual
            # error message.  Which is why we need to try creating
            # the folder first, before adding its entry.
            path = join(parent_path, system_item_name)
            if system_item_name != item_name:
                # Make sure it's new
                if os.path.exists(path):
                    for i in range(20):
                        suffix = i + 1
                        new_path = "%s-%d" % (path, suffix)
                        if not os.path.exists(new_path):
                            path = new_path
                            break
            item.trailblazeForPath(path)
        else:
            path = self._prepareUniqueFileSystemName(parent_path, item_name)
        try:
            itemDetailsDict = {}
            item.fillDetails(itemDetailsDict)
            if itemIsContainer:
                new_id = self.toolbox_db.addContainerItem(itemDetailsDict, item.typeName, path, item_name, parent.id)
            else:
                new_id = self.toolbox_db.addTool(itemDetailsDict, item.typeName, path, item_name, parent.id)

            old_id = item.id
            item.id = new_id
            # Even if the old and new IDs are the same, we don't want
            # to keep the old item in the cache.
            try:
                del self._tools[old_id]
            except KeyError:
                log.error("No self._tools[%r]", old_id)
            self._tools[new_id] = item
            item.saveNewToolToDisk(path)
            if showNewItem:
                self._koToolboxHView.addNewItemToParent(parent, item)
            item.added()
        except:
            log.exception("addNewItemToParent: failed")
            raise
开发者ID:,项目名称:,代码行数:59,代码来源:


示例12: _clonePartList

 def _clonePartList(self, newproject, partList):
     # clone parts and add them to the project
     for part in partList:
         part = UnwrapObject(part)
         if part.type == 'project':
             self._clonePartList(newproject, part.children)
         else:
             newpart = part.copyToProject(newproject)
             newproject.addChild(newpart)
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:9,代码来源:koProjectPackageService.py


示例13: lint

 def lint(self, request):
     try:
         html_linter = UnwrapObject(self._koLintService.getLinterForLanguage("HTML"))
         return html_linter.lint(request, TPLInfo=self._tplPatterns)
     except:
         if "lint" not in self._checkValidVersion_complained:
             self._checkValidVersion_complained["lint"] = True
             log.exception("Problem in koPHPLinter.lint")
         return koLintResults()
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:9,代码来源:koPHPLinter.py


示例14: KGit_hookFunction

 def KGit_hookFunction(self):
     wm = components.classes["@mozilla.org/appshell/window-mediator;1"].getService(components.interfaces.nsIWindowMediator)
     win = wm.getMostRecentWindow("Komodo")
     tree = win.document.getElementById('places-files-tree')
     treebox = tree.boxObject.QueryInterface(components.interfaces.nsITreeBoxObject)
     pview = UnwrapObject(treebox.view)
     if pview._buildCellProperties == self.KGit_buildCellProperties:
       return
     self._buildCellProperties_old = pview._buildCellProperties
     pview._buildCellProperties = self.KGit_buildCellProperties
开发者ID:girvo,项目名称:komodo-komodin-git,代码行数:10,代码来源:kGit.py


示例15: KoTemplateCategoriesView

class KoTemplateCategoriesView(TreeView):
    _com_interfaces_ = [components.interfaces.koITemplateCategoriesView,
                        components.interfaces.nsITreeView]
    _reg_clsid_ = "{0723776F-EE9D-4F20-B438-3AF893192346}"
    _reg_contractid_ = "@activestate.com/koTemplateCategoriesView;1"
    _reg_desc_ = "Komodo Template Categories nsITreeView"

    def __init__(self):
        TreeView.__init__(self) #, debug="categories") #XXX
        self._tree = None
        self._sortedBy = None
        # The table used to fill in the tree. It is a list of dicts. Each
        # dict represents one row in the tree/outliner. This dictionary is
        # also (because it is convenient) used to store data in addition to
        # the named rows of the XUL tree. e.g.,
        #  [ {"category-name": "My Templates",  # row 0
        #     "node": <Node instance for this category>},
        #    ... ]
        # This attribute is re-generated from self.templateTree whenever
        # the rows change (say, by the user opening a category with
        # sub-categories).
        self._data = []
        
        self._prefSvc = components.classes["@activestate.com/koPrefService;1"]\
                        .getService().prefs # global prefs
        self.templateTree = None # Working copy of template tree Nodes.
        self.selectedTemplateByCategory = None
        self.categoryIsOpen = None
        self.atomSvc = components.classes["@mozilla.org/atom-service;1"].\
                  getService(components.interfaces.nsIAtomService)
        self.folderOpenAtom = self.atomSvc.getAtom("folderOpen")
                               
        self.folderClosedAtom = self.atomSvc.getAtom("folderClosed")

    def initialize(self, templateSvc, templatesView):
        # Need to unwrap these Python XPCOM object because we access
        # methods on them that are not in the IDL.
        self.templateSvc = UnwrapObject(templateSvc)
        self.templatesView = UnwrapObject(templatesView)
        
        if not self.templateSvc.loaded:
            self.templateSvc.loadTemplates()
        self.templateTree = self.templateSvc.getTemplateTree() # a working copy
        
        # Restore the user selections from prefs
        stbcStr = self._prefSvc.getStringPref("%s_selected_template_by_category" % self.templateSvc.basename)
        try:
            self.selectedTemplateByCategory = eval(stbcStr)
        except SyntaxError, ex:
            self.selectedTemplateByCategory = {}
        ocStr = self._prefSvc.getStringPref("%s_open_categories" % self.templateSvc.basename)
        try:
            self.categoryIsOpen = eval(ocStr)
        except SyntaxError, ex:
            self.categoryIsOpen = {}
开发者ID:,项目名称:,代码行数:55,代码来源:


示例16: _loadAllLanguages

 def _loadAllLanguages(self):
     self._allRows = []
     langRegistry = components.classes["@activestate.com/koLanguageRegistryService;1"].getService(components.interfaces.koILanguageRegistryService)
     langRegistry = UnwrapObject(langRegistry)
     langNames = langRegistry.getLanguageNames()
     for langName in langNames:
         isPrimary = langRegistry._primaryLanguageNames.get(langName, False)
         self._allRows.append({'name':langName,
                               'name_lc':langName.lower(),
                               'status':isPrimary,
                               'origStatus':isPrimary})
开发者ID:harpchad,项目名称:KomodoEdit,代码行数:11,代码来源:koLanguage.py


示例17: _gatherIconsAux

 def _gatherIconsAux(self, part, icons):
     part = UnwrapObject(part)
     icon = part.get_iconurl()
     if self.test:
         print "icon [%s]"%icon
     if not icon.startswith(('chrome://', 'moz-icon://stock/')):
         newicon = os.path.join('.icons', os.path.basename(icon))
         part.set_iconurl(newicon)
         icons.append((uriparse.URIToLocalPath(icon),newicon))
     if hasattr(part, 'getChildren'):
         for p in part.getChildren():
             self._gatherIconsAux(p, icons)
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:12,代码来源:koProjectPackageService.py


示例18: save

 def save(self, prefs):
     if not self._wasChanged:
         return
     langRegistry = UnwrapObject(Cc["@activestate.com/koLanguageRegistryService;1"]
                                   .getService(Ci.koILanguageRegistryService))
     for row in self._rows:
         langName, status, origStatus = row['name'], row['status'], row['origStatus']
         if status != origStatus:
             langRegistry.changeLanguageStatus(langName, status)
             # Update the pref
             primaryLanguagePref = "languages/%s/primary" % (langName,)
             prefs.setBoolean(primaryLanguagePref, bool(status))
     self.notifyObservers(None, 'primary_languages_changed', '')
开发者ID:harpchad,项目名称:KomodoEdit,代码行数:13,代码来源:koLanguage.py


示例19: savePrefs

 def savePrefs(self, kpf):
     prefSvc = components.classes["@activestate.com/koPrefService;1"]\
                         .getService().prefs # global prefs
     # multi tree, we want JUST the project passed in.  Get all the
     # id's from the project, and then get the matching id's from
     # nodeIsOpen
     kpf = UnwrapObject(kpf)
     nodeIsOpen = {}
     for id in self._nodeIsOpen.keys():
         if kpf.getChildById(id):
             nodeIsOpen[id] = self._nodeIsOpen[id]
     prefSvc.setStringPref("kpf_open_nodes_%s" % kpf.id,
                           repr(nodeIsOpen))
开发者ID:,项目名称:,代码行数:13,代码来源:


示例20: paths

 def paths(self):
     """Generate all paths for this collection."""
     for type, item in self.items:
         if type == "path":
             yield item
         elif type == "file":
             path = _local_path_from_url(item.url)
             if path is not None:
                 yield path
         elif type == "container":
             container = UnwrapObject(item)
             for path in container.genLocalPaths():
                 yield path                
开发者ID:Acidburn0zzz,项目名称:KomodoEdit,代码行数:13,代码来源:koFindContext.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xpidl.unaliasType函数代码示例发布时间:2022-05-26
下一篇:
Python dsl.descendant函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap