mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-05 23:10:29 +03:00
import_subcommand.py: format
This commit is contained in:
parent
b7749ece8d
commit
5da4e670dd
3 changed files with 57 additions and 35 deletions
|
|
@ -18,32 +18,29 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import stat
|
||||
import urllib
|
||||
|
||||
import git
|
||||
import json
|
||||
import shutil
|
||||
import stat
|
||||
import sys
|
||||
import yaml
|
||||
import urllib
|
||||
from argparse import ArgumentParser
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
import git
|
||||
import yaml
|
||||
|
||||
try:
|
||||
from yaml import CSafeLoader as SafeLoader
|
||||
except ImportError:
|
||||
from yaml import SafeLoader
|
||||
|
||||
from . import _
|
||||
from . import common
|
||||
from . import metadata
|
||||
from . import _, common, metadata
|
||||
from .exception import FDroidException
|
||||
|
||||
|
||||
config = None
|
||||
|
||||
|
||||
|
|
@ -122,7 +119,7 @@ def getrepofrompage(url: str) -> tuple[Optional[str], str]:
|
|||
index = page.find('hg clone')
|
||||
if index != -1:
|
||||
repotype = 'hg'
|
||||
repo = page[index + 9:]
|
||||
repo = page[index + 9 :]
|
||||
index = repo.find('<')
|
||||
if index == -1:
|
||||
return (None, _("Error while getting repo address"))
|
||||
|
|
@ -134,7 +131,7 @@ def getrepofrompage(url: str) -> tuple[Optional[str], str]:
|
|||
index = page.find('git clone')
|
||||
if index != -1:
|
||||
repotype = 'git'
|
||||
repo = page[index + 10:]
|
||||
repo = page[index + 10 :]
|
||||
index = repo.find('<')
|
||||
if index == -1:
|
||||
return (None, _("Error while getting repo address"))
|
||||
|
|
@ -243,18 +240,37 @@ def main():
|
|||
# Parse command line...
|
||||
parser = ArgumentParser()
|
||||
common.setup_global_opts(parser)
|
||||
parser.add_argument("-u", "--url", default=None,
|
||||
help=_("Project URL to import from."))
|
||||
parser.add_argument("-s", "--subdir", default=None,
|
||||
help=_("Path to main Android project subdirectory, if not in root."))
|
||||
parser.add_argument("-c", "--categories", default=None,
|
||||
help=_("Comma separated list of categories."))
|
||||
parser.add_argument("-l", "--license", default=None,
|
||||
help=_("Overall license of the project."))
|
||||
parser.add_argument("--omit-disable", action="store_true", default=False,
|
||||
help=_("Do not add 'disable:' to the generated build entries"))
|
||||
parser.add_argument("--rev", default=None,
|
||||
help=_("Allows a different revision (or git branch) to be specified for the initial import"))
|
||||
parser.add_argument(
|
||||
"-u", "--url", default=None, help=_("Project URL to import from.")
|
||||
)
|
||||
parser.add_argument(
|
||||
"-s",
|
||||
"--subdir",
|
||||
default=None,
|
||||
help=_("Path to main Android project subdirectory, if not in root."),
|
||||
)
|
||||
parser.add_argument(
|
||||
"-c",
|
||||
"--categories",
|
||||
default=None,
|
||||
help=_("Comma separated list of categories."),
|
||||
)
|
||||
parser.add_argument(
|
||||
"-l", "--license", default=None, help=_("Overall license of the project.")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--omit-disable",
|
||||
action="store_true",
|
||||
default=False,
|
||||
help=_("Do not add 'disable:' to the generated build entries"),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--rev",
|
||||
default=None,
|
||||
help=_(
|
||||
"Allows a different revision (or git branch) to be specified for the initial import"
|
||||
),
|
||||
)
|
||||
metadata.add_metadata_arguments(parser)
|
||||
options = common.parse_args(parser)
|
||||
metadata.warnings_action = options.W
|
||||
|
|
@ -268,7 +284,9 @@ def main():
|
|||
|
||||
local_metadata_files = common.get_local_metadata_files()
|
||||
if local_metadata_files:
|
||||
raise FDroidException(_("This repo already has local metadata: %s") % local_metadata_files[0])
|
||||
raise FDroidException(
|
||||
_("This repo already has local metadata: %s") % local_metadata_files[0]
|
||||
)
|
||||
|
||||
build = metadata.Build()
|
||||
if options.url is None and Path('.git').is_dir():
|
||||
|
|
@ -294,7 +312,9 @@ def main():
|
|||
git_repo = git.Repo(tmp_importer_dir)
|
||||
|
||||
if not options.omit_disable:
|
||||
build.disable = 'Generated by `fdroid import` - check version fields and commitid'
|
||||
build.disable = (
|
||||
'Generated by `fdroid import` - check version fields and commitid'
|
||||
)
|
||||
write_local_file = False
|
||||
else:
|
||||
raise FDroidException("Specify project url.")
|
||||
|
|
@ -405,8 +425,11 @@ def main():
|
|||
Path('build').mkdir(exist_ok=True)
|
||||
build_dir = Path('build') / appid
|
||||
if build_dir.exists():
|
||||
logging.warning(_('{path} already exists, ignoring import results!')
|
||||
.format(path=build_dir))
|
||||
logging.warning(
|
||||
_('{path} already exists, ignoring import results!').format(
|
||||
path=build_dir
|
||||
)
|
||||
)
|
||||
sys.exit(1)
|
||||
elif tmp_importer_dir:
|
||||
# For Windows: Close the repo or a git.exe instance holds handles to repo
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue