Coretex
coretex.entities.sample.sample.Sample Class Reference
Inheritance diagram for coretex.entities.sample.sample.Sample:
coretex.entities.sample.local_sample.LocalSample coretex.entities.sample.network_sample.NetworkSample coretex.entities.sample.any_local_sample.AnyLocalSample coretex.entities.sample.custom_sample.local_custom_sample.LocalCustomSample coretex.entities.sample.image_sample.local_image_sample.LocalImageSample coretex.entities.sample.sequence_sample.local_sequence_sample.LocalSequenceSample coretex.entities.sample.custom_sample.custom_sample.CustomSample coretex.entities.sample.image_sample.image_sample.ImageSample coretex.entities.sample.sequence_sample.sequence_sample.SequenceSample coretex.entities.sample.custom_sample.custom_sample.CustomSample coretex.entities.sample.image_sample.image_sample.ImageSample coretex.entities.sample.sequence_sample.sequence_sample.SequenceSample

Public Member Functions

None download (self, bool decrypt=True, 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 29 of file sample.py.

Member Function Documentation

◆ download()

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

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

Definition at line 50 of file sample.py.

50  def download(self, decrypt: bool = True, ignoreCache: bool = False) -> None:
51  """
52  Downloads the Sample if it is an instance or a subclass of NetworkSample
53  Ignored for instances and subclasses of LocalSample
54  """
55 
56  pass
57 

◆ joinPath()

Path coretex.entities.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 98 of file sample.py.

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

◆ unzip()

None coretex.entities.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

Reimplemented in coretex.entities.sample.sequence_sample.local_sequence_sample.LocalSequenceSample, and coretex.entities.sample.network_sample.NetworkSample.

Definition at line 65 of file sample.py.

65  def unzip(self, ignoreCache: bool = False) -> None:
66  """
67  Unzip sample zip file
68 
69  Parameters
70  ----------
71  ignoreCache : bool
72  if set to false performs unzip action even if
73  sample is previously unzipped
74  """
75 
76  if not self.zipPath.exists():
77  raise FileNotFoundError(f"Sample \"{self.name}\" archive does not exist at path \"{self.zipPath}\"")
78 
79  if self.path.exists() and not ignoreCache:
80  return
81 
82  try:
83  self.__unzipSample()
84  except BadZipFile:
85  # Delete invalid zip file
86  self.zipPath.unlink()
87 
88  # Re-download
89  self.download()
90 
91  # Try to unzip - if it fails again it should crash
92  self.__unzipSample()
93 

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