Skip to content

Commit 99457dc

Browse files
committed
Add escaping for namespace with keyword name.
1 parent 0a24600 commit 99457dc

File tree

8 files changed

+406
-399
lines changed

8 files changed

+406
-399
lines changed

dropbox/async.py

Lines changed: 2 additions & 306 deletions
Original file line numberDiff line numberDiff line change
@@ -3,309 +3,5 @@
33
# @generated
44
# flake8: noqa
55
# pylint: skip-file
6-
try:
7-
from . import stone_validators as bv
8-
from . import stone_base as bb
9-
except (ImportError, SystemError, ValueError):
10-
# Catch errors raised when importing a relative module when not in a package.
11-
# This makes testing this file directly (outside of a package) easier.
12-
import stone_validators as bv
13-
import stone_base as bb
14-
15-
class LaunchResultBase(bb.Union):
16-
"""
17-
Result returned by methods that launch an asynchronous job. A method who may
18-
either launch an asynchronous job, or complete the request synchronously,
19-
can use this union by extending it, and adding a 'complete' field with the
20-
type of the synchronous response. See :class:`LaunchEmptyResult` for an
21-
example.
22-
23-
This class acts as a tagged union. Only one of the ``is_*`` methods will
24-
return true. To get the associated value of a tag (if one exists), use the
25-
corresponding ``get_*`` method.
26-
27-
:ivar str async_job_id: This response indicates that the processing is
28-
asynchronous. The string is an id that can be used to obtain the status
29-
of the asynchronous job.
30-
"""
31-
32-
_catch_all = None
33-
34-
@classmethod
35-
def async_job_id(cls, val):
36-
"""
37-
Create an instance of this class set to the ``async_job_id`` tag with
38-
value ``val``.
39-
40-
:param str val:
41-
:rtype: LaunchResultBase
42-
"""
43-
return cls('async_job_id', val)
44-
45-
def is_async_job_id(self):
46-
"""
47-
Check if the union tag is ``async_job_id``.
48-
49-
:rtype: bool
50-
"""
51-
return self._tag == 'async_job_id'
52-
53-
def get_async_job_id(self):
54-
"""
55-
This response indicates that the processing is asynchronous. The string
56-
is an id that can be used to obtain the status of the asynchronous job.
57-
58-
Only call this if :meth:`is_async_job_id` is true.
59-
60-
:rtype: str
61-
"""
62-
if not self.is_async_job_id():
63-
raise AttributeError("tag 'async_job_id' not set")
64-
return self._value
65-
66-
def __repr__(self):
67-
return 'LaunchResultBase(%r, %r)' % (self._tag, self._value)
68-
69-
LaunchResultBase_validator = bv.Union(LaunchResultBase)
70-
71-
class LaunchEmptyResult(LaunchResultBase):
72-
"""
73-
Result returned by methods that may either launch an asynchronous job or
74-
complete synchronously. Upon synchronous completion of the job, no
75-
additional information is returned.
76-
77-
This class acts as a tagged union. Only one of the ``is_*`` methods will
78-
return true. To get the associated value of a tag (if one exists), use the
79-
corresponding ``get_*`` method.
80-
81-
:ivar complete: The job finished synchronously and successfully.
82-
"""
83-
84-
# Attribute is overwritten below the class definition
85-
complete = None
86-
87-
def is_complete(self):
88-
"""
89-
Check if the union tag is ``complete``.
90-
91-
:rtype: bool
92-
"""
93-
return self._tag == 'complete'
94-
95-
def __repr__(self):
96-
return 'LaunchEmptyResult(%r, %r)' % (self._tag, self._value)
97-
98-
LaunchEmptyResult_validator = bv.Union(LaunchEmptyResult)
99-
100-
class PollArg(object):
101-
"""
102-
Arguments for methods that poll the status of an asynchronous job.
103-
104-
:ivar async_job_id: Id of the asynchronous job. This is the value of a
105-
response returned from the method that launched the job.
106-
"""
107-
108-
__slots__ = [
109-
'_async_job_id_value',
110-
'_async_job_id_present',
111-
]
112-
113-
_has_required_fields = True
114-
115-
def __init__(self,
116-
async_job_id=None):
117-
self._async_job_id_value = None
118-
self._async_job_id_present = False
119-
if async_job_id is not None:
120-
self.async_job_id = async_job_id
121-
122-
@property
123-
def async_job_id(self):
124-
"""
125-
Id of the asynchronous job. This is the value of a response returned
126-
from the method that launched the job.
127-
128-
:rtype: str
129-
"""
130-
if self._async_job_id_present:
131-
return self._async_job_id_value
132-
else:
133-
raise AttributeError("missing required field 'async_job_id'")
134-
135-
@async_job_id.setter
136-
def async_job_id(self, val):
137-
val = self._async_job_id_validator.validate(val)
138-
self._async_job_id_value = val
139-
self._async_job_id_present = True
140-
141-
@async_job_id.deleter
142-
def async_job_id(self):
143-
self._async_job_id_value = None
144-
self._async_job_id_present = False
145-
146-
def __repr__(self):
147-
return 'PollArg(async_job_id={!r})'.format(
148-
self._async_job_id_value,
149-
)
150-
151-
PollArg_validator = bv.Struct(PollArg)
152-
153-
class PollResultBase(bb.Union):
154-
"""
155-
Result returned by methods that poll for the status of an asynchronous job.
156-
Unions that extend this union should add a 'complete' field with a type of
157-
the information returned upon job completion. See :class:`PollEmptyResult`
158-
for an example.
159-
160-
This class acts as a tagged union. Only one of the ``is_*`` methods will
161-
return true. To get the associated value of a tag (if one exists), use the
162-
corresponding ``get_*`` method.
163-
164-
:ivar in_progress: The asynchronous job is still in progress.
165-
"""
166-
167-
_catch_all = None
168-
# Attribute is overwritten below the class definition
169-
in_progress = None
170-
171-
def is_in_progress(self):
172-
"""
173-
Check if the union tag is ``in_progress``.
174-
175-
:rtype: bool
176-
"""
177-
return self._tag == 'in_progress'
178-
179-
def __repr__(self):
180-
return 'PollResultBase(%r, %r)' % (self._tag, self._value)
181-
182-
PollResultBase_validator = bv.Union(PollResultBase)
183-
184-
class PollEmptyResult(PollResultBase):
185-
"""
186-
Result returned by methods that poll for the status of an asynchronous job.
187-
Upon completion of the job, no additional information is returned.
188-
189-
This class acts as a tagged union. Only one of the ``is_*`` methods will
190-
return true. To get the associated value of a tag (if one exists), use the
191-
corresponding ``get_*`` method.
192-
193-
:ivar complete: The asynchronous job has completed successfully.
194-
"""
195-
196-
# Attribute is overwritten below the class definition
197-
complete = None
198-
199-
def is_complete(self):
200-
"""
201-
Check if the union tag is ``complete``.
202-
203-
:rtype: bool
204-
"""
205-
return self._tag == 'complete'
206-
207-
def __repr__(self):
208-
return 'PollEmptyResult(%r, %r)' % (self._tag, self._value)
209-
210-
PollEmptyResult_validator = bv.Union(PollEmptyResult)
211-
212-
class PollError(bb.Union):
213-
"""
214-
Error returned by methods for polling the status of asynchronous job.
215-
216-
This class acts as a tagged union. Only one of the ``is_*`` methods will
217-
return true. To get the associated value of a tag (if one exists), use the
218-
corresponding ``get_*`` method.
219-
220-
:ivar invalid_async_job_id: The job ID is invalid.
221-
:ivar internal_error: Something went wrong with the job on Dropbox's end.
222-
You'll need to verify that the action you were taking succeeded, and if
223-
not, try again. This should happen very rarely.
224-
"""
225-
226-
_catch_all = 'other'
227-
# Attribute is overwritten below the class definition
228-
invalid_async_job_id = None
229-
# Attribute is overwritten below the class definition
230-
internal_error = None
231-
# Attribute is overwritten below the class definition
232-
other = None
233-
234-
def is_invalid_async_job_id(self):
235-
"""
236-
Check if the union tag is ``invalid_async_job_id``.
237-
238-
:rtype: bool
239-
"""
240-
return self._tag == 'invalid_async_job_id'
241-
242-
def is_internal_error(self):
243-
"""
244-
Check if the union tag is ``internal_error``.
245-
246-
:rtype: bool
247-
"""
248-
return self._tag == 'internal_error'
249-
250-
def is_other(self):
251-
"""
252-
Check if the union tag is ``other``.
253-
254-
:rtype: bool
255-
"""
256-
return self._tag == 'other'
257-
258-
def __repr__(self):
259-
return 'PollError(%r, %r)' % (self._tag, self._value)
260-
261-
PollError_validator = bv.Union(PollError)
262-
263-
AsyncJobId_validator = bv.String(min_length=1)
264-
LaunchResultBase._async_job_id_validator = AsyncJobId_validator
265-
LaunchResultBase._tagmap = {
266-
'async_job_id': LaunchResultBase._async_job_id_validator,
267-
}
268-
269-
LaunchEmptyResult._complete_validator = bv.Void()
270-
LaunchEmptyResult._tagmap = {
271-
'complete': LaunchEmptyResult._complete_validator,
272-
}
273-
LaunchEmptyResult._tagmap.update(LaunchResultBase._tagmap)
274-
275-
LaunchEmptyResult.complete = LaunchEmptyResult('complete')
276-
277-
PollArg._async_job_id_validator = AsyncJobId_validator
278-
PollArg._all_field_names_ = set(['async_job_id'])
279-
PollArg._all_fields_ = [('async_job_id', PollArg._async_job_id_validator)]
280-
281-
PollResultBase._in_progress_validator = bv.Void()
282-
PollResultBase._tagmap = {
283-
'in_progress': PollResultBase._in_progress_validator,
284-
}
285-
286-
PollResultBase.in_progress = PollResultBase('in_progress')
287-
288-
PollEmptyResult._complete_validator = bv.Void()
289-
PollEmptyResult._tagmap = {
290-
'complete': PollEmptyResult._complete_validator,
291-
}
292-
PollEmptyResult._tagmap.update(PollResultBase._tagmap)
293-
294-
PollEmptyResult.complete = PollEmptyResult('complete')
295-
296-
PollError._invalid_async_job_id_validator = bv.Void()
297-
PollError._internal_error_validator = bv.Void()
298-
PollError._other_validator = bv.Void()
299-
PollError._tagmap = {
300-
'invalid_async_job_id': PollError._invalid_async_job_id_validator,
301-
'internal_error': PollError._internal_error_validator,
302-
'other': PollError._other_validator,
303-
}
304-
305-
PollError.invalid_async_job_id = PollError('invalid_async_job_id')
306-
PollError.internal_error = PollError('internal_error')
307-
PollError.other = PollError('other')
308-
309-
ROUTES = {
310-
}
311-
6+
# If you have issues importing this module because Python recognizes it as a keyword, use async_ instead.
7+
from async_ import *

0 commit comments

Comments
 (0)