本文整理汇总了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()
示例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()
示例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
示例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)
示例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')
示例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()
示例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()