This repository was archived by the owner on Apr 4, 2024. It is now read-only.
File tree 2 files changed +17
-12
lines changed
python/selfie-lib/selfie_lib
2 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -51,12 +51,15 @@ def __str__(self):
51
51
return f"[{ self ._subject } { self ._facet_data } ]"
52
52
53
53
@staticmethod
54
- def of (binary ):
55
- return Snapshot (SnapshotValue .of (binary ), {})
56
-
57
- @staticmethod
58
- def of (string ):
59
- return Snapshot (SnapshotValue .of (string ), {})
54
+ def of (data ):
55
+ if isinstance (data , bytes ):
56
+ # Handling binary data
57
+ return Snapshot (SnapshotValue .of (data ), {})
58
+ elif isinstance (data , str ):
59
+ # Handling string data
60
+ return Snapshot (SnapshotValue .of (data ), {})
61
+ else :
62
+ raise TypeError ("Data must be either binary or string" )
60
63
61
64
@staticmethod
62
65
def of_entries (entries ):
Original file line number Diff line number Diff line change @@ -20,13 +20,15 @@ def value_string(self) -> str:
20
20
pass
21
21
22
22
@staticmethod
23
- def of (value : Union [bytes , str ]) -> "SnapshotValue" :
24
- if isinstance (value , bytes ):
25
- return SnapshotValueBinary (value )
26
- elif isinstance (value , str ):
27
- return SnapshotValueString (unix_newlines (value ))
23
+ def of (cls , data ):
24
+ if isinstance (data , bytes ):
25
+ return cls (SnapshotValue .of (data ), {})
26
+ elif isinstance (data , str ):
27
+ return cls (SnapshotValue .of (data ), {})
28
+ elif isinstance (data , SnapshotValue ):
29
+ return cls (data , {})
28
30
else :
29
- raise TypeError ("Value must be either bytes or str " )
31
+ raise TypeError ("Unsupported type for Snapshot creation " )
30
32
31
33
32
34
class SnapshotValueBinary (SnapshotValue ):
You can’t perform that action at this time.
0 commit comments