Skip to content

Commit

Permalink
Merge pull request #1 from ctxis/typo-fixes
Browse files Browse the repository at this point in the history
fix some typos
  • Loading branch information
lefterisnik committed Jun 29, 2016
2 parents 4617c54 + 92063d3 commit 9653de0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Application which provides an `django` like interface to interact with SOAP APIs
## Setup
* `pip install https://github.com/ctxis/lather/archive/master.zip`

and then add you can use this library like this:
and then you can use this library like this:

```python
## models.py
Expand All @@ -34,5 +34,5 @@ client = client.LatherClient()
client.register(models.Customer)
```

## Support
## Specifically supported SOAP APIs
* Microsoft Dynamics NAV Web Services
8 changes: 4 additions & 4 deletions lather/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ def __init__(self, base, username=None, password=None, auth=AuthEnums.NTLM,
self.service = service
self.invalid_companies = kwargs.pop('invalid_companies', [])
# Initialize companies with a list containing a None object. This is
# usefull because we dont have to rewrite the QuerySet class. It will
# useful because we don't have to rewrite the QuerySet class. It will
# iterate over the companies and essentially will make an endpoint
# without company. Usefull for the Generic services
# without company. Useful for the Generic services
self.companies = [None]
if self.service == ServiceEnums.NAV:
self.companies = []
Expand Down Expand Up @@ -174,8 +174,8 @@ def update_companies(self):
the companies
"""
if self.service != ServiceEnums.NAV:
raise Exception('You can only call this function only if the '
'system is NAV')
raise Exception('You can only call this function if the '
'system is MS NAV')
client = self.connect(self.main)
self.companies = list(set(client.Companies()) - set(self.invalid_companies))

Expand Down
26 changes: 13 additions & 13 deletions lather/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

class Field(object):
"""
Suds library de-serialize the attributes, there is no need for
de-serialization. Suds library also cares about the serialization. So in
Suds library de-serializes the attributes, there is no need for
de-serialization. Suds library also does the serialization. So in
this class we only define the validators
"""

Expand Down Expand Up @@ -115,19 +115,19 @@ def _query(self, client, method, **kwargs):
Central method which executes the api calls
"""
if not method:
raise TypeError('Method must be string not None.')
raise TypeError('Method must be a string not None.')
if kwargs.get('attrs', None):
return getattr(client, method)(kwargs.get('attrs'))
return getattr(client, method)(**kwargs)

def _check_kwargs(self, method, **kwargs):
params = self.model.client.get_service_params(method,
self.model._meta.page)
# Because, elements are suds.sax.text.Text, convert them to str
# Because elements are suds.sax.text.Text, convert them to str
params = [str(x[0]) for x in params]
if params:
if len(kwargs.keys()) > len(params):
raise AttributeError('You specify too many arguments.')
raise AttributeError('You have specified too many arguments.')
for k in params:
if k not in kwargs.keys():
raise AttributeError('You have to specify the arg: %s' % k)
Expand Down Expand Up @@ -258,7 +258,7 @@ def get(self, **kwargs):
@require_client
def update(self, obj=None, companies=None, delete=False, **kwargs):
if obj:
# This if will be true when the previous funciton is the
# This if will be true when the previous function is the
# update_or_create
if self.queryset:
for inst in self.queryset:
Expand Down Expand Up @@ -374,8 +374,8 @@ def delete(self, obj=None, **kwargs):
success = False
else:
# Send the delete action to all the companies
# TODO: Maybe run first a get or filter to get the object
# TODO: because the same Key may not be unique
# TODO: Maybe first run a get or filter to get the object
# TODO: because a Key may not be unique
keys = kwargs.get(self.model._meta.default_id, None)
if self.queryset and not keys:
tmp_list = self.queryset[:]
Expand Down Expand Up @@ -419,7 +419,7 @@ def delete(self, obj=None, **kwargs):
for company in companies:
client = self._connect(company)
# TODO: catch more accurate the error: Webfault
# because whenever tries to delete somthing which
# because whenever tries to delete something which
# doesn't exist raise this error
try:
if not self._query(client, self.model._meta.delete,
Expand All @@ -435,7 +435,7 @@ def get_or_create(self, companies=None, **kwargs):
created = False
defaults = kwargs.pop('defaults', None)
# Sometimes, the returning object doesn't contain all the attributes
# from the defaults so if you specify a new value to an atttibute
# from the defaults so if you specify a new value to an attribute
# contained in the defaults but not in the returned object, it will not
# saved, so we are going to add this attributes to the declared_fields
if not self.model._meta.declared_fields:
Expand Down Expand Up @@ -772,7 +772,7 @@ def __init__(self, *args, **kwargs):
# the declared_fields_names
if not self._meta.declared_fields:
raise TypeError(
'You cannot pass args without specifing custom fields.')
'You cannot pass args without specifying custom fields.')
else:
if len(args) > len(self._meta.get_declared_field_names()):
raise TypeError('Too many arguments. You can set '
Expand Down Expand Up @@ -952,13 +952,13 @@ def save(self):
"""
self.clean()
# Create dict with all the fields (declared and discovered)
# TODO: add reaonly fields to ignore at this point because some of them
# TODO: add readonly fields to ignore at this point because some of them
# maybe cannot handle it from the backend
tmp_dict = dict((field, getattr(self, field)) for field in
self._meta.get_field_names() if
field not in self._meta.readonly_fields)

# If there wans't any change at the companies just update, otherwise
# If there wasn't any change at the companies just update, otherwise
# run create which handles these new companies
if len(self.get_keys()) == len(self.get_companies()):
self.objects.update(obj=self, **tmp_dict)
Expand Down
2 changes: 1 addition & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class Response(object):
"""
Simple class which represent the suds response
Simple class which represents the suds response
"""
def __init__(self, keylist, dict):
self.__keylist__ = keylist
Expand Down

0 comments on commit 9653de0

Please sign in to comment.