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


Python Lock.is_lock_file方法代码示例

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


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

示例1: filter_objects_to_download

# 需要导入模块: from lock import Lock [as 别名]
# 或者: from lock.Lock import is_lock_file [as 别名]
    def filter_objects_to_download(remote_object_list):
        filtered_object_list = {}

        logger.debug('Filtering %i remote objects to download.', len(remote_object_list))

        for (name, object) in remote_object_list.items():
            logger.debug('Processing remote object "%s" at version %i.', object['name'], object['version'])

            if Lock.is_lock_file(name):
                logger.debug('Skipping server lock file.')
                continue

            try:
                # throws
                local_version = working_copy.meta_file.get_object_version(object['name'])

                logger.debug('Object exists locally since last pull.')

                # file has existed locally since last sync
            
                if local_version == object['version']:
                    # nothing changed - we have the same version as on the server
                    # although local file may be dirty
                    logger.debug('Local object version %i and remote object version %i match, no download needed.', local_version, object['version'])
                    continue

                # versions are strictly increasing
                assert(object['version'] > local_version)

                logger.debug('Local object version %i is outdated and superseeded by remote object version %i.', local_version, object['version'])

                if dirty.is_local_object_dirty(working_copy, object['name']):
                    logger.debug('Local object is dirty, bailing out with conflict.')
                    raise pithossync.ConflictError
            except KeyError:
                # file is new on the server-side
                # check if it has also been created locally

                logger.debug('Object is new since last pull.')
                
                # check if folder
                if object['is_folder'] and os.path.isdir(object['name']):
                    logger.debug('Remote object is a folder and has also been created locally, no action needed.')

                    # remote object is a folder and has also been created locally as a folder
                    # nothing to do
                    continue

                if dirty.is_local_object_dirty(working_copy, object['name']):
                    logger.debug('Object has also been created independently locally, bailing out with conflict.')

                    raise pithossync.ConflictError

            if object['is_folder']:
                type = 'folder'
            else:
                type = 'file'

            logger.debug('Queueing remote object of type %s named "%s" at version "%i" to be fetched.', type, object['name'], object['version'])

            filtered_object_list[object['name']] = object

        logger.debug('%i remote objects filtered down to %i.', len(remote_object_list), len(filtered_object_list))

        return filtered_object_list
开发者ID:dionyziz,项目名称:pithossync,代码行数:67,代码来源:pull.py


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