pypas-cli 0.4.2__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {pypas_cli-0.4.2/src/pypas_cli.egg-info → pypas_cli-0.4.3}/PKG-INFO +1 -1
  2. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/pyproject.toml +1 -1
  3. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/lib/sysutils.py +32 -3
  4. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/main.py +2 -5
  5. {pypas_cli-0.4.2 → pypas_cli-0.4.3/src/pypas_cli.egg-info}/PKG-INFO +1 -1
  6. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/LICENSE +0 -0
  7. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/README.md +0 -0
  8. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/setup.cfg +0 -0
  9. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/__init__.py +0 -0
  10. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/lib/auth.py +0 -0
  11. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/lib/config.py +0 -0
  12. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/lib/console.py +0 -0
  13. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/lib/decorators.py +0 -0
  14. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/lib/exercise.py +0 -0
  15. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/lib/monads.py +0 -0
  16. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/lib/network.py +0 -0
  17. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas/settings.py +0 -0
  18. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas_cli.egg-info/SOURCES.txt +0 -0
  19. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas_cli.egg-info/dependency_links.txt +0 -0
  20. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas_cli.egg-info/entry_points.txt +0 -0
  21. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas_cli.egg-info/requires.txt +0 -0
  22. {pypas_cli-0.4.2 → pypas_cli-0.4.3}/src/pypas_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypas-cli
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Python Practical Assignments
5
5
  Author-email: Sergio Delgado Quintero <sdelquin@gmail.com>
6
6
  Maintainer-email: Sergio Delgado Quintero <sdelquin@gmail.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pypas-cli"
3
- version = "0.4.2"
3
+ version = "0.4.3"
4
4
  description = "Python Practical Assignments"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -73,10 +73,17 @@ def get_package_data(package: str = 'pypas-cli') -> dict[str, str]:
73
73
  return {}
74
74
 
75
75
 
76
- def get_package_info(package: str = 'pypas-cli') -> str:
76
+ def show_package_info(package: str = 'pypas-cli') -> None:
77
77
  if data := get_package_data(package):
78
- return f'Package: {data.get("name")}\nVersion: {data.get("version")}\nPath: {data.get("location")}'
79
- return "Package '{package}' is not already installed."
78
+ console.print(
79
+ dedent(f"""\
80
+ Package: {data.get('name')}
81
+ Version: [note]{data.get('version')}[/note]
82
+ Path: {data.get('location')}\
83
+ """)
84
+ )
85
+ else:
86
+ console.error(f"Package '{package}' is not yet installed")
80
87
 
81
88
 
82
89
  def get_latest_package_version(package: str = 'pypas-cli') -> str | None:
@@ -152,3 +159,25 @@ def unzip(zip_path: Path, extract_to: Path | None = None) -> Path:
152
159
  with zipfile.ZipFile(zip_path, 'r') as zip_ref:
153
160
  zip_ref.extractall(extract_to)
154
161
  return extract_to
162
+
163
+
164
+ def handle_upgrade_pypas():
165
+ latest_version = get_latest_package_version()
166
+ package_data = get_package_data()
167
+ current_version = package_data.get('version')
168
+ # current_version = '0.0.0' # Temporary hardcoded version for testing
169
+ if latest_version and current_version:
170
+ if latest_version != current_version:
171
+ if upgrade_pypas():
172
+ console.success(
173
+ f'Upgraded pypas-cli from [note]v{current_version}[/note] to [note]v{latest_version}[/note]'
174
+ )
175
+ else:
176
+ console.error('Error upgrading pypas')
177
+ else:
178
+ console.success(
179
+ f"You're on the latest version of pypas-cli: [note]v{current_version}[/note]",
180
+ emphasis=False,
181
+ )
182
+ else:
183
+ console.error('Could not determine pypas-cli version information')
@@ -27,7 +27,7 @@ def default(
27
27
  ):
28
28
  if version:
29
29
  sysutils.handle_package_version()
30
- print(sysutils.get_package_info())
30
+ sysutils.show_package_info()
31
31
  # https://typer.tiangolo.com/tutorial/commands/context/#exclusive-executable-callback
32
32
  elif ctx.invoked_subcommand is None:
33
33
  typer.echo(ctx.get_help())
@@ -94,10 +94,7 @@ def auth(token: str = typer.Argument(help='Access token')):
94
94
  @app.command()
95
95
  def upgrade():
96
96
  """Upgrade pypas-cli from PyPI."""
97
- if sysutils.upgrade_pypas():
98
- print(sysutils.get_package_info())
99
- else:
100
- console.error('Error upgrading pypas')
97
+ sysutils.handle_upgrade_pypas()
101
98
 
102
99
 
103
100
  @app.command()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pypas-cli
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Python Practical Assignments
5
5
  Author-email: Sergio Delgado Quintero <sdelquin@gmail.com>
6
6
  Maintainer-email: Sergio Delgado Quintero <sdelquin@gmail.com>
File without changes
File without changes
File without changes