From a3069a4c6a364617b130b9b7c5207f5f055cc9b7 Mon Sep 17 00:00:00 2001 From: alterNERDtive Date: Wed, 8 Jan 2020 14:54:39 +0100 Subject: [PATCH] new command: `systemlist` Runs an EDSM search query for systems starting with the given string. --- README.md | 18 ++++++++++++++++-- explorationtools.py | 16 ++++++++++++++++ generate_docs.sh | 6 ++++++ pyEDSM | 2 +- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fc2b661..e99211c 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ optional arguments: ## explorationtools.py ## ``` -usage: explorationtools.py [-h] {bodycount,distancebetween,findcommander} ... +usage: explorationtools.py [-h] + {bodycount,distancebetween,findcommander,systemlist} + ... A collection of tools useful for exploration. @@ -42,7 +44,7 @@ optional arguments: -h, --help show this help message and exit subcommands: - {bodycount,distancebetween,findcommander} + {bodycount,distancebetween,findcommander,systemlist} sub-command help bodycount Returns the number of bodies in a system. Will exit with code 1 on server error and code 2 if the system @@ -53,6 +55,8 @@ subcommands: findcommander Attempts to find a CMDR’s last known position. Will exit with code 1 on server error and code 2 if the CMDR could not be found on EDSM. + systemlist Pulls all system names starting with the given string + from EDSM ``` ``` @@ -91,6 +95,16 @@ optional arguments: --url output the commander’s profile URL ``` +``` +usage: explorationtools.py systemlist [-h] partialsystem + +positional arguments: + partialsystem the partial system name to query against + +optional arguments: + -h, --help show this help message and exit +``` + ## Need Help / Want to Contribute? ## Just [file an issue](https://github.com/alterNERDtive/elite-scripts/issues/new) diff --git a/explorationtools.py b/explorationtools.py index 3e1a143..4a521c5 100755 --- a/explorationtools.py +++ b/explorationtools.py @@ -29,6 +29,15 @@ def getCommanderProfileUrl(name, apikey): def getCommanderSystem(name, apikey): return Commander(name, apikey).currentSystem +def getSystemList(name): + ret = "" + + systems = System.getSystems(name) + for system in systems: + ret += "{}\n".format(system.name) + + return ret[:-1] + # =========================================================================== parser = argparse.ArgumentParser(description="A collection of tools useful for " @@ -61,6 +70,11 @@ parser_find.add_argument("name", help="the commander in question") parser_find.add_argument("apikey", default="", nargs="?", help="the commander’s EDSM API key. Can be empty for public profiles.") +parser_bodycount = subparsers.add_parser("systemlist", + help="Pulls all system names starting with the given string from EDSM") +parser_bodycount.add_argument("partialsystem", nargs=1, + help="the partial system name to query against") + argcomplete.autocomplete(parser) args = parser.parse_args() @@ -78,6 +92,8 @@ try: out = getCommanderProfileUrl(args.name, args.apikey) else: out = getCommanderSystem(args.name, args.apikey) + elif args.subCommand == "systemlist": + out = getSystemList(args.partialsystem) except ServerError as e: print(e) sys.exit(1) diff --git a/generate_docs.sh b/generate_docs.sh index fc62a6c..727973f 100644 --- a/generate_docs.sh +++ b/generate_docs.sh @@ -47,6 +47,12 @@ EOF cat >> README.md << EOF \`\`\` +\`\`\` +EOF +./explorationtools.py systemlist -h >> README.md +cat >> README.md << EOF +\`\`\` + ## Need Help / Want to Contribute? ## Just [file an issue](https://github.com/alterNERDtive/elite-scripts/issues/new) diff --git a/pyEDSM b/pyEDSM index 318ad17..b476c34 160000 --- a/pyEDSM +++ b/pyEDSM @@ -1 +1 @@ -Subproject commit 318ad170111f95395a4cf9c16222f180ab4c1c0a +Subproject commit b476c34de50e6a76f93a522140acbf3536f18728