Skip to content

Commit

Permalink
Fix variable names (#818)
Browse files Browse the repository at this point in the history
* Fix variable names

Several variable names didn't follow the python style. This PR
fixes it.
  • Loading branch information
sergio-costas authored Dec 3, 2024
1 parent 106803f commit 24f1446
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions updatesnap/SnapVersionModule/snap_version_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import requests


def process_snap_version_data(upstreamversion, snap_name, version_schema, has_update):
def process_snap_version_data(upstream_version, snap_name, version_schema, has_update):
""" Returns processed snap version and grade """

# Time stamp of Snap build in Snap Store
Expand All @@ -21,12 +21,12 @@ def process_snap_version_data(upstreamversion, snap_name, version_schema, has_up
edge_channel_info = next((channel for channel in snap_info["channel-map"]
if channel["channel"]["name"] == "edge"
and channel["channel"]["architecture"] == "amd64"), None)
snapbuilddate = 0
snap_build_date = 0
if edge_channel_info:
# Parse the date string using datetime
snapbuilddate = datetime.fromisoformat(edge_channel_info["created-at"]
.replace("Z", "+00:00"))
snapbuilddate = int(snapbuilddate.timestamp())
snap_build_date = datetime.fromisoformat(edge_channel_info["created-at"]
.replace("Z", "+00:00"))
snap_build_date = int(snap_build_date.timestamp())

# Time stamp of the last GIT commit of the snapping repository
git_log_output = subprocess.run(['git', 'log', '-1', '--date=unix'],
Expand All @@ -36,30 +36,30 @@ def process_snap_version_data(upstreamversion, snap_name, version_schema, has_up
date_string = date_string.split(':', 1)[1].strip()

# Convert the date string to a Unix timestamp
gitcommitdate = int(date_string)
git_commit_date = int(date_string)

prevversion = max(
previous_version = max(
next((channel["version"] for channel in snap_info["channel-map"]
if channel["channel"]["name"] == "stable")),
next((channel["version"] for channel in snap_info["channel-map"]
if channel["channel"]["name"] == "edge"))
)

match = re.match(version_schema, upstreamversion)
match = re.match(version_schema, upstream_version)
if not match:
logging.warning("Version schema does not match with snapping repository version")
return None
upstreamversion = match.group(1).replace('_', '.')
upstream_version = match.group(1).replace('_', '.')

if upstreamversion > prevversion.split('-')[0]:
return f"{upstreamversion}-1"
if upstream_version > previous_version.split('-')[0]:
return f"{upstream_version}-1"
# Determine package release number
if (gitcommitdate > snapbuilddate or has_update):
packagerelease = int(prevversion.split('-')[-1]) + 1
if (git_commit_date > snap_build_date or has_update):
package_release = int(previous_version.split('-')[-1]) + 1
else:
packagerelease = int(prevversion.split('-')[-1])
package_release = int(previous_version.split('-')[-1])

return f"{upstreamversion}-{packagerelease}"
return f"{upstream_version}-{package_release}"


def process_rock_version_data(upstream_version, previous_version, version_schema, has_update):
Expand All @@ -78,11 +78,11 @@ def process_rock_version_data(upstream_version, previous_version, version_schema
return f"{upstream_version}-1"
# Determine package release number
if has_update:
packagerelease = int(previous_version.split('-')[-1]) + 1
package_release = int(previous_version.split('-')[-1]) + 1
else:
packagerelease = int(previous_version.split('-')[-1])
package_release = int(previous_version.split('-')[-1])

return f"{upstream_version}-{packagerelease}"
return f"{upstream_version}-{package_release}"


def is_version_update(snap, manager_yaml, arguments, has_update):
Expand Down
4 changes: 2 additions & 2 deletions updatesnap/updatesnapyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ def main():
description='Find the lastest source'
' versions for snap files and generates a new snapcraft.yaml.')
parser.add_argument('--github-user', action='store', default=None,
help='User name for accesing Github projects.')
help='User name for accessing Github projects.')
parser.add_argument('--github-token', action='store', default=None,
help='Access token for accesing Github projects.')
help='Access token for accessing Github projects.')
parser.add_argument('--version-schema', action='store', default='None',
help='Version schema of snapping repository')
parser.add_argument('--rock-version-schema', action='store', default='None',
Expand Down

0 comments on commit 24f1446

Please sign in to comment.