用户: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()