Skip to content
This repository has been archived by the owner on Dec 18, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from MousaZeidBaker/fix_dependency_containing_…
Browse files Browse the repository at this point in the history
…capital_letters

fix for dependencies containing capital letters
  • Loading branch information
MousaZeidBaker authored Oct 13, 2021
2 parents 92d021c + f99222e commit 91f695c
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "poetryup"
version = "0.3.5"
version = "0.3.6"
description = "Update dependencies and bump their version in the pyproject.toml file"
authors = ["Mousa Zeid Baker"]
packages = [
Expand Down
20 changes: 11 additions & 9 deletions src/poetryup/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Any

from tomlkit.items import Table
from tomlkit.items import String, Table


def lookup_tomlkit_table(table: Table, key: str) -> Any:
Expand All @@ -16,8 +16,9 @@ def lookup_tomlkit_table(table: Table, key: str) -> Any:
Any: The value of the key if found, None otherwise
"""

if key in table:
return table[key]
for item_key, item_value in table.items():
if item_key.lower() == key and type(item_value) == String:
return item_value

for value in table.values():
if type(value) is Table:
Expand All @@ -40,13 +41,14 @@ def update_tomlkit_table(table: Table, key: str, new_value: Any) -> bool:
Any: True if key found and value updated, False otherwise
"""

if key in table:
table[key] = new_value
return True
for item_key, item_value in table.items():
if item_key.lower() == key and type(item_value) == String:
table[item_key] = new_value
return True

for value in table.values():
if type(value) is Table:
updated = update_tomlkit_table(table=value, key=key, new_value=new_value)
for item_value in table.values():
if type(item_value) is Table:
updated = update_tomlkit_table(table=item_value, key=key, new_value=new_value)
if updated is True:
return True

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[tool.poetry]
name = "test-poetryup"
version = "0.1.0"
description = "Test PoetryUp"
authors = ["Mousa Zeid Baker"]
packages = [
{ include = "test_poetryup", from = "src" }
]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/MousaZeidBaker/poetryup"
repository = "https://github.com/MousaZeidBaker/poetryup"
keywords=[
"packaging",
"dependency",
"poetry",
"poetryup",
]
include = ["LICENSE"]

[tool.poetry.dependencies]
python = "^3.6"
PoetryUp = "^0.2.0"

[tool.poetry.dev-dependencies]

[tool.poetry.scripts]
poetryup = "src.test_poetryup.test_poetryup:main"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[tool.poetry]
name = "test-poetryup"
version = "0.1.0"
description = "Test PoetryUp"
authors = ["Mousa Zeid Baker"]
packages = [
{ include = "test_poetryup", from = "src" }
]
license = "MIT"
readme = "README.md"
homepage = "https://github.com/MousaZeidBaker/poetryup"
repository = "https://github.com/MousaZeidBaker/poetryup"
keywords=[
"packaging",
"dependency",
"poetry",
"poetryup",
]
include = ["LICENSE"]

[tool.poetry.dependencies]
python = "^3.6"
PoetryUp = "^0.1.0"

[tool.poetry.dev-dependencies]

[tool.poetry.scripts]
poetryup = "src.test_poetryup.test_poetryup:main"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 91f695c

Please sign in to comment.