Exemplo n.º 1
0
 def build_plugin_from_params(self, vendor: str, name: str,
                              output: str) -> Optional[VampyPlugin]:
     library_file_name = get_file_name(
         self.vamp_host_interface.get_library_for("{}:{}".format(
             vendor, name)))
     if self._is_plugin_available(vendor, name):
         return VampyPlugin(vendor, name, output, library_file_name)
     return None
Exemplo n.º 2
0
def _read_mp3_file_meta(absolute_path: str,
                        audio_file_size: int) -> CompressedAudioFileMeta:
    mp3 = MP3(filename=absolute_path)
    return CompressedAudioFileMeta(file_name=get_file_name(absolute_path),
                                   file_size_bytes=audio_file_size,
                                   channels_count=mp3.info.channels,
                                   sample_rate=mp3.info.sample_rate,
                                   bit_rate_kbps=to_kilo(mp3.info.bitrate),
                                   length_sec=mp3.info.length)
Exemplo n.º 3
0
def _read_flac_file_meta(absolute_path,
                         audio_file_size) -> CompressedAudioFileMeta:
    flac = FLAC(filename=absolute_path)
    return CompressedAudioFileMeta(file_name=get_file_name(absolute_path),
                                   file_size_bytes=audio_file_size,
                                   channels_count=flac.info.channels,
                                   sample_rate=flac.info.sample_rate,
                                   bit_rate_kbps=to_kilo(flac.info.bitrate),
                                   length_sec=flac.info.length)
Exemplo n.º 4
0
 def meta(self, file_name: str) -> FileMeta:
     file_name = self._build_full_path(file_name)
     file_stats = os.stat(file_name)
     last_access_utc = utc_timestamp_to_datetime(file_stats.st_atime)
     last_modification_utc = utc_timestamp_to_datetime(file_stats.st_mtime)
     created_on_utc = utc_timestamp_to_datetime(file_stats.st_ctime)
     return FileMeta(file_name=get_file_name(file_name),
                     size=file_stats.st_size,
                     last_access=last_access_utc,
                     last_modification=last_modification_utc,
                     created_on=created_on_utc)
 def test_should_create_flac_audio_file_meta(self):
     flac_audio_file_meta = read_audio_file_meta(self.flac_audio_file_name)
     assert_that(flac_audio_file_meta).is_not_none()
     assert_that(flac_audio_file_meta.channels_count).is_equal_to(1)
     assert_that(flac_audio_file_meta.sample_rate).is_equal_to(
         self.audio_file_sample_rate)
     assert_that(flac_audio_file_meta.file_name).is_equal_to(
         get_file_name(TEST_FLAC_AUDIO_FILE))
     assert_that(flac_audio_file_meta.bit_rate_kbps).is_between(
         *self.flac_audio_file_bit_rate_kbps_between)
     assert_that(flac_audio_file_meta.length_sec).is_between(
         *self.audio_file_length_seconds_between)
Exemplo n.º 6
0
 def build_plugins_from_key(self, vampy_key: str) -> List[VampyPlugin]:
     vendor, name = self._split_vampy_key_into_vendor_and_name(vampy_key)
     plugin_outputs = self.vamp_interface.get_outputs_of(vampy_key)
     library_file_name = get_file_name(
         self.vamp_host_interface.get_library_for(vampy_key))
     all_plugins = [
         VampyPlugin(vendor, name, o, library_file_name)
         for o in plugin_outputs
     ]
     return [
         p for p in all_plugins
         if p.full_key not in self.black_list_plugin_key
     ]
Exemplo n.º 7
0
def read_file_meta(file_name: str) -> Optional[FileMeta]:
    if file_exists(file_name):
        file_stats = os.stat(file_name)
        last_access_utc = utc_timestamp_to_datetime(file_stats.st_atime)
        last_modification_utc = utc_timestamp_to_datetime(file_stats.st_mtime)
        created_on_utc = utc_timestamp_to_datetime(file_stats.st_ctime)
        return FileMeta(file_name=get_file_name(file_name),
                        size=file_stats.st_size,
                        last_access=last_access_utc,
                        last_modification=last_modification_utc,
                        created_on=created_on_utc)
    else:
        logger.warning("Requested file {} does not exist".format(file_name))
        return None
Exemplo n.º 8
0
 def test_getting_dir_name(self):
     assert_that(get_file_name('/home')).is_equal_to('home')
Exemplo n.º 9
0
 def test_getting_file_name(self):
     assert_that(get_file_name('/etc/passwd')).is_equal_to('passwd')
     assert_that(
         get_file_name('D:/folder/file.txt')).is_equal_to('file.txt')
     assert_that(
         get_file_name('D://folder//file.txt')).is_equal_to('file.txt')
Exemplo n.º 10
0
 def list(self) -> List[str]:
     """List file names (with extensions)"""
     return [get_file_name(f) for f in self.list_full_paths()]