|
E9211 Python Untranslatable Code
[Previous]  [Next] 
|
![]() |
User Manual [Previous]  [Next] E9211 Python Untranslatable CodeUntagged code cannot be translated to PythonCode written without a language tag in an action, an entry, exit or do activity, a code injection, a derived attribute or an initial value is Java. For Python, Umple translates such code when it keeps to the subset of Java listed on the Python page. Code outside that subset, for example a call to the Java library or to a method the model does not define, is reported with this error, which names the code and shows how that kind of code is written in Python. The class is then not generated. The error is also reported for a derived attribute written only for other languages, which would have no value in Python, and for an interface constant whose value is not a literal, which Umple does not translate to Python. Give the code a Python version: add a Python block beside the Java one, or move the code into a method with a Python body and call that method. Method bodies and extra code are never translated: an untagged method body is taken to be Python already. Example
// The default value calls the Java library, which cannot be
// translated to Python, so Python generation reports E9211
generate Python;
class Session {
String user = System.getProperty("user.name");
}
Load the above code into UmpleOnline Solution to The Above So the Message No Longer Appears
// The value comes from a method with a Java body and a
// Python body, so each language uses its own library
generate Python;
class Session {
String user = currentUser();
String currentUser() Java { return System.getProperty("user.name"); }
Python { import getpass; return getpass.getuser() }
}
Load the above code into UmpleOnline |