{"id":18624078,"url":"https://github.com/mitghi/pytile38","last_synced_at":"2025-10-03T14:32:58.034Z","repository":{"id":106909623,"uuid":"226375948","full_name":"mitghi/pytile38","owner":"mitghi","description":"Tile38 python client","archived":false,"fork":false,"pushed_at":"2023-03-03T15:38:53.000Z","size":12,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T09:01:51.452Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mitghi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2019-12-06T17:15:05.000Z","updated_at":"2024-11-25T05:53:47.000Z","dependencies_parsed_at":"2023-03-13T14:38:49.404Z","dependency_job_id":null,"html_url":"https://github.com/mitghi/pytile38","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/mitghi%2Fpytile38","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitghi%2Fpytile38/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitghi%2Fpytile38/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mitghi%2Fpytile38/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mitghi","download_url":"https://codeload.github.com/mitghi/pytile38/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248335512,"owners_count":21086604,"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":[],"created_at":"2024-11-07T04:27:17.072Z","updated_at":"2025-10-03T14:32:58.027Z","avatar_url":"https://github.com/mitghi.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytile38\n\nSimple python client for [Tile38](https://github.com/tidwall/tile38).\nCurrently, only a subset of commands are supported. However, you can manually add new commands by defining a scheme ( look at tile.py ).\n\nCommands are built from instance properties or keyword arguments, therefore each command only requires missing attributes. \n\n# Models\n\nEach model instance represents an entry in Tile38.\n\n```python\nclass Shop(TilePointBase):\n\tserializer = Serializer\n        identifier = Key(\"shop\")\n\t\n        id = Value(\"\")\n        lat = Value(0.0)\n        lon = Value(0.0)\n```\n\nSerializer is responsible for serializing/parsing data ( both for class methods and instance methods ).\n\n```python\nclass Serializer(object):\n\t@classmethod\n\tdef is_valid(cls, response):\n\t\tif response.result:\n\t\t\treturn True\n\t\treturn False\n\n\t@classmethod\n\tdef get(cls, instance=None, response=None, id=None, **kwargs):\n\t\tresult = response.result\n\t\tfields = result[1] if (isinstance(result, list) and len(result) \u003e 1) else None\n\t\tinstance = instance()\n\t\tlat, lon = 0.0, 0.0\n\t\tif response.kwargs.get(\"withfields\"):\n\t\t\tinstance.fields = [tuple(fields[i:i+2]) for i in range(0, len(fields), 2)]\n\t\t\tresult = result[0]\n\t\tif response.kwargs.get(\"type\") == \"point\":\n\t\t\tlon, lat = list(map(float, result))\t\t\t\n\t\telif response.kwargs.get(\"type\") == None:\n\t\t\tlon, lat = list(map(float, result.get(\"coordinates\")))\n\t\tinstance.lat = lat\n\t\tinstance.lon = lon\n\t\tinstance.id = id\n\n\t\treturn instance\n\n\t@classmethod\n\tdef ids(cls, response=None, **kwargs):\n\t\tdata = response.result[1]\n\t\tresult = []\n\t\tfor d in data:\n\t\t\tname, info = d[0:2]\n\t\t\tname = name\n\t\t\tresult.append(name)\n\n\t\treturn result\n\n\t@classmethod\n\tdef nearby(cls, response=None, **kwargs):\n\t\tdata = response.result[1]\n\t\tresult = []\n\t\tfor d in data:\n\t\t\tname, info = d[0:2]\n\t\t\tlat, lon = info.get(\"coordinates\")[::-1]\n\t\t\tcoordinates = {\"lat\": lat, \"long\": lon}\n\t\t\titem = {\"name\":name, \"coordinates\": coordinates}\n\t\t\tresult.append(item)\n\n\t\treturn result\n\n```\n\n# Example\n\n```python\nshop1 = Shop.create(lat=45.02695, lon=-77.431641, id=\"modula\")\nshop1.set(type=\"point\") # alternatively, you can add this property to Shop class\nshop2 = Shop.create(lat=43.516689, lon=-74.794922, id=\"bellissimo\", type=\"point\")\nshop2.set(type=\"point\")\n\nshop3 = Shop.create(lat=51.835778, \n                    lon=9.931641,\n                    id=\"metzgerei\",\n                    type=\"point\",\n                    fields=[('hat_gelesen', 0),('agb_seiten', 100), ('kunde_muss_nochmal_bestätigen', 1)])\nshop3.set(type=\"point\", ex=60) # set expiration\n\n\nshop4 = Shop.get(id=\"metzgerei\", withfields=True) # get point with associated fields\n\nshop4.fields\n\u003e\u003e\u003e [('agb_seiten', 100000000), ('kunde_muss_nochmal_bestätigen', 1), ('neu_dazukommende_agb_seiten', 19590713256714670000000), ('oh_neue_agb', 1), ('wird_im_x_tagen_gesendet', 3900)]\n\nshop4.lat = 33.33\nshop4.set(type=\"point\") # update this point with new data\ndict(shop4)\n\u003e\u003e\u003e {'lat': 33.33, 'lon': 9.931641, 'id': 'metzgerei'}\n\n# check ttl\nshop3.ttl().result\n\u003e\u003e\u003e 59\n\n# remove expiration\nshop3.persist().result \n\u003e\u003e\u003e True\n\nShop.ids()\n# \u003e\u003e\u003e ['modula', 'bellissimo'] \n```\n\n#### dependencies\n- [credis](https://github.com/yihuang/credis) ( requires Cython )\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitghi%2Fpytile38","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmitghi%2Fpytile38","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmitghi%2Fpytile38/lists"}