0
# Core Analysis Functions
1
2
Main functions for running pyroma analysis programmatically and from the command line. These functions provide the primary interface for integrating pyroma into development workflows, automation scripts, and continuous integration pipelines.
3
4
## Capabilities
5
6
### Main Entry Point
7
8
**main()**
9
10
```python { .api }
11
def main():
12
"""Command-line interface entry point for pyroma.
13
14
Handles argument parsing and executes package analysis based on
15
provided arguments. Exits with code 0 for successful analysis
16
above minimum rating, code 2 for ratings below minimum.
17
"""
18
```
19
20
Command-line interface that parses arguments and executes analysis:
21
22
- Supports multiple analysis modes (auto, directory, file, pypi)
23
- Configurable minimum rating threshold (1-10, default 8)
24
- Optional test skipping with `--skip-tests`
25
- Quiet mode for CI/CD integration
26
- Auto-detection of analysis mode based on argument type
27
28
### Core Analysis Function
29
30
**run(mode, argument, quiet=False, skip_tests=None)**
31
32
```python { .api }
33
def run(mode, argument, quiet=False, skip_tests=None):
34
"""Run pyroma analysis on a package.
35
36
Args:
37
mode: Analysis mode - "directory", "file", "pypi", or "auto"
38
argument: Package path, filename, or PyPI package name
39
quiet: If True, suppresses output except final rating
40
skip_tests: List of test class names to skip during analysis
41
42
Returns:
43
int: Package rating from 0-10
44
45
Raises:
46
ValueError: If package not found or invalid mode specified
47
"""
48
```
49
50
The primary analysis function that:
51
52
- Extracts package metadata using appropriate data extractor
53
- Runs comprehensive quality assessment using rating system
54
- Provides detailed feedback on packaging issues
55
- Returns numerical rating for programmatic use
56
57
Usage examples:
58
59
```python
60
# Analyze local project directory
61
rating = run('directory', '/path/to/project')
62
63
# Analyze distribution file
64
rating = run('file', 'package-1.0.tar.gz')
65
66
# Analyze PyPI package
67
rating = run('pypi', 'requests')
68
69
# Skip specific tests
70
rating = run('directory', '.', skip_tests=['BusFactor', 'SDist'])
71
72
# Quiet mode for scripts
73
rating = run('directory', '.', quiet=True)
74
```
75
76
### Integration Functions
77
78
**zester(data)**
79
80
```python { .api }
81
def zester(data):
82
"""Integration hook for zest.releaser.
83
84
Prompts user to run pyroma analysis before package release.
85
If rating is below 8, asks for confirmation to continue.
86
87
Args:
88
data: Release data dictionary from zest.releaser
89
90
Exits:
91
System exit with code 1 if user chooses not to continue
92
after low rating
93
"""
94
```
95
96
Pre-release hook for zest.releaser that:
97
98
- Automatically runs pyroma on package before tagging
99
- Prompts user for confirmation if rating is below 8
100
- Integrates seamlessly with existing release workflows
101
- Helps maintain packaging quality standards
102
103
### Utility Functions
104
105
**get_all_tests()**
106
107
```python { .api }
108
def get_all_tests():
109
"""Get list of all available test class names.
110
111
Returns:
112
list: List of test class names that can be used with skip_tests
113
114
Example:
115
['Name', 'Version', 'Description', 'Classifiers', ...]
116
"""
117
```
118
119
**parse_tests(arg)**
120
121
```python { .api }
122
def parse_tests(arg):
123
"""Parse test names from string with various separators.
124
125
Args:
126
arg: Test names separated by spaces, commas, or semicolons
127
128
Returns:
129
str or None: Parsed test name if valid, None if invalid
130
"""
131
```
132
133
**skip_tests(arg)**
134
135
```python { .api }
136
def skip_tests(arg):
137
"""Argument parser type function for validating skip_tests.
138
139
Args:
140
arg: Comma/space/semicolon-separated test names
141
142
Returns:
143
str: Validated test name
144
145
Raises:
146
ArgumentTypeError: If test name is not valid
147
"""
148
```
149
150
**min_argument(arg)**
151
152
```python { .api }
153
def min_argument(arg):
154
"""Argument parser type function for minimum rating validation.
155
156
Args:
157
arg: Rating value as string (must be 1-10)
158
159
Returns:
160
int: Validated rating value
161
162
Raises:
163
ArgumentTypeError: If rating is not between 1-10
164
"""
165
```