repl.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:uhu 作者: updatehub 项目源码 文件源码
def __init__(self, package_fn=None):
        """Creates a new interactive prompt.

        The interactive prompt will work using an exisiting
        configuration file (if it exists).

        It is also able to load an existing configuration file placed
        in a non standard place if REPL is created using the
        `package_fn`.

        Finally, if there is no configuration file present in the
        working directory, neighter a package file is explicty passed,
        `UHURepl` will create a new one.

        :param package_fn: An UHU package filename.
        """
        self.local_config = get_local_config_file()

        if package_fn is not None:
            self.package = self.load_package(package_fn)
        elif os.path.exists(self.local_config):
            self.package = self.load_package(self.local_config)
        else:
            self.package = Package()

        if self.package.product:
            self.prompt = set_product_prompt(self.package.product)
        else:
            self.prompt = 'uhu> '

        self.arg = None
        self.history = InMemoryHistory()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号