• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python file.File类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中picard.file.File的典型用法代码示例。如果您正苦于以下问题:Python File类的具体用法?Python File怎么用?Python File使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了File类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _save_and_rename

 def _save_and_rename(self, old_filename, metadata, settings):
     """Includes an additional check for WavPack correction files"""
     wvc_filename = old_filename.replace(".wv", ".wvc")
     if isfile(wvc_filename):
         if settings["rename_files"] or settings["move_files"]:
             self._rename(wvc_filename, metadata, settings)
     File._save_and_rename(self, old_filename, metadata, settings)
开发者ID:lalinsky,项目名称:picard,代码行数:7,代码来源:apev2.py


示例2: example_2

 def example_2(self):
     file = File("track05.mp3")
     file.state = File.NORMAL
     # The data for this example does not match the release on MusicBrainz,
     # but still works well enough as an example.
     file.metadata['album'] = 'Explosive Doowops, Volume 4'
     file.metadata['title'] = 'Why? Oh Why?'
     file.metadata['artist'] = 'The Fantasys'
     file.metadata['artistsort'] = 'Fantasys, The'
     file.metadata['albumartist'] = config.setting['va_name']
     file.metadata['albumartistsort'] = config.setting['va_name']
     file.metadata['tracknumber'] = '5'
     file.metadata['totaltracks'] = '26'
     file.metadata['discnumber'] = '2'
     file.metadata['totaldiscs'] = '2'
     file.metadata['date'] = '1999-02-03'
     file.metadata['releasetype'] = ['album', 'compilation']
     file.metadata['~primaryreleasetype'] = ['album']
     file.metadata['~secondaryreleasetype'] = ['compilation']
     file.metadata['releasestatus'] = 'official'
     file.metadata['releasecountry'] = 'US'
     file.metadata['compilation'] = '1'
     file.metadata['~extension'] = 'mp3'
     file.metadata['musicbrainz_albumid'] = 'bcc97e8a-2055-400b-a6ed-83288285c6fc'
     file.metadata['musicbrainz_albumartistid'] = '89ad4ac3-39f7-470e-963a-56509c546377'
     file.metadata['musicbrainz_artistid'] = '06704773-aafe-4aca-8833-b449e0a6467f'
     file.metadata['musicbrainz_recordingid'] = 'd92837ee-b1e4-4649-935f-e433c3e5e429'
     file.metadata['musicbrainz_releasetrackid'] = 'eac99807-93d4-3668-9714-fa0c1b487ccf'
     return file
开发者ID:KLuken,项目名称:picard,代码行数:29,代码来源:renaming.py


示例3: example_1

 def example_1(self):
     file = File("ticket_to_ride.mp3")
     file.state = File.NORMAL
     file.metadata['album'] = 'Help!'
     file.metadata['title'] = 'Ticket to Ride'
     file.metadata['artist'] = 'The Beatles'
     file.metadata['artistsort'] = 'Beatles, The'
     file.metadata['albumartist'] = 'The Beatles'
     file.metadata['albumartistsort'] = 'Beatles, The'
     file.metadata['tracknumber'] = '7'
     file.metadata['totaltracks'] = '14'
     file.metadata['discnumber'] = '1'
     file.metadata['totaldiscs'] = '1'
     file.metadata['date'] = '1965-08-06'
     file.metadata['releasetype'] = ['album', 'soundtrack']
     file.metadata['~primaryreleasetype'] = ['album']
     file.metadata['~secondaryreleasetype'] = ['soundtrack']
     file.metadata['releasestatus'] = 'official'
     file.metadata['releasecountry'] = 'US'
     file.metadata['~extension'] = 'mp3'
     file.metadata['musicbrainz_albumid'] = '2c053984-4645-4699-9474-d2c35c227028'
     file.metadata['musicbrainz_albumartistid'] = 'b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d'
     file.metadata['musicbrainz_artistid'] = 'b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d'
     file.metadata['musicbrainz_recordingid'] = 'ed052ae1-c950-47f2-8d2b-46e1b58ab76c'
     file.metadata['musicbrainz_releasetrackid'] = '7668a62a-2fac-3151-a744-5707ac8c883c'
     return file
开发者ID:KLuken,项目名称:picard,代码行数:26,代码来源:renaming.py


示例4: example_2

 def example_2(self):
     file = File("track05.mp3")
     file.state = File.NORMAL
     file.metadata['album'] = "Coup d'État, Volume 1: Ku De Ta / Prologue"
     file.metadata['title'] = "I've Got to Learn the Mambo"
     file.metadata['artist'] = "Snowboy feat. James Hunter"
     file.metadata['artistsort'] = "Snowboy feat. Hunter, James"
     file.metadata['albumartist'] = config.setting['va_name']
     file.metadata['albumartistsort'] = config.setting['va_name']
     file.metadata['tracknumber'] = '5'
     file.metadata['totaltracks'] = '13'
     file.metadata['discnumber'] = '2'
     file.metadata['totaldiscs'] = '2'
     file.metadata['discsubtitle'] = "Beat Up"
     file.metadata['date'] = '2005-07-04'
     file.metadata['releasetype'] = ['album', 'compilation']
     file.metadata['~primaryreleasetype'] = 'album'
     file.metadata['~secondaryreleasetype'] = 'compilation'
     file.metadata['releasestatus'] = 'official'
     file.metadata['releasecountry'] = 'AU'
     file.metadata['compilation'] = '1'
     file.metadata['~multiartist'] = '1'
     file.metadata['~extension'] = 'mp3'
     file.metadata['musicbrainz_albumid'] = '4b50c71e-0a07-46ac-82e4-cb85dc0c9bdd'
     file.metadata['musicbrainz_recordingid'] = 'b3c487cb-0e55-477d-8df3-01ec6590f099'
     file.metadata['musicbrainz_releasetrackid'] = 'f8649a05-da39-39ba-957c-7abf8f9012be'
     file.metadata['musicbrainz_albumartistid'] = '89ad4ac3-39f7-470e-963a-56509c546377'
     file.metadata['musicbrainz_artistid'] = ['7b593455-d207-482c-8c6f-19ce22c94679',
                                              '9e082466-2390-40d1-891e-4803531f43fd']
     return file
开发者ID:mineo,项目名称:picard,代码行数:30,代码来源:renaming.py


示例5: example_2

 def example_2(self):
     file = File("track05.mp3")
     file.state = File.NORMAL
     file.metadata['album'] = 'Explosive Doowops, Volume 4'
     file.metadata['title'] = 'Why? Oh Why?'
     file.metadata['artist'] = 'The Fantasys'
     file.metadata['artistsort'] = 'Fantasys, The'
     file.metadata['albumartist'] = self.config.setting['va_name']
     file.metadata['albumartistsort'] = self.config.setting['va_name']
     file.metadata['tracknumber'] = '5'
     file.metadata['totaltracks'] = '26'
     file.metadata['discnumber'] = '2'
     file.metadata['totaldiscs'] = '2'
     file.metadata['date'] = '1999-02-03'
     file.metadata['releasetype'] = 'compilation'
     file.metadata['releasestatus'] = 'official'
     file.metadata['releasecountry'] = 'US'
     file.metadata['compilation'] = '1'
     file.metadata['~extension'] = 'mp3'
     file.metadata['musicbrainz_albumid'] = 'bcc97e8a-2055-400b-a6ed-83288285c6fc'
     file.metadata['musicbrainz_albumartistid'] = '89ad4ac3-39f7-470e-963a-56509c546377'
     file.metadata['musicbrainz_artistid'] = '06704773-aafe-4aca-8833-b449e0a6467f'
     file.metadata['musicbrainz_trackid'] = 'd92837ee-b1e4-4649-935f-e433c3e5e429'
     return file
开发者ID:RubenKelevra,项目名称:piage,代码行数:24,代码来源:renaming.py


示例6: example_1

 def example_1(self):
     file = File("ticket_to_ride.mp3")
     file.state = File.NORMAL
     file.metadata['album'] = 'Help!'
     file.metadata['title'] = 'Ticket to Ride'
     file.metadata['artist'] = 'The Beatles'
     file.metadata['artistsort'] = 'Beatles, The'
     file.metadata['albumartist'] = 'The Beatles'
     file.metadata['albumartistsort'] = 'Beatles, The'
     file.metadata['tracknumber'] = '7'
     file.metadata['totaltracks'] = '14'
     file.metadata['discnumber'] = '1'
     file.metadata['totaldiscs'] = '1'
     file.metadata['date'] = '1965-08-06'
     file.metadata['releasetype'] = 'album'
     file.metadata['releasestatus'] = 'official'
     file.metadata['releasecountry'] = 'US'
     file.metadata['~extension'] = 'mp3'
     file.metadata['musicbrainz_albumid'] = '2c053984-4645-4699-9474-d2c35c227028'
     file.metadata['musicbrainz_albumartistid'] = 'b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d'
     file.metadata['musicbrainz_artistid'] = 'b10bbbfc-cf9e-42e0-be17-e2c3e1d2600d'
     file.metadata['musicbrainz_trackid'] = '898a2916-f64d-48d3-ab1a-3446fb450448'
     return file
开发者ID:RubenKelevra,项目名称:piage,代码行数:23,代码来源:renaming.py


示例7: setUp

 def setUp(self):
     super().setUp()
     self.tmp_directory = mkdtemp()
     filepath = os.path.join(self.tmp_directory, 'a.mp3')
     self.file = File(filepath)
开发者ID:Jormangeud,项目名称:picard,代码行数:5,代码来源:test_file.py


示例8: TestPreserveTimes

class TestPreserveTimes(PicardTestCase):

    def setUp(self):
        super().setUp()
        self.tmp_directory = mkdtemp()
        filepath = os.path.join(self.tmp_directory, 'a.mp3')
        self.file = File(filepath)

    def tearDown(self):
        shutil.rmtree(self.tmp_directory)

    def _create_testfile(self):
        # create a dummy file
        with open(self.file.filename, 'w') as f:
            f.write('xxx')
            f.flush()
            os.fsync(f.fileno())

    def _modify_testfile(self):
        # dummy file modification, append data to it
        with open(self.file.filename, 'a') as f:
            f.write('yyy')
            f.flush()
            os.fsync(f.fileno())

    def _read_testfile(self):
        with open(self.file.filename, 'r') as f:
            return f.read()

    def test_preserve_times(self):
        self._create_testfile()

        # test if times are preserved
        (before_atime_ns, before_mtime_ns) = self.file._preserve_times(self.file.filename, self._modify_testfile)

        # HERE an external access to the file is possible, modifying its access time

        # read times again and compare with original
        st = os.stat(self.file.filename)
        (after_atimes_ns, after_mtimes_ns) = (st.st_atime_ns, st.st_mtime_ns)

        # modification times should be equal
        self.assertEqual(before_mtime_ns, after_mtimes_ns)

        # access times may not be equal
        # time difference should be positive and reasonably low (if no access in between, it should be 0)
        delta = after_atimes_ns - before_atime_ns
        tolerance = 10**7  #  0.01 seconds
        self.assertTrue(0 <= delta < tolerance)

        # ensure written data can be read back
        # keep it at the end, we don't want to access file before time checks
        self.assertEqual(self._read_testfile(), 'xxxyyy')

    def test_preserve_times_nofile(self):

        with self.assertRaises(self.file.PreserveTimesStatError):
            self.file._preserve_times(self.file.filename,
                                      self._modify_testfile)
        with self.assertRaises(FileNotFoundError):
            self._read_testfile()

    def test_preserve_times_nofile_utime(self):
        self._create_testfile()

        def save():
            os.remove(self.file.filename)

        with self.assertRaises(self.file.PreserveTimesUtimeError):
            result = self.file._preserve_times(self.file.filename, save)
开发者ID:Jormangeud,项目名称:picard,代码行数:70,代码来源:test_file.py



注:本文中的picard.file.File类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python log.debug函数代码示例发布时间:2022-05-27
下一篇:
Python dataobj.DataObject类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap