.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/advanced/scripts_to_executables.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code or to run this example in your browser via Binder .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_advanced_scripts_to_executables.py: ============================== 7.10 Scripts to executables ============================== .. GENERATED FROM PYTHON SOURCE LINES 6-33 .. code-block:: default import os import sys from collections import Counter def main(path, start:int=26): if not os.path.exists(path): print(f"{path} does not exist.") return stations = [file[start:] for file in os.listdir(path)] uniques = set(stations) # find duplicates in stations counts = Counter(stations) duplicates = {item:count for item, count in counts.items() if count > 1} if duplicates: print(f"Found {len(duplicates)} duplicates in {path}") for duplicate, count in duplicates.items(): print(f"{duplicate} found {count} times") print(f"There are {len(uniques)} unique files.") else: print(f"No duplicates found in {path}") .. GENERATED FROM PYTHON SOURCE LINES 34-42 .. code-block:: default if __name__ == "__main__": path = sys.argv[1] if len(sys.argv) > 1 else os.getcwd() start = int(sys.argv[2]) if len(sys.argv) > 2 else 0 main(path, start) .. rst-class:: sphx-glr-script-out .. code-block:: none No duplicates found in /home/docs/checkouts/readthedocs.org/user_builds/python-seekho/checkouts/latest/scripts/advanced .. GENERATED FROM PYTHON SOURCE LINES 43-44 pyinstaller --onefile scripts_to_executables.py .. GENERATED FROM PYTHON SOURCE LINES 46-47 dist/scripts_to_executables .. GENERATED FROM PYTHON SOURCE LINES 49-50 dist/scripts_to_executables /mnt/datawaha/hyex/atr/gscad_database/raw/BOMAustralia/zip_files .. GENERATED FROM PYTHON SOURCE LINES 52-52 dist/scripts_to_executables /mnt/datawaha/hyex/atr/gscad_database/raw/BOMAustralia/zip_files 26 .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.002 seconds) .. _sphx_glr_download_auto_examples_advanced_scripts_to_executables.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: binder-badge .. image:: images/binder_badge_logo.svg :target: https://mybinder.org/v2/gh/AtrCheema/python-seekho/master?urlpath=lab/tree/notebooks/auto_examples/advanced/scripts_to_executables.ipynb :alt: Launch binder :width: 150 px .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: scripts_to_executables.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: scripts_to_executables.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_