![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
github.com/aspose-words-cloud/aspose-words-cloud-go/v2006
// // MIT License
// Copyright (c) 2019 Aspose Pty Ltd
// Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. //
package api_test
import ( "bufio" "bytes" "fmt" "io" "os" "path" "path/filepath" "regexp" "runtime" "testing"
"github.com/aspose-words-cloud/aspose-words-cloud-go/v2006/api"
"github.com/aspose-words-cloud/aspose-words-cloud-go/v2006/api/models"
)
func TestReadmeCode(t *testing.T) {
localFilePath := commonTestFile
remoteFolder := path.Join(remoteBaseTestDataFolder, "ReadmeCode")
remoteName := "ReadmeCode.docx"
remotePath := path.Join(remoteFolder, remoteName)
configFilePath := GetConfigFilePath()
// Start README example
// init words cloud api
config, _ := models.NewConfiguration(configFilePath)
wordsApi, ctx, _ := api.CreateWordsApi(config)
// upload test.docx to a cloud
// remote.docx is a name in the cloud
file, _ := os.Open(localFilePath)
wordsApi.UploadFile(ctx, file, remotePath, nil)
// get a text for the first paragraph of the first section
options := map[string]interface{}{
"folder": remoteFolder,
}
result, _, _ := wordsApi.GetParagraphs(ctx, remoteName, "", options)
fmt.Println(result.Paragraphs.ParagraphLinkList[0].Text)
// End README example
writeToReadme(t)
}
func writeToReadme(t testing.T) { // set regexes startPatern := regexp.MustCompile("^\s// Start README example\s*$") endPattern := regexp.MustCompile("^\s*// End README example\s*$")
// set paths
_, filename, _, _ := runtime.Caller(0)
testFolder := filepath.Dir(filename)
sourcePath := filepath.Join(testFolder, "readme_test.go")
readmePath := filepath.Join(testFolder, "../../README.md")
// read the file
codeLines, err := readLines(sourcePath)
if err != nil {
t.Error(err)
}
// extract example code
var readmeCode []string
skipMode := true
for i := 0; i < len(codeLines); i++ {
if skipMode {
skipMode = !startPatern.Match([]byte(codeLines[i]))
}
if !skipMode {
readmeCode = append(readmeCode, codeLines[i])
skipMode = endPattern.Match([]byte(codeLines[i]))
}
}
if len(readmeCode) < 2 {
t.Error("Code has not found in readme_test.go")
}
// read readme.md
readmeLines, err := readLines(readmePath)
if err != nil {
t.Error(err)
}
// replace example code
var newReadmeLines []string
codeMode := false
for i := 0; i < len(readmeLines); i++ {
if !codeMode {
codeMode = startPatern.Match([]byte(readmeLines[i]))
if codeMode {
newReadmeLines = append(newReadmeLines, readmeCode...)
}
}
if codeMode {
codeMode = !endPattern.Match([]byte(readmeLines[i]))
continue
}
if !codeMode {
newReadmeLines = append(newReadmeLines, readmeLines[i])
}
}
// write new readme
err = writeLines(newReadmeLines, readmePath)
if err != nil {
t.Error(err)
}
}
// Read a whole file into the memory and store it as array of lines func readLines(path string) (lines []string, err error) { var ( file *os.File part []byte prefix bool ) if file, err = os.Open(path); err != nil { return } defer file.Close()
reader := bufio.NewReader(file)
buffer := bytes.NewBuffer(make([]byte, 0))
for {
if part, prefix, err = reader.ReadLine(); err != nil {
break
}
buffer.Write(part)
if !prefix {
lines = append(lines, buffer.String())
buffer.Reset()
}
}
if err == io.EOF {
err = nil
}
return
}
func writeLines(lines []string, path string) (err error) { var ( file *os.File )
if file, err = os.Create(path); err != nil {
return
}
defer file.Close()
for _, item := range lines {
_, err := file.WriteString(item + "\n")
if err != nil {
break
}
}
return
}
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.