8000 complete refactor by doronz88 · Pull Request #3 · doronz88/applecatalog · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

complete refactor #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ jobs:
python -m pip install -U .
- name: Test query
run: |
python -m applecatalog products list -q
python -m applecatalog list -q
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,47 @@ images, CommandLineTools, XProtect database and just everything you can think of
You can either install using `pip`:

```shell
python3 -m pip install -U --user applecatalog
python3 -m pip install -U applecatalog
```

Or install locally from git:

```shell
git clone git@github.com:doronz88/applecatalog.git
cd applecatalog
python3 -m pip install -U --user -e .
python3 -m pip install -U -e .
```

# Usage

```
Usage: applecatalog [OPTIONS] COMMAND [ARGS]...
Usage: python -m applecatalog [OPTIONS] COMMAND [ARGS]...

Options:
--help Show this message and exit.

Commands:
date last update date
products products options
download download a single product packages
info query info for a single product
list list all products
```

## Example
## Snippets

```shell
# List CommandLineTools
python3 -m applecatalog list -q | grep CLTools

# List macOS
python3 -m applecatalog list --macos

# Download single component (by given PRODUCT_ID)
python3 -m applecatalog download PRODUCT_ID /tmp

```

## Example output

```
➜ dev applecatalog products list
Expand All @@ -62,7 +78,7 @@ Product(id='041-88172', version='2.0.1', title='Dictation Language Update - Chin
Listing macOS images can be done as follows:

```
➜ apple-catalog git:(master) ✗ applecatalog products macos list
➜ apple-catalog git:(master) ✗ applecatalog products list --macos
MacOsProduct(product='061-26578', name=None, build='18F2059', version='10.14.5')
MacOsProduct(product='061-26589', name=None, build='18G103', version='10.14.6')
MacOsProduct(product='041-91758', name=None, build='17G66', version='10.13.6')
Expand Down Expand Up @@ -104,18 +120,3 @@ This should create an `Install macOS XXXXXX.app` application at your `/Applicati
bootable device from this installation you can use the following official guidelines:

https://support.apple.com/en-us/HT201372

# Downloading latest XProtect files

```
➜ apple-catalog git:(master) applecatalog products xprotect download ./xprotect
2021-07-08 12:05:30 DoronZ.local root[24986] DEBUG downloading: XProtectPlistConfigData_10_15.pkg
100%|█████████████████████████████████████████████████████████████████████████████████████████████| 972k/972k [00:00<00:00, 109MiB/s]
➜ apple-catalog git:(master) ✗ ll xprotect
total 4744
-rw-r--r-- 1 z staff 2.0M Jul 8 12:05 LegacyEntitlementAllowlist.plist
-rw-r--r-- 1 z staff 23K Jul 8 12:05 XProtect.meta.plist
-rw-r--r-- 1 z staff 111K Jul 8 12:05 XProtect.plist
-rw-r--r-- 1 z staff 128K Jul 8 12:05 XProtect.yara
-rw-r--r-- 1 z staff 28K Jul 8 12:05 gk.db
```
57 changes: 16 additions & 41 deletions applecatalog/__main__.py
8000
Original file line number Diff line number Diff line change
Expand Up @@ -43,62 +43,37 @@ def date():
print(Catalog().date)


@cli.group()
def products():
""" products options """
pass


@products.command('list')
@cli.command('list')
@click.option('--macos', is_flag=True)
@click.option('-q', '--quick', is_flag=True, help='don\'t require extended information')
def products_list(quick):
def list(macos: bool, quick: bool):
""" list all products """
for product in Catalog().products(detailed=not quick):

catalog = Catalog()
if macos:
for k in catalog.macos_products:
print(k)
return
for product in catalog.products(detailed=not quick):
print(product)


@products.command('download')
@cli.command('download')
@click.argument('product_id')
@click.argument('out_dir', type=click.Path(dir_okay=True, exists=False))
def products_download(product_id: str, out_dir: str):
def download(product_id: str, out_dir: str):
""" download a single product packages """
if not os.path.exists(out_dir):
os.makedirs(out_dir)
out_dir = Path(out_dir)
out_dir.mkdir(exist_ok=True, parents=True)
Catalog().download(product_id, out_dir)


@products.command('info')
@cli.command('info')
@click.argument('product_id')
def products_info(product_id: str):
def info(product_id: str):
""" query info for a single product """
pprint(Catalog().get_product(product_id))


@products.group()
def macos():
""" macos products options """
pass


@macos.command('list')
def macos_list():
""" list all macos products """
for k in Catalog().macos_products:
print(k)


@products.group()
def xprotect():
""" xprotect products options """
pass


@xprotect.command('date')
def xprotect_date():
""" XProtect update date """
product = get_xprotect_product()
print(product.date)


if __name__ == '__main__':
cli()
2 changes: 0 additions & 2 deletions applecatalog/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import Generator, List, Mapping

import requests
from parameter_decorators import str_to_path
from tqdm import tqdm

APPLE_SEED_URL = 'https://swscan.apple.com/content/catalogs/others/index-13-12-10.16-10.15-10.14-10.13-10.12-10.11-' \
Expand Down Expand Up @@ -96,7 +95,6 @@ def macos_products(self) -> Generator[MacOsProductInfo, None, None]:
yield MacOsProductInfo(product=product_id, name=name, build=auxinfo.get('BUILD'),
version=auxinfo.get('VERSION'))

@str_to_path('out_dir')
def download(self, product_id: str, out_dir: Path) -> List[Path]:
results = []
product = self._catalog['Products'][product_id]
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ coloredlogs
tqdm
click
requests
parameter_decorators
0