Calmcode - parse: parse

How the Parse string format works.

1 2 3 4 5

Let's take this list of urls.

githubs = [
    "https://github.com/koaning/justcharts/",
    "https://github.com/koaning/human-learn/",
    "https://github.com/r1chardj0n3s/parse/",
]

We're going to extract the owner and the reponame from each url and we'll use the parse library for this. First, we'll need to download parse. You can do that from the notebook via:

%pip install parse

If you'd like to download it from the terminal you can use:

python -m pip install parse

To fetch the properties from the urls we can now run:

from parse import parse

githubs = [
    "https://github.com/koaning/justcharts/",
    "https://github.com/koaning/human-learn/",
    "https://github.com/r1chardj0n3s/parse/",
]

[parse("https://github.com/{owner}/{repo}/", url).named for url in githubs]

The results will be:

[{'owner': 'koaning', 'repo': 'justcharts'},
{'owner': 'koaning', 'repo': 'human-learn'},
{'owner': 'r1chardj0n3s', 'repo': 'parse'}]