Skip to content

Instantly share code, notes, and snippets.

Created Aug 2, 2020
What would you like to do?
#!/usr/bin/env python
import argparse
import subprocess
import os
import re
import json
def read_version(version):
ver = re.compile('Using\s([\w\_\-]+)\s\(([\d\.]+)\)')
versions = {}
for line in version.readlines():
s =
if s is not None:
versions[] =
return versions
def gather_jsons(versions, spec, specs_path):
spe = re.compile('Specs\/\w\/\w\/\w\/[\w\_\-]+\/([\d\.]+)\/[\w\_\-]+\.podspec\.json')
mapping = {}
for line in spec.readlines():
s =
if s is not None:
data = json.load(open(specs_path + '/' +
if == versions[data['name']]:
mapping[data['name']] = data
return mapping
def main():
parser = argparse.ArgumentParser(description="Pods Spec to Pods.WORKSPACE")
parser.add_argument('--specs', nargs=1)
parser.add_argument('--versions', nargs=1)
parser.add_argument('--specs-path', nargs=1)
args = parser.parse_args()
args.specs = args.specs[0]
args.specs_path = args.specs_path[0]
args.versions = args.versions[0]
with open(args.versions) as version:
versions = read_version(version)
with open(args.specs) as spec:
mapping = gather_jsons(versions, spec, args.specs_path)
for name, data in mapping.items():
source = data['source']
if 'git' in source:
http = source['git'][:-4] + '/archive/' + source['tag'] + '.zip'
http = source['http']
print("new_pod_repository(\n name = \"{}\",\n url = \"{}\"\n)\n".format(name, http))
if __name__ == "__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment