-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathn0struct.pydoc
1851 lines (1696 loc) · 85 KB
/
n0struct.pydoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
Help on package n0struct:
NAME
n0struct
DESCRIPTION
list/dict extensions allow to
* work (find/get/set/update) with tree-like structures, generated for example by json.loads(..), using xpath approach
* direct/wise compare lists/dictionaries/tree-like structures + exclude sub-nodes from comparison
* transform on the fly values in attributes during comparing
* .to_json(): convert tree-like structures into string buffer for saving into JSON file
* .to_xml(): convert tree-like structures into string buffer for saving into XML file
* .to_xpath: convert tree-like structures into string buffer for saving into XPATH file
PACKAGE CONTENTS
n0struct_arrays
n0struct_comprehensions
n0struct_date
n0struct_files
n0struct_files_csv
n0struct_files_fwf
n0struct_findall
n0struct_git
n0struct_logging
n0struct_mask
n0struct_n0dict_
n0struct_n0dict__
n0struct_n0list_
n0struct_n0list_n0dict
n0struct_random
n0struct_references
n0struct_transform_structure
n0struct_utils
n0struct_utils_compare
n0struct_utils_find
test (package)
CLASSES
builtins.object
n0struct.n0struct_git.Git
collections.abc.MutableSet(collections.abc.Set)
n0struct.n0struct_references.OrderedSet
n0struct.n0struct_n0dict_.n0dict_(n0struct.n0struct_n0dict__.n0dict__)
n0struct.n0struct_n0list_n0dict.n0dict
n0struct.n0struct_n0list_.n0list_(builtins.list)
n0struct.n0struct_n0list_n0dict.n0list
pathlib.PurePath(builtins.object)
pathlib.Path
class Git(builtins.object)
| Git(repo_root_dir: str, repository_url: str, rsa_key_path: str = '', show_result=False)
|
| # ******************************************************************************
| # ******************************************************************************
|
| Methods defined here:
|
| __init__(self, repo_root_dir: str, repository_url: str, rsa_key_path: str = '', show_result=False)
| Initialize self. See help(type(self)) for accurate signature.
|
| checkout(self, branch_name: str, show_result=None)
| # ##############################################################################################
|
| log(self, git_arguments: Union[str, list])
| # ##############################################################################################
|
| run(self, git_arguments: Union[str, list], show_result=None) -> tuple
| # ##############################################################################################
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
class OrderedSet(collections.abc.MutableSet)
| OrderedSet(iterable=None)
|
| # ******************************************************************************
| # ******************************************************************************
| # https://stackoverflow.com/questions/1653970/does-python-have-an-ordered-set
| # https://code.activestate.com/recipes/576694/
|
| Method resolution order:
| OrderedSet
| collections.abc.MutableSet
| collections.abc.Set
| collections.abc.Collection
| collections.abc.Sized
| collections.abc.Iterable
| collections.abc.Container
| builtins.object
|
| Methods defined here:
|
| __contains__(self, key) -> bool
|
| __eq__(self, other) -> bool
| Return self==value.
|
| __init__(self, iterable=None)
| Initialize self. See help(type(self)) for accurate signature.
|
| __iter__(self) -> Generator
|
| __len__(self) -> int
|
| __repr__(self) -> str
| Return repr(self).
|
| __reversed__(self) -> Generator
|
| add(self, key)
| Add an element.
|
| discard(self, key)
| Remove an element. Do not raise an exception if absent.
|
| pop(self, last=True) -> Any
| Return the popped value. Raise KeyError if empty.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __hash__ = None
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.MutableSet:
|
| __iand__(self, it)
|
| __ior__(self, it)
|
| __isub__(self, it)
|
| __ixor__(self, it)
|
| clear(self)
| This is slow (creates N new iterators!) but effective.
|
| remove(self, value)
| Remove an element. If not a member, raise a KeyError.
|
| ----------------------------------------------------------------------
| Methods inherited from collections.abc.Set:
|
| __and__(self, other)
|
| __ge__(self, other)
| Return self>=value.
|
| __gt__(self, other)
| Return self>value.
|
| __le__(self, other)
| Return self<=value.
|
| __lt__(self, other)
| Return self<value.
|
| __or__(self, other)
| Return self|value.
|
| __rand__ = __and__(self, other)
|
| __ror__ = __or__(self, other)
|
| __rsub__(self, other)
|
| __rxor__ = __xor__(self, other)
|
| __sub__(self, other)
|
| __xor__(self, other)
|
| isdisjoint(self, other)
| Return True if two sets have a null intersection.
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Collection:
|
| __subclasshook__(C) from abc.ABCMeta
| Abstract classes can override this to customize issubclass().
|
| This is invoked early on by abc.ABCMeta.__subclasscheck__().
| It should return True, False or NotImplemented. If it returns
| NotImplemented, the normal algorithm is used. Otherwise, it
| overrides the normal algorithm (and the outcome is cached).
|
| ----------------------------------------------------------------------
| Class methods inherited from collections.abc.Iterable:
|
| __class_getitem__ = GenericAlias(...) from abc.ABCMeta
| Represent a PEP 585 generic type
|
| E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).
class Path(PurePath)
| Path(*args, **kwargs)
|
| PurePath subclass that can make system calls.
|
| Path represents a filesystem path but unlike PurePath, also offers
| methods to do system calls on path objects. Depending on your system,
| instantiating a Path will return either a PosixPath or a WindowsPath
| object. You can also instantiate a PosixPath or WindowsPath directly,
| but cannot instantiate a WindowsPath on a POSIX system or vice versa.
|
| Method resolution order:
| Path
| PurePath
| builtins.object
|
| Methods defined here:
|
| __enter__(self)
|
| __exit__(self, t, v, tb)
|
| absolute(self)
| Return an absolute version of this path by prepending the current
| working directory. No normalization or symlink resolution is performed.
|
| Use resolve() to get the canonical path to a file.
|
| chmod(self, mode, *, follow_symlinks=True)
| Change the permissions of the path, like os.chmod().
|
| exists(self)
| Whether this path exists.
|
| expanduser(self)
| Return a new path with expanded ~ and ~user constructs
| (as returned by os.path.expanduser)
|
| glob(self, pattern)
| Iterate over this subtree and yield all existing files (of any
| kind, including directories) matching the given relative pattern.
|
| group(self)
| Return the group name of the file gid.
|
| hardlink_to(self, target)
| Make this path a hard link pointing to the same file as *target*.
|
| Note the order of arguments (self, target) is the reverse of os.link's.
|
| is_block_device(self)
| Whether this path is a block device.
|
| is_char_device(self)
| Whether this path is a character device.
|
| is_dir(self)
| Whether this path is a directory.
|
| is_fifo(self)
| Whether this path is a FIFO.
|
| is_file(self)
| Whether this path is a regular file (also True for symlinks pointing
| to regular files).
|
| is_mount(self)
| Check if this path is a POSIX mount point
|
| is_socket(self)
| Whether this path is a socket.
|
| is_symlink(self)
| Whether this path is a symbolic link.
|
| iterdir(self)
| Iterate over the files in this directory. Does not yield any
| result for the special paths '.' and '..'.
|
| lchmod(self, mode)
| Like chmod(), except if the path points to a symlink, the symlink's
| permissions are changed, rather than its target's.
|
| link_to(self, target)
| Make the target path a hard link pointing to this path.
|
| Note this function does not make this path a hard link to *target*,
| despite the implication of the function and argument names. The order
| of arguments (target, link) is the reverse of Path.symlink_to, but
| matches that of os.link.
|
| Deprecated since Python 3.10 and scheduled for removal in Python 3.12.
| Use `hardlink_to()` instead.
|
| lstat(self)
| Like stat(), except if the path points to a symlink, the symlink's
| status information is returned, rather than its target's.
|
| mkdir(self, mode=511, parents=False, exist_ok=False)
| Create a new directory at this given path.
|
| open(self, mode='r', buffering=-1, encoding=None, errors=None, newline=None)
| Open the file pointed by this path and return a file object, as
| the built-in open() function does.
|
| owner(self)
| Return the login name of the file owner.
|
| read_bytes(self)
| Open the file in bytes mode, read it, and close the file.
|
| read_text(self, encoding=None, errors=None)
| Open the file in text mode, read it, and close the file.
|
| readlink(self)
| Return the path to which the symbolic link points.
|
| rename(self, target)
| Rename this path to the target path.
|
| The target path may be absolute or relative. Relative paths are
| interpreted relative to the current working directory, *not* the
| directory of the Path object.
|
| Returns the new Path instance pointing to the target path.
|
| replace(self, target)
| Rename this path to the target path, overwriting if that path exists.
|
| The target path may be absolute or relative. Relative paths are
| interpreted relative to the current working directory, *not* the
| directory of the Path object.
|
| Returns the new Path instance pointing to the target path.
|
| resolve(self, strict=False)
| Make the path absolute, resolving all symlinks on the way and also
| normalizing it.
|
| rglob(self, pattern)
| Recursively yield all existing files (of any kind, including
| directories) matching the given relative pattern, anywhere in
| this subtree.
|
| rmdir(self)
| Remove this directory. The directory must be empty.
|
| samefile(self, other_path)
| Return whether other_path is the same or not as this file
| (as returned by os.path.samefile()).
|
| stat(self, *, follow_symlinks=True)
| Return the result of the stat() system call on this path, like
| os.stat() does.
|
| symlink_to(self, target, target_is_directory=False)
| Make this path a symlink pointing to the target path.
| Note the order of arguments (link, target) is the reverse of os.symlink.
|
| touch(self, mode=438, exist_ok=True)
| Create this file with the given access mode, if it doesn't exist.
|
| unlink(self, missing_ok=False)
| Remove this file or link.
| If the path is a directory, use rmdir() instead.
|
| write_bytes(self, data)
| Open the file in bytes mode, write to it, and close the file.
|
| write_text(self, data, encoding=None, errors=None, newline=None)
| Open the file in text mode, write to it, and close the file.
|
| ----------------------------------------------------------------------
| Class methods defined here:
|
| cwd() from builtins.type
| Return a new path pointing to the current working directory
| (as returned by os.getcwd()).
|
| home() from builtins.type
| Return a new path pointing to the user's home directory (as
| returned by os.path.expanduser('~')).
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| __new__(cls, *args, **kwargs)
| Construct a PurePath from one or several strings and or existing
| PurePath objects. The strings and path objects are combined so as
| to yield a canonicalized path, which is incorporated into the
| new PurePath object.
|
| ----------------------------------------------------------------------
| Methods inherited from PurePath:
|
| __bytes__(self)
| Return the bytes representation of the path. This is only
| recommended to use under Unix.
|
| __eq__(self, other)
| Return self==value.
|
| __fspath__(self)
|
| __ge__(self, other)
| Return self>=value.
|
| __gt__(self, other)
| Return self>value.
|
| __hash__(self)
| Return hash(self).
|
| __le__(self, other)
| Return self<=value.
|
| __lt__(self, other)
| Return self<value.
|
| __reduce__(self)
| Helper for pickle.
|
| __repr__(self)
| Return repr(self).
|
| __rtruediv__(self, key)
|
| __str__(self)
| Return the string representation of the path, suitable for
| passing to system calls.
|
| __truediv__(self, key)
|
| as_posix(self)
| Return the string representation of the path with forward (/)
| slashes.
|
| as_uri(self)
| Return the path as a 'file' URI.
|
| is_absolute(self)
| True if the path is absolute (has both a root and, if applicable,
| a drive).
|
| is_relative_to(self, *other)
| Return True if the path is relative to another path or False.
|
| is_reserved(self)
| Return True if the path contains one of the special names reserved
| by the system, if any.
|
| joinpath(self, *args)
| Combine this path with one or several arguments, and return a
| new path representing either a subpath (if all arguments are relative
| paths) or a totally different path (if one of the arguments is
| anchored).
|
| match(self, path_pattern)
| Return True if this path matches the given pattern.
|
| relative_to(self, *other)
| Return the relative path to another path identified by the passed
| arguments. If the operation is not possible (because this is not
| a subpath of the other path), raise ValueError.
|
| with_name(self, name)
| Return a new path with the file name changed.
|
| with_stem(self, stem)
| Return a new path with the stem changed.
|
| with_suffix(self, suffix)
| Return a new path with the file suffix changed. If the path
| has no suffix, add given suffix. If the given suffix is an empty
| string, remove the suffix from the path.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from PurePath:
|
| anchor
| The concatenation of the drive and root, or ''.
|
| drive
| The drive prefix (letter or UNC path), if any.
|
| name
| The final path component, if any.
|
| parent
| The logical parent of the path.
|
| parents
| A sequence of this path's logical parents.
|
| parts
| An object providing sequence-like access to the
| components in the filesystem path.
|
| root
| The root of the path, if any.
|
| stem
| The final path component, minus its last suffix.
|
| suffix
| The final component's last suffix, if any.
|
| This includes the leading period. For example: '.txt'
|
| suffixes
| A list of the final component's suffixes, if any.
|
| These include the leading periods. For example: ['.tar', '.gz']
class n0dict(n0struct.n0struct_n0dict_.n0dict_)
| n0dict(*args, **kw)
|
| https://github.com/martinblech/xmltodict/issues/252
| For Python >= 3.6, dictionary are Sorted by insertion order, so avoid the use of OrderedDict for those python versions.
|
| Method resolution order:
| n0dict
| n0struct.n0struct_n0dict_.n0dict_
| n0struct.n0struct_n0dict__.n0dict__
| builtins.dict
| builtins.object
|
| Methods defined here:
|
| __init__(self, *args, **kw)
| args == tuple, kw == mapping(dictionary)
|
| * == convert from tuple into list of arguments
| ** == convert from mapping into list of named arguments
|
| :param args:
| :param kw:
| force_dict=True => leave JSON subnodes as dict.
| by default all dictionaries will be converted into n0dict,
| but all lists will stay lists. lists could be
| converted into n0list only with recursively=True.
| force_dict=True is required to slightly decrease time for convertion of JSON-text into structure.
|
| recursively=??? => removed. required to use n0dict.convert_recursively(dict/n0dict)
|
| file=f"{file_path}" => load XML-text/JSON-text from {file_path}
|
| compare(self, other: 'n0dict', self_name: 'str' = 'self', other_name: 'str' = 'other', prefix: 'str' = '', continuity_check='continuity_check', one_of_list_compare=<function n0list.compare>, composite_key: 'tuple' = (), compare_only: 'tuple' = (), exclude_xpaths: 'tuple' = (), transform: 'typing.Tuple[typing.Tuple[str, typing.Callable, typing.Callable]]' = ()) -> 'n0dict'
| # **************************************************************************
| # * n0dict. compare(..)
| # **************************************************************************
|
| direct_compare(self, other: 'n0dict', self_name: 'str' = 'self', other_name: 'str' = 'other', prefix: 'str' = '', continuity_check='continuity_check', one_of_list_compare=<function n0list.direct_compare>, composite_key: 'tuple' = (), compare_only: 'tuple' = (), exclude_xpaths: 'tuple' = (), transform: 'tuple' = ()) -> 'n0dict'
| # **************************************************************************
| # * n0dict. direct_compare(..)
| # **************************************************************************
|
| ----------------------------------------------------------------------
| Static methods defined here:
|
| convert_recursively(node: 'typing.Any', xpath: 'str' = '/', level: 'int' = 0) -> 'typing.Any'
| # **************************************************************************
| # **************************************************************************
|
| ----------------------------------------------------------------------
| Methods inherited from n0struct.n0struct_n0dict_.n0dict_:
|
| to_json(self, indent: int = 4, pairs_in_one_line=True, json_convention: bool = True, skip_empty_arrays: bool = False, compress: bool = False) -> str
| Public function: export self into json result string
|
| to_xml(self, indent: int = 4, encoding: str = 'utf-8', quote: str = '"') -> str
| Public function: export self into xml result string
|
| to_xpath(self, mode: int = None) -> str
| Public function: collect elements xpath starts from root and print with indents
|
| xpath(self, mode: int = None) -> list
| Public function: collect elements xpath starts from root
|
| ----------------------------------------------------------------------
| Methods inherited from n0struct.n0struct_n0dict__.n0dict__:
|
| __getitem__(self, xpath)
| Public function:
| return self[where1/where2/.../whereN]
| AKA
| return self[where1][where2]...[whereN]
|
| If any of [where1][where2]...[whereN] are not found, exception IndexError will be raised
|
| __setitem__(self, xpath: 'typing.Union[str, int]', new_value)
| Public function:
| self[where1/where2/.../whereN] = value
| AKA
| self[where1][where2]...[whereN] = value
|
| if xpath will be started with ?, the nothing will be done if new_value is None or empty
| if xpath is exist, then the value will be overwritten
| if not exist, then the node will be created
|
| could be used predicates:
| [<item>=<value>]
| [<item>='<value>']
| or indexes
| [0]
| [1]
| [2]
| [-1]
| [-2]
| [-3]
| or functions
| [last()]
| [last()-1]
| [last()-2]
| or commands for creating (convertion into list) new node
| [new()]
|
| all_not_valid(self, validate)
| # **************************************************************************
|
| all_valid(self, validate)
| # **************************************************************************
|
| any_not_valid(self, validate)
| # **************************************************************************
|
| any_valid(self, validate)
| # **************************************************************************
|
| delete(self, xpath: 'str', recursively: 'bool' = False) -> 'n0dict__'
| # **************************************************************************
|
| findall(self, xpath: 'str', raise_exception: 'bool' = True)
|
| findfirst(self, xpath: 'str', raise_exception: 'bool' = True)
|
| first(self, xpath: 'str', if_not_found=None)
| Public function:
| return self[where1/where2/.../whereN]
| AKA
| return self[where1][where2]...[whereN]
|
| If any of [where1][where2]...[whereN] are not found, if_not_found will be returned
| If self[where1/where2/.../whereN] is list, thet the first element will be returned
|
| get(self, xpath: 'str', if_not_found=None)
| Public function:
| return self[where1/where2/.../whereN]
| AKA
| return self[where1][where2]...[whereN]
|
| If any of [where1][where2]...[whereN] are not found, if_not_found will be returned
|
| has_all(self, tupple_of_keys: 'typing.Union[tuple, list]') -> 'bool'
| # **************************************************************************
| # **************************************************************************
|
| has_any_of(self, tupple_of_keys: 'typing.Union[tuple, list]') -> 'bool'
| # **************************************************************************
| # **************************************************************************
|
| isEqual(self, xpath, value)
| Public function: return empty lists in dict, if self[xpath] == value
|
| isExist(self, xpath) -> 'dict'
| Public function: return empty lists in dict, if self[xpath] exists
|
| isTheSame(self, xpath, other_n0dict, other_xpath=None, transformation=<function n0dict__.<lambda>>)
| Public function: return empty lists in dict, if transformation(self[xpath]) == transformation(other_n0dict[other_xpath])
|
| is_exist(self, xpath: 'str') -> 'bool'
| Public function: return True, if self[xpath] exists
|
| pop(self, xpath: 'str', if_not_found=None, recursively: 'bool' = False) -> 'typing.Any'
| D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
|
| If the key is not found, return the default if given; otherwise,
| raise a KeyError.
|
| update_extend(self, other)
| # **************************************************************************
| # **************************************************************************
|
| valid(self, node_xpath: 'str', validate, expected_result_for_error: 'bool' = False, msg: 'str' = None)
| :param node_xpath:
| xpath to the node inside self
| :param validate:
| list/scalar/function = validation
| :param expected_result_for_error:
| By default expected that if result of validation is True, then self[node_xpath] is not valid (return False)
| :param msg:
| if None => return result as bool True(validation)/False
| :return:
|
| Examples:
| xml.valid('node/subnode', ["", None], True, "ERROR")
| If xml['node/subnode'] is equal "" or None (result of comparising is True), then return ERROR, else ""
| xml.valid('node/subnode', ["", None], True)
| If xml['node/subnode'] is equal "" or None (result of comparising is True), then return False (not valid), else True
| xml.valid('node/subnode', "", True)
| If xml['node/subnode'] is equal "" (result of comparising is True), then return False (not valid), else True
| xml.valid('node/subnode', [1, 2], False, "ERROR")
| If xml['node/subnode'] is not equal 1 or 2 (result of comparising is False), then return ERROR, else ""
| xml.valid('node/subnode', [1, 2], False)
| If xml['node/subnode'] is not equal 1 or 2 (result of comparising is False), then return False (not valid), else True
| xml.valid('node/subnode', [1, 2])
| If xml['node/subnode'] is not equal 1 or 2 (result of comparising is False), then return False (not valid), else True
|
| ----------------------------------------------------------------------
| Data descriptors inherited from n0struct.n0struct_n0dict__.n0dict__:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.dict:
|
| __contains__(self, key, /)
| True if the dictionary has the specified key, else False.
|
| __delitem__(self, key, /)
| Delete self[key].
|
| __eq__(self, value, /)
| Return self==value.
|
| __ge__(self, value, /)
| Return self>=value.
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __gt__(self, value, /)
| Return self>value.
|
| __ior__(self, value, /)
| Return self|=value.
|
| __iter__(self, /)
| Implement iter(self).
|
| __le__(self, value, /)
| Return self<=value.
|
| __len__(self, /)
| Return len(self).
|
| __lt__(self, value, /)
| Return self<value.
|
| __ne__(self, value, /)
| Return self!=value.
|
| __or__(self, value, /)
| Return self|value.
|
| __repr__(self, /)
| Return repr(self).
|
| __reversed__(self, /)
| Return a reverse iterator over the dict keys.
|
| __ror__(self, value, /)
| Return value|self.
|
| __sizeof__(...)
| D.__sizeof__() -> size of D in memory, in bytes
|
| clear(...)
| D.clear() -> None. Remove all items from D.
|
| copy(...)
| D.copy() -> a shallow copy of D
|
| items(...)
| D.items() -> a set-like object providing a view on D's items
|
| keys(...)
| D.keys() -> a set-like object providing a view on D's keys
|
| popitem(self, /)
| Remove and return a (key, value) pair as a 2-tuple.
|
| Pairs are returned in LIFO (last-in, first-out) order.
| Raises KeyError if the dict is empty.
|
| setdefault(self, key, default=None, /)
| Insert key with a value of default if key is not in the dictionary.
|
| Return the value for key if key is in the dictionary, else default.
|
| update(...)
| D.update([E, ]**F) -> None. Update D from dict/iterable E and F.
| If E is present and has a .keys() method, then does: for k in E: D[k] = E[k]
| If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v
| In either case, this is followed by: for k in F: D[k] = F[k]
|
| values(...)
| D.values() -> an object providing a view on D's values
|
| ----------------------------------------------------------------------
| Class methods inherited from builtins.dict:
|
| __class_getitem__(...) from builtins.type
| See PEP 585
|
| fromkeys(iterable, value=None, /) from builtins.type
| Create a new dictionary with keys from iterable and values set to value.
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.dict:
|
| __new__(*args, **kwargs) from builtins.type
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from builtins.dict:
|
| __hash__ = None
class n0list(n0struct.n0struct_n0list_.n0list_)
| n0list(*args, **kw)
|
| Class extended builtins.list(builtins.object) with additional methods:
| . direct_compare() = compare element self[i] with other[i] with the same indexes
| . compare() = compare element self[i] with any other[?] WITHOUT using sorting
|
| Method resolution order:
| n0list
| n0struct.n0struct_n0list_.n0list_
| builtins.list
| builtins.object
|
| Methods defined here:
|
| __init__(self, *args, **kw)
| args == tuple, kw == mapping(dictionary)
|
| * == convert from tuple into list of arguments
| ** == convert from mapping into list of named arguments
|
| :param args:
| :param kw:
| force_dict=True => leave JSON subnodes as dict.
| by default all dictionaries will be converted into n0dict,
| but all lists will stay lists. lists could be converted into n0list only
| with n0dict.convert_recursively(dict/n0dict).
| force_dict=True is required to slightly decrease time for convertion of JSON-text into structure.
|
| recursively=??? => removed. required to use n0dict.convert_recursively(dict/n0dict)
|
| file=f"{file_path}" => load JSON-text from {file_path}
|
| compare(self, other: 'n0list', self_name: 'str' = 'self', other_name: 'str' = 'other', prefix: 'str' = '', continuity_check: 'str' = 'continuity_check', composite_key: 'tuple' = (), compare_only: 'tuple' = (), exclude_xpaths: 'tuple' = (), transform: 'tuple' = ()) -> 'n0dict'
| Recursively compare self[i] with other[?] WITHOUT using order of elements.
| If self[i] is n0list/n0dict (and if other[?] is found with the same type),
| then goes deeper with n0list. compare(..)/n0dict.direct_compare(..)
|
| :param other:
| :param self_name:
| :param other_name:
| :param prefix:
| :param continuity_check:
| :param composite_key:
| :param compare_only:
| :param exclude_xpaths:
| :param transform: ()|None|empty mean nothing to transform, else [[<xpath to elem>,<lambda for transformatio>],..]
| :return:
| n0dict({
| "differences": [], # generated for each case of not equality
| "not_equal": [], # generated if elements with the same xpath and type are not equal
| "self_unique": [], # generated if elements from self list don't exist in other list
| "other_unique": [], # generated if elements from other list don't exist in self list
| "difftypes": [], # generated if elements with the same xpath have different types
| })
| if not returned["differences"]: self and other are equal with conditions:
| except exclude_xpaths;
| compare_only
| transform
|
| direct_compare(self, other: 'n0list', self_name: 'str' = 'self', other_name: 'str' = 'other', prefix: 'str' = '', continuity_check: 'str' = 'continuity_check', composite_key: 'tuple' = (), compare_only: 'tuple' = (), exclude_xpaths: 'tuple' = (), transform: 'tuple' = ()) -> 'n0dict'
| Recursively compare self[i] with other[i]
| strictly according to the order of elements.
| If self[i] (other[i] must be the same) is n0list/n0dict, then goes deeper
| with n0list.direct_compare/n0dict.direct_compare(..)
|
| :param self: etalon list for compare.
| :param other: list to compare with etalon
| :param self_name: <default = "self"> dict/list name, used in result["differences"]
| :param other_name: <default = "other"> dict/list name, used in result["differences"]
| :param prefix: <default = ""> xpath prefix, used for full xpath generation
| :param continuity_check: used for checking that below arguments are defined only with names
| :param composite_key: For compatibility with compare(..)
| :param compare_only: For compatibility with compare(..)
| :param exclude_xpaths: ()|None|empty mean nothing to exclude
| :param transform: ()|None|empty mean nothing to transform, else [[<xpath to elem>,<lambda for transformatio>],..]
| :return:
| n0dict({
| "differences": [], # generated for each case of not equality
| "not_equal": [], # generated if elements with the same xpath and type are not equal
| "self_unique": [], # generated if elements from self list don't exist in other list
| "other_unique": [], # generated if elements from other list don't exist in self list
| "difftypes": [], # generated if elements with the same xpath have different types
| })
| if not returned["differences"]: self and other are equal with conditions:
| except exclude_xpaths;
| compare_only
| transform
|
| ----------------------------------------------------------------------
| Methods inherited from n0struct.n0struct_n0list_.n0list_:
|
| __contains__(self, other_list)
| Return key in self.
|
| __getitem__(self, xpath)
| Public function:
| return self[where1/where2/.../whereN]
| AKA
| return self[where1][where2]...[whereN]
|
| If any of [where1][where2]...[whereN] are not found, exception IndexError will be raised
|
| all_in(self, other_list)
| # **************************************************************************
|
| all_not_in(self, other_list)
| # **************************************************************************
|
| any_in(self, other_list)
| # **************************************************************************
|
| any_not_in(self, other_list)
| # **************************************************************************
|
| consists_of_all(self, other_list)
| # **************************************************************************
|
| consists_of_any(self, other_list)
| # **************************************************************************
|
| findall(self, xpath: str, raise_exception: bool = True)
|
| findfirst(self, xpath: str, raise_exception: bool = True)
|
| first(self, xpath: str, if_not_found=None)
| Public function:
| return self[where1/where2/.../whereN]
| AKA
| return self[where1][where2]...[whereN]
|
| If any of [where1][where2]...[whereN] are not found, if_not_found will be returned
| If self[where1/where2/.../whereN] is list, thet the first element will be returned
|
| get(self, xpath: Union[str, int], if_not_found=None)
| Public function:
| return self[where1/where2/.../whereN]
| AKA
| return self[where1][where2]...[whereN]
|
| If any of [where1][where2]...[whereN] are not found, if_not_found will be returned
|
| not_consists_of_any(self, other_list)
| # **************************************************************************
|
| to_json(self, indent: int = 4, pairs_in_one_line=True, json_convention: bool = True, skip_empty_arrays: bool = False, compress: bool = False) -> str
| Public function: export self into json result string
|
| ----------------------------------------------------------------------
| Data descriptors inherited from n0struct.n0struct_n0list_.n0list_:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.list:
|
| __add__(self, value, /)
| Return self+value.
|
| __delitem__(self, key, /)
| Delete self[key].
|