2323
2424vollog = logging .getLogger (__file__ )
2525
26- class S3FileSystemHandler (resources .VolatilityHandler ):
27- if HAS_S3FS :
28- @classmethod
29- def non_cached_schemes (cls ) -> List [str ]:
30- return ["s3" ]
31-
32- @staticmethod
33- def default_open (req : urllib .request .Request ) -> Optional [Any ]:
34- """Handles the request if it's the s3 scheme."""
35- if req .type == "s3" :
36- object_uri = "://" .join (req .full_url .split ("://" )[1 :])
37- return s3fs .S3FileSystem ().open (object_uri )
38- return None
39- else :
40- raise exceptions .LayerException ("s3 requirement is missing." )
41-
42-
43- class GSFileSystemHandler (resources .VolatilityHandler ):
44- if HAS_GCSFS :
45- @classmethod
46- def non_cached_schemes (cls ) -> List [str ]:
47- return ["gs" ]
48-
49- @staticmethod
50- def default_open (req : urllib .request .Request ) -> Optional [Any ]:
51- """Handles the request if it's the gs scheme."""
52- if req .type == "gs" :
53- object_uri = "://" .join (req .full_url .split ("://" )[1 :])
54- return gcsfs .GCSFileSystem ().open (object_uri )
55- return None
56- else :
57- raise exceptions .LayerException ("gcsfs requirement is missing." )
26+ if HAS_S3FS :
27+
28+ class S3FileSystemHandler (resources .VolatilityHandler ):
29+
30+ @classmethod
31+ def non_cached_schemes (cls ) -> List [str ]:
32+ return ["s3" ]
33+
34+ @staticmethod
35+ def default_open (req : urllib .request .Request ) -> Optional [Any ]:
36+ """Handles the request if it's the s3 scheme."""
37+ if req .type == "s3" :
38+ object_uri = "://" .join (req .full_url .split ("://" )[1 :])
39+ return s3fs .S3FileSystem ().open (object_uri )
40+ return None
41+
42+ if HAS_GCSFS :
43+
44+ class GSFileSystemHandler (resources .VolatilityHandler ):
45+ @classmethod
46+ def non_cached_schemes (cls ) -> List [str ]:
47+ return ["gs" ]
48+
49+ @staticmethod
50+ def default_open (req : urllib .request .Request ) -> Optional [Any ]:
51+ """Handles the request if it's the gs scheme."""
52+ if req .type == "gs" :
53+ object_uri = "://" .join (req .full_url .split ("://" )[1 :])
54+ return gcsfs .GCSFileSystem ().open (object_uri )
55+ return None
0 commit comments