| Summary: | python code generation not independent of diagram view | ||
|---|---|---|---|
| Product: | [Applications] umbrello | Reporter: | Egbert Voigt <Egbert.Voigt> |
| Component: | general | Assignee: | Umbrello Development Group <umbrello-devel> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | openSUSE | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Egbert Voigt
2006-08-03 17:28:29 UTC
SVN commit 569409 by okellogg: writeClass(): Patch from Egbert Voigt adds missing imports for superclasses. BUG:131790 M +7 -0 ChangeLog M +22 -7 umbrello/codegenerators/pythonwriter.cpp --- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #569408:569409 @@ -1,3 +1,10 @@ +Version 1.5.5 + +* Bugs/wishes from http://bugs.kde.org: +* Java import - importing interfaces - absent visibility treated as package + instead of public (131327) +* Python code generation not independent of diagram view (131790) + Version 1.5.4 * Bugs/wishes from http://bugs.kde.org: --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codegenerators/pythonwriter.cpp #569408:569409 @@ -87,7 +87,23 @@ h<<str<<m_endl; } - + // generate import statement for superclasses and take packages into account + str = cleanName(c->getName()); + QString pkg = cleanName(c->getPackage()); + if (!pkg.isEmpty()) + str.prepend(pkg + "."); + QStringList includesList = QStringList(str); //save imported classes + int i = superclasses.count(); + for (UMLClassifier *classifier = superclasses.first(); + classifier && i; classifier = superclasses.next(), i--) { + str = cleanName(classifier->getName()); + pkg = cleanName(classifier->getPackage()); + if (!pkg.isEmpty()) + str.prepend(pkg + "."); + includesList.append(str); + h << "from " + str + " import *" << m_endl; + } + //write includes and take namespaces into account UMLClassifierList includes; findObjectsRelated(c,includes); @@ -99,16 +115,15 @@ 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; + str = headerName.replace(QChar('/'),QChar('.')); + if (includesList.findIndex(str) < 0) // not yet imported + h << "from " << str << " import *" << m_endl; } } h<<m_endl; - h<<"class "<<classname<<(superclasses.count() > 0 ? " (":""); - int i = superclasses.count(); + h << "class " << classname << (superclasses.count() > 0 ? " (" : "(object)"); + i = superclasses.count(); for (UMLClassifier *obj = superclasses.first(); obj && i; obj = superclasses.next(), i--) { |