Commit 9859b6cd authored by Etienne Nadji's avatar Etienne Nadji

Clean up module

	nouveau fichier : vepub_cleanup.py
	modifié :         vim_epub.vim
parent 21e10196
#!/usr/bin/python2
# -*- coding:Utf-8 -*-
# Vim-EPUB css python module
# Part of vim-epub plugin for Vim
# Released under GNU GPL version 3
# By Etienne Nadji <etnadji@eml.cc>
from __future__ import unicode_literals
import os
from vim_epub import vimvar
def is_cleanup(vim,field):
if field == "panels":
if vimvar(vim,"VimEPUB_CleanPanels") == "True":
return True
else:
return False
elif field == "all":
if vimvar(vim,"VimEPUB_CleanPanels") == "True":
return True
else:
return False
def active_cleanup(vim,field):
if field == "panels":
vim.command('let g:VimEPUB_CleanPanels = "True"')
def desactive_cleanup(vim,field):
if field == "panels":
vim.command('let g:VimEPUB_CleanPanels = "False"')
def clean_panels(vim):
"""Clean informations panels files."""
curdir = os.path.realpath(os.curdir)
metadatas = "{0}{1}metadatas.txt".format(curdir,os.sep)
fontdefs = "{0}{1}FontDefinitions.txt".format(curdir,os.sep)
for panel in [metadatas,fontdefs]:
if os.path.exists(panel):
os.remove(panel)
desactive_cleanup(vim,"panels")
def cleanup(vim,clean_all=False):
"""Clean up VimEPUB temporary files not produced with vim_epub.EPUB"""
if clean_all:
c_all = is_cleanup(vim,"all")
else:
panels = is_cleanup(vim,"panels")
if panels or c_all: clean_panels(vim)
# vim:set shiftwidth=4 softtabstop=4:
......@@ -21,6 +21,8 @@ au BufReadCmd *.epub let g:VimEPUB_EReaderCommand = "none"
au BufReadCmd *.epub let g:VimEPUB_OpenMedia_Font = "none"
au BufReadCmd *.epub let g:VimEPUB_OpenMedia_Image = "none"
au BufReadCmd *.epub let g:VimEPUB_CleanPanels = "False"
let g:VimEPUB_EPUB_Version = "2;3"
let g:VimEPUB_Skels_Dir = "None"
......@@ -308,29 +310,11 @@ from __future__ import unicode_literals
from vim import *
from vim_epub import *
import vepub_css as cssparse
import vepub_css as css_utils
font_name = get_current_line(vim)
with Open_EPUB(vim.buffers) as epubs:
# SOIT CHEMIN = font_name
# * Essai 1 * Dans les fichiers CSS
# SI des fichiers CSS
# SOIT trouvé = False
#
# POUR chaque fichier CSS
# Trouver des "@font-face"
# Lire la définition "src: url('CHEMIN_POLICE');"
# SI CHEMIN_POLICE == CHEMIN
# trouvé = True
# SINON
# Rien
# SI trouvé
# Afficher les résultats
# SINON
# => * xhtml *
available_css_files = epubs.get_files_by_extension("css")
if available_css_files:
......@@ -344,7 +328,7 @@ with Open_EPUB(vim.buffers) as epubs:
cssf = []
for css in available_css_files:
css_file = "{0}{1}".format(epubs.temporary_epub["path"],css)
defs = cssparse.find_font_face_src(css_file)
defs = css_utils.find_font_face_src(css_file)
if defs:
for fdef in defs:
......@@ -354,10 +338,10 @@ with Open_EPUB(vim.buffers) as epubs:
if cssf:
epubs.remove_temp_dir()
summary = cssparse.make_fontdef_summary(
summary = css_utils.make_fontdef_summary(
font_name,
cssf,
"font_definitions"
"FontDefinitions.txt"
)
vim.command(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment