Lennart Regebro avatar Lennart Regebro committed 20060c1

J1m pointed out that if we run the tests (which I intend to do) that will flag for lack of dependencies. So this ugly code gets removed.

Comments (0)

Files changed (4)

pyroma/projectdata.py

         sys.path.append(self._old_path)
         
         os.chdir(self._old_path)
-
-def _find_imports(path):
-    # The ast module is buggy when it comes to handling comments and 
-    # whitespace at the end of files. Whitespace we can strip:
-    data = open(path, 'rt').read().strip()
-    try:
-        rootnode = ast.parse(data, filename=path)
-    except SyntaxError, e:
-        print "Warning could not parse a Python file. This is probably not your fault"
-        print "File:", e.args[1][0]
-        print "Line:", e.args[1][1]
-        print "Code:", e.args[1][3]
-        raise StopIteration
-    
-    for node in ast.walk(rootnode):
-        if isinstance(node, ast.Import):
-            for name in node.names:
-                dependency = name.name
-        elif isinstance(node, ast.ImportFrom):
-            dependency = node.module
-        else:
-            continue
-
-        if '.' in dependency:
-            # Only the first name is relevant
-            yield dependency.split('.')[0]
-        else:
-            yield dependency
-    
-def _find_py_modules(path):
-    """Find all python files in the package in 'path'"""
-    files = os.listdir(path)
-    if '__init__.py' not in files:
-        # This is not a part of the package
-        raise StopIteration
-    for filename in files:
-        filepath = os.path.join(path, filename)
-        if filename.endswith('.py'):
-            # Yield the module name and the file path to the module.
-            if filename == '__init__.py':
-                yield filepath.split(os.path.sep)[-2], filepath
-            else:
-                yield os.path.splitext(filename)[0], filepath
-        elif os.path.isdir(filepath):
-            for x in _find_py_modules(filepath):
-                    yield x
     
 def get_data(path):
     """
         except ImportError:
             return {}
 
-    # This didn't work well enough, maybe remove?
-    ## Find all dependencies:
-    #imports = set()
-    #modules_in_package = set()
-    #packages = metadata['packages']
-    
-    ## Remove namespace packages, for example):
-    #for package in sorted(metadata['packages'], key=lambda x: -len(x)):
-        #if '.' in package:
-            #parent = package.rsplit('.', 1)[0]
-            #if parent in packages:
-                #packages.remove(package)
-    
-    #for package in packages:
-        #if '.' in package:
-            #package = package.replace('.', os.path.sep)
-        #package_dirs = metadata.get('package_dir', {'':''})
-        #package_dir = package_dirs.get(package, package_dirs[''])
-            
-        #for module, filepath in _find_py_modules(
-            #os.path.join(path, package_dir, package)):
-            #modules_in_package.add(module)
-            #imports.update(list(_find_imports(filepath)))
-                
-    #metadata['_imports'] = imports - modules_in_package
     return metadata
     

pyroma/ratings.py

                "specifying a test suite, it's easy to find and run tests "\
                "both for automated tools and humans."
 
-class Dependencies(BaseTest):
-    
-    def test(self, data):
-        if data.get('_source_download') is False:
-            # Could not download source from PyPI. Skip this.
-            return None
-        declared_dependencies = data.get('install_requires', []) + \
-                                data.get('tests_require', []) + \
-                                data.get('setup_requires', [])
-        for r in data.get('extras_require', {}).itervalues():
-            declared_dependencies.extend(r)
-
-        if not declared_dependencies: 
-            # No dependencies declared. If it *has* dependencies, this is 
-            # bad form and gives a lot of minus.
-            self.weight = 200
-        else:
-            # It has declared dependencies, perhaps it forgot to add new ones,
-            # perhaps some dependencies are optional. We give it less weight
-            # because they may be optional:
-            self.weight = 50
-
-        # Add the packages in the module to the declared dependencies.
-        declared_dependencies.extend(data['packages'])       
-
-        # Update the declared with aliases:
-        for d in declared_dependencies:
-            declared_dependencies.extend(ALIASES.get(d, []))
-            
-        dependencies = data['_imports'] - STDLIB
-        self._undeclared = dependencies - set(declared_dependencies)
-        return not bool(self._undeclared)
-        
-    def message(self):
-        undeclared = ', '.join(self._undeclared)
-        return "Did you forget to declare the following dependencies?: " + undeclared
-
 class PackageDocs(BaseTest):
     weight = 0 # Just a recommendation
     
     License(),
     ZipSafe(),
     TestSuite(),
-    #Dependencies(),
     PackageDocs(),
     ValidREST(),
 ]

pyroma/testdata/complete/setup.py

 
 version = '1.0'
 
+with open('README.txt', 'rt') as readme:
+    long_description = readme.read()
+    
 setup(name='complete',
       version=version,
       description='This is a test package for pyroma.',
-      long_description=open('README.txt', 'rt').read(),
+      long_description=long_description,
       classifiers=['Development Status :: 6 - Mature',
                    'Operating System :: OS Independent',
                    'Programming Language :: Python :: 2.6',],
         "Programming Language :: Python :: 2.7",
         "Programming Language :: Python :: 3",
         "Programming Language :: Python :: 3.1",
+        "Programming Language :: Python :: 3.2",
         ],
       keywords='pypi quality testing',
       author='Lennart Regebro',
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.