Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncouple project name and project path #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions psa
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,8 @@ def main():

parser.add_option("-v", "--verbose", action="store_true", default=False,
help="Output debug messages")
parser.add_option("-P", "--project", action="store", default="",
type="string", help="Set project name manually")

(options, args) = parser.parse_args()

Expand All @@ -844,13 +846,13 @@ def main():
if args[0] == "init":
psa_init(args)
elif args[0] == "build-deb":
psa_build(args)
psa_build(args, options)
elif args[0] == "update":
psa_update(args)
psa_update(args, options)
elif args[0] == "list":
psa_list_templates()
else:
fatal("Unknow command. Try init, build-deb, update, or list")
fatal("Unknown command. Try init, build-deb, update, or list")

def get_readme_path():
'''Returns the README file path'''
Expand Down Expand Up @@ -943,13 +945,18 @@ def get_template(name):

return TEMPLATES.get(name, None)

def get_local_config(path=None):
def get_local_config(options, path=None):
'''Loads the local project config file'''
if path is None:
path = os.curdir

# Guess project name from current dir name
project = os.path.basename(os.path.abspath(path))
if options.project == "":
# Guess project name from current dir name
project = os.path.basename(os.path.abspath(path))
else:
# Take project name from arguments
project = options.project
print "Project name is %s" % project
filename = os.path.join(os.curdir, project+'.psa')

try:
Expand Down Expand Up @@ -1018,10 +1025,10 @@ def psa_init(args):
not supported, open the %s file and comment out the
needed lines.""" % slug))

def psa_build(args):
def psa_build(args, options):
'''Builds the project'''

config = get_local_config()
config = get_local_config(options)

if not config:
fatal("""\
Expand Down Expand Up @@ -1050,10 +1057,10 @@ def psa_build(args):
print "Done! The binary package can be found at ./deb_dist"
return

def psa_update(args):
def psa_update(args, options):
'''Updates fields of the project'''

config = get_local_config()
config = get_local_config(options)

if not config:
fatal("""\
Expand Down