Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Commit ec4f406

Browse files
authored
Merge pull request #58 from grrttedwards/feature/57/cmd-line-configfile
Feature/57/cmd line configfile
2 parents 6eb9f75 + d68c245 commit ec4f406

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

README.md

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22

33
This utility provides an alternative to the Twitch/Curse client for management and updating of addons for World of Warcraft. The Twitch/Curse client is rather bloated and buggy, and comes with many features that most users will not ever use in the first place. This utility, however, is lightweight and makes it very easy to manage which addons are being updated, and to update them just by running a python script.
44

5+
_Now supporting both retail and classic addon management!_
6+
57
[![Build Status](https://travis-ci.com/grrttedwards/wow-addon-updater.svg?branch=master)](https://travis-ci.com/grrttedwards/wow-addon-updater)
68

79
## First-time setup
810

9-
This utility has two dependencies:
11+
You must have a version of [Python](https://www.python.org/) 3.6+.
12+
13+
This utility has two external dependencies:
1014

11-
* A version of [Python](https://www.python.org/) 3.6+
12-
* The [requests](http://docs.python-requests.org/en/master/) module
15+
- The [requests](https://pypi.org/project/requests/) module, for making HTTP requests
16+
- The [BeautifulSoup4](https://pypi.org/project/beautifulsoup4/) module, for HTML document parsing
1317

1418
The install should be managed by [`pipenv`](https://github.com/pypa/pipenv). All you need to do is run the following:
1519

@@ -26,19 +30,39 @@ After performing the setup steps, `pipenv run` is used to execute the utility. T
2630
pipenv run python -m updater
2731
```
2832

33+
More advanced usage includes specifying the configuration file, which is detailed in the next section.
34+
2935
## Configuring the utility
3036

31-
The `config.ini` file is used by the utility to find where to install the addons to, and where to get the list of addons from.
37+
The `config.ini` file is used by default to find where to install the addons to, and where to get the list of addons from.
3238

33-
The default location in Windows to install the addons to is `C:\Program Files (x86)\World of Warcraft\_retail_\Interface\AddOns`. If this is not the location where you have World of Warcraft installed, you will need to edit `config.ini` to point to your addons folder.
39+
It requires that some properties be set, if you do not want to use the defaults such as:
3440

35-
The standard addon location on macOS is `/Applications/World of Warcraft/Interface/AddOns`
41+
- `WoW Addon Location`
42+
- The WoW application files addon directory
43+
- (The standard addon location on macOS is `/Applications/World of Warcraft/Interface/AddOns`)
44+
- (default `= C:\Program Files (x86)\World of Warcraft\_retail_\Interface\AddOns`)
3645

37-
The default name of the addon list file is `addons.txt`, but this file will not exist on your PC, so you should either create `addons.txt` in the same location as the utility, or name the file something else and edit "config.ini" to point to the new file.
46+
- `Addon List File`
47+
- A file specifying which addons to install and/or update
48+
- This file will not exist at first, so you should create `addons.txt` in the same directory as the utility.
49+
- (default `= addons.txt`)
3850

39-
The `Installed Versions File` property determines where to store the file that keeps track of the current versions of your addons.
51+
- `Installed Versions File`
52+
- A file which tracks your installed addon versions
53+
- (default `= installed.ini`)
4054

41-
The game version that you would like to target addons for must be specified in the `Game Version` property. The two options are `retail` or `classic`.
55+
- `Game Version`
56+
- The game version (either `retail` or `classic`) that you would like to target for addons
57+
- (default `= retail`)
58+
59+
### Multiple configurations
60+
The module supports a command-line configuration for maintaining multiple set of addons. For example, a set of addons for retail, and a different set of addons for classic.
61+
To use a different configuration file, specify it with the `--config` flag (or `-c`) e.g.
62+
63+
```bash
64+
pipenv run python -m updater -c my-custom-config.ini
65+
```
4266

4367
## Supported addon hosts
4468
The following hosts are supported as download targets. The URL specified should be to the main page of the addon, or in the case of GitHub, to the root of the repository.

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Changelog
22

3+
* 8/31/2019
4+
Add command-line argument for specifying a configuration file. Now multiple independent configurations can be used i.e. one for retail, and one for classic.
5+
36
* 8/31/2019
47
Enhance support for Curse classic-only addons. Now those addons can download if the page only supports one release, and that release is the classic game version.
58

test/manager/test_addon_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def setUp(self):
3737
self.mock_site = MockSite(TEST_URL, GameVersion.agnostic)
3838
patcher = patch('updater.manager.addon_manager.site_handler.get_handler')
3939
patcher.start().return_value = self.mock_site
40-
with patch.object(addon_manager.AddonManager, "__init__", lambda x: None):
41-
self.manager = addon_manager.AddonManager()
40+
with patch.object(addon_manager.AddonManager, "__init__", lambda x, y: None):
41+
self.manager = addon_manager.AddonManager('config.ini')
4242
self.manager.manifest = []
4343
self.manager.get_installed_version = Mock(return_value=EXP_INST_VERSION)
4444
self.manager.game_version = GameVersion.retail

updater/__main__.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import argparse
12
from os.path import isfile
23

34
import requests
@@ -25,7 +26,14 @@ def check_version():
2526

2627
def main():
2728
check_version()
28-
AddonManager().update_all()
29+
30+
parser = argparse.ArgumentParser(description='Update your WoW addons.')
31+
parser.add_argument('-c', '--config', nargs='?', default='config.ini', type=str, metavar='FILE',
32+
help='the file to be used for configuration')
33+
34+
args = parser.parse_args()
35+
36+
AddonManager(args.config).update_all()
2937

3038

3139
if __name__ == "__main__":

updater/manager/addon_manager.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,16 @@ def error(message: str):
2121

2222
class AddonManager:
2323
_UNAVAILABLE = 'Unavailable'
24-
_CONFIG_FILE = 'config.ini'
2524

26-
def __init__(self):
25+
def __init__(self, config_file):
2726
self.manifest = []
2827

2928
# Read config file
30-
if not isfile(AddonManager._CONFIG_FILE):
31-
error(f"Failed to read config file. Are you sure there is a file called {AddonManager._CONFIG_FILE}?")
29+
if not isfile(config_file):
30+
error(f"Failed to read config file. Are you sure there is a file called {config_file}?")
3231

3332
config = configparser.ConfigParser()
34-
config.read(AddonManager._CONFIG_FILE)
33+
config.read(config_file)
3534

3635
try:
3736
self.wow_addon_location = config['WOW ADDON UPDATER']['WoW Addon Location']

0 commit comments

Comments
 (0)