Skip to content
Snippets Groups Projects
Commit 36a81616 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

DOC STY: Formatting of docstrings.

parent 0ae5bed5
No related branches found
No related tags found
2 merge requests!22Release 0.3,!3Bloxberg proof of concept
This commit is part of merge request !3. Comments created here will be created in the context of that merge request.
...@@ -171,13 +171,16 @@ class UpdateCache(Cache): ...@@ -171,13 +171,16 @@ class UpdateCache(Cache):
return old_ones return old_ones
def insert(self, cont, run_id): def insert(self, cont, run_id):
""" insert a pending, unauthorized update """Insert a pending, unauthorized update
Parameters:
----------- Parameters
----------
cont: Container with the records to be updated containing the desired cont: Container with the records to be updated containing the desired
version, i.e. the state after the update. version, i.e. the state after the update.
run_id: the id of the crawler run
run_id: int
The id of the crawler run
""" """
cont = put_in_container(cont) cont = put_in_container(cont)
old_ones = UpdateCache.get_previous_version(cont) old_ones = UpdateCache.get_previous_version(cont)
......
"""Submodule for working with data models.
"""
...@@ -106,7 +106,7 @@ class DataModel(dict): ...@@ -106,7 +106,7 @@ class DataModel(dict):
print(ent.name) print(ent.name)
if noquestion or str(input("Do you really want to insert those " if noquestion or str(input("Do you really want to insert those "
"entities? [y] ")).lower() == "y": "entities? [y/N] ")).lower() == "y":
non_existing_entities.insert() non_existing_entities.insert()
self.sync_ids_by_name(non_existing_entities) self.sync_ids_by_name(non_existing_entities)
print("Updated entities.") print("Updated entities.")
...@@ -131,7 +131,7 @@ class DataModel(dict): ...@@ -131,7 +131,7 @@ class DataModel(dict):
if any_change: if any_change:
if noquestion or input("Do you really want to apply the above " if noquestion or input("Do you really want to apply the above "
"changes? [y]") == "y": "changes? [y/N]") == "y":
existing_entities.update() existing_entities.update()
print("Synchronized existing entities.") print("Synchronized existing entities.")
else: else:
...@@ -171,9 +171,7 @@ class DataModel(dict): ...@@ -171,9 +171,7 @@ class DataModel(dict):
A iterable with entities. A iterable with entities.
names : iterable of str names : iterable of str
Only entities which do *not* have one of these names will end up in Only entities which do *not* have one of these names will end up in
the the returned iterable.
returned iterable.
Returns Returns
------- -------
......
""" """
This script provides methods to read a DataModel from a yaml file. This module (and script) provides methods to read a DataModel from a YAML file.
If a file name is passed to parse_model_from_yaml it is parsed and a DataModel If a file name is passed to parse_model_from_yaml it is parsed and a DataModel
is created. The yaml file needs to be structured in a certain way which will be is created. The yaml file needs to be structured in a certain way which will be
...@@ -13,7 +13,7 @@ and will be added with the respective importance. These properties can be ...@@ -13,7 +13,7 @@ and will be added with the respective importance. These properties can be
RecordTypes or Properties and can be defined right there. RecordTypes or Properties and can be defined right there.
Every Property or RecordType only needs to be defined once anywhere. When it is Every Property or RecordType only needs to be defined once anywhere. When it is
not defined, simply the name can be supplied with no value. not defined, simply the name can be supplied with no value.
Parents can be provided under the inherit_from_xxxx keywords. The value needs Parents can be provided under the 'inherit_from_xxxx' keywords. The value needs
to be a list with the names. Here, NO NEW entities can be defined. to be a list with the names. Here, NO NEW entities can be defined.
""" """
import re import re
...@@ -24,9 +24,10 @@ import yaml ...@@ -24,9 +24,10 @@ import yaml
from .data_model import DataModel from .data_model import DataModel
# Keywords which are allowed in data model descriptions.
KEYWORDS = ["parent", KEYWORDS = ["parent",
"importance", "importance",
"datatype", "datatype", # for example TEXT, INTEGER or REFERENCE
"unit", "unit",
"description", "description",
"recommended_properties", "recommended_properties",
...@@ -95,12 +96,12 @@ class Parser(object): ...@@ -95,12 +96,12 @@ class Parser(object):
Parameters Parameters
---------- ----------
filename : str filename : str
The path to the YAML file. The path to the YAML file.
Returns Returns
------- -------
out : DataModel out : DataModel
The created DataModel The created DataModel
""" """
with open(filename, 'r') as outfile: with open(filename, 'r') as outfile:
ymlmodel = yaml.load(outfile, Loader=SafeLineLoader) ymlmodel = yaml.load(outfile, Loader=SafeLineLoader)
...@@ -112,12 +113,12 @@ class Parser(object): ...@@ -112,12 +113,12 @@ class Parser(object):
Parameters Parameters
---------- ----------
string : str string : str
The YAML string. The YAML string.
Returns Returns
------- -------
out : DataModel out : DataModel
The created DataModel The created DataModel
""" """
ymlmodel = yaml.load(string, Loader=SafeLineLoader) ymlmodel = yaml.load(string, Loader=SafeLineLoader)
return self._create_model_from_dict(ymlmodel) return self._create_model_from_dict(ymlmodel)
...@@ -128,12 +129,12 @@ class Parser(object): ...@@ -128,12 +129,12 @@ class Parser(object):
Parameters Parameters
---------- ----------
ymlmodel : dict ymlmodel : dict
The dictionary parsed from a YAML file. The dictionary parsed from a YAML file.
Returns Returns
------- -------
out : DataModel out : DataModel
The created DataModel The created DataModel
""" """
if not isinstance(ymlmodel, dict): if not isinstance(ymlmodel, dict):
...@@ -185,15 +186,15 @@ class Parser(object): ...@@ -185,15 +186,15 @@ class Parser(object):
Parameters Parameters
---------- ----------
name : name :
The value to be converted to a string. The value to be converted to a string.
context : obj context : obj
Will be printed in the case of warnings. Will be printed in the case of warnings.
Returns Returns
------- -------
out : str out : str
If `name` was a string, return it. Else return str(`name`). If `name` was a string, return it. Else return str(`name`).
""" """
if name is None: if name is None:
print("WARNING: Name of this context is None: {}".format(context), print("WARNING: Name of this context is None: {}".format(context),
......
...@@ -17,12 +17,13 @@ ...@@ -17,12 +17,13 @@
# sys.path.insert(0, os.path.abspath('../caosdb')) # sys.path.insert(0, os.path.abspath('../caosdb'))
# -- Project information -----------------------------------------------------
import sphinx_rtd_theme import sphinx_rtd_theme
# -- Project information -----------------------------------------------------
project = 'caosadvancedtools' project = 'caosadvancedtools'
copyright = '2020, IndiScale GmbH' copyright = '2021, IndiScale GmbH'
author = 'Daniel Hornung' author = 'Daniel Hornung'
# The short X.Y version # The short X.Y version
...@@ -92,6 +93,9 @@ html_theme = "sphinx_rtd_theme" ...@@ -92,6 +93,9 @@ html_theme = "sphinx_rtd_theme"
# relative to this directory. They are copied after the builtin static files, # relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css". # so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static'] html_static_path = ['_static']
# Disable static path to remove warning.
html_static_path = []
# Custom sidebar templates, must be a dictionary that maps document names # Custom sidebar templates, must be a dictionary that maps document names
# to template names. # to template names.
...@@ -185,10 +189,11 @@ epub_exclude_files = ['search.html'] ...@@ -185,10 +189,11 @@ epub_exclude_files = ['search.html']
# Example configuration for intersphinx: refer to the Python standard library. # Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = { intersphinx_mapping = {
'https://docs.python.org/': None, "python": ("https://docs.python.org/", None),
"caosdb-pylib": ("https://caosdb.gitlab.io/caosdb-pylib/", None), "caosdb-pylib": ("https://caosdb.gitlab.io/caosdb-pylib/", None),
} }
# TODO Which options do we want? # TODO Which options do we want?
autodoc_default_options = { autodoc_default_options = {
'members': None, 'members': None,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment