python-tldp/tldp/outputs.py

43 lines
1.0 KiB
Python
Raw Normal View History

2016-02-11 03:22:23 +00:00
#! /usr/bin/python
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)
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)
os.mkdir(self.outputdir)
2016-02-11 17:15:22 +00:00
@property
def txt_name(self):
return os.path.join(self.outputdir, self.stem, '.txt')
2016-02-11 17:15:22 +00:00
@property
def pdf_name(self):
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):
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):
return os.path.join(self.outputdir, self.stem, '-single.html')
2016-02-11 03:22:23 +00:00
# -- end of file