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


Python History.get_state方法代码示例

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


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

示例1: revert_actions

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import get_state [as 别名]
    def revert_actions(self, arg):
        """
        Calculate the actions necessary to revert to a given state, the
        argument may be one of:
          * complete set of eggs, i.e. a set of egg file names
          * revision number (negative numbers allowed)
          * datetime in ISO format, i.e. YYYY-mm-dd HH:MM:SS
          * simple strings like '1 day ago', see parse_dt module
        """
        if self.hook:
            raise NotImplementedError
        h = History(self.prefixes[0])
        h.update()
        if isinstance(arg, set):
            state = arg
        else:
            state = self._get_state(h, arg)

        curr = h.get_state()
        if state == curr:
            return []

        res = []
        for egg in curr - state:
            res.append(("remove", egg))

        for egg in state - curr:
            if not isfile(join(self.local_dir, egg)):
                self._connect()
                if self.remote.exists(egg):
                    res.append(("fetch_0", egg))
                else:
                    raise EnpkgError("cannot revert -- missing %r" % egg)
            res.append(("install", egg))
        return res
开发者ID:jasonmccampbell,项目名称:enstaller,代码行数:37,代码来源:enpkg.py

示例2: revert_actions

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import get_state [as 别名]
    def revert_actions(self, arg):
        """
        Calculate the actions necessary to revert to a given state, the
        argument may be one of:
          * complete set of eggs, i.e. a set of egg file names
          * revision number (negative numbers allowed)
        """
        if self.hook:
            raise NotImplementedError
        h = History(self.prefixes[0])
        h.update()
        if isinstance(arg, set):
            state = arg
        else:
            try:
                rev = int(arg)
            except ValueError:
                raise EnpkgError("Error: integer expected, got: %r" % arg)
            try:
                state = h.get_state(rev)
            except IndexError:
                raise EnpkgError("Error: no such revision: %r" % arg)

        curr = h.get_state()
        if state == curr:
            return []

        res = []
        for egg in curr - state:
            if egg.startswith('enstaller'):
                continue
            res.append(('remove', egg))

        for egg in state - curr:
            if egg.startswith('enstaller'):
                continue
            if not isfile(join(self.local_dir, egg)):
                self._connect()
                if self.remote.exists(egg):
                    res.append(('fetch_0', egg))
                else:
                    raise EnpkgError("cannot revert -- missing %r" % egg)
            res.append(('install', egg))
        return res
开发者ID:shaheershantk,项目名称:Blog-Engine-Using-Flask,代码行数:46,代码来源:enpkg.py

示例3: revert

# 需要导入模块: from history import History [as 别名]
# 或者: from history.History import get_state [as 别名]
def revert(enst, rev_in, quiet=False):
    history = History(enst.prefixes[0])
    try:
        rev = int(rev_in)
    except ValueError:
        # we have a "date string"
        from parse_dt import parse
        rev = parse(rev_in)
        if rev is None:
            sys.exit("Error: could not parse: %r" % rev_in)

    print "reverting to: %r" % rev
    try:
        state = history.get_state(rev)
    except IndexError:
        sys.exit("Error: no such revision: %r" % rev)

    curr = set(egginst.get_installed())
    if state == curr:
        print "Nothing to revert"
        return

    # remove packages
    for fn in curr - state:
        enst.remove_egg(fn)

    # install packages (fetch from server if necessary)
    to_install = []
    need_fetch = []
    for fn in state - curr:
        to_install.append(fn)
        if not isfile(join(enst.egg_dir, fn)):
            need_fetch.append(fn)
    if need_fetch:
        for fn in need_fetch:
            dist = enst.chain.get_dist(filename_as_req(fn))
            if dist:
                enst.chain.fetch_dist(dist, enst.egg_dir,
                                      dry_run=enst.dry_run)
    for fn in to_install:
        egg_path = join(enst.egg_dir, fn)
        if isfile(egg_path):
            ei = egginst.EggInst(egg_path)
            ei.install()

    history.update()
开发者ID:ilanschnell,项目名称:enstaller,代码行数:48,代码来源:main.py


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