Skip to content

Commit 324976e

Browse files
pushpit kambojpushpit kamboj
authored andcommitted
[releaser] removed all the blank lines
1 parent e86bb29 commit 324976e

File tree

2 files changed

+0
-28
lines changed

2 files changed

+0
-28
lines changed

openwisp_utils/releaser/config.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,16 @@ def get_package_type_from_setup():
2727
".ansible-lint": "ansible",
2828
".luacheckrc": "openwrt-agents",
2929
}
30-
3130
for filename, package_type in package_type_files.items():
3231
if os.path.exists(filename):
3332
return package_type
34-
3533
return None
3634

3735

3836
def detect_changelog_style(changelog_path):
3937
# Detects if the changelog uses the 'Version ' prefix for its entries
4038
if not os.path.exists(changelog_path):
4139
return True
42-
4340
with open(changelog_path, "r", encoding="utf-8") as f:
4441
content = f.read()
4542
# Look for a line that starts with 'Version X.Y.Z'
@@ -57,12 +54,10 @@ def _handle_python_version(config):
5754
project_name = get_package_name_from_setup()
5855
if not project_name:
5956
return
60-
6157
package_directory = project_name.replace("-", "_")
6258
init_py_path = os.path.join(package_directory, "__init__.py")
6359
if not os.path.exists(init_py_path):
6460
return
65-
6661
with open(init_py_path, "r") as f:
6762
content = f.read()
6863
version_match = re.search(r"^VERSION\s*=\s*\((.*)\)", content, re.M)
@@ -79,13 +74,11 @@ def _handle_npm_version(config):
7974
"""Handles version detection for NPM packages."""
8075
if not os.path.exists("package.json"):
8176
return
82-
8377
with open("package.json", "r") as f:
8478
content = json.load(f)
8579
version_str = content.get("version")
8680
if not version_str:
8781
return
88-
8982
config["version_path"] = "package.json"
9083
try:
9184
if "-" in version_str:
@@ -94,13 +87,11 @@ def _handle_npm_version(config):
9487
version_tuple, version_type = version_str.split("_", 1)
9588
else:
9689
version_tuple, version_type = version_str, "final"
97-
9890
parts = version_tuple.split(".")
9991
if len(parts) < 3:
10092
raise ValueError(
10193
f"Version '{version_str}' does not have expected 3 parts (X.Y.Z)"
10294
)
103-
10495
config["CURRENT_VERSION"] = [
10596
int(parts[0]),
10697
int(parts[1]),
@@ -115,23 +106,20 @@ def _handle_docker_version(config):
115106
"""Handles version detection for Docker packages."""
116107
if not os.path.exists("Makefile"):
117108
return
118-
119109
with open("Makefile", "r") as f:
120110
content = f.read()
121111
version_match = re.search(
122112
r"^OPENWISP_VERSION\s*=\s*([^\s]+)", content, re.MULTILINE
123113
)
124114
if not version_match:
125115
return
126-
127116
config["version_path"] = "Makefile"
128117
version_str = version_match.group(1)
129118
parts = version_str.split(".")
130119
if len(parts) < 3:
131120
raise ValueError(
132121
f"Version '{version_str}' does not have expected 3 parts (X.Y.Z)"
133122
)
134-
135123
config["CURRENT_VERSION"] = [
136124
int(parts[0]),
137125
int(parts[1]),
@@ -145,7 +133,6 @@ def _handle_ansible_version(config):
145133
version_py_path = os.path.join("templates", "openwisp2", "version.py")
146134
if not os.path.exists(version_py_path):
147135
return
148-
149136
with open(version_py_path, "r") as f:
150137
content = f.read()
151138
version_match = re.search(
@@ -155,7 +142,6 @@ def _handle_ansible_version(config):
155142
)
156143
if not version_match:
157144
return
158-
159145
config["version_path"] = version_py_path
160146
try:
161147
version_str = version_match.group(1)
@@ -164,7 +150,6 @@ def _handle_ansible_version(config):
164150
raise ValueError(
165151
f"Version '{version_str}' does not have expected 3 parts (X.Y.Z)"
166152
)
167-
168153
config["CURRENT_VERSION"] = [
169154
int(parts[0]),
170155
int(parts[1]),
@@ -179,19 +164,16 @@ def _handle_openwrt_agents_version(config):
179164
"""Handles version detection for OpenWRT agents packages."""
180165
if not os.path.exists("VERSION"):
181166
return
182-
183167
with open("VERSION", "r") as f:
184168
version_str = f.read().strip()
185169
if not version_str:
186170
return
187-
188171
config["version_path"] = "VERSION"
189172
parts = version_str.split(".")
190173
if len(parts) < 3:
191174
raise ValueError(
192175
f"Version '{version_str}' does not have expected 3 parts (X.Y.Z)"
193176
)
194-
195177
config["CURRENT_VERSION"] = [
196178
int(parts[0]),
197179
int(parts[1]),
@@ -229,11 +211,9 @@ def load_config():
229211
config["repo"] = "/".join(repo_path.split("/")[-2:])
230212
except (subprocess.CalledProcessError, FileNotFoundError):
231213
config["repo"] = None
232-
233214
config["version_path"] = None
234215
config["CURRENT_VERSION"] = None
235216
config["package_type"] = get_package_type_from_setup()
236-
237217
# Use handler function if available for the detected package type
238218
handler = PACKAGE_VERSION_HANDLERS.get(config["package_type"])
239219
if handler:

openwisp_utils/releaser/version.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ def get_current_version(config):
1212
if not current_version:
1313
# Return None if CURRENT_VERSION is missing, allowing the main script to handle it
1414
return None, None
15-
1615
try:
1716
major, minor, patch = (
1817
current_version[0],
@@ -38,7 +37,6 @@ def _bump_with_regex(content, pattern, replacement, version_path, error_msg):
3837
)
3938
if count == 0:
4039
raise RuntimeError(f"Failed to find and bump {error_msg} in {version_path}.")
41-
4240
return new_content
4341

4442

@@ -106,27 +104,21 @@ def bump_version(config, new_version):
106104
if not version_path:
107105
# version bumping was not performed
108106
return False
109-
110107
try:
111108
new_version_parts = new_version.split(".")
112109
if len(new_version_parts) != 3:
113110
raise ValueError("Version must be in the format X.Y.Z")
114111
except ValueError as e:
115112
print(f"Error: Invalid version format. {e}", file=sys.stderr)
116113
sys.exit(1)
117-
118114
with open(version_path, "r") as f:
119115
content = f.read()
120-
121116
handler = VERSION_BUMP_HANDLERS.get(package_type)
122117
if not handler:
123118
raise RuntimeError(f"Unknown package type: {package_type}")
124-
125119
new_content = handler(content, new_version, version_path)
126-
127120
with open(version_path, "w") as f:
128121
f.write(new_content)
129-
130122
return True
131123

132124

0 commit comments

Comments
 (0)