mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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:
|
else:
|
||||||
str_compat = unicode
|
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 decoding_strings(f):
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
out = f(*args, **kwargs)
|
out = f(*args, **kwargs)
|
||||||
|
|
@ -178,7 +185,7 @@ def main():
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
description="A kickstarter for Pelican",
|
description="A kickstarter for Pelican",
|
||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
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")
|
help="The path to generate the blog into")
|
||||||
parser.add_argument('-t', '--title', metavar="title",
|
parser.add_argument('-t', '--title', metavar="title",
|
||||||
help='Set the title of the website')
|
help='Set the title of the website')
|
||||||
|
|
@ -200,7 +207,8 @@ needed by Pelican.
|
||||||
|
|
||||||
project = os.path.join(
|
project = os.path.join(
|
||||||
os.environ.get('VIRTUAL_ENV', os.curdir), '.project')
|
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")
|
CONF['basedir'] = open(project, 'r').read().rstrip("\n")
|
||||||
print('Using project associated with current virtual environment.'
|
print('Using project associated with current virtual environment.'
|
||||||
'Will save to:\n%s\n' % CONF['basedir'])
|
'Will save to:\n%s\n' % CONF['basedir'])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue