cmem-cmemc 23.2__py3-none-any.whl → 23.3.0__py3-none-any.whl

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.
cmem/cmemc/cli/context.py CHANGED
@@ -31,9 +31,9 @@ from cmem.cmempy.health import (
31
31
  from cmem.cmemc.cli.exceptions import (InvalidConfiguration)
32
32
  from cmem.cmemc.cli.utils import is_completing
33
33
 
34
- DI_TARGET_VERSION = "v23.2.0"
34
+ DI_TARGET_VERSION = "v23.3.0"
35
35
 
36
- DP_TARGET_VERSION = "v23.2.0"
36
+ DP_TARGET_VERSION = "v23.3.0"
37
37
 
38
38
  KNOWN_CONFIG_KEYS = {
39
39
  'CMEM_BASE_URI': cmempy_config.get_cmem_base_uri,
@@ -63,6 +63,7 @@ class ApplicationContext():
63
63
  """Context of the command line interface."""
64
64
 
65
65
  # pylint: disable=too-many-instance-attributes
66
+ # pylint: disable=too-many-public-methods
66
67
 
67
68
  def __init__(self, debug=False, quiet=False):
68
69
  """Initialize main context."""
@@ -151,8 +152,24 @@ class ApplicationContext():
151
152
  urllib3.disable_warnings()
152
153
  return
153
154
 
155
+ def set_connection_from_params(self, params):
156
+ """Set connection and config by manually checking params (completion)."""
157
+ self.set_config_file(
158
+ getenv("CMEMC_CONFIG_FILE", self.config_file)
159
+ )
160
+ if params["config_file"]:
161
+ self.set_config_file(params["config_file"])
162
+
163
+ self.config = self.get_config()
164
+ # look for connection in environment and set connection
165
+ self.set_connection(
166
+ getenv("CMEMC_CONNECTION", '')
167
+ )
168
+ if params["connection"]:
169
+ self.set_connection(params["connection"])
170
+
154
171
  def set_connection_from_args(self, args):
155
- """Set connection and config by manually checking args (completion)."""
172
+ """Set connection and config by manually checking param (completion)."""
156
173
  # look for environment and load config
157
174
  self.set_config_file(
158
175
  getenv("CMEMC_CONFIG_FILE", self.config_file)
@@ -22,6 +22,7 @@ def get_icon_for_command_group(full_name):
22
22
  "dataset": "eccenca/artefact-dataset",
23
23
  "dataset resource": "eccenca/artefact-file",
24
24
  "project": "eccenca/artefact-project",
25
+ "project variable": "material/variable-box",
25
26
  "query": "eccenca/application-queries",
26
27
  "graph": "eccenca/artefact-dataset-eccencadataplatform",
27
28
  "vocabulary": "eccenca/application-vocabularies",
@@ -46,6 +47,7 @@ def get_tags_for_command_group(full_name: str) -> str:
46
47
  "dataset": ["cmemc"],
47
48
  "dataset resource": ["cmemc"],
48
49
  "project": ["Project", "cmemc"],
50
+ "project variable": ["Variables", "cmemc"],
49
51
  "query": ["SPARQL", "cmemc"],
50
52
  "graph": ["KnowledgeGraph", "cmemc"],
51
53
  "vocabulary": ["Vocabulary", "cmemc"],
@@ -59,14 +61,15 @@ def get_tags_for_command_group(full_name: str) -> str:
59
61
  return markdown
60
62
 
61
63
 
62
- def enhance_help_text_markdown(
63
- text: str, skip_first_line: bool = False
64
+ def get_enhanced_help_text_markdown(
65
+ command_or_group, skip_first_line: bool = False
64
66
  ) -> str:
65
67
  """Add ammunition and code ticks where possible."""
68
+ text = command_or_group.help
69
+ first_line = command_or_group.get_short_help_str(limit=200)
66
70
  help_text_ = ""
67
71
  for line in text.splitlines():
68
- if skip_first_line:
69
- skip_first_line = False
72
+ if skip_first_line and line.strip().startswith(first_line):
70
73
  continue
71
74
  if line == "":
72
75
  help_text_ = f"{help_text_}\n\n"
@@ -236,7 +239,7 @@ def create_group_index_md(ctx, command_group, directory, full_name):
236
239
  Path(directory).mkdir(parents=True, exist_ok=True)
237
240
  file_name = f"{directory}/index.md"
238
241
 
239
- help_text = enhance_help_text_markdown(command_group.help)
242
+ help_text = get_enhanced_help_text_markdown(command_group)
240
243
  # config help has now text but too much lists
241
244
  if command_group.name == "config":
242
245
  help_text = f"```text\n{command_group.help}\n```"
@@ -267,7 +270,7 @@ def get_markdown_for_command(ctx, command, group_name) -> str:
267
270
  command.format_help(ctx, formatter)
268
271
 
269
272
  # the help text is everything without options and usages
270
- help_text = enhance_help_text_markdown(command.help, True)
273
+ help_text = get_enhanced_help_text_markdown(command, True)
271
274
 
272
275
  # the options text is the documentation of the options
273
276
  options_text_ = str(formatter.getvalue())
cmem/cmemc/cli/utils.py CHANGED
@@ -3,14 +3,19 @@ import json
3
3
  import os
4
4
  import re
5
5
  import unicodedata
6
+ from dataclasses import dataclass
6
7
  from typing import Dict
7
8
 
8
9
  from importlib.metadata import version
10
+
11
+ import requests
12
+ from bs4 import BeautifulSoup
9
13
  from prometheus_client import Metric
10
14
  from prometheus_client.parser import text_string_to_metric_families
11
15
 
12
16
  from cmem.cmempy.dp.admin import get_prometheus_data
13
17
  from cmem.cmempy.dp.proxy.graph import get_graphs_list
18
+ from cmem.cmempy.workspace.projects.project import get_projects
14
19
 
15
20
  NAMESPACES = {
16
21
  "void": "http://rdfs.org/ns/void#",
@@ -259,3 +264,78 @@ def metrics_get_family(job_id, metric_id):
259
264
  raise ValueError(
260
265
  f"The job {job_id} does not have a metric {metric_id}."
261
266
  ) from error
267
+
268
+
269
+ def check_or_select_project(app, project_id=None):
270
+ """Check for given project, select the first one if there is only one.
271
+
272
+ Args:
273
+ app (ApplicationContext): the click cli app context.
274
+ project_id (str): The project ID.
275
+
276
+ Raises:
277
+ ValueError: if no projects available.
278
+ ValueError: if more than one project is.
279
+
280
+ Returns:
281
+ Maybe project_id if there was no project_id before.
282
+ """
283
+ if project_id is not None:
284
+ return project_id
285
+
286
+ projects = get_projects()
287
+ if len(projects) == 1:
288
+ project_name = projects[0]["name"]
289
+ app.echo_warning(
290
+ "Missing project (--project) - since there is only one project, "
291
+ f"this is selected: {project_name}"
292
+ )
293
+ return project_name
294
+
295
+ if len(projects) == 0:
296
+ raise ValueError(
297
+ "There are no projects available. "
298
+ "Please create a project with 'cmemc project create'."
299
+ )
300
+
301
+ # more than one project
302
+ raise ValueError(
303
+ "There is more than one project available so you need to "
304
+ "specify the project with '--project'."
305
+ )
306
+
307
+
308
+ @dataclass
309
+ class PublishedPackage:
310
+ """Represents a published package from pypi.org."""
311
+ name: str
312
+ description: str
313
+ version: str
314
+ published: str
315
+
316
+
317
+ def get_published_packages() -> list[PublishedPackage]:
318
+ """Get a scraped list of plugin packages scraped from pypi.org."""
319
+ url = "https://pypi.org/search/?q=%22cmem-plugin-%22"
320
+ soup = BeautifulSoup(
321
+ requests.get(url, timeout=5).content,
322
+ "html.parser"
323
+ )
324
+ packages = []
325
+ snippets = soup.find_all("a", class_="package-snippet")
326
+ for _ in snippets:
327
+ name = _.findChildren(class_="package-snippet__name")[0].getText()
328
+ if name == "cmem-plugin-base":
329
+ continue
330
+ description = _.findChildren(class_="package-snippet__description")[0].getText()
331
+ package_version = _.findChildren(class_="package-snippet__version")[0].getText()
332
+ published = _.findChildren(name="time")[0].attrs["datetime"]
333
+ packages.append(
334
+ PublishedPackage(
335
+ name=name,
336
+ description=description,
337
+ version=package_version,
338
+ published=published
339
+ )
340
+ )
341
+ return packages
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cmem-cmemc
3
- Version: 23.2
3
+ Version: 23.3.0
4
4
  Summary: Command line client for eccenca Corporate Memory
5
5
  Home-page: https://eccenca.com/go/cmemc
6
6
  License: Apache 2.0
@@ -17,16 +17,16 @@ Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3.9
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
- Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.12
21
21
  Classifier: Topic :: Database
22
22
  Classifier: Topic :: Software Development :: Testing
23
23
  Classifier: Topic :: Utilities
24
24
  Requires-Dist: beautifulsoup4 (>=4.12.2,<5.0.0)
25
25
  Requires-Dist: certifi (>=2023.5.7)
26
- Requires-Dist: click (==7.1.2)
26
+ Requires-Dist: click (>=8.1.7,<9.0.0)
27
27
  Requires-Dist: click-didyoumean (>=0.3.0,<0.4.0)
28
28
  Requires-Dist: click-help-colors (>=0.9.1,<0.10.0)
29
- Requires-Dist: cmem-cmempy (==23.2)
29
+ Requires-Dist: cmem-cmempy (==23.3.0)
30
30
  Requires-Dist: configparser (>=5.3.0,<6.0.0)
31
31
  Requires-Dist: jinja2 (>=3.1.2,<4.0.0)
32
32
  Requires-Dist: natsort (>=8.3.1,<9.0.0)
@@ -0,0 +1,35 @@
1
+ cmem/__init__.py,sha256=OzrBXrHY3fXthcUqenPHDz_MXGlOSeyxEqasW2ZXkQ8,109
2
+ cmem/cmemc/__init__.py,sha256=W3KviSav-BgWl_0-OvpaTQJN51yP7J8qc5QHdj0KJbI,28
3
+ cmem/cmemc/cli/__init__.py,sha256=47s7BytGUhsTH7jF_Q28t3jIOSjVhC288SJAZBCAiuY,5838
4
+ cmem/cmemc/cli/_cmemc.zsh,sha256=fmkrBHIQxus8cp2AgO1tzZ5mNZdGL_83cYz3a9uAdsg,1326
5
+ cmem/cmemc/cli/commands/__init__.py,sha256=tUt6gII59eOn9mWcP0WajOpa-MxwhMXFYHNiC4Cb35U,3471
6
+ cmem/cmemc/cli/commands/admin.py,sha256=5aXvkNrgDf1rMd7X1jOKIxFvhoWnRockfcnSLlgvQbg,6785
7
+ cmem/cmemc/cli/commands/client.py,sha256=d7J9LoJC0hC3n5ZTuHaoNH20F2bUu-KaBNExpBZwMbo,5300
8
+ cmem/cmemc/cli/commands/config.py,sha256=QkvEtlveUWXVHJ3TcTWL9odxhHB7BxVnom_Q-OzcBuI,5568
9
+ cmem/cmemc/cli/commands/dataset.py,sha256=9GnR1lbjB_ov_IpQavIUU2bTlwGTPAPW7e0cJasnu1k,30602
10
+ cmem/cmemc/cli/commands/graph.py,sha256=Ieg_DMMDoQCrLr0i6lPDqnr3_0Q7WCvYsE-wucfy1Pg,27110
11
+ cmem/cmemc/cli/commands/metrics.py,sha256=0B8ZbydQ3EYeNfrhj8-c5AB_hD5v1KIQSTRG9OevARU,7808
12
+ cmem/cmemc/cli/commands/project.py,sha256=zrQ9Ex1819yNJiIoztku9U9BsrWDq981MlUskAhCARQ,20221
13
+ cmem/cmemc/cli/commands/python.py,sha256=-MKO0BosigTLJI3MiE7t1agd4WOfFx44NVM7FKDoqCE,9641
14
+ cmem/cmemc/cli/commands/query.py,sha256=rOrM3BmK1rl67U7x-pygbs1imILsjLUvO8vIaYo0vNo,27725
15
+ cmem/cmemc/cli/commands/resource.py,sha256=r0_Be0kDFNybAx6aQfWDuYaVa9n2lBbkhmn03Yd5KJg,7556
16
+ cmem/cmemc/cli/commands/scheduler.py,sha256=iZ69qpxeW996kNubo17ReRF24DJARVqFC0a9ea7hY3E,8192
17
+ cmem/cmemc/cli/commands/store.py,sha256=xT9Yh3NjiwEDNxupoZXaVmTBXecw_up7BuO4qr3TPbA,6823
18
+ cmem/cmemc/cli/commands/user.py,sha256=2h7VgOh357TsmgYh5oNhYHFxsLN4aoZqgjW99DTThFQ,11144
19
+ cmem/cmemc/cli/commands/variable.py,sha256=kdvKxmfOzoFl4ZuQRBQo3q5XqbBsnITZUaaYcADn4kk,11586
20
+ cmem/cmemc/cli/commands/vocabulary.py,sha256=qFTq2YJ0zmGePyU8J0sUnGeE2_v3UYTYFyFDogpVLko,16218
21
+ cmem/cmemc/cli/commands/workflow.py,sha256=uYaOxEKZ5ntHGmeYS46Jwq2cFw-Bvknl5UCI_lkZHTo,24354
22
+ cmem/cmemc/cli/commands/workspace.py,sha256=TLJguKIIrruw5xNIpkDJ0BZKcSmGegtYFn7W_hTc0-Y,4761
23
+ cmem/cmemc/cli/completion.py,sha256=aaNn3_ECqOMmVYACEYsndUvvFEfmqYJzvWKFlpMFxmI,46262
24
+ cmem/cmemc/cli/context.py,sha256=cnEvXQ7Aq-u7UfWZaOKRd0ver17MUyihSEDZ6j1tdX4,16294
25
+ cmem/cmemc/cli/exceptions.py,sha256=yHyHF-oZ81XIIb_trbFnWcqbzq_zPT4JaoDhFi_Stl0,139
26
+ cmem/cmemc/cli/manual_helper/__init__.py,sha256=G3Lqw2aPxo8x63Tg7L0aa5VD9BMaRzZDmhrog7IuEPg,43
27
+ cmem/cmemc/cli/manual_helper/graph.py,sha256=06fOyZeCXRNiQ3LyNaU2p70Z0Neax4KAJitUFVUsD30,3261
28
+ cmem/cmemc/cli/manual_helper/multi_page.py,sha256=o3z81XqjSLX3r0F-snp3SOlV3xyQ5yAg0hnzV8U9s4Y,11452
29
+ cmem/cmemc/cli/manual_helper/single_page.py,sha256=MNaQAwdvcHhOv5xvjDnuSRDkuimOXtIWdUa8skwYq0w,1303
30
+ cmem/cmemc/cli/utils.py,sha256=MOrfwIa4zS1yDw2k5abIVTsO0os5Kj8uaFhtz4wWm2c,10540
31
+ cmem_cmemc-23.3.0.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
32
+ cmem_cmemc-23.3.0.dist-info/METADATA,sha256=YeXU8JJ2_zIRoWwLhXSFYIDwYS59zEBu2lzNq13YXbw,2584
33
+ cmem_cmemc-23.3.0.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
34
+ cmem_cmemc-23.3.0.dist-info/entry_points.txt,sha256=cl-mawezSjt0JzpCWfAudsm_9ekKcFGzJxlnglRno38,45
35
+ cmem_cmemc-23.3.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 1.5.2
2
+ Generator: poetry-core 1.8.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -1,33 +0,0 @@
1
- cmem/__init__.py,sha256=OzrBXrHY3fXthcUqenPHDz_MXGlOSeyxEqasW2ZXkQ8,109
2
- cmem/cmemc/__init__.py,sha256=W3KviSav-BgWl_0-OvpaTQJN51yP7J8qc5QHdj0KJbI,28
3
- cmem/cmemc/cli/__init__.py,sha256=nOkwCdEs_wBccdfVkZKeiCbJxU4NoMzYZe84xiyvmAM,5571
4
- cmem/cmemc/cli/commands/__init__.py,sha256=Y5ukwSpHpVn97aQSli1cLSIIMkfXMKjKyixLPgj1L78,3417
5
- cmem/cmemc/cli/commands/admin.py,sha256=faAXk_0FF_Lu1ARojQO0O1dxmnLzIfG7iNEHTN_kfOM,6785
6
- cmem/cmemc/cli/commands/client.py,sha256=vkg0FmN0cfY5RNh40n9U9W-pHjFYgVQ0yxRSjAgwQUU,5300
7
- cmem/cmemc/cli/commands/config.py,sha256=t_TpgRzfb-cyKVPAm4UAU_ib5yhJTckatlcuB6Mils8,5562
8
- cmem/cmemc/cli/commands/dataset.py,sha256=jbJpbo2FREB_PiaqKappoRClHqh4ng9fChTbcofYkII,28680
9
- cmem/cmemc/cli/commands/graph.py,sha256=ZcHUhBc9bH6Z4ZGfTxA7c9oQ38Sv6MeqAT-freSwxxs,27110
10
- cmem/cmemc/cli/commands/metrics.py,sha256=QEpezyerLaORM_gNqKMS8Nbx10dx2pJipuJdR0Hgrdk,7808
11
- cmem/cmemc/cli/commands/project.py,sha256=QeotX8see0oEtEgMI1ZrELoc2FfImG5YRMCakejU9s8,18907
12
- cmem/cmemc/cli/commands/python.py,sha256=hKRczEg3VjRjp8HLpzXLtPD38r2EzCkPm12RmyBIVNg,6948
13
- cmem/cmemc/cli/commands/query.py,sha256=zTEhgvHEMfqNrDOBQ3M3swGFPo2ErV2-Zg060LKTxgc,27725
14
- cmem/cmemc/cli/commands/resource.py,sha256=DSpvcqWRSkfKbtV2HlVydThU3o7Q-EspE6smILe0B_o,7556
15
- cmem/cmemc/cli/commands/scheduler.py,sha256=wmsln-CYGqiurSyEQSLochwNShDnPvkcIjj-mDeEKy0,8192
16
- cmem/cmemc/cli/commands/store.py,sha256=vTWgDMjCsqrridkch7XYUgSbS2GhxQ2iB-m_To4gIx8,6961
17
- cmem/cmemc/cli/commands/user.py,sha256=zuodbVoUGVxOaNgJB80nNUKeFRnFvYJGoIKSmUjHB7Y,11144
18
- cmem/cmemc/cli/commands/vocabulary.py,sha256=haYTFMb3YMbvC1EqO1EuhRCPZaDBBZz-2E340zEg3fE,16218
19
- cmem/cmemc/cli/commands/workflow.py,sha256=bqc3ZdupGJ1IRnpGHFoWF5jnDYZYiTyGJFd_gfvMzKY,22673
20
- cmem/cmemc/cli/commands/workspace.py,sha256=7szXu6FbwcvtC4YpTaVmcPLGFHXOsoGKaco-fbQ7sUA,4761
21
- cmem/cmemc/cli/completion.py,sha256=t6oZcGF6Hm2dDfVVTFc2lFXgHHo-j1pkuKq23mheEjE,42232
22
- cmem/cmemc/cli/context.py,sha256=2Ro8Asl9dymIWWqoRkcDqYzMoI5gnxVNLpdrouXUh3c,15652
23
- cmem/cmemc/cli/exceptions.py,sha256=yHyHF-oZ81XIIb_trbFnWcqbzq_zPT4JaoDhFi_Stl0,139
24
- cmem/cmemc/cli/manual_helper/__init__.py,sha256=G3Lqw2aPxo8x63Tg7L0aa5VD9BMaRzZDmhrog7IuEPg,43
25
- cmem/cmemc/cli/manual_helper/graph.py,sha256=06fOyZeCXRNiQ3LyNaU2p70Z0Neax4KAJitUFVUsD30,3261
26
- cmem/cmemc/cli/manual_helper/multi_page.py,sha256=Kx-K1SwSHbPs41VdX_rtLebkOASXqhvY-Dusp7-_Yn8,11234
27
- cmem/cmemc/cli/manual_helper/single_page.py,sha256=MNaQAwdvcHhOv5xvjDnuSRDkuimOXtIWdUa8skwYq0w,1303
28
- cmem/cmemc/cli/utils.py,sha256=Jqb1DF8Y_DC6Hf7L2IVrinnm9ShHkLPTYjnZcPsSHFI,8086
29
- cmem_cmemc-23.2.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
30
- cmem_cmemc-23.2.dist-info/METADATA,sha256=QOPuWwUviPmQ0gauoeC4ZmUg3N1XVHaMglkDSShNxTU,2572
31
- cmem_cmemc-23.2.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
32
- cmem_cmemc-23.2.dist-info/entry_points.txt,sha256=cl-mawezSjt0JzpCWfAudsm_9ekKcFGzJxlnglRno38,45
33
- cmem_cmemc-23.2.dist-info/RECORD,,