From fceb9263e7b9dccc0ec90309c983ab6a7fba812e Mon Sep 17 00:00:00 2001 From: "Jules Lasne (jlasne)" Date: Fri, 14 Dec 2018 00:12:36 +0100 Subject: [PATCH] Fixed argparse and ran black --- .gitignore | 3 +++ potodo/__init__.py | 4 +++- potodo/__main__.py | 4 +++- potodo/potodo.py | 51 ++++++++++++++++++++++++++++++---------------- setup.py | 2 +- 5 files changed, 44 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 894a44c..6f1ca70 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,6 @@ venv.bak/ # mypy .mypy_cache/ + +venv +.idea \ No newline at end of file diff --git a/potodo/__init__.py b/potodo/__init__.py index a9b2ec5..6d0a5ef 100644 --- a/potodo/__init__.py +++ b/potodo/__init__.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 + __author__ = """Jules Lasne""" __email__ = "jules.lasne@gmail.com" -__version__ = "0.0.1" \ No newline at end of file +__version__ = "0.0.2" diff --git a/potodo/__main__.py b/potodo/__main__.py index 259d881..8bef5bd 100644 --- a/potodo/__main__.py +++ b/potodo/__main__.py @@ -1 +1,3 @@ -__import__("potodo.potodo").potodo.main() \ No newline at end of file +#!/usr/bin/env python3 + +__import__("potodo.potodo").potodo.main() diff --git a/potodo/potodo.py b/potodo/potodo.py index f5585a4..2511089 100644 --- a/potodo/potodo.py +++ b/potodo/potodo.py @@ -1,4 +1,4 @@ -#!/bin/python3 +#!/usr/bin/env python3 import sys import argparse @@ -25,9 +25,7 @@ def get_gh_issue_reservation(repo: str): :return: Returns a dict containing all issues with `title:login` """ - issues = requests.get( - "https://api.github.com/repos/" + repo + "/issues" - ).json() + issues = requests.get("https://api.github.com/repos/" + repo + "/issues").json() reservations = { issue["title"].split()[-1].lower(): issue["user"]["login"] for issue in issues } @@ -76,7 +74,9 @@ def exec_potodo(path: str, above: int, below: int, repo: str): is_above = False is_below = False else: - raise ValueError("Unexpected error occuped when processing values for above and below.") + raise ValueError( + "Unexpected error occuped when processing values for above and below." + ) if repo: issue_reservations = get_gh_issue_reservation(repo) @@ -108,10 +108,12 @@ def exec_potodo(path: str, above: int, below: int, repo: str): printed_list.append(False) continue else: - raise ValueError("Unexpected error: is_above/is_below values shouldn't be like this") + raise ValueError( + "Unexpected error: is_above/is_below values shouldn't be like this" + ) - t = str(po_file).split('/')[-2:] - po_file_name = t[0] + '/' + t[1] + t = str(po_file).split("/")[-2:] + po_file_name = t[0] + "/" + t[1] buffer.append( f"- {po_file.name:<30} " @@ -146,23 +148,38 @@ def main(): """ parser = argparse.ArgumentParser( - prog="potodo", - description="List and prettify the po files left to translate", + prog="potodo", description="List and prettify the po files left to translate" ) - parser.add_argument("-p", "--path", type=str, - help="REQUIRED: Execute Potodo in the given path", required=True) + parser.add_argument( + 'path', + type=Path, + help="Execute Potodo in the given path", + ) - parser.add_argument("-r", "--repo", type=str, - help="REQUIRED: Repo in the form of ORG/REPO to display if translation is reserved in issues", required=True) + parser.add_argument( + 'repo', + type=str, + help="Repo in the form of ORG/REPO to display if translation is reserved in issues", + ) group = parser.add_mutually_exclusive_group() - group.add_argument('-a', '--above', type=int, help="Will list all TODOs ABOVE given INT%% completion") - group.add_argument('-b', '--below', type=int, help="Will list all TODOs BELOW given INT%% completion") + group.add_argument( + "-a", + "--above", + type=int, + help="Will list all TODOs ABOVE given INT%% completion", + ) + group.add_argument( + "-b", + "--below", + type=int, + help="Will list all TODOs BELOW given INT%% completion", + ) args = parser.parse_args() if not args.path: - path = '.' + path = "." else: path = str(args.path) diff --git a/setup.py b/setup.py index 9bc4905..93158b8 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ with open("README.md") as readme: setuptools.setup( name="potodo", - version="0.0.1", + version="0.0.2", description="Will list all .po files that are to be transated", long_description=long_description, long_description_content_type="text/markdown", # This is important!