Explorar el Código

Allow overriding the archive ID

tags/v1.0
JustAnotherArchivist hace 3 años
padre
commit
7e8958b063
Se han modificado 2 ficheros con 8 adiciones y 5 borrados
  1. +2
    -1
      codearchiver/core.py
  2. +6
    -4
      codearchiver/modules/git.py

+ 2
- 1
codearchiver/core.py Ver fichero

@@ -124,9 +124,10 @@ class Module:
'''Whether or not this module is for handling `inputUrl`.'''
return False

def __init__(self, inputUrl):
def __init__(self, inputUrl, id_ = None):
self._inputUrl = inputUrl
self._url = inputUrl.url
self._id = id_
self._httpClient = HttpClient()

@abc.abstractmethod


+ 6
- 4
codearchiver/modules/git.py Ver fichero

@@ -14,8 +14,8 @@ class Git(codearchiver.core.Module):
def matches(inputUrl):
return inputUrl.url.endswith('.git')

def __init__(self, inputUrl, extraBranches = {}):
super().__init__(inputUrl)
def __init__(self, *args, extraBranches = {}, **kwargs):
super().__init__(*args, **kwargs)
self._extraBranches = extraBranches

def process(self):
@@ -24,7 +24,9 @@ class Git(codearchiver.core.Module):
logger.fatal(f'{directory!r} already exists')
return
startTime = datetime.datetime.utcnow()
bundle = f'{self._url.replace("/", "_")}.{startTime:%Y%m%dT%H%M%SZ}.bundle'
if self._id is None:
self._id = f'git_{self._url.replace("/", "_")}_{startTime:%Y%m%dT%H%M%SZ}'
bundle = f'{self._id}.bundle'
if os.path.exists(bundle):
logger.fatal(f'{bundle!r} already exists')
return
@@ -49,7 +51,7 @@ class Git(codearchiver.core.Module):
logger.info(f'Removing clone')
shutil.rmtree(directory)

return codearchiver.core.Result(id = f'git-{bundle[:-7]}', files = [bundle])
return codearchiver.core.Result(id = self._id, files = [bundle])

def __repr__(self):
return f'{type(self).__module__}.{type(self).__name__}({self._inputUrl!r}, extraBranches = {self._extraBranches!r})'

Cargando…
Cancelar
Guardar