id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c8500 | gp.getContent().appendRotate(angle, x, y)
} | |
c8501 | UnitsToPoints(gp.config.Unit, u)
} | |
c8502 | UnitsToPointsVar(gp.config.Unit, u...)
} | |
c8503 | PointsToUnits(gp.config.Unit, u)
} | |
c8504 | PointsToUnitsVar(gp.config.Unit, u...)
} | |
c8505 | }
r = &Rect{W: rect.W, H: rect.H}
PointsToUnitsVar(t, &r.W, &r.H)
return
} | |
c8506 | }
r = &Rect{W: rect.W, H: rect.H}
UnitsToPointsVar(t, &r.W, &r.H)
return
} | |
c8507 | = h * imageRect.Dx() / imageRect.Dy()
}
if h == 0 {
h = w * imageRect.Dy() / imageRect.Dx()
}
return float64(w), float64(h)
} | |
c8508 | if err != nil {
return nil
}
url, _ := url.Parse(str)
url.Scheme = Kind
return url
} | |
c8509 | "retrieving item metadata")
}
return i.metadata, nil
} | |
c8510 | := i.bucket.DownloadFileByName(i.name)
return r, err
} | |
c8511 | != nil {
return "", errors.Wrap(err, "retreiving etag")
}
return i.lastModified.String(), nil
} | |
c8512 |
if err != nil {
return nil, err
}
container := &container{
id: name,
client: l.client,
}
return container, nil
} | |
c8513 | cont.Name,
client: l.client,
// count: cont.Count,
// bytes: cont.Bytes,
}
}
marker := ""
if len(response) == count {
marker = response[len(response)-1].Name
}
return containers, marker, nil
} | |
c8514 | // TODO: grab info + headers
if err != nil {
return nil, stow.ErrNotFound
}
c := &container{
id: id,
client: l.client,
}
return c, nil
} | |
c8515 | return l.client.ContainerDelete(id)
} | |
c8516 | configurations[kind] = validatefn
kinds = append(kinds, kind)
kindmatches = append(kindmatches, func(u *url.URL) string {
if kindmatchfn(u) {
return kind // match
}
return "" // empty string means no match
})
} | |
c8517 | return nil, errUnknownKind(kind)
}
return fn(config)
} | |
c8518 | configurations[kind]
if !ok {
return errUnknownKind(kind)
}
return fn(config)
} | |
c8519 | continue
}
return kind, nil
}
return "", errUnknownKind("")
} | |
c8520 | val, ok := c[name]
return val, ok
} | |
c8521 | error) {
return os.Open(i.path)
} | |
c8522 | genericURL,
}
}
genericURL := fmt.Sprintf("%s/%s", i.container.Name(), i.Name())
return &url.URL{
Scheme: "s3",
Path: genericURL,
}
} | |
c8523 | aws.String(i.ID()),
}
response, err := i.client.GetObject(params)
if err != nil {
return nil, errors.Wrap(err, "Open, getting the object")
}
return response.Body, nil
} | |
c8524 | "getObjectTagging")
return
}
i.tags = make(map[string]interface{})
for _, t := range res.TagSet {
i.tags[*t.Key] = *t.Value
}
})
return i.tags, i.tagsErr
} | |
c8525 | != nil {
i.infoErr = infoErr
return
}
i.lastModified, i.infoErr = itemInfo.LastMod()
if infoErr != nil {
i.infoErr = infoErr
return
}
i.metadata, i.infoErr = itemInfo.Metadata()
if infoErr != nil {
i.infoErr = infoErr
return
}
})
}
return i.infoErr
} | |
c8526 | r
// FIXME: this is a workaround to issue https://github.com/graymeta/stow/issues/120
if s, ok := res.(readSeekCloser); ok {
res = &fixReadSeekCloser{readSeekCloser: s, item: i}
}
return res, err
} | |
c8527 |
// request doesn't have to be sent again.
err := i.ensureInfo()
if err != nil {
return time.Time{}, err
}
return i.lastModified, nil
} | |
c8528 | value := range md.ObjectMetadata() {
m[key] = value
}
return m, nil
} | |
c8529 |
items := make([]stow.Item, len(objects))
for i, obj := range objects {
items[i] = &item{
id: obj.Name,
container: c,
client: c.client,
hash: obj.Hash,
size: obj.Bytes,
lastModified: obj.LastModified,
}
}
marker := ""
if len(objects) == count {
marker = o... | |
c8530 | to update Item metadata")
}
item := &item{
id: name,
container: c,
client: c.client,
size: size,
// not setting metadata here, the refined version isn't available
// unless an explicit getItem() is done. Possible to write a func to facilitate
// this.
}
return item, nil
} | |
c8531 | nil {
return nil, err
}
u.Scheme = "google"
// Discard the query string
u.RawQuery = ""
return u, nil
} | |
c8532 | don't seem to support prefixes, so do it ourself
if strings.HasPrefix(cont.Name, prefix) {
containers = append(containers, &container{
bucket: cont,
})
}
}
return containers, "", nil
} | |
c8533 | {
return nil, stow.ErrNotFound
}
return &container{
bucket: bucket,
}, nil
} | |
c8534 | c.(*container).bucket.ListFileNames(filename, 1)
if err != nil {
return nil, stow.ErrNotFound
}
if len(response.Files) != 1 {
return nil, errors.New("unexpected number of responses from ListFileNames")
}
return c.Item(response.Files[0].ID)
} | |
c8535 | return err
}
return stowCont.(*container).bucket.Delete()
} | |
c8536 | object.ETag,
Key: object.Key,
LastModified: object.LastModified,
Owner: object.Owner,
Size: object.Size,
StorageClass: object.StorageClass,
},
}
containerItems = append(containerItems, newItem)
}
// Create a marker and determine if the list of items to retrieve is ... | |
c8537 | to retrieve Item information, parsing metadata")
}
i := &item{
container: c,
client: c.client,
properties: properties{
ETag: &etag,
Key: &id,
LastModified: res.LastModified,
Owner: nil, // not returned in the response.
Size: res.ContentLength,
StorageClass:... | |
c8538 |
k := strings.ToLower(key)
m[k] = *value
}
return m, nil
} | |
c8539 | }
list = append(list, fileinfo{
FileInfo: info,
name: flatname,
})
return nil
})
if err != nil {
return nil, err
}
return list, nil
} | |
c8540 | 0, errMultiPartUploadTooBig
}
chunkSize *= 2
if chunkSize > maxChunkSize {
chunkSize = maxChunkSize
}
}
return chunkSize, nil
} | |
c8541 | upload the parts in parallel
for {
n, err := r.Read(buf)
if err != nil {
if err == io.EOF {
break
}
return err
}
blockID := encodedBlockID(rawID)
chunk := buf[:n]
if err := blob.PutBlock(blockID, chunk, nil); err != nil {
return err
}
blocks = append(blocks, az.Block{
ID: blo... | |
c8542 |
region, _ := l.config.Config("region")
newContainer := &container{
name: containerName,
client: l.client,
region: region,
customEndpoint: l.customEndpoint,
}
return newContainer, nil
} | |
c8543 |
var err error
client := l.client
bucketRegion := region
if !endpointSet && endpoint == "" {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
bucketRegion, err = s3manager.GetBucketRegionWithClient(ctx, l.client, *bucket.Name)
cancel()
if err != nil {
return nil, "", erro... | |
c8544 | }
for _, item := range items {
err = fn(item, nil)
if err != nil {
return err
}
}
if IsCursorEnd(cursor) {
break
}
}
return nil
} | |
c8545 | }
}
for _, container := range containers {
err = fn(container, nil)
if err != nil {
return err
}
}
if IsCursorEnd(cursor) {
break
}
}
return nil
} | |
c8546 | nil {
return nil, err
}
mdParsed, err := parseMetadata(res.Metadata)
if err != nil {
return nil, err
}
i := &Item{
name: id,
container: c,
client: c.client,
size: int64(res.Size),
etag: res.Etag,
hash: res.Md5Hash,
lastModified: t,
url: u,
... | |
c8547 | return nil, "", err
}
containerItems[i] = &Item{
name: o.Name,
container: c,
client: c.client,
size: int64(o.Size),
etag: o.Etag,
hash: o.Md5Hash,
lastModified: t,
url: u,
metadata: mdParsed,
object: o,
}
}
return cont... | |
c8548 |
t, err := time.Parse(time.RFC3339, res.Updated)
if err != nil {
return nil, err
}
u, err := prepUrl(res.MediaLink)
if err != nil {
return nil, err
}
mdParsed, err := parseMetadata(res.Metadata)
if err != nil {
return nil, err
}
newItem := &Item{
name: name,
container: c,
client: ... | |
c8549 | cursor = response.NextFileName
if prefix == "" || cursor == "" {
return items, cursor, nil
}
if len(items) == count {
break
}
if !strings.HasPrefix(cursor, prefix) {
return items, "", nil
}
}
if cursor != "" && cursor != items[len(items)-1].Name() {
// append a space because that's a funn... | |
c8550 | metadata")
}
file, err := c.bucket.UploadFile(name, mdPrepped, r)
if err != nil {
return nil, err
}
return &item{
id: file.ID,
name: file.Name,
size: file.ContentLength,
bucket: c.bucket,
}, nil
} | |
c8551 | item.Name() {
fileStatus = &response.Files[i]
break
}
}
if fileStatus == nil {
// we've deleted all versions of the file
return nil
}
if _, err := c.bucket.DeleteFileVersion(item.name, response.Files[0].ID); err != nil {
return err
}
}
} | |
c8552 | filepath.Abs(f)
if err != nil {
return nil, err
}
name, err := filepath.Rel(absroot, path)
if err != nil {
return nil, err
}
cs = append(cs, &container{
name: name,
path: path,
})
}
return cs, nil
} | |
c8553 |
if err != nil {
return nil, err
}
newContainer := &Container{
name: containerName,
client: l.client,
}
return newContainer, nil
} | |
c8554 | nil {
return nil, "", err
}
containers := make([]stow.Container, len(res.Items))
for i, o := range res.Items {
containers[i] = &Container{
name: o.Name,
client: l.client,
}
}
return containers, res.NextPageToken, nil
} | |
c8555 | = mock
mock.Response().Mock = mock
// Registers the mock in the global store
mocks = append(mocks, mock)
} | |
c8556 | if mock == m {
return true
}
}
return false
} | |
c8557 | = append(mocks[:i], mocks[i+1:]...)
storeMutex.Unlock()
}
}
} | |
c8558 | for _, mock := range mocks {
if mock.Done() {
continue
}
buf = append(buf, mock)
}
mocks = buf
} | |
c8559 | append(m.Matchers, fn)
} | |
c8560 | return false, err
}
if !matches {
return false, nil
}
}
return true, nil
} | |
c8561 | := mock.Match(req)
if err != nil {
return nil, err
}
if matches {
return mock, nil
}
}
return nil, nil
} | |
c8562 | make(http.Header),
PathParams: make(map[string]string),
}
} | |
c8563 | = url.Parse(uri)
return r
} | |
c8564 | *Request {
r.URLStruct = u
return r
} | |
c8565 |
}
r.Method = strings.ToUpper(method)
return r
} | |
c8566 | *Request {
r.BodyBuffer = []byte(body)
return r
} | |
c8567 | = ioutil.ReadFile(path)
return r
} | |
c8568 |
r.Header.Set("Content-Encoding", scheme)
r.CompressionScheme = scheme
return r
} | |
c8569 |
r.BodyBuffer, r.Error = readAndDecode(data, "json")
return r
} | |
c8570 | "+basicAuth(username, password))
return r
} | |
c8571 | r.Header.Set(key, value)
return r
} | |
c8572 | *Request {
r.Header.Set(key, ".*")
return r
} | |
c8573 | {
for key, value := range headers {
r.Header.Set(key, value)
}
return r
} | |
c8574 | value)
r.URLStruct.RawQuery = query.Encode()
return r
} | |
c8575 | query.Set(key, value)
}
r.URLStruct.RawQuery = query.Encode()
return r
} | |
c8576 | *Request {
r.MatchParam(key, ".*")
return r
} | |
c8577 | *Request {
r.Counter = num
return r
} | |
c8578 | *Request {
r.Mock.AddMatcher(fn)
return r
} | |
c8579 | *Request {
r.Mock.SetMatcher(matcher)
return r
} | |
c8580 | = append(r.Mappers, fn)
return r
} | |
c8581 |
if r.Response != nil {
r.Response.UseNetwork = true
}
return r
} | |
c8582 | r.Response.Status(status)
} | |
c8583 | r.Response.SetError(err)
} | |
c8584 | *Response {
replier(r.Response)
return r.Response
} | |
c8585 | if len(mock.BodyBuffer) > 0 {
res.ContentLength = int64(len(mock.BodyBuffer))
res.Body = createReadCloser(mock.BodyBuffer)
}
// Apply response mappers
for _, mapper := range mock.Mappers {
if tres := mapper(res); tres != nil {
res = tres
}
}
// Sleep to simulate delay, if necessary
if mock.ResponseD... | |
c8586 | req,
Header: make(http.Header),
Body: createReadCloser([]byte{}),
}
} | |
c8587 | := range values {
res.Header.Add(key, value)
}
}
return res.Header
} | |
c8588 | {
return ioutil.NopCloser(bytes.NewReader(body))
} | |
c8589 | networking
// wasn't enabled for this request
fmt.Printf("Body From httpbin: %s\n", string(body))
fmt.Printf("Status From httpbin: %s\n", res.Status)
io.WriteString(w, "Local Response="+res.Header.Get("Server"))
}))
} | |
c8590 | ereq.Method == "" || req.Method == ereq.Method, nil
} | |
c8591 | req.URL.Scheme == "" || ereq.URLStruct.Scheme == req.URL.Scheme, nil
} | |
c8592 |
if strings.EqualFold(url.Host, req.URL.Host) {
return true, nil
}
return regexp.MatchString(url.Host, req.URL.Host)
} | |
c8593 | }
return regexp.MatchString(ereq.URLStruct.Path, req.URL.Path)
} | |
c8594 | nil {
return false, err
}
if match {
break
}
}
if !match {
return false, nil
}
}
return true, nil
} | |
c8595 | err != nil {
return false, err
}
if match {
break
}
}
if !match {
return false, nil
}
}
return true, nil
} | |
c8596 |
return false, nil
}
if s != value {
return false, nil
}
}
return true, nil
} | |
c8597 | *Response {
r.StatusCode = code
return r
} | |
c8598 | r.Header.Set(key, value)
return r
} | |
c8599 | r.Header.Add(key, value)
return r
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.