Skip to content
Merged
Show file tree
Hide file tree
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
23 changes: 22 additions & 1 deletion material/plugins/info/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

import getpass
import glob
import json
import logging
Expand Down Expand Up @@ -200,6 +201,19 @@ def on_config(self, config):
if path.startswith(os.getcwd()):
self.exclusion_patterns.append(_resolve_pattern(path))

# Guess other Virtual Environment paths in case we forget to activate
# them or in case we have multiple. Making sure which venv is activated
# is not necessary, as it is an optional step in the guidelines.
for path in glob.iglob(
pathname = "**/pyvenv.cfg",
root_dir = os.getcwd(),
recursive = True
):
path = os.path.join(os.getcwd(), os.path.dirname(path))
if path not in site.PREFIXES:
print(f"Possible inactive venv: {path}")
self.exclusion_patterns.append(_resolve_pattern(path))

# Exclude site_dir for projects
if projects_plugin:
for path in glob.iglob(
Expand Down Expand Up @@ -266,6 +280,12 @@ def on_config(self, config):
]))
)

# Try to get login to replace it with USERNAME placeholder
try:
username = getpass.getuser()
except Exception:
username = ""

# Add information on platform
f.writestr(
os.path.join(example, "platform.json"),
Expand All @@ -280,12 +300,13 @@ def on_config(self, config):
*sys.argv[1:]
]),
"env:$PYTHONPATH": os.getenv("PYTHONPATH", ""),
"env:$VIRTUAL_ENV": os.getenv("VIRTUAL_ENV", ""),
"sys.path": sys.path,
"excluded_entries": self.excluded_entries
},
default = str,
indent = 2
)
).replace(username, "USERNAME")
)

# Retrieve list of processed files
Expand Down
23 changes: 22 additions & 1 deletion src/plugins/info/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

import getpass
import glob
import json
import logging
Expand Down Expand Up @@ -200,6 +201,19 @@ def on_config(self, config):
if path.startswith(os.getcwd()):
self.exclusion_patterns.append(_resolve_pattern(path))

# Guess other Virtual Environment paths in case we forget to activate
# them or in case we have multiple. Making sure which venv is activated
# is not necessary, as it is an optional step in the guidelines.
for path in glob.iglob(
pathname = "**/pyvenv.cfg",
root_dir = os.getcwd(),
recursive = True
):
path = os.path.join(os.getcwd(), os.path.dirname(path))
if path not in site.PREFIXES:
print(f"Possible inactive venv: {path}")
self.exclusion_patterns.append(_resolve_pattern(path))

# Exclude site_dir for projects
if projects_plugin:
for path in glob.iglob(
Expand Down Expand Up @@ -266,6 +280,12 @@ def on_config(self, config):
]))
)

# Try to get login to replace it with USERNAME placeholder
try:
username = getpass.getuser()
except Exception:
username = ""

# Add information on platform
f.writestr(
os.path.join(example, "platform.json"),
Expand All @@ -280,12 +300,13 @@ def on_config(self, config):
*sys.argv[1:]
]),
"env:$PYTHONPATH": os.getenv("PYTHONPATH", ""),
"env:$VIRTUAL_ENV": os.getenv("VIRTUAL_ENV", ""),
"sys.path": sys.path,
"excluded_entries": self.excluded_entries
},
default = str,
indent = 2
)
).replace(username, "USERNAME")
)

# Retrieve list of processed files
Expand Down