示例#1
0
 def download_resource(self, path):
     """Downloads active resource to given path. Returns path to downloaded file."""
     if self.get_type() != None and self.get_guid() != None:
         file_client = memoQFile.MemoQFile()
         return file_client.download_file(
             path,
             self.client.service.ExportResource(self.get_type(),
                                                self.get_guid()))
示例#2
0
    def test_upload_download_file(self):
        test = memoQFile.MemoQFile()

        file_guid = test.upload_file("testFiles/test.txt")
        self.assertNotEqual(file_guid, None, "Guid shouldn't equal none!")

        file_path = test.download_file(".", file_guid)
        self.assertTrue(os.path.isfile(file_path), "File should exist!")

        os.remove(file_path)
示例#3
0
    def import_document(self, path):
        """Uploads and then imports given file to active project for all target languages.
        Returns true on success."""
        file_client = memoQFile.MemoQFile()
        file_guid = file_client.upload_file(path)
        if file_guid == None:
            return False

        langs = self.client.factory.create(
            '{http://kilgray.com/memoqservices/2007}targetLangCodes')
        langs.string = self.project.languages.target

        result = self.client.service.ImportTranslationDocument(
            self.project.get_project_guid(), file_guid, langs)
        if result != None:
            return True
        else:
            return False
示例#4
0
    def export_documents(self, path):
        """Exports all documents from active project to given path.
        Prints path to each file on success and returns true."""
        if self.project.get_project_guid() == None:
            return "No project!"

        export_results = []
        for guid in self.document_guids():
            export_results.append(
                self.client.service.ExportTranslationDocument(
                    self.project.get_project_guid(), guid))

        file_client = memoQFile.MemoQFile()
        if len(export_results):
            for document in export_results:
                print(file_client.download_file(path, document.FileGuid))
            return True
        else:
            return False
示例#5
0
    def export_documents2(self, path):
        """Exports all documents from active project to given path using extended method.
        Prints path to each file on success and returns true."""
        if self.project.get_project_guid() == None:
            return "No project!"

        options = self.client.factory.create(
            '{http://kilgray.com/memoqservices/2007}DocumentExportOptions')
        options.CopySourceToEmptyTarget = True

        export_results = []
        for guid in self.document_guids():
            export_results.append(
                self.client.service.ExportTranslationDocument2(
                    self.project.get_project_guid(), guid, options))

        file_client = memoQFile.MemoQFile()
        if len(export_results):
            for document in export_results:
                print(file_client.download_file(path, document.FileGuid))
            return True
        else:
            return False