本文整理汇总了Python中aspose.cloud.common.utils.Utils类的典型用法代码示例。如果您正苦于以下问题:Python Utils类的具体用法?Python Utils怎么用?Python Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: replace_text
def replace_text(self, old_text, new_text, is_regular_expression=False, page_number=0):
try:
if self.file_name == '':
raise Exception('filename not specified')
if old_text == '':
raise Exception('old text not specified')
if new_text == '':
raise Exception('new text not specified')
post_hash = { "OldValue" : old_text, "NewValue" : new_text, "Regex": "false" }
json_data = json.dumps(post_hash)
if page_number > 0:
str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/pages/" + str(page_number) + '/replaceText'
else:
str_uri = Product.base_product_uri + "/pdf/" + self.file_name + '/replaceText'
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", json_data)
v_output = Utils.validate_output(Utils(), response_stream)
if v_output == "":
folder = Folder()
output_stream = folder.get_file(self.file_name)
output_path = AsposeApp.output_location + self.file_name
Utils.save_file(Utils(), output_stream, output_path)
return output_path
else:
return v_output
except:
raise
示例2: replace_text
def replace_text(self, file_name, old_value, new_value, is_match_case, is_match_whole_word):
try:
if file_name == "":
raise Exception("Please Specify File Name")
field_arr = {
"OldValue": old_value,
"NewValue": new_value,
"IsMatchCase": str(is_match_case),
"IsMatchWholeWord": str(is_match_whole_word),
}
json_arr = json.dumps(field_arr)
str_uri = Product.base_product_uri + "/words/" + file_name + "/replaceText"
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", json_arr)
v_output = Utils.validate_output(Utils(), response_stream)
if v_output == "":
folder = Folder()
output_stream = folder.get_file(file_name)
output_path = AsposeApp.output_location + file_name
Utils.save_file(Utils(), output_stream, output_path)
return output_path
else:
return v_output
except:
raise
示例3: get_shapes
def get_shapes(self, slide_number,storage_type = None,storage_name =None,folder=None):
try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/slides/" + self.file_name + "/slides/" + str(slide_number) + "/shapes"
if folder is not None:
str_uri += "?folder=" + folder
if storage_name is not None:
str_uri += "&storage=" + storage_name
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
json_data = json.loads(response_stream)
shapes = {}
if json_data["Code"] == 200:
shape = {}
for json_data["ShapeList"]["Links"] in shape:
signed_uri = Utils.sign(Utils(), shape["Uri"]["Href"])
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
data = json.loads(response_stream)
shapes = data
return shapes
else:
return json_data
except:
raise
示例4: insert_watermark_image
def insert_watermark_image(self, file_name, image_filename, rotation_angle):
try:
if file_name == "":
raise Exception("Please Specify File Name")
if image_filename == "":
raise Exception("Please Specify Image File Name")
str_uri = (
Product.base_product_uri
+ "/words/"
+ file_name
+ "/insertWatermarkImage?imageFile="
+ image_filename
+ "&rotationAngle="
+ str(rotation_angle)
)
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "POST", "json", "")
v_output = Utils.validate_output(Utils(), response_stream)
if v_output == "":
folder = Folder()
output_stream = folder.get_file(file_name)
output_path = AsposeApp.output_location + file_name
Utils.save_file(Utils(), output_stream, output_path)
return output_path
else:
return v_output
except:
raise
示例5: replace_text
def replace_text(self, *args):
num_of_args = len(args)
if(num_of_args == 2):
old_text = args[0]
new_text = args[1]
elif(num_of_args == 3):
old_text = args[0]
new_text = args[1]
slide_number = args[2]
else:
raise Exception("Invalid Numbers of Arguments")
try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/slides/" + self.file_name
if num_of_args == 3:
str_uri += "/slides/" + str(slide_number)
str_uri += "/replaceText?oldValue=" + old_text + "&newValue=" + new_text + "&ignoreCase=true"
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "POST", "JSON", "")
json_data = json.loads(response_stream)
if json_data["Code"] == 200:
return str(json_data["Matches"]) + " Found And Replaced"
else:
return False
except:
raise
示例6: save
def save(self, codeText, symbology, imageFormat, xResolution, yResolution, xDimension, yDimension):
strURI = Product.base_product_uri + "/barcode/generate?text=" + codeText + "&type=" + str(symbology) + "&format=" + imageFormat
if xResolution <= 0:
strURI += ""
else:
strURI += "&resolutionX=" + str(xResolution)
if yResolution <= 0:
strURI += ""
else:
strURI += "&resolutionY=" + str(yResolution)
if xDimension <= 0:
strURI += ""
else:
strURI += "&dimensionX=" + str(xDimension)
if yDimension <= 0:
strURI += ""
else:
strURI += "&dimensionY=" + str(yDimension)
try:
signedURI = Utils.sign(Utils(), strURI)
response = Utils.process_command(Utils(), signedURI, "GET", "", "")
v_output = Utils.validate_output(self, response)
if(v_output == ""):
output_path = AsposeApp.output_location + "barcode" + str(symbology) + "." + imageFormat
Utils.save_file(self, response, output_path)
return output_path
except:
raise
示例7: get_image_count
def get_image_count(self, page_number):
try:
if self.file_name == "":
raise Exception("Please Specify Pdf File")
str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/pages/" + str(page_number) + "/images"
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
json_data = json.loads(response_stream)
return len(json_data["Images"]["List"])
except:
raise
示例8: is_child_bookmark
def is_child_bookmark(self, bookmark_index):
try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/bookmarks/" + str(bookmark_index)
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
json_data = json.loads(response_stream)
return json_data["Bookmark"]
except:
raise
示例9: get_child_bookmark_count
def get_child_bookmark_count(self, parent_index):
try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/bookmarks/" + str(parent_index) + "/bookmarks"
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
json_data = json.loads(response_stream)
return len(json_data["Bookmarks"]["List"])
except:
raise
示例10: get_annotation
def get_annotation(self, page_number, annotation_index):
try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/pages/" + str(page_number) + "/annotations/" + str(annotation_index)
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
json_data = json.loads(response_stream)
return json_data["Annotation"]
except:
raise
示例11: get_attachment
def get_attachment(self, attachment_index):
try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/pdf/" + self.file_name + "/attachments/" + str(attachment_index)
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
json_data = json.loads(response_stream)
return json_data["Attachments"]
except:
raise
示例12: get_mailmerge_field_names
def get_mailmerge_field_names(self, file_name):
try:
if file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/words/" + file_name + "/mailMergeFieldNames"
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET" , "", "")
json_data = json.loads(response_stream)
return json_data["FieldNames"]
except:
raise
示例13: create_empty_workbook
def create_empty_workbook(self):
try:
str_uri = Product.base_product_uri + "/cells/" + self.file_name
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "PUT", "", "")
json_data = json.loads(response_stream)
if json_data["Code"] == 200:
return json_data
else:
return False
except:
raise
示例14: convert
def convert(self):
try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/slides/" + self.file_name + "?format=" + self.save_format
signed_uri = Utils.sign(self, str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
output_path = AsposeApp.output_location + Utils.get_filename(Utils(), self.file_name) + "." + self.save_format
Utils.save_file(Utils(), response_stream, output_path);
return output_path
except:
raise
示例15: convert_to_image_by_size
def convert_to_image_by_size(self, slide_number, image_format, width, height):
try:
if self.file_name == "":
raise Exception("Please Specify File Name")
str_uri = Product.base_product_uri + "/slides/" + self.file_name + "/slides/" + str(slide_number) + "?format=" + image_format + "&width=" + str(width) + "&height=" + str(height)
signed_uri = Utils.sign(Utils(), str_uri)
response_stream = Utils.process_command(Utils(), signed_uri, "GET", "", "")
output_path = AsposeApp.output_location + Utils.get_filename(Utils(), self.file_name) + "_slide_" + str(slide_number) + "." + image_format
Utils.save_file(Utils(), response_stream, output_path);
return output_path
except:
raise