import sys
fn = sys.argv[1]
if sys.version_info.major == 2:
content = open(fn, "r").read().decode("utf-8-sig").encode("utf-8")
open(fn, "w").write(content)
else:
content = open(fn, mode='r', encoding='utf-8-sig').read()
open(fn, mode='w', encoding='utf-8').write(content)
wget http://osm.sbin.ru/osm_dump/RU-MOS.osm.pbf
osmium tags-filter RU-MOS.osm.pbf boundary=administrative -o boundaries.osm
ogr2ogr -f GeoJSON boundaries.geojson boundaries.osm multipolygons
ogr2ogr --config SHAPE_ENCODING UTF8 -skipfailures -f "ESRI Shapefile" output_dir boundaries.osm multipolygons