Skip to content

Commit 9ecf395

Browse files
committed
Fix flake8 warnings
1 parent 74fbd38 commit 9ecf395

File tree

1 file changed

+11
-46
lines changed

1 file changed

+11
-46
lines changed

tools/download-s3.py

Lines changed: 11 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# p-confluent-kafka-python__bld-travis__plat-linux__tag-__sha-112130ce297656ea1c39e7c94c99286f95133a24__bid-271588764__/confluent_kafka-0.11.0-cp35-cp35m-manylinux1_x86_64.whl
2121

2222

23-
import sys
2423
import re
2524
import os
2625
import argparse
@@ -31,9 +30,8 @@
3130
dry_run = False
3231

3332

34-
3533
class Artifact (object):
36-
def __init__ (self, arts, path, info=None):
34+
def __init__(self, arts, path, info=None):
3735
self.path = path
3836
# Remove unexpanded AppVeyor $(..) tokens from filename
3937
self.fname = re.sub(r'\$\([^\)]+\)', '', os.path.basename(path))
@@ -42,13 +40,12 @@ def __init__ (self, arts, path, info=None):
4240
self.arts = arts
4341
arts.artifacts.append(self)
4442

45-
def __repr__ (self):
43+
def __repr__(self):
4644
return self.path
4745

48-
def download (self, dirpath):
46+
def download(self, dirpath):
4947
""" Download artifact from S3 and store in dirpath directory.
5048
If the artifact is already downloaded nothing is done. """
51-
dest = self.lpath
5249
if os.path.isfile(self.lpath) and os.path.getsize(self.lpath) > 0:
5350
return
5451
print('Downloading %s -> %s' % (self.path, self.lpath))
@@ -58,49 +55,17 @@ def download (self, dirpath):
5855

5956

6057
class Artifacts (object):
61-
def __init__ (self, gitref, dlpath):
58+
def __init__(self, gitref, dlpath):
6259
super(Artifacts, self).__init__()
6360
self.gitref = gitref
6461
self.artifacts = list()
6562
# Download directory
6663
self.dlpath = dlpath
6764
if not os.path.isdir(self.dlpath):
6865
if not dry_run:
69-
os.makedirs(self.dlpath, 0755)
70-
71-
def collect_single (self, path, folder):
72-
""" Collect single entry
73-
:param: path string: S3 or local path to file
74-
:param: folder string: S3 folder name
75-
"""
76-
folder = os.path.dirname(key.key)
77-
78-
rinfo = re.findall(r'(?P<tag>[^-]+)-(?P<val>.*?)__', folder)
79-
if rinfo is None or len(rinfo) == 0:
80-
# print('Incorrect folder/file name format for %s' % folder)
81-
return None
82-
83-
info = dict(rinfo)
84-
85-
# Ignore AppVeyor Debug builds
86-
if info.get('bldtype', '').lower() == 'debug':
87-
print('Ignoring debug artifact %s' % folder)
88-
return None
66+
os.makedirs(self.dlpath, 0o755)
8967

90-
tag = info.get('tag', None)
91-
if tag is not None and (len(tag) == 0 or tag.startswith('$(')):
92-
# AppVeyor doesn't substite $(APPVEYOR_REPO_TAG_NAME)
93-
# with an empty value when not set, it leaves that token
94-
# in the string - so translate that to no tag.
95-
tag = None
96-
97-
sha = info.get('sha', None)
98-
if (tag is not None and tag == self.gitref) or (sha is not None and sha.startswith(self.gitref)):
99-
return Artifact(self, path, info, lpath=lpath)
100-
101-
return None
102-
103-
def collect_single_s3 (self, path):
68+
def collect_single_s3(self, path):
10469
""" Collect single S3 artifact
10570
:param: path string: S3 path
10671
"""
@@ -136,8 +101,7 @@ def collect_single_s3 (self, path):
136101

137102
return None
138103

139-
140-
def collect_s3 (self):
104+
def collect_s3(self):
141105
""" Collect and download build-artifacts from S3 based on git reference """
142106
print('Collecting artifacts matching tag/sha %s from S3 bucket %s' % (self.gitref, s3_bucket))
143107
self.s3 = boto3.resource('s3')
@@ -149,7 +113,7 @@ def collect_s3 (self):
149113
for a in self.artifacts:
150114
a.download(self.dlpath)
151115

152-
def collect_local (self, path):
116+
def collect_local(self, path):
153117
""" Collect artifacts from a local directory possibly previously
154118
collected from s3 """
155119
for f in os.listdir(path):
@@ -159,12 +123,13 @@ def collect_local (self, path):
159123
Artifact(self, lpath)
160124

161125

162-
163126
if __name__ == '__main__':
164127

165128
parser = argparse.ArgumentParser()
166129
parser.add_argument("--no-s3", help="Don't collect from S3", action="store_true")
167-
parser.add_argument("--dry-run", help="Locate artifacts but don't actually download or do anything", action="store_true")
130+
parser.add_argument("--dry-run",
131+
help="Locate artifacts but don't actually download or do anything",
132+
action="store_true")
168133
parser.add_argument("--directory", help="Download directory (default: dl-<gitref>)", default=None)
169134
parser.add_argument("tag", help="Tag or git SHA to collect")
170135

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy