Manual:Pywikibot/user-config.py/ko
File:Git icon.svg | <translate> Wikimedia [[<tvar|1>Special:MyLanguage/Gerrit</>|Git repository]] has this file:</translate> user-config.py.sample |
<translate> Generate <tvar |
File:Pywikibot MW gear icon.svg |
매뉴얼:Pywikibot |
---|
|
· <span style="" title="<translate nowrap> Edit this template</translate>"><translate> e</translate> |
설정
어떤 프로그램을 돌리더라도, 그 전에 user-config.py
라는 이름을 가진 파일을 pywikibot
디렉터리에 만들어야 합니다.
두 가지 방법으로 만들 수 있습니다:
- 매뉴얼을 따라 파일을 만드세요. 최소 두세개의 항목을 추려내야 하며, 정확한 위치에 있으야 합니다.
generate_user_files.py
스크립트를 커맨드 쉘에서 python pwb.py generate_user_files.py를 입력하는 것으로 실행하세요. 이는 "마법사" 식의 파일을 만들게 도와줄 것이고, 그리고 딱 맞는 장소에 저장할 수 있게 도와줄 것입니다.
저장 장소
pywikibot은 특정 장소의 user-config
를 다음의 순서로 탐색합니다:
- Specified via the
-dir:
argument (for example:-dir:/foo/bar
)
- The content of the environment variable
PYWIKIBOT_DIR
- The current directory
- The directory in which the
pwb.py
file is
- The
.pywikibot
directory in the application data directory (Windows) or home directory (that directory gets automatically created)
(get_base_dir()
도 참고해주세요.)
Below are instructions for manually editing this file.
Open a text editor (e.g. Notepad in Windows) and save the text file as user-config.py
in the pywikibot
folder.
If your language uses non-ASCII characters, you should use a Unicode-aware editor such as Notepad++ and save your user-config with Unicode encoding without BOM marks. Don't forget to insert
# -*- coding: utf-8 -*-
as the first line.
Add the following lines to user-config.py
:
Code | Explanation |
---|---|
family = 'wikipedia'
mylang = 'en'
|
xx is the code for the language you are working on, for example 'en' is English.[1] Family is the project name.[2] |
usernames['wikipedia']['en'] = 'ExampleBot'
|
Your In this example, the user is working on English Wikipedia, and has created a bot account with the username "ExampleBot". [3] |
(Optional) authenticate['*.wikipedia.org'] = ('<consumer_key>','<consumer_secret>', '<access_key>', '<access_secret>')
This replaces password-based authentication with OAuth, which is more secure (especially for bots with shared ownership). See Pywikibot/OAuth on how to obtain the keys/secrets. | |
(Optional) usernames['wikipedia']['de'] = 'BeispielBot'
usernames['wikipedia']['en'] = 'ExampleBot'
usernames['wiktionary']['de'] = 'BeispielBot'
|
If you are working on more than one Wikimedia project, you can also add several usernames. |
(Optional, and rarely needed) console_encoding = 'utf-8'
textfile_encoding = 'unicode_escape'
|
If this is the encoding used by your system. Always try without first. |
(Optional) sort_ignore_case = True
|
Some scripts may use this for sorting, e.g. solve_disambiguation.py. Default is False. Capitalized titles will preceed uncapitalized ones if this key is False or omitted, and capitalization will be disregarded by sorting if True. |
(Optional) password_file = "user-password.py"
|
Define a password file. The lines of the file should be tuples in any of the following formats: (code, family, username, password)
(family, username, password)
(username, password)
For BotPasswords, refer to Pywikibot/BotPasswords. |
(Optional)user_agent_description = "Description <contact@email.com>"
|
A free-form string that can be user to describe specific bot/tool, provide contact information, etc. |
Now save user-config.py
again.
user-config.py examples
EksempelBot on no.wikipedia
mylang = 'no' usernames['wikipedia']['no'] = 'EksempelBot' console_encoding = 'utf-8' use_api_login = True
ExampleBot on Commons
mylang = 'commons' family = 'commons' usernames['commons']['commons'] = 'ExampleBot' console_encoding = 'utf-8' use_api_login = True
ExampleBot on Wikidata
mylang = 'wikidata' family = 'wikidata' usernames['wikidata']['wikidata'] = 'ExampleBot' console_encoding = 'utf-8' use_api_login = True
ExampleBot on Test wiki
mylang = 'test' family = 'test' usernames['test']['test'] = 'ExampleBot'
ExampleBot on Test2 wiki
mylang = 'test2' family = 'wikipedia' usernames['wikipedia']['test2'] = 'ExampleBot'
BeispielBot on de.wikipedia and de.wikibooks, with de.wikipedia as main wiki
mylang = 'de' usernames['wikipedia']['de'] = 'BeispielBot' usernames['wikibooks']['de'] = 'BeispielBot' console_encoding = 'utf-8' use_api_login = True
For non-Wikimedia wikis
- See main page Pywikibot/Use on third-party wikis
See also
- config.py (the source code of the module that loads and interpretes user-config.py)
Notes
- ↑ If you want to work with more than one language, choose the most common one. You can override this on the command line by using
-lang:zh
parameter. - ↑ Meta uses 'meta' for both language code and wiki family, Commons uses 'commons' for both, and Testwiki uses 'test' for both, the multilingual wikisource uses '-' for the language. You can override this on the command line by using
-family:wikibooks
. - ↑ Note that on Linux/Unix hosts username capitalization matters! While logging in may not be an issue, testing the log in or attempting to use a bot will not use the correct cookie file and may result in anonymous access to the API. This can cause problems for private wikis that do not allow anonymous access or use third party authentication. Default usernames for mediawiki and those pulled via LDAP or other third party authentication schemes will have an uppercase character for the first letter, thus 'user' becomes 'User'.
- <translate> If you need more help on setting up your Pywikibot visit the {{<tvar name="1">irc|pywikibot</tvar>|#pywikibot IRC channel}} or [[<tvar name="2">mail:pywikibot</tvar>|pywikibot@ mailing list]].</translate>