Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: vpython/api/vpython/util.go

Issue 2927573002: [vpython] Fix PEP425 naming. (Closed)
Patch Set: rebase and update Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « vpython/api/vpython/spec.pb.go ('k') | vpython/application/application.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package vpython 5 package vpython
6 6
7 import ( 7 import (
8 "strings" 8 "strings"
9 9
10 "github.com/golang/protobuf/proto" 10 "github.com/golang/protobuf/proto"
11 ) 11 )
12 12
13 // Version is a version string. It must be updated any time the text protobufs 13 // Version is a version string. It must be updated any time the text protobufs
14 // advance in a non-backwards-compatible way. 14 // advance in a non-backwards-compatible way.
15 // 15 //
16 // This version string is used in the generation of filenames, and must be 16 // This version string is used in the generation of filenames, and must be
17 // filesystem-compatible. 17 // filesystem-compatible.
18 const Version = "v1" 18 const Version = "v2"
19 19
20 // Clone returns a deep clone of the supplied Environment. 20 // Clone returns a deep clone of the supplied Environment.
21 // 21 //
22 // If e is nil, a non-nil empty Environment will be returned. 22 // If e is nil, a non-nil empty Environment will be returned.
23 func (e *Environment) Clone() *Environment { 23 func (e *Environment) Clone() *Environment {
24 if e == nil { 24 if e == nil {
25 return &Environment{} 25 return &Environment{}
26 } 26 }
27 return proto.Clone(e).(*Environment) 27 return proto.Clone(e).(*Environment)
28 } 28 }
29 29
30 // IsZero returns true if this tag is a zero value. 30 // IsZero returns true if this tag is a zero value.
31 func (t *Pep425Tag) IsZero() bool { 31 func (t *PEP425Tag) IsZero() bool {
32 » return t == nil || (t.Version == "" && t.Abi == "" && t.Arch == "") 32 » return t == nil || (t.Python == "" && t.Abi == "" && t.Platform == "")
33 } 33 }
34 34
35 // TagString returns an underscore-separated string containing t's fields. 35 // TagString returns an underscore-separated string containing t's fields.
36 func (t *Pep425Tag) TagString() string { 36 func (t *PEP425Tag) TagString() string {
37 » return strings.Join([]string{t.Version, t.Abi, t.Arch}, "-") 37 » return strings.Join([]string{t.Python, t.Abi, t.Platform}, "-")
38 } 38 }
39 39
40 // HasABI returns true if t declares that it only works with a specific ABI. 40 // HasABI returns true if t declares that it only works with a specific ABI.
41 func (t *Pep425Tag) HasABI() bool { return t.Abi != "none" } 41 func (t *PEP425Tag) HasABI() bool { return t.Abi != "none" }
42 42
43 // AnyArch returns true if t declares that it works on any architecture. 43 // AnyPlatform returns true if t declares that it works on any platform.
44 func (t *Pep425Tag) AnyArch() bool { return t.Arch == "any" } 44 func (t *PEP425Tag) AnyPlatform() bool { return t.Platform == "any" }
45 45
46 // Count returns the number of populated fields in this tag. 46 // Count returns the number of populated fields in this tag.
47 func (t *Pep425Tag) Count() (v int) { 47 func (t *PEP425Tag) Count() (v int) {
48 if t.HasABI() { 48 if t.HasABI() {
49 v++ 49 v++
50 } 50 }
51 » if t.AnyArch() { 51 » if t.AnyPlatform() {
52 v++ 52 v++
53 } 53 }
54 return 54 return
55 } 55 }
56 56
57 // Clone returns a deep clone of the supplied Spec. 57 // Clone returns a deep clone of the supplied Spec.
58 // 58 //
59 // If e is nil, a non-nil empty Spec will be returned. 59 // If e is nil, a non-nil empty Spec will be returned.
60 func (s *Spec) Clone() *Spec { 60 func (s *Spec) Clone() *Spec {
61 if s == nil { 61 if s == nil {
62 return &Spec{} 62 return &Spec{}
63 } 63 }
64 return proto.Clone(s).(*Spec) 64 return proto.Clone(s).(*Spec)
65 } 65 }
OLDNEW
« no previous file with comments | « vpython/api/vpython/spec.pb.go ('k') | vpython/application/application.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698