appy.bin: updated publish.py, that is now able to generate a DistUtils tar.gz for Appy; publish.py can now be called with option '-s' (silent): in this mode no question is asked to the user, default values are used; updated new.py that generates a better Plone4-ready simple Zope instance; appy: moved FileWrapper from appy.gen.utils to appy.shared.utils to avoid circular package dependencies; appy.gen: use of .pyt extensions for template Python classes in appy.gen.templates in order to avoid byte-compilation errors when distutils installs the package; appy.pod: when using function 'document' in 'from' statements, first arg can now be a appy.shared.utils.FileWrapper instance.
This commit is contained in:
parent
e78cf62694
commit
6ece750d9a
15 changed files with 237 additions and 210 deletions
|
@ -20,6 +20,7 @@
|
|||
import os, os.path, time, shutil, struct, random
|
||||
from appy.pod import PodError
|
||||
from appy.pod.odf_parser import OdfEnvironment
|
||||
from appy.shared.utils import FileWrapper
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
FILE_NOT_FOUND = "'%s' does not exist or is not a file."
|
||||
|
@ -59,9 +60,12 @@ class DocImporter:
|
|||
self.importPath = self.moveFile(at, self.importPath)
|
||||
else:
|
||||
# We need to dump the file content (in self.content) in a temp file
|
||||
# first. self.content may be binary or a file handler.
|
||||
# first. self.content may be binary, a file handler or a
|
||||
# FileWrapper.
|
||||
if isinstance(self.content, file):
|
||||
fileContent = self.content.read()
|
||||
elif isinstance(self.content, FileWrapper):
|
||||
fileContent = content.content
|
||||
else:
|
||||
fileContent = self.content
|
||||
f = file(self.importPath, 'wb')
|
||||
|
|
|
@ -26,6 +26,7 @@ from appy.pod import PodError
|
|||
from appy.shared import mimeTypesExts
|
||||
from appy.shared.xml_parser import XmlElement
|
||||
from appy.shared.utils import FolderDeleter, executeCommand
|
||||
from appy.shared.utils import FileWrapper
|
||||
from appy.pod.pod_parser import PodParser, PodEnvironment, OdInsert
|
||||
from appy.pod.converter import FILE_TYPES
|
||||
from appy.pod.buffers import FileBuffer
|
||||
|
@ -281,6 +282,8 @@ class Renderer:
|
|||
if not content and not at:
|
||||
raise PodError(DOC_NOT_SPECIFIED)
|
||||
# Guess document format
|
||||
if isinstance(content, FileWrapper):
|
||||
format = content.mimeType
|
||||
if not format:
|
||||
# It should be deduced from p_at
|
||||
if not at:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue