{"id":18812179,"url":"https://github.com/drorspei/replacements","last_synced_at":"2026-01-11T18:30:13.539Z","repository":{"id":57461193,"uuid":"408944990","full_name":"drorspei/replacements","owner":"drorspei","description":"Replace strings with other strings","archived":false,"fork":false,"pushed_at":"2022-03-29T04:18:12.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-01-30T07:38:40.577Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/drorspei.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}},"created_at":"2021-09-21T19:12:43.000Z","updated_at":"2021-12-22T15:24:05.000Z","dependencies_parsed_at":"2022-09-17T04:31:04.352Z","dependency_job_id":null,"html_url":"https://github.com/drorspei/replacements","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/drorspei%2Freplacements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drorspei%2Freplacements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drorspei%2Freplacements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drorspei%2Freplacements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drorspei","download_url":"https://codeload.github.com/drorspei/replacements/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239748247,"owners_count":19690232,"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-07T23:30:21.270Z","updated_at":"2026-01-11T18:30:13.479Z","avatar_url":"https://github.com/drorspei.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# replacements\n\nThere is a single class of interest in this project: `Replacer`.\n\nIt is an object for replacing strings with other strings in json-like objects.\n\nThe initializer takes a list of _assignments_, each of which is a dictionary containing a `name`, a `type`, and optionally `args` and `kwargs`.\n\nThere are currently 6 implemented types:\n* `identity`: returns the argument passed to it.\n* `localfile`: passes the `args` and `kwargs` to `open` and then reads the file object. The mode is always 'r'.\n* `fsspec`: passes the `args` and `kwargs` to `fsspec.open`, opens that, and reads. The mode is always 'r'. Requires fsspec to be installed. fsspec has multiple protocols installed, e.g. http(s), (s)ftp and zip. This can also be used for data on S3, if s3fs is installed.\n* `awssecret`: takes two arguments: `region_name` and `secret_id`. Uses boto to call secretsmanager, and returns the returned `SecretString`.\n* `env`: takes two arguments: `name`, and optionally a `default` value. If the environment variable doesn't exist and no default value was passed, an AssertionError will be raised.\n* `base64uuid4`: the base64 (the url safe \"-_\" variant) of a `uuid.uuid4` call. Use this to create a unique id that can be used in multiple derived replacements.\n\nExample:\n\n```python\nReplacer([{\n    \"name\": \"name\",\n    \"type\": \"identity\",\n    \"args\": [\"World\"]\n}])(\"Hello, ${name}!\")\n```\n\nreturns \"Hello, World!\"\n\nThere can be dependencies between the assignments. They are resolved\nlinearly using the list order:\n\n```python\nReplacer([\n    {\n        \"name\": \"name\",\n        \"type\": \"identity\",\n        \"args\": [\"World\"]\n    },\n    {\n        \"name\": \"greeting\",\n        \"type\": \"identity\",\n        \"args\": [\"Hello, ${name}!\"]\n    }\n])(\"${greeting}\")\n```\n\nalso returns \"Hello, World!\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrorspei%2Freplacements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrorspei%2Freplacements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrorspei%2Freplacements/lists"}