commit:     63808ef00f94ad31d4291ebf5048da9348caa659
Author:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
AuthorDate: Mon May  9 23:14:34 2016 +0000
Commit:     Devan Franchini <twitch153 <AT> gentoo <DOT> org>
CommitDate: Mon May  9 23:28:46 2016 +0000
URL:        https://gitweb.gentoo.org/proj/layman.git/commit/?id=63808ef0

Adds sourcefile var to inits for plug-in modules

X-Gentoo-Bug: 582154
X-Gentoo-Bug-URL: https://bugs.gentoo.org/582154

 layman/config_modules/makeconf/__init__.py    |  1 +
 layman/config_modules/reposconf/__init__.py   |  1 +
 layman/db_modules/json_db/__init__.py         |  1 +
 layman/db_modules/sqlite_db/__init__.py       |  1 +
 layman/db_modules/xml_db/__init__.py          |  1 +
 layman/module.py                              | 10 +++++++++-
 layman/overlays/modules/bzr/__init__.py       |  1 +
 layman/overlays/modules/cvs/__init__.py       |  1 +
 layman/overlays/modules/darcs/__init__.py     |  1 +
 layman/overlays/modules/g_sorcery/__init__.py |  1 +
 layman/overlays/modules/git/__init__.py       |  1 +
 layman/overlays/modules/mercurial/__init__.py |  1 +
 layman/overlays/modules/rsync/__init__.py     |  1 +
 layman/overlays/modules/squashfs/__init__.py  |  1 +
 layman/overlays/modules/stub/__init__.py      |  1 +
 layman/overlays/modules/svn/__init__.py       |  1 +
 layman/overlays/modules/tar/__init__.py       |  1 +
 17 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/layman/config_modules/makeconf/__init__.py 
b/layman/config_modules/makeconf/__init__.py
index c385960..bec0661 100644
--- a/layman/config_modules/makeconf/__init__.py
+++ b/layman/config_modules/makeconf/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'makeconf-module': {
             'name': 'makeconf',
             'class': 'ConfigHandler',
+            'sourcefile': 'makeconf',
             'description': __doc__,
             'functions': ['add', 'delete', 'disable', 'enable', 'read',
                           'update', 'write'],

diff --git a/layman/config_modules/reposconf/__init__.py 
b/layman/config_modules/reposconf/__init__.py
index f8f69bc..8528627 100644
--- a/layman/config_modules/reposconf/__init__.py
+++ b/layman/config_modules/reposconf/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'reposconf-module': {
             'name': 'reposconf',
             'class': 'ConfigHandler',
+            'sourcefile': 'reposconf',
             'description': __doc__,
             'functions': ['add', 'delete', 'disable', 'enable', 'read',
                           'update', 'write'],

diff --git a/layman/db_modules/json_db/__init__.py 
b/layman/db_modules/json_db/__init__.py
index ac4daa7..5b91e58 100644
--- a/layman/db_modules/json_db/__init__.py
+++ b/layman/db_modules/json_db/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'json-module': {
             'name': 'json_db',
             'class': 'DBHandler',
+            'sourcefile': 'json_db',
             'description': __doc__,
             'functions': ['add_new', 'read_db', 'remove', 'write'],
             'func_desc': {

diff --git a/layman/db_modules/sqlite_db/__init__.py 
b/layman/db_modules/sqlite_db/__init__.py
index 536fc2d..a3678dc 100644
--- a/layman/db_modules/sqlite_db/__init__.py
+++ b/layman/db_modules/sqlite_db/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'sqlite-module': {
             'name': 'sqlite_db',
             'class': 'DBHandler',
+            'sourcefile': 'sqlite_db',
             'description': __doc__,
             'functions': ['add_new', 'read_db', 'remove', 'write'],
             'func_desc': {

diff --git a/layman/db_modules/xml_db/__init__.py 
b/layman/db_modules/xml_db/__init__.py
index c8a5bf9..f4bd13c 100644
--- a/layman/db_modules/xml_db/__init__.py
+++ b/layman/db_modules/xml_db/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'xml-module': {
             'name': 'xml_db',
             'class': 'DBHandler',
+            'sourcefile': 'xml_db',
             'description': __doc__,
             'functions': ['add_new', 'read_db', 'remove', 'write'],
             'func_desc': {

diff --git a/layman/module.py b/layman/module.py
index 99d243b..08bcbc2 100644
--- a/layman/module.py
+++ b/layman/module.py
@@ -48,7 +48,15 @@ class Module(object):
         for submodule in self.module_spec['provides']:
             kid = self.module_spec['provides'][submodule]
             kidname = kid['name']
-            kid['module_name'] = '.'.join([mod_name, kidname])
+            try:
+                kid['module_name'] = '.'.join([mod_name, kidname])
+            except ImportError:
+                kid['module_name'] = '.'.join([mod_name, self.name])
+                f = self.__module.__file__
+                msg = 'Module.__initialize(); module spec is old, missing '\
+                      'attribute: \'sourcefile\'.\nBackward compatibility '\
+                      'may be removed in the future.\nFile: %(f)s' % {'f': f}
+                self.output.warn(msg)
             kid['is_imported'] = False
             self.kids[kidname] = kid
             self.kids_names.append(kidname)

diff --git a/layman/overlays/modules/bzr/__init__.py 
b/layman/overlays/modules/bzr/__init__.py
index e69cc6d..ef269b4 100644
--- a/layman/overlays/modules/bzr/__init__.py
+++ b/layman/overlays/modules/bzr/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'bzr-module': {
             'name': 'bzr',
             'class': 'BzrOverlay',
+            'sourcefile': 'bzr',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync', 'update'],
             'func_desc': {

diff --git a/layman/overlays/modules/cvs/__init__.py 
b/layman/overlays/modules/cvs/__init__.py
index f085919..f94dcd3 100644
--- a/layman/overlays/modules/cvs/__init__.py
+++ b/layman/overlays/modules/cvs/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'cvs-module': {
             'name': 'cvs',
             'class': 'CvsOverlay',
+            'sourcefile': 'cvs',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync', 'update'],
             'func_desc': {

diff --git a/layman/overlays/modules/darcs/__init__.py 
b/layman/overlays/modules/darcs/__init__.py
index be5d267..8c08b02 100644
--- a/layman/overlays/modules/darcs/__init__.py
+++ b/layman/overlays/modules/darcs/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'darcs-module': {
             'name': 'darcs',
             'class': 'DarcsOverlay',
+            'sourcefile': 'darcs',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync'],
             'func_desc': {

diff --git a/layman/overlays/modules/g_sorcery/__init__.py 
b/layman/overlays/modules/g_sorcery/__init__.py
index 2b3caf3..f726e92 100644
--- a/layman/overlays/modules/g_sorcery/__init__.py
+++ b/layman/overlays/modules/g_sorcery/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'g-sorcery-module': {
             'name': 'g-sorcery',
             'class': 'GSorceryOverlay',
+            'sourcefile': 'g_sorcery',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync'],
             'func_desc': {

diff --git a/layman/overlays/modules/git/__init__.py 
b/layman/overlays/modules/git/__init__.py
index 3a2d932..3e22087 100644
--- a/layman/overlays/modules/git/__init__.py
+++ b/layman/overlays/modules/git/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'git-module': {
             'name': 'git',
             'class': 'GitOverlay',
+            'sourcefile': 'git',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync', 'update'],
             'func_desc': {

diff --git a/layman/overlays/modules/mercurial/__init__.py 
b/layman/overlays/modules/mercurial/__init__.py
index 1999109..0959aa2 100644
--- a/layman/overlays/modules/mercurial/__init__.py
+++ b/layman/overlays/modules/mercurial/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'mercurial-module': {
             'name': 'mercurial',
             'class': 'MercurialOverlay',
+            'sourcefile': 'mercurial',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync', 'update'],
             'func_desc': {

diff --git a/layman/overlays/modules/rsync/__init__.py 
b/layman/overlays/modules/rsync/__init__.py
index 862f647..75b0597 100644
--- a/layman/overlays/modules/rsync/__init__.py
+++ b/layman/overlays/modules/rsync/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'rsync-module': {
             'name': 'rsync',
             'class': 'RsyncOverlay',
+            'sourcefile': 'rsync',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync'],
             'func_desc': {

diff --git a/layman/overlays/modules/squashfs/__init__.py 
b/layman/overlays/modules/squashfs/__init__.py
index 753fe21..e71c382 100644
--- a/layman/overlays/modules/squashfs/__init__.py
+++ b/layman/overlays/modules/squashfs/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'squashfs-module': {
             'name': 'squashfs',
             'class': 'SquashfsOverlay',
+            'sourcefile': 'squashfs',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync'],
             'func_desc': {

diff --git a/layman/overlays/modules/stub/__init__.py 
b/layman/overlays/modules/stub/__init__.py
index a124d6a..f1880e4 100644
--- a/layman/overlays/modules/stub/__init__.py
+++ b/layman/overlays/modules/stub/__init__.py
@@ -13,6 +13,7 @@ module_spec = {
             'name': 'stub',
             'class': 'StubOverlay',
             'description': __doc__,
+            'sourcefile': 'stub',
             'functions': ['add', 'supported', 'sync', 'update'],
             'func_desc': {
                 'add': 'Stub add function',

diff --git a/layman/overlays/modules/svn/__init__.py 
b/layman/overlays/modules/svn/__init__.py
index f7d72c7..3e1b7b6 100644
--- a/layman/overlays/modules/svn/__init__.py
+++ b/layman/overlays/modules/svn/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'svn-module': {
             'name': 'svn',
             'class': 'SvnOverlay',
+            'sourcefile': 'svn',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync', 'update'],
             'func_desc': {

diff --git a/layman/overlays/modules/tar/__init__.py 
b/layman/overlays/modules/tar/__init__.py
index c3a5ca8..177f590 100644
--- a/layman/overlays/modules/tar/__init__.py
+++ b/layman/overlays/modules/tar/__init__.py
@@ -12,6 +12,7 @@ module_spec = {
         'tar-module': {
             'name': 'tar',
             'class': 'TarOverlay',
+            'sourcefile': 'tar',
             'description': __doc__,
             'functions': ['add', 'supported', 'sync'],
             'func_desc': {

Reply via email to