Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
喜羊羊3508
Dak
提交
daaee3bc
D
Dak
项目概览
喜羊羊3508
/
Dak
10 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
daaee3bc
编写于
6月 10, 2001
作者:
J
James Troup
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix extract_component_from_section and add a test suite.
上级
0523d95c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
140 addition
and
6 deletion
+140
-6
TODO
TODO
+2
-0
test/004/test.py
test/004/test.py
+113
-0
utils.py
utils.py
+25
-6
未找到文件。
TODO
浏览文件 @
daaee3bc
...
...
@@ -57,6 +57,8 @@ Urgent
Less Urgent
-----------
o main/utils -> main/utils, main rather than utils, main
o doogie'
s
binary
->
source
index
o
ANIAS
should
be
done
in
katie
?
...
...
test/004/test.py
0 → 100755
浏览文件 @
daaee3bc
#!/usr/bin/env python
# Check utils.extract_component_from_section()
# Copyright (C) 2000 James Troup <james@nocrew.org>
# $Id: test.py,v 1.1 2001-06-10 16:35:04 troup Exp $
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
################################################################################
import
os
,
string
,
sys
sys
.
path
.
append
(
os
.
path
.
abspath
(
'../../'
));
import
utils
################################################################################
def
fail
(
message
):
sys
.
stderr
.
write
(
"%s
\n
"
%
(
message
));
sys
.
exit
(
1
);
################################################################################
# prefix: non-US
# component: main, contrib, non-free
# section: games, admin, libs, [...]
# [1] Order is as above.
# [2] Prefix is optional for the default archive, but mandatory when
# uploads are going anywhere else.
# [3] Default component is main and may be omitted.
# [4] Section is optional.
# [5] Prefix is case insensitive
# [6] Everything else is case sensitive.
def
test
(
input
,
output
):
result
=
utils
.
extract_component_from_section
(
input
);
if
result
!=
output
:
fail
(
"%s -> %s [should have been %s]"
%
(
input
,
repr
(
result
),
repr
(
output
)));
def
main
():
# Err, whoops? should probably be "utils", "main"...
input
=
"main/utils"
;
output
=
(
"main/utils"
,
"main"
);
test
(
input
,
output
);
# Validate #3
input
=
"utils"
;
output
=
(
"utils"
,
"main"
);
test
(
input
,
output
);
input
=
"non-free/libs"
;
output
=
(
"non-free/libs"
,
"non-free"
);
test
(
input
,
output
);
input
=
"contrib/net"
;
output
=
(
"contrib/net"
,
"contrib"
);
test
(
input
,
output
);
# Validate #3 with a prefix
input
=
"non-US"
;
output
=
(
"non-US"
,
"non-US/main"
);
test
(
input
,
output
);
# Validate #4
input
=
"main"
;
output
=
(
"main"
,
"main"
);
test
(
input
,
output
);
input
=
"contrib"
;
output
=
(
"contrib"
,
"contrib"
);
test
(
input
,
output
);
input
=
"non-free"
;
output
=
(
"non-free"
,
"non-free"
);
test
(
input
,
output
);
# Validate #4 with a prefix
input
=
"non-US/main"
;
output
=
(
"non-US/main"
,
"non-US/main"
);
test
(
input
,
output
);
input
=
"non-US/contrib"
;
output
=
(
"non-US/contrib"
,
"non-US/contrib"
);
test
(
input
,
output
);
input
=
"non-US/non-free"
;
output
=
(
"non-US/non-free"
,
"non-US/non-free"
);
test
(
input
,
output
);
# Validate #5
input
=
"non-us"
;
output
=
(
"non-us"
,
"non-US/main"
);
test
(
input
,
output
);
input
=
"non-us/contrib"
;
output
=
(
"non-us/contrib"
,
"non-US/contrib"
);
test
(
input
,
output
);
# Validate #6 (section)
input
=
"utIls"
;
output
=
(
"utIls"
,
"main"
);
test
(
input
,
output
);
################################################################################
if
__name__
==
'__main__'
:
main
()
utils.py
浏览文件 @
daaee3bc
# Utility functions
# Copyright (C) 2000 James Troup <james@nocrew.org>
# $Id: utils.py,v 1.2
5 2001-06-01 00:17:45
troup Exp $
# $Id: utils.py,v 1.2
6 2001-06-10 16:35:03
troup Exp $
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
...
...
@@ -46,6 +46,15 @@ file_exists_exc = "Destination file exists";
send_mail_invalid_args_exc
=
"Both arguments are non-null."
;
sendmail_failed_exc
=
"Sendmail invocation failed"
;
# Valid components; used by extract_component_from_section() because
# it doesn't know about Conf from it's caller. FIXME
valid_components
=
{
"main"
:
""
,
"contrib"
:
""
,
"non-free"
:
""
};
######################################################################################
def
open_file
(
filename
,
mode
):
...
...
@@ -77,7 +86,9 @@ def str_isnum (s):
######################################################################################
# What a mess. FIXME
# Prefix and components hardcoded into this like a good'un; need to unhardcod at some
# stage. [FIXME]
def
extract_component_from_section
(
section
):
component
=
""
;
...
...
@@ -85,15 +96,23 @@ def extract_component_from_section(section):
component
=
string
.
split
(
section
,
'/'
)[
0
];
if
string
.
lower
(
component
)
==
"non-us"
and
string
.
count
(
section
,
'/'
)
>
0
:
s
=
string
.
split
(
section
,
'/'
)[
1
];
if
s
==
"main"
or
s
==
"non-free"
or
s
==
"contrib"
:
# Avoid e.g. non-US/libs
if
valid_components
.
has_key
(
s
)
:
# Avoid e.g. non-US/libs
component
=
string
.
split
(
section
,
'/'
)[
0
]
+
'/'
+
string
.
split
(
section
,
'/'
)[
1
];
if
string
.
lower
(
section
)
==
"non-us"
:
component
=
"non-US/main"
;
# non-US prefix is case insensitive
if
string
.
lower
(
component
)[:
6
]
==
"non-us"
:
component
=
"non-US"
+
component
[
6
:];
# Expand default component
if
component
==
""
:
component
=
"main"
;
elif
string
.
lower
(
component
)
==
"non-us"
:
if
valid_components
.
has_key
(
section
):
component
=
section
;
else
:
component
=
"main"
;
elif
component
==
"non-US"
:
component
=
"non-US/main"
;
return
(
section
,
component
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录