开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 0

乘着船/python-for-android

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (22)
标签 (20)
master
develop
release-2024年01月21日
Pillow_post_get_bbox
release-2022年12月20日
release-2022年09月04日
release-2020年06月02日
release-2020年04月29日
release-2020年03月30日
develop-merge-master-2
release-2020年04月01日
release-2019年10月06日
feature/entry_point_from_getextra
release-2019年08月09日
release-2019年07月08日
release-2019年06月06日
feature/add_kivent_recipes_again
dump_restore_manifest
stable
old_toolchain
v2024.01.21
v2023.09.16
v2023.05.21
v2023.02.10
v2023.01.28
v2022.12.20
v2022.09.04
v2022.07.20
v2022.03.13
v2021.09.05
v2020.06.02
v2020.04.29
v2020.03.30
v2019.10.06
v2019.08.09
v2019.07.08
v2019.06.06
0.7.0
0.6.0
0.5.3
master
分支 (22)
标签 (20)
master
develop
release-2024年01月21日
Pillow_post_get_bbox
release-2022年12月20日
release-2022年09月04日
release-2020年06月02日
release-2020年04月29日
release-2020年03月30日
develop-merge-master-2
release-2020年04月01日
release-2019年10月06日
feature/entry_point_from_getextra
release-2019年08月09日
release-2019年07月08日
release-2019年06月06日
feature/add_kivent_recipes_again
dump_restore_manifest
stable
old_toolchain
v2024.01.21
v2023.09.16
v2023.05.21
v2023.02.10
v2023.01.28
v2022.12.20
v2022.09.04
v2022.07.20
v2022.03.13
v2021.09.05
v2020.06.02
v2020.04.29
v2020.03.30
v2019.10.06
v2019.08.09
v2019.07.08
v2019.06.06
0.7.0
0.6.0
0.5.3
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (22)
标签 (20)
master
develop
release-2024年01月21日
Pillow_post_get_bbox
release-2022年12月20日
release-2022年09月04日
release-2020年06月02日
release-2020年04月29日
release-2020年03月30日
develop-merge-master-2
release-2020年04月01日
release-2019年10月06日
feature/entry_point_from_getextra
release-2019年08月09日
release-2019年07月08日
release-2019年06月06日
feature/add_kivent_recipes_again
dump_restore_manifest
stable
old_toolchain
v2024.01.21
v2023.09.16
v2023.05.21
v2023.02.10
v2023.01.28
v2022.12.20
v2022.09.04
v2022.07.20
v2022.03.13
v2021.09.05
v2020.06.02
v2020.04.29
v2020.03.30
v2019.10.06
v2019.08.09
v2019.07.08
v2019.06.06
0.7.0
0.6.0
0.5.3
util.py 5.14 KB
一键复制 编辑 原始数据 按行查看 历史
import contextlib
from fnmatch import fnmatch
import logging
from os.path import exists, join
from os import getcwd, chdir, makedirs, walk
from pathlib import Path
from platform import uname
import shutil
from tempfile import mkdtemp
import packaging.version
from pythonforandroid.logger import (logger, Err_Fore, error, info)
LOGGER = logging.getLogger("p4a.util")
build_platform = "{system}-{machine}".format(
system=uname().system, machine=uname().machine
).lower()
"""the build platform in the format `system-machine`. We use
this string to define the right build system when compiling some recipes or
to get the right path for clang compiler"""
@contextlib.contextmanager
def current_directory(new_dir):
cur_dir = getcwd()
logger.info(''.join((Err_Fore.CYAN, '-> directory context ', new_dir,
Err_Fore.RESET)))
chdir(new_dir)
yield
logger.info(''.join((Err_Fore.CYAN, '<- directory context ', cur_dir,
Err_Fore.RESET)))
chdir(cur_dir)
@contextlib.contextmanager
def temp_directory():
temp_dir = mkdtemp()
try:
logger.debug(''.join((Err_Fore.CYAN, ' + temp directory used ',
temp_dir, Err_Fore.RESET)))
yield temp_dir
finally:
shutil.rmtree(temp_dir)
logger.debug(''.join((Err_Fore.CYAN, ' - temp directory deleted ',
temp_dir, Err_Fore.RESET)))
def walk_valid_filens(base_dir, invalid_dir_names, invalid_file_patterns):
"""Recursively walks all the files and directories in ``dirn``,
ignoring directories that match any pattern in ``invalid_dirns``
and files that patch any pattern in ``invalid_filens``.
``invalid_dirns`` and ``invalid_filens`` should both be lists of
strings to match. ``invalid_dir_patterns`` expects a list of
invalid directory names, while ``invalid_file_patterns`` expects a
list of glob patterns compared against the full filepath.
File and directory paths are evaluated as full paths relative to ``dirn``.
"""
for dirn, subdirs, filens in walk(base_dir):
# Remove invalid subdirs so that they will not be walked
for i in reversed(range(len(subdirs))):
subdir = subdirs[i]
if subdir in invalid_dir_names:
subdirs.pop(i)
for filen in filens:
for pattern in invalid_file_patterns:
if fnmatch(filen, pattern):
break
else:
yield join(dirn, filen)
def load_source(module, filename):
# Python 3.5+
import importlib.util
if hasattr(importlib.util, 'module_from_spec'):
spec = importlib.util.spec_from_file_location(module, filename)
mod = importlib.util.module_from_spec(spec)
spec.loader.exec_module(mod)
return mod
else:
# Python 3.3 and 3.4:
from importlib.machinery import SourceFileLoader
return SourceFileLoader(module, filename).load_module()
class BuildInterruptingException(Exception):
def __init__(self, message, instructions=None):
super().__init__(message, instructions)
self.message = message
self.instructions = instructions
def handle_build_exception(exception):
"""
Handles a raised BuildInterruptingException by printing its error
message and associated instructions, if any, then exiting.
"""
error('Build failed: {}'.format(exception.message))
if exception.instructions is not None:
info('Instructions: {}'.format(exception.instructions))
exit(1)
def rmdir(dn, ignore_errors=False):
if not exists(dn):
return
LOGGER.debug("Remove directory and subdirectory {}".format(dn))
shutil.rmtree(dn, ignore_errors)
def ensure_dir(dn):
if exists(dn):
return
LOGGER.debug("Create directory {0}".format(dn))
makedirs(dn)
def move(source, destination):
LOGGER.debug("Moving {} to {}".format(source, destination))
shutil.move(source, destination)
def touch(filename):
Path(filename).touch()
def build_tools_version_sort_key(
version_string: str,
) -> packaging.version.Version:
"""
Returns a packaging.version.Version object for comparison purposes.
It includes canonicalization of the version string to allow for
comparison of versions with spaces in them (historically, RC candidates)
If the version string is invalid, it returns a version object with
version 0, which will be sorted at worst position.
"""
try:
# Historically, Android build release candidates have had
# spaces in the version number.
return packaging.version.Version(version_string.replace(" ", ""))
except packaging.version.InvalidVersion:
# Put badly named versions at worst position.
return packaging.version.Version("0")
def max_build_tool_version(
build_tools_versions: list,
) -> str:
"""
Returns the maximum build tools version from a list of build tools
versions. It uses the :meth:`build_tools_version_sort_key` function to
canonicalize the version strings and then returns the maximum version.
"""
return max(build_tools_versions, key=build_tools_version_sort_key)
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/buddygr/python-for-android.git
git@gitee.com:buddygr/python-for-android.git
buddygr
python-for-android
python-for-android
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /