{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "<bound method Path.absolute of WindowsPath('Excel/Mappe1.xlsx')>\nMappe1.xlsx\n.xlsx\nMappe1\n"
    }
   ],
   "source": [
    "from pathlib import PurePath\n",
    "\n",
    "filename = PurePath(\"Excel\\\\Mappe1.xlsx\")\n",
    "\n",
    "print(filename.absolute)\n",
    "print(filename.name)\n",
    "# prints \"raw_data.txt\"\n",
    "\n",
    "print(filename.suffix)\n",
    "# prints \"txt\"\n",
    "\n",
    "print(filename.stem)\n",
    "# prints \"raw_data\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "output_type": "error",
     "ename": "TypeError",
     "evalue": "This COM object can not automate the makepy process - please run makepy manually for this object",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mcom_error\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32mC:\\dev\\Python\\Python38-32\\lib\\site-packages\\win32com\\client\\gencache.py\u001b[0m in \u001b[0;36mEnsureDispatch\u001b[1;34m(prog_id, bForDemand)\u001b[0m\n\u001b[0;32m    529\u001b[0m                 \u001b[1;32mtry\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 530\u001b[1;33m                         \u001b[0mti\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdisp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_oleobj_\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mGetTypeInfo\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    531\u001b[0m                         \u001b[0mdisp_clsid\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mti\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mGetTypeAttr\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m[\u001b[0m\u001b[1;36m0\u001b[0m\u001b[1;33m]\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mcom_error\u001b[0m: (-2147467263, 'Nicht implementiert', None, None)",
      "\nDuring handling of the above exception, another exception occurred:\n",
      "\u001b[1;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[1;32m<ipython-input-4-45d6d54b965f>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mtr\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mwin32com\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mclient\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mgencache\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mEnsureDispatch\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"CognosTransformer.Application\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[1;32mC:\\dev\\Python\\Python38-32\\lib\\site-packages\\win32com\\client\\gencache.py\u001b[0m in \u001b[0;36mEnsureDispatch\u001b[1;34m(prog_id, bForDemand)\u001b[0m\n\u001b[0;32m    539\u001b[0m                         \u001b[0mdisp\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mdisp_class\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mdisp\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0m_oleobj_\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    540\u001b[0m                 \u001b[1;32mexcept\u001b[0m \u001b[0mpythoncom\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mcom_error\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 541\u001b[1;33m                         \u001b[1;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34m\"This COM object can not automate the makepy process - please run makepy manually for this object\"\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    542\u001b[0m         \u001b[1;32mreturn\u001b[0m \u001b[0mdisp\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    543\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n",
      "\u001b[1;31mTypeError\u001b[0m: This COM object can not automate the makepy process - please run makepy manually for this object"
     ]
    }
   ],
   "source": [
    "import win32com.client\n",
    "tr = win32com.client.gencache.EnsureDispatch(\"CognosTransformer.Application\")\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "output_type": "stream",
     "name": "stdout",
     "text": "Could not locate a type library matching 'C:\\Program Files (x86)\\Cognos\\cer5\\bin\\trnsfrmr.dll'\n"
    }
   ],
   "source": [
    "import sys\n",
    "from win32com.client import makepy\n",
    "\n",
    "outputFile = \"C:\\\\Projekte\\\\Python\\\\transformer_automation.py\"\n",
    "comTypeLibraryOrDLL = \"C:\\\\Program Files (x86)\\\\Cognos\\\\cer5\\\\bin\\\\transdll.dll\"\n",
    "sys.argv = [\"makepy\", \"-o\", outputFile, comTypeLibraryOrDLL]\n",
    "\n",
    "makepy.main ()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "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.8.2-final"
  },
  "orig_nbformat": 2,
  "kernelspec": {
   "name": "python38232bitbfe000d0e0804f0ba6fab56a16b38371",
   "display_name": "Python 3.8.2 32-bit"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}