当前位置: 首页>>代码示例>>Python>>正文


Python Path.remove方法代码示例

本文整理汇总了Python中unipath.Path.remove方法的典型用法代码示例。如果您正苦于以下问题:Python Path.remove方法的具体用法?Python Path.remove怎么用?Python Path.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unipath.Path的用法示例。


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

示例1: download_qualities

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import remove [as 别名]
def download_qualities(force=False, i_have_enough_space=False, keep=False):
    url = 'https://ndownloader.figshare.com/files/6059502'
    bz2 = Path(DATA_DIR, 'article_qualities.tsv.bz2')
    tsv = Path(DATA_DIR, 'article_qualities.tsv')

    # Try to prevent accidentally downloading too big a file.
    if not i_have_enough_space:
        try:
            gb_available = int(run("df -g . | awk '/\//{ print $4 }'").stdout)
            if gb_available < 100:
                raise NotEnoughGBAvailable
        except:
            raise NotEnoughGBAvailable
        else:
            logger.info('Rest easy, you have enough space.')
    else:
        logger.info('Skipping space check. Good luck soldier!')

    if SQLITE_PATH.exists() and not force:
        raise DBAlreadyExists

    logger.info('Downloading and decompressing.')
    run('wget {url} > {bz2} && bunzip2 {bz2}'.format(url=url, bz2=bz2))

    logger.info('Importing into sqlite.')
    conn = connect_to_sqlite_db()
    for chunk in pandas.read_table(tsv, chunksize=100000):
        chunk.to_sql('qualities', conn, if_exists='append', index=False)
    conn.close()

    if not keep:
        tsv.remove()
开发者ID:evoapps,项目名称:evotrees,代码行数:34,代码来源:import_qualities.py

示例2: delete_file

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import remove [as 别名]
 def delete_file(self, name):
     """Delete a specific file"""
     if self.ftp:
         self.ftp.delete(name)
     else:
         path = Path(self.path).child(name)
         path.remove()
开发者ID:YukSeungChan,项目名称:alchemydumps,代码行数:9,代码来源:backup.py

示例3: delete

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import remove [as 别名]
  def delete(self, lookup_repo_name):
    repo = Repository(lookup_repo_name, self.path, self.git)
    dest = Path(self.path, 'conf/repos/%s.conf' % lookup_repo_name)
    if not dest.exists():
      raise ValueError('Repository %s not existing.' % lookup_repo_name)
    dest.remove()
    self.git.commit([str(dest)], 'Deleted repo %s.' % lookup_repo_name)

    return repo
开发者ID:bcersows,项目名称:pyolite,代码行数:11,代码来源:repository.py

示例4: remove

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import remove [as 别名]
    def remove(self, key):
        directory = Path(self.user.path, 'keydir', self.user.name,
                                         hashlib.md5(key.strip().split()[1]).hexdigest())
        key_file = Path(directory, "%s.pub" % self.user.name)

        if not key_file.exists():
            raise ValueError("Invalid key")

        key_file.remove()
        key_file.parent.rmdir()

        self.user.git.commit(['keydir'],
                                                 'Removed key for user %s' % self.user.name)
开发者ID:Codevolve,项目名称:pyolite,代码行数:15,代码来源:keys.py

示例5: move_to_venv

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import remove [as 别名]
    def move_to_venv(self, which_one):
        """
        Moves the created config_files into the bin folder to be executed.
        Does this by first pasting all the contents of the temporary file
        into the new or existing target file and then deleting the temp file.
        """
        target = Path(self.venv_folder, self.project_name, 'bin', which_one)
        source = Path(self.install_path, which_one)
        logger.info('target: %s, move_orig: %s' % (target, source))

        if source.exists():
            logger.info('Moving %s into place ...' % which_one)
            content = source.read_file()

            #make sure the directory exists
            if not target.parent.exists():
                target.parent.mkdir(parents=True)
            target.write_file(content, 'w+')

            source.remove()

        logger.info('...done')
开发者ID:Libermentix,项目名称:project_installer,代码行数:24,代码来源:installer.py

示例6: test_remove_broken_symlink

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import remove [as 别名]
 def test_remove_broken_symlink(self):
     symlink = Path(self.d, "symlink")
     symlink.write_link("broken")
     assert symlink.lexists()
     symlink.remove()
     assert not symlink.lexists()
开发者ID:Mondego,项目名称:pyreco,代码行数:8,代码来源:allPythonContent.py

示例7: delete_avatar

# 需要导入模块: from unipath import Path [as 别名]
# 或者: from unipath.Path import remove [as 别名]
def delete_avatar(player_model):
    avatar = Path(settings.MEDIA_ROOT, str(player_model.avatar))
    avatar_sm = Path(settings.MEDIA_ROOT, str(player_model.avatar_sm))
    avatar.remove()
    avatar_sm.remove()
开发者ID:Cryptite,项目名称:loka,代码行数:7,代码来源:tasks.py


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