{"id":19989199,"url":"https://github.com/clamytoe/cylon","last_synced_at":"2025-06-10T10:07:52.676Z","repository":{"id":84639548,"uuid":"126501016","full_name":"clamytoe/Cylon","owner":"clamytoe","description":"Python object that allows you to access the next and previous items from a list.","archived":false,"fork":false,"pushed_at":"2018-05-14T19:04:32.000Z","size":38,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-12T11:50:04.954Z","etag":null,"topics":["next","object","previous","python3-6"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clamytoe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-23T15:02:24.000Z","updated_at":"2018-05-14T23:29:31.000Z","dependencies_parsed_at":"2023-07-20T20:30:23.194Z","dependency_job_id":null,"html_url":"https://github.com/clamytoe/Cylon","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clamytoe%2FCylon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clamytoe%2FCylon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clamytoe%2FCylon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clamytoe%2FCylon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clamytoe","download_url":"https://codeload.github.com/clamytoe/Cylon/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241430312,"owners_count":19961635,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["next","object","previous","python3-6"],"created_at":"2024-11-13T04:45:48.002Z","updated_at":"2025-03-01T21:48:19.972Z","avatar_url":"https://github.com/clamytoe.png","language":"Python","readme":"# Cylon\n\u003e Python object that allows you to access **next()** and **prev()** items from a list.\n\n![Python version][python-version]\n[![Build Status][travis-image]][travis-url]\n[![BCH compliance][bch-image]][bch-url]\n[![GitHub issues][issues-image]][issues-url]\n[![GitHub forks][fork-image]][fork-url]\n[![GitHub Stars][stars-image]][stars-url]\n[![License][license-image]][license-url]\n\nWhy **Cylon**? Well it was either that or KITT and Cylon just sounded cooler! For those of you not old enough, both Cylons and KITT had a light that moved left to right, just like you can access the items in this object.\n\nNormal *list()* operations are supported as well.\n\n## How to set it all up\nClone the project to your computer. Assuming you have a *Projects* folder:\n\n```bash\ncd Projects\ngit clone https://github.com/clamytoe/Cylon.git\ncd Cylon\npython setup.py install\n```\n\n## How to use\nAfter it has been installed, just use it like any other module. One thing to note is to make sure not to forget to import **prev** as well. It's not perfect, but until I can figure out how to do it without it, it'll have to be like this:\n\n```bash\n\u003e\u003e\u003e from cylon import Cylon, prev\n\u003e\u003e\u003e models = [\n...    'U-87 Cyber Combat Unit',\n...    'Civilian Cylon',\n...    'Cylon War-Era Centurion',\n...    'Cython',\n...    'Djerba Centurion',\n...    'Modern Centurion',\n...    'Inorganic Humanoids',\n...    'Cylon Spacecraft',\n...    'Cylon Hybrids',\n...    'Humanoid Cylons',\n...]\n\u003e\u003e\u003e cylon_models = Cylon(models)\n```\n\n### Accessing current item\n```bash\n\u003e\u003e\u003e cylon_models.current()\n'U-87 Cyber Combat Unit'\n```\nYou can also print the current item by simply printing the object:\n\n```bash\n\u003e\u003e\u003e print(cylon_models)\nU-87 Cyber Combat Unit\n```\n\n### Accessing next item\n```bash\n\u003e\u003e\u003e cylon_models.next()\n'Civilian Cylon'\n```\nTo move to the next one:\n```bash\n\u003e\u003e\u003e next(cylon_models)\n'Civilian Cylon'\n```\nNow if you check the current item:\n```bash\n\u003e\u003e\u003e cylon_models.current()\n'Civilian Cylon'\n```\n\n### Accessing prev item\nThis one works the same way:\n```bash\n\u003e\u003e\u003e cylon_models.current()\n'Civilian Cylon'\n\u003e\u003e\u003e cylon_models.prev()\n'U-87 Cyber Combat Unit'\n\u003e\u003e\u003e prev(cylon_models)\n'U-87 Cyber Combat Unit'\n\u003e\u003e\u003e cylon_models.current()\n'U-87 Cyber Combat Unit'\n```\nIf you happen to go past the beginning or end of the list, it simply wraps around:\n```bash\n\u003e\u003e\u003e prev(cylon_models)\n'Humanoid Cylons'\n```\n\n### Accessing nearby neighbors\nI was recently made aware that in the world of High Performance Computing (HPC) the concept of neighbors is called a \"stencil\". So that's what I called it. By default it will show the two items before and after the currently selected item.\n\n```bash\n\u003e\u003e\u003e cylon_models.stencil()\n['Cylon Spacecraft', 'Cylon Hybrids', 'Humanoid Cylons', 'U-87 Cyber Combat Unit', 'Civilian Cylon']\n```\nYou can also specify more neighbors as well:\n\n```bash\n\u003e\u003e\u003e cylon_models.stencil(7)\n['Cylon War-Era Centurion', 'Cython', 'Djerba Centurion', 'Modern Centurion', 'Inorganic Humanoids', 'Cylon Spacecraft', 'Cylon Hybrids', 'Humanoid Cylons', 'U-87 Cyber Combat Unit', 'Civilian Cylon', 'Cylon War-Era Centurion', 'Cython', 'Djerba Centurion', 'Modern Centurion', 'Inorganic Humanoids']\n```\n\n### For further features review help()\nHere's a snippet of what's available:\n\n```bash\nHelp on class Cylon in module cylon.cylon:\n\nclass Cylon(collections.abc.MutableSequence)\n |  Provides next() and prev() methods to a list object\n |  \n |  If you need to traverse your list object in either direction,\n |  then this is the module to use.\n |  \n |  Methods defined here:\n |  \n |  __delitem__(self, index)\n |      Remove the item at the index indicated\n |  \n |  __getitem__(self, index)\n |      Return the item at the index indicated\n |  \n |  __init__(self, items=[])\n |      Initialize object with the list of items that are passed to it\n |  \n |  __len__(self)\n |      Return the length of the object\n |  \n |  __next__(self)\n |      Return the next item in the object\n |  \n |  __prev__(self)\n |      Return the previous item in the object\n |  \n |  __repr__(self)\n |      Return repr(self).\n |  \n |  __setitem__(self, index, value)\n |      Set the value of the object at the specified index\n |  \n |  __str__(self)\n |      Return currently selected item\n |  \n |  current(self)\n |      Return the current item\n |  \n |  insert(self, index, value)\n |      Insert value/object at the given index\n |  \n |  next(self)\n |      Display the next item without changing current\n |  \n |  prev(self)\n |      Display the previous item without changing current\n |  \n |  stencil(self, count=2)\n |      Return a list with before and after neighbors of current item\n |      \n |      Count determines how many of each are displayed.\n |\n```\n\n[python-version]:https://img.shields.io/badge/python-3.6.4-brightgreen.svg\n[travis-image]:https://travis-ci.org/clamytoe/Cylon.svg?branch=master\n[travis-url]:https://travis-ci.org/clamytoe/Cylon\n[bch-image]:https://bettercodehub.com/edge/badge/clamytoe/Cylon?branch=master\n[bch-url]:https://bettercodehub.com/\n[issues-image]:https://img.shields.io/github/issues/clamytoe/Cylon.svg\n[issues-url]:https://github.com/clamytoe/Cylon/issues\n[fork-image]:https://img.shields.io/github/forks/clamytoe/Cylon.svg\n[fork-url]:https://github.com/clamytoe/Cylon/network\n[stars-image]:https://img.shields.io/github/stars/clamytoe/Cylon.svg\n[stars-url]:https://github.com/clamytoe/Cylon/stargazers\n[license-image]:https://img.shields.io/github/license/clamytoe/Cylon.svg\n[license-url]:https://github.com/clamytoe/Cylon/blob/master/LICENSE\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclamytoe%2Fcylon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclamytoe%2Fcylon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclamytoe%2Fcylon/lists"}