Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-pylib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-pylib
Commits
e9c369e2
Verified
Commit
e9c369e2
authored
7 months ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
DOC: Updated documentation for get_entity_by_...
parent
f6751a39
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!149
Release 0.15.1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/linkahead/utils/get_entity.py
+21
-3
21 additions, 3 deletions
src/linkahead/utils/get_entity.py
with
21 additions
and
3 deletions
src/linkahead/utils/get_entity.py
+
21
−
3
View file @
e9c369e2
...
...
@@ -30,7 +30,13 @@ from .escape import escape_squoted_text
def
get_entity_by_name
(
name
:
str
,
role
:
Optional
[
str
]
=
None
)
->
Entity
:
"""
Return the result of a unique query that uses the name to find the correct entity.
Submits the query
"
FIND ENTITY WITH name=
'
{name}
'"
.
Submits the query
"
FIND {role} WITH name=
'
{name}
'"
.
Parameters
----------
role: str, optional
The role for the query, defaults to ``ENTITY``.
"""
name
=
escape_squoted_text
(
name
)
if
role
is
None
:
...
...
@@ -42,7 +48,13 @@ def get_entity_by_name(name: str, role: Optional[str] = None) -> Entity:
def
get_entity_by_id
(
eid
:
Union
[
str
,
int
],
role
:
Optional
[
str
]
=
None
)
->
Entity
:
"""
Return the result of a unique query that uses the id to find the correct entity.
Submits the query
"
FIND ENTITY WITH id=
'
{eid}
'"
.
Submits the query
"
FIND {role} WITH id=
'
{eid}
'"
.
Parameters
----------
role: str, optional
The role for the query, defaults to ``ENTITY``.
"""
if
role
is
None
:
role
=
"
ENTITY
"
...
...
@@ -53,7 +65,13 @@ def get_entity_by_id(eid: Union[str, int], role: Optional[str] = None) -> Entity
def
get_entity_by_path
(
path
:
str
)
->
Entity
:
"""
Return the result of a unique query that uses the path to find the correct file.
Submits the query
"
FIND FILE WHICH IS STORED AT
'
{path}
'"
.
Submits the query
"
FIND {role} WHICH IS STORED AT
'
{path}
'"
.
Parameters
----------
role: str, optional
The role for the query, defaults to ``ENTITY``.
"""
# type hint can be ignored, it's a unique query
return
execute_query
(
f
"
FIND FILE WHICH IS STORED AT
'
{
path
}
'"
,
unique
=
True
)
# type: ignore
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment