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
This commit is contained in:
Toshio Kuratomi 2018-12-20 10:07:49 -08:00
parent ed8e60d804
commit 27c7d5bb01
19 changed files with 26 additions and 22 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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):

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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'くらとみ'),