Skip to content

Commit

Permalink
Merge pull request #5 from chr15m/custom_repository
Browse files Browse the repository at this point in the history
Allow user to specify pypi repo (for testing).
  • Loading branch information
alexmojaki committed Jun 13, 2020
2 parents 4dc4cca + 262eafe commit 1b1941e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ Optional arguments:

`is_outdated` is a boolean which is True if the given version is earlier than the latest version, which is the string `latest_version`.

Optional arguments:

- `repository_url` (default `https://pypi.python.org/pypi/%s/json`): format string to use a different repository pypi repository URL. For example test.pypi.org or a private repository. Formatter is passed the package name as the first argument.

This still makes the HTTP call with retries and caches the result on disk. It doesn't use a separate thread or emit any warnings (unless there is an exception specifically while using the cache, in which case the check will be done without the cache).

## Additional configuration
Expand Down
4 changes: 2 additions & 2 deletions outdated/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__version__ = '0.2.0'


def check_outdated(package, version):
def check_outdated(package, version, repository_url='https://pypi.python.org/pypi/%s/json'):
"""
Given the name of a package on PyPI and a version (both strings), checks
if the given version is the latest version of the package available.
Expand All @@ -36,7 +36,7 @@ def check_outdated(package, version):
latest = None

def get_latest():
url = 'https://pypi.python.org/pypi/%s/json' % package
url = repository_url % package
response = utils.get_url(url)
return json.loads(response)['info']['version']

Expand Down

0 comments on commit 1b1941e

Please sign in to comment.