ebroecker / pyreqif

should be a python implementation of reqif-format (import/export)
BSD 2-Clause "Simplified" License
32 stars 15 forks source link

Hierarchy #9

Closed laurentcabot closed 4 years ago

laurentcabot commented 4 years ago

That's a nice module and it works fine. Anyway the requirements hierarchy is lost. All items are at the same level. Is there any way to keep the ReqIf hierarchy ?

laurentcabot commented 4 years ago

... perhaps with Excel line grouping. There is a relation class in the ReqIf described in the ReqIf Standard.

ebroecker commented 4 years ago

well .. the hierarchy is in the python data model, only the excel-exporter does not make use of it. If you look at example.py, an ascii export is done which respects the hierarchy.

laurentcabot commented 4 years ago

Hum... I'm going to have a look. I know: rebuilding the hierarchy in Excel is not so obvious. Anyway, thanks for feedback.

ebroecker commented 4 years ago

I'm gonna look if i find some idea for excel

ebroecker commented 4 years ago

Please try branch iss9: pip install git+https://github.com/ebroecker/pyreqif@iss9

laurentcabot commented 4 years ago

Thanks
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2219' in position 0: ordinal not in range(128)
in xlsx.py line 34.....

ebroecker commented 4 years ago

@laurentcabot

could you try again?

laurentcabot commented 4 years ago

The ReqIf to Excel works fine now, with respect to the hierarchy. Good job! A nice feature also would be to keep the pictures / attachments that are included in the ReqIf file.

ebroecker commented 4 years ago

I did some investigation, but did not manage yet to write OLE-Objects in excel with xlsxwriter or openpyxl yet.

So the original issue can be closed now?

laurentcabot commented 4 years ago

Yes, you can close it. Thanks a lot!

ebroecker commented 4 years ago

well - added some image support also

laurentcabot commented 4 years ago

Checking....

laurentcabot commented 4 years ago

The result is globally correct (only the cell high which is not ajusted to the image). However there is one concern in case of multiple images in the same requirement: only the first one is present. Regarding the cells format (in general), should be top alignment with automatic wrap lines (that's a minor issue!)

ebroecker commented 4 years ago

@laurentcabot I fixed some of your wishes. Not sure if multiple images work, because the lack of such an input document.

laurentcabot commented 4 years ago

Thanks a lot ! I will try this on monday. I can prepare some ReqIf test files if you need (we use ReqIf Studio)

laurentcabot commented 4 years ago

Thanks a lot ! I will try this on monday. I can prepare some ReqIf test files if you need (we use ReqIf Studio)

laurentcabot commented 4 years ago

Crashes:

laurentcabot commented 4 years ago
write_excel_line    C:\HZK1ZQ\JOB\DEV\SW\ReqIf_to_XlsxHtml\pyreqif\xlsx.py  47      

TypeError: 'NoneType' object is not callable

ebroecker commented 4 years ago

OK, I wrote some workaround: https://github.com/ebroecker/pyreqif/commit/a1dc80cb3a24c37340ef05bc9ce576213d534ae4

just try branch iss9 again

laurentcabot commented 4 years ago

generates "Error with image: xxxx" in xlsx.py. I've modified as follows:

                try:
                    im = Image.open(file)

                    _, height = im.size
                    max_height = max(height, max_height)
                    worksheet.set_row(row, max_height, None, {'level': depth})
                    im.close()
                except:
                    print("Error with image: {}".format(file))

Still hangup with im.close() but generates a xlsx file with correct cells sizes.

Edit: enabled python syntax highlighting

laurentcabot commented 4 years ago

Several images in the same article are still superimposed

ebroecker commented 4 years ago

Do you get Error with image .. outputs? Is so, are these the images, where the height is not correct?

Sorry, did not read your first post.... I guess the Image.open cannot handle your images, what format do they have?

maybe try:

                try:
                    im = Image.open(file)
                    im.close()
                    _, height = im.size
                    max_height = max(height, max_height)
                    worksheet.set_row(row, max_height, None, {'level': depth})
                except:
                    print("Error with image: {}".format(file))
                    worksheet.set_row(row, 300, None, {'level': depth})
                    max_height = max(max_height, 300)

to set row height to 300 if no height could be extracted from image

laurentcabot commented 4 years ago

images are correctly opened (they are png). in step by step mode, the script hangs up at the im.close() OK. I try your patch

laurentcabot commented 4 years ago

same error message, but does not crash. the Excel file is correct except for superimposed messages

laurentcabot commented 4 years ago

The PB is clearly at the "im.close()"

ebroecker commented 4 years ago

ok, maybe the im.close is wrong anyway. Do you see a height?

does this happen, if there are multiple pictures in one row?

The close won't be necessary, but the height would be good for not superimposed images.

Maybe you could create a minimal example with superimposed images for testing at my side...

laurentcabot commented 4 years ago

Yes the heigh is correct. It happens in any case (single or multiple image) Yes I'm going to create a sample file.

laurentcabot commented 4 years ago

Here it is: Test3.zip The file is downloadable from ReqIf Academy. I've added a multiple image item at the beginning.

ebroecker commented 4 years ago

With the patch above - Test3 seems to work without im.close exception

laurentcabot commented 4 years ago

Hum... Not so good. No error message but no image at all

ebroecker commented 4 years ago

Your Document or Test3 document?

laurentcabot commented 4 years ago

My document. I'm checking with the test3

laurentcabot commented 4 years ago

Same behavior: no image at all chapter3.xlsx

ebroecker commented 4 years ago

ok, this is strange. My one looks like: chapter3.xlsx

C:\local\pyreqif\reqif2xlsx.py C:\local\pyreqif\someFolder\chapter3.reqif C:\local\pyreqif\chapter3.xlsx

laurentcabot commented 4 years ago

Which is correct except the superimposed image.. You have updated iss9 ?

ebroecker commented 4 years ago

where do you have a superimposed image?

grafik

laurentcabot commented 4 years ago

In line 4, you have two different images, superimposed.

laurentcabot commented 4 years ago

Anyway, it seems we have different behaviors. Mine never stops in xslx lines 30 and 32. Therefore, no image.

laurentcabot commented 4 years ago

Priblem at line rtfFilename = urllib.parse.unquote(rtfFilename) and then goes to except.

ebroecker commented 4 years ago

chapter3.xlsx ok, did not see this - now multiple pictures in one cell are one above the other...

laurentcabot commented 4 years ago

Congratulations ! This works perfectly. However I have commented the im.close() at line 56, otherwise it crashes on this im.close(). I do not understand why. That's a very valuable script. Thanks a lot for this ReqIf to Excel. I did enjoy to cooperate with you. Perhaps an excel to ReqIf ? Sounds feasable. Challenging.

ebroecker commented 4 years ago

.... well reading images from excel is not easy - at least with the usual python libs ... The other things might definitively be possible

ebroecker commented 4 years ago

... @laurentcabot

some attempt for xlsx to reqif is done in branch: xlsx_to_reqif

laurentcabot commented 4 years ago

OK. Trying....