Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
26924ece
D
Dak
项目概览
喜羊羊3508
/
Dak
9 个月 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Dak
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
26924ece
编写于
2月 05, 2023
作者:
A
Ansgar
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
small modernization changes
上级
bdfa7aa5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
29 deletion
+18
-29
daklib/termcolor.py
daklib/termcolor.py
+0
-3
daklib/utils.py
daklib/utils.py
+18
-26
未找到文件。
daklib/termcolor.py
浏览文件 @
26924ece
...
...
@@ -25,9 +25,6 @@ TermColor utils for dak
from
typing
import
Optional
__all__
=
[]
###############################################################################
_COLORS_
=
(
'red'
,
'green'
,
'yellow'
,
'blue'
,
'violet'
,
'cyan'
,
'white'
)
_COLOR_CODES_
=
{
k
:
31
+
_COLORS_
.
index
(
k
)
for
k
in
_COLORS_
}
...
...
daklib/utils.py
浏览文件 @
26924ece
...
...
@@ -79,16 +79,15 @@ def input_or_exit(prompt: Optional[str] = None) -> str:
def
extract_component_from_section
(
section
:
str
)
->
tuple
[
str
,
str
]:
component
=
""
"""split "component/section" into "section", "component" parts
if
section
.
find
(
'/'
)
!=
-
1
:
component
=
section
.
split
(
'/'
)[
0
]
# Expand default component
if
component
==
""
:
component
=
"main"
If "component" is not given, "main" is used instead.
return
(
section
,
component
)
:return: tuple (section, component)
"""
if
section
.
find
(
'/'
)
!=
-
1
:
return
tuple
(
reversed
(
section
.
split
(
'/'
,
1
)))
return
section
,
"main"
################################################################################
...
...
@@ -129,8 +128,7 @@ def parse_deb822(armored_contents: bytes, signing_rules: Literal[-1, 0, 1] = 0,
if
index
!=
num_of_lines
:
raise
InvalidDscError
(
index
)
break
slf
=
re_single_line_field
.
match
(
line
)
if
slf
:
if
slf
:
=
re_single_line_field
.
match
(
line
):
field
=
slf
.
groups
()[
0
].
lower
()
changes
[
field
]
=
slf
.
groups
()[
1
]
first
=
1
...
...
@@ -138,8 +136,7 @@ def parse_deb822(armored_contents: bytes, signing_rules: Literal[-1, 0, 1] = 0,
if
line
==
" ."
:
changes
[
field
]
+=
'
\n
'
continue
mlf
=
re_multi_line_field
.
match
(
line
)
if
mlf
:
if
mlf
:
=
re_multi_line_field
.
match
(
line
):
if
first
==
-
1
:
raise
ParseChangesError
(
"'%s'
\n
[Multi-line field continuing on from nothing?]"
%
(
line
))
if
first
==
1
and
changes
[
field
]
!=
""
:
...
...
@@ -154,8 +151,7 @@ def parse_deb822(armored_contents: bytes, signing_rules: Literal[-1, 0, 1] = 0,
if
"source"
in
changes
:
# Strip the source version in brackets from the source field,
# put it in the "source-version" field instead.
srcver
=
re_srchasver
.
search
(
changes
[
"source"
])
if
srcver
:
if
srcver
:
=
re_srchasver
.
search
(
changes
[
"source"
]):
changes
[
"source"
]
=
srcver
.
group
(
1
)
changes
[
"source-version"
]
=
srcver
.
group
(
2
)
...
...
@@ -405,8 +401,7 @@ def send_mail(message: str, whitelists: Optional[list[str]] = None) -> None:
call_sendmail
=
False
# sign mail
mailkey
=
Cnf
.
get
(
'Dinstall::Mail-Signature-Key'
,
''
)
if
mailkey
:
if
mailkey
:
=
Cnf
.
get
(
'Dinstall::Mail-Signature-Key'
,
''
):
kwargs
=
{
'keyids'
:
[
mailkey
],
'pubring'
:
Cnf
.
get
(
'Dinstall::SigningPubKeyring'
)
or
None
,
...
...
@@ -552,16 +547,13 @@ def result_join(original: Iterable[Optional[str]], sep: str = '\t') -> str:
################################################################################
def
prefix_multi_line_string
(
str
,
prefix
,
include_blank_lines
:
bool
=
False
):
out
=
""
for
line
in
str
.
split
(
'
\n
'
):
line
=
line
.
strip
()
if
line
or
include_blank_lines
:
out
+=
"%s%s
\n
"
%
(
prefix
,
line
)
# Strip trailing new line
if
out
:
out
=
out
[:
-
1
]
return
out
def
prefix_multi_line_string
(
lines
:
str
,
prefix
:
str
,
include_blank_lines
:
bool
=
False
)
->
str
:
"""prepend `prefix` to each line in `lines`"""
return
"
\n
"
.
join
(
prefix
+
cleaned_line
for
line
in
lines
.
split
(
"
\n
"
)
if
(
cleaned_line
:
=
line
.
strip
())
or
include_blank_lines
)
################################################################################
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录