Exemple #1
0
def download_multi(translations, commit_objs, fmt=None, name="translations"):
    filenames = set()
    components = set()

    for obj in commit_objs:
        try:
            obj.commit_pending("download", None)
        except Exception:
            report_error(cause="Download commit")

    for translation in translations:
        # Add translation files
        if translation.filename:
            filenames.add(translation.get_filename())
        # Add templates for all components
        if translation.component_id in components:
            continue
        components.add(translation.component_id)
        for filename in (
                translation.component.template,
                translation.component.new_base,
                translation.component.intermediate,
        ):
            if filename:
                fullname = os.path.join(translation.component.full_path,
                                        filename)
                if os.path.exists(fullname):
                    filenames.add(fullname)

    return zip_download(data_dir("vcs"), sorted(filenames), name)
Exemple #2
0
 def download_file(self, filename, content_type, component=None):
     """Wrapper for file download."""
     if os.path.isdir(filename):
         response = zip_download(filename, filename)
         filename = "{}.zip".format(component.slug if component else "weblate")
     else:
         with open(filename, "rb") as handle:
             response = HttpResponse(handle.read(), content_type=content_type)
         filename = os.path.basename(filename)
     response["Content-Disposition"] = 'attachment; filename="{0}"'.format(filename)
     return response
Exemple #3
0
def download_multi(translations, fmt=None):
    filenames = set()
    components = set()

    for translation in translations:
        # Add translation files
        if translation.filename:
            filenames.add(translation.get_filename())
        # Add templates for all components
        if translation.component_id in components:
            continue
        components.add(translation.component_id)
        for name in (
            translation.component.template,
            translation.component.new_base,
            translation.component.intermediate,
        ):
            if name:
                filenames.add(os.path.join(translation.component.full_path, name))

    return zip_download(data_dir("vcs"), sorted(filenames))
Exemple #4
0
def download_multi(translations, fmt=None):
    filenames = [t.get_filename() for t in translations]
    return zip_download(data_dir("vcs"),
                        [filename for filename in filenames if filename])
Exemple #5
0
def download_multi(translations, fmt=None):
    return zip_download(data_dir('vcs'),
                        [t.get_filename() for t in translations])