Coretex
coretex.coretex.sample.sample.Sample Class Reference
Inheritance diagram for coretex.coretex.sample.sample.Sample:
coretex.coretex.sample.local_sample.LocalSample coretex.coretex.sample.network_sample.NetworkSample coretex.coretex.sample.any_local_sample.AnyLocalSample coretex.coretex.sample.custom_sample.local_custom_sample.LocalCustomSample coretex.coretex.sample.image_sample.local_image_sample.LocalImageSample coretex.coretex.sample.custom_sample.custom_sample.CustomSample coretex.coretex.sample.image_sample.image_sample.ImageSample coretex.coretex.sample.custom_sample.custom_sample.CustomSample coretex.coretex.sample.image_sample.image_sample.ImageSample coretex.coretex.sample.image_segmentation_sample.local_image_segmentation_sample.LocalImageSegmentationSample coretex.coretex.sample.image_segmentation_sample.image_segmentation_sample.ImageSegmentationSample coretex.coretex.sample.image_segmentation_sample.image_segmentation_sample.ImageSegmentationSample

Public Member Functions

bool download (self, bool ignoreCache=False)
 
None unzip (self, bool ignoreCache=False)
 
Path joinPath (self, Union[Path, str] other)
 

Detailed Description

    Represents the generic class Sample
    Includes methods that can be used by any instance of Sample
    and abstract methods that must be implemented by any subclass

Definition at line 30 of file sample.py.

Member Function Documentation

◆ download()

bool coretex.coretex.sample.sample.Sample.download (   self,
bool   ignoreCache = False 
)
    Downloads the Sample if it is an instance or a subclass of NetworkSample
    Ignored for instances and subclasses of LocalSample

    Returns
    -------
    bool -> True if Sample has been downloaded successfully,
    False if something went wrong, in LocalSample case True is always returned

Reimplemented in coretex.coretex.sample.network_sample.NetworkSample, and coretex.coretex.sample.local_sample.LocalSample.

Definition at line 51 of file sample.py.

51  def download(self, ignoreCache: bool = False) -> bool:
52  """
53  Downloads the Sample if it is an instance or a subclass of NetworkSample
54  Ignored for instances and subclasses of LocalSample
55 
56  Returns
57  -------
58  bool -> True if Sample has been downloaded successfully,
59  False if something went wrong, in LocalSample case True is always returned
60  """
61  pass
62 

◆ joinPath()

Path coretex.coretex.sample.sample.Sample.joinPath (   self,
Union[Path, str]  other 
)
    Joins sample path and provided path

    Parameters
    ----------
    other : Union[Path, str]
path for join

    Returns
    -------
    Path -> path created from sample path and provided path

    Example
    -------
    >>> print(sampleObj.joinPath("dummy.zip"))
    Path("path/to/sample/dummy.zip")

Definition at line 100 of file sample.py.

100  def joinPath(self, other: Union[Path, str]) -> Path:
101  """
102  Joins sample path and provided path
103 
104  Parameters
105  ----------
106  other : Union[Path, str]
107  path for join
108 
109  Returns
110  -------
111  Path -> path created from sample path and provided path
112 
113  Example
114  -------
115  >>> print(sampleObj.joinPath("dummy.zip"))
116  Path("path/to/sample/dummy.zip")
117  """
118 
119  if isinstance(other, str):
120  other = Path(other)
121 
122  return Path(self.path) / other

◆ unzip()

None coretex.coretex.sample.sample.Sample.unzip (   self,
bool   ignoreCache = False 
)
    Unzip sample zip file

    Parameters
    ----------
    ignoreCache : bool
if set to false performs unzip action even if
sample is previously unzipped

Definition at line 70 of file sample.py.

70  def unzip(self, ignoreCache: bool = False) -> None:
71  """
72  Unzip sample zip file
73 
74  Parameters
75  ----------
76  ignoreCache : bool
77  if set to false performs unzip action even if
78  sample is previously unzipped
79  """
80 
81  if os.path.exists(self.path) and not ignoreCache:
82  return
83 
84  try:
85  self.__unzipSample()
86  except BadZipFile:
87  # Delete invalid zip file
88  os.unlink(self.zipPath)
89 
90  # Re-download
91  self.download()
92 
93  # Try to unzip - if it fails again it should crash
94  self.__unzipSample()
95 

The documentation for this class was generated from the following file: