Skip to content

Commit

Permalink
Merge pull request #210 from Crinibus/refactor-visualizing
Browse files Browse the repository at this point in the history
Refactor visualize.py
  • Loading branch information
Crinibus authored Feb 16, 2023
2 parents 6443514 + 8768c89 commit f72ec48
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 255 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ To visualize your data, just run main.py with the ```-v``` or ```--visualize```
- ```-c [<category> [<category> ...]]``` or ```--category [<category> [<category> ...]]``` to visualize all products in one or more categories
- ```--id [<id> [<id> ...]]``` to visualize one or more products with the specified id(s)
- ```-n [<name> [<name> ...]]``` or ```--name [<name> ...]]``` to visualize one or more products with the specified name(s)
- ```--compare``` to compare two or more products with the specified id(s) and/or name(s) on one graph. Use with ```--id``` and/or ```--name```
- ```--compare``` to compare two or more products with the specified id(s), name(s) and/or category(s) on one graph. Use with ```--id```, ```--name``` and/or ```--category```

### Example graph
![](https://user-images.githubusercontent.com/57172157/171033112-908f6420-6c7a-44ef-ba67-8a4a73bbd96e.png)
Expand Down Expand Up @@ -359,15 +359,18 @@ python3 main.py -v -c <category> -utd

**Compare two products**

To compare two products on one graph, use the flag ```--compare``` with flag ```--id``` and/or ```--name```, like so:
To compare two products on one graph, use the flag ```--compare``` with flag ```--id```, ```--name``` and/or ```--category``` , like so:
```
python3 main.py -v --compare --id <id>
```
```
python3 main.py -v --compare --name <name>
```
```
python3 main.py -v --compare --id <id> --name <name>
python3 main.py -v --compare --category <category>
```
```
python3 main.py -v --compare --id <id> --name <name> --category <category>
```

***OBS** when using ```--name``` multiple products can be visualized*
***OBS** when using ```--name``` or ```--category``` multiple products can be visualized*
10 changes: 7 additions & 3 deletions scraper/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,13 @@ def validate_arguments(parser: argparse.ArgumentParser) -> argparse.Namespace:

if args.visualize:
if not any([args.all, args.category, args.id, args.name, args.compare]):
parser.error("When using --visualize, then one of the following is required: --all, --category, --id, --name")
if args.compare and not any([args.id, args.name]):
parser.error("When using --visualize and --compare, then one of the following is required: --id, --name")
parser.error(
"When using --visualize, then one of the following is required: --all, --category, --id, --name, --compare"
)
if args.compare and not any([args.id, args.name, args.category]):
parser.error(
"When using --visualize and --compare, then one of the following is required: --id, --name, --category"
)

if args.latest_datapoint:
if not args.name and not args.id:
Expand Down
Loading

0 comments on commit f72ec48

Please sign in to comment.