コード例 #1
0
def upload_smartling_file(filepath, filename, locale='de-DE', file_type='json'):
    uploadDataUtf16 = UploadData(filepath, filename, file_type)
    uploadDataUtf16.setApproveContent("true")
    uploadDataUtf16.setCallbackUrl(settings.SMARTLING_CALLBACK_URL)
    useSandbox = False
    example = SmartlingApi(useSandbox, uploadDataUtf16, locale, filename)
    example.fapi.upload(example.uploadData)
コード例 #2
0
def utf16_test():
    #add charset and approveContent parameters
    uploadDataUtf16 = UploadData(FILE_PATH, FILE_NAME_UTF16, FILE_TYPE)
    uploadDataUtf16.setApproveContent("true")
    uploadDataUtf16.setCallbackUrl(CALLBACK_URL)
    useSandbox = False
    example = SmartlingApiExample(useSandbox, uploadDataUtf16, "it-IT", FILE_NAME_RENAMED)
    example.test()
コード例 #3
0
def upload_smartling_file(filepath,
                          filename,
                          locale='de-DE',
                          file_type='json'):
    uploadDataUtf16 = UploadData(filepath, filename, file_type)
    uploadDataUtf16.setApproveContent("true")
    uploadDataUtf16.setCallbackUrl(settings.SMARTLING_CALLBACK_URL)
    useSandbox = False
    example = SmartlingApi(useSandbox, uploadDataUtf16, locale, filename)
    example.fapi.upload(example.uploadData)
コード例 #4
0
    def test_commandUpload_Callback_Approved(self):
        ud = UploadData("path", "name", "type")
        ud.setApproveContent("true")
        ud.setCallbackUrl("smartling.com")

        api = FileApiBase("host", "apiKey", "projectId")
        api.uploadMultipart = self.mock_uploadMultipart
        params = api.commandUpload(ud)

        assert_equal(len(params), 5)
        assert_equal(params[Params.APPROVED], "true")
        assert_equal(params[Params.CALLBACK_URL], "smartling.com")
コード例 #5
0
    def test_commandUpload_Callback_Approved(self):
        ud = UploadData("path", "name", "type")
        ud.setApproveContent("true")
        ud.setCallbackUrl("smartling.com")

        api = FileApiBase("host", "apiKey", "projectId")
        api.uploadMultipart = self.mock_uploadMultipart
        params = api.commandUpload(ud)

        assert_equal(len(params), 5)
        assert_equal(params[Params.APPROVED], "true")
        assert_equal(params[Params.CALLBACK_URL], "smartling.com")
コード例 #6
0
    def test_commandUpload_Directives(self):
        ud = UploadData("path", "name", "type")
        ud.setApproveContent("true")
        ud.setCallbackUrl("smartling.com")
        ud.addDirective(SmartlingDirective("placeholder_format_custom", "\[.+?\]"))
        ud.addDirective(SmartlingDirective("placeholder_format", "IOS"))

        api = FileApiBase("host", "apiKey", "projectId")
        api.uploadMultipart = self.mock_uploadMultipart
        params = api.commandUpload(ud)

        assert_equal(len(params), 7)
        assert_equal(params["smartling.placeholder_format_custom"], "\[.+?\]")
        assert_equal(params["smartling.placeholder_format"], "IOS")
コード例 #7
0
    def test_commandUpload_Directives(self):
        ud = UploadData("path", "name", "type")
        ud.setApproveContent("true")
        ud.setCallbackUrl("smartling.com")
        ud.addDirective(
            SmartlingDirective("placeholder_format_custom", "\[.+?\]"))
        ud.addDirective(SmartlingDirective("placeholder_format", "IOS"))

        api = FileApiBase("host", "apiKey", "projectId")
        api.uploadMultipart = self.mock_uploadMultipart
        params = api.commandUpload(ud)

        assert_equal(len(params), 7)
        assert_equal(params["smartling.placeholder_format_custom"], "\[.+?\]")
        assert_equal(params["smartling.placeholder_format"], "IOS")
コード例 #8
0
def upload_file(fapi, file_name, conf):
    """ Uploads a file to smartling
    """
    if not conf.has_key('file-type'):
        raise SmarterlingError("%s doesn't have a file-type" % file_name)
    print("Uploading %s to smartling" % file_name)
    data = UploadData(
        os.path.dirname(file_name)+os.sep,
        os.path.basename(file_name),
        conf.get('file-type'))
    data.setUri(file_uri(file_name, conf))
    if conf.has_key('approve-content'):
        data.setApproveContent("true" if conf.get('approve-content', True) else "false")
    if conf.has_key('callback-url'):
        data.setCallbackUrl(conf.get('callback-url'))
    for name, value in conf.get('directives', {}).items():
        data.addDirective(SmartlingDirective(name, value))
    (response, code) = fapi.upload(data)
    if code!=200:
        print(repr(response))
        raise SmarterlingError("Error uploading file: %s" % file_name)
    else:
        print("Uploaded %s, wordCount: %s, stringCount: %s" % (file_name, response.data.wordCount, response.data.stringCount))
コード例 #9
0
 def doUpload(self):
     #ensure file is uploaded which is necessary for all tests
     uploadData = UploadData(self.FILE_PATH, self.FILE_NAME, self.FILE_TYPE)
     uploadData.setCallbackUrl(self.CALLBACK_URL)
     return self.fapi.upload(uploadData)
コード例 #10
0
 def doUpload(self, name, uri):
     #ensure file is uploaded which is necessary for all tests
     uploadData = UploadData(self.FILE_PATH, name, self.FILE_TYPE)
     uploadData.setUri(uri)
     uploadData.setCallbackUrl(self.CALLBACK_URL)
     return self.fapi.upload(uploadData)
コード例 #11
0
 def test_setCallbackUrl(self):
     ud = UploadData("path", "name", "type")
     ud.setCallbackUrl("smartling.com")
     assert_equal(ud.callbackUrl, "smartling.com")
コード例 #12
0
 def test_setCallbackUrl(self):
     ud = UploadData("path", "name", "type")
     ud.setCallbackUrl("smartling.com")
     assert_equal(ud.callbackUrl, "smartling.com")
コード例 #13
0
        
        self.printMarker("delete from server goes here")
        print self.fapi.delete(self.new_name)
        
        self.printMarker("doing list again to see if it's deleted")
        print self.fapi.list()
        


FILE_NAME      = "java.properties"
FILE_NAME_UTF16= "javaUTF16.properties"
FILE_TYPE      = "javaProperties"        
FILE_PATH      = "../resources/"
FILE_NAME_RENAMED = "java.properties.renamed"
CALLBACK_URL      = "http://yourdomain.com/callback"

#test simple file
uploadDataASCII = UploadData(FILE_PATH, FILE_NAME, FILE_TYPE)
uploadDataASCII.addDirective(SmartlingDirective("placeholder_format_custom","\[.+?\]"))
useSandbox = False
example = SmartlingApiExample (useSandbox, uploadDataASCII, "ru-RU", FILE_NAME_RENAMED)
example.test()

#add charset and approveContent parameters
uploadDataUtf16 = UploadData(FILE_PATH, FILE_NAME_UTF16, FILE_TYPE)
uploadDataUtf16.setApproveContent("true")
uploadDataUtf16.setCallbackUrl(CALLBACK_URL)
useSandbox = True
example = SmartlingApiExample (useSandbox, uploadDataUtf16, "ru-RU", FILE_NAME_RENAMED)
example.test()