Renamed "fh" to "fp" when opening files, following the Python convention.
This commit is contained in:
		| @@ -35,8 +35,8 @@ def init_base_accounts_command() -> None: | |||||||
|         click.echo("Base accounts already exist.") |         click.echo("Base accounts already exist.") | ||||||
|         raise click.Abort |         raise click.Abort | ||||||
|  |  | ||||||
|     with open(data_dir / "base_accounts.csv") as fh: |     with open(data_dir / "base_accounts.csv") as fp: | ||||||
|         data: list[dict[str, str]] = [x for x in csv.DictReader(fh)] |         data: list[dict[str, str]] = [x for x in csv.DictReader(fp)] | ||||||
|     account_data: list[dict[str, str]] = [{"code": x["code"], |     account_data: list[dict[str, str]] = [{"code": x["code"], | ||||||
|                                            "title_l10n": x["title"]} |                                            "title_l10n": x["title"]} | ||||||
|                                           for x in data] |                                           for x in data] | ||||||
|   | |||||||
| @@ -58,8 +58,8 @@ def init_currencies_command(username: str) -> None: | |||||||
|     """Initializes the currencies.""" |     """Initializes the currencies.""" | ||||||
|     existing_codes: set[str] = {x.code for x in Currency.query.all()} |     existing_codes: set[str] = {x.code for x in Currency.query.all()} | ||||||
|  |  | ||||||
|     with open(data_dir / "currencies.csv") as fh: |     with open(data_dir / "currencies.csv") as fp: | ||||||
|         data: list[dict[str, str]] = [x for x in csv.DictReader(fh)] |         data: list[dict[str, str]] = [x for x in csv.DictReader(fp)] | ||||||
|     to_add: list[dict[str, str]] = [x for x in data |     to_add: list[dict[str, str]] = [x for x in data | ||||||
|                                     if x["code"] not in existing_codes] |                                     if x["code"] not in existing_codes] | ||||||
|     if len(to_add) == 0: |     if len(to_add) == 0: | ||||||
|   | |||||||
| @@ -57,13 +57,13 @@ class BaseAccountCommandTestCase(unittest.TestCase): | |||||||
|         from accounting import data_dir |         from accounting import data_dir | ||||||
|         from accounting.models import BaseAccount |         from accounting.models import BaseAccount | ||||||
|  |  | ||||||
|         with open(data_dir / "base_accounts.csv") as fh: |         with open(data_dir / "base_accounts.csv") as fp: | ||||||
|             data: dict[dict[str, t.Any]] \ |             data: dict[dict[str, t.Any]] \ | ||||||
|                 = {x["code"]: {"code": x["code"], |                 = {x["code"]: {"code": x["code"], | ||||||
|                                "title": x["title"], |                                "title": x["title"], | ||||||
|                                "l10n": {y[5:]: x[y] |                                "l10n": {y[5:]: x[y] | ||||||
|                                         for y in x if y.startswith("l10n-")}} |                                         for y in x if y.startswith("l10n-")}} | ||||||
|                    for x in csv.DictReader(fh)} |                    for x in csv.DictReader(fp)} | ||||||
|  |  | ||||||
|         runner: FlaskCliRunner = self.app.test_cli_runner() |         runner: FlaskCliRunner = self.app.test_cli_runner() | ||||||
|         result: Result = runner.invoke(args="accounting-init-base") |         result: Result = runner.invoke(args="accounting-init-base") | ||||||
|   | |||||||
| @@ -88,13 +88,13 @@ class CurrencyCommandTestCase(unittest.TestCase): | |||||||
|         from accounting import data_dir |         from accounting import data_dir | ||||||
|         from accounting.models import Currency |         from accounting.models import Currency | ||||||
|  |  | ||||||
|         with open(data_dir / "currencies.csv") as fh: |         with open(data_dir / "currencies.csv") as fp: | ||||||
|             data: dict[dict[str, t.Any]] \ |             data: dict[dict[str, t.Any]] \ | ||||||
|                 = {x["code"]: {"code": x["code"], |                 = {x["code"]: {"code": x["code"], | ||||||
|                                "name": x["name"], |                                "name": x["name"], | ||||||
|                                "l10n": {y[5:]: x[y] |                                "l10n": {y[5:]: x[y] | ||||||
|                                         for y in x if y.startswith("l10n-")}} |                                         for y in x if y.startswith("l10n-")}} | ||||||
|                    for x in csv.DictReader(fh)} |                    for x in csv.DictReader(fp)} | ||||||
|  |  | ||||||
|         runner: FlaskCliRunner = self.app.test_cli_runner() |         runner: FlaskCliRunner = self.app.test_cli_runner() | ||||||
|         with self.app.app_context(): |         with self.app.app_context(): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user