core.py
File containing all the business logic, to be used by the API and the web-app.
Exceptions
Bases: Exception
Exception raised when the PyPi API doesn't respond or respond with an unhandled HTTP code.
Source code in oblique/core.py
15 16 17 18 19 20 | |
Bases: Exception
Exception raised when the given package name is not a package registered in PyPi index.
Source code in oblique/core.py
23 24 25 26 27 28 | |
Functions
Function that call the PyPi API and retrieve the releases data for a specific package name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pkg_name |
str
|
The package name for which we want to retrieve the data. |
required |
Raises:
| Type | Description |
|---|---|
PyPiAPIException
|
Exception raised if the PyPi API behaves unexpectedly. |
Returns:
| Type | Description |
|---|---|
List[Tuple[str, datetime, bool]]
|
List[Tuple[str, datetime, bool]]: Releases data for this package. It's
a list, where each element represents a single release, which is a
tuple with :
* The version of the release
* The release date
* If this release was yanked ( |
Source code in oblique/core.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
Function that retrieve the statistics of a package stored in the DB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db |
Session
|
DB Session. |
required |
db_package |
Package
|
The DB object corresponding to the package we want to extract statistics from. |
required |
human_readable |
bool
|
If set to |
True
|
Raises:
| Type | Description |
|---|---|
UnknownPackageException
|
Exception raised if the package is not a package registered in PyPi index (has no releases). |
Returns:
| Type | Description |
|---|---|
Tuple[str, int, int]
|
Tuple[str, int, int]: The statistics for this package. This is a tuple with : * The release date in a human-readable format * The number of versions released * The number of versions yanked |
Source code in oblique/core.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
Main function to retrieve informations about a PyPi package.
This function will first check if the informations is cached locally. If it's not cached locally, the data is retrieved from the PyPi API and cached locally. The cache is valid for 24h.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db |
Session
|
DB Session. |
required |
pkg_name |
str
|
Name of the package for which we want data. |
required |
human_readable |
bool
|
If set to |
True
|
force_refresh |
bool
|
If set to |
False
|
Returns:
| Type | Description |
|---|---|
Tuple[str, int, int]
|
Tuple[str, int, int]: The statistics for the package. This is a tuple with : * The release date in a human-readable format * The number of versions released * The number of versions yanked |
Source code in oblique/core.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |