Improvements in plugins_index.txt
- Removed author and email in favor of repository link. Repository link is obtained from the 'home_page' field obtained from pypi. For plugins that don't have that field set, function obtain_override_repositories is used to override it in favor of known repositories url. - Shortened "Python 2.7" in favor of "py27" to save space; Same for "Python 3.3".
This commit is contained in:
		
							parent
							
								
									ddfb2d5f3a
								
							
						
					
					
						commit
						3a37f33d99
					
				|  | @ -2,8 +2,8 @@ | ||||||
| Script to generate the file `plugins_index.txt` with information about | Script to generate the file `plugins_index.txt` with information about | ||||||
| pytest plugins taken directly from a live PyPI server. | pytest plugins taken directly from a live PyPI server. | ||||||
| 
 | 
 | ||||||
| This will evolve to include test compatibility (pythons and pytest versions) | Also includes plugin compatibility between different python and pytest versions, | ||||||
| information also. | obtained from http://pytest-plugs.herokuapp.com. | ||||||
| """ | """ | ||||||
| from __future__ import print_function | from __future__ import print_function | ||||||
| from collections import namedtuple | from collections import namedtuple | ||||||
|  | @ -68,16 +68,15 @@ def obtain_plugins_table(plugins, client): | ||||||
|     """ |     """ | ||||||
|     rows = [] |     rows = [] | ||||||
|     ColumnData = namedtuple('ColumnData', 'text link') |     ColumnData = namedtuple('ColumnData', 'text link') | ||||||
|     headers = ['Name', 'Author', 'Downloads', 'Python 2.7', 'Python 3.3', |     headers = ['Name', 'Py27', 'Py33', 'Repository', 'Summary'] | ||||||
|                'Summary'] |  | ||||||
|     pytest_version = pytest.__version__ |     pytest_version = pytest.__version__ | ||||||
|  |     repositories = obtain_override_repositories() | ||||||
|     print('*** pytest-{0} ***'.format(pytest_version)) |     print('*** pytest-{0} ***'.format(pytest_version)) | ||||||
|     plugins = list(plugins) |     plugins = list(plugins) | ||||||
|     for index, (package_name, version) in enumerate(plugins): |     for index, (package_name, version) in enumerate(plugins): | ||||||
|         print(package_name, version, '...', end='') |         print(package_name, version, '...', end='') | ||||||
| 
 | 
 | ||||||
|         release_data = client.release_data(package_name, version) |         release_data = client.release_data(package_name, version) | ||||||
|         download_count = release_data['downloads']['last_month'] |  | ||||||
|         url = '.. image:: {site}/status/{name}-{version}' |         url = '.. image:: {site}/status/{name}-{version}' | ||||||
|         image_url = url.format( |         image_url = url.format( | ||||||
|             site='http://pytest-plugs.herokuapp.com', |             site='http://pytest-plugs.herokuapp.com', | ||||||
|  | @ -87,12 +86,13 @@ def obtain_plugins_table(plugins, client): | ||||||
|         row = ( |         row = ( | ||||||
|             ColumnData(package_name + '-' + version, |             ColumnData(package_name + '-' + version, | ||||||
|                        release_data['release_url']), |                        release_data['release_url']), | ||||||
|             ColumnData(release_data['author'], release_data['author_email']), |  | ||||||
|             ColumnData(str(download_count), None), |  | ||||||
|             ColumnData(image_url.format(py='py27', pytest=pytest_version), |             ColumnData(image_url.format(py='py27', pytest=pytest_version), | ||||||
|                        None), |                        None), | ||||||
|             ColumnData(image_url.format(py='py33', pytest=pytest_version), |             ColumnData(image_url.format(py='py33', pytest=pytest_version), | ||||||
|                        None), |                        None), | ||||||
|  |             ColumnData( | ||||||
|  |                 repositories.get(package_name, release_data['home_page']), | ||||||
|  |                 None), | ||||||
|             ColumnData(release_data['summary'], None), |             ColumnData(release_data['summary'], None), | ||||||
|         ) |         ) | ||||||
|         assert len(row) == len(headers) |         assert len(row) == len(headers) | ||||||
|  | @ -103,6 +103,20 @@ def obtain_plugins_table(plugins, client): | ||||||
|     return headers, rows |     return headers, rows | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | def obtain_override_repositories(): | ||||||
|  |     """ | ||||||
|  |     Used to override the "home_page" obtained from pypi to known | ||||||
|  |     package repositories. Used when the author didn't fill the "home_page" | ||||||
|  |     field in setup.py. | ||||||
|  | 
 | ||||||
|  |     :return: dict of {package_name: repository_url} | ||||||
|  |     """ | ||||||
|  |     return { | ||||||
|  |         'pytest-blockage': 'https://github.com/rob-b/pytest-blockage', | ||||||
|  |         'pytest-konira': 'http://github.com/alfredodeza/pytest-konira', | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| def generate_plugins_index_from_table(filename, headers, rows): | def generate_plugins_index_from_table(filename, headers, rows): | ||||||
|     """ |     """ | ||||||
|     Generates a RST file with the table data given. |     Generates a RST file with the table data given. | ||||||
|  | @ -157,16 +171,8 @@ def generate_plugins_index_from_table(filename, headers, rows): | ||||||
|         print(file=f) |         print(file=f) | ||||||
|         print(get_row_limiter('='), file=f) |         print(get_row_limiter('='), file=f) | ||||||
|         print(file=f) |         print(file=f) | ||||||
|         print('*(Downloads are given from last month only)*', file=f) |         today = datetime.date.today().strftime('%Y-%m-%d') | ||||||
|         print(file=f) |         print('*(Updated on %s)*' % today, file=f) | ||||||
|         print('*(Updated on %s)*' % _get_today_as_str(), file=f) |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| def _get_today_as_str(): |  | ||||||
|     """ |  | ||||||
|     internal. only exists so we can patch it in testing. |  | ||||||
|     """ |  | ||||||
|     return datetime.date.today().strftime('%Y-%m-%d') |  | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def generate_plugins_index(client, filename): | def generate_plugins_index(client, filename): | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue