Skip to content

Commit a429000

Browse files
committed
Merge pull request #1 from puentesarrin/typos
Fixed several typos.
2 parents 7bd9971 + 7ff051e commit a429000

7 files changed

Lines changed: 51 additions & 46 deletions

File tree

restea/adapters/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def get_routes(self, path='', iden=''):
4242
class BaseRequestWrapper(object):
4343
'''
4444
BaseRequestWrapper wraps the `restea.request.Request` objects to abstract
45-
implementation bettween different frameworks
45+
implementation between different frameworks
4646
'''
4747
def __init__(self, original_request):
4848
'''
@@ -64,7 +64,7 @@ def headers(self):
6464
'''
6565
Returns a headers dict
6666
67-
:returns: dict -- headers been send to server
67+
:returns: dict -- received request headers
6868
'''
6969
raise NotImplementedError
7070

restea/adapters/djangowrap.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
class DjangoRequestWrapper(BaseRequestWrapper):
1212
'''
13-
Object wrapping django request object.
13+
Object wrapping Django request object.
1414
'''
1515
@property
1616
def method(self):
@@ -26,7 +26,7 @@ def headers(self):
2626
'''
2727
Returns a headers dict
2828
29-
:returns: dict -- headers been send to server
29+
:returns: dict -- received request headers
3030
'''
3131
return self._original_request.META
3232

@@ -51,8 +51,8 @@ def data(self):
5151

5252
class DjangoResourceRouter(BaseResourceWrapper):
5353
'''
54-
Wraps over django views, implements django view api and creates routing in
55-
the django urlrouter format
54+
Wraps over Django views, implements Django view API and creates routing in
55+
the Django urlrouter format
5656
'''
5757

5858
def wrap_request(self, request, *args, **kwargs):

restea/adapters/flaskwrap.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class FlaskRequestWrapper(BaseRequestWrapper):
1111
'''
12-
Object wrapping flask request context.
12+
Object wrapping Flask request context.
1313
'''
1414
@property
1515
def data(self):
@@ -34,7 +34,7 @@ def headers(self):
3434
'''
3535
Returns a headers dict
3636
37-
:returns: dict -- headers been send to server
37+
:returns: dict -- received request headers
3838
'''
3939
return self._original_request.headers
4040

@@ -50,14 +50,14 @@ def get(self, value):
5050

5151
class FlaskResourceWrapper(BaseResourceWrapper):
5252
'''
53-
FlaskResourceWrapper implements flask 'view' api for the
54-
`restea.Resource` object, aka routing and return values in flask format
53+
FlaskResourceWrapper implements Flask 'view' API for the
54+
`restea.Resource` object, aka routing and return values in Flask format
5555
'''
5656
@property
5757
def app(self):
5858
'''
59-
Returns current flask application
60-
:returns: :class: `app.Flask` -- current flask app
59+
Returns current Flask application
60+
:returns: :class: `app.Flask` -- current Flask app
6161
'''
6262
return flask.current_app
6363

@@ -83,7 +83,7 @@ def wrap_request(self, *args, **kwargs):
8383

8484
def __adapt_path(self, path):
8585
'''
86-
Adapts the path to math flask requirements for the url routes
86+
Adapts the path to path Flask requirements for the url routes
8787
8888
:param path: string -- route path
8989
:returns: string -- normalized route path

restea/errors.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
class RestError(Exception):
22
'''
3-
Base rest error exception class. All other rest exception are derived from
4-
RestError
3+
Base rest error exception class. All other rest exceptions are derived from
4+
RestError.
55
'''
66
def __init__(self, message, code=None):
77
'''
88
:param message: string -- exception message
9-
:param code: int -- code of the error, optional. used to be returned
10-
alongside meesage
9+
:param code: int -- error code, optional. used to be returned
10+
alongside message
1111
'''
1212
super(RestError, self).__init__(message)
1313
self.code = code
@@ -29,7 +29,7 @@ class ForbiddenError(RestError):
2929

3030
class NotFoundError(RestError):
3131
'''
32-
HTTP 404. Not found error
32+
HTTP 404. Not found
3333
'''
3434
http_code = 404
3535

restea/fields.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class FieldSet(object):
88
class Error(Exception):
99
pass
1010

11-
#: error thrown in case misconfigured field, for istance if setting
11+
#: error thrown in case misconfigured field, for instance if setting
1212
# can't be found for a given field
1313
class ConfigurationError(Exception):
1414
pass
@@ -46,9 +46,9 @@ def validate(self, data):
4646
'''
4747
Validates payload input
4848
:param data: dict -- input playload data to be validated
49-
:raises restea.fields.FieldSet.Error: field validation faield
49+
:raises restea.fields.FieldSet.Error: field validation failed
5050
:raises restea.fields.FieldSet.Error: required field missing
51-
:raises restea.fields.FieldSet.ConfigurationError: misformed field
51+
:raises restea.fields.FieldSet.ConfigurationError: badformed field
5252
:returns: dict -- validated data
5353
'''
5454
field_names = self.field_names
@@ -87,7 +87,7 @@ def set_name(self, name):
8787

8888
def _validate_field(self, field_value):
8989
'''
90-
Validates a field value. Shold be overriden in a child class
90+
Validates a field value. Should be overriden in a child class
9191
:param field_name: string -- name of the field to be validated
9292
'''
9393
raise NotImplementedError
@@ -138,7 +138,9 @@ def _validate_field(self, field_value):
138138
try:
139139
return int(field_value)
140140
except (ValueError, TypeError):
141-
raise FieldSet.Error('Field "{}" not a number'.format(self._name))
141+
raise FieldSet.Error(
142+
'Field "{}" is not a number'.format(self._name)
143+
)
142144

143145

144146
class String(Field):
@@ -164,5 +166,7 @@ def _validate_field(self, field_value):
164166
:returns: string -- validated value
165167
'''
166168
if not isinstance(field_value, basestring):
167-
raise FieldSet.Error('Field "{}" not a string'.format(self._name))
169+
raise FieldSet.Error(
170+
'Field "{}" is not a string'.format(self._name)
171+
)
168172
return field_value

restea/formats.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
class LoadError(Exception):
88
'''
9-
Error raiseed in case serializing or unserializing went wrong
9+
Error raised in case serializing or unserializing went wrong
1010
'''
1111

1212

1313
class FormatterRegistry(type):
1414
'''
15-
Registry metaclass. Registers all `restea.formats.BaseFormat` sublcasses
15+
Registry metaclass. Registers all `restea.formats.BaseFormat` subclasses
1616
in _formatter_registry
1717
'''
1818
def __init__(cls, name, bases, dict):
@@ -30,10 +30,10 @@ class BaseFormatter(object):
3030
@classmethod
3131
def unserialize(cls, data):
3232
'''
33-
Unserializes imcomming data (payload)
33+
Unserializes incoming data (payload)
3434
3535
:param data: string - raw data to be unserialized
36-
:returns: dict -- respesenation of the data in python datastructure
36+
:returns: dict -- respresentation of the data in Python data structure
3737
'''
3838
raise NotImplementedError
3939

@@ -42,8 +42,8 @@ def serialize(cls, data):
4242
'''
4343
Serializes outgoing data
4444
45-
:param data: dict - python data structure to be serialized
46-
:returns: string -- serialized respesenation of the data
45+
:param data: dict - Python data structure to be serialized
46+
:returns: string -- serialized representation of the data
4747
'''
4848
raise NotImplementedError
4949

@@ -56,10 +56,10 @@ class JsonFormat(BaseFormatter):
5656
@classmethod
5757
def unserialize(cls, data):
5858
'''
59-
Unserializes imcomming data (payload)
59+
Unserializes incomming data (payload)
6060
6161
:param data: string - raw data to be unserialized
62-
:returns: dict -- respesenation of the data in python datastructure
62+
:returns: dict -- representation of the data in Python data structure
6363
'''
6464
try:
6565
return json.loads(data)
@@ -71,8 +71,8 @@ def serialize(cls, data):
7171
'''
7272
Serializes outgoing data
7373
74-
:param data: dict - python data structure to be serialized
75-
:returns: string -- serialized respesenation of the data
74+
:param data: dict - Python data structure to be serialized
75+
:returns: string -- serialized representation of the data
7676
'''
7777
try:
7878
return json.dumps(data)
@@ -82,7 +82,7 @@ def serialize(cls, data):
8282

8383
def get_formatter(format_name):
8484
'''
85-
Factory method returning format class based on it's name
85+
Factory method returning format class based on its name
8686
:param format_name: string -- name of the format
8787
:returns: either subclass :class: `restea.formats.BaseFormatter` or None
8888
'''

restea/resource.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class Resource(object):
1010
'''
11-
Resoruce class implements all the logic of mapping HTTP methods to
11+
Resource class implements all the logic of mapping HTTP methods to
1212
methods and error handling
1313
'''
1414

@@ -26,7 +26,7 @@ def __init__(self, request, formatter):
2626
sublcass -- request wrapper object
2727
2828
:param formatter: :class: `restea.formats.BaseFormatter` subclass --
29-
formatter class implmementing serialization and unserialization of
29+
formatter class implementing serialization and unserialization of
3030
the data
3131
'''
3232
if not hasattr(self, 'fields'):
@@ -40,15 +40,15 @@ def _iden_required(self, method_name):
4040
Checks if given method requires iden
4141
4242
:param method_name: string -- name of method on a resrouce
43-
:returns: bool - boolean value of whatever iden needed or not
43+
:returns: bool - boolean value of whatever iden is needed or not
4444
'''
4545
return method_name not in ('list', 'create')
4646

4747
def _apply_decorators(self, method):
4848
'''
4949
Returns method decorated with decorators specified in self.decorators
5050
:param method: -- resource method
51-
:returns: method derocated
51+
:returns: decorated method
5252
'''
5353
if not hasattr(self, 'decorators'):
5454
return method
@@ -65,7 +65,7 @@ def _get_method_name(self, has_iden):
6565
:param has_iden: specifies if requested url has iden (i.e /res/ vs
6666
/res/1)
6767
:raises errors.MethodNotAllowedError: if HTTP method is not supprted
68-
:returns: string - name of the resorce method name
68+
:returns: string - name of the resource method name
6969
'''
7070
method = self.request.method
7171
method = self.request.headers.get(
@@ -97,7 +97,7 @@ def _get_method_name(self, has_iden):
9797
@property
9898
def _is_valid_formatter(self):
9999
'''
100-
Returns is self.fomatter refers to a valid formatter class object
100+
Returns is self.formatter refers to a valid formatter class object
101101
:returns: bool
102102
'''
103103
return (
@@ -125,7 +125,7 @@ def _get_method(self, method_name):
125125
:param method_name: string -- name of the method
126126
:raises errors.BadRequestError: method is not implemented for a given
127127
resource
128-
:returns: -- method of the rest resource object
128+
:returns: -- method of the REST resource object
129129
'''
130130
method_exists = hasattr(self, method_name)
131131
if not method_exists:
@@ -140,7 +140,7 @@ def _get_payload(self):
140140
Returns a validated and parsed payload data for request
141141
142142
:raises restea.errors.BadRequestError: unparseable data
143-
:raises restea.errors.BadRequestError: payload is not mapable
143+
:raises restea.errors.BadRequestError: payload is not mappable
144144
:raises restea.errors.BadRequestError: validation of fields not passed
145145
:returns: dict - validated data passed to resource
146146
'''
@@ -173,7 +173,7 @@ def process(self, *args, **kwargs):
173173
174174
:raises restea.errors.BadRequestError: wrong self.formatter type
175175
:raises restea.errors.ServerError: Some unhandled exception in
176-
resrouce method implementation or formatter serialization error
176+
resource method implementation or formatter serialization error
177177
178178
:returns: string -- serialized data to be returned to client
179179
'''
@@ -198,14 +198,15 @@ def process(self, *args, **kwargs):
198198
try:
199199
return self.formatter.serialize(res)
200200
except formats.LoadError:
201-
raise errors.ServerError('Service can\'t respond in this format')
201+
raise errors.ServerError('Service can\'t respond with this format')
202202

203203
def dispatch(self, *args, **kwargs):
204204
'''
205205
Dispatches the request and handles exception to return data, status
206206
and content type
207207
208-
:retruns: tuple -- 3 element tuple: result, http code and content type
208+
:returns: tuple -- 3 element tuple: result, HTTP status code and
209+
content type
209210
'''
210211
try:
211212
return (

0 commit comments

Comments
 (0)