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

Move all imports to have "readthedocs" at the top level. #1496

Merged
merged 12 commits into from
Jul 30, 2015

Conversation

ericholscher
Copy link
Member

This is something we should have done a long time ago,
as it matches Django's recommended layout since 1.4.

This allows us to remove the path hacking of adding the readthedocs subdir
to the PYTHONPATH on execution.

All changes were automated,
except for a few small hand-made changes,
which are the non-automated commits here.

Only other things changed:

  • manage.py moved to top-level directory
  • PYTHONPATH hacking removing from manage.py
  • Prepended readthedocs to all imports

This is the script run:

import os

for app in os.listdir('readthedocs'):
    for dir in ['readthedocs']: # Useful for updating imports on dependent source

        if '__' in app or '.' in app:
            continue

        cmd = "find %s -type f -name '*.py' -exec perl -pi -w -e 's/^(\s+)?from %s/$1from readthedocs.%s/g' {} +" % (dir,app, app)
        print cmd
        os.system(cmd)

        cmd = "find %s -type f -name '*.py' -exec perl -pi -w -e 's/^(\s+)?import %s/$1import readthedocs.%s/g' {} +" % (dir,app, app)
        print cmd
        os.system(cmd)

        cmd = "find %s -type f -name '*.py' -exec perl -pi -w -e \"s|include\('%s|include\('readthedocs.%s|g\" {} +" % (dir,app, app)
        print cmd
        os.system(cmd)

        cmd = "find %s -type f -name '*.py' -exec perl -pi -w -e \"s/'%s.views/'readthedocs.%s.views/g\" {} +" % (dir, app, app)
        print cmd
        os.system(cmd)

        cmd = "find %s -type f -name '*.py' -exec perl -pi -w -e \"s/\@mock.patch\('%s/\@mock.patch\('readthedocs.%s/g\" {} +" % (dir, app, app)
        print cmd
        os.system(cmd)

@ericholscher ericholscher added the PR: work in progress Pull request is not ready for full review label Jul 29, 2015
@d0ugal
Copy link
Contributor

d0ugal commented Jul 29, 2015

yes yes yes!

@gregmuellegger
Copy link
Contributor

I haven't reviewed the commits, but big 👍 for namespacing the packages.

@ericholscher ericholscher added PR: ready for review and removed PR: work in progress Pull request is not ready for full review labels Jul 30, 2015
@ericholscher
Copy link
Member Author

👍 in person from @agjohnson

ericholscher added a commit that referenced this pull request Jul 30, 2015
Move all imports to have "readthedocs" at the top level.
@ericholscher ericholscher merged commit 1459ec6 into master Jul 30, 2015
gregmuellegger added a commit that referenced this pull request Jul 31, 2015
The location of the manage.py file changed with #1496. Accommodate that in the
docs as well.
gregmuellegger added a commit that referenced this pull request Jul 31, 2015
Accommodating changes from #1496 in the API documentation.
@gregmuellegger gregmuellegger deleted the fix-imports branch August 22, 2015 13:25
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