cmem-cmemc 23.1.3__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.1"
34
+ DI_TARGET_VERSION = "v23.3.0"
35
35
 
36
- DP_TARGET_VERSION = "v23.1"
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)
@@ -15,12 +15,14 @@ def get_icon_for_command_group(full_name):
15
15
  "admin metrics": "material/chart-line-variant",
16
16
  "admin store": "material/database-outline",
17
17
  "admin user": "material/account-cog",
18
+ "admin client": "material/account-cog",
18
19
  "admin workspace": "material/folder-multiple-outline",
19
20
  "admin workspace python": "material/language-python",
20
21
  "config": "material/cog-outline",
21
22
  "dataset": "eccenca/artefact-dataset",
22
23
  "dataset resource": "eccenca/artefact-file",
23
24
  "project": "eccenca/artefact-project",
25
+ "project variable": "material/variable-box",
24
26
  "query": "eccenca/application-queries",
25
27
  "graph": "eccenca/artefact-dataset-eccencadataplatform",
26
28
  "vocabulary": "eccenca/application-vocabularies",
@@ -38,12 +40,14 @@ def get_tags_for_command_group(full_name: str) -> str:
38
40
  "admin metrics": ["cmemc"],
39
41
  "admin store": ["SPARQL", "cmemc"],
40
42
  "admin user": ["Keycloak", "Security", "cmemc"],
43
+ "admin client": ["Keycloak", "Security", "cmemc"],
41
44
  "admin workspace": ["cmemc"],
42
45
  "admin workspace python": ["Python", "cmemc"],
43
46
  "config": ["Configuration", "cmemc"],
44
47
  "dataset": ["cmemc"],
45
48
  "dataset resource": ["cmemc"],
46
49
  "project": ["Project", "cmemc"],
50
+ "project variable": ["Variables", "cmemc"],
47
51
  "query": ["SPARQL", "cmemc"],
48
52
  "graph": ["KnowledgeGraph", "cmemc"],
49
53
  "vocabulary": ["Vocabulary", "cmemc"],
@@ -57,14 +61,15 @@ def get_tags_for_command_group(full_name: str) -> str:
57
61
  return markdown
58
62
 
59
63
 
60
- def enhance_help_text_markdown(
61
- text: str, skip_first_line: bool = False
64
+ def get_enhanced_help_text_markdown(
65
+ command_or_group, skip_first_line: bool = False
62
66
  ) -> str:
63
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)
64
70
  help_text_ = ""
65
71
  for line in text.splitlines():
66
- if skip_first_line:
67
- skip_first_line = False
72
+ if skip_first_line and line.strip().startswith(first_line):
68
73
  continue
69
74
  if line == "":
70
75
  help_text_ = f"{help_text_}\n\n"
@@ -234,7 +239,7 @@ def create_group_index_md(ctx, command_group, directory, full_name):
234
239
  Path(directory).mkdir(parents=True, exist_ok=True)
235
240
  file_name = f"{directory}/index.md"
236
241
 
237
- help_text = enhance_help_text_markdown(command_group.help)
242
+ help_text = get_enhanced_help_text_markdown(command_group)
238
243
  # config help has now text but too much lists
239
244
  if command_group.name == "config":
240
245
  help_text = f"```text\n{command_group.help}\n```"
@@ -265,7 +270,7 @@ def get_markdown_for_command(ctx, command, group_name) -> str:
265
270
  command.format_help(ctx, formatter)
266
271
 
267
272
  # the help text is everything without options and usages
268
- help_text = enhance_help_text_markdown(command.help, True)
273
+ help_text = get_enhanced_help_text_markdown(command, True)
269
274
 
270
275
  # the options text is the documentation of the options
271
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.1.3
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.1.1)
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)
@@ -49,11 +49,9 @@ cmemc is the official command line client for [eccenca Corporate Memory](https:/
49
49
 
50
50
  In order to install the cmemc, run:
51
51
 
52
- pip install cmem-cmemc
53
-
54
- You may consider installing cmemc only for the current user:
52
+ pipx install cmem-cmemc
55
53
 
56
- pip install cmem-cmemc --user
54
+ Of course you can install cmemc also with pip, but we recommend [pipx](https://pypa.github.io/pipx/) for normal desktop usage.
57
55
 
58
56
  ## Configuration and Usage
59
57
 
@@ -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,32 +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=D94DjpFGVA1eePwInGHlSFRaQJLjUB5cE6Krn8eDh74,3311
5
- cmem/cmemc/cli/commands/admin.py,sha256=TAECccpn0wFChY1CAdTyuM-MI3_zEhjc7iGpp_hzOVk,6709
6
- cmem/cmemc/cli/commands/config.py,sha256=t_TpgRzfb-cyKVPAm4UAU_ib5yhJTckatlcuB6Mils8,5562
7
- cmem/cmemc/cli/commands/dataset.py,sha256=Sk3xlMACvcfLuiuu79uGoX5gFp0zqoHLAGU67u2b7aI,27505
8
- cmem/cmemc/cli/commands/graph.py,sha256=ZcHUhBc9bH6Z4ZGfTxA7c9oQ38Sv6MeqAT-freSwxxs,27110
9
- cmem/cmemc/cli/commands/metrics.py,sha256=QEpezyerLaORM_gNqKMS8Nbx10dx2pJipuJdR0Hgrdk,7808
10
- cmem/cmemc/cli/commands/project.py,sha256=UU32GO2FX0MLD_LE0d811vDzhuH1500D1-KFC5S59PQ,17612
11
- cmem/cmemc/cli/commands/python.py,sha256=hKRczEg3VjRjp8HLpzXLtPD38r2EzCkPm12RmyBIVNg,6948
12
- cmem/cmemc/cli/commands/query.py,sha256=zTEhgvHEMfqNrDOBQ3M3swGFPo2ErV2-Zg060LKTxgc,27725
13
- cmem/cmemc/cli/commands/resource.py,sha256=DSpvcqWRSkfKbtV2HlVydThU3o7Q-EspE6smILe0B_o,7556
14
- cmem/cmemc/cli/commands/scheduler.py,sha256=wmsln-CYGqiurSyEQSLochwNShDnPvkcIjj-mDeEKy0,8192
15
- cmem/cmemc/cli/commands/store.py,sha256=vTWgDMjCsqrridkch7XYUgSbS2GhxQ2iB-m_To4gIx8,6961
16
- cmem/cmemc/cli/commands/user.py,sha256=hjye5MRrPCxn50IKmSylQK7mQiqKUEoMEWVqWtqMuNI,10654
17
- cmem/cmemc/cli/commands/vocabulary.py,sha256=haYTFMb3YMbvC1EqO1EuhRCPZaDBBZz-2E340zEg3fE,16218
18
- cmem/cmemc/cli/commands/workflow.py,sha256=Tyd3rkeqlXuJ8FplerU_WVcJrm7Hz0bu8d2QPoQ5k0Y,21832
19
- cmem/cmemc/cli/commands/workspace.py,sha256=7szXu6FbwcvtC4YpTaVmcPLGFHXOsoGKaco-fbQ7sUA,4761
20
- cmem/cmemc/cli/completion.py,sha256=PfMAkIRlXLoz-gxPkXkc4FYJQjqwPz-P8Ly3pVPvHqQ,38221
21
- cmem/cmemc/cli/context.py,sha256=vNQOacNobygnQB5DZr9DxJkbsZm895Uq2PZafw18wtI,15648
22
- cmem/cmemc/cli/exceptions.py,sha256=yHyHF-oZ81XIIb_trbFnWcqbzq_zPT4JaoDhFi_Stl0,139
23
- cmem/cmemc/cli/manual_helper/__init__.py,sha256=G3Lqw2aPxo8x63Tg7L0aa5VD9BMaRzZDmhrog7IuEPg,43
24
- cmem/cmemc/cli/manual_helper/graph.py,sha256=06fOyZeCXRNiQ3LyNaU2p70Z0Neax4KAJitUFVUsD30,3261
25
- cmem/cmemc/cli/manual_helper/multi_page.py,sha256=wPR-43eEFKHevVUp0v9B3bGL_PkcNsAatBr9eZU58Pk,11127
26
- cmem/cmemc/cli/manual_helper/single_page.py,sha256=MNaQAwdvcHhOv5xvjDnuSRDkuimOXtIWdUa8skwYq0w,1303
27
- cmem/cmemc/cli/utils.py,sha256=Jqb1DF8Y_DC6Hf7L2IVrinnm9ShHkLPTYjnZcPsSHFI,8086
28
- cmem_cmemc-23.1.3.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
29
- cmem_cmemc-23.1.3.dist-info/METADATA,sha256=Mfo9L7FRuPAb6YAG_1w5AGhWBtHffzW_ffrfDtyPI_I,2544
30
- cmem_cmemc-23.1.3.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
31
- cmem_cmemc-23.1.3.dist-info/entry_points.txt,sha256=cl-mawezSjt0JzpCWfAudsm_9ekKcFGzJxlnglRno38,45
32
- cmem_cmemc-23.1.3.dist-info/RECORD,,