[Uml-devel] [Bug 131790] New: python code generation not independent of diagram view

Egbert Voigt Egbert.Voigt at alcatel.de
Thu Aug 3 15:28:30 UTC 2006


------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=131790         
           Summary: python code generation not independent of diagram view
           Product: umbrello
           Version: unspecified
          Platform: SuSE RPMs
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: umbrello-devel.kde.org
        ReportedBy: Egbert.Voigt alcatel de


Version:           1.5.3 (using KDE KDE 3.5.1)
Installed from:    SuSE RPMs
Compiler:          gcc 4.1.0 
OS:                Linux

Precondition

 Two diagrams,
  - the first shows a package P1 and a class C1 inside this package
  - the second diagram contains a class C2 as a subclass of C1

Bug

 In case of making python code generation viewing the first diagram the result of class C2 is
 "class C2 (C1):", missing the include statement for class C1.

 The same generation gives a different output when viewing diagram two. Here is the result correct, i.e.
 "from P1.C1 import *

  class C2 (C1):"

The following patch solves this problem and allows also the usage of the new-style objects (introduced with Python 2.2), simply using "object" as base class.

cd umbrello-1.5.3/umbrello/umbrello/codegenerators
diff pythonwriter.cpp pythonwriter.cpp_new
91a92,109
>     // generate import statement for superclasses and take packages into account
>     int i = superclasses.count();
>     if (cleanName(c->getPackage()) == "")
>         str = cleanName(c->getName());
>     else
>         str = cleanName(c->getPackage())+"." +cleanName(c->getName());
>     QStringList includesList  = QStringList(str); //save imported classes
>     for(UMLClassifier *classifier = superclasses.first();
>             classifier && i; classifier = superclasses.next(), i--) {
>         if (cleanName(classifier->getPackage()) == "")
>             str = cleanName(classifier->getName());
>         else
>             str = cleanName(classifier->getPackage())+ "." +cleanName(classifier->getName());
>         includesList.append(str);
>         h<<"from "+str +" import *" <<m_endl;
>     }
>
>
99,106c117,123
<             first = headerName.at(0);
<             first = first.upper();
<             headerName = headerName.replace(0, 1, first);
<             if (headerName.find('/') > 0)
<                 h<<"from "<<headerName.replace(QChar('/'),QChar('.'))<<" import *"<<m_endl;
<             else
<                 h<<"from "<<headerName<<" import *"<<m_endl;
<         }
---
>           first = headerName.at(0);
>           first = first.upper();
>           headerName = headerName.replace(0, 1, first);
>           str = headerName.replace(QChar('/'),QChar('.'));
>           if (includesList.findIndex(str) <0) //not yet imported
>               h<<"from "<< str <<" import *"<<m_endl;
>       }
110,111c127,129
<     h<<"class "<<classname<<(superclasses.count() > 0 ? " (":"");
<     int i = superclasses.count();
---
>
>     h<<"class "<<classname<<(superclasses.count() > 0 ? " (":"(object)");
>     i = superclasses.count();




More information about the umbrello-devel mailing list