Skip to content

Commit

Permalink
Several static analysis fixes, v2.0.2
Browse files Browse the repository at this point in the history
* Don't use relative imports
* Remove __version__ from module init, unnecessary maintenance
* Change Classifier to "new" style class
* Don't redefine built-in list
* Fix typo when calling os.makedirs
  • Loading branch information
briancline committed Nov 21, 2013
1 parent 27cc733 commit 52f1450
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions crm114/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from classifier import Classifier
from crm114.classifier import Classifier

__version__ = "1.0.0a1"
__license__ = '(c) 2005 Sam Deane. ' \
'(c) 2013 Brian Cline. ' \
'MIT License. See LICENSE file for details.'
Expand Down
12 changes: 6 additions & 6 deletions crm114/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
" output /:*:best:\\t:*:prob:/ }'"


class Classifier:
class Classifier(object):
def __init__(self, path, categories=None):
""" Wrapper class for the CRM-114 Discriminator. """
self.categories = categories if categories else []
Expand Down Expand Up @@ -51,14 +51,14 @@ def classify(self, text):
fin.write(text)
fin.close()

list = string.split(fout.readline())
output_list = string.split(fout.readline())
fout.close()

if list is None:
if output_list is None:
return ('', 0.0)
else:
category = list[0]
probability = float(list[1])
category = output_list[0]
probability = float(output_list[1])
return (category, probability)

def create_files(self):
Expand All @@ -67,7 +67,7 @@ def create_files(self):

# Create directory if necessary
if not os.path.exists(self.path):
os.mkdirs(self.path)
os.makedirs(self.path)

# Create category files
for category in self.categories:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='crm114',
version='2.0.1',
version='2.0.2',
author='Brian Cline',
author_email='[email protected]',
description=('Python wrapper classes for the CRM-114 Discriminator '
Expand Down

0 comments on commit 52f1450

Please sign in to comment.