MCPcopy Index your code
hub / github.com/ronreiter/interactive-tutorials / Ideone

Class Ideone

ideone/__init__.py:25–326  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 pass
24
25class Ideone(object):
26
27 ERROR_OK = 'OK'
28
29 def __init__(self, user, password, api_url=None):
30 self.user = user
31 self.password = password
32 self.api_url = api_url if api_url else 'https://ideone.com/api/1/service.wsdl'
33 self._import = Import('http://schemas.xmlsoap.org/soap/encoding/')
34 self._doctor = ImportDoctor(self._import)
35 self.client = Client(self.api_url, doctor=self._doctor)
36 self._language_dict = None
37
38 @staticmethod
39 def _transform_to_dict(result):
40 """
41 Transform the array from Ideone into a Python dictionary.
42 """
43 result_dict = {}
44 property_list = result.item
45 for item in property_list:
46 result_dict[item.key[0]] = item.value[0]
47 return result_dict
48
49 @staticmethod
50 def _handle_error(result_dict):
51 """
52 Raise an exception if the Ideone gave us an error.
53 """
54 error = result_dict['error']
55 if error == Ideone.ERROR_OK:
56 return
57 else:
58 raise IdeoneError(error)
59
60 @staticmethod
61 def _collapse_language_array(language_array):
62 """
63 Convert the Ideone language list into a Python dictionary.
64 """
65 language_dict = {}
66 for language in language_array.item:
67 key = language.key[0]
68 value = language.value[0]
69 language_dict[key] = value
70
71 return language_dict
72
73 def _translate_language_name(self, language_name):
74 """
75 Translate a human readable langauge name into its Ideone
76 integer representation.
77
78 Keyword Arguments
79 -----------------
80
81 * langauge_name: a string of the language (e.g. "c++")
82

Callers 1

run_codeFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected