Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
Feishu-Bitable-Python-API/GET_VIEW_ID.py at main · BlueSkyXN/Feishu-Bitable-Python-API · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
BlueSkyXN
Feishu-Bitable-Python-API
Repository navigation
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
Feishu-Bitable-Python-API
/
GET_VIEW_ID.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
56 lines (44 loc) · 3.27 KB
main
Breadcrumbs
Feishu-Bitable-Python-API
/
GET_VIEW_ID.py
Copy path
Top
File metadata and controls
Code
Blame
56 lines (44 loc) · 3.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import
argparse
import
configparser
from
LIST_VIEWS
import
LIST_VIEWS
# 检索视图
# 此函数用于通过给定的名称获取视图的ID
def
GET_VIEW_ID
(
view_name
=
"默认视图"
,
app_token
=
None
,
user_access_token
=
None
,
page_size
=
None
,
page_token
=
None
,
config_file
=
None
):
if
config_file
is
None
or
not
config_file
.
strip
():
# 如果未提供配置文件路径,则使用默认的配置文件 'feishu-config.ini'
config_file
=
'feishu-config.ini'
config
=
configparser
.
ConfigParser
()
config
.
read
(
config_file
,
encoding
=
'utf-8'
)
if
not
app_token
:
app_token
=
config
.
get
(
'TOKEN'
,
'app_token'
)
if
not
user_access_token
:
user_access_token
=
config
.
get
(
'TOKEN'
,
'user_access_token'
)
if
not
page_size
:
page_size
=
config
.
get
(
'LIST_VIEWS'
,
'page_size'
,
fallback
=
100
)
if
not
page_token
:
page_token
=
config
.
get
(
'LIST_VIEWS'
,
'page_token'
,
fallback
=
None
)
response
=
LIST_VIEWS
(
app_token
,
user_access_token
,
page_size
,
page_token
,
config_file
)
# 调用LIST_VIEWS函数获取所有视图的信息
# 在返回的所有视图信息中,寻找名称匹配的视图
for
item
in
response
[
"data"
][
"items"
]:
if
item
[
"view_name"
]
==
view_name
:
# 如果找到了名称匹配的视图,返回其ID
return
item
[
"view_id"
]
return
"NONE"
# 如果没有找到名称匹配的视图,返回"NONE"
# 此函数用于解析命令行参数并调用GET_VIEW_ID函数
def
GET_VIEW_ID_CMD
():
parser
=
argparse
.
ArgumentParser
()
# 创建一个命令行参数解析对象
parser
.
add_argument
(
'-n'
,
'--name'
,
default
=
None
,
help
=
'视图的名字'
)
# 添加一个名为'-n'或'--name'的参数,用于指定要查询的视图的名称
parser
.
add_argument
(
'-i'
,
'--input'
,
default
=
None
,
help
=
'视图的名字'
)
# 添加一个名为'-i'或'--input'的参数,用于指定要查询的视图的名称
parser
.
add_argument
(
'--app_token'
,
help
=
'应用的 token'
)
# 添加一个名为'--app_token'的参数,用于传递应用的 token
parser
.
add_argument
(
'--user_access_token'
,
help
=
'用户的 access token'
)
# 添加一个名为'--user_access_token'的参数,用于传递用户的 access token
parser
.
add_argument
(
'--page_size'
,
type
=
int
,
help
=
'每页的大小'
)
# 添加一个名为'--page_size'的参数,用于传递每页的大小
parser
.
add_argument
(
'--page_token'
,
help
=
'分页标记'
)
# 添加一个名为'--page_token'的参数,用于传递分页标记
parser
.
add_argument
(
'--config_file'
,
help
=
'配置文件路径'
)
# 添加一个名为'--config_file'的参数,用于传递配置文件的路径
args
=
parser
.
parse_args
()
# 解析命令行参数
view_name
=
args
.
name
if
args
.
name
is
not
None
else
args
.
input
# 检查'-n/--name'和'-i/--input'参数,优先使用'-n/--name'
if
view_name
is
None
:
# 如果没有提供视图名称,则打印错误信息并退出
print
(
"错误:未提供视图名称,请使用'-n/--name'或'-i/--input'参数提供视图名称。"
)
return
view_id
=
GET_VIEW_ID
(
view_name
,
args
.
app_token
,
args
.
user_access_token
,
args
.
page_size
,
args
.
page_token
,
args
.
config_file
)
# 调用GET_VIEW_ID函数获取视图的ID
print
(
view_id
)
# 打印视图的ID
# 主函数
if
__name__
==
"__main__"
:
GET_VIEW_ID_CMD
()
# 调用GET_VIEW_ID_CMD函数
You can’t perform that action at this time.