使用者:Japanbot
![]() | 此為機器人帳號,操作者為j87j8787(討論),屬合規附屬帳戶,以半自動或全自動方式協助用戶處理繁瑣而重複的工作。此機器人並未獲得社群批准運作,或其操作許可已被撤銷,是故不應進行大規模操作,亦請勿在缺乏操作者監察下運作,操作者及機器人用戶空間除外。 管理員︰若然此機器人進行大規模操作或相信在缺乏監察下運作,而且所編輯區域並非操作者或機器人用戶名字空間,請施予封禁。 |
# -*- coding: utf-8 -*- """ Script to create user files (user-config.py, user-fixes.py) """ __version__ = '$Id: generate_user_files.py 6869 2009-05-11 00:35:02Z cosoleto $' import os, sys, codecs, re base_dir = '' console_encoding = sys.stdout.encoding if console_encoding is None or sys.platform == 'cygwin': console_encoding = "iso-8859-1" def listchoice(clist = [], message = None, default = None): if not message: message = "Select" if default: message += " (default: %s)" % default message += ": " for n, i in enumerate(clist): print ("%d: %s" % (n + 1, i)) while True: choice = raw_input(message) if choice == '' and default: return default try: return clist[int(choice) - 1] except: print("Invalid response") return response def file_exists(filename): if os.path.exists(filename): print("'%s' already exists." % filename) return True return False def generate_township(): _fnc = os.path.join(base_dir, "township") if not file_exists(_fnc): fdata = codecs.open("data", "r", "utf-8") row=[] for str in fdata.readlines(): column=[] line=str.split() for field in line: column.append(field) row.append(column) for data in row: name=data[0] if name.find(u"乡")<>-1: level=u"乡" if name.find(u"镇")<>-1: level=u"镇" if name.find(u"街道")<>-1: level=u"街道" if data[1]<>"0": disam=' '+data[1] else: disam='' code=data[2] post='' num_villiage=data[3] villiage=data[4] county=data[5] f = codecs.open(_fnc, "a", "utf-8") f.write(u"""{{-start-}} '''%s%s''' {{Infobox Prefecture Japan | Name = %s | Symbol = | SymbolName = %s徽 | SymbolDescription = | Japanese = 県 | Hiragana = | Romanization = | Number = | Governor = | Capital = | Region = | Island = | TotalArea = | AreaRank = | PCWater = | PopDate = | Population = | PopRank = | Density = | Districts = | Municipalities = | ISOCode = | Flower = | Tree = | Bird = | Map = | Post = | Address = | Phone = | Website = |}} '''%s'''是[[日本]]的一個縣。 == 行政区划 == %s共辖%s,分别是: %s。 {{japan}} {{日本小作品}} [[Category:%s|*]] {{-stop-}} """ % (name, disam, name, county, level, code, post, name, county, level, name, num_villiage, villiage, county, county)) f.close() fdata.close() print("'%s' written." % _fnc) if __name__ == "__main__": generate_township()