Пример #1
0
    def test_add(self):
        o = get_versioned_object(self.co_path)
        self.create_files({
            "test1.txt": "First file\n",
            "test2.txt": "Second file\n",
        })
        file_path = os.path.join(self.co_path, "test1.txt")
        o.add(os.path.join(file_path))
        o = get_versioned_object(file_path)
        assert os.path.samefile(o.location_abs, file_path)

        assert o.getcleanfile().decode('utf-8') == "First file\n"
Пример #2
0
    def test_add(self):
        o = get_versioned_object(self.co_path)
        self.create_files({
            "test1.txt": "First file\n",
            "test2.txt": "Second file\n",
        })
        file_path = os.path.join(self.co_path, "test1.txt")
        o.add(os.path.join(file_path))
        o = get_versioned_object(file_path)
        assert os.path.samefile(o.location_abs, file_path)

        assert o.getcleanfile() == "First file\n"
Пример #3
0
    def test_add(self):
        o = get_versioned_object(self.co_path)
        self.create_files({
            "test1.txt": b"First file\n",
            "test2.txt": b"Second file\n",
        })
        file_path = os.path.join(self.co_path, "test1.txt")
        o.add(os.path.join(file_path))
        o = get_versioned_object(file_path)

        # The samefile is available on Unix only, compare path only
        assert os.path.abspath(o.location_abs) == os.path.abspath(file_path)

        assert o.getcleanfile().decode('utf-8') == "First file\n"
Пример #4
0
    def test_add(self):
        o = get_versioned_object(self.co_path)
        self.create_files({
            "test1.txt": b"First file\n",
            "test2.txt": b"Second file\n",
        })
        file_path = os.path.join(self.co_path, "test1.txt")
        o.add(os.path.join(file_path))
        o = get_versioned_object(file_path)

        # The samefile is available on Unix only, compare path only
        assert os.path.abspath(o.location_abs) == os.path.abspath(file_path)

        assert o.getcleanfile().decode('utf-8') == "First file\n"
Пример #5
0
    def update_from_templates(self, pootle_path=None):
        """Update translation project from templates."""

        if self.is_template_project:
            return

        template_translation_project = self.project \
            .get_template_translationproject()

        if template_translation_project is None or \
           template_translation_project == self:
            return

        monolingual = self.project.is_monolingual()

        if not monolingual:
            self.sync()

        if pootle_path is None:
            oldstats = self.getquickstats()

        from pootle_app.project_tree import convert_template, \
            get_translated_name, get_translated_name_gnu

        for store in template_translation_project.stores.iterator():

            if self.file_style == 'gnu':
                new_pootle_path, new_path = get_translated_name_gnu(
                    self, store)
            else:
                new_pootle_path, new_path = get_translated_name(self, store)

            if pootle_path is not None and new_pootle_path != pootle_path:
                continue

            convert_template(self, store, new_pootle_path, new_path,
                             monolingual)

        all_files, new_files = self.scan_files()
        #self.update(conservative=False)

        from pootle_misc.versioncontrol import hasversioning
        project_path = self.project.get_real_path()
        if new_files and hasversioning(project_path):
            from translate.storage import versioncontrol
            vcs = versioncontrol.get_versioned_object(project_path)
            output = vcs.add([s.abs_real_path for s in new_files],
                             "New files added from %s based on templates" %
                             (settings.TITLE))

        if pootle_path is None:
            newstats = self.getquickstats()

            from pootle_app.models.signals import post_template_update
            post_template_update.send(sender=self,
                                      oldstats=oldstats,
                                      newstats=newstats)
Пример #6
0
def add_files(path, files, message):
    vcs_path = to_vcs_path(path)
    path = to_podir_path(path)
    vcs = versioncontrol.get_versioned_object(vcs_path)
    #: list of (podir_path, vcs_path) tuples
    file_paths = [(to_podir_path(f), to_vcs_path(f)) for f in files]
    for podir_path, vcs_path in file_paths:
        os.makedirs(os.path.dirname(vcs_path))
        shutil.copy(podir_path, vcs_path)
    output = vcs.add([to_vcs_path(f) for f in files], message)
    return output
Пример #7
0
def add_files(path, files, message):
    vcs_path = to_vcs_path(path)
    path = to_podir_path(path)
    vcs = versioncontrol.get_versioned_object(vcs_path)
    #: list of (podir_path, vcs_path) tuples
    file_paths = [(to_podir_path(f), to_vcs_path(f)) for f in files]
    for podir_path, vcs_path in file_paths:
        os.makedirs(os.path.dirname(vcs_path))
        shutil.copy(podir_path, vcs_path)
    output = vcs.add([to_vcs_path(f) for f in files], message)
    return output
Пример #8
0
    def update_from_templates(self, pootle_path=None):
        """Update translation project from templates."""

        if self.is_template_project:
            return

        template_translation_project = self.project.get_template_translationproject()

        if template_translation_project is None or template_translation_project == self:
            return

        monolingual = self.project.is_monolingual()

        if not monolingual:
            self.sync()

        if pootle_path is None:
            oldstats = self.getquickstats()

        from pootle_app.project_tree import convert_template, get_translated_name, get_translated_name_gnu

        for store in template_translation_project.stores.iterator():

            if self.file_style == "gnu":
                new_pootle_path, new_path = get_translated_name_gnu(self, store)
            else:
                new_pootle_path, new_path = get_translated_name(self, store)

            if pootle_path is not None and new_pootle_path != pootle_path:
                continue

            convert_template(self, store, new_pootle_path, new_path, monolingual)

        all_files, new_files = self.scan_files()
        # self.update(conservative=False)

        from pootle_misc.versioncontrol import hasversioning

        project_path = self.project.get_real_path()
        if new_files and hasversioning(project_path):
            from translate.storage import versioncontrol

            vcs = versioncontrol.get_versioned_object(project_path)
            output = vcs.add(
                [s.abs_real_path for s in new_files], "New files added from %s based on templates" % (settings.TITLE)
            )

        if pootle_path is None:
            newstats = self.getquickstats()

            from pootle_app.models.signals import post_template_update

            post_template_update.send(sender=self, oldstats=oldstats, newstats=newstats)
Пример #9
0
def update_dir(path):
    """Updates a whole directory without syncing with the po directory.

    This assumes that we can update cleanly, and must be followed by
    :meth:`~pootle_translationproject.models.TranslationProject.scan_files`
    since the podirectory isn't updated as part of this call.

    For some systems (like git) this can cause the rest of a cloned repository
    to be updated as well, so changes might not be limited to the given path.
    """
    vcs_path = to_vcs_path(path)
    vcs_object = versioncontrol.get_versioned_object(vcs_path)
    vcs_object.update(needs_revert=False)
Пример #10
0
 def test_detection(self):
     print self.co_path
     o = get_versioned_object(self.co_path)
     assert isinstance(o, svn.svn)
     assert o.location_abs == self.co_path
Пример #11
0
 def test_detection(self):
     print(self.co_path)
     o = get_versioned_object(self.co_path)
     assert isinstance(o, svn.svn)
     assert o.location_abs == self.co_path