Skip to content

Commit

Permalink
change REPO_DIR approach
Browse files Browse the repository at this point in the history
  • Loading branch information
lgolston committed Jan 15, 2024
1 parent 5e44939 commit b932312
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions lib/cartopy/tests/test_coding_standards.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
# licensing details.

from fnmatch import fnmatch
import os
from pathlib import Path
import re
import subprocess

import pytest

import cartopy


# Add shebang possibility or C comment starter to the LICENSE_RE_PATTERN
SHEBANG_PATTERN = r'((\#\!.*|\/\*)\n)?'
Expand All @@ -29,12 +26,11 @@
LICENSE_RE_PATTERN = re.escape(LICENSE_TEMPLATE)
LICENSE_RE = re.compile(SHEBANG_PATTERN + LICENSE_RE_PATTERN, re.MULTILINE)


# Guess cartopy repo directory of cartopy - realpath is used to mitigate
# against Python finding the cartopy package via a symlink.
CARTOPY_DIR = Path(cartopy.__file__).parent.resolve()
REPO_DIR = Path(os.getenv('CARTOPY_GIT_DIR',
CARTOPY_DIR.parent.parent))
# Get repo directory for cartopy (https://stackoverflow.com/a/53675112)
REPO_DIR = subprocess.Popen(['git', 'rev-parse', '--show-toplevel'],
stdout=subprocess.PIPE
).communicate()[0].rstrip().decode('utf-8')
REPO_DIR = Path(REPO_DIR)


class TestLicenseHeaders:
Expand Down

0 comments on commit b932312

Please sign in to comment.