Skip to content

Instantly share code, notes, and snippets.

@muelli
Created January 22, 2018 23:10
Show Gist options
  • Save muelli/6bb1b43fed4c4b7ecb6f51bdd0c36868 to your computer and use it in GitHub Desktop.
Save muelli/6bb1b43fed4c4b7ecb6f51bdd0c36868 to your computer and use it in GitHub Desktop.
distrowatch to CSV extractor
#!/usr/bin/env python
import logging
import pulldistros
log = logging.getLogger(__name__)
def main():
distros = pulldistros.distros()
for distro in distros:
log.debug("Getting Distro %s", distro)
dinfo = pulldistros.distinfo(distro)
log.debug("%s: %r", distro, dinfo)
releases = dinfo['releases']
date_name = sorted(((value['Release Date'], key) for key, value in releases.items()))
first_release_date, first_release_name = map(lambda s: s.strip(), date_name[0])
last_release_date, last_release_name = map(lambda s: s.strip(), date_name[-1])
number_of_releases = len(date_name)
log.info('%s Home Page: %r', distro, dinfo['Home Page'])
url = dinfo['Home Page'].split()[0].replace('https://', 'http://').strip()
name = distro.strip()
popularity = dinfo['Popularity'].strip()
status = dinfo['Status'].strip()
origin = dinfo['Origin'].strip()
dwurl = "http://distrowatch.com/" + distro
s = ("%s ; %s; %s; %s; %s"
";%s; %s"
";%s"
";%s;%s"
";%s")
s %= (url, name, popularity, status, origin,
first_release_name, first_release_date,
number_of_releases,
last_release_date, last_release_name,
dwurl)
log.info("Printing now... %s", s)
assert '\n' not in url
assert '\n' not in s
print ("%s" % s)
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
print (main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment