Skip to content

Commit

Permalink
[refs #10 #74] A large refactor to centralise configuration, and to r…
Browse files Browse the repository at this point in the history
…emove the "adaptors" concept which was confusing and not particularly useful.
  • Loading branch information
carlio committed Nov 24, 2014
1 parent 8acda72 commit 82e549a
Show file tree
Hide file tree
Showing 25 changed files with 436 additions and 469 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Prospector Changelog
=======

## Version 0.8

* [#74](https://github.com/landscapeio/prospector/issues/74),[#10](https://github.com/landscapeio/prospector/issues/10) Tools will now use any configuration specific to them by default. That is to say, if a `.pylintrc` file exists, then that will be used in preference to prospector's own opinions of how to use pylint.
* Added centralised configuration management, with an abstraction away from how prospector and each tool is actually configured.
* Removed the "adaptors" concept. This was a sort of visitor pattern in which each tool's configuration could be updated by an adaptor, which 'visited' the tool to tweak settings based on what the adaptor represented. In practise this was not useful and a confusing way to tweak behaviour - tools now configure themselves based on configuration options directly.
* Changed the default output format to be 'grouped' rather than 'text'

## Version 0.7.3

* [#70](https://github.com/landscapeio/prospector/issues/70) ProfilesThe E265 error from PEP8 - "Block comment should start with a `.yml` extension can now be autoloaded
Expand Down
2 changes: 1 addition & 1 deletion prospector/__pkginfo__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

VERSION = (0, 7, 3)
VERSION = (0, 8)


def get_version():
Expand Down
7 changes: 0 additions & 7 deletions prospector/adaptor/__init__.py

This file was deleted.

23 changes: 0 additions & 23 deletions prospector/adaptor/base.py

This file was deleted.

8 changes: 0 additions & 8 deletions prospector/adaptor/common.py

This file was deleted.

18 changes: 0 additions & 18 deletions prospector/adaptor/libraries.py

This file was deleted.

77 changes: 0 additions & 77 deletions prospector/adaptor/profile.py

This file was deleted.

26 changes: 13 additions & 13 deletions prospector/autodetect.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import os
import re
from prospector.adaptor import LIBRARY_ADAPTORS
from requirements_detector import find_requirements
from requirements_detector.detect import RequirementsNotFound


POSSIBLE_LIBRARIES = ('django', 'celery')


# see http://docs.python.org/2/reference/lexical_analysis.html#identifiers
_FROM_IMPORT_REGEX = re.compile(r'^\s*from ([\._a-zA-Z0-9]+) import .*$')
_IMPORT_REGEX = re.compile(r'^\s*import ([\._a-zA-Z0-9]+)$')
_IMPORT_MULTIPLE_REGEX = re.compile(r'^\s*import ([\._a-zA-Z0-9]+(, ){1})+')


def find_from_imports(file_contents):
names = set()
for line in file_contents.split('\n'):
Expand All @@ -26,15 +30,15 @@ def find_from_imports(file_contents):
import_names = match.group(1).split('.')

for import_name in import_names:
if import_name in LIBRARY_ADAPTORS:
if import_name in POSSIBLE_LIBRARIES:
names.add(import_name)

return names


def find_from_path(path):
names = set()
max_possible = len(LIBRARY_ADAPTORS.keys())
max_possible = len(POSSIBLE_LIBRARIES)

for item in os.listdir(path):
item_path = os.path.abspath(os.path.join(path, item))
Expand All @@ -56,7 +60,7 @@ def find_from_requirements(path):
names = []
for requirement in reqs:
if requirement.name is not None \
and requirement.name.lower() in LIBRARY_ADAPTORS:
and requirement.name.lower() in POSSIBLE_LIBRARIES:
names.append(requirement.name.lower())
return names

Expand All @@ -68,20 +72,16 @@ def autodetect_libraries(path):
if path == '':
path = '.'

adaptor_names = []
libraries = []

try:
adaptor_names = find_from_requirements(path)
libraries = find_from_requirements(path)

# pylint: disable=W0704
except RequirementsNotFound:
pass

if len(adaptor_names) == 0:
adaptor_names = find_from_path(path)

adaptors = []
for adaptor_name in adaptor_names:
adaptors.append((adaptor_name, LIBRARY_ADAPTORS[adaptor_name]()))
if libraries < len(POSSIBLE_LIBRARIES):
libraries = find_from_path(path)

return adaptors
return libraries
Loading

0 comments on commit 82e549a

Please sign in to comment.