Skip to content

Commit

Permalink
refactorage
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Nov 30, 2021
1 parent d09e156 commit 3514794
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions metomi/rosie/suite_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class SuiteId:
REC_IDX = re.compile(r"\A(?:(\w+)-)?(\w+)(?:/([^\@/]+))?(?:@([^\@/]+))?\Z")
BRANCH_TRUNK = "trunk"
REV_HEAD = "HEAD"
VC_FILENAME = "log/version/vcs.conf"
svn = SvnCaller()

STATUS_CR = "X"
Expand Down Expand Up @@ -390,11 +391,11 @@ def _from_location(self, location):
suite_engine_proc, "SUITE_DIR_REL_ROOT", None
)
while loc.relative_to(sdrr):
suite_version_file_name = loc / VC_FILENAME
suite_version_file_name = loc / self.VC_FILENAME
loc = loc.parent
if not os.access(suite_version_file_name, os.F_OK | os.R_OK):
continue
location = self.parse_cylc_vc_file(suite_version_file_name)
location = self._parse_cylc_vc_file(suite_version_file_name)
break

# Assume location is a Subversion working copy of a Rosie suite
Expand Down Expand Up @@ -428,12 +429,25 @@ def _from_location(self, location):
self.revision = info_entry["commit:revision"]

@staticmethod
def parse_cylc_vc_file(fpath):
def _parse_cylc_vc_file(fpath):
"""Take a path to a Cylc VC file and returns an svn URL.
Args:
fpath: Location of Cylc Version Control info.
fpath: Location of Cylc Version Control log file.
Returns: SVN location, or None
Examples:
>>> class MockFpath():
... def read_text(self):
... return (
... 'version control system="svn"\\n'
... 'url="/a/b/c"\\n'
... 'revision="4242"'
... )
>>> mypath = MockFpath()
>>> SuiteId.parse_cylc_vc_file(mypath)
'/a/b/c@4242'
"""
location = None
vcsystem = None
Expand Down

0 comments on commit 3514794

Please sign in to comment.