示例#1
0
文件: core.py 项目: vortexvt/pontoon
def update_resources(db_project, vcs_project):
    """Update the database on what resource files exist in VCS."""
    log.debug(f"Scanning {vcs_project.source_directory_path}")
    vcs_changed_files, vcs_removed_files = vcs_project.changed_source_files

    removed_resources = db_project.resources.filter(path__in=vcs_removed_files)
    removed_paths = removed_resources.values_list("path", flat=True)

    changed_resources = db_project.resources.filter(path__in=vcs_changed_files)
    changed_paths = changed_resources.values_list("path", flat=True)

    added_paths = []

    log.debug("Removed files: {}".format(", ".join(removed_paths) or "None"))
    removed_resources.delete()

    for relative_path, vcs_resource in vcs_project.resources.items():
        resource, created = db_project.resources.get_or_create(
            path=relative_path)
        resource.format = Resource.get_path_format(relative_path)
        resource.total_strings = len(vcs_resource.entities)
        resource.save()

        if created:
            added_paths.append(relative_path)

    log.debug("Added files: {}".format(", ".join(added_paths) or "None"))
    return added_paths, removed_paths, changed_paths
示例#2
0
文件: core.py 项目: sportymsk/pontoon
def update_resources(db_project, vcs_project):
    """Update the database on what resource files exist in VCS."""
    log.debug('Scanning {}'.format(vcs_project.source_directory_path))
    _, vcs_removed_files = vcs_project.changed_source_files

    removed_resources = db_project.resources.filter(path__in=vcs_removed_files)
    removed_paths = removed_resources.values_list('path', flat=True)

    added_paths = []

    log.debug('Removed files: {}'.format(', '.join(removed_paths) or 'None'))
    removed_resources.delete()

    for relative_path, vcs_resource in vcs_project.resources.items():
        resource, created = db_project.resources.get_or_create(
            path=relative_path)
        resource.format = Resource.get_path_format(relative_path)
        resource.total_strings = len(vcs_resource.entities)
        resource.save()

        if created:
            added_paths.append(relative_path)

    log.debug('Added files: {}'.format(', '.join(added_paths) or 'None'))
    return removed_paths, added_paths
示例#3
0
文件: core.py 项目: mathjazz/pontoon
def update_resources(db_project, vcs_project):
    """Update the database on what resource files exist in VCS."""
    log.debug('Scanning {}'.format(vcs_project.source_directory_path))
    vcs_changed_files, vcs_removed_files = vcs_project.changed_source_files

    removed_resources = db_project.resources.filter(path__in=vcs_removed_files)
    removed_paths = removed_resources.values_list('path', flat=True)

    changed_resources = db_project.resources.filter(path__in=vcs_changed_files)
    changed_paths = changed_resources.values_list('path', flat=True)

    added_paths = []

    log.debug('Removed files: {}'.format(', '.join(removed_paths) or 'None'))
    removed_resources.delete()

    for relative_path, vcs_resource in vcs_project.resources.items():
        resource, created = db_project.resources.get_or_create(path=relative_path)
        resource.format = Resource.get_path_format(relative_path)
        resource.total_strings = len(vcs_resource.entities)
        resource.save()

        if created:
            added_paths.append(relative_path)

    log.debug('Added files: {}'.format(', '.join(added_paths) or 'None'))
    return added_paths, removed_paths, changed_paths
示例#4
0
    def update_resources(self, db_project, vcs_project):
        """Update the database on what resource files exist in VCS."""
        relative_paths = vcs_project.resources.keys()
        db_project.resource_set.exclude(path__in=relative_paths).delete()

        for relative_path, vcs_resource in vcs_project.resources.items():
            resource, created = db_project.resource_set.get_or_create(path=relative_path)
            resource.format = Resource.get_path_format(relative_path)
            resource.entity_count = len(vcs_resource.entities)
            resource.save()
示例#5
0
def update_resources(db_project, vcs_project):
    """Update the database on what resource files exist in VCS."""
    relative_paths = vcs_project.resources.keys()
    db_project.resources.exclude(path__in=relative_paths).delete()

    for relative_path, vcs_resource in vcs_project.resources.items():
        resource, created = db_project.resources.get_or_create(path=relative_path)
        resource.format = Resource.get_path_format(relative_path)
        resource.entity_count = len(vcs_resource.entities)
        resource.save()
示例#6
0
def update_resources(db_project, vcs_project):
    """Update the database on what resource files exist in VCS."""
    log.debug('Scanning {}'.format(vcs_project.source_directory_path()))
    relative_paths = vcs_project.resources.keys()
    removed_resources = db_project.resources.exclude(path__in=relative_paths)
    removed_paths = removed_resources.values_list('path', flat=True)
    log.debug('Removed paths: {}'.format(', '.join(removed_paths)))
    removed_resources.delete()

    for relative_path, vcs_resource in vcs_project.resources.items():
        resource, created = db_project.resources.get_or_create(path=relative_path)
        resource.format = Resource.get_path_format(relative_path)
        resource.total_strings = len(vcs_resource.entities)
        resource.save()
    return removed_paths