Procházet zdrojové kódy

Rename github to github_tools so that modules don't conflict with PyGithub (#223)

Jon Meow před 5 roky
rodič
revize
2efbe1074e

+ 0 - 0
github/README.md → github_tools/README.md


+ 0 - 0
github_tools/__init__.py


+ 0 - 0
github/github_helpers.py → github_tools/github_helpers.py


+ 1 - 1
github/github_helpers_test.py → github_tools/github_helpers_test.py

@@ -9,7 +9,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 import unittest
 from unittest import mock
 
-import github_helpers
+from github_tools import github_helpers
 
 
 _TEST_QUERY = """

+ 8 - 1
github/pr_comments.py → github_tools/pr_comments.py

@@ -11,9 +11,16 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 import argparse
 import datetime
 import hashlib
+import os
+import sys
 import textwrap
 
-import github_helpers
+# To support direct runs, ensure the pythonpath has the repo root.
+_PYTHONPATH = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
+if _PYTHONPATH not in sys.path:
+    sys.path.insert(0, _PYTHONPATH)
+
+from github_tools import github_helpers
 
 # The main query, into which other queries are composed.
 _QUERY = """

+ 1 - 1
github/pr_comments_test.py → github_tools/pr_comments_test.py

@@ -10,7 +10,7 @@ import os
 import unittest
 from unittest import mock
 
-import pr_comments
+from github_tools import pr_comments
 
 
 class TestPRComments(unittest.TestCase):

+ 8 - 1
github/update_label_access.py → github_tools/update_label_access.py

@@ -14,12 +14,19 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 """
 
 import argparse
+import os
+import sys
 
 # https://github.com/PyGithub/PyGithub
 # GraphQL is preferred, but falling back to pygithub for unsupported mutations.
 import github
 
-import github_helpers
+# To support direct runs, ensure the pythonpath has the repo root.
+_PYTHONPATH = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
+if _PYTHONPATH not in sys.path:
+    sys.path.insert(0, _PYTHONPATH)
+
+from github_tools import github_helpers
 
 # The organization to mirror members from.
 _ORG = "carbon-language"

+ 2 - 2
github/update_label_access_test.py → github_tools/update_label_access_test.py

@@ -10,8 +10,8 @@ import github
 import unittest
 from unittest import mock
 
-import github_helpers
-import update_label_access
+from github_tools import github_helpers
+from github_tools import update_label_access
 
 
 class TestUpdateLabelAccess(unittest.TestCase):