Jan. 31st, 2012

nonethefewer: (Default)
I am not good at recursion.  *sadface*

I am writing a Python script to translate a TestLink export into something better.  A common TestLink structure:

[folder] Navigation
  [folder] Customer
    [case#] Edit profile
    [case#] Upload photo
  [folder] Admin
    [folder] System
      [case#] Change theme
      [case#] Edit employees
    [folder] Calendar
      [case#] Add appointment
  [case#] Drop-down menu animations


A case has prerequisites, steps, and expected (that I care about).  So I want a Python script to pull that out of each case, while preserving the original structure.  The problem is, I have never been good at grokking recursion, even before one got into Python.  I mean, I can sort of see, but "sort of see" and "accurately code" are worlds apart.

For a folder and case, it needs to make a section tag, set the name to the name of the folder, then create the case and append it to the folder.  If it's at the base of the folder (the drop-down item, above), it needs to go in the "All Cases" section.

And there might be multiple top-level cases... at least they're all at the bottom.

So I'd want to:

main:

* open the XML file
* run dosection
* put the whole shebang into a file

dosection:

* keep the name of the thing it's to be added to (e.g., "Admin", "root")
* create a section (e.g., "System", "All Cases") and name it appropriately
* for each case-or-section underneath:
** if there's a new section in there, start this again
** otherwise, run the makecase function
* append the thing to the original section bit

makecase:

* carry along the name of the section it's to be added to (e.g., "System", "All Cases")
* create the prereq node; add data; add to section
* create the summary node; add data; add to section
* create the expected node; add data; add to section
* return to dosection

...maybe?
Page generated Jul. 20th, 2025 01:45 pm
Powered by Dreamwidth Studios