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

Add --package-name option to pcreate. #2783

Merged
merged 2 commits into from
Oct 3, 2016
Merged

Add --package-name option to pcreate. #2783

merged 2 commits into from
Oct 3, 2016

Conversation

goodwillcoding
Copy link
Member

This solves the problem of scaffold creating an existing directory where the package created should not be named after the base folder. For example if I am in I run pcreate in ~/code/trypyramid.com and
would like to create package called tpc this is currently impossible. This solves the issues by allowing me to specify the package name on the command line.

Note: I'll add changelog changes post review

of scaffold creating an existing directory where the package
created should not be named after the base folder.
For example if I am in I run pcreate in ~/code/trypyramid.com and
would like to create package called tpc this is currently
impossible. This solves the issues by allowing me to specify
the package name on the command line
safe_name = pkg_resources.safe_name(project_name)
if self.options.package_name is None:
pkg_name = _bad_chars_re.sub(
'', project_name.lower().replace('-', '_'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code not run on the project name if --package-name is not specified? It seems the pkg_name should be normalized in one spot.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's existing code though, unmodified.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only change is if package name is given it is assumed to be safe and hence assigned in the else block. The assumption of safety is documented in help for pcreate

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry I read that test wrong, I thought it was is not None. So are we not validating the package name if you specify --package-name?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not validating it. Rationale being: if user provide the package name then it's a case where they want a specific one and hence need to know if it is safe. I can add validation of course if you think it is needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the assumption of safety documented? I don't get that from reading the help. Maybe rephrase that sentence slightly because I think has to be a valid python package name implies that it will be validated. Perhaps Assumed to be a valid python package name.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed verbiage, and pushed.

more explicitly states that package name is assumed to be safe
@digitalresistor digitalresistor merged commit 11cbc8f into Pylons:master Oct 3, 2016
@digitalresistor
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants