forked from github/pelican
Allow --path even when using a virtualenv project
This commit is contained in:
parent
d0c15d5a0c
commit
d6ebf772e3
1 changed files with 10 additions and 2 deletions
|
|
@ -59,6 +59,13 @@ if six.PY3:
|
|||
else:
|
||||
str_compat = unicode
|
||||
|
||||
# Create a 'marked' default path, to determine if someone has supplied
|
||||
# a path on the command-line.
|
||||
class _DEFAULT_PATH_TYPE(str_compat):
|
||||
is_default_path = True
|
||||
|
||||
_DEFAULT_PATH = _DEFAULT_PATH_TYPE(os.curdir)
|
||||
|
||||
def decoding_strings(f):
|
||||
def wrapper(*args, **kwargs):
|
||||
out = f(*args, **kwargs)
|
||||
|
|
@ -178,7 +185,7 @@ def main():
|
|||
parser = argparse.ArgumentParser(
|
||||
description="A kickstarter for Pelican",
|
||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
||||
parser.add_argument('-p', '--path', default=os.curdir,
|
||||
parser.add_argument('-p', '--path', default=_DEFAULT_PATH,
|
||||
help="The path to generate the blog into")
|
||||
parser.add_argument('-t', '--title', metavar="title",
|
||||
help='Set the title of the website')
|
||||
|
|
@ -200,7 +207,8 @@ needed by Pelican.
|
|||
|
||||
project = os.path.join(
|
||||
os.environ.get('VIRTUAL_ENV', os.curdir), '.project')
|
||||
if os.path.isfile(project):
|
||||
no_path_was_specified = hasattr(args.path, 'is_default_path')
|
||||
if os.path.isfile(project) and no_path_was_specified:
|
||||
CONF['basedir'] = open(project, 'r').read().rstrip("\n")
|
||||
print('Using project associated with current virtual environment.'
|
||||
'Will save to:\n%s\n' % CONF['basedir'])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue