From bb3aa7eccf4a506a0243c41edb46d44bc751399a Mon Sep 17 00:00:00 2001
From: Greg Albrecht <gba@onbeep.com>
Date: Mon, 16 Sep 2013 17:45:01 -0700
Subject: [PATCH] updating for linting, pepping, copyright and licensing.

---
 LICENSE            | 42 ++++++++++++++++++++-----------
 Makefile           | 12 +++------
 README.rst         | 62 +++++++++++++++++++++++++++++++++++++++-------
 kiss/__init__.py   |  8 +++---
 kiss/classes.py    |  8 +++---
 kiss/constants.py  |  2 +-
 kiss/util.py       | 24 +-----------------
 requirements.txt   |  6 ++---
 setup.cfg          |  6 ++---
 setup.py           |  5 ++--
 tests/__init__.py  |  1 +
 tests/constants.py |  2 +-
 tests/context.py   |  3 +++
 tests/test_kiss.py |  7 ++++--
 14 files changed, 116 insertions(+), 72 deletions(-)

diff --git a/LICENSE b/LICENSE
index 529db57..0777fc8 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,16 +1,30 @@
-1. Original components are covered under Apache License 2.0.
+1. Original components are covered under Apache License 2.0:
+
+   Copyright 2013 OnBeep, Inc.
+
+   Licensed 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.
+
 
 2. Components derived from dixprs are covered by the following license:
-"""
-You are allowed to:
-
-- Use DIXPRS free for HAM radio.
-- Redistribute DIXPRS for HAM radio purposes in original format
-  (archive files available in download section).
-- Modify it for yourself.
-- Redistribute modified version for HAM radio use as long as you keep
-  original copyright text in files with the original licence conditions.
-
-Commercial use or changing above rules is not allowed without prior written
-approval of author, HA5DI.
-"""
\ No newline at end of file
+
+  You are allowed to:
+
+  - Use DIXPRS free for HAM radio.
+  - Redistribute DIXPRS for HAM radio purposes in original format
+    (archive files available in download section).
+  - Modify it for yourself.
+  - Redistribute modified version for HAM radio use as long as you keep
+    original copyright text in files with the original licence conditions.
+
+  Commercial use or changing above rules is not allowed without prior written
+  approval of author, HA5DI.
diff --git a/Makefile b/Makefile
index f0b520e..f6634dc 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,9 @@
-# Makefile for kiss
+# Makefile for KISS Python Module.
 #
 # Source:: https://github.com/ampledata/kiss
-# Author:: Greg Albrecht <gba@splunk.com>
+# Author:: Greg Albrecht W2GMD <gba@onbeep.com>
 # Copyright:: Copyright 2013 OnBeep, Inc.
-# License:: Apache License 2.0
+# License:: Apache License, Version 2.0
 #
 
 
@@ -11,10 +11,6 @@ init:
 	pip install -r requirements.txt --use-mirrors
 
 lint:
-	pylint -f parseable -i y -r y kiss/*.py tests/*.py *.py | \
-		tee pylint.log
-
-cli_lint:
 	pylint -f colorized -i y -r n kiss/*.py tests/*.py *.py
 
 flake8:
@@ -44,7 +40,7 @@ publish:
 nosetests:
 	python setup.py nosetests
 
-test: init lint flake8 clonedigger nosetests
+test: init clonedigger nosetests lint flake8
 
 clean:
 	rm -rf *.egg* build dist *.pyc *.pyo cover doctest_pypi.cfg nosetests.xml \
diff --git a/README.rst b/README.rst
index 41008c6..9125862 100644
--- a/README.rst
+++ b/README.rst
@@ -1,18 +1,62 @@
-KISS is a protocol for communicating with a serial TNC device used for Amateur Radio.
+A pure-Python implementation of the KISS Protocol for communicating with serial TNC devices for use with Amateur Radio.
 
-A Python implementation of the KISS Protocol for communicating with serial TNC devices for use with Amateur Radio.
+Installation
+============
+Install from pypi using pip::
 
-A pure-Python KISS module partially based off the work on dixprs by HA5DI, et al.
+    pip install kiss
 
-dixprs: https://sites.google.com/site/dixprs/
 
-As this project still uses components derived from dixprs, portions fall
-under License #2 in LICENSE.txt
+Usage Example
+=============
+Read & print frames from a TNC connected to '/dev/ttyUSB0' at 1200 baud::
 
-Otherwise, non-derived portions are covered by License #1 in LICENSE.txt.
+    import kiss
 
+    k = kiss.KISS('/dev/ttyUSB0', 1200)
+    k.start()  # inits the TNC, optionally passes KISS config flags.
+    k.read(callback=print)
 
 
- description=(''),
+Testing
+=======
+Run nosetests from a Makefile target::
 
-    long_description=(''),
+    make test
+
+
+Inspiration
+===========
+Inspiration for this project came from:
+
+* HA5DI's dixprs_: A Python APRS project with KISS, digipeater, et al., support.
+* GE0RG's APRSDroid_: A Java/Scala Android APRS App.
+* KA2DDO's YAAC_: A Java APRS app.
+* aprs.fi_'s Ham-APRS-FAP_: A Perl APRS parser.
+
+.. _dixprs: https://sites.google.com/site/dixprs/
+.. _aprsdroid: http://aprsdroid.org/
+.. _YAAC: http://www.ka2ddo.org/ka2ddo/YAAC.html
+.. _aprs.fi: http://search.cpan.org/dist/Ham-APRS-FAP/
+.. _Ham-APRS-FAP: http://search.cpan.org/dist/Ham-APRS-FAP/
+
+
+Source
+======
+https://github.com/ampledata/kiss
+
+Author
+======
+Greg Albrecht W2GMD gba@onbeep.com
+
+http://ampledata.org/
+
+
+Copyright
+=========
+Copyright 2013 OnBeep, Inc.
+
+
+License
+=======
+Apache License, Version 2.0. See LICENSE for details.
\ No newline at end of file
diff --git a/kiss/__init__.py b/kiss/__init__.py
index 8dbae7c..f0d470c 100644
--- a/kiss/__init__.py
+++ b/kiss/__init__.py
@@ -10,7 +10,7 @@ KISS Python Module.
 
 :author: Greg Albrecht W2GMD <gba@onbeep.com>
 :copyright: Copyright 2013 OnBeep, Inc.
-:license: Apache 2.0, see LICENSE for details.
+:license: Apache License, Version 2.0
 :source: <https://github.com/ampledata/kiss>
 
 """
@@ -19,7 +19,7 @@ __title__ = 'kiss'
 __version__ = '0.0.3'
 __build__ = '0x000003'
 __author__ = 'Greg Albrecht W2GMD <gba@onbeep.com>'
-__license__ = 'Apache 2.0'
+__license__ = 'Apache License, Version 2.0'
 __copyright__ = 'Copyright 2013 OnBeep, Inc.'
 
 
@@ -33,7 +33,9 @@ try:  # Python 2.7+
     from logging import NullHandler
 except ImportError:
     class NullHandler(logging.Handler):
+        """Default logging handler to avoid "No handler found" warnings."""
         def emit(self, record):
+            """Default logging handler to avoid "No handler found" warnings."""
             pass
 
-logging.getLogger(__name__).addHandler(NullHandler())
\ No newline at end of file
+logging.getLogger(__name__).addHandler(NullHandler())
diff --git a/kiss/classes.py b/kiss/classes.py
index e6882f1..0d42b61 100644
--- a/kiss/classes.py
+++ b/kiss/classes.py
@@ -5,7 +5,7 @@
 
 __author__ = 'Greg Albrecht W2GMD <gba@onbeep.com>'
 __copyright__ = 'Copyright 2013 OnBeep, Inc.'
-__license__ = 'Apache 2.0'
+__license__ = 'Apache License, Version 2.0'
 
 
 import logging
@@ -32,7 +32,7 @@ class KISS(object):
     def __init__(self, port, speed):
         self.port = port
         self.speed = speed
-        self.serial_int = None  # TODO Potentially very f*cking unsafe.
+        self.serial_int = None
 
     def __enter__(self):
         return self
@@ -53,8 +53,9 @@ class KISS(object):
         self.serial_int = serial.Serial(self.port, self.speed)
         self.serial_int.timeout = kiss.constants.SERIAL_TIMEOUT
 
+        # TODO: Configuration section is incomplete - ampledata.
         # http://en.wikipedia.org/wiki/KISS_(TNC)#Command_Codes
-        kiss_config = {}  # TODO Yes, this isn't complete.
+        kiss_config = {}
         for setting in ['TX_DELAY', 'PERSISTENCE', 'SLOT_TIME', 'TX_TAIL',
                         'FULL_DUPLEX']:
             if kiss_config.get(setting):
@@ -81,6 +82,7 @@ class KISS(object):
         """
         self.logger.debug('callback=%s', callback)
         read_buffer = ''
+
         while 1:
             read_data = self.serial_int.read(kiss.constants.READ_BYTES)
 
diff --git a/kiss/constants.py b/kiss/constants.py
index d0513ca..7ee2e38 100644
--- a/kiss/constants.py
+++ b/kiss/constants.py
@@ -5,7 +5,7 @@
 
 __author__ = 'Greg Albrecht W2GMD <gba@onbeep.com>'
 __copyright__ = 'Copyright 2013 OnBeep, Inc.'
-__license__ = 'Apache 2.0'
+__license__ = 'Apache License, Version 2.0'
 
 
 import logging
diff --git a/kiss/util.py b/kiss/util.py
index 3ff7f11..253e32b 100644
--- a/kiss/util.py
+++ b/kiss/util.py
@@ -5,24 +5,12 @@
 
 __author__ = 'Greg Albrecht W2GMD <gba@onbeep.com>'
 __copyright__ = 'Copyright 2013 OnBeep, Inc.'
-__license__ = 'Apache 2.0'
+__license__ = 'Apache License, Version 2.0'
 
 
-import logging
-
 import kiss.constants
 
 
-logger = logging.getLogger(__name__)
-logger.setLevel(kiss.constants.LOG_LEVEL)
-console_handler = logging.StreamHandler()
-console_handler.setLevel(kiss.constants.LOG_LEVEL)
-formatter = logging.Formatter(kiss.constants.LOG_FORMAT)
-console_handler.setFormatter(formatter)
-logger.addHandler(console_handler)
-logger.propagate = False
-
-
 def escape_special_codes(raw_codes):
     """
     Escape special codes, per KISS spec.
@@ -39,13 +27,3 @@ def escape_special_codes(raw_codes):
         kiss.constants.FEND,
         kiss.constants.FESC_TFEND
     )
-
-
-def unescape_special_codes(codes):
-    return codes.replace(
-        chr(0xc0),
-        chr(0xdb) + chr(0xdc)
-    ).replace(
-        chr(0xc0),
-        chr(0xdb) + chr(0xdd)
-    )
diff --git a/requirements.txt b/requirements.txt
index 108d21b..35d9123 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,9 +1,9 @@
-# Python Distribution Package Requirements for kiss.
+# Python Distribution Package Requirements for KISS.
 #
 # Source:: https://github.com/ampledata/kiss
-# Author:: Greg Albrecht <gba@onbeep.com>
+# Author:: Greg Albrecht W2GMD <gba@onbeep.com>
 # Copyright:: Copyright 2013 OnBeep, Inc.
-# License:: Apache License 2.0
+# License:: Apache License, Version 2.0
 
 
 flake8
diff --git a/setup.cfg b/setup.cfg
index d1c14c8..6a1da6c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,9 +1,9 @@
-# Nosetests configuration for kiss.
+# Nosetests configuration for KISS.
 #
 # Source:: https://github.com/ampledata/kiss
-# Author:: Greg Albrecht <gba@onbeep.com>
+# Author:: Greg Albrecht W2GMD <gba@onbeep.com>
 # Copyright:: Copyright 2013 OnBeep, Inc.
-# License:: Apache License 2.0
+# License:: Apache License, Version 2.0
 #
 
 
diff --git a/setup.py b/setup.py
index 1db0e78..0efab86 100644
--- a/setup.py
+++ b/setup.py
@@ -8,8 +8,8 @@ Source:: https://github.com/ampledata/kiss
 """
 
 __author__ = 'Greg Albrecht W2GMD <gba@onbeep.com>'
-__copyright__ = 'Copyright 2013 Onbeep, Inc.'
-__license__ = 'Apache License 2.0'
+__copyright__ = 'Copyright 2013 OnBeep, Inc.'
+__license__ = 'Apache License, Version 2.0'
 
 
 import os
@@ -20,6 +20,7 @@ import kiss
 try:
     from setuptools import setup
 except ImportError:
+    # pylint: disable=F0401,E0611
     from distutils.core import setup
 
 
diff --git a/tests/__init__.py b/tests/__init__.py
index e69de29..a211b8d 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -0,0 +1 @@
+"""Tests for KISS Python Module."""
diff --git a/tests/constants.py b/tests/constants.py
index cd3aa73..bfec065 100644
--- a/tests/constants.py
+++ b/tests/constants.py
@@ -5,7 +5,7 @@
 
 __author__ = 'Greg Albrecht W2GMD <gba@onbeep.com>'
 __copyright__ = 'Copyright 2013 OnBeep, Inc.'
-__license__ = 'Apache 2.0'
+__license__ = 'Apache License, Version 2.0'
 
 
 TEST_FRAMES = 'tests/test_frames.log'
diff --git a/tests/context.py b/tests/context.py
index 6a0b028..6654f6e 100644
--- a/tests/context.py
+++ b/tests/context.py
@@ -1,10 +1,13 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+"""Context for tests for KISS Python Module."""
+
 
 import os
 import sys
 
 sys.path.insert(0, os.path.abspath('..'))
 
+# pylint: disable=W0611
 import kiss
diff --git a/tests/test_kiss.py b/tests/test_kiss.py
index a087893..2c63726 100644
--- a/tests/test_kiss.py
+++ b/tests/test_kiss.py
@@ -5,7 +5,7 @@
 
 __author__ = 'Greg Albrecht W2GMD <gba@onbeep.com>'
 __copyright__ = 'Copyright 2013 OnBeep, Inc.'
-__license__ = 'Apache 2.0'
+__license__ = 'Apache License, Version 2.0'
 
 
 import unittest
@@ -15,8 +15,11 @@ from .context import kiss
 from . import constants
 
 
+# pylint: disable=R0904,C0103
 class KISSTestCase(unittest.TestCase):
 
+    """Test class for KISS Python Module."""
+
     def setUp(self):
         """Setup."""
         self.test_frames = open(constants.TEST_FRAMES, 'r')
@@ -42,4 +45,4 @@ class KISSTestCase(unittest.TestCase):
 
 
 if __name__ == '__main__':
-    unittest.main()
\ No newline at end of file
+    unittest.main()
-- 
GitLab