Move the arguments module into cli/ and context_objects into utils

* Note: Python2 is not as intelligent at detecting false import loops as
  Python3.  context_objects.py cannot be added to cli/arguments because it
  would set up an import loop between cli/__init__.py,
  cli/arguments/context_objects.py, and context.py on Python2.

ci_complete
pull/50537/head
Toshio Kuratomi 6 years ago
parent ed8e60d804
commit 27c7d5bb01

@ -18,7 +18,7 @@ from abc import ABCMeta, abstractmethod
from ansible import constants as C
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleOptionsError, AnsibleError
from ansible.inventory.manager import InventoryManager
from ansible.module_utils.six import with_metaclass, string_types

@ -7,8 +7,8 @@ __metaclass__ = type
from ansible import constants as C
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli import CLI
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.module_utils._text import to_text

@ -26,8 +26,8 @@ import sys
from ansible import constants as C
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli import CLI
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.module_utils._text import to_native, to_text
from ansible.module_utils.parsing.convert_bool import boolean

@ -16,8 +16,8 @@ import ansible.plugins.loader as plugin_loader
from ansible import constants as C
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli import CLI
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.module_utils._text import to_native
from ansible.module_utils.common._collections_compat import Sequence

@ -16,8 +16,8 @@ from jinja2 import Environment, FileSystemLoader
import ansible.constants as C
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli import CLI
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.galaxy import Galaxy
from ansible.galaxy.api import GalaxyAPI

@ -10,8 +10,8 @@ from operator import attrgetter
from ansible import constants as C
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli import CLI
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.inventory.host import Host
from ansible.plugins.loader import vars_loader

@ -9,8 +9,8 @@ import os
import stat
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli import CLI
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.executor.playbook_executor import PlaybookExecutor
from ansible.playbook.block import Block

@ -16,8 +16,8 @@ import time
from ansible import constants as C
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli import CLI
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleOptionsError
from ansible.module_utils._text import to_native, to_text
from ansible.plugins.loader import module_loader

@ -10,8 +10,8 @@ import sys
from ansible import constants as C
from ansible import context
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli import CLI
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleOptionsError
from ansible.module_utils._text import to_text, to_bytes
from ansible.parsing.dataloader import DataLoader

@ -15,14 +15,18 @@ running the ansible command line tools.
These APIs are still in flux so do not use them unless you are willing to update them with every Ansible release
"""
from ansible.arguments.context_objects import CLIArgs, GlobalCLIArgs
from ansible.utils.context_objects import CLIArgs, GlobalCLIArgs
__all__ = ('CLIARGS',)
# Note: this is not the singleton version. The Singleton is only created once the program has
# actually parsed the args
CLIARGS = CLIArgs({})
# This should be called immediately after cli_args are processed (parsed, validated, and any
# normalization performed on them). No other code should call it
def _init_global_context(cli_args):
"""Initialize the global context objects"""
global CLIARGS

@ -1,4 +1,4 @@
# Copyright: (c) 2018, Toshio Kuratomi <tkuratomi@ansible.com>
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# Make coding more python3-ish

@ -8,7 +8,7 @@ __metaclass__ = type
import pytest
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli.arguments import optparse_helpers as opt_help
class TestOptparseHelpersVersion:

@ -27,13 +27,13 @@ import tempfile
import yaml
from ansible import context
from ansible.arguments import context_objects as co
from ansible.arguments import optparse_helpers as opt_help
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.cli.galaxy import GalaxyCLI
from units.compat import unittest
from units.compat.mock import call, patch
from ansible.errors import AnsibleError, AnsibleOptionsError
from ansible.module_utils.six import PY3
from ansible.utils import context_objects as co
from units.compat import unittest
from units.compat.mock import call, patch
class TestGalaxy(unittest.TestCase):

@ -22,10 +22,10 @@ __metaclass__ = type
from units.compat import unittest
from units.compat.mock import MagicMock
from ansible.arguments import context_objects as co
from ansible.executor.playbook_executor import PlaybookExecutor
from ansible.playbook import Playbook
from ansible.template import Templar
from ansible.utils import context_objects as co
from units.mock.loader import DictDataLoader

@ -22,10 +22,10 @@ from units.compat import unittest
from units.compat.mock import MagicMock
from ansible import context
from ansible.arguments import context_objects as co
from ansible.executor.task_queue_manager import TaskQueueManager
from ansible.playbook import Playbook
from ansible.plugins.callback import CallbackBase
from ansible.utils import context_objects as co
__metaclass__ = type

@ -13,12 +13,12 @@ import pytest
from ansible import constants as C
from ansible import context
from ansible.arguments import context_objects as co
from ansible.arguments import optparse_helpers as opt_help
from units.compat import unittest
from ansible.cli.arguments import optparse_helpers as opt_help
from ansible.errors import AnsibleError, AnsibleParserError
from ansible.module_utils.six.moves import shlex_quote
from ansible.playbook.play_context import PlayContext
from ansible.utils import context_objects as co
from units.compat import unittest
from units.mock.loader import DictDataLoader

@ -15,8 +15,8 @@ import optparse
import pytest
from ansible.arguments import context_objects as co
from ansible.module_utils.common.collections import ImmutableDict
from ansible.utils import context_objects as co
MAKE_IMMUTABLE_DATA = ((u'くらとみ', u'くらとみ'),
Loading…
Cancel
Save