@@ -50,61 +50,35 @@ def _process_custom_annotations(self, annotation_type, field_path, processor):
50
50
51
51
AddTagArg_validator = bv .Struct (AddTagArg )
52
52
53
- class BaseError (bb .Union ):
53
+ class BaseTagError (bb .Union ):
54
54
"""
55
55
This class acts as a tagged union. Only one of the ``is_*`` methods will
56
56
return true. To get the associated value of a tag (if one exists), use the
57
57
corresponding ``get_*`` method.
58
-
59
- :ivar files.BaseError.unknown: Action failed.
60
- :ivar files.BaseError.transient: Action failed. Try again.
61
- :ivar files.BaseError.input_validation: Action failed due to wrong params.
62
- :ivar files.BaseError.cancelled: Action cancelled.
63
58
"""
64
59
65
60
_catch_all = 'other'
66
61
# Attribute is overwritten below the class definition
67
- unknown = None
68
- # Attribute is overwritten below the class definition
69
- transient = None
70
- # Attribute is overwritten below the class definition
71
- input_validation = None
72
- # Attribute is overwritten below the class definition
73
- cancelled = None
74
- # Attribute is overwritten below the class definition
75
62
other = None
76
63
77
- def is_unknown (self ):
78
- """
79
- Check if the union tag is ``unknown``.
80
-
81
- :rtype: bool
82
- """
83
- return self ._tag == 'unknown'
84
-
85
- def is_transient (self ):
86
- """
87
- Check if the union tag is ``transient``.
88
-
89
- :rtype: bool
90
- """
91
- return self ._tag == 'transient'
92
-
93
- def is_input_validation (self ):
64
+ @classmethod
65
+ def path (cls , val ):
94
66
"""
95
- Check if the union tag is ``input_validation``.
67
+ Create an instance of this class set to the ``path`` tag with value
68
+ ``val``.
96
69
97
- :rtype: bool
70
+ :param LookupError val:
71
+ :rtype: BaseTagError
98
72
"""
99
- return self . _tag == 'input_validation'
73
+ return cls ( 'path' , val )
100
74
101
- def is_cancelled (self ):
75
+ def is_path (self ):
102
76
"""
103
- Check if the union tag is ``cancelled ``.
77
+ Check if the union tag is ``path ``.
104
78
105
79
:rtype: bool
106
80
"""
107
- return self ._tag == 'cancelled '
81
+ return self ._tag == 'path '
108
82
109
83
def is_other (self ):
110
84
"""
@@ -114,42 +88,15 @@ def is_other(self):
114
88
"""
115
89
return self ._tag == 'other'
116
90
117
- def _process_custom_annotations (self , annotation_type , field_path , processor ):
118
- super (BaseError , self )._process_custom_annotations (annotation_type , field_path , processor )
119
-
120
- BaseError_validator = bv .Union (BaseError )
121
-
122
- class BaseTagError (BaseError ):
123
- """
124
- This class acts as a tagged union. Only one of the ``is_*`` methods will
125
- return true. To get the associated value of a tag (if one exists), use the
126
- corresponding ``get_*`` method.
127
-
128
- :ivar files.BaseTagError.feature_not_supported: Tags are not turned on for
129
- your team. Please turn on the feature.
130
- :ivar files.BaseTagError.path_not_found: Path not found.
131
- """
132
-
133
- # Attribute is overwritten below the class definition
134
- feature_not_supported = None
135
- # Attribute is overwritten below the class definition
136
- path_not_found = None
137
-
138
- def is_feature_not_supported (self ):
139
- """
140
- Check if the union tag is ``feature_not_supported``.
141
-
142
- :rtype: bool
143
- """
144
- return self ._tag == 'feature_not_supported'
145
-
146
- def is_path_not_found (self ):
91
+ def get_path (self ):
147
92
"""
148
- Check if the union tag is ``path_not_found`` .
93
+ Only call this if :meth:`is_path` is true .
149
94
150
- :rtype: bool
95
+ :rtype: LookupError
151
96
"""
152
- return self ._tag == 'path_not_found'
97
+ if not self .is_path ():
98
+ raise AttributeError ("tag 'path' not set" )
99
+ return self ._value
153
100
154
101
def _process_custom_annotations (self , annotation_type , field_path , processor ):
155
102
super (BaseTagError , self )._process_custom_annotations (annotation_type , field_path , processor )
@@ -162,7 +109,8 @@ class AddTagError(BaseTagError):
162
109
return true. To get the associated value of a tag (if one exists), use the
163
110
corresponding ``get_*`` method.
164
111
165
- :ivar files.AddTagError.too_many_tags: Item already has max supported tags.
112
+ :ivar files.AddTagError.too_many_tags: The item already has the maximum
113
+ supported number of tags.
166
114
"""
167
115
168
116
# Attribute is overwritten below the class definition
@@ -6888,20 +6836,20 @@ class RemoveTagError(BaseTagError):
6888
6836
return true. To get the associated value of a tag (if one exists), use the
6889
6837
corresponding ``get_*`` method.
6890
6838
6891
- :ivar files.RemoveTagError.tag_not_exists_for_this_path : That tag doesn't
6892
- exist at this path.
6839
+ :ivar files.RemoveTagError.tag_not_present : That tag doesn't exist at this
6840
+ path.
6893
6841
"""
6894
6842
6895
6843
# Attribute is overwritten below the class definition
6896
- tag_not_exists_for_this_path = None
6844
+ tag_not_present = None
6897
6845
6898
- def is_tag_not_exists_for_this_path (self ):
6846
+ def is_tag_not_present (self ):
6899
6847
"""
6900
- Check if the union tag is ``tag_not_exists_for_this_path ``.
6848
+ Check if the union tag is ``tag_not_present ``.
6901
6849
6902
6850
:rtype: bool
6903
6851
"""
6904
- return self ._tag == 'tag_not_exists_for_this_path '
6852
+ return self ._tag == 'tag_not_present '
6905
6853
6906
6854
def _process_custom_annotations (self , annotation_type , field_path , processor ):
6907
6855
super (RemoveTagError , self )._process_custom_annotations (annotation_type , field_path , processor )
@@ -10616,35 +10564,14 @@ def _process_custom_annotations(self, annotation_type, field_path, processor):
10616
10564
('tag_text' , AddTagArg .tag_text .validator ),
10617
10565
]
10618
10566
10619
- BaseError ._unknown_validator = bv .Void ()
10620
- BaseError ._transient_validator = bv .Void ()
10621
- BaseError ._input_validation_validator = bv .Void ()
10622
- BaseError ._cancelled_validator = bv .Void ()
10623
- BaseError ._other_validator = bv .Void ()
10624
- BaseError ._tagmap = {
10625
- 'unknown' : BaseError ._unknown_validator ,
10626
- 'transient' : BaseError ._transient_validator ,
10627
- 'input_validation' : BaseError ._input_validation_validator ,
10628
- 'cancelled' : BaseError ._cancelled_validator ,
10629
- 'other' : BaseError ._other_validator ,
10630
- }
10631
-
10632
- BaseError .unknown = BaseError ('unknown' )
10633
- BaseError .transient = BaseError ('transient' )
10634
- BaseError .input_validation = BaseError ('input_validation' )
10635
- BaseError .cancelled = BaseError ('cancelled' )
10636
- BaseError .other = BaseError ('other' )
10637
-
10638
- BaseTagError ._feature_not_supported_validator = bv .Void ()
10639
- BaseTagError ._path_not_found_validator = bv .Void ()
10567
+ BaseTagError ._path_validator = LookupError_validator
10568
+ BaseTagError ._other_validator = bv .Void ()
10640
10569
BaseTagError ._tagmap = {
10641
- 'feature_not_supported ' : BaseTagError ._feature_not_supported_validator ,
10642
- 'path_not_found ' : BaseTagError ._path_not_found_validator ,
10570
+ 'path ' : BaseTagError ._path_validator ,
10571
+ 'other ' : BaseTagError ._other_validator ,
10643
10572
}
10644
- BaseTagError ._tagmap .update (BaseError ._tagmap )
10645
10573
10646
- BaseTagError .feature_not_supported = BaseTagError ('feature_not_supported' )
10647
- BaseTagError .path_not_found = BaseTagError ('path_not_found' )
10574
+ BaseTagError .other = BaseTagError ('other' )
10648
10575
10649
10576
AddTagError ._too_many_tags_validator = bv .Void ()
10650
10577
AddTagError ._tagmap = {
@@ -12112,13 +12039,13 @@ def _process_custom_annotations(self, annotation_type, field_path, processor):
12112
12039
('tag_text' , RemoveTagArg .tag_text .validator ),
12113
12040
]
12114
12041
12115
- RemoveTagError ._tag_not_exists_for_this_path_validator = bv .Void ()
12042
+ RemoveTagError ._tag_not_present_validator = bv .Void ()
12116
12043
RemoveTagError ._tagmap = {
12117
- 'tag_not_exists_for_this_path ' : RemoveTagError ._tag_not_exists_for_this_path_validator ,
12044
+ 'tag_not_present ' : RemoveTagError ._tag_not_present_validator ,
12118
12045
}
12119
12046
RemoveTagError ._tagmap .update (BaseTagError ._tagmap )
12120
12047
12121
- RemoveTagError .tag_not_exists_for_this_path = RemoveTagError ('tag_not_exists_for_this_path ' )
12048
+ RemoveTagError .tag_not_present = RemoveTagError ('tag_not_present ' )
12122
12049
12123
12050
RestoreArg .path .validator = WritePath_validator
12124
12051
RestoreArg .rev .validator = Rev_validator
0 commit comments