[Erp5-report] r37960 gabriel - in /erp5/trunk/utils/cloudooo/cloudooo: ./ tests/

nobody at svn.erp5.org nobody at svn.erp5.org
Tue Aug 24 01:03:42 CEST 2010


Author: gabriel
Date: Tue Aug 24 01:03:41 2010
New Revision: 37960

URL: http://svn.erp5.org?rev=37960&view=rev
Log:
add function to extract the module name from pkg_resources. This function will be used to call the scripts unoconverter and unomimemapper without know your full path

Modified:
    erp5/trunk/utils/cloudooo/cloudooo/tests/testUtils.py
    erp5/trunk/utils/cloudooo/cloudooo/utils.py

Modified: erp5/trunk/utils/cloudooo/cloudooo/tests/testUtils.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/tests/testUtils.py?rev=37960&r1=37959&r2=37960&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/tests/testUtils.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/tests/testUtils.py [utf8] Tue Aug 24 01:03:41 2010
@@ -28,7 +28,8 @@
 
 import unittest
 import logging
-from cloudooo.utils import logger, configureLogger, convertStringToBool
+from cloudooo.utils import logger, configureLogger, convertStringToBool, \
+		extractModuleName
 from cloudoooTestCase import make_suite
 
 class TestUtils(unittest.TestCase):
@@ -51,6 +52,13 @@ class TestUtils(unittest.TestCase):
     self.assertEquals(convertStringToBool('faLse'), False)
     self.assertEquals(convertStringToBool(''), None)
 
+  def testExtractModuleName(self):
+    """Test if the module name resturns correctly"""
+    self.assertEquals(extractModuleName("unoconverter"),
+		    "cloudooo.bin.unoconverter")
+    self.assertEquals(extractModuleName("unomimemapper"),
+		    "cloudooo.bin.unomimemapper")
+
 def test_suite():
   return make_suite(TestUtils)
 

Modified: erp5/trunk/utils/cloudooo/cloudooo/utils.py
URL: http://svn.erp5.org/erp5/trunk/utils/cloudooo/cloudooo/utils.py?rev=37960&r1=37959&r2=37960&view=diff
==============================================================================
--- erp5/trunk/utils/cloudooo/cloudooo/utils.py [utf8] (original)
+++ erp5/trunk/utils/cloudooo/cloudooo/utils.py [utf8] Tue Aug 24 01:03:41 2010
@@ -122,3 +122,13 @@ def convertStringToBool(string):
     return False
   else:
     return None
+
+def extractModuleName(script_name):
+  """it extracts the module name from pkg_resources
+  """
+  import pkg_resources
+  resources = pkg_resources.get_distribution("cloudooo")
+  console_script_list = resources.get_entry_map()['console_scripts']
+  return console_script_list[script_name].module_name
+
+




More information about the Erp5-report mailing list