Related
I need to add currency symbol to marker label to a plotly graphic_objects chart in python. For example "€0.15" How do I do that?
from tkinter import *
from tkinter import ttk
import plotly.graph_objects as go
window = Tk()
monthly_comparison_result=[["","","","","","","","","","","","",],["","","","","","","","","","","","",],["","","","","","","","","","","","",],["","","","","","","","","","","","",]]
for i in range(4):
for j in range(12): monthly_comparison_result[i][j] = dividend_monthly_comparison[j][i]
for i in range(12): monthly_comparison_result[1][i] = monthly_comparison_result[1][i][1:].replace(",", ".")
for i in range(12): monthly_comparison_result[2][i] = monthly_comparison_result[2][i][1:].replace(",", ".")
for i in range(12): monthly_comparison_result[3][i] = monthly_comparison_result[3][i][1:].replace(",", ".")
annual_bar_chart = go.Figure()
annual_bar_chart.add_trace(go.Bar(x=monthly_comparison_result[0], y=monthly_comparison_result[1], name='2021', text=monthly_comparison_result[1], textposition="outside", textfont=dict(family="sans serif",size=18,color="black")))
annual_bar_chart.add_trace(go.Bar(x=monthly_comparison_result[0], y=monthly_comparison_result[2], name='2022', text=monthly_comparison_result[2], textposition="outside", textfont=dict(family="sans serif",size=18,color="black")))
annual_bar_chart.add_trace(go.Bar(x=monthly_comparison_result[0], y=monthly_comparison_result[3], name='2023', text=monthly_comparison_result[3], textposition="outside", textfont=dict(family="sans serif",size=18,color="black")))
annual_bar_chart.update_layout(barmode='group', xaxis_tickangle=-45, autotypenumbers='convert types', margin=dict(l=00, r=00, b=0, t=0, pad=0), title_font_size=40, paper_bgcolor='#f0f0f0', plot_bgcolor="#f0f0f0", autosize=True, showlegend=True, width=1830, height=500, yaxis_tickprefix='€', yaxis_tickformat=',.')
annual_bar_chart.show()
The variable 'dividend_monthly_comparison' contains:
[['Ianuarie', '€0,03', '€0,49', ''], ['Februarie', '€0,11', '€1,01', ''], ['Martie', '€0,09', '€0,56', ''], ['Aprilie', '€0,08', '€0,85', ''], ['Mai', '€0,47', '€0,85', ''], ['Iunie', '€0,18', '€0,88', ''], ['Iulie', '€0,34', '€0,99', ''], ['August', '€0,82', '€1,05', ''], ['Septembrie', '€0,21', '', ''], ['Octombrie', '€0,62', '', ''], ['Noiembrie', '€1,09', '', ''], ['Decembrie', '€0,50', '', ''], ['Total', '€4,55', '€6,68', '€0,00']]
The variable 'monthly_comparison_result' is the transposed array
Simply construct the text as you want it. Have used a list comprehension to achieve this. Have done a minor refactor of your code to reduce copy paste effect to create traces.
import plotly.graph_objects as go
dividend_monthly_comparison = [['Ianuarie', '€0,03', '€0,49', ''], ['Februarie', '€0,11', '€1,01', ''], ['Martie', '€0,09', '€0,56', ''], ['Aprilie', '€0,08', '€0,85', ''], ['Mai', '€0,47', '€0,85', ''], ['Iunie', '€0,18', '€0,88', ''], ['Iulie', '€0,34', '€0,99', ''], ['August', '€0,82', '€1,05', ''], ['Septembrie', '€0,21', '', ''], ['Octombrie', '€0,62', '', ''], ['Noiembrie', '€1,09', '', ''], ['Decembrie', '€0,50', '', ''], ['Total', '€4,55', '€6,68', '€0,00']] # fmt: skip
monthly_comparison_result=[["","","","","","","","","","","","",],["","","","","","","","","","","","",],["","","","","","","","","","","","",],["","","","","","","","","","","","",]] # fmt: skip
for i in range(4):
for j in range(12):
monthly_comparison_result[i][j] = dividend_monthly_comparison[j][i]
for i in range(12):
monthly_comparison_result[1][i] = monthly_comparison_result[1][i][1:].replace(
",", "."
)
for i in range(12):
monthly_comparison_result[2][i] = monthly_comparison_result[2][i][1:].replace(
",", "."
)
for i in range(12):
monthly_comparison_result[3][i] = monthly_comparison_result[3][i][1:].replace(
",", "."
)
annual_bar_chart = go.Figure()
for i, mcr in enumerate(monthly_comparison_result[1:]):
annual_bar_chart.add_trace(
go.Bar(
x=monthly_comparison_result[0],
y=mcr,
name=f"{2021+i}",
text=["€" + v if v != "" else "" for v in mcr],
textposition="outside",
textfont=dict(family="sans serif", size=18, color="black"),
)
)
annual_bar_chart.update_layout(
barmode="group",
xaxis_tickangle=-45,
autotypenumbers="convert types",
margin=dict(l=00, r=00, b=0, t=0, pad=0),
title_font_size=40,
paper_bgcolor="#f0f0f0",
plot_bgcolor="#f0f0f0",
autosize=True,
showlegend=True,
width=1830,
height=500,
yaxis_tickprefix="€",
yaxis_tickformat=",.",
)
annual_bar_chart.show()
def InitialiseSudoku(): # this function is for initialisation of the sudoku function
cols = '0123456789ABCDEF'
rows = 'ABCDEFGHIJKLMNOP'
global coordinates
coordinates = represent(rows, cols)
global subgridlist
subgridlist = ([represent(rows, c) for c in cols] + [represent(r, cols) for r in rows] + [represent(rs, cs) for rs in
subgrids = dict((s, [u for u in subgridlist if s in u]) for s in coordinates)
global constraintpartners
constraintpartners = dict((s, set(sum(subgrids[s], [])) - set([s])) for s in coordinates)
global dictionary
global value
i = 0
for s in coordinates:
dictionary[s] = ['1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1']
value[s] = input_list[i]
prune_domain[s] = ['', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '']
i = i + 1
this produces a syntax error on the line:
subgrids = dict((s, [u for u in subgridlist if s in u]) for s in coordinates)
the specific error is the = sign
In general errors often are on the line before the error lists (this is because the line before is valid up to expecting a particular syntax construction.
This seems to be an instance of that case, on line 9 you state
for rs in
But that's not complete, it should be
for rs in <iterable/variable>
Where iterable/variableis whatever you are iterating over.
I have a text that contains stuff like this :
(some text)
libncursesw5-dev:amd64 depends on libc6-dev | libc-dev;(some text)
libx32ncursesw5 depends on libc6-x32 (>= 2.16);(some text)
libx32ncurses5-dev depends on libncurses5-dev (= 5.9+20150516-2ubuntu1);(some text)
libx32ncursesw5-dev depends on libc6-dev-x32;(some text)
lib32tinfo-dev depends on lib32c-dev;(some text)
Here is a full example on one of the sentences :
dpkg: error processing package lib32tinfo5 (--install):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of libncurses5-dev:amd64:
libncurses5-dev:amd64 depends on libc6-dev | libc-dev; however:
Package libc6-dev is not installed.
Package libc-dev is not installed.
The whole text is divided in several paragraphs such as the one above, each paragraph contains one of those sentences.
I would like a regex using re library in python that would give me something like this using findall option :
('libc6-dev', '', 'libc-dev', '')
('libc6-x32','2.16')
('libncurses5-dev','5.9+20150516-2ubuntu1')
('libc6-dev-x32','')
('lib32c-dev','')
In another words, I would like your help in order to get from such text, a tuple containing the packages with their versions if specified.
I did this regex :
(?<=depends on )([a-zA-Z0-9\-]*)(?: \([=> ]*([a-zA-Z0-9-+.]*)(?:\)))?|(?: \| )([a-zA-Z0-9\-]*)(?: \([=> ]*([a-zA-Z0-9-+.]*)(?:\)))?(?=;)
I got this result :
('libc6-dev', '', '', '')
('', '', 'libc-dev', '')
('libc6-x32', '2.16', '', '')
('libncurses5-dev', '5.9+20150516-2ubuntu1', '', '')
('libc6-dev-x32', '', '', '')
('lib32c-dev', '', '', '')
As you can see, for the sentence :
libncursesw5-dev:amd64 depends on libc6-dev | libc-dev;
I got this answer :
('libc6-dev', '', '', '')
('', '', 'libc-dev', '')
Rather than this one :
('libc6-dev', '', 'libc-dev', '')
Thank you for your help.
#!/usr/bin/python2
# -*- coding: utf-8 -*-
import re
input = """(some text)
libncursesw5-dev:amd64 depends on libc6-dev | libc-dev;(some text)
libx32ncursesw5 depends on libc6-x32 (>= 2.16);(some text)
libx32ncurses5-dev depends on libncurses5-dev (= 5.9+20150516-2ubuntu1);(some text)
libx32ncursesw5-dev depends on libc6-dev-x32;(some text)
lib32tinfo-dev depends on lib32c-dev;(some text)"""
#a = []
#m = re.findall("depends on ([^\s;]+)\ \|\ ([^\s;]+)", input) # 1
#a = a + m
#m = re.findall("depends on ([^\s;]+)\ \([><=]{,2} ([^;]+)\)", input) # 2, 3
#a = a + m
#m = re.findall("depends on ([^\s;]+)", input) # 4, 5
#a = a + m
m = re.findall("depends on ([^\s;]+)\ \|\ ([^\s;]+)|depends on ([^\s;]+)\ \([><=]{,2} ([^;]+)\)|depends on ([^\s;]+)", input)
print m
output:
[
('libc6-dev', 'libc-dev', '', '', ''),
('', '', 'libc6-x32', '2.16', ''),
('', '', 'libncurses5-dev', '5.9+20150516-2ubuntu1', ''),
('', '', '', '', 'libc6-dev-x32'),
('', '', '', '', 'lib32c-dev')
]
you can get it one by one or all together with | i don't know if this can help you
I need to skip 47 lines of the file(header and so on),then read this
4.163186002791e+04 3.578830331359e+04 3.076496349687e+04 2.644671278966e+04 2.273458304119e+04
1.954349752908e+04 1.680032112209e+04 1.444218412726e+04 1.241504140604e+04 1.067243373686e+04
9.174423035938e+03 7.886677033340e+03 6.779682426302e+03 5.828068476394e+03 5.010025548360e+03
1.737988920100e+03 1.284332855871e+03 1.104060538508e+03 8.158747205330e+02 7.013564117662e+02
6.029121922103e+02 5.182858606802e+02 4.455379022877e+02 2.433020871700e+02 2.091515701348e+02
1.797945089525e+02 1.545580816278e+02 1.328639052196e+02 9.818329499070e+01 7.255514128762e+01
5.361653963401e+01 4.609078195788e+01 3.962135930423e+01 3.406000172766e+01 2.927925083995e+01
2.516953864546e+01 2.163667639887e+01 1.859969593339e+01 1.598899398582e+01 1.374473698894e+01
1.181548977143e+01 1.015703673713e+01 8.731368506527e+00 7.505810795983e+00 6.452275569743e+00
5.546617302183e+00 4.768079596776e+00 4.098819479081e+00 3.523498461194e+00 3.028931005477e+00
2.603782330822e+00 2.238308635635e+00 1.924133783786e+00 1.654057335509e+00 1.421889523591e+00
1.222309392724e+00 1.050742850800e+00 9.032578372386e-01 7.764742057598e-01 6.674862562538e-01
5.737961402745e-01 4.932566139141e-01 3.133421372728e-01 2.315524554696e-01 1.990511474577e-01
1.711118080085e-01 1.470941072881e-01 1.264475938317e-01 1.086990789815e-01 9.344179207682e-02
8.032605785014e-02 6.905128236880e-02 5.935906385039e-02 5.102727046220e-02
possibly as list,and then again skip 21 lines and read the part of the file in same format as presented above.
Firstly my idea was something like this:
from itertools import islice
n=15
with open('91_FULLMERGED.edi') as f:
lines_after_48 = f.readlines()[48:]
while True:
next_15_lines = list(islice(lines_after_48, n))
if not next_15_lines:
break
But that is not working.
milenko#milenko-HP-Compaq-6830s:~/EDIs$ python k1.py
It is just standing still in terminal.
How to solve this?
Code
I use the csv reader cause the format is csv with delimiter ' '. At first I just skipped 47 lines by just next(f,None). Afterwards the csv module is making the trick. If you want to output as a file you can just use the csv writer. You can uncomment the code if you want to remove the empty strings from the output list. But then the output to the file is not similar to the input. It depends on how you wanna use the data.
import csv
with open('input.txt', 'rb') as f:
for i in range(47):
next(f, None)
reader = csv.reader(f,delimiter=' ')
values = list(reader)
# if you want to remove the ''
#for idx, val in enumerate(values):
# values[idx] = [x for x in values[idx] if x != '']
print values
with open('output.txt', 'wb') as f:
writer = csv.writer(f, delimiter=' ', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for line in values:
writer.writerow(line)
Output to screen
[['4.163186002791e+04', '', '3.578830331359e+04', '', '3.076496349687e+04', '', '2.644671278966e+04', '', '2.273458304119e+04'],
['1.954349752908e+04', '', '1.680032112209e+04', '', '1.444218412726e+04', '', '1.241504140604e+04', '', '1.067243373686e+04'],
['9.174423035938e+03', '', '7.886677033340e+03', '', '6.779682426302e+03', '', '5.828068476394e+03', '', '5.010025548360e+03'],
['1.737988920100e+03', '', '1.284332855871e+03', '', '1.104060538508e+03', '', '8.158747205330e+02', '', '7.013564117662e+02'],
['6.029121922103e+02', '', '5.182858606802e+02', '', '4.455379022877e+02', '', '2.433020871700e+02', '', '2.091515701348e+02'],
['1.797945089525e+02', '', '1.545580816278e+02', '', '1.328639052196e+02', '', '9.818329499070e+01', '', '7.255514128762e+01'],
['5.361653963401e+01', '', '4.609078195788e+01', '', '3.962135930423e+01', '', '3.406000172766e+01', '', '2.927925083995e+01'],
['2.516953864546e+01', '', '2.163667639887e+01', '', '1.859969593339e+01', '', '1.598899398582e+01', '', '1.374473698894e+01'],
['1.181548977143e+01', '', '1.015703673713e+01', '', '8.731368506527e+00', '', '7.505810795983e+00', '', '6.452275569743e+00'],
['5.546617302183e+00', '', '4.768079596776e+00', '', '4.098819479081e+00', '', '3.523498461194e+00', '', '3.028931005477e+00'],
['2.603782330822e+00', '', '2.238308635635e+00', '', '1.924133783786e+00', '', '1.654057335509e+00', '', '1.421889523591e+00'],
['1.222309392724e+00', '', '1.050742850800e+00', '', '9.032578372386e-01', '', '7.764742057598e-01', '', '6.674862562538e-01'],
['5.737961402745e-01', '', '4.932566139141e-01', '', '3.133421372728e-01', '', '2.315524554696e-01', '', '1.990511474577e-01'],
['1.711118080085e-01', '', '1.470941072881e-01', '', '1.264475938317e-01', '', '1.086990789815e-01', '', '9.344179207682e-02'],
['8.032605785014e-02', '', '6.905128236880e-02', '', '5.935906385039e-02', '', '5.102727046220e-02']]
Output to file output.txt
4.163186002791e+04 3.578830331359e+04 3.076496349687e+04 2.644671278966e+04 2.273458304119e+04
1.954349752908e+04 1.680032112209e+04 1.444218412726e+04 1.241504140604e+04 1.067243373686e+04
9.174423035938e+03 7.886677033340e+03 6.779682426302e+03 5.828068476394e+03 5.010025548360e+03
1.737988920100e+03 1.284332855871e+03 1.104060538508e+03 8.158747205330e+02 7.013564117662e+02
6.029121922103e+02 5.182858606802e+02 4.455379022877e+02 2.433020871700e+02 2.091515701348e+02
1.797945089525e+02 1.545580816278e+02 1.328639052196e+02 9.818329499070e+01 7.255514128762e+01
5.361653963401e+01 4.609078195788e+01 3.962135930423e+01 3.406000172766e+01 2.927925083995e+01
2.516953864546e+01 2.163667639887e+01 1.859969593339e+01 1.598899398582e+01 1.374473698894e+01
1.181548977143e+01 1.015703673713e+01 8.731368506527e+00 7.505810795983e+00 6.452275569743e+00
5.546617302183e+00 4.768079596776e+00 4.098819479081e+00 3.523498461194e+00 3.028931005477e+00
2.603782330822e+00 2.238308635635e+00 1.924133783786e+00 1.654057335509e+00 1.421889523591e+00
1.222309392724e+00 1.050742850800e+00 9.032578372386e-01 7.764742057598e-01 6.674862562538e-01
5.737961402745e-01 4.932566139141e-01 3.133421372728e-01 2.315524554696e-01 1.990511474577e-01
1.711118080085e-01 1.470941072881e-01 1.264475938317e-01 1.086990789815e-01 9.344179207682e-02
8.032605785014e-02 6.905128236880e-02 5.935906385039e-02 5.102727046220e-02
My Input Values I used
SKIP (for line 1 ... removed 45 Lines for better readablity
SKIP to line 47)
4.163186002791e+04 3.578830331359e+04 3.076496349687e+04 2.644671278966e+04 2.273458304119e+04
1.954349752908e+04 1.680032112209e+04 1.444218412726e+04 1.241504140604e+04 1.067243373686e+04
9.174423035938e+03 7.886677033340e+03 6.779682426302e+03 5.828068476394e+03 5.010025548360e+03
1.737988920100e+03 1.284332855871e+03 1.104060538508e+03 8.158747205330e+02 7.013564117662e+02
6.029121922103e+02 5.182858606802e+02 4.455379022877e+02 2.433020871700e+02 2.091515701348e+02
1.797945089525e+02 1.545580816278e+02 1.328639052196e+02 9.818329499070e+01 7.255514128762e+01
5.361653963401e+01 4.609078195788e+01 3.962135930423e+01 3.406000172766e+01 2.927925083995e+01
2.516953864546e+01 2.163667639887e+01 1.859969593339e+01 1.598899398582e+01 1.374473698894e+01
1.181548977143e+01 1.015703673713e+01 8.731368506527e+00 7.505810795983e+00 6.452275569743e+00
5.546617302183e+00 4.768079596776e+00 4.098819479081e+00 3.523498461194e+00 3.028931005477e+00
2.603782330822e+00 2.238308635635e+00 1.924133783786e+00 1.654057335509e+00 1.421889523591e+00
1.222309392724e+00 1.050742850800e+00 9.032578372386e-01 7.764742057598e-01 6.674862562538e-01
5.737961402745e-01 4.932566139141e-01 3.133421372728e-01 2.315524554696e-01 1.990511474577e-01
1.711118080085e-01 1.470941072881e-01 1.264475938317e-01 1.086990789815e-01 9.344179207682e-02
8.032605785014e-02 6.905128236880e-02 5.935906385039e-02 5.102727046220e-02
give a chance to linecache. and in case of large files, try generators.
import linecache
from sys import argv
def get_specific_lines(f, start, stop):
for i in range(start, stop):
yield linecache.getline(f, i)
script, f, s, e = argv
# check code if (f)ile exists, (s)tart and (e)nd are numeric.
for line in get_specific_lines(f, int(s), int(e)):
print line
$ wc -l asbc.txt
197310 asbc.txt
$ python read.py asbc.txt 144322 144325
Bu yarım dəqiqə ərzində Qleb qabaqcadan dəqiq hesablanmış ləng hərəkətlə əlini qəbulediciyə uzatdı, diktora xırıldamağa imkan vermədən boynunu bururmuş kimi açarın dəstəyini burdu.
Onun azca bundan əvvəlki canlı sifəti yorğun, bozumtul rəng almışdı.
Pryançikovun başı isə başqa problemə qarışmışdı. Hansı gücləndirici kaskadı qoymaq lazım olduğu haqda fikirləşə-fikirləşə o, qayğısız zümzümə edirdi:
I want to send a python list to my ladon service.
Consider the following python list
lst_col_title = [(1, 'Column1', 10, 'L'),(2, 'Column2', 15, 'L'),(3, 'Column3', 15, 'L'),(4, 'Column4', 10, 'L'),(5, 'Column5', 10, 'L')]
Is their any possible way to send this kind of list to ladon services using suds.
EDIT
Actually I want to send the following python variables to a ladon service using suds
str_report_name = 'OPENING BALANCE REPORT'
str_report_format = 'GENERAL'
lst_main_heading = [('<w><h><b><ds>NAME TRAVEL & TOURISM</ds></b></h></w>', 1), ('<p5><b> <b></p5>', 2), ('<b><p2>P.O BOX 3000, JEDDAH 12345, KSA, Phone: 02 6845455</p2></b>', 3), ('<b><p2>Email: info#nametravel.com, Fax: 02 6873455, C.R.No: </p2></b>', 4), ('', 5)]
lst_header = []
lst_report_header = [['', 'CREDIT NOTE', '', '<u><b><w>'], ['', '', '', ''], ['', 'No: RF/1', '', '<b>'], ['To, CASH KAAU (942)', '', 'Date: 01/01/2011', '<b>'], [' P.O. Box No. 3263,DOHA,QATAR', '', 'Code: C022 ', '<b>'], [' Tel: +91 9945 4561 45, Fax: +21 7894 7894', '', '', '<b>'], [' E-Mail: cashkaau123#gmail.com', '', '', '<b>'], ['', '', '', ''], ['Please note that we have CREDITED your account with following details.', '', '', '']]
lst_page_header = []
lst_footer = []
lst_page_footer = []
lst_report_footer = [['Two Thousand Two Hundred Seventeen Saudi Riyal Only ', '', '2217.00', '<b>'], ['', '', '', ''], ['Accountant', 'Created By:ADMIN', 'Manager', ''], ['', '', '', ''], ['Signature', '', '', '']]
lst_report_data = [('', '', '', '', ''), (1, '065-9778821549', 'ABOUNASEF/SEHAM KAMEL MRS', 'JED/CAI/JED', '2584.00'), ('', '', '<i>Less</i>: Cancellation Fee', '', '367.00'), ('', '', '', '', ''), ('', 'THIS IS TO CHECK THE NARRATION PRINTING THIS IS TO CHECK THE NARRATION PRINTING THIS IS TO CHECK THE NARR<i>', '', '', '')]
bln_show_column_heading = True
lst_col_title = [(1, 'Column1', 10, 'L'),(2, 'Column2', 15, 'L'),(3, 'Column3', 15, 'L'),(4, 'Column4', 10, 'L'),(5, 'Column5', 10, 'L')]
This is my ladon service
#ladonize(str,str,[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING], rtype=str)
def generate_pdf_print(self, str_report_name,str_report_format,lst_main_heading, lst_header, lst_report_header, lst_page_header, lst_footer, lst_report_footer, lst_page_footer, lst_report_data, bln_show_column_heading, lst_col_title, **args):
But [PORTABLE_STRING] will not do what I want.
As I am new to web services, I have no idea how to deal with thease type of complex python types.
UPDATE
I have created a new ladon type for
lst_col_title = [(1, 'Column1', 10, 'L'),(2, 'Column2', 15, 'L'),(3, 'Column3', 15, 'L'),(4, 'Column4', 10, 'L'),(5, 'Column5', 10, 'L')]
as:
class Table(LadonType):
slno = int
col_title = PORTABLE_STRING
col_size = int
col_align = PORTABLE_STRING
and modified the #ladonize as,
#ladonize(str,str,[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[PORTABLE_STRING],[ Table ], rtype=str)
Is this a right way?
It raises an error for me
' Server raised fault: '
classname: <class 'AccountEngine.Table'>
Dictionary expected for prime_dict got "<type 'unicode'>" of value "1"'
I believe this is what you are looking for. Essentially what you want to do is convert each of your tuples to a LadonType, then return a list of those types, similar to the listAlbums and listBands methods in that tutorial. Here's another tutorial on LadonTypes.
Ladon
from ladon.ladonizer import ladonize
from ladon.types.ladontype import LadonType
class Calculator(object):
class Table(LadonType):
slno = int
colTitle = str
colSize = int
colAlign = str
#ladonize([Table],rtype=int) #notice the [], around table that means the input will be a list of Table LadonTypes.
def setTables(self,tables):
return len(tables)
Suds
from suds.client import Client
client = Client('http://localhost:8888/Calculator/soap/description')
table = client.factory.create('Table')
table.slno = 1
table.colTitle = 'col1'
table.colSize = 10
table.colAlign = 'L'
table2 = client.factory.create('Table')
table2.slno = 2
table2.colTitle = 'col2'
table2.colSize = 15
table2.colAlign = 'L'
tableList = [table, table2]
print client.service.setTables(tableList)
I have solved this problem, by converting each list as string.
self.generate_pdf_file(str_report_name,
str_report_format,
str(lst_main_heading),
str(lst_header),
str(lst_report_header),
str(lst_page_header),
str(lst_footer),
str(lst_report_footer),
str(lst_page_footer),
str(lst_report_data),
bln_show_column_heading,
str(lst_col_title))
Now my #ladonize looks like:
#ladonize(str,str,str,str,str,str,str,str,str,str,str,str, rtype=str)
def generate_pdf_print(self, str_report_name,str_report_format,lst_main_heading, lst_header, lst_report_header, lst_page_header, lst_footer, lst_report_footer, lst_page_footer, lst_report_data, bln_show_column_heading, lst_col_title, **args):
And reverted those valuesusing eval as follows:
def generate_pdf_print(self,db,
str_report_name = 'OPENING BALANCE REPORT',
str_report_format = 'GENERAL',
lst_main_heading = [],
lst_header = [],
lst_report_header = [],
lst_page_header = [],
lst_footer = [],
lst_report_footer = [],
lst_page_footer = [],
lst_report_data = [],
bln_show_column_heading = True,
lst_col_title = [],
int_count_blocks_of_data_in_print = 1,
str_pdf_theme = 'Default'
):
lst_main_heading = eval(lst_main_heading)
lst_header = eval(lst_header)
lst_report_header = eval(lst_report_header)
lst_page_header = eval(lst_page_header)
lst_footer = eval(lst_footer)
lst_page_footer = eval(lst_page_footer)
lst_report_footer = eval(lst_report_footer)
lst_report_data = eval(lst_report_data)
bln_show_column_heading = True
lst_col_title = eval(lst_col_title)
It´s posiible send a list of LadonType objects.
Example:
class Mov(LadonType):
id = int
text = str
#ladonize([Mov], rtype=PORTABLE_STRING)
def ReceiveMovs(self, moves):
....
Client (ArrayOfxxx, where xxx is the object class name):
moves = client.factory.create("ArrayOfMov")
data1 = client.factory.create("Mov")
data1.id = 1
data1.text = "Test 1"
data2 = client.factory.create("Mov")
data2.id = 2
data2.text = "Test 2"
and the most important part in client:
moves["item"] = [data1, data2]
res = client.service.ReceiveMovs(moves=moves)
I hope this help!!
Apologies for my english.