text stringlengths 0 828 |
|---|
:returns: Path to the cloned repository |
''' |
repo_name = repo_url.split('/')[-1].rsplit('.', maxsplit=1)[0] |
repo_path = (self._cache_path / repo_name).resolve() |
self.logger.debug(f'Synchronizing with repo; URL: {repo_url}, revision: {revision}') |
try: |
self.logger.debug(f'Cloning repo {repo_url} to {repo_path}') |
run( |
f'git clone {repo_url} {repo_path}', |
shell=True, |
check=True, |
stdout=PIPE, |
stderr=STDOUT |
) |
except CalledProcessError as exception: |
if repo_path.exists(): |
self.logger.debug('Repo already cloned; pulling from remote') |
try: |
run( |
'git pull', |
cwd=repo_path, |
shell=True, |
check=True, |
stdout=PIPE, |
stderr=STDOUT |
) |
except CalledProcessError as exception: |
self.logger.warning(str(exception)) |
else: |
self.logger.error(str(exception)) |
if revision: |
run( |
f'git checkout {revision}', |
cwd=repo_path, |
shell=True, |
check=True, |
stdout=PIPE, |
stderr=STDOUT |
) |
return repo_path" |
1477,"def _shift_headings(self, content: str, shift: int) -> str: |
'''Shift Markdown headings in a string by a given value. The shift can |
be positive or negative. |
:param content: Markdown content |
:param shift: Heading shift |
:returns: Markdown content with headings shifted by ``shift`` |
''' |
def _sub(heading): |
new_heading_level = len(heading.group('hashes')) + shift |
self.logger.debug(f'Shift heading level to {new_heading_level}, heading title: {heading.group(""title"")}') |
if new_heading_level <= 6: |
return f'{""#"" * new_heading_level} {heading.group(""title"")}{heading.group(""tail"")}' |
else: |
self.logger.debug('New heading level is out of range, using bold paragraph text instead of heading') |
return f'**{heading.group(""title"")}**{heading.group(""tail"")}' |
return self._heading_pattern.sub(_sub, content)" |
1478,"def _find_top_heading_level(self, content: str) -> int: |
'''Find the highest level heading (i.e. having the least '#'s) |
in a Markdown string. |
:param content: Markdown content |
:returns: Maximum heading level detected; if no heading is found, 0 is returned |
''' |
result = float('inf') |
for heading in self._heading_pattern.finditer(content): |
heading_level = len(heading.group('hashes')) |
if heading_level < result: |
result = heading_level |
self.logger.debug(f'Maximum heading level: {result}') |
return result if result < float('inf') else 0" |
1479,"def _cut_from_heading_to_heading( |
self, |
content: str, |
from_heading: str, |
to_heading: str or None = None, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.