Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-392-Failing-to-load-ruamel.yaml 3d05ac506 -> d51cf9394 
(forced update)


ARIA-392 Failing to load ruamel.yaml


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/d51cf939
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/d51cf939
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/d51cf939

Branch: refs/heads/ARIA-392-Failing-to-load-ruamel.yaml
Commit: d51cf9394204a47cb86ab4d45060b0ad3dee2dd1
Parents: 19e95f7
Author: max-orlov <ma...@gigaspaces.com>
Authored: Mon Oct 23 15:58:14 2017 +0300
Committer: max-orlov <ma...@gigaspaces.com>
Committed: Wed Nov 8 23:08:03 2017 +0200

----------------------------------------------------------------------
 aria/__init__.py                                |  3 +-
 aria/cli/config/config.py                       |  3 +-
 aria/cli/csar.py                                |  2 +-
 aria/cli/inputs.py                              |  2 +-
 aria/modeling/types.py                          |  2 +-
 aria/parser/reading/yaml.py                     |  2 +-
 aria/utils/formatting.py                        |  3 +-
 aria/utils/yaml.py                              | 49 ++++++++++++++++++++
 .../simple_v1_0/modeling/__init__.py            |  3 +-
 9 files changed, 58 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/aria/__init__.py
----------------------------------------------------------------------
diff --git a/aria/__init__.py b/aria/__init__.py
index a059877..9bd6f8f 100644
--- a/aria/__init__.py
+++ b/aria/__init__.py
@@ -17,14 +17,13 @@
 The ARIA root package provides entry points for extension and storage 
initialization.
 """
 
-import sys
 
 from pkgutil import iter_modules
 import pkg_resources
-
 aria_package_name = 'apache-ariatosca'
 __version__ = pkg_resources.get_distribution(aria_package_name).version
 
+
 from .orchestrator.decorators import workflow, operation  # pylint: 
disable=wrong-import-position
 from . import (  # pylint: disable=wrong-import-position
     extension,

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/aria/cli/config/config.py
----------------------------------------------------------------------
diff --git a/aria/cli/config/config.py b/aria/cli/config/config.py
index bbece80..cba76cd 100644
--- a/aria/cli/config/config.py
+++ b/aria/cli/config/config.py
@@ -19,10 +19,11 @@ CLI configuration mechanism.
 
 import os
 import pkg_resources
-from ruamel import yaml
 
 from jinja2.environment import Template
 
+from ...utils.yaml.ruamel import yaml
+
 
 CONFIG_FILE_NAME = 'config.yaml'
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/aria/cli/csar.py
----------------------------------------------------------------------
diff --git a/aria/cli/csar.py b/aria/cli/csar.py
index 32a8eb1..1ef96c1 100644
--- a/aria/cli/csar.py
+++ b/aria/cli/csar.py
@@ -27,7 +27,7 @@ import tempfile
 import zipfile
 
 import requests
-from ruamel import yaml
+from ..utils.yaml.ruamel import yaml
 
 CSAR_FILE_EXTENSION = '.csar'
 META_FILE = 'TOSCA-Metadata/TOSCA.meta'

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/aria/cli/inputs.py
----------------------------------------------------------------------
diff --git a/aria/cli/inputs.py b/aria/cli/inputs.py
index 495dd5f..43744b0 100644
--- a/aria/cli/inputs.py
+++ b/aria/cli/inputs.py
@@ -19,7 +19,7 @@ Helpers for validating and coercing service template inputs.
 
 import os
 import glob
-from ruamel import yaml
+from ..utils.yaml.ruamel import yaml
 
 from .env import logger
 from .exceptions import AriaCliError

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/aria/modeling/types.py
----------------------------------------------------------------------
diff --git a/aria/modeling/types.py b/aria/modeling/types.py
index 38240fa..47752a4 100644
--- a/aria/modeling/types.py
+++ b/aria/modeling/types.py
@@ -26,7 +26,7 @@ from sqlalchemy import (
     event
 )
 from sqlalchemy.ext import mutable
-from ruamel import yaml
+from ..utils.yaml.ruamel import yaml
 
 from . import exceptions
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/aria/parser/reading/yaml.py
----------------------------------------------------------------------
diff --git a/aria/parser/reading/yaml.py b/aria/parser/reading/yaml.py
index f5eac43..4dab808 100644
--- a/aria/parser/reading/yaml.py
+++ b/aria/parser/reading/yaml.py
@@ -10,7 +10,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from ruamel import yaml # @UnresolvedImport
+from ...utils.yaml.ruamel import yaml # @UnresolvedImport
 
 from ...utils.collections import OrderedDict
 from .reader import Reader

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/aria/utils/formatting.py
----------------------------------------------------------------------
diff --git a/aria/utils/formatting.py b/aria/utils/formatting.py
index fa34b7d..af13667 100644
--- a/aria/utils/formatting.py
+++ b/aria/utils/formatting.py
@@ -20,8 +20,7 @@ String formatting and string-based format utilities.
 import json
 from types import MethodType
 
-from ruamel import yaml  # @UnresolvedImport
-
+from .yaml.ruamel import yaml  # @UnresolvedImport
 from .collections import FrozenList, FrozenDict, StrictList, StrictDict, 
OrderedDict
 
 

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/aria/utils/yaml.py
----------------------------------------------------------------------
diff --git a/aria/utils/yaml.py b/aria/utils/yaml.py
new file mode 100644
index 0000000..6605df8
--- /dev/null
+++ b/aria/utils/yaml.py
@@ -0,0 +1,49 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+"""
+The ARIA root package provides entry points for extension and storage 
initialization.
+"""
+
+import os
+import sys
+import types
+
+try:
+    import ruamel                                                              
 # pylint: disable=unused-import
+except ImportError:
+    if sys.version_info[0] > 2:
+        raise
+
+    # Traverse all of the site-packages and try to load ruamel.
+    for packages_dir in sys.path:
+        ruamel_path = os.path.join(packages_dir, 'ruamel')
+        if not os.path.exists(ruamel_path):
+            continue
+
+        # If the top dir has an __init__.py file, the loading should have
+        # succeeded automatically
+        if os.path.exists(os.path.join(ruamel_path, '__init__.py')):
+            raise
+
+        # Dynamically create mapping to the ruamel package
+        ruamel_module = sys.modules.setdefault(
+            'ruamel',
+            types.ModuleType('ruamel')
+        )
+        # add path to the mapped package
+        ruamel_module.__dict__.setdefault('__path__', []).append(ruamel_path)
+
+        import ruamel                                                          
 # pylint: disable=unused-import

http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/d51cf939/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
----------------------------------------------------------------------
diff --git a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py 
b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
index 0588a8f..3d77b6d 100644
--- a/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
+++ b/extensions/aria_extension_tosca/simple_v1_0/modeling/__init__.py
@@ -23,14 +23,13 @@ Relies on many helper methods in the presentation classes.
 
 import os
 import re
-from types import FunctionType
 from datetime import datetime
 
-from ruamel import yaml
 
 from aria.parser.validation import Issue
 from aria.utils.formatting import string_list_as_string
 from aria.utils.collections import (StrictDict, OrderedDict)
+from aria.utils.yaml.ruamel import yaml
 from aria.orchestrator import WORKFLOW_DECORATOR_RESERVED_ARGUMENTS
 from aria.modeling.models import (Type, ServiceTemplate, NodeTemplate,
                                   RequirementTemplate, RelationshipTemplate, 
CapabilityTemplate,

Reply via email to