2016-02-11 03:22:23 +00:00
|
|
|
#! /usr/bin/python
|
|
|
|
|
2016-02-11 19:29:00 +00:00
|
|
|
from __future__ import absolute_import, division, print_function
|
2016-02-11 17:15:22 +00:00
|
|
|
|
2016-02-11 03:22:23 +00:00
|
|
|
import os
|
|
|
|
|
2016-02-11 17:15:22 +00:00
|
|
|
from .utils import logger
|
|
|
|
|
|
|
|
|
|
|
|
class OutputDir(object):
|
|
|
|
|
2016-02-12 18:32:09 +00:00
|
|
|
def __repr__(self):
|
|
|
|
return '<%s:%s>' % (self.__class__.__name__, self.outputdir)
|
|
|
|
|
2016-02-11 17:28:31 +00:00
|
|
|
def __init__(self, outputdir):
|
|
|
|
self.outputdir = os.path.abspath(outputdir)
|
|
|
|
self.stem = os.path.basename(outputdir)
|
|
|
|
self.parent = os.path.dirname(self.outputdir)
|
2016-02-11 17:15:22 +00:00
|
|
|
|
|
|
|
def mkdir(self):
|
|
|
|
if not os.path.exists(self.parent):
|
|
|
|
raise OSError("Missing parent directory: " + self.parent)
|
2016-02-11 17:28:31 +00:00
|
|
|
os.mkdir(self.outputdir)
|
2016-02-11 17:15:22 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def txt_name(self):
|
2016-02-11 17:28:31 +00:00
|
|
|
return os.path.join(self.outputdir, self.stem, '.txt')
|
2016-02-11 17:15:22 +00:00
|
|
|
|
|
|
|
@property
|
|
|
|
def pdf_name(self):
|
2016-02-11 17:28:31 +00:00
|
|
|
return os.path.join(self.outputdir, self.stem, '.pdf')
|
2016-02-11 03:22:23 +00:00
|
|
|
|
2016-02-11 17:15:22 +00:00
|
|
|
@property
|
|
|
|
def html_name(self):
|
2016-02-11 17:28:31 +00:00
|
|
|
return os.path.join(self.outputdir, self.stem, '.html')
|
2016-02-11 03:22:23 +00:00
|
|
|
|
2016-02-11 17:15:22 +00:00
|
|
|
@property
|
|
|
|
def htmls_name(self):
|
2016-02-11 17:28:31 +00:00
|
|
|
return os.path.join(self.outputdir, self.stem, '-single.html')
|
2016-02-11 03:22:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
# -- end of file
|