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


Python Object.get方法代码示例

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


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

示例1: refresh_commit_info

# 需要导入模块: from ming.base import Object [as 别名]
# 或者: from ming.base.Object import get [as 别名]
 def refresh_commit_info(self, oid, seen_object_ids, lazy=True):
     from allura.model.repository import CommitDoc
     ci_doc = CommitDoc.m.get(_id=oid)
     if ci_doc and lazy:
         return False
     revno = self._revno(oid)
     rev = self._revision(oid)
     try:
         log_entry = self._svn.log(
             self._url,
             revision_start=rev,
             limit=1,
             discover_changed_paths=True)[0]
     except pysvn.ClientError:
         log.info('ClientError processing %r %r, treating as empty',
                  oid, self._repo, exc_info=True)
         log_entry = Object(date='', message='', changed_paths=[])
     log_date = None
     if hasattr(log_entry, 'date'):
         log_date = datetime.utcfromtimestamp(log_entry.date)
     user = Object(
         name=h.really_unicode(log_entry.get('author', '--none--')),
         email='',
         date=log_date)
     args = dict(
         tree_id=None,
         committed=user,
         authored=user,
         message=h.really_unicode(log_entry.get("message", "--none--")),
         parent_ids=[],
         child_ids=[])
     if revno > 1:
         args['parent_ids'] = [self._oid(revno - 1)]
     if ci_doc:
         ci_doc.update(**args)
         ci_doc.m.save()
     else:
         ci_doc = CommitDoc(dict(args, _id=oid))
         try:
             ci_doc.m.insert(safe=True)
         except DuplicateKeyError:
             if lazy:
                 return False
     return True
开发者ID:apache,项目名称:allura,代码行数:46,代码来源:svn.py

示例2: refresh_commit_info

# 需要导入模块: from ming.base import Object [as 别名]
# 或者: from ming.base.Object import get [as 别名]
 def refresh_commit_info(self, oid, seen_object_ids, lazy=True):
     from allura.model.repo import CommitDoc, DiffInfoDoc
     ci_doc = CommitDoc.m.get(_id=oid)
     if ci_doc and lazy:
         return False
     revno = self._revno(oid)
     rev = self._revision(oid)
     try:
         log_entry = self._svn.log(
             self._url,
             revision_start=rev,
             limit=1,
             discover_changed_paths=True)[0]
     except pysvn.ClientError:
         log.info('ClientError processing %r %r, treating as empty',
                  oid, self._repo, exc_info=True)
         log_entry = Object(date='', message='', changed_paths=[])
     log_date = None
     if hasattr(log_entry, 'date'):
         log_date = datetime.utcfromtimestamp(log_entry.date)
     user = Object(
         name=h.really_unicode(log_entry.get('author', '--none--')),
         email='',
         date=log_date)
     args = dict(
         tree_id=None,
         committed=user,
         authored=user,
         message=h.really_unicode(log_entry.get("message", "--none--")),
         parent_ids=[],
         child_ids=[])
     if revno > 1:
         args['parent_ids'] = [self._oid(revno - 1)]
     if ci_doc:
         ci_doc.update(**args)
         ci_doc.m.save()
     else:
         ci_doc = CommitDoc(dict(args, _id=oid))
         try:
             ci_doc.m.insert(safe=True)
         except DuplicateKeyError:
             if lazy:
                 return False
     # Save diff info
     di = DiffInfoDoc.make(dict(_id=ci_doc._id, differences=[]))
     for path in log_entry.changed_paths:
         if path.action in ('A', 'M', 'R'):
             try:
                 rhs_info = self._svn.info2(
                     self._url + h.really_unicode(path.path),
                     revision=self._revision(ci_doc._id),
                     recurse=False)[0][1]
                 rhs_id = self._obj_oid(ci_doc._id, rhs_info)
             except pysvn.ClientError, e:
                 # pysvn will sometimes misreport deleted files (D) as
                 # something else (like A), causing info2() to raise a
                 # ClientError since the file doesn't exist in this
                 # revision. Set lrhs_id = None to treat like a deleted file
                 log.info('This error was handled gracefully and logged '
                          'for informational purposes only:\n' + str(e))
                 rhs_id = None
         else:
             rhs_id = None
         if ci_doc.parent_ids and path.action in ('D', 'M', 'R'):
             try:
                 lhs_info = self._svn.info2(
                     self._url + h.really_unicode(path.path),
                     revision=self._revision(ci_doc.parent_ids[0]),
                     recurse=False)[0][1]
                 lhs_id = self._obj_oid(ci_doc._id, lhs_info)
             except pysvn.ClientError, e:
                 # pysvn will sometimes report new files as 'M'odified,
                 # causing info2() to raise ClientError since the file
                 # doesn't exist in the parent revision. Set lhs_id = None
                 # to treat like a newly added file.
                 log.info('This error was handled gracefully and logged '
                          'for informational purposes only:\n' + str(e))
                 lhs_id = None
开发者ID:AsylumCorp,项目名称:incubator-allura,代码行数:80,代码来源:svn.py


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