|
25 | 25 | parser.add_argument("--branch", help="git branch (default='%s')" % default_branch, action="store", default=default_branch)
|
26 | 26 | parser.add_argument("--cache", help="location of previously downloaded repo", action="store", default="./cache")
|
27 | 27 | parser.add_argument("--input", help="YAML of potential repos", action="store", default="data/sources.yaml")
|
28 |
| -parser.add_argument("--output", help="output directory", action="store", default="./logos") |
| 28 | +parser.add_argument("--output", help="output directory", action="store", default="./local") |
29 | 29 | parser.add_argument("--nocleanup", help="do not erase temporary files", default=True, dest='cleanup', action="store_false")
|
| 30 | +parser.add_argument("--nocopy", help="do not copy files", action="store_false", default=True, dest='copy') |
| 31 | +parser.add_argument("--provider", help="only do specific provider", action="store", default="*", dest="provider") |
30 | 32 | parser.add_argument('repos', help='repos (all if none specified)', metavar='repos', nargs='*')
|
31 | 33 |
|
32 | 34 | args = parser.parse_args()
|
|
65 | 67 |
|
66 | 68 | repodata = repolist[repo_handle]
|
67 | 69 |
|
| 70 | + if args.provider != '*' and args.provider != repodata['provider']: |
| 71 | + sys.stdout.write("INFO: skipping %s (provider is %s, not %s)\n" % (repo_handle, repodata['provider'], args.provider)) |
| 72 | + continue |
| 73 | + |
68 | 74 | sys.stdout.write("OUTPUT: processing %s (%s)\n" % (repo_handle, repodata["repo"]))
|
69 | 75 |
|
70 | 76 | gitdir = os.path.join(cachedir, repo_handle)
|
|
171 | 177 |
|
172 | 178 | dstdir, dstname = os.path.split(dstpath)
|
173 | 179 |
|
174 |
| - pathlib.Path(dstdir).mkdir(parents=True, exist_ok=True) |
175 |
| - shutil.copyfile(srcpath, dstpath) |
| 180 | + if args.copy: |
| 181 | + pathlib.Path(dstdir).mkdir(parents=True, exist_ok=True) |
| 182 | + shutil.copyfile(srcpath, dstpath) |
| 183 | + |
| 184 | + if args.verbose: |
| 185 | + sys.stdout.write("DEBUG: repo %s copy from '%s' to '%s' (%s)\n" % (repo_handle, str(srcpath), dstpath, shortpath)) |
| 186 | + else: |
| 187 | + shortpath = "https://raw.githubusercontent.com/" + repodata["repo"] + "/" + repodata["branch"] + srcpath[len(gitdir):] |
176 | 188 |
|
177 |
| - if args.verbose: |
178 |
| - sys.stdout.write("DEBUG: repo %s copy from '%s' to '%s' (%s)\n" % (repo_handle, str(srcpath), dstpath, shortpath)) |
179 | 189 |
|
180 | 190 | images.append({
|
181 | 191 | 'name': name,
|
|
195 | 205 | 'data': repodata,
|
196 | 206 | 'handle': repo_handle,
|
197 | 207 | 'lastmodified': datetime.datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d %H:%M:%S'),
|
198 |
| - 'name': repodata['name'] if 'name' in repodata else repodata['repo'], |
| 208 | + 'name': repodata['name'] if 'name' in repodata else repo_handle, |
199 | 209 | 'provider': repodata['provider'],
|
200 | 210 | 'provider_icon': 'https://www.vectorlogo.zone/logos/' + repodata['provider'] + '/' + repodata['provider'] + '-icon.svg',
|
201 | 211 | 'url': giturl,
|
|
206 | 216 | if 'website' in repodata:
|
207 | 217 | data['website'] = repodata['website']
|
208 | 218 |
|
| 219 | + pathlib.Path(os.path.join(outputdir, repo_handle)).mkdir(parents=True, exist_ok=True) |
209 | 220 | outputpath = os.path.join(outputdir, repo_handle, "sourceData.json")
|
210 | 221 |
|
211 | 222 | outputfile = open(outputpath, 'w')
|
|
0 commit comments