<commit_before>'''Implements the Cloud.com API'''


from cloudtool.utils import describe
import urllib
import urllib2
import os
import xml.dom.minidom
import re

class CloudAPI:
    
	@describe("server", "Management Server host name or address")
	@describe("responseformat", "Response format: xml or json")
	@describe("stripxml", "True if xml tags have to be stripped in the output, false otherwise")
	def __init__(self,
			server="127.0.0.1:8096",
			responseformat="xml",
			stripxml="false"
			):
		self.__dict__.update(locals())
        
	def _make_request(self,command,parameters=None):
		'''Command is a string, parameters is a dictionary'''
		if ":" in self.server:
			host,port = self.server.split(":")
			port = int(port)
		else:
			host = self.server
			port = 8096
		
		url = "http://" + self.server + "/?"
		
		if not parameters: parameters = {}
		parameters["command"] = command
		parameters["response"] = self.responseformat
		querystring = urllib.urlencode(parameters)
		url += querystring
		
		f = urllib2.urlopen(url)
		data = f.read()
		if self.stripxml == "true":
			data=re.sub("<\?.*\?>", "\n", data);
			data=re.sub("</[a-z]*>", "\n", data);<commit_msg>Defaulted "stripxml" parameter to true in cloud cli tool.<commit_after>'''Implements the Cloud.com API'''


from cloudtool.utils import describe
import urllib
import urllib2
import os
import xml.dom.minidom
import re

class CloudAPI:
    
	@describe("server", "Management Server host name or address")
	@describe("responseformat", "Response format: xml or json")
	@describe("stripxml", "True if xml tags have to be stripped in the output, false otherwise")
	def __init__(self,
			server="127.0.0.1:8096",
			responseformat="xml",
			stripxml="true"
			):
		self.__dict__.update(locals())
        
	def _make_request(self,command,parameters=None):
		'''Command is a string, parameters is a dictionary'''
		if ":" in self.server:
			host,port = self.server.split(":")
			port = int(port)
		else:
			host = self.server
			port = 8096
		
		url = "http://" + self.server + "/?"
		
		if not parameters: parameters = {}
		parameters["command"] = command
		parameters["response"] = self.responseformat
		querystring = urllib.urlencode(parameters)
		url += querystring
		
		f = urllib2.urlopen(url)
		data = f.read()
		if self.stripxml == "true":
			data=re.sub("<\?.*\?>", "\n", data);
			data=re.sub("</[a-z]*>", "\n", data);
{'fraction_non_alphanumeric': 0.1567070622649394, 'fraction_numerical': 0.013372335979941497, 'mean_word_length': 3.9057377049180326, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 15}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2733478', 'n_tokens_mistral': 893, 'n_tokens_neox': 782, 'n_words': 213}