1
0
Fork 0
forked from github/pelican

content: Convert StaticContent.filepath to .filename

For reasons that are unclear to me, StaticContent introduces the
`filepath` attribute rather than using the existing (and semantically
equivalent) Page.filename.  This has caused confusion before [1], and
it's probably a good idea to merge the two.

While I was touching the line, I also updated the string formatting in
StaticGenerator.generate_output to use the forward compatible
'{}'.format() syntax.

[1]: https://github.com/getpelican/pelican/issues/162#issuecomment-3000363
This commit is contained in:
W. Trevor King 2013-01-04 13:08:08 -05:00
commit 61f05672e6
2 changed files with 4 additions and 4 deletions

View file

@ -305,11 +305,11 @@ class StaticContent(object):
settings = copy.deepcopy(_DEFAULT_CONFIG)
self.src = src
self.url = dst or src
self.filepath = os.path.join(settings['PATH'], src)
self.filename = os.path.join(settings['PATH'], src)
self.save_as = os.path.join(settings['OUTPUT_PATH'], self.url)
def __str__(self):
return self.filepath
return self.filename
def is_valid_content(content, f):

View file

@ -520,8 +520,8 @@ class StaticGenerator(Generator):
# copy all StaticContent files
for sc in self.staticfiles:
mkdir_p(os.path.dirname(sc.save_as))
shutil.copy(sc.filepath, sc.save_as)
logger.info('copying %s to %s' % (sc.filepath, sc.save_as))
shutil.copy(sc.filename, sc.save_as)
logger.info('copying {} to {}'.format(sc.filename, sc.save_as))
class PdfGenerator(Generator):