Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove python2 support. #121

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 29 additions & 31 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,40 @@

"""Setup script."""

from setuptools import setup, find_packages
import textfsm
# To use a consistent encoding
from codecs import open
from os import path
from setuptools import find_packages, setup
import textfsm

here = path.abspath(path.dirname(__file__))

# Get the long description from the README file
with open(path.join(here, 'README.md'), encoding="utf8") as f:
long_description = f.read()
with open(path.join(here, 'README.md'), encoding='utf8') as f:
long_description = f.read()

setup(name='textfsm',
maintainer='Google',
maintainer_email='textfsm-dev@googlegroups.com',
version=textfsm.__version__,
description='Python module for parsing semi-structured text into python tables.',
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/google/textfsm',
license='Apache License, Version 2.0',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries'],
packages=['textfsm'],
entry_points={
'console_scripts': [
'textfsm=textfsm.parser:main'
]
},
include_package_data=True,
package_data={'textfsm': ['../testdata/*']},
install_requires=['six', 'future'],
)
setup(
name='textfsm',
maintainer='Google',
maintainer_email='textfsm-dev@googlegroups.com',
version=textfsm.__version__,
description=(
'Python module for parsing semi-structured text into python tables.'
),
long_description=long_description,
long_description_content_type='text/markdown',
url='https://github.com/google/textfsm',
license='Apache License, Version 2.0',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Topic :: Software Development :: Libraries',
],
packages=['textfsm'],
entry_points={'console_scripts': ['textfsm=textfsm.parser:main']},
include_package_data=True,
package_data={'textfsm': ['../testdata/*']},
)
21 changes: 6 additions & 15 deletions tests/clitable_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,12 @@

"""Unittest for clitable script."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import copy
import io
import os
import re
import unittest

from io import StringIO
from textfsm import clitable
from textfsm import copyable_regex_object


class UnitTestIndexTable(unittest.TestCase):
Expand All @@ -47,8 +40,7 @@ def testParseIndex(self):

self.assertEqual(indx.compiled.size, 3)
for col in ('Command', 'Vendor', 'Template', 'Hostname'):
self.assertTrue(isinstance(indx.compiled[1][col],
copyable_regex_object.CopyableRegexObject))
self.assertIsInstance(indx.compiled[1][col], re.Pattern)

self.assertTrue(indx.compiled[1]['Hostname'].match('random string'))

Expand All @@ -66,8 +58,7 @@ def _PreCompile(key, value):
indx = clitable.IndexTable(_PreParse, _PreCompile, file_path)
self.assertEqual(indx.index[2]['Template'], 'CLITABLE_TEMPLATEC')
self.assertEqual(indx.index[1]['Command'], 'sh[[ow]] ve[[rsion]]')
self.assertTrue(isinstance(indx.compiled[1]['Hostname'],
copyable_regex_object.CopyableRegexObject))
self.assertIsInstance(indx.compiled[1]['Hostname'], re.Pattern)
self.assertFalse(indx.compiled[1]['Command'])

def testGetRowMatch(self):
Expand Down Expand Up @@ -101,7 +92,7 @@ def setUp(self):
'Start\n'
' ^${Col1} ${Col2} ${Col3} -> Record\n'
'\n')
self.template_file = StringIO(self.template)
self.template_file = io.StringIO(self.template)

def testCompletion(self):
"""Tests '[[]]' syntax replacement."""
Expand All @@ -123,7 +114,7 @@ def testCliCompile(self):

self.assertEqual('sh(o(w)?)? ve(r(s(i(o(n)?)?)?)?)?',
self.clitable.index.index[1]['Command'])
self.assertEqual(None, self.clitable.index.compiled[1]['Template'])
self.assertIsNone(self.clitable.index.compiled[1]['Template'])
self.assertTrue(
self.clitable.index.compiled[1]['Command'].match('sho vers'))

Expand Down Expand Up @@ -267,7 +258,7 @@ def testTableSort(self):
'Start\n'
' ^${Col1} ${Col2} ${Col3} -> Record\n'
'\n')
self.template_file = StringIO(self.template)
self.template_file = io.StringIO(self.template)
self.clitable._TemplateNamesToFiles = lambda t: [self.template_file]
self.clitable.ParseCmd(self.input_data + input_data2,
attributes={'Command': 'sh ver'})
Expand Down
42 changes: 0 additions & 42 deletions tests/copyable_regex_object_test.py

This file was deleted.

11 changes: 3 additions & 8 deletions tests/terminal_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@

"""Unittest for terminal module."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

from builtins import range
from builtins import object
import sys
import unittest

Expand All @@ -39,6 +32,7 @@ def setUp(self):
self.terminal_orig = terminal.TerminalSize

def tearDown(self):
super(TerminalTest, self).tearDown()
terminal.os.environ = self.environ_orig
terminal.os.open = self.open_orig
terminal.TerminalSize = self.terminal_orig
Expand Down Expand Up @@ -157,6 +151,7 @@ def setUp(self):
self.p = terminal.Pager()

def tearDown(self):
super(PagerTest, self).tearDown()
terminal.Pager._GetCh = self.get_ch_orig
terminal.TerminalSize = self.ts_orig
sys.stdout = sys.__stdout__
Expand All @@ -180,7 +175,7 @@ def testPage(self):
sys.stdout.output = ''
self.p = terminal.Pager()
self.p._text = ''
for i in range(10):
for _ in range(10):
self.p._text += 'a' * 100 + '\n'
self.p.Page()
self.assertEqual(20, sys.stdout.CountLines())
Expand Down
Loading