Skip to content

Commit

Permalink
Merge pull request #239 from dlyssenko/fix_for_sphinx_issue
Browse files Browse the repository at this point in the history
fixed issue where sphinx failed to generate API modules doc
  • Loading branch information
dlyssenko committed Sep 20, 2022
2 parents 5a65745 + ac98b81 commit ffe955d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
3 changes: 2 additions & 1 deletion docs/generate_modules.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/python
from __future__ import absolute_import, division, print_function

from os import listdir, path, makedirs
from os.path import isfile, join, exists
Expand All @@ -22,7 +23,7 @@ def get_module_names(p):
mods = list()
mods = [f.split('.')[0] for f in listdir(p)
if isfile(join(p, f)) and not f.endswith('.pyc') and not f.startswith('__')]
print len(mods)
print( len(mods) )
return mods

def process_modules(modules):
Expand Down
6 changes: 5 additions & 1 deletion pyeapi/api/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
ultimately derive from BaseEntity which provides some common functions to
make building API modules easier.
"""
from collections.abc import Callable, Mapping
import sys
if sys.version_info < (3, 3):
from collections import Callable, Mapping
else:
from collections.abc import Callable, Mapping

from pyeapi.eapilib import CommandError, ConnectionError
from pyeapi.utils import make_iterable
Expand Down
14 changes: 7 additions & 7 deletions pyeapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
import inspect
import logging
import logging.handlers
import collections
if sys.version_info < (3, 3):
from collections import Iterable
else:
from collections.abc import Iterable


from itertools import tee

Expand Down Expand Up @@ -170,12 +174,8 @@ def make_iterable(value):
if isinstance(value, str) or isinstance(value, dict):
value = [value]

if sys.version_info <= (3, 3):
if not isinstance(value, collections.Iterable):
raise TypeError('value must be an iterable object')
else:
if not isinstance(value, collections.abc.Iterable):
raise TypeError('value must be an iterable object')
if not isinstance(value, Iterable):
raise TypeError('value must be an iterable object')

return value

Expand Down
14 changes: 7 additions & 7 deletions test/unit/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import sys
import unittest
import collections

from mock import patch, Mock

import pyeapi.utils

COLLECTIONS_ITERABLE = (collections.Iterable if sys.version_info <= (3, 3)
else collections.abc.Iterable)
if sys.version_info < (3, 3):
from collections import Iterable
else:
from collections.abc import Iterable

class TestUtils(unittest.TestCase):

Expand All @@ -26,17 +26,17 @@ def test_load_module_raises_import_error(self, mock_import_module):

def test_make_iterable_from_string(self):
result = pyeapi.utils.make_iterable('test')
self.assertIsInstance(result, COLLECTIONS_ITERABLE)
self.assertIsInstance(result, Iterable)
self.assertEqual(len(result), 1)

def test_make_iterable_from_unicode(self):
result = pyeapi.utils.make_iterable(u'test')
self.assertIsInstance(result, COLLECTIONS_ITERABLE)
self.assertIsInstance(result, Iterable)
self.assertEqual(len(result), 1)

def test_make_iterable_from_iterable(self):
result = pyeapi.utils.make_iterable(['test'])
self.assertIsInstance(result, COLLECTIONS_ITERABLE)
self.assertIsInstance(result, Iterable)
self.assertEqual(len(result), 1)


Expand Down

0 comments on commit ffe955d

Please sign in to comment.