forked from flathunters/flathunter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request flathunters#369 from mrclrchtr/main
Add possibility to start main.py with config.yml
- Loading branch information
Showing
3 changed files
with
44 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"""Parser for some startup arguments""" | ||
|
||
import argparse | ||
import os | ||
|
||
from flathunter.config import Env | ||
|
||
|
||
def parse(): | ||
"""Processes and return command-line arguments""" | ||
parser = argparse.ArgumentParser( | ||
description=("Searches for flats on Immobilienscout24.de and wg-gesucht.de" | ||
" and sends results to Telegram User"), | ||
epilog="Designed by Nody" | ||
) | ||
if Env.FLATHUNTER_TARGET_URLS is not None: | ||
default_config_path = None | ||
else: | ||
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
default_config_path = f"{root_dir}/config.yaml" | ||
parser.add_argument('--config', '-c', | ||
type=argparse.FileType('r', encoding='UTF-8'), | ||
default=default_config_path, | ||
help=f'Config file to use. If not set, try to use "{default_config_path}"' | ||
) | ||
parser.add_argument('--heartbeat', '-hb', | ||
action='store', | ||
default=None, | ||
help=('Set the interval time to receive heartbeat messages to check' | ||
'that the bot is alive. Accepted strings are "hour", "day", "week".' | ||
'Defaults to None.') | ||
) | ||
return parser.parse_args() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters