Skip to content

Commit a86de88

Browse files
committed
formating
1 parent 639b854 commit a86de88

5 files changed

Lines changed: 24 additions & 21 deletions

File tree

devpack/__init__.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,15 @@
3131
# "PACKAGE_DATA_PATH"
3232
]
3333

34-
35-
def dist_is_editable(dist: Any) -> bool:
36-
"""
37-
Return True if given Distribution is an editable installation."""
38-
import sys
39-
from pathlib import Path
40-
41-
for path_item in sys.path:
42-
egg_link = Path(path_item) / f"{dist.project_name}.egg-link"
43-
if egg_link.is_file():
44-
return True
45-
return False
46-
47-
4834
PROJECT_NAME = __project__.lower().strip().replace(" ", "_")
4935
PROJECT_VERSION = __version__
5036
PROJECT_YEAR = 2018
5137
PROJECT_AUTHOR = __author__.lower().strip().replace(" ", "_")
5238
PROJECT_APP_PATH = AppPath(app_name=PROJECT_NAME, app_author=PROJECT_AUTHOR)
5339
PROJECT_ORGANISATION = "pything"
5440

41+
from warg import dist_is_editable
42+
5543
distributions = {v.key: v for v in pkg_resources.working_set}
5644
if PROJECT_NAME in distributions:
5745
distribution = distributions[PROJECT_NAME]

devpack/batch_tools/privates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from typing import Optional, Callable, Iterable
1616

1717
from draugr.os_utilities.linux_utilities.user_utilities import get_username
18+
1819
from warg.os_utilities.filtering import is_python_module, negate
1920

2021

devpack/entry_points/versioning.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import argparse
22
from pathlib import Path
33

4-
from devpack.versioning_tools.bump import version_bump
5-
64

75
def bump():
86
"""

devpack/versioning_tools/bump.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
from enum import Enum
12
from pathlib import Path
3+
24
from sorcery import assigned_names
3-
from enum import Enum
45

56

67
class BumpOrderEnum(Enum):
@@ -10,15 +11,18 @@ class BumpOrderEnum(Enum):
1011

1112

1213
def bump_version_import(
13-
module_name: str, package: str = None, order: BumpOrderEnum = BumpOrderEnum.patch
14+
module_name: str,
15+
package: str = None,
16+
order: BumpOrderEnum = BumpOrderEnum.patch,
17+
reset_lower_order: bool = True,
1418
) -> str:
1519
import importlib
1620

1721
module = importlib.import_module(module_name, package)
1822

1923
version = module.__version__
2024

21-
return version_bump(version)
25+
return version_bump(version, reset_lower_order=reset_lower_order)
2226

2327

2428
def version_partition(version: str) -> str:
@@ -36,11 +40,17 @@ def version_partition(version: str) -> str:
3640
return (version,)
3741

3842

39-
def version_bump(version: str, order: BumpOrderEnum = BumpOrderEnum.patch) -> str:
43+
def version_bump(
44+
version: str,
45+
order: BumpOrderEnum = BumpOrderEnum.patch,
46+
reset_lower_order: bool = True,
47+
) -> str:
4048
# TODO: HANDLE weird alpha, beta, rc versioning e.g. 1.2a, 12.3.alpha, 1.2.3.4rc
4149

4250
partitioned = version_partition(version)
4351

52+
# TODO: USE reset_lower_order!
53+
4454
if len(partitioned) == 1:
4555
return str(int(partitioned[0]) + 1)
4656

@@ -71,6 +81,9 @@ def version_bump(version: str, order: BumpOrderEnum = BumpOrderEnum.patch) -> st
7181
pre = str(pre) + "."
7282

7383
if post != "":
84+
if reset_lower_order:
85+
post = ".".join(["0" for p in post.split(".")])
86+
7487
post = "." + str(post)
7588

7689
return pre + str(int(ordered) + 1) + post
@@ -110,5 +123,7 @@ def ujhasduhau():
110123
print(version_bump("1.2", order=e))
111124
print(version_bump("1.2.3", order=e))
112125
print(version_bump("1.2.3.4", order=e))
126+
print("_")
127+
print(version_bump("1.2.3.4", order=e, reset_lower_order=False))
113128

114129
ujhasduhau()

samples/imports.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import apppath
21
import draugr
2+
3+
import apppath
34
import warg
45

56
print(warg.__version__)

0 commit comments

Comments
 (0)