mirror of https://github.com/tLDP/python-tldp
support --script mode anywhere and don't chdir()
This commit is contained in:
parent
4499cd6181
commit
f2ef7d2184
|
@ -424,7 +424,19 @@ class TestDriverScript(TestInventoryBase):
|
||||||
tldp.driver.script(c, inv.all.values(), file=stdout)
|
tldp.driver.script(c, inv.all.values(), file=stdout)
|
||||||
stdout.seek(0)
|
stdout.seek(0)
|
||||||
data = stdout.read()
|
data = stdout.read()
|
||||||
self.assertTrue(c.linuxdoc_sgml2html in data)
|
self.assertTrue('Published-HOWTO' in data)
|
||||||
|
|
||||||
|
def test_script_no_pubdir(self):
|
||||||
|
c = self.config
|
||||||
|
c.script = True
|
||||||
|
stdout = io.StringIO()
|
||||||
|
self.add_published('New-HOWTO', example.ex_linuxdoc)
|
||||||
|
c.pubdir = None
|
||||||
|
inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
|
||||||
|
tldp.driver.script(c, inv.all.values(), file=stdout)
|
||||||
|
stdout.seek(0)
|
||||||
|
data = stdout.read()
|
||||||
|
self.assertTrue('New-HOWTO' in data)
|
||||||
|
|
||||||
def test_run_script(self):
|
def test_run_script(self):
|
||||||
self.add_published('Published-HOWTO', example.ex_linuxdoc)
|
self.add_published('Published-HOWTO', example.ex_linuxdoc)
|
||||||
|
|
|
@ -87,6 +87,8 @@ class BaseDoctype(object):
|
||||||
|
|
||||||
def build_precheck(self):
|
def build_precheck(self):
|
||||||
classname = self.__class__.__name__
|
classname = self.__class__.__name__
|
||||||
|
if self.config.script:
|
||||||
|
return True
|
||||||
for tool, validator in self.required.items():
|
for tool, validator in self.required.items():
|
||||||
thing = getattr(self.config, tool, None)
|
thing = getattr(self.config, tool, None)
|
||||||
logger.debug("%s, tool = %s, thing = %s", classname, tool, thing)
|
logger.debug("%s, tool = %s, thing = %s", classname, tool, thing)
|
||||||
|
@ -282,6 +284,7 @@ class BaseDoctype(object):
|
||||||
# - chdir to output dir
|
# - chdir to output dir
|
||||||
# - copy source images/resources to output dir
|
# - copy source images/resources to output dir
|
||||||
#
|
#
|
||||||
|
if not self.config.script:
|
||||||
opwd = os.getcwd()
|
opwd = os.getcwd()
|
||||||
if not self.build_prepare():
|
if not self.build_prepare():
|
||||||
return False
|
return False
|
||||||
|
@ -301,6 +304,7 @@ class BaseDoctype(object):
|
||||||
else:
|
else:
|
||||||
self.hook_build_failure()
|
self.hook_build_failure()
|
||||||
|
|
||||||
|
if not self.config.script:
|
||||||
os.chdir(opwd)
|
os.chdir(opwd)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
|
@ -245,7 +245,11 @@ def post_publish_cleanup(docs):
|
||||||
def prepare_docs_script_mode(config, docs):
|
def prepare_docs_script_mode(config, docs):
|
||||||
for source in docs:
|
for source in docs:
|
||||||
if not source.output:
|
if not source.output:
|
||||||
source.working = OutputDirectory.fromsource(config.pubdir, source)
|
fromsource = OutputDirectory.fromsource
|
||||||
|
if not config.pubdir:
|
||||||
|
source.working = fromsource(source.dirname, source)
|
||||||
|
else:
|
||||||
|
source.working = fromsource(config.pubdir, source)
|
||||||
else:
|
else:
|
||||||
source.working = source.output
|
source.working = source.output
|
||||||
return True, None
|
return True, None
|
||||||
|
|
Loading…
Reference in New Issue