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

Python util.create_dir函数代码示例

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

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



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

示例1: init_album

    def init_album(self):
        #album json
        js = self.handler.read_link(url_album % self.album_id).json()['album']
        #name
        self.album_name = util.decode_html(js['name'])
        #album logo
        self.logo = js['picUrl']
        # artist_name
        self.artist_name = js['artists'][0]['name']
        #handle songs
        for jsong in js['songs']:
            song = NeteaseSong(self.handler, song_json=jsong)
            song.group_dir = self.artist_name + u'_' + self.album_name
            song.group_dir = song.group_dir.replace('/', '_')
            song.post_set()
            self.songs.append(song)

        d = path.dirname(self.songs[-1].abs_path)
        #creating the dir
        LOG.debug(msg.head_163 + msg.fmt_create_album_dir % d)
        util.create_dir(d)

        #download album logo images
        LOG.debug(msg.head_163 + msg.fmt_dl_album_cover % self.album_name)
        downloader.download_url(self.logo, path.join(d,'cover.' +self.logo.split('.')[-1]))
开发者ID:sk1418,项目名称:zhuaxia,代码行数:25,代码来源:netease.py


示例2: init_playlist

 def init_playlist(self):
     j = self.handler.read_link(url_playlist % (self.playlist_id) ).json()['result']
     self.playlist_name = j['name']
     for jsong in j['tracks']:
         song = NeteaseSong(self.handler, song_json=jsong)
         #rewrite filename, make it different
         song.group_dir = self.playlist_name
         song.post_set()
         self.songs.append(song)
     if len(self.songs):
         #creating the dir
         util.create_dir(path.dirname(self.songs[-1].abs_path))
开发者ID:CreateChen,项目名称:zhuaxia,代码行数:12,代码来源:netease.py


示例3: init_collection

 def init_collection(self):
     j = self.xm.read_link(url_collection % (self.collection_id) ).json()['collect']
     self.collection_name = j['name']
     for jsong in j['songs']:
         song = Song(self.xm, song_json=jsong)
         #rewrite filename, make it different
         song.group_dir = self.collection_name
         song.abs_path = path.join(config.DOWNLOAD_DIR, song.group_dir, song.filename)
         self.songs.append(song)
     if len(self.songs):
         #creating the dir
         util.create_dir(path.dirname(self.songs[-1].abs_path))
开发者ID:ChantWei,项目名称:zhuaxia,代码行数:12,代码来源:xiami.py


示例4: init_album

    def init_album(self):
        resp_json = self.handler.read_link(url_album % self.album_id).json()
        j = resp_json['data']['trackList']

        if not j :
            LOG.error(resp_json['message'])
            return
        #description
        html = self.handler.read_link(self.url).text
        soup = BeautifulSoup(html,'html.parser')
        if  soup.find('meta', property="og:title"):
            self.album_desc = soup.find('span', property="v:summary").text
            # name
            self.album_name = soup.find('meta', property="og:title")['content']
            # album logo
            self.logo = soup.find('meta', property="og:image")['content']
            # artist_name
            self.artist_name = soup.find('meta', property="og:music:artist")['content']
        else:
            aSong = j[0]
            self.album_name = aSong['album_name']
            self.logo = aSong['album_pic']
            self.artist_name = aSong['artistVOs'][0]['artistName']
            self.album_desc = None

        #handle songs
        for jsong in j:
            song = XiamiSong(self.handler, song_json=jsong)
            song.song_name = jsong['name']  # name or songName
            song.group_dir = self.artist_name + u'_' + self.album_name
            song.group_dir = song.group_dir.replace('/','_')
            song.post_set()
            self.songs.append(song)

        d = path.dirname(self.songs[-1].abs_path)
        #creating the dir
        LOG.debug(msg.head_xm + msg.fmt_create_album_dir % d)
        util.create_dir(d)

        #download album logo images
        LOG.debug(msg.head_xm + msg.fmt_dl_album_cover % self.album_name)
        if self.logo:
            self.logo = self.handler.add_http_prefix(self.logo)
            downloader.download_url(self.logo, path.join(d,'cover.' +self.logo.split('.')[-1]))

        LOG.debug(msg.head_xm + msg.fmt_save_album_desc % self.album_name)
        if self.album_desc:
            self.album_desc = re.sub(r'<\s*[bB][rR]\s*/>','\n',self.album_desc)
            self.album_desc = re.sub(r'<.*?>','',self.album_desc)
            self.album_desc = util.decode_html(self.album_desc)
            import codecs
            with codecs.open(path.join(d,'album_description.txt'), 'w', 'utf-8') as f:
                f.write(self.album_desc)
开发者ID:sk1418,项目名称:zhuaxia,代码行数:53,代码来源:xiami.py


示例5: init_collection

 def init_collection(self):
     j = self.xm.read_link(url_collection % (self.collection_id) ).json()['data']['trackList']
     j_first_song = j[0]
     #read collection name
     self.collection_name = self.get_collection_name()
     for jsong in j:
         song = XiamiSong(self.xm, song_json=jsong)
         #rewrite filename, make it different
         song.group_dir = self.collection_name
         song.post_set()
         self.songs.append(song)
     if len(self.songs):
         #creating the dir
         util.create_dir(path.dirname(self.songs[-1].abs_path))
开发者ID:luis-wang,项目名称:zhuaxia,代码行数:14,代码来源:xiami.py


示例6: init_topsong

    def init_topsong(self):
        j = self.handler.read_link(url_artist_top_song % (self.artist_id)).json()
        self.artist_name = j['artist']['name']
        for jsong in j['hotSongs']:
            song = NeteaseSong(self.handler, song_json=jsong)
            song.group_dir = self.artist_name + '_TopSongs'
            song.post_set()
            self.songs.append(song)
            #check config for top X
            if len(self.songs) >= config.DOWNLOAD_TOP_SONG:
                break

        if len(self.songs):
            #creating the dir
            util.create_dir(path.dirname(self.songs[-1].abs_path))
开发者ID:CreateChen,项目名称:zhuaxia,代码行数:15,代码来源:netease.py


示例7: init_topsong

    def init_topsong(self):
        j = self.xm.read_link(url_artist_top_song % (self.artist_id)).json()
        for jsong in j['songs']:
            song = XiamiSong(self.xm, song_json=jsong)
            song.group_dir = self.artist_name + '_TopSongs'
            song.post_set()
            self.songs.append(song)
            #check config for top X
            if len(self.songs) >= config.DOWNLOAD_TOP_SONG:
                break

        if len(self.songs):
            #set the artist name
            self.artist_name = self.songs[-1].artist_name
            #creating the dir
            util.create_dir(path.dirname(self.songs[-1].abs_path))
开发者ID:Alexander-kim,项目名称:zhuaxia,代码行数:16,代码来源:xiami.py


示例8: load_single_config

def load_single_config(conf_parser, conf_key):
    config_warn_msg = "Cannot load config [%s], use default value: %s"
    try:
        v = conf_parser.get("settings", conf_key)
        if not v:
            raise Exception("ConfigError", "invalid")
        gkey = var_dict[conf_key][0]
        ty = var_dict[conf_key][1]

        if ty == "n":
            globals()[gkey] = int(v)
        else:
            if ty == "p":
                util.create_dir(v)
            globals()[gkey] = v
    except:
        log.warn(config_warn_msg % (conf_key, str(globals()[var_dict[conf_key][0]])))
开发者ID:Nerostake,项目名称:zhuaxia,代码行数:17,代码来源:config.py


示例9: test

def test():
	cd_to_pigz()
	util.create_dir("pigz_test_tmp")
	shutil.copyfile("pigz.c", os.path.join("pigz_test_tmp", "pigz.c"))

	os.chdir("pigz_test_tmp")
	sha1_orig = util.file_sha1("pigz.c")
	test_one_with_flag(sha1_orig, ".gz", "-f")
	test_one_with_flag2(sha1_orig, ".gz", "-fb", "32")
	test_one_with_flag2(sha1_orig, ".gz", "-fp", "1")
	test_one_with_flag(sha1_orig, ".zz", "-fz")
	test_one_with_flag(sha1_orig, ".zip", "-fK")
	test_one_with_flag2(sha1_orig, ".gz", "-11", "-f")
	# TODO: more tests for stdin/stdout
	# TODO: compare with gzip/compress (if available in path)
	cd_to_pigz()
	rm_dirs(["pigz_test_tmp"])
开发者ID:andschenk,项目名称:pigz,代码行数:17,代码来源:build.py


示例10: init_fav

 def init_fav(self):
     page = 1
     while True:
         j = self.xm.read_link(url_fav % (self.uid, str(page)) ).json()
         if j['songs'] :
             for jsong in j['songs']:
                 song = Song(self.xm, song_json=jsong)
                 #rewrite filename, make it different
                 song.group_dir = 'favorite_%s' % self.uid
                 song.abs_path = path.join(config.DOWNLOAD_DIR, song.group_dir, song.filename)
                 self.songs.append(song)
             page += 1
         else:
             break
     if len(self.songs):
         #creating the dir
         util.create_dir(path.dirname(self.songs[-1].abs_path))
开发者ID:ChantWei,项目名称:zhuaxia,代码行数:17,代码来源:xiami.py


示例11: draw_date_stats

def draw_date_stats(date_stats):
    langs_info = read_auxiliary_file('../aux_files/langs_all_info.csv')
    code_to_lang = get_code_lang_mapping(langs_info)
    code_to_lang['overall'] = 'Общее распределение по датам'

    graphs_dir = create_dir('date_graphs')
    # draw_each_lang_separately(date_stats, code_to_lang, graphs_dir)
    # draw_all_langs_same_plot(date_stats, code_to_lang, graphs_dir)
    draw_overall_dates_with_registrars(date_stats, graphs_dir)
开发者ID:irinfox,项目名称:minor_langs_internet_analysis,代码行数:9,代码来源:domain_registration_stats.py


示例12: load_single_config

def load_single_config(conf_parser, conf_key):
    config_warn_msg = "Cannot load config [%s], use default value: %s"
    try:
        v = conf_parser.get('settings', conf_key)
        if not v:
            raise Exception('ConfigError','invalid')
        gkey = var_dict[conf_key][0]
        ty = var_dict[conf_key][1]

        if ty == 'n':
            globals()[gkey] = int(v)
        else:
            if ty =='p':
                util.create_dir(v)
            globals()[gkey] = v
    except:
        if not conf_key.find('proxy.http'):
            log.warn(config_warn_msg % (conf_key, str(globals()[var_dict[conf_key][0]])))
开发者ID:aniikiki,项目名称:zhuaxia,代码行数:18,代码来源:config.py


示例13: init_fav

    def init_fav(self):
        """ parse html and load json and init Song object
        for each found song url"""
        page = 1
        user = ''
        total = 0
        cur = 1 #current processing link
        LOG.debug(msg.head_xm + msg.fmt_init_fav % self.uid)
        while True:
            html = self.handler.read_link(url_fav%(self.uid,page)).text
            soup = BeautifulSoup(html,'html.parser')
            if not user:
                user = soup.title.string
            if not total:
                total = soup.find('span', class_='counts').string

            links = [link.get('href') for link in soup.find_all(href=re.compile(r'xiami.com/song/[^?]+')) if link]
            if links:
                for link in links:
                    LOG.debug(msg.head_xm + msg.fmt_parse_song_url % link)
                    if self.verbose:
                        sys.stdout.write(log.hl('[%d/%s] parsing song ........ '%(cur, total), 'green'))
                        sys.stdout.flush()
                    try:
                        cur += 1
                        song = XiamiSong(self.handler, url=link)
                        #time.sleep(2)
                        if self.verbose:
                            sys.stdout.write(log.hl('DONE\n', 'green'))
                    except:
                        sys.stdout.write(log.hl('FAILED\n', 'error'))
                        continue
                    #rewrite filename, make it different
                    song.group_dir = user
                    song.post_set()
                    self.songs.append(song)
                page += 1
            else:
                break

        if len(self.songs):
            #creating the dir
            util.create_dir(path.dirname(self.songs[-1].abs_path))
        LOG.debug(msg.head_xm + msg.fmt_init_fav_ok % self.uid)
开发者ID:sk1418,项目名称:zhuaxia,代码行数:44,代码来源:xiami.py


示例14: init_collection

 def init_collection(self):
     LOG.debug(msg.head_xm + msg.fmt_init_collect % self.collection_id)
     j = self.handler.read_link(url_collection % (self.collection_id) ).json()['data']['trackList']
     if not j:
         LOG.warning(msg.head_xm + " cannot load data for url: %s "% self.url)
         return
     j_first_song = j[0]
     #read collection name
     self.collection_name = self.get_collection_name()
     for jsong in j:
         song = XiamiSong(self.handler, song_json=jsong)
         #rewrite filename, make it different
         song.group_dir = self.collection_name
         song.post_set()
         self.songs.append(song)
     if len(self.songs):
         #creating the dir
         util.create_dir(path.dirname(self.songs[-1].abs_path))
     LOG.debug(msg.head_xm + msg.fmt_init_collect_ok % self.collection_id)
开发者ID:sk1418,项目名称:zhuaxia,代码行数:19,代码来源:xiami.py


示例15: init_topsong

    def init_topsong(self):
        LOG.debug(msg.head_xm + msg.fmt_init_artist% self.artist_id)
        j = self.handler.read_link(url_artist_top_song % (self.artist_id)).json()['data']['trackList']
        for jsong in j:
            song = XiamiSong(self.handler, song_json=jsong)
            if not self.artist_name:
                self.artist_name = song.artist_name
            song.group_dir = self.artist_name + '_TopSongs'
            song.post_set()
            self.songs.append(song)
            #check config for top X
            if config.DOWNLOAD_TOP_SONG>0 and len(self.songs) >= config.DOWNLOAD_TOP_SONG:
                break

        if len(self.songs):
            #set the artist name
            self.artist_name = self.songs[-1].artist_name
            #creating the dir
            util.create_dir(path.dirname(self.songs[-1].abs_path))
        LOG.debug(msg.head_xm + msg.fmt_init_artist_ok % self.artist_id)
开发者ID:sk1418,项目名称:zhuaxia,代码行数:20,代码来源:xiami.py


示例16: load_single_config

def load_single_config(conf_parser, conf_key):
    config_warn_msg = "Cannot load config [%s], use default value: %s"
    try:
        v = conf_parser.get('settings', conf_key)
        if not v:
            raise Exception('ConfigError','invalid')
        gkey = var_dict[conf_key][0]
        ty = var_dict[conf_key][1]

        if ty == 'n':
            #here check topx should less than 30
            if conf_key == 'download.artist.topsong' and int(v) >30:
                return 
            globals()[gkey] = int(v)
        else:
            if ty =='p':
                util.create_dir(v)
            globals()[gkey] = v
    except:
        log.warn(config_warn_msg % (conf_key, str(globals()[var_dict[conf_key][0]])))
开发者ID:Alexander-kim,项目名称:zhuaxia,代码行数:20,代码来源:config.py


示例17: init_album

    def init_album(self):
        j = self.handler.read_link(url_album % self.album_id).json()['data']['trackList']
        j_first_song = j[0]
        #name
        self.album_name = util.decode_html(j_first_song['album_name'])
        #album logo
        self.logo = j_first_song['album_pic']
        # artist_name
        self.artist_name = j_first_song['artist']

        #description
        html = self.handler.read_link(self.url).text
        soup = BeautifulSoup(html,'html.parser')
        self.album_desc = soup.find('span', property="v:summary").text

        #handle songs
        for jsong in j:
            song = XiamiSong(self.handler, song_json=jsong)
            song.group_dir = self.artist_name + u'_' + self.album_name
            song.post_set()
            self.songs.append(song)

        d = path.dirname(self.songs[-1].abs_path)
        #creating the dir
        LOG.debug(msg.head_xm + msg.fmt_create_album_dir % d)
        util.create_dir(d)

        #download album logo images
        LOG.debug(msg.head_xm + msg.fmt_dl_album_cover % self.album_name)
        downloader.download_url(self.logo, path.join(d,'cover.' +self.logo.split('.')[-1]))

        LOG.debug(msg.head_xm + msg.fmt_save_album_desc % self.album_name)
        if self.album_desc:
            self.album_desc = re.sub(r'<\s*[bB][rR]\s*/>','\n',self.album_desc)
            self.album_desc = re.sub(r'<.*?>','',self.album_desc)
            self.album_desc = util.decode_html(self.album_desc)
            import codecs
            with codecs.open(path.join(d,'album_description.txt'), 'w', 'utf-8') as f:
                f.write(self.album_desc)
开发者ID:aniikiki,项目名称:zhuaxia,代码行数:39,代码来源:xiami.py


示例18: init_album

    def init_album(self):
        j = self.xm.read_link(url_album % self.album_id).json()['album']
        # name
        self.album_name = util.decode_html(j['title'])
        # album logo
        self.logo = j['album_logo']
        # artist_name
        self.artist_name = j['artist_name']

        # description
        self.album_desc = j['description']

        # handle songs
        for jsong in j['songs']:
            song = XiamiSong(self.xm, song_json=jsong)
            song.group_dir = self.artist_name + u'_' + self.album_name
            song.post_set()
            self.songs.append(song)

        d = path.dirname(self.songs[-1].abs_path)
        # creating the dir
        LOG.debug(u'创建专辑目录[%s]' % d)
        util.create_dir(d)

        # download album logo images
        LOG.debug(u'下载专辑[%s]封面' % self.album_name)
        downloader.download_by_url(
            self.logo, path.join(d, 'cover.' + self.logo.split('.')[-1]))

        LOG.debug(u'保存专辑[%s]介绍' % self.album_name)
        if self.album_desc:
            self.album_desc = re.sub(
                r'<\s*[bB][rR]\s*/>', '\n', self.album_desc)
            self.album_desc = re.sub(r'<.*?>', '', self.album_desc)
            self.album_desc = util.decode_html(self.album_desc)
            import codecs
            with codecs.open(path.join(d, 'album_description.txt'), 'w', 'utf-8') as f:
                f.write(self.album_desc)
开发者ID:eilinx,项目名称:zhuaxia,代码行数:38,代码来源:xiami.py


示例19: init_album

    def init_album(self):
        #album json
        js = self.m163.read_link(url_album % self.album_id).json()['album']
        #name
        self.album_name = util.decode_html(js['name'])
        #album logo
        self.logo = js['picUrl']
        # artist_name
        self.artist_name = js['artists'][0]['name']
        #handle songs
        for jsong in js['songs']:
            song = NeteaseSong(self.m163, song_json=jsong)
            song.group_dir = self.artist_name + u'_' + self.album_name
            song.post_set()
            self.songs.append(song)

        d = path.dirname(self.songs[-1].abs_path)
        #creating the dir
        LOG.debug(u'创建专辑目录[%s]' % d)
        util.create_dir(d)

        #download album logo images
        LOG.debug(u'下载专辑[%s]封面'% self.album_name)
        downloader.download_by_url(self.logo, path.join(d,'cover.' +self.logo.split('.')[-1]))
开发者ID:Alexander-kim,项目名称:zhuaxia,代码行数:24,代码来源:netease.py


示例20: init_album

    def init_album(self):
        # album json
        js = self.handler.read_link(url_album % self.album_id).json()["album"]
        # name
        self.album_name = util.decode_html(js["name"])
        # album logo
        self.logo = js["picUrl"]
        # artist_name
        self.artist_name = js["artists"][0]["name"]
        # handle songs
        for jsong in js["songs"]:
            song = NeteaseSong(self.handler, song_json=jsong)
            song.group_dir = self.artist_name + u"_" + self.album_name
            song.post_set()
            self.songs.append(song)

        d = path.dirname(self.songs[-1].abs_path)
        # creating the dir
        LOG.debug(msg.head_163 + msg.fmt_create_album_dir % d)
        util.create_dir(d)

        # download album logo images
        LOG.debug(msg.head_163 + msg.fmt_dl_album_cover % self.album_name)
        downloader.download_by_url(self.logo, path.join(d, "cover." + self.logo.split(".")[-1]))
开发者ID:rokite,项目名称:zhuaxia,代码行数:24,代码来源:netease.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.create_grid函数代码示例发布时间:2022-05-27
下一篇:
Python util.copyfile函数代码示例发布时间: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