Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python 的 ‎Scope.get_resource函数有问题 #112

Open
sixteen250 opened this issue May 28, 2024 · 0 comments
Open

python 的 ‎Scope.get_resource函数有问题 #112

sixteen250 opened this issue May 28, 2024 · 0 comments

Comments

@sixteen250
Copy link

sixteen250 commented May 28, 2024

    def get_resource(self):
        #省略
        for i in range(len(self.resource_prefix)):
            if not str(self.resource_prefix[i]).startswith('/'):
                self.resource_prefix[i] = '/' + self.resource_prefix[i]
                if self.service_type == 'cos':
                    resource.append("qcs::{service_type}:{region}:uid/{appid}:{bucket}{prefix}".format(service_type=self.service_type, region=self.region,
                                                                                        appid=appid, bucket=self.bucket,
                                                                                        prefix=self.resource_prefix[i]))
                elif self.service_type == 'ci':
                    resource.append("qcs::{service_type}:{region}:uid/{appid}:bucket/{bucket}{prefix}".format(service_type=self.service_type, region=self.region,
                                                                                                       appid=appid, bucket=self.bucket,
                                                                                                       prefix=self.resource_prefix[i]))

if self.service_type == 'cos': 应该是在 if not str(self.resource_prefix[i]).startswith('/'):外面的

不然的话第二次调用get_resource就是返回空列表了

scope = Scope('name/cos:PutObject', '11111-1119673638', 'ap-nanjing', ['test/test.txt', 'test/test2.txt'])
print(scope.get_resource())
print(scope.get_resource())

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant