本文整理汇总了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'
示例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"
示例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)
示例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]))
示例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'
示例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)
示例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))
示例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))
示例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)
示例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'
示例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)
示例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)
示例13: localdate
def localdate(text):
""":localdate: Date. Converts a date to local date."""
return (util.parsedate(text)[0], util.makedate()[1])