Commit 77cada1a authored by Gabriel Monnerat's avatar Gabriel Monnerat

add function to extract the module name from pkg_resources. This function will...

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

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@37960 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ecc9f09e
......@@ -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)
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment