freeipa

FreeIPA is an integrated Identity and Authentication solution for Linux/UNIX networked environments.  |  http://www.freeipa.org/

Commit 8f98fa1 Replace ipaplatform's symlinks with a meta importer

6 files Authored by cheimes 2 years ago , Committed by dkupka 2 years ago ,
Replace ipaplatform's symlinks with a meta importer

Signed-off-by: Christian Heimes <cheimes@redhat.com>
Reviewed-By: Petr Spacek <pspacek@redhat.com>

    
1 @@ -77,7 +77,3 @@
2   
3   /ipaplatform/__init__.py
4   /ipaplatform/setup.py
5 - /ipaplatform/tasks.py
6 - /ipaplatform/services.py
7 - /ipaplatform/paths.py
8 - /ipaplatform/constants.py
 1 @@ -197,11 +197,6 @@
 2   »       if [ "$(SUPPORTED_PLATFORM)" != "" ]; then \
 3   »       »       sed -e s/__PLATFORM__/$(SUPPORTED_PLATFORM)/ \
 4   »       »       »       ipaplatform/__init__.py.in > ipaplatform/__init__.py; \
 5 - »       »       rm -f ipaplatform/paths.py ipaplatform/services.py ipaplatform/tasks.py ipaplatform/constants.py; \
 6 - »       »       ln -s $(SUPPORTED_PLATFORM)/paths.py ipaplatform/paths.py; \
 7 - »       »       ln -s $(SUPPORTED_PLATFORM)/services.py ipaplatform/services.py; \
 8 - »       »       ln -s $(SUPPORTED_PLATFORM)/tasks.py ipaplatform/tasks.py; \
 9 - »       »       ln -s $(SUPPORTED_PLATFORM)/constants.py ipaplatform/constants.py; \
10   »       fi
11   
12   »       if [ "$(SKIP_API_VERSION_CHECK)" != "yes" ]; then \
 1 @@ -1,12 +1,20 @@
 2   #
 3   # Copyright (C) 2015  FreeIPA Contributors see COPYING for license
 4   #
 5 + """Module containing platform-specific functionality.
 6 + 
 7 + ipaplatform.constants
 8 + ipaplatform.paths
 9 + ipaplatform.services
10 + ipaplatform.tasks
11 + """
12 + import os
13   
14 - '''
15 - Module containing platform-specific functionality for every platform.
16 - '''
17   
18   NAME = "__PLATFORM__"
19   
20 - # FIXME: too much cyclic dependencies
21 - # from __PLATFORM__ import paths, tasks, services
22 + # Create an alias for platform specific modulues, e.g.
23 + # 'import ipaplatform.paths' loads 'ipaplatform/NAME/paths.py'.
24 + 
25 + __path__.append(
26 +     os.path.join(os.path.dirname(os.path.abspath(__file__)), NAME))
 1 @@ -483,7 +483,10 @@
 2   
 3   # Objects below are expected to be exported by platform module
 4   
 5 - service = None
 6 + def base_service_class_factory(name):
 7 +     raise NotImplementedError
 8 + 
 9 + service = base_service_class_factory
10   knownservices = None
11   
12   # System may support more time&date services. FreeIPA supports ntpd only, other
1 @@ -58,7 +58,7 @@
2   import pysss_nss_idmap
3   import pysss
4   import six
5 - from ipaplatform.paths import paths
6 + from ipaplatform.paths import paths  # pylint: disable=import-error
7   
8   from ldap.filter import escape_filter_chars
9   from time import sleep
 1 @@ -6,9 +6,11 @@
 2   
 3   import copy
 4   import sys
 5 + import textwrap
 6   
 7 - from astroid import MANAGER
 8 + from astroid import MANAGER, register_module_extender
 9   from astroid import scoped_nodes
10 + from astroid.builder import AstroidBuilder
11   
12   
13   def register(linter):
14 @@ -255,3 +257,19 @@
15           fake_class(cls, ipa_class_members[class_name_with_module])
16   
17   MANAGER.register_transform(scoped_nodes.Class, fix_ipa_classes)
18 + 
19 + 
20 + def ipaplatform_transform():
21 +     """Module aliases for IpaPlatformImporter
22 +     """
23 +     return AstroidBuilder(MANAGER).string_build(textwrap.dedent(
24 +         """
25 +         from ipaplatform.base import constants
26 +         from ipaplatform.base import paths
27 +         from ipaplatform.base import services
28 +         from ipaplatform.base import tasks
29 +         """
30 +     ))
31 + 
32 + 
33 + register_module_extender(MANAGER, 'ipaplatform', ipaplatform_transform)