Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fixes for the linkedin search API #1

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions liclient/__init__.py
Expand Up @@ -230,7 +230,6 @@ def prepare_request(self, access_token, url, kws=[]):
else: else:
prep_url = self.append_sequential_arg(k, kws[k], prep_url) prep_url = self.append_sequential_arg(k, kws[k], prep_url)
prep_url = re.sub('&&', '&', prep_url) prep_url = re.sub('&&', '&', prep_url)
print prep_url
return user_token, prep_url return user_token, prep_url


def append_id_args(self, ids, prep_url): def append_id_args(self, ids, prep_url):
Expand Down Expand Up @@ -269,7 +268,6 @@ def prepare_field_selectors(self, selectors, url):
selector_string = selector_string.strip(',') selector_string = selector_string.strip(',')
selector_string += ')' selector_string += ')'
prep_url += selector_string prep_url += selector_string
print prep_url
return prep_url return prep_url


def check_network_code(self, code): def check_network_code(self, code):
Expand Down Expand Up @@ -363,7 +361,7 @@ def invitation_factory(self, recipient, subject, body, **kwargs):


class LinkedInSearchAPI(LinkedInAPI): class LinkedInSearchAPI(LinkedInAPI):
def __init__(self, params, access_token): def __init__(self, params, access_token):
self.api_search_url = 'http://api.linkedin.com/v1/people/' self.api_search_url = 'http://api.linkedin.com/v1/people'
self.routing = { self.routing = {
'keywords': self.keywords, 'keywords': self.keywords,
'name': self.name, 'name': self.name,
Expand Down
10 changes: 9 additions & 1 deletion liclient/parsers/lixml.py
Expand Up @@ -2,6 +2,10 @@
import mappers import mappers
import re import re


class UnavailableAPIService(Exception):
pass


class LinkedInXMLParser(object): class LinkedInXMLParser(object):
def __init__(self, content): def __init__(self, content):
self.routing = { self.routing = {
Expand All @@ -17,7 +21,11 @@ def __init__(self, content):
} }
self.tree = etree.fromstring(content) self.tree = etree.fromstring(content)
self.root = self.tree.tag self.root = self.tree.tag
self.results = self.__forward_tree(self.tree, self.root) try:
self.results = self.__forward_tree(self.tree, self.root)
except KeyError as e:
raise UnavailableAPIService(e)



def __forward_tree(self, tree, root): def __forward_tree(self, tree, root):
results = self.routing[root](tree) results = self.routing[root](tree)
Expand Down