Skip to content

Instantly share code, notes, and snippets.

@mariusvniekerk
Created November 2, 2018 00:54
Show Gist options
  • Save mariusvniekerk/f1318d0ead834512071f55cfb13b2fd2 to your computer and use it in GitHub Desktop.
Save mariusvniekerk/f1318d0ead834512071f55cfb13b2fd2 to your computer and use it in GitHub Desktop.
Perform a search for a file on libcfgraph!
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import glob\n",
"import os\n",
"import json"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [],
"source": [
"from pandas.io import json"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# There is a crazy repo here\n",
"\n",
"### https://github.com/regro/libcfgraph\n",
"\n",
"We're going to use it to find which conda-forge package on `win-64` contains `'sed.exe'`"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Already up to date.\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"fatal: destination path '/home/jovyan/libcfgraph' already exists and is not an empty directory.\n"
]
}
],
"source": [
"%%bash\n",
"git clone https://github.com/regro/libcfgraph ~/libcfgraph\n",
"cd ~/libcfgraph\n",
"git pull"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"PLATFORM = 'win-64'\n",
"SUFFIX = '/sed.exe'"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [],
"source": [
"x = glob.glob(os.path.expanduser(f'~/libcfgraph/artifacts/*/*/{PLATFORM}/*.json'))"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: tqdm in /opt/conda/lib/python3.6/site-packages (4.28.1)\n",
"\u001b[33mYou are using pip version 18.0, however version 18.1 is available.\n",
"You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n"
]
}
],
"source": [
"!pip install tqdm"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"import tqdm"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [],
"source": [
"results = set()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
"def search_files(data, package, suffix, filename):\n",
" for fn in data['files']:\n",
" if fn.endswith(suffix):\n",
" results.add((package, filename))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 40685/40685 [00:08<00:00, 5071.51it/s]\n"
]
}
],
"source": [
"compiled_things = set()\n",
"migrated_things = set()\n",
"for metadata in tqdm.tqdm(x):\n",
" *_, package, channel, arch, fn = metadata.split(os.path.sep)\n",
" with open(metadata, 'r') as fo:\n",
" data = json.loads(fo.read())\n",
" search_files(data, package=package, filename=fn, suffix='/sed.exe')"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{('git', 'git-2.12.2-4.json'),\n",
" ('git', 'git-2.13.3-0.json'),\n",
" ('git', 'git-2.14.1-0.json'),\n",
" ('git', 'git-2.14.1-1.json'),\n",
" ('git', 'git-2.14.2-0.json'),\n",
" ('git', 'git-2.14.2-1.json'),\n",
" ('git', 'git-2.14.2-2.json'),\n",
" ('git', 'git-2.14.2-3.json'),\n",
" ('git', 'git-2.18.0-ha0abe07_1.json'),\n",
" ('git', 'git-2.19.0-h21ff451_0.json'),\n",
" ('git', 'git-2.19.1-h21ff451_0.json'),\n",
" ('git', 'git-2.19.1-h21ff451_1000.json'),\n",
" ('git', 'git-2.8.2-2.json'),\n",
" ('git', 'git-2.8.2-3.json'),\n",
" ('git', 'git-2.8.2-4.json')}"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"results"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment