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

Python util.parsedate函数代码示例

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

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



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

示例1: __init__

    def __init__(self, repo, text="", user=None, date=None, extra=None,
                 changes=None):
        self._repo = repo
        self._rev = None
        self._node = None
        self._text = text
        if date:
            self._date = util.parsedate(date)
        if user:
            self._user = user
        if changes:
            self._status = list(changes[:4])
            self._unknown = changes[4]
            self._ignored = changes[5]
            self._clean = changes[6]
        else:
            self._unknown = None
            self._ignored = None
            self._clean = None

        self._extra = {}
        if extra:
            self._extra = extra.copy()
        if 'branch' not in self._extra:
            branch = self._repo.dirstate.branch()
            try:
                branch = branch.decode('UTF-8').encode('UTF-8')
            except UnicodeDecodeError:
                raise util.Abort(_('branch name not in UTF-8!'))
            self._extra['branch'] = branch
        if self._extra['branch'] == '':
            self._extra['branch'] = 'default'
开发者ID:helloandre,项目名称:cr48,代码行数:32,代码来源:context.py


示例2: __init__

    def __init__(self, repo, text="", user=None, date=None, extra=None, changes=None):
        self._repo = repo
        self._rev = None
        self._node = None
        self._text = text
        if date:
            self._date = util.parsedate(date)
        if user:
            self._user = user
        if changes:
            self._status = list(changes[:4])
            self._unknown = changes[4]
            self._ignored = changes[5]
            self._clean = changes[6]
        else:
            self._unknown = None
            self._ignored = None
            self._clean = None

        self._extra = {}
        if extra:
            self._extra = extra.copy()
        if "branch" not in self._extra:
            try:
                branch = encoding.fromlocal(self._repo.dirstate.branch())
            except UnicodeDecodeError:
                raise util.Abort(_("branch name not in UTF-8!"))
            self._extra["branch"] = branch
        if self._extra["branch"] == "":
            self._extra["branch"] = "default"
开发者ID:yonas,项目名称:HgWeb-Syntax-Highlighter,代码行数:30,代码来源:context.py


示例3: add

    def add(self, manifest, files, desc, transaction, p1, p2,
                  user, date=None, extra={}):
        user = user.strip()
        # An empty username or a username with a "\n" will make the
        # revision text contain two "\n\n" sequences -> corrupt
        # repository since read cannot unpack the revision.
        if not user:
            raise error.RevlogError(_("empty username"))
        if "\n" in user:
            raise error.RevlogError(_("username %s contains a newline")
                                    % repr(user))

        # strip trailing whitespace and leading and trailing empty lines
        desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')

        user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)

        if date:
            parseddate = "%d %d" % util.parsedate(date)
        else:
            parseddate = "%d %d" % util.makedate()
        if extra and extra.get("branch") in ("default", ""):
            del extra["branch"]
        if extra:
            extra = encodeextra(extra)
            parseddate = "%s %s" % (parseddate, extra)
        l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
        text = "\n".join(l)
        return self.addrevision(text, transaction, len(self), p1, p2)
开发者ID:Nurb432,项目名称:plan9front,代码行数:29,代码来源:changelog.py


示例4: create

    def create(self, transaction, prec, succs=(), flag=0, parents=None,
               date=None, metadata=None):
        """obsolete: add a new obsolete marker

        * ensuring it is hashable
        * check mandatory metadata
        * encode metadata

        If you are a human writing code creating marker you want to use the
        `createmarkers` function in this module instead.

        return True if a new marker have been added, False if the markers
        already existed (no op).
        """
        if metadata is None:
            metadata = {}
        if date is None:
            if 'date' in metadata:
                # as a courtesy for out-of-tree extensions
                date = util.parsedate(metadata.pop('date'))
            else:
                date = util.makedate()
        if len(prec) != 20:
            raise ValueError(prec)
        for succ in succs:
            if len(succ) != 20:
                raise ValueError(succ)
        if prec in succs:
            raise ValueError(_('in-marker cycle with %s') % node.hex(prec))

        metadata = tuple(sorted(metadata.iteritems()))

        marker = (str(prec), tuple(succs), int(flag), metadata, date, parents)
        return bool(self.add(transaction, [marker]))
开发者ID:areshero,项目名称:ThirdWorldApp,代码行数:34,代码来源:obsolete.py


示例5: __init__

    def __init__(self, repo, parents=None, text="", user=None, date=None,
                 extra=None, changes=None):
        self._repo = repo
        self._rev = None
        self._node = None
        self._text = text
        if date:
            self._date = util.parsedate(date)
        if user:
            self._user = user
        if parents:
            self._parents = [changectx(self._repo, p) for p in parents]
        if changes:
            self._status = list(changes)

        self._extra = {}
        if extra:
            self._extra = extra.copy()
        if 'branch' not in self._extra:
            branch = self._repo.dirstate.branch()
            try:
                branch = branch.decode('UTF-8').encode('UTF-8')
            except UnicodeDecodeError:
                raise util.Abort(_('branch name not in UTF-8!'))
            self._extra['branch'] = branch
        if self._extra['branch'] == '':
            self._extra['branch'] = 'default'
开发者ID:Frostman,项目名称:intellij-community,代码行数:27,代码来源:context.py


示例6: commit

def commit(ui, repo, commitfunc, pats, opts):
    '''commit the specified files or all outstanding changes'''
    date = opts.get('date')
    if date:
        opts['date'] = util.parsedate(date)
    message = logmessage(opts)

    # extract addremove carefully -- this function can be called from a command
    # that doesn't support addremove
    if opts.get('addremove'):
        addremove(repo, pats, opts)

    return commitfunc(ui, repo, message, match(repo, pats, opts), opts)
开发者ID:MezzLabs,项目名称:mercurial,代码行数:13,代码来源:cmdutil.py


示例7: commit

def commit(ui, repo, commitfunc, pats, opts):
    '''commit the specified files or all outstanding changes'''
    date = opts.get('date')
    if date:
        opts['date'] = util.parsedate(date)
    message = logmessage(opts)

    # extract addremove carefully -- this function can be called from a command
    # that doesn't support addremove
    if opts.get('addremove'):
        addremove(repo, pats, opts)

    fns, match, anypats = matchpats(repo, pats, opts)
    if pats:
        status = repo.status(files=fns, match=match)
        modified, added, removed, deleted, unknown = status[:5]
        files = modified + added + removed
        slist = None
        for f in fns:
            if f == '.':
                continue
            if f not in files:
                rf = repo.wjoin(f)
                rel = repo.pathto(f)
                try:
                    mode = os.lstat(rf)[stat.ST_MODE]
                except OSError:
                    raise util.Abort(_("file %s not found!") % rel)
                if stat.S_ISDIR(mode):
                    name = f + '/'
                    if slist is None:
                        slist = list(files)
                        slist.sort()
                    i = bisect.bisect(slist, name)
                    if i >= len(slist) or not slist[i].startswith(name):
                        raise util.Abort(_("no match under directory %s!")
                                         % rel)
                elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
                    raise util.Abort(_("can't commit %s: "
                                       "unsupported file type!") % rel)
                elif f not in repo.dirstate:
                    raise util.Abort(_("file %s not tracked!") % rel)
    else:
        files = []
    try:
        return commitfunc(ui, repo, files, message, match, opts)
    except ValueError, inst:
        raise util.Abort(str(inst))
开发者ID:c0ns0le,项目名称:cygwin,代码行数:48,代码来源:cmdutil.py


示例8: commit

def commit(ui, repo, commitfunc, pats, opts):
    '''commit the specified files or all outstanding changes'''
    date = opts.get('date')
    if date:
        opts['date'] = util.parsedate(date)
    message = logmessage(opts)

    # extract addremove carefully -- this function can be called from a command
    # that doesn't support addremove
    if opts.get('addremove'):
        addremove(repo, pats, opts)

    m = match(repo, pats, opts)
    if pats:
        modified, added, removed = repo.status(match=m)[:3]
        files = util.sort(modified + added + removed)

        def is_dir(f):
            name = f + '/'
            i = bisect.bisect(files, name)
            return i < len(files) and files[i].startswith(name)

        for f in m.files():
            if f == '.':
                continue
            if f not in files:
                rf = repo.wjoin(f)
                rel = repo.pathto(f)
                try:
                    mode = os.lstat(rf)[stat.ST_MODE]
                except OSError:
                    if is_dir(f): # deleted directory ?
                        continue
                    raise util.Abort(_("file %s not found!") % rel)
                if stat.S_ISDIR(mode):
                    if not is_dir(f):
                        raise util.Abort(_("no match under directory %s!")
                                         % rel)
                elif not (stat.S_ISREG(mode) or stat.S_ISLNK(mode)):
                    raise util.Abort(_("can't commit %s: "
                                       "unsupported file type!") % rel)
                elif f not in repo.dirstate:
                    raise util.Abort(_("file %s not tracked!") % rel)
        m = matchfiles(repo, files)
    try:
        return commitfunc(ui, repo, message, m, opts)
    except ValueError, inst:
        raise util.Abort(str(inst))
开发者ID:pombredanne,项目名称:SmartNotes,代码行数:48,代码来源:cmdutil.py


示例9: add

    def add(self, manifest, list, desc, transaction, p1=None, p2=None,
                  user=None, date=None, extra={}):

        user, desc = util.fromlocal(user), util.fromlocal(desc)

        if date:
            parseddate = "%d %d" % util.parsedate(date)
        else:
            parseddate = "%d %d" % util.makedate()
        if extra and extra.get("branch") in ("default", ""):
            del extra["branch"]
        if extra:
            extra = self.encode_extra(extra)
            parseddate = "%s %s" % (parseddate, extra)
        list.sort()
        l = [hex(manifest), user, parseddate] + list + ["", desc]
        text = "\n".join(l)
        return self.addrevision(text, transaction, self.count(), p1, p2)
开发者ID:c0ns0le,项目名称:cygwin,代码行数:18,代码来源:changelog.py


示例10: __init__

    def __init__(self, repo, parents, text, files, filectxfn, user=None,
                 date=None, extra=None):
        self._repo = repo
        self._rev = None
        self._node = None
        self._text = text
        self._date = date and util.parsedate(date) or util.makedate()
        self._user = user
        parents = [(p or nullid) for p in parents]
        p1, p2 = parents
        self._parents = [changectx(self._repo, p) for p in (p1, p2)]
        files = util.sort(util.unique(files))
        self._status = [files, [], [], [], []]
        self._filectxfn = filectxfn

        self._extra = extra and extra.copy() or {}
        if 'branch' not in self._extra:
            self._extra['branch'] = 'default'
        elif self._extra.get('branch') == '':
            self._extra['branch'] = 'default'
开发者ID:pombredanne,项目名称:SmartNotes,代码行数:20,代码来源:context.py


示例11: add

    def add(self, manifest, files, desc, transaction, p1=None, p2=None,
                  user=None, date=None, extra={}):

        user = user.strip()
        if "\n" in user:
            raise error.RevlogError(_("username %s contains a newline")
                                    % repr(user))
        user, desc = util.fromlocal(user), util.fromlocal(desc)

        if date:
            parseddate = "%d %d" % util.parsedate(date)
        else:
            parseddate = "%d %d" % util.makedate()
        if extra and extra.get("branch") in ("default", ""):
            del extra["branch"]
        if extra:
            extra = self.encode_extra(extra)
            parseddate = "%s %s" % (parseddate, extra)
        l = [hex(manifest), user, parseddate] + util.sort(files) + ["", desc]
        text = "\n".join(l)
        return self.addrevision(text, transaction, len(self), p1, p2)
开发者ID:pombredanne,项目名称:SmartNotes,代码行数:21,代码来源:changelog.py


示例12: add

    def add(self, manifest, files, desc, transaction, p1, p2,
                  user, date=None, extra=None):
        # Convert to UTF-8 encoded bytestrings as the very first
        # thing: calling any method on a localstr object will turn it
        # into a str object and the cached UTF-8 string is thus lost.
        user, desc = encoding.fromlocal(user), encoding.fromlocal(desc)

        user = user.strip()
        # An empty username or a username with a "\n" will make the
        # revision text contain two "\n\n" sequences -> corrupt
        # repository since read cannot unpack the revision.
        if not user:
            raise error.RevlogError(_("empty username"))
        if "\n" in user:
            raise error.RevlogError(_("username %s contains a newline")
                                    % repr(user))

        # strip trailing whitespace and leading and trailing empty lines
        desc = '\n'.join([l.rstrip() for l in desc.splitlines()]).strip('\n')

        if date:
            parseddate = "%d %d" % util.parsedate(date)
        else:
            parseddate = "%d %d" % util.makedate()
        if extra:
            branch = extra.get("branch")
            if branch in ("default", ""):
                del extra["branch"]
            elif branch in (".", "null", "tip"):
                raise error.RevlogError(_('the name \'%s\' is reserved')
                                        % branch)
        if extra:
            extra = encodeextra(extra)
            parseddate = "%s %s" % (parseddate, extra)
        l = [hex(manifest), user, parseddate] + sorted(files) + ["", desc]
        text = "\n".join(l)
        return self.addrevision(text, transaction, len(self), p1, p2)
开发者ID:agbiotec,项目名称:galaxy-tools-vcr,代码行数:37,代码来源:changelog.py


示例13: localdate

def localdate(text):
    """:localdate: Date. Converts a date to local date."""
    return (util.parsedate(text)[0], util.makedate()[1])
开发者ID:chuchiperriman,项目名称:hg-stable,代码行数:3,代码来源:templatefilters.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.password_hash函数代码示例发布时间:2022-05-26
下一篇:
Python util.params函数代码示例发布时间: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