terminusdb / terminusdb-client-python

@@ -158,7 +158,7 @@
Loading
158 158
                setattr(obj, key, value)
159 159
            if kwargs.get("_id"):
160 160
                obj._id = kwargs.get("_id")
161 -
            elif hasattr(obj, "_subdocument"):
161 +
            elif hasattr(obj.__class__, "_subdocument"):
162 162
                pass
163 163
            elif hasattr(obj, "_key") and hasattr(obj._key, "idgen"):
164 164
                obj._id = obj._key.idgen(obj)

@@ -3,6 +3,7 @@
Loading
3 3
4 4
# import pprint
5 5
import re
6 +
import warnings
6 7
7 8
from .woql_core import _copy_dict, _path_tokenize, _path_tokens_to_json
8 9
@@ -76,9 +77,9 @@
Loading
76 77
        self.subsumption = self.sub
77 78
        self.equals = self.eq
78 79
        self.substring = self.substr
79 -
        self.update = self.update_object
80 -
        self.delete = self.delete_object
81 -
        self.read = self.read_object
80 +
        self.update = self.update_document  # self.update_object
81 +
        self.delete = self.delete_document  # self.delete_object
82 +
        self.read = self.read_document  # self.read_object
82 83
        self.optional = self.opt
83 84
        self.idgenerator = self.idgen
84 85
        self.concatenate = self.concat
@@ -1163,35 +1164,99 @@
Loading
1163 1164
        return self
1164 1165
1165 1166
    def update_object(self, docjson):
1167 +
        warnings.warn(
1168 +
            "update_object() is deprecated; use update_document()",
1169 +
            warnings.DeprecationWarning,
1170 +
        )
1171 +
        return self.update_document(docjson)
1172 +
        # if docjson and docjson == "args":
1173 +
        #     return ["document"]
1174 +
        # if self._cursor.get("@type"):
1175 +
        #     self._wrap_cursor_with_and()
1176 +
        # self._cursor["@type"] = "UpdateObject"
1177 +
        # if isinstance(docjson, str):
1178 +
        #     doc = self._expand_data_value(docjson)
1179 +
        # else:
1180 +
        #     doc = docjson
1181 +
        # self._cursor["document"] = doc
1182 +
        # return self._updated()
1183 +
1184 +
    def update_document(self, docjson, json_or_iri=None):
1166 1185
        if docjson and docjson == "args":
1167 1186
            return ["document"]
1168 1187
        if self._cursor.get("@type"):
1169 1188
            self._wrap_cursor_with_and()
1170 -
        self._cursor["@type"] = "UpdateObject"
1189 +
        self._cursor["@type"] = "UpdateDocument"
1171 1190
        if isinstance(docjson, str):
1172 -
            doc = self._expand_data_value(docjson)
1191 +
            doc = self._expand_value_variable(docjson)
1173 1192
        else:
1174 1193
            doc = docjson
1175 1194
        self._cursor["document"] = doc
1195 +
        if json_or_iri is not None:
1196 +
            self._cursor["identifier"] = self._clean_node_value(json_or_iri)
1197 +
        return self._updated()
1198 +
1199 +
    def insert_document(self, docjson, json_or_iri=None):
1200 +
        if docjson and docjson == "args":
1201 +
            return ["document"]
1202 +
        if self._cursor.get("@type"):
1203 +
            self._wrap_cursor_with_and()
1204 +
        self._cursor["@type"] = "InsertDocument"
1205 +
        if isinstance(docjson, str):
1206 +
            doc = self._expand_value_variable(docjson)
1207 +
        else:
1208 +
            doc = docjson
1209 +
        self._cursor["document"] = doc
1210 +
        if json_or_iri is not None:
1211 +
            self._cursor["identifier"] = self._clean_node_value(json_or_iri)
1176 1212
        return self._updated()
1177 1213
1178 1214
    def delete_object(self, json_or_iri):
1215 +
        warnings.warn(
1216 +
            "delete_object() is deprecated; use delete_document()",
1217 +
            warnings.DeprecationWarning,
1218 +
        )
1219 +
        return self.delete_document(json_or_iri)
1220 +
        # if json_or_iri and json_or_iri == "args":
1221 +
        #     return ["document"]
1222 +
        # if self._cursor.get("@type"):
1223 +
        #     self._wrap_cursor_with_and()
1224 +
        # self._cursor["@type"] = "DeleteObject"
1225 +
        # self._cursor["document_uri"] = self._clean_node_value(json_or_iri)
1226 +
        # return self._updated()
1227 +
1228 +
    def delete_document(self, json_or_iri):
1179 1229
        if json_or_iri and json_or_iri == "args":
1180 1230
            return ["document"]
1181 1231
        if self._cursor.get("@type"):
1182 1232
            self._wrap_cursor_with_and()
1183 -
        self._cursor["@type"] = "DeleteObject"
1184 -
        self._cursor["document_uri"] = self._clean_node_value(json_or_iri)
1233 +
        self._cursor["@type"] = "DeleteDocument"
1234 +
        self._cursor["identifier"] = self._clean_node_value(json_or_iri)
1185 1235
        return self._updated()
1186 1236
1187 1237
    def read_object(self, iri, output_var):
1238 +
        warnings.warn(
1239 +
            "read_object() is deprecated; use read_document()",
1240 +
            warnings.DeprecationWarning,
1241 +
        )
1242 +
        return self.read_document(iri, output_var)
1243 +
        # if iri and iri == "args":
1244 +
        #     return ["document"]
1245 +
        # if self._cursor.get("@type"):
1246 +
        #     self._wrap_cursor_with_and()
1247 +
        # self._cursor["@type"] = "ReadObject"
1248 +
        # self._cursor["document_uri"] = iri
1249 +
        # self._cursor["document"] = self._expand_data_variable(output_var)
1250 +
        # return self
1251 +
1252 +
    def read_document(self, iri, output_var):
1188 1253
        if iri and iri == "args":
1189 1254
            return ["document"]
1190 1255
        if self._cursor.get("@type"):
1191 1256
            self._wrap_cursor_with_and()
1192 -
        self._cursor["@type"] = "ReadObject"
1193 -
        self._cursor["document_uri"] = iri
1194 -
        self._cursor["document"] = self._expand_data_variable(output_var)
1257 +
        self._cursor["@type"] = "ReadDocument"
1258 +
        self._cursor["identifier"] = self._clean_node_value(iri)
1259 +
        self._cursor["document"] = self._expand_value_variable(output_var)
1195 1260
        return self
1196 1261
1197 1262
    def get(self, as_vars, query_resource=None):
Files Coverage
terminusdb_client 64.72%
Project Totals (11 files) 64.72%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading