aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2023-09-13 13:51:37 -0400
committerGitHub <noreply@github.com>2023-09-13 13:51:37 -0400
commit6d2ad5ec316d313de5e181613daaff3cd95f3f23 (patch)
treee1300b6d9dff6f0483c7750cac0ce27715985d70
parent3a5f5e528d13d30e0b240edb19859c4cf570e9b3 (diff)
parentee7de4593594013ca117bd9b72da44ab1e731c73 (diff)
downloadfirewatch-6d2ad5ec316d313de5e181613daaff3cd95f3f23.tar.gz
Merge pull request #5 from jhunkeler/conda-style-packagesHEAD0.0.4master
Add ability to display .conda packages
-rw-r--r--README.md21
-rw-r--r--firewatch/firewatch.py18
2 files changed, 33 insertions, 6 deletions
diff --git a/README.md b/README.md
index a547c76..0dc15bc 100644
--- a/README.md
+++ b/README.md
@@ -18,23 +18,28 @@ This utility requires Python 3.6 or greater and `requests`.
## Usage
```
-$ firewatch --help
-usage: firewatch [-h] [--benchmark] [--brute-force] [--channel CHANNELS]
- [--order ORDER] [--platform PLATFORMS]
- [--time-span TIME_SPAN]
+usage: firewatch [-h] [--benchmark] [--brute-force] [--channel CHANNELS] [--deprecated] [--order ORDER]
+ [--platform PLATFORMS] [--r-lang] [--time-span TIME_SPAN] [--version]
+ [package ...]
-optional arguments:
+positional arguments:
+ package Return package starting with pattern PACKAGE
+
+options:
-h, --help show this help message and exit
--benchmark Display total time to parse and sort channel data
--brute-force Derive timestamps from HTTP header: "last-modified"
--channel CHANNELS, -c CHANNELS
Conda channel
+ --deprecated, -d Enable deprecated Anaconda, Inc. channel(s)
--order ORDER, -o ORDER
[asc|dsc]
--platform PLATFORMS, -p PLATFORMS
[linux|osx|win]-[32|64]
+ --r-lang, -R Enable R channels
--time-span TIME_SPAN, -t TIME_SPAN
i[s|m|h|d|w|M|y|D|c] (120s, 12h, 1d, 2w, 3m, 4y)
+ --version, -V Display software version
```
@@ -66,4 +71,10 @@ $ firewatch -t 3d -c conda-forge -c intel
$ firewatch -t 1M -c http://ssb.stsci.edu/astroconda
```
+_What about showing only certain packages?_
+
+You are in luck. Issue package name(s) as positional arguments.
+```
+$ firewatch -c conda-forge cfitsio hstcal
+```
diff --git a/firewatch/firewatch.py b/firewatch/firewatch.py
index 9d0ca7b..8da1f95 100644
--- a/firewatch/firewatch.py
+++ b/firewatch/firewatch.py
@@ -75,9 +75,12 @@ def get_packages(channels):
)
try:
+ print(f"Retrieving {channel}", file=sys.stderr)
with requests.get(repodata) as r:
r.raise_for_status()
- data['packages'] = json.loads(r.text)['packages']
+ remote = json.loads(r.text)
+ data['packages'] = remote['packages']
+ data['packages'].update(remote['packages.conda'])
packages.append(data)
except requests.exceptions.RequestException as e:
@@ -180,6 +183,9 @@ def main():
from argparse import ArgumentParser
parser = ArgumentParser()
+ parser.add_argument('package', default=[], nargs='*',
+ help='Return package starting with pattern PACKAGE')
+
parser.add_argument('--benchmark', action='store_true',
help='Display total time to parse and sort channel data')
@@ -260,6 +266,16 @@ def main():
chn = info['channel']
tstr = ts.isoformat()
+
+ has_package = False
+ if args.package:
+ for p in args.package:
+ if name.startswith(p):
+ has_package = True
+
+ if not has_package:
+ continue
+
if span_delta < ts:
try:
print(f'{tstr:<20s}: {chn:<{channel_width}s}: {name:<40s}')