Skip to content

Fix logic in Project.conf_dir #1629

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

Merged
merged 3 commits into from
Sep 14, 2015
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 6 additions & 4 deletions readthedocs/builds/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ def get_downloads(self, pretty=False):
return data

def get_conf_py_path(self):
conf_py_path = self.project.conf_file(self.slug)
conf_py_path = conf_py_path.replace(
self.project.checkout_path(self.slug), '')
return conf_py_path.replace('conf.py', '')
conf_py_path = self.project.conf_dir(self.slug)
if not conf_py_path.endswith('/'):
conf_py_path += '/'
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be os.path.sep or rely on os.path.join. Also, if you use os.path.relpath below, you shouldn't need this at all as it handles normalizing paths a little bit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Excellent idea. Fixed.

checkout_prefix = self.project.checkout_path(self.slug)
conf_py_path = conf_py_path[len(checkout_prefix):]
return conf_py_path

def get_build_path(self):
'''Return version build path if path exists, otherwise `None`'''
Expand Down
2 changes: 1 addition & 1 deletion readthedocs/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ def conf_file(self, version=LATEST):
def conf_dir(self, version=LATEST):
conf_file = self.conf_file(version)
if conf_file:
return conf_file.replace('/conf.py', '')
return os.path.dirname(conf_file)

@property
def is_type_sphinx(self):
Expand Down