---
type: "Source File"
title: "import re"
description: "import re app_path = \"/home/ben/infra/copecheck-cities/app.py\" with open(app_path, \"r\") as f: content = f.read() old = ''' \"us\": { \"name\": \"United States\", \"flag\": \"\\\\U0001f1fa\\\\U0001f1f8\", \"data_file\": \"us.json\"."
resource: "https://cities.copecheck.com"
tags: ["copecheck", "cities", "source-file", "py"]
timestamp: "2026-05-09T15:07:01Z"
site: "cities"
source_path: "copecheck-cities/patch_countries.py"
---

# import re

Source path: `copecheck-cities/patch_countries.py`  
Index snapshot generated: `2026-11-24T13:27:52Z`  
File modified: `2026-05-09T15:07:01Z`

```py
import re

app_path = "/home/ben/infra/copecheck-cities/app.py"
with open(app_path, "r") as f:
    content = f.read()

old = '''    "us": {
        "name": "United States",
        "flag": "\\U0001f1fa\\U0001f1f8",
        "data_file": "us.json",
        "description": "50 cities \\u2014 one per state \\u2014 ranked by AI displacement vulnerability, based on BLS workforce composition data and Frey & Osborne automation probabilities.",
    }
}'''

new = '''    "us": {
        "name": "United States",
        "flag": "\\U0001f1fa\\U0001f1f8",
        "data_file": "us.json",
        "description": "50 cities \\u2014 one per state \\u2014 ranked by AI displacement vulnerability, based on BLS workforce composition data and Frey & Osborne automation probabilities.",
    },
    "ie": {
        "name": "Ireland",
        "flag": "\\U0001f1ee\\U0001f1ea",
        "data_file": "ie.json",
        "description": "15 cities ranked by AI displacement vulnerability, based on CSO Census 2022 workforce data and Frey & Osborne automation probabilities.",
    },
    "ca": {
        "name": "Canada",
        "flag": "\\U0001f1e8\\U0001f1e6",
        "data_file": "ca.json",
        "description": "15 cities ranked by AI displacement vulnerability, based on Statistics Canada employment data and Frey & Osborne automation probabilities.",
    },
    "au": {
        "name": "Australia",
        "flag": "\\U0001f1e6\\U0001f1fa",
        "data_file": "au.json",
        "description": "15 cities ranked by AI displacement vulnerability, based on ABS 2021 Census workforce data and Frey & Osborne automation probabilities.",
    },
    "nz": {
        "name": "New Zealand",
        "flag": "\\U0001f1f3\\U0001f1ff",
        "data_file": "nz.json",
        "description": "13 cities ranked by AI displacement vulnerability, based on Stats NZ Census data and Frey & Osborne automation probabilities.",
    },
}'''

if old in content:
    content = content.replace(old, new)
    with open(app_path, "w") as f:
        f.write(content)
    print("OK: patched app.py with 4 new countries")
else:
    print("ERROR: could not find match")
    # Debug
    import sys
    lines = content.split('\n')
    for i, line in enumerate(lines):
        if 'United States' in line:
            print(f"Line {i}: {repr(line)}")
        if 'data_file' in line and 'us.json' in line:
            print(f"Line {i}: {repr(line)}")
```
