summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2011-11-05 03:50:48 +0100
committerGravatar Tom Willemsen2011-11-05 03:50:48 +0100
commit528737be805c61ee3ccda767c98920ec5e14f928 (patch)
tree6fabb7951d8105657e6c66b0300130b3fcb949b1
parent0e14ef7f7c336d138c31a83845039cbea8dce4af (diff)
downloaddotfiles-528737be805c61ee3ccda767c98920ec5e14f928.tar.gz
dotfiles-528737be805c61ee3ccda767c98920ec5e14f928.zip
Skip .git dir
-rw-r--r--pages/management/commands/parse_markdown.py59
1 files changed, 31 insertions, 28 deletions
diff --git a/pages/management/commands/parse_markdown.py b/pages/management/commands/parse_markdown.py
index 38fc7ea..4b2e774 100644
--- a/pages/management/commands/parse_markdown.py
+++ b/pages/management/commands/parse_markdown.py
@@ -5,37 +5,40 @@ from django.core.management.base import BaseCommand, CommandError
from settings import MARKDOWN_PATH, DEPLOY_PATH
+ignore_dir = '.git'
+
class Command(BaseCommand):
help = 'Parse markdown files in %s' % MARKDOWN_PATH
def handle(self, *args, **options):
for root, dirs, files in os.walk(MARKDOWN_PATH):
- for file in files:
- subdir = root.replace(MARKDOWN_PATH, "")
- mdfile = '%s/%s' % (root, file)
- mdtuple = os.path.splitext(file)
- mdname = '%s/%s' % (subdir, mdtuple[0])
- htmlpath = '%s/templates/html_pages/%s' % (DEPLOY_PATH, mdname)
- htmlfile = '%s/index.html' % htmlpath
-
- if options['verbosity'] == '3':
- print 'Subdir: ', subdir
- print 'Mdfile: ', mdfile
- print 'Mdtuple: ', mdtuple
- print 'Htmlpath: ', htmlpath
- print 'Htmlfile: ', htmlfile
-
- if mdtuple[1] == '.mdwn' and os.path.exists(mdfile) \
- and (not os.path.exists(htmlfile) \
- or os.path.getmtime(mdfile) > os.path.getmtime(htmlfile)):
-
- if not os.path.exists(htmlpath):
- os.makedirs(htmlpath)
-
- md = markdown.Markdown()
- print 'Converting ', mdname, '-->', htmlfile,
- wikiExtension = 'wikilinks(base_url=%s/)' % subdir
- markdown.markdownFromFile(input=mdfile, output=htmlfile, encoding="utf-8",
- extensions=[wikiExtension])
- print ' ... succeeded'
+ if ignore_dir not in root:
+ for file in files:
+ subdir = root.replace(MARKDOWN_PATH, "")
+ mdfile = '%s/%s' % (root, file)
+ mdtuple = os.path.splitext(file)
+ mdname = '%s/%s' % (subdir, mdtuple[0])
+ htmlpath = '%s/templates/html_pages/%s' % (DEPLOY_PATH, mdname)
+ htmlfile = '%s/index.html' % htmlpath
+
+ if options['verbosity'] == '3':
+ print 'Subdir: ', subdir
+ print 'Mdfile: ', mdfile
+ print 'Mdtuple: ', mdtuple
+ print 'Htmlpath: ', htmlpath
+ print 'Htmlfile: ', htmlfile
+
+ if mdtuple[1] == '.mdwn' and os.path.exists(mdfile) \
+ and (not os.path.exists(htmlfile) \
+ or os.path.getmtime(mdfile) > os.path.getmtime(htmlfile)):
+
+ if not os.path.exists(htmlpath):
+ os.makedirs(htmlpath)
+
+ md = markdown.Markdown()
+ print 'Converting ', mdname, '-->', htmlfile,
+ wikiExtension = 'wikilinks(base_url=%s/)' % subdir
+ markdown.markdownFromFile(input=mdfile, output=htmlfile, encoding="utf-8",
+ extensions=[wikiExtension])
+ print ' ... succeeded'