Changeset View
Changeset View
Standalone View
Standalone View
swh/loader/cvs/loader.py
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | ]: | ||||
except FileNotFoundError: | except FileNotFoundError: | ||||
pass | pass | ||||
else: | else: | ||||
# create, or update, this file in the work tree | # create, or update, this file in the work tree | ||||
if not rcsfile: | if not rcsfile: | ||||
rcsfile = rcsparse.rcsfile(f.path) | rcsfile = rcsparse.rcsfile(f.path) | ||||
rcs = RcsKeywords() | rcs = RcsKeywords() | ||||
contents = rcs.expand_keyword(f.path, rcsfile, f.rev) | contents = rcs.expand_keyword(f.path, rcsfile, f.rev) | ||||
try: | os.makedirs(os.path.dirname(wtpath), exist_ok=True) | ||||
outfile = open(wtpath, mode="wb") | |||||
except FileNotFoundError: | |||||
os.makedirs(os.path.dirname(wtpath)) | |||||
outfile = open(wtpath, mode="wb") | outfile = open(wtpath, mode="wb") | ||||
outfile.write(contents) | outfile.write(contents) | ||||
outfile.close() | outfile.close() | ||||
(revision, swh_dir) = self.compute_swh_revision(k, logmsg) | (revision, swh_dir) = self.compute_swh_revision(k, logmsg) | ||||
(contents, skipped_contents, directories) = from_disk.iter_directory( | (contents, skipped_contents, directories) = from_disk.iter_directory( | ||||
swh_dir | swh_dir | ||||
) | ) | ||||
yield contents, skipped_contents, directories, revision | yield contents, skipped_contents, directories, revision | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | def prepare(self): | ||||
for root, dirs, files in os.walk(self.cvsroot_path): | for root, dirs, files in os.walk(self.cvsroot_path): | ||||
if "CVSROOT" in dirs: | if "CVSROOT" in dirs: | ||||
have_cvsroot = True | have_cvsroot = True | ||||
dirs.remove("CVSROOT") | dirs.remove("CVSROOT") | ||||
continue | continue | ||||
for f in files: | for f in files: | ||||
filepath = os.path.join(root, f) | filepath = os.path.join(root, f) | ||||
if f[-2:] == ",v": | if f[-2:] == ",v": | ||||
try: | |||||
rcsfile = rcsparse.rcsfile(filepath) # noqa: F841 | rcsfile = rcsparse.rcsfile(filepath) # noqa: F841 | ||||
except (Exception): | |||||
raise | |||||
else: | |||||
self.log.debug( | self.log.debug( | ||||
"Looks like we have data to convert; " | "Looks like we have data to convert; " | ||||
"found a valid RCS file at %s", | "found a valid RCS file at %s", | ||||
filepath, | filepath, | ||||
) | ) | ||||
have_rcsfile = True | have_rcsfile = True | ||||
break | break | ||||
if have_rcsfile: | if have_rcsfile: | ||||
break | break | ||||
if not have_rcsfile: | if not have_rcsfile: | ||||
raise NotFound( | raise NotFound( | ||||
"Directory %s does not contain any valid RCS files %s", | "Directory %s does not contain any valid RCS files %s", | ||||
self.cvsroot_path, | self.cvsroot_path, | ||||
) | ) | ||||
▲ Show 20 Lines • Show All 145 Lines • Show Last 20 Lines |