Skip to content

Commit

Permalink
Merge branch 'master' into pydantic2
Browse files Browse the repository at this point in the history
  • Loading branch information
jesper-friis authored Aug 15, 2023
2 parents b7762bf + 7d13867 commit 0ce89e1
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


## Type of change
- [ ] Bug fix
- [ ] Bug fix & code cleanup
- [ ] New feature
- [ ] Documentation update
- [ ] Test update
Expand Down
3 changes: 1 addition & 2 deletions bindings/python/dlite-entity-python.i
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def standardise(v, prop, asdict=False):
return conv(v)
def get_instance(id: "str", metaid: "str" = None, check_storages: "bool" = True) -> "Instance":
def get_instance(id: str, metaid: str = None, check_storages: bool = True) -> "Instance":
"""Return instance with given id.

Arguments:
Expand All @@ -105,7 +105,6 @@ def get_instance(id: "str", metaid: "str" = None, check_storages: "bool" = True)

Returns:
DLite Instance.

"""
if isinstance(id, Instance):
inst = id
Expand Down
13 changes: 6 additions & 7 deletions bindings/python/dlite-entity.i
Original file line number Diff line number Diff line change
Expand Up @@ -622,22 +622,21 @@ Call signatures:
}

%feature("docstring", "\
Return property ``name`` as a string.
Return property `name` as a string.

Parameters:
Arguments:
width: Minimum field width. Unused if 0, auto if -1.
prec: Precision. Auto if -1, unused if -2.
flags: Or'ed sum of formatting flags:

- ``0``: Default (json).
- ``1``: Raw unquoted output.
- ``2``: Quoted output.
- `0`: Default (json).
- `1`: Raw unquoted output.
- `2`: Quoted output.

Returns:
Property as a string.

")
get_property_as_string;
") get_property_as_string;
%newobject get_property_as_string;
char *get_property_as_string(const char *name,
int width=0, int prec=-2, int flags=0) {
Expand Down
8 changes: 4 additions & 4 deletions bindings/python/dlite-misc-python.i
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class err():
"""Context manager for temporary turning off or redirecting errors.
By default errors are skipped within the err context. But if
``filename`` is provided, the error messages are written to that file.
`filename` is provided, the error messages are written to that file.
Special file names includes:
- ``None`` or empty: No output is written.
- ``<stderr>``: Write errors to stderr (default).
- ``<stdout>``: Write errors to stdout.
- "None" or empty: No output is written.
- "<stderr>": Write errors to stderr (default).
- "<stdout>": Write errors to stdout.
"""
def __init__(self, filename=None):
Expand Down
36 changes: 18 additions & 18 deletions bindings/python/dlite-misc.i
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,23 @@ const char *dlite_get_license(void);
%feature("docstring", "\
Returns an UUID, depending on:

- If ``id`` is NULL or empty, generates a new random version 4 UUID.
- If ``id`` is not a valid UUID string, generates a new version 5 sha1-based
UUID from ``id`` using the DNS namespace.
- If `id` is NULL or empty, generates a new random version 4 UUID.
- If `id` is not a valid UUID string, generates a new version 5 sha1-based
UUID from `id` using the DNS namespace.

Otherwise return ``id`` (which already must be a valid UUID).
Otherwise return `id` (which already must be a valid UUID).
") dlite_get_uuid;
%cstring_bounded_output(char *buff36, DLITE_UUID_LENGTH+1);
void dlite_get_uuid(char *buff36, const char *id=NULL);

%feature("docstring", "\
Returns the generated UUID version number if ``id`` had been passed to
get_uuid() or zero if ``id`` is already a valid UUID.
Returns the generated UUID version number if `id` had been passed to
get_uuid() or zero if `id` is already a valid UUID.
") get_uuid_version;
posstatus_t get_uuid_version(const char *id=NULL);

%feature("docstring", "\
Returns a (metadata) uri by combining ``name``, ``version`` and ``namespace`` as:
Returns a (metadata) uri by combining `name`, `version` and `namespace` as:

namespace/version/name
") dlite_join_meta_uri;
Expand All @@ -68,7 +68,7 @@ char *dlite_join_meta_uri(const char *name, const char *version,


%feature("docstring", "\
Returns (name, version, namespace)-tuplet from valid metadata ``uri``.
Returns (name, version, namespace)-tuplet from valid metadata `uri`.
") dlite_split_meta_uri;
%cstring_output_allocate(char **name, if (*$1) free(*$1));
%cstring_output_allocate(char **version, if (*$1) free(*$1));
Expand All @@ -83,15 +83,15 @@ Returns an url constructed from the arguments of the form:
driver://location?options#fragment
The ``driver``, ``options`` and ``fragment`` arguments may be None.
The `driver`, `options` and `fragment` arguments may be None.
") dlite_join_url;
%newobject dlite_join_url;
char *dlite_join_url(const char *driver, const char *location,
const char *options=NULL, const char *fragment=NULL);

%feature("docstring", "\
Returns a (driver, location, options, fragment)-tuplet by splitting
``url`` of the form
`url` of the form
driver://location?options#fragment
Expand All @@ -111,11 +111,11 @@ match.

Understands the following patterns:

- ``*``: Any number of characters.
- ``?``: Any single character.
- ``[a-z]``: Any single character in the range a-z.
- ``[^a-z]``: Any single character not in the range a-z.
- ``\\x``: Match x.
- `*`: Any number of characters.
- `?`: Any single character.
- `[a-z]`: Any single character in the range a-z.
- `[^a-z]`: Any single character not in the range a-z.
- `\\x`: Match x.
") globmatch;
int globmatch(const char *pattern, const char *s);

Expand Down Expand Up @@ -150,9 +150,9 @@ void dlite_err_set_stream(FILE *);
%feature("docstring", "\
Set error log file. Special values includes:

- ``None`` or empty: Turn off error output.
- ``<stderr>``: Standard error.
- ``<stdout>``: Standard output.
- `None` or empty: Turn off error output.
- `<stderr>`: Standard error.
- `<stdout>`: Standard output.

All other values are treated as a filename that will be opened in append mode.
") dlite_err_set_file;
Expand Down
1 change: 1 addition & 0 deletions bindings/python/dlite-python.i
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ obj_t *dlite_swig_get_scalar(DLiteType type, size_t size, void *data)
case 4: value = *((float32_t *)data); break;
case 8: value = *((float64_t *)data); break;
#ifdef HAVE_FLOAT80_T
// TODO: check for overflow
case 10: value = *((float80_t *)data); break;
#endif
#ifdef HAVE_FLOAT96_T
Expand Down
20 changes: 7 additions & 13 deletions bindings/python/dlite-storage.i
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

/* Storage iterator */
%feature("docstring", "\
Iterates over instances in storage ``s``. If ``pattern`` is given, only
instances whos metadata URI matches ``pattern`` are returned.
Iterates over instances in storage `s`. If `pattern` is given, only
instances whos metadata URI matches `pattern` are returned.
") StorageIterator;
%inline %{
struct StorageIterator {
Expand Down Expand Up @@ -57,7 +57,7 @@ Returns next instance or None if exhausted.") next;
enum _DLiteIDFlag {
dliteIDTranslateToUUID=0, /*!< Translate id's that are not a valid UUID to
a (version 5) UUID (default). */
dliteIDRequireUUID=1, /*!< Require that ``id`` is a valid UUID. */
dliteIDRequireUUID=1, /*!< Require that `id` is a valid UUID. */
dliteIDKeepID=2 /*!< Store data under the given id, even if it
is not a valid UUID. Not SOFT compatible,
but may be useful for input files. */
Expand All @@ -71,7 +71,7 @@ Represents a data storage.
Parameters
----------
driver_or_url : string
Name of driver used to connect to the storage or, if ``location`` is not
Name of driver used to connect to the storage or, if `location` is not
given, the URL to the storage:

driver://location?options
Expand All @@ -80,14 +80,8 @@ location : string
The location to the storage. For file storages, this is the file name.
options : string
Additional options passed to the driver as a list of semicolon-separated
``key=value`` pairs. Each driver may have their own options. Some
common options are:

- ``mode={'append','r','w'}``:
- 'append': Append to existing storage or create a new one (hdf5,json).
- ``compact={'yes','no'}``: Whether to store in a compact format (json).
- ``meta={'yes','no'}``: Whether to format output as metadata (json).

``key=value`` pairs. See the documentation of the individual drivers to
see which options they support.
") _DLiteStorage;
%rename(Storage) _DLiteStorage;

Expand Down Expand Up @@ -138,7 +132,7 @@ struct _DLiteStorage {

%feature("docstring",
"Returns a list of UUIDs of all instances in the storage whos "
"metadata matches ``pattern``. If ``pattern`` is None, all UUIDs "
"metadata matches `pattern`. If `pattern` is None, all UUIDs "
"will be returned.") get_uuids;
char **get_uuids(const char *pattern=NULL) {
return dlite_storage_uuids($self, pattern);
Expand Down
Loading

0 comments on commit 0ce89e1

Please sign in to comment.