def OnImport( self, event ): from generate_code.gen_yuml import PySourceAsYuml import urllib dlg = wx.FileDialog(parent=self, message="choose", defaultDir='.', defaultFile="", wildcard="*.py", style=wx.OPEN|wx.MULTIPLE, pos=wx.DefaultPosition) if dlg.ShowModal() == wx.ID_OK: filenames = dlg.GetPaths() print 'Importing...' wx.BeginBusyCursor(cursor=wx.HOURGLASS_CURSOR) print filenames files=filenames p = PySourceAsYuml() p.optionModuleAsClass = 0 p.verbose = 0 if files: for f in files: p.Parse(f) p.CalcYumls() print p #yuml_txt = "[Customer]+1->*[Order],[Order]++1-items >*[LineItem],[Order]-0..1>[PaymentMethod]" yuml_txt = ','.join(str(p).split()) baseUrl = 'http://yuml.me/diagram/dir:lr;scruffy/class/' url = baseUrl + urllib.quote(yuml_txt) self.yuml.ViewImage(url=url) wx.EndBusyCursor() print 'Import - Done.'
class TestCaseYuml01(unittest.TestCase): def setUp(self): self.p = PySourceAsYuml() def _dump(self, p, expected): print() print("_" * 80 + " yUML CALCULATED:") print(str(p).strip()) print("-" * 80 + " yUML EXPECTED:") print(expected) print("_" * 80 + " yUML END DUMP") def test01ParseMeTestUnoptimised(self): FILE = PYTHON_CODE_EXAMPLES_TO_PARSE + "testmodule01.py" self.p.Parse(FILE) self.p.CalcYumls(optimise=False) expected = """ [ParseMeTest]b-.->[Blah] [ParseMeTest]f++-*[Blah] [ParseMeTest|a;b;d;e;e2;f|__init__();IsInBattle();DoA()] [ParseMeTest]^[ParseMeTest2|_secretinfo|DoB()] """.strip() # self._dump(self.p, expected) self.assertEqual(expected, str(self.p).strip()) def test02ParseMeTestOptimised(self): FILE = PYTHON_CODE_EXAMPLES_TO_PARSE + "testmodule01.py" self.p.Parse(FILE) self.p.CalcYumls(optimise=True) expected = """ [ParseMeTest|a;b;d;e;e2;f|__init__();IsInBattle();DoA()]b-.->[Blah] [ParseMeTest]f++-*[Blah] [ParseMeTest]^[ParseMeTest2|_secretinfo|DoB()] """.strip() # self._dump(self.p, expected) self.assertEqual(expected, str(self.p).strip()) def test01FlagUnoptimised(self): FILE = PYTHON_CODE_EXAMPLES_TO_PARSE + "testmodule66.py" self.p.Parse(FILE) self.p.CalcYumls(optimise=False) expected = """ [Flags]flags++-*[Flag] [Flags|flags;numberOfFlags|__init__();readFlags();AddFlag();__repr__()] [Flag|flagx;flagy;owner|__init__();readflag();__repr__()] """.strip() # self._dump(self.p, expected) self.assertEqual(expected, str(self.p).strip()) def test02FlagOptimised(self): FILE = PYTHON_CODE_EXAMPLES_TO_PARSE + "testmodule66.py" self.p.Parse(FILE) self.p.CalcYumls(optimise=True) expected = """ [Flags|flags;numberOfFlags|__init__();readFlags();AddFlag();__repr__()]flags++-*[Flag|flagx;flagy;owner|__init__();readflag();__repr__()] """.strip() # self._dump(self.p, expected) self.assertEqual(expected, str(self.p).strip())
def OnImport(self, event): from generate_code.gen_yuml import PySourceAsYuml import urllib dlg = wx.FileDialog(parent=self, message="choose", defaultDir='.', defaultFile="", wildcard="*.py", style=wx.OPEN | wx.MULTIPLE, pos=wx.DefaultPosition) if dlg.ShowModal() == wx.ID_OK: filenames = dlg.GetPaths() print 'Importing...' wx.BeginBusyCursor(cursor=wx.HOURGLASS_CURSOR) print filenames files = filenames p = PySourceAsYuml() p.optionModuleAsClass = 0 p.verbose = 0 if files: for f in files: p.Parse(f) p.CalcYumls() print p #yuml_txt = "[Customer]+1->*[Order],[Order]++1-items >*[LineItem],[Order]-0..1>[PaymentMethod]" yuml_txt = ','.join(str(p).split()) baseUrl = 'http://yuml.me/diagram/dir:lr;scruffy/class/' url = baseUrl + urllib.quote(yuml_txt) self.yuml.ViewImage(url=url) wx.EndBusyCursor() print 'Import - Done.'
def setUp(self): self.p = PySourceAsYuml()