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


Python sample.__file__方法代码示例

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


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

示例1: setupTxns

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def setupTxns(self):
        import data
        dataDir = os.path.dirname(data.__file__)

        tmpENVS = {
            "local": Environment("pool_transactions_local",
                                 "transactions_local"),
        }
        tmpENVS.update(ENVS)
        for envName, env in tmpENVS.items():
            for _, fileName in env._asdict().items():
                sourceFilePath = os.path.join(dataDir, fileName)
                if os.path.exists(sourceFilePath):
                    destFilePath = os.path.join(self.base_dir, fileName)
                    copyfile(sourceFilePath, destFilePath)

        return self 
开发者ID:sovrin-foundation,项目名称:old-sovrin,代码行数:19,代码来源:setup_util.py

示例2: test_moduleNotInPath

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_moduleNotInPath(self):
        """
        If passed the path to a file containing the implementation of a
        module within a package which is not on the import path,
        L{runner.filenameToModule} returns a module object loosely
        resembling the module defined by that file anyway.
        """
        # "test_sample" isn't actually the name of this module.  However,
        # filenameToModule can't seem to figure that out.  So clean up this
        # mis-named module.  It would be better if this weren't necessary
        # and filenameToModule either didn't exist or added a correctly
        # named module to sys.modules.
        self.addCleanup(sys.modules.pop, 'test_sample', None)

        self.mangleSysPath(self.oldPath)
        sample1 = runner.filenameToModule(
            os.path.join(self.parent, 'goodpackage', 'test_sample.py'))
        self.mangleSysPath(self.newPath)
        from goodpackage import test_sample as sample2
        self.failUnlessEqual(os.path.splitext(sample2.__file__)[0],
                             os.path.splitext(sample1.__file__)[0]) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:23,代码来源:test_loader.py

示例3: test_packageNotInPath

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_packageNotInPath(self):
        """
        If passed the path to a directory which represents a package which
        is not on the import path, L{runner.filenameToModule} returns a
        module object loosely resembling the package defined by that
        directory anyway.
        """
        # "__init__" isn't actually the name of the package!  However,
        # filenameToModule is pretty stupid and decides that is its name
        # after all.  Make sure it gets cleaned up.  See the comment in
        # test_moduleNotInPath for possible courses of action related to
        # this.
        self.addCleanup(sys.modules.pop, "__init__")

        self.mangleSysPath(self.oldPath)
        package1 = runner.filenameToModule(
            os.path.join(self.parent, 'goodpackage'))
        self.mangleSysPath(self.newPath)
        import goodpackage
        self.failUnlessEqual(os.path.splitext(goodpackage.__file__)[0],
                             os.path.splitext(package1.__file__)[0]) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:23,代码来源:test_loader.py

示例4: test_directory

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_directory(self):
        """
        Test loader against a filesystem directory. It should handle
        'path' and 'path/' the same way.
        """
        path  = util.sibpath(__file__, 'goodDirectory')
        os.mkdir(path)
        f = file(os.path.join(path, '__init__.py'), "w")
        f.close()
        try:
            module = runner.filenameToModule(path)
            self.assert_(module.__name__.endswith('goodDirectory'))
            module = runner.filenameToModule(path + os.path.sep)
            self.assert_(module.__name__.endswith('goodDirectory'))
        finally:
            shutil.rmtree(path) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:18,代码来源:test_loader.py

示例5: setupTxns

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def setupTxns(self, key, force: bool = False):
        """
        Create base transactions

        :param key: ledger
        :param force: replace existing transaction files
        """
        import data
        dataDir = os.path.dirname(data.__file__)

        # TODO: Need to get "test" and "live" from ENVS property in config.py
        # but that gives error due to some dependency issue
        allEnvs = {
            "local": Environment("pool_transactions_local",
                                 "domain_transactions_local"),
            "test": Environment("pool_transactions_sandbox",
                                "domain_transactions_sandbox"),
            "live": Environment("pool_transactions_live",
                                "domain_transactions_live")
        }
        for env in allEnvs.values():
            fileName = getattr(env, key, None)
            if not fileName:
                continue
            sourceFilePath = os.path.join(dataDir, fileName)
            if not os.path.exists(sourceFilePath):
                continue
            destFilePath = os.path.join(
                self.base_dir, genesis_txn_file(fileName))
            if os.path.exists(destFilePath) and not force:
                continue
            copyfile(sourceFilePath, destFilePath)

        return self 
开发者ID:hyperledger,项目名称:indy-node,代码行数:36,代码来源:setup_util.py

示例6: setupSampleInvites

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def setupSampleInvites(self):
        import sample
        sdir = os.path.dirname(sample.__file__)
        sidir = os.path.join(self.base_dir, "sample")
        os.makedirs(sidir, exist_ok=True)
        files = glob.iglob(os.path.join(sdir, "*.indy"))
        for file in files:
            if os.path.isfile(file):
                copy2(file, sidir)
        return self 
开发者ID:hyperledger,项目名称:indy-node,代码行数:12,代码来源:setup_util.py

示例7: setupSampleInvites

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def setupSampleInvites(self):
        import sample
        sdir = os.path.dirname(sample.__file__)
        sidir = os.path.join(self.base_dir, "sample")
        os.makedirs(sidir, exist_ok=True)
        files = glob.iglob(os.path.join(sdir, "*.sovrin"))
        for file in files:
            if os.path.isfile(file):
                shutil.copy2(file, sidir)
        return self 
开发者ID:sovrin-foundation,项目名称:old-sovrin,代码行数:12,代码来源:setup_util.py

示例8: getInvitationFile

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def getInvitationFile(fileName):
    sampleDir = os.path.dirname(sample.__file__)
    return os.path.join(sampleDir, fileName) 
开发者ID:sovrin-foundation,项目名称:old-sovrin,代码行数:5,代码来源:conftest.py

示例9: test_findFile

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_findFile(self):
        path = util.sibpath(__file__, 'sample.py')
        sample1 = self.loader.findByName(path)
        import sample as sample2
        self.failUnlessEqual(sample1, sample2) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:7,代码来源:test_loader.py

示例10: test_findNonFile

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_findNonFile(self):
        path = util.sibpath(__file__, 'nonexistent.py')
        self.failUnlessRaises(ValueError, self.loader.findByName, path) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:5,代码来源:test_loader.py

示例11: test_moduleInPath

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_moduleInPath(self):
        sample1 = runner.filenameToModule(util.sibpath(__file__, 'sample.py'))
        import sample as sample2
        self.failUnlessEqual(sample2, sample1) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:6,代码来源:test_loader.py

示例12: test_filenameNotPython

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_filenameNotPython(self):
        self.failUnlessRaises(ValueError, runner.filenameToModule,
                              util.sibpath(__file__, 'notpython.py')) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:5,代码来源:test_loader.py

示例13: test_filenameMatchesPackage

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_filenameMatchesPackage(self):
        filename = os.path.join(self.parent, 'goodpackage.py')
        fd = open(filename, 'w')
        fd.write(packages.testModule)
        fd.close()
        try:
            module = runner.filenameToModule(filename)
            self.failUnlessEqual(filename, module.__file__)
        finally:
            os.remove(filename) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:12,代码来源:test_loader.py

示例14: test_moduleNotInPath

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_moduleNotInPath(self):
        sys.path, newPath = self.oldPath, sys.path
        sample1 = runner.filenameToModule(os.path.join(self.parent,
                                                       'goodpackage',
                                                       'test_sample.py'))
        sys.path = newPath
        from goodpackage import test_sample as sample2
        self.failUnlessEqual(os.path.splitext(sample2.__file__)[0],
                             os.path.splitext(sample1.__file__)[0]) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:11,代码来源:test_loader.py

示例15: test_packageNotInPath

# 需要导入模块: import sample [as 别名]
# 或者: from sample import __file__ [as 别名]
def test_packageNotInPath(self):
        sys.path, newPath = self.oldPath, sys.path
        package1 = runner.filenameToModule(os.path.join(self.parent,
                                                        'goodpackage'))
        sys.path = newPath
        import goodpackage
        self.failUnlessEqual(os.path.splitext(goodpackage.__file__)[0],
                             os.path.splitext(package1.__file__)[0]) 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:10,代码来源:test_loader.py


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